Skip to main content

Withdrawing collateral from a multiply position after fully repaying debt allows you to unlock and retrieve your equity.

This operation uses buildWithdrawTxns (not getWithdrawWithLeverageIxs, which is for deleveraging by selling collateral to repay debt).

Multiply Withdraw with xStocks

Withdraw TSLAx collateral from a multiply position after all debt has been repaid.
1

Import Dependencies

Import the required packages for Solana RPC communication, Kamino SDK operations, and transaction building.
2

Load Configuration and Initialize Market

Load the keypair and initialize the xStocks market.
3

Find TSLAx Reserve

Dynamically discover the TSLAx token mint by searching the market reserves by symbol.
4

Configure Withdrawal Parameters

Set the amount of TSLAx collateral to withdraw.
TSLAx uses 8 decimals.
buildWithdrawTxns requires all debt to be repaid before withdrawing collateral. If you have outstanding debt, repay it first or use getWithdrawWithLeverageIxs to deleverage by selling collateral.
5

Fetch Existing Multiply Obligation

Create the multiply obligation type and fetch the existing position from the blockchain.
6

Build Withdrawal Transaction

Use KaminoAction.buildWithdrawTxns to generate the withdrawal instructions.
buildWithdrawTxns is used for withdrawing collateral when debt is fully repaid. For deleveraging (selling collateral to repay outstanding debt), use getWithdrawWithLeverageIxs instead.
7

Send Transaction

Get a fresh blockhash, build the transaction, sign it, and send it to the network.
The withdrawal is complete. Your TSLAx collateral has been transferred to your wallet.

Borrow and Multiply SDK Methods

Multiply operations use MultiplyObligation. Vanilla operations use VanillaObligation. The obligation type determines which PDA is derived for your position.