Withdrawing collateral from a multiply position unlocks your equity. With debt still open, the position must stay under its borrow limit.
This operation uses
buildWithdrawTxns: no swap and no debt repaid. To take value out of a position that still has debt while keeping its leverage, use getWithdrawWithLeverageIxs.Multiply Withdraw with xStocks
Withdraw TSLAx collateral from a multiply position after all debt has been repaid.1
Import Dependencies
2
Load Market and Initialize RPC
3
Load the Multiply Obligation
A Multiply position is its own obligation, addressed by the collateral and debt mints.4
Build Withdrawal Instructions
Withdraw TSLAx collateral from the Multiply position.TSLAx uses 8 decimals, so
1_250_000 is 0.0125 TSLAx. With debt still open, the withdrawal raises the position’s LTV and must keep it under the borrow limit. To withdraw all of it, pass new BN(U64_MAX) as the amount once the debt is repaid.5
Build the Transaction
6
Borrow and Multiply SDK Methods
Multiply operations use
MultiplyObligation. Vanilla operations use VanillaObligation. The obligation type determines which PDA is derived for your position.