The Jupiter Developer Platform is live. Previous portal users keep their rate limits for free until 30 June 2026 — set up billing on the new platform before then. See the Migration Guide for details.
Use this file to discover all available pages before exploring further.
Deposit and withdraw assets from Jupiter Earn vaults using Privy embedded wallets, allowing your users to earn yield without managing their own private keys.
Shared setup for both deposit and withdraw operations.
import { PrivyClient } from "@privy-io/node";import { Connection, PublicKey, TransactionMessage, VersionedTransaction,} from "@solana/web3.js";import BN from "bn.js";import { getDepositIxs, getWithdrawIxs } from "@jup-ag/lend/earn";const PRIVY_APP_ID = "put-your-privy-app-id-here";const PRIVY_APP_SECRET = "put-your-privy-app-secret-here";const RPC_ENDPOINT = "https://api.mainnet-beta.solana.com";const ASSET_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDCconst AUTH_KEY_ID = "put-your-auth-key-id-here"; // from Privy dashboard or REST APIconst AUTH_KEY_PRIVATE = "put-your-auth-key-private-here"; // P-256 private keyconst WALLET_ID = "put-your-wallet-id-here";const privy = new PrivyClient({ appId: PRIVY_APP_ID, appSecret: PRIVY_APP_SECRET,});const connection = new Connection(RPC_ENDPOINT);const wallet = await privy.wallets().get(WALLET_ID);if (!wallet) { throw new Error(`Wallet ${WALLET_ID} not found`);}const signer = new PublicKey(wallet.address);
Authorization keys: Generate a P-256 key pair via the Privy dashboard, generateP256KeyPair() from @privy-io/node, or OpenSSL. The dashboard/API returns a key ID (AUTH_KEY_ID) used to identify the key when configuring wallet ownership. The private key (AUTH_KEY_PRIVATE) is used in the authorization_context when signing transactions. See the Privy authorization keys docs for details.
const WITHDRAW_AMOUNT = new BN(10_000_000); // 10 USDC (6 decimals)const { ixs: withdrawIxs } = await getWithdrawIxs({ connection, signer, asset: new PublicKey(ASSET_MINT), amount: WITHDRAW_AMOUNT,});if (!withdrawIxs?.length) { throw new Error("No withdraw instructions returned by Jupiter Lend SDK");}
Withdraw full position
To withdraw the entire balance instead of a fixed amount, use the Read SDK to fetch the position:
import { Client } from "@jup-ag/lend-read";const readClient = new Client(connection);const position = await readClient.lending.getUserPosition( new PublicKey(ASSET_MINT), signer);if (position.underlyingAssets.isZero()) { throw new Error("No Earn position to withdraw");}const WITHDRAW_AMOUNT = position.underlyingAssets;
This requires @jup-ag/lend-read: npm install @jup-ag/lend-read