Hello,
I will appreciate help regarding the problem I have with this endpoint on Margin account:
POST /sapi/v1/margin/order
The issue is that POST will not completely repay all borrowed+interest asset in spite of positive netAsset balance. Example:
STATUS before POST
"asset": "AVAX",
"free": "0.03518132",
"locked": "0",
"borrowed": "2.67772132",
"interest": "0.00004144",
"netAsset": "-2.64258144"
POST (/sapi/v1/margin/order) symbol=AVAXUSDT&side=BUY&type=MARKET&quantity=2.65&sideEffectType=AUTO_REPAY×tamp=1715052885689 (notice AUTO REPAY!!!)
RESPONSE PAYLOAD
"symbol": "AVAXUSDT",
"orderId": XXX,
"clientOrderId": "XXX",
"transactTime": 1715052885880,
"price": "0",
"origQty": "2.65",
"executedQty": "2.65",
"cummulativeQuoteQty": "97.361",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "BUY",
"fills": [
{
"price": "36.74",
"qty": "2.65",
"commission": "0.00265",
"commissionAsset": "AVAX",
"tradeId": XXX
}
],
"isIsolated": false,
"selfTradePreventionMode": "EXPIRE_MAKER"
STATUS PAYLOAD (there is(was) enough of free AVAX to repay * but it was not repaid completely !!!)
"asset": "AVAX",
"free": "0.03518132",
"locked": "0",
"borrowed": "0.03041276",
"interest": "0",
"netAsset": "0.00476856"
POST to /sapi/v1/margin/borrow-repay after that, specifying the amount to be repaid (borrowed + insterest), will repay all debts as it is supposed to.
Question is does sideEffectType=AUTO_REPAY work as intended or am I feeding it with the wrong data? I have calculated the amount I need to buy (borrowed+interest+fee and lot size filter). In the example above that is 2.65.
Fall back to simple 2 stage BUY + REPAY seems more convenient.
JFTR, I am trying all this on sub account.
Cheers!