Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tripolskypetr/wallet-manager/llms.txt
Use this file to discover all available pages before exploring further.
commitCancel is the full position exit function. It implements the correct “cancel then sell” sequence that avoids the common broker-adapter mistake of selling while funds are still frozen in pending orders. On spot, every resting order locks its base coin (for a SELL) or USDT (for a BUY) — placing a new sell on top of that lock either fails with an insufficient-balance error or silently trades only the unlocked remainder. commitCancel eliminates this problem by first cancelling everything, verifying the book is clean, and only then selling the full free balance.
Signature
Parameters
Binance trading pair symbol to flatten, e.g.
"SOLUSDT". All open orders on this symbol will be cancelled and the entire free coin balance will be sold.Return value
Promise<number> — average exit price from the sell order’s fills array. Returns 0 if the free coin balance (after subtracting the maker fee and minQty dust) is at or below minQty — nothing to sell.
Execution flow
Cancel all open orders
Iterates up to 10 rounds. Each round calls
binance.openOrders(symbol) and attempts binance.cancel(symbol, orderId) for every live order, with a 1-second sleep between individual cancels. Individual cancel errors are caught and tolerated — the sweep loop continues to the next order and retries on the next round. The loop exits early once openOrders returns an empty list. Throws only if the final round still has errors.Verify zero open orders
After the cancel sweep, a second loop polls
binance.openOrders(symbol) up to 10 times (1-second sleep each). If any order remains after all 10 attempts, throws Error("Order not canceled"). This hard verification prevents the sell step from running while any order might still be locking funds.Sell entire free coin balance
Fetches the full balance map via If
FETCH_BALANCE_FN. Reads the minQty and maker fee for the symbol. Computes the sellable quantity:quantity <= minQty, returns 0 (dust only — nothing to sell).Otherwise, formats the quantity to LOT_SIZE stepSize and places a LIMIT SELL at averagePrice × 0.999 (formatted to PRICE_FILTER tickSize). Polls up to 10 × 10s. On timeout: cancels the limit and market-sells the remaining unfilled quantity via binance.marketSell().Audit log
After completion,WalletPublicService emits: