How to understand futures cross collateral repay

Q: these endpoints are related to futures cross collateral borrow and repay, how to understand and how to borrow and repay by different endpoints

POST /sapi/v1/futures/loan/borrow

POST /sapi/v1/futures/loan/repay
POST /sapi/v1/futures/loan/collateralRepay 

A: Let’s say Alice has assets in the futures account:

BTC: 1

then she wish to borrow USDT for futures trading.

  1. From this endpoint, POST /sapi/v1/futures/loan/borrow, she sent a request to borrow USDT, then there will be USDT in the account, but also some BTC is locked.

  2. Time to repay

    • Alice has enough USDT in account.

      • Call POST /sapi/v1/futures/loan/repay to pay with USDT from the balance, the BTC will be released.
      • Call POST /sapi/v1/futures/loan/collateralRepay to pay USDT by BTC. If Alice wish to keep USDT, but sell BTC, this is the endpoint to go with.
    • Alice don’t have enough USDT in the account.

      • Call POST /sapi/v1/futures/loan/collateralRepay to pay USDT by BTC, the quoted amount of BTC is sold for the repay.

To repay by this POST /sapi/v1/futures/loan/collateralRepay endpoint, it’s required to get a quote first, which can be done from here:

GET /sapi/v1/futures/loan/collateralRepay

For more details about futures collateral endpoints, please find from our API document.