> ## Documentation Index
> Fetch the complete documentation index at: https://dev.jup.ag/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Jupiter Lend Overview

> Jupiter's lending protocol for earning yield on deposits and borrowing against collateral.

The Jupiter Lend API and SDK give you access to Earn (deposit-and-earn) and Borrow (collateralised borrowing) on Solana.

Deposit into Earn vaults to earn yield, or use assets as collateral in Borrow markets to take out loans. The SDK and API provide deposits, withdrawals, borrows, and repayments as ready-made transactions or as raw instructions for CPI and custom flows.

***

## Integrate Jupiter Earn / Borrow

<CardGroup cols={2}>
  <Card icon="code" href="https://www.npmjs.com/package/@jup-ag/lend" title="TypeScript SDK">
    Compose on-chain flows for Jupiter Earn and Borrow. The SDK returns raw instructions so you can build transactions, sign, send, or use them in CPI and custom flows.
  </Card>

  <Card icon="globe" href="/api-reference/lend/earn" title="REST API">
    REST API for Earn: deposit, withdraw, mint, and redeem as unsigned base64 transactions or as raw instructions; read endpoints for vault tokens, user positions, and earnings. Borrow API coming soon.
  </Card>
</CardGroup>

## Jupiter Lend Products

<CardGroup cols={2}>
  <Card icon="chart-line" href="/lend/earn" title="Jupiter Earn vaults">
    Deposit assets into Jupiter Earn vaults and generate yield.
  </Card>

  <Card icon="coins" href="/lend/borrow" title="Borrow markets">
    Borrow assets against collateral in Jupiter markets.
  </Card>
</CardGroup>

## Advanced Integration

<CardGroup cols={3}>
  <Card icon="bolt" href="/lend/flashloan" title="Flashloans">
    Borrow and repay within a single transaction with zero fees and no collateral.
  </Card>

  <Card icon="layer-group" href="/lend/advanced" title="Advanced Recipes">
    Multiply, unwind, vault swap, and other composite flows using flashloans.
  </Card>

  <Card icon="link" href="/lend/earn/cpi" title="CPI Integration">
    Call Jupiter Lend directly from your on-chain Solana program.
  </Card>
</CardGroup>

## Getting Started

Set up your development environment:

<Steps>
  <Step iconType="regular" titleSize="h2" title="Install Dependencies">
    Add the Jupiter Lend TypeScript SDK and Solana web3.js to your dependencies.

    ```shellscript theme={null}
    npm i @jup-ag/lend @solana/web3.js
    ```

    <Note>
      Jupiter Lend SDK is built on top of **@solana/web3.js** for RPC communication and transaction construction.
    </Note>
  </Step>

  <Step iconType="regular" titleSize="h2" title="Setup the RPC">
    ```typescript theme={null}
    import { Connection } from "@solana/web3.js";

    const connection = new Connection(
      "https://api.mainnet-beta.solana.com",
      {
        commitment: "confirmed",
      }
    );
    ```

    <Note>
      Public RPC endpoints are rate-limited and not recommended for production use.

      Use a dedicated RPC provider such as [Helius](https://www.helius.dev), [Triton](https://triton.one), or [Alchemy](https://www.alchemy.com/solana) for improved reliability and performance.
    </Note>
  </Step>

  <Step iconType="regular" titleSize="h2" title="Create or Import Wallet">
    Choose a method to create or import a wallet for signing transactions.

    <Note>
      Alternatively, create a wallet using a browser wallet provider like [Jupiter Wallet](https://chromewebstore.google.com/detail/jupiter-wallet/iledlaeogohbilgbfhmbgkgmpplbfboh)
    </Note>

    <Accordion title="Create Wallet with Solana CLI">
      Use the Solana CLI to generate a new keypair file.

      ```shellscript theme={null}
      solana-keygen new -o wallet.json
      ```
    </Accordion>

    <Accordion title="Generate Keypair Programmatically">
      Generate a new keypair programmatically using the Solana web3.js.

      ```typescript theme={null}
      import { Keypair } from "@solana/web3.js";

      const keypair = Keypair.generate();
      console.log("Public Key:", keypair.publicKey.toBase58());
      ```
    </Accordion>

    <Accordion title="Load Wallet from Local Keypair File">
      Import a wallet from an existing keypair file.

      ```typescript theme={null}
      import { Keypair } from "@solana/web3.js";
      import fs from "fs";
      import path from "path";

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

      const userKeypair = loadKeypair("/path/to/wallet.json");
      console.log("Public Key:", userKeypair.publicKey.toBase58());
      ```
    </Accordion>

    <Accordion title="Import Private Key">
      Import a private key exported from a browser wallet (base58-encoded string).

      ```typescript theme={null}
      import { Keypair } from "@solana/web3.js";
      import bs58 from "bs58";

      const privateKey = "YOUR_BASE58_PRIVATE_KEY"; // exported from your browser wallet
      const userKeypair = Keypair.fromSecretKey(bs58.decode(privateKey));
      console.log("Public Key:", userKeypair.publicKey.toBase58());
      ```
    </Accordion>

    <Danger>
      Never expose or commit private keys to version control. Use secure key management in production environments.
    </Danger>
  </Step>
</Steps>
