Skip to main content
Deposit assets into Jupiter Earn vaults using the SDK.
The SDK generates transaction instructions that you can add to your own transaction flow.

Getting Started

Import the required packages for Solana RPC and Jupiter Earn SDK operations.
1

Import Dependencies

Import the packages you need for Solana RPC and Jupiter Lend (Earn) SDK operations.
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
import BN from "bn.js";
import { getDepositIxs, getMintIxs } from "@jup-ag/lend/earn";
2

Build Instructions

Use the Jupiter Earn SDK to generate deposit instructions.
const connection = new Connection("https://api.mainnet-beta.solana.com");
const signer = new PublicKey("YOUR_WALLET_ADDRESS");

const { ixs: depositIxs } = await getDepositIxs({
    connection,
    signer,
    asset: new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // USDC Mint
    amount: new BN(10_000_000), // 10 USDC (6 decimals)
  });

console.log('Deposit Instructions:', depositIxs);
Important
  • amount = underlying asset amount being deposited (e.g. USDC)
  • Not vault shares
  • To deposit by specifying the number of vault shares to receive, use getMintIxs

Complete Flow

This example builds, signs, and sends a deposit transaction.
1

Import Dependencies

Import the packages you need for Solana RPC and Jupiter Lend (Earn) SDK operations.
import {
 Connection,
 Keypair,
 PublicKey,
 Transaction,
 sendAndConfirmTransaction,
} from "@solana/web3.js";
import BN from "bn.js";
import { getDepositIxs } from "@jup-ag/lend/earn";
import fs from "fs";
import path from "path";
2

Set up connection and deposit parameters

Set your RPC, signer, asset mint, and deposit amount.
const RPC_URL = "https://api.mainnet-beta.solana.com";
const userKeypair = Keypair.generate(); // <-- Replace this with your wallet
const ASSET_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const DEPOSIT_AMOUNT = new BN(10_000_000);
If your signer is stored as a local JSON keypair file, you can load it using the helper function below.
function loadKeypair(keypairPath: string): Keypair {
  const fullPath = path.resolve(keypairPath);
  const secret = JSON.parse(fs.readFileSync(fullPath, "utf8"));
  return Keypair.fromSecretKey(new Uint8Array(secret));
}
Then initialise your signer:
const userKeypair = loadKeypair("/path/to/your/keypair.json");
3

Build Deposit Instructions

Build a transaction from the deposit instructions, set blockhash and fee payer, then sign with the user keypair and send the transaction.
const { ixs: depositIxs } = await getDepositIxs({
    connection,
    signer,
    asset: ASSET_MINT,
    amount: DEPOSIT_AMOUNT,
});
4

Build and send transaction

Build a transaction from the deposit instructions, set blockhash and fee payer, then sign with the user keypair and send the transaction.
const latestBlockhash = await connection.getLatestBlockhash();
const transaction = new Transaction({
    feePayer: signer,
    ...latestBlockhash,
});
transaction.add(...depositIxs);

const signature = await sendAndConfirmTransaction(connection, transaction, [userKeypair]);
console.log("Deposit successful! Signature:", signature);
You have successfully deposited your assets into Jupiter Earn Vaults. Your assets are now earning yield.

Full code example

import {
    Connection,
    Keypair,
    PublicKey,
    Transaction,
    sendAndConfirmTransaction,
} from "@solana/web3.js";
import BN from "bn.js";
import { getDepositIxs } from "@jup-ag/lend/earn";
import fs from "fs";
import path from "path";


const KEYPAIR_PATH = "/path/to/your/keypair.json"; // Path to your local keypair file (update this path)
const ASSET_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // Asset mint to deposit (USDC for example)
const DEPOSIT_AMOUNT = new BN(10_000_000); // Amount to deposit, in smallest units (e.g., 1 USDC = 1_000_000)
const RPC_URL = "https://api.mainnet-beta.solana.com"; // RPC endpoint

function loadKeypair(keypairPath: string): Keypair {
    const fullPath = path.resolve(keypairPath);
    const secret = JSON.parse(fs.readFileSync(fullPath, "utf8"));
    return Keypair.fromSecretKey(new Uint8Array(secret));
}

// 1. Load user keypair and establish connection
const userKeypair = loadKeypair(KEYPAIR_PATH);
const connection = new Connection(RPC_URL, { commitment: "confirmed" });
const signer = userKeypair.publicKey;

// 2. Get deposit instructions from SDK
const { ixs: depositIxs } = await getDepositIxs({
    connection,
    signer,
    asset: ASSET_MINT,
    amount: DEPOSIT_AMOUNT,
});

if (!depositIxs?.length) {
    throw new Error("No deposit instructions returned by Jupiter Lend SDK.");
}

// 3. Build the transaction with latest blockhash and add deposit instructions
// This prepares the transaction ready to be signed and sent
const latestBlockhash = await connection.getLatestBlockhash();
const transaction = new Transaction({
    feePayer: signer,
    ...latestBlockhash,
});
transaction.add(...depositIxs);
transaction.sign(userKeypair);

// 4. Sign and send the transaction
const signature = await sendAndConfirmTransaction(connection, transaction, [userKeypair]);
console.log("Deposit successful! Signature:", signature);