diff --git a/.env.local.example b/.env.local.example index a572ed9126..cff2c05989 100644 --- a/.env.local.example +++ b/.env.local.example @@ -2,7 +2,7 @@ # # QUICK START: # 1. cp .env.local.example .env -# 2. docker-compose up -d +# 2. docker compose up -d # 3. npm run setup # # That's it! The setup script will: diff --git a/README.md b/README.md index f33e4ce46d..86d9c5d972 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ npm install cp .env.local.example .env # 3. Start database -docker-compose up -d +docker compose up -d # 4. Run setup (generates seeds, starts API, registers admin) npm run setup @@ -251,10 +251,10 @@ Seed data is stored in `migration/seed/` and can be customized as needed. ### Docker Commands ```bash -docker-compose up -d # Start database -docker-compose logs db-init # Check if database was created -docker-compose down # Stop database -docker-compose down -v # Stop and delete data +docker compose up -d # Start database +docker compose logs db-init # Check if database was created +docker compose down # Stop database +docker compose down -v # Stop and delete data docker logs dfx-mssql # View database logs ``` diff --git a/scripts/setup.sh b/scripts/setup.sh index 08bf88e798..156a6764e2 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -76,12 +76,12 @@ fi # Start database echo "" echo "🗄️ Starting database..." -docker-compose up -d +docker compose up -d # Wait for database initialization echo "⏳ Waiting for database initialization..." for i in {1..30}; do - if docker-compose logs db-init 2>&1 | grep -q "Database 'dfx' ready"; then + if docker compose logs db-init 2>&1 | grep -q "Database 'dfx' ready"; then echo "✅ Database ready" break fi diff --git a/src/subdomains/core/liquidity-management/adapters/actions/binance.adapter.ts b/src/subdomains/core/liquidity-management/adapters/actions/binance.adapter.ts index 02726136ae..d01d5964eb 100644 --- a/src/subdomains/core/liquidity-management/adapters/actions/binance.adapter.ts +++ b/src/subdomains/core/liquidity-management/adapters/actions/binance.adapter.ts @@ -58,38 +58,28 @@ export class BinanceAdapter extends CcxtExchangeAdapter { const network = this.exchangeService.mapNetwork(Blockchain.LIGHTNING) || undefined; const balance = await this.exchangeService.getAvailableBalance(asset); - const withdrawalFee = await this.exchangeService.getWithdrawalFee(asset, network); - - const amount = Util.floor( - Math.min(order.maxAmount, balance - withdrawalFee, BINANCE_LIGHTNING_MAX_WITHDRAWAL_BTC), - 8, - ); + const amount = Util.floor(Math.min(order.maxAmount, balance * 0.99, BINANCE_LIGHTNING_MAX_WITHDRAWAL_BTC), 8); if (amount <= 0) throw new OrderNotProcessableException( `${this.exchangeService.name}: not enough balance for ${asset} (balance: ${balance}, min. requested: ${order.minAmount}, max. requested: ${order.maxAmount})`, ); + const amountSats = LightningHelper.btcToSat(amount); - // Generate invoice via LnBits for the target amount (excluding fee) + // Generate invoice via LnBits for the target amount const invoice = await this.lightningClient.getLnBitsWalletPayment({ amount: amountSats, memo: `LM Order ${order.id}`, expirySec: 1800, // 30 min (Binance limit) }); - order.inputAmount = amount + withdrawalFee; + order.inputAmount = amount; order.inputAsset = asset; order.outputAsset = asset; - // Send invoice to Binance - amount must be invoice_amount + withdrawal_fee - const response = await this.exchangeService.withdrawFunds( - asset, - amount + withdrawalFee, - invoice.pr, - undefined, - network, - ); + // Send only the invoice amount — Binance deducts the fee from the balance separately + const response = await this.exchangeService.withdrawFunds(asset, amount, invoice.pr, undefined, network); return response.id; }