Skip to main content

Withdraw

Redeem a position to receive a proportional share of the underlying assets, including accrued fees and rewards.
1

Import Dependencies

Import the required packages for Solana RPC communication, Kamino SDK operations, address lookup table fetching, and Kit transaction building.
2

Configure Constants and Initialize Kamino

Set the keypair path, RPC endpoints, and target strategy. Load the signer and initialize the Kamino client.
3

Load Strategy State

Fetch the strategy account so the SDK has the current state and token mints.
4

Resolve User Token Accounts

Compute the user’s associated token accounts for shares, Token A, and Token B. Build creation instructions for any that don’t already exist.
5

Build Withdraw All Shares Instructions

Call withdrawAllShares to build the withdraw bundle, then compose the full instruction list with a compute unit limit, ATA creations, prerequisites, the withdraw, and the optional shares ATA close.
6

Resolve Address Lookup Tables

Collect every account referenced by the withdraw instructions, fetch the minimal LUT set from the Kamino API, then load each LUT account.
The strategy’s own LUT is intentionally excluded — for this strategy it contains stale entries that cause AccountOwnedByWrongProgram. The minimal LUT set from Kamino’s API is sufficient.
7

Build, Sign, and Send Transaction

Compose the v0 transaction with LUT compression, sign, verify it fits the size limit, then send and confirm.
The withdrawal is complete. Token A and Token B have been transferred to your ATAs.

Full Code Example