Skip to main content
Withdraw liquidity or collateral from the reserve. The SDK handles transaction building, instruction creation, and collateral release calculations.

Withdraw for Lending

Withdraw liquidity from the reserve.
1

Import Dependencies

2

Load Market and Initialize RPC

3

Build Redeem Instructions

Redeem all of the wallet’s USDC reserve cTokens for USDC, principal plus the interest they earned.
The amount is in cTokens, not USDC, so this reads the wallet’s cToken balance and redeems all of it.
4

Build the Transaction

5

Sign and Send

The withdrawal is complete. The cTokens are redeemed and the USDC is back in the wallet.

Withdraw for Borrowing

Withdraw collateral from an obligation.
1

Import Dependencies

2

Load Market and Initialize RPC

3

Load the Obligation

Load the wallet’s borrow position so the SDK refreshes every reserve it uses.
4

Build Withdraw Instructions

Withdraw USDC collateral from the borrow position.
With open borrows, the withdrawal must keep the position under its borrow limit. To withdraw all of a deposit, pass new BN(U64_MAX) as the amount (U64_MAX is exported by the SDK).
5

Build the Transaction

6

Sign and Send

The withdrawal is complete. The collateral is back in the wallet.
  1. The collateral amount is removed from your obligation
  2. Your borrowing capacity decreases
  3. Your loan-to-value (LTV) ratio increases