### Setup Kamino Lending SDK Examples Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Installs dependencies and sets the RPC endpoint for running the examples. ```bash cd klend-sdk/examples yarn install export RPC_ENDPOINT=YOUR_RPC_URL_HERE ``` -------------------------------- ### Kvault SDK Setup Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/kvault-examples/README.md Install dependencies and set environment variables for RPC endpoint and keypair file before running Kvault examples. ```bash cd klend-sdk/examples yarn install export RPC_ENDPOINT=YOUR_RPC_URL_HERE export KEYPAIR_FILE=YOUR_KEYPAIR_FILE_HERE ``` -------------------------------- ### Get Oracle Metadata Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Example demonstrating how to fetch and log the oracle metadata, showing the provider and name for each source. ```typescript const metadata = await reserve.getOracleMetadata(); metadata.forEach(([provider, name]) => { console.log(`${provider}: ${name}`); }); ``` -------------------------------- ### Install Kamino Lending SDK Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Install the Kamino Lending SDK using npm or yarn. ```shell # npm npm install @kamino-finance/klend-sdk # yarn yarn add @kamino-finance/klend-sdk ``` -------------------------------- ### Running Kvault Examples Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/kvault-examples/README.md Execute Kvault examples using `yarn ts-node` by specifying the example file path. ```bash cd klend-sdk/examples yarn ts-node kvault/.ts ``` -------------------------------- ### Install Klend SDK Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/00-INDEX.md Install the Klend SDK using npm. This is the first step before using any SDK functionalities. ```bash npm install @kamino-finance/klend-sdk ``` -------------------------------- ### Install Required Dependencies Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/08-quickstart-and-patterns.md Install the core dependencies required by the SDK, including Solana web3.js, decimal.js, and Anchor. ```bash npm install @solana/kit @solana/web3.js decimal.js bn.js npm install @coral-xyz/anchor @coral-xyz/borsh ``` -------------------------------- ### Install Kamino Manager CLI Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Clone the repository, navigate to the directory, and install dependencies using yarn. Ensure yarn is installed beforehand. ```shell git clone git@github.com:Kamino-Finance/klend-sdk.git cd klend-sdk yarn ``` -------------------------------- ### Run Reserve Supply and Borrow Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to get the total supplied and borrowed amounts for a reserve. ```bash yarn run reserve-supply-borrow ``` -------------------------------- ### Install Kamino SDK with npm Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Installs the Kamino SDK using npm within your project directory. ```shell # npm npm install @kamino-finance/klend-sdk ``` -------------------------------- ### Install Kamino SDK with yarn Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Installs the Kamino SDK using yarn within your project directory. ```shell # yarn yarn add @kamino-finance/klend-sdk ``` -------------------------------- ### Run Loan LTV Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to retrieve the Loan-to-Value ratio for a loan. ```bash yarn run loan-ltv ``` -------------------------------- ### Run Market Reserves Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to retrieve a list of all available market reserves. ```bash yarn run market-reserves ``` -------------------------------- ### Initialize KaminoReserve from Address Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Example demonstrating how to load and initialize a KaminoReserve instance using its address and retrieve its token symbol and deposit APY. ```typescript import { KaminoReserve, address } from '@kamino-finance/klend-sdk'; const usdcReserve = await KaminoReserve.initializeFromAddress( address('EPzP1QwUfW8yy5gVDJKQDCwVY8Sm5z8zLVZvh1RG6Qo5'), rpc, 400 ); console.log(`Reserve: ${usdcReserve.getTokenSymbol()}`); console.log(`Deposit APY: ${usdcReserve.getDepositAPY().toString()}%`); ``` -------------------------------- ### Run User Loans Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to fetch all loans associated with a specific user. ```bash yarn run user-loans ``` -------------------------------- ### Run Reserve Caps Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to fetch the supply and borrow caps for a reserve. ```bash yarn run reserve-caps ``` -------------------------------- ### Run Reserve APY Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to fetch the current supply, borrow, and rewards APY for a reserve. ```bash yarn run reserve-apy ``` -------------------------------- ### Run Reserve Rewards APY Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to specifically fetch the rewards APY for a reserve. ```bash yarn run reserve-rewards-apy ``` -------------------------------- ### Run Reserve APY History Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to retrieve the historical APY data for a reserve. ```bash yarn run reserve-apy-history ``` -------------------------------- ### Run Loan Info Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a Typescript script to fetch detailed loan information, including deposits and borrows. ```bash yarn tsx-node ./example_loan_info.ts ``` -------------------------------- ### Run Loan Value Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to calculate the deposited, borrowed, and net value of a loan. ```bash yarn run loan-value ``` -------------------------------- ### Instantiate and Derive PDA for VanillaObligation Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/05-types.md Example of how to create a VanillaObligation instance and derive its Program Derived Address (PDA). ```typescript const obligation = new VanillaObligation(programId); const pda = await obligation.toPda(marketAddress, userAddress); ``` -------------------------------- ### Simple Deposit Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/02-KaminoAction.md Builds and sends transactions for a simple deposit action. This is a common pattern for adding funds to a lending market. ```typescript const action = await KaminoAction.buildDepositTxns( market, new BN('5000000'), // USDC amount with decimals usdcMint, new VanillaObligation(), userSigner ); const txns = action.buildTransactions(); await sendTransactions(txns, wallet); ``` -------------------------------- ### Log Transaction Instructions Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/09-errors-and-validation.md Logs the labels for setup, lending, and cleanup instructions generated by KaminoAction, and the total number of transactions built. ```typescript const action = await KaminoAction.buildDepositTxns(...); console.log('Setup Instructions:', action.setupIxsLabels); console.log('Lending Instructions:', action.lendingIxsLabels); console.log('Cleanup Instructions:', action.cleanupIxsLabels); const txns = action.buildTransactions(); console.log(`Total transactions: ${txns.length}`); ``` -------------------------------- ### Error Handling Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/02-KaminoAction.md Demonstrates how to catch and handle errors thrown by KaminoAction during transaction building, specifically checking for reserve-related issues. ```typescript try { const action = await KaminoAction.buildBorrowTxns( market, new BN('1000000'), unknownMint, obligation, userSigner ); } catch (error) { if (error.message.includes('Reserve')) { console.error('Token not available in this market'); } } ``` -------------------------------- ### Deposit and Borrow (Leverage) Example Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/02-KaminoAction.md Builds transactions for a leveraged position, involving both depositing one asset and borrowing another. This pattern is used to increase potential returns. ```typescript const action = await KaminoAction.buildDepositAndBorrowTxns( market, new BN('10000000'), // Deposit 10 USDC usdcMint, new BN('5000000'), // Borrow 5 SOL solMint, new LeverageObligation(usdcMint, solMint), userSigner ); ``` -------------------------------- ### Decimal Type Conversions Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/05-types.md Examples of converting strings, numbers, Fractions, and BN values to the Decimal type for precise calculations. ```typescript import Decimal from 'decimal.js'; // String to Decimal const amount = new Decimal('1000.5'); // Number to Decimal (note: precision loss possible) const amount2 = new Decimal(1000.5); // Fraction to Decimal const fraction = new Fraction(value); const decimal = fraction.toDecimal(); // BN to Decimal const bn = new BN('1000000000'); const decimal2 = new Decimal(bn.toString()); ``` -------------------------------- ### Calculate and Build Deposit with Leverage Swap Inputs Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/08-quickstart-and-patterns.md This example shows how to calculate the necessary inputs for a leveraged deposit, including swap details. It requires DEX quoter and specific leverage parameters. ```typescript import { getDepositWithLeverageSwapInputs, buildDepositWithLeverageIxs, LeverageObligation } from '@kamino-finance/klend-sdk'; import Decimal from 'decimal.js'; // Calculate leverage amounts const { swapInputs, initialInputs } = await getDepositWithLeverageSwapInputs({ owner: userSigner, kaminoMarket: market, debtTokenMint: solMint, collTokenMint: usdcMint, depositAmount: new Decimal('10000'), priceDebtToColl: new Decimal('24'), slippagePct: new Decimal('1'), targetLeverage: new Decimal('3'), quoter: jupiterQuoter, // Your DEX quoter }); // Get swap instructions from Jupiter/Orca/etc const swapIxs = await getSwapInstructions(swapInputs); // Build all instructions const leverageIxs = await buildDepositWithLeverageIxs( market, solReserve, usdcReserve, userSigner, new LeverageObligation(usdcMint, solMint, market.programId), none(), currentSlot, false, undefined, initialInputs, undefined, [{ preActionIxs: [], swapIxs: swapIxs, lookupTables: [], quote: { priceAInB: new Decimal('24'), quoteResponse: quote } }] ); ``` -------------------------------- ### Get Raw Instructions Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/02-KaminoAction.md Retrieves the underlying instructions for a KaminoAction without building full transactions. Use this if you need to manually construct or modify transactions. ```typescript buildIxns(): Instruction[] ``` -------------------------------- ### Get Interest Rate Trends Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/08-quickstart-and-patterns.md Iterate through market reserves to log deposit APY, borrow APY, and calculate the spread for each token. ```typescript const reserves = market.getReserves(); reserves.forEach((reserve) => { console.log(`${reserve.getTokenSymbol()}:`); console.log(` Deposit APY: ${reserve.getDepositAPY().toString()}%`); console.log(` Borrow APY: ${reserve.getBorrowAPY().toString()}%`); const spread = reserve.getBorrowAPY().minus(reserve.getDepositAPY()); console.log(` Spread: ${spread.toString()}%`); }); ``` -------------------------------- ### Get Multiply/Leverage Loan Info and PNL Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to retrieve loan information and Profit and Loss (PNL) for leveraged positions. ```bash yarn multiply-loan-info-and-pnl ``` -------------------------------- ### Download Lending Market and Reserves Configuration Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Downloads the configuration for a lending market along with all associated reserve configurations. Use the staging flag for staging environments. ```bash yarn kamino-manager download-lending-market-config-and-all-reserves-configs --lending-market lending_market_address --staging ``` -------------------------------- ### Get Oracle Mappings CLI Command Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Retrieves scope oracle mappings, which are necessary for configuring the reserve oracle configuration. ```bash yarn kamino-manager get-oracle-mappings ``` -------------------------------- ### Get Obligation Statistics Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/03-KaminoObligation.md Retrieves comprehensive statistics for an obligation, including deposit and borrow totals, LTV, and health factors. Use this to get a full overview of an obligation's financial state. ```typescript getStats(): ObligationStats ``` ```typescript { userTotalDeposit: Decimal; userTotalCollateralDeposit: Decimal; userTotalLiquidatableDeposit: Decimal; userTotalBorrow: Decimal; userTotalBorrowBorrowFactorAdjusted: Decimal; borrowLimit: Decimal; borrowLiquidationLimit: Decimal; borrowUtilization: Decimal; netAccountValue: Decimal; loanToValue: Decimal; liquidationLtv: Decimal; leverage: Decimal; potentialElevationGroupUpdate: number; } ``` ```typescript const stats = obligation.getStats(); console.log(`LTV: ${stats.loanToValue.toString()}`); console.log(`Liquidation threshold: ${stats.liquidationLtv.toString()}`); console.log(`Health: ${stats.borrowUtilization.toString()}`); ``` -------------------------------- ### getBorrowRewardYield Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Gets reward yield for borrows. ```APIDOC ## getBorrowRewardYield ### Description Gets reward yield for borrows. ### Method N/A (SDK Method) ### Endpoint N/A (SDK Method) ### Parameters #### Query Parameters - **farmState** (FarmState) - Optional - State of the farm. ### Returns `Promise` - Reward yield information. ``` -------------------------------- ### getDepositRewardYield Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Gets reward yield for deposits. ```APIDOC ## getDepositRewardYield ### Description Gets reward yield for deposits. ### Method N/A (SDK Method) ### Endpoint N/A (SDK Method) ### Parameters #### Query Parameters - **farmState** (FarmState) - Optional - State of the farm. ### Returns `Promise` - Reward yield information. ``` -------------------------------- ### getFarmInfo Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Gets farming information for the reserve. ```APIDOC ## getFarmInfo ### Description Gets farming information for the reserve. ### Method N/A (SDK Method) ### Endpoint N/A (SDK Method) ### Returns `ReserveFarmInfo` - Farm configuration and reward data. ``` -------------------------------- ### getAllObligationsByBorrowedReserve Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Gets all obligations that have borrows in a specific reserve. ```APIDOC ## getAllObligationsByBorrowedReserve ### Description Gets all obligations that have borrows in a specific reserve. ### Method GET (assumed) ### Endpoint /obligations/borrowed-reserve/{reserve} ### Parameters #### Path Parameters - **reserve** (Address) - Required - The reserve address. ### Response #### Success Response (200) - **KaminoObligation[]** - Array of obligations with borrows in the specified reserve. ### Response Example ```json [ { "address": "string", "owner": "string", "market": "string", "borrowedAmount": "string", "depositedAmount": "string", "borrowedTokens": [ { "mint": "string", "amount": "string" } ], "depositedTokens": [ { "mint": "string", "amount": "string" } ], "unborrowedAmount": "string", "undepositedAmount": "string", "unborrowedTokens": [ { "mint": "string", "amount": "string" } ], "undepositedTokens": [ { "mint": "string", "amount": "string" } ], "leverage": "string", "tag": "number" } ] ``` ``` -------------------------------- ### getAllObligationsByDepositedReserve Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Gets all obligations that have deposits in a specific reserve. ```APIDOC ## getAllObligationsByDepositedReserve ### Description Gets all obligations that have deposits in a specific reserve. ### Method GET (assumed) ### Endpoint /obligations/deposited-reserve/{reserve} ### Parameters #### Path Parameters - **reserve** (Address) - Required - The reserve address. ### Response #### Success Response (200) - **KaminoObligation[]** - Array of obligations with deposits in the specified reserve. ### Response Example ```json [ { "address": "string", "owner": "string", "market": "string", "borrowedAmount": "string", "depositedAmount": "string", "borrowedTokens": [ { "mint": "string", "amount": "string" } ], "depositedTokens": [ { "mint": "string", "amount": "string" } ], "unborrowedAmount": "string", "undepositedAmount": "string", "unborrowedTokens": [ { "mint": "string", "amount": "string" } ], "undepositedTokens": [ { "mint": "string", "amount": "string" } ], "leverage": "string", "tag": "number" } ] ``` ``` -------------------------------- ### Download Lending Market Configuration Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Downloads the configuration for a given lending market. The staging flag can be used to target staging environments. ```bash yarn kamino-manager download-lending-market-config --lending-market lending_market_address --staging ``` -------------------------------- ### getAllObligationsByTag Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Gets all obligations with a specific tag and market address. ```APIDOC ## getAllObligationsByTag ### Description Gets all obligations with a specific tag and market address. ### Method GET (assumed) ### Endpoint /markets/{market}/obligations/tag/{tag} ### Parameters #### Path Parameters - **tag** (number) - Required - The tag to filter obligations by. - **market** (Address) - Required - The market address. ### Response #### Success Response (200) - **KaminoObligation[]** - Array of obligations with the specified tag. ### Response Example ```json [ { "address": "string", "owner": "string", "market": "string", "borrowedAmount": "string", "depositedAmount": "string", "borrowedTokens": [ { "mint": "string", "amount": "string" } ], "depositedTokens": [ { "mint": "string", "amount": "string" } ], "unborrowedAmount": "string", "undepositedAmount": "string", "unborrowedTokens": [ { "mint": "string", "amount": "string" } ], "undepositedTokens": [ { "mint": "string", "amount": "string" } ], "leverage": "string", "tag": "number" } ] ``` ``` -------------------------------- ### getCollateralMintSupply Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Gets the total supply of collateral tokens from the token mint. ```APIDOC ## getCollateralMintSupply ### Description Gets the total supply of collateral tokens from the token mint. ### Method N/A (SDK Method) ### Endpoint N/A (SDK Method) ### Returns `Promise` - The total supply of collateral tokens. ``` -------------------------------- ### getProgramId Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Gets the program ID for a specified environment (mainnet-beta or staging). ```APIDOC ## getProgramId ### Description Gets the program ID for a specified environment (mainnet-beta or staging). ### Method function ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **env** ('mainnet-beta' | 'staging') - Optional - The environment for which to retrieve the program ID. ### Response #### Success Response (200) - **programId** (Address) - Program ID for the environment. #### Response Example (Address, example not provided in source) ``` -------------------------------- ### Address Handling with @solana/kit Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/05-types.md Demonstrates how to create an Address object from a string and convert it back to a string using the address utility. ```typescript import { address } from '@solana/kit'; // Create Address from string const mint = address('EPzP1QwUfW8yy5gVDJKQDCwVY8Sm5z8zLVZvh1RG6Qo5'); // Get string from Address const mintString = mint.toString(); ``` -------------------------------- ### getRewardInfoForFarm Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Gets reward information for a specific farm, optionally filtered by obligation address. ```APIDOC ## getRewardInfoForFarm ### Description Gets reward information for a specific farm, optionally filtered by obligation address. ### Method GET (assumed) ### Endpoint /farms/{farmAddress}/rewards ### Parameters #### Path Parameters - **farmAddress** (Address) - Required - The address of the farm. #### Query Parameters - **obligationAddress** (Address) - Optional - The address of the obligation. ### Response #### Success Response (200) - **RewardInfo** - Object containing reward details. ### Response Example ```json { "pendingRewards": "100.50", "totalRewardsClaimed": "5000.00" } ``` ``` -------------------------------- ### Deposit Multiply/Leverage Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a script for depositing collateral in a leveraged position. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE yarn multiply-deposit ``` -------------------------------- ### getAllObligationsForMarket Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Gets all active obligations in the market. Optionally filters by obligation type tag. ```APIDOC ## getAllObligationsForMarket ### Description Gets all active obligations in the market. Optionally filters by obligation type tag. ### Method GET (assumed) ### Endpoint /obligations ### Parameters #### Query Parameters - **tag** (number) - Optional - Obligation type tag to filter ### Response #### Success Response (200) - **KaminoObligation[]** - Array of all obligations. ### Response Example ```json [ { "address": "string", "owner": "string", "market": "string", "borrowedAmount": "string", "depositedAmount": "string", "borrowedTokens": [ { "mint": "string", "amount": "string" } ], "depositedTokens": [ { "mint": "string", "amount": "string" } ], "unborrowedAmount": "string", "undepositedAmount": "string", "unborrowedTokens": [ { "mint": "string", "amount": "string" } ], "undepositedTokens": [ { "mint": "string", "amount": "string" } ], "leverage": "string", "tag": "number" } ] ``` ``` -------------------------------- ### Get Kamino Market Name Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Retrieves the human-readable name of the Kamino market, such as 'Main'. ```typescript getName(): string ``` -------------------------------- ### Simulate Swap Collateral Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a Typescript script to simulate swapping collateral from one token to another. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE tsx example_swap_coll_simulation.ts ``` -------------------------------- ### Get All Reserves in Kamino Market Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Returns an array containing all `KaminoReserve` objects associated with this market. ```typescript getReserves(): Array ``` -------------------------------- ### Borrow Tokens from Single Reserve Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a script to borrow tokens from a single reserve. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE yarn run borrow-tokens ``` -------------------------------- ### Get Kamino Market Address Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Retrieves the public key address of the Kamino market account. ```typescript getAddress(): Address ``` -------------------------------- ### Get Program ID for Environment Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Retrieves the program ID for a specified environment (mainnet-beta or staging). ```typescript function getProgramId(env?: 'mainnet-beta' | 'staging'): Address ``` -------------------------------- ### buildIxns Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/02-KaminoAction.md Retrieves the underlying Solana instructions that constitute the action, without constructing full transactions. This is useful when you need to manually assemble or inspect the instructions. ```APIDOC ## buildIxns ### Description Gets the underlying instructions without building full transactions. ### Method Signature ```typescript buildIxns(): Instruction[] ``` ### Returns `Instruction[]` - Array of all instructions organized in this action. ``` -------------------------------- ### Create a New Kamino Market Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Use the CLI to create a new lending market. The mode can be 'inspect', 'simulate', 'execute', or 'multisig'. The 'staging' flag uses staging programs. ```shell yarn kamino-manager create-market --staging --mode execute ``` -------------------------------- ### Load Market and Get User Obligation Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/00-INDEX.md Demonstrates how to load a KaminoMarket instance and retrieve a user's obligation data. Requires RPC connection, market address, and a wallet address. ```typescript const market = await KaminoMarket.load(rpc, marketAddress, 400); const obligation = await market.getObligationByWallet( userAddress, new VanillaObligation() ); ``` -------------------------------- ### Kamino Manager CLI Environment Variables Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Configure the .env file with necessary program IDs and admin/RPC settings. Replace placeholder values with your own. ```dotenv ADMIN="admin.json" RPC="https://rpc.cluster" KLEND_PROGRAM_ID_MAINNET="KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD" KVAULT_PROGRAM_ID_MAINNET="KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd" KLEND_PROGRAM_ID_STAGING="SLendK7ySfcEzyaFqy93gDnD3RtrpXJcnRwb6zFHJSh" KVAULT_PROGRAM_ID_STAGING="stKvQfwRsQiKnLtMNVLHKS3exFJmZFsgfzBPWHECUYK" ``` -------------------------------- ### getMaxAndLiquidationLtvAndBorrowFactorForPair Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Gets the maximum LTV, liquidation LTV, and borrow factor parameters for a collateral/debt token pair. ```APIDOC ## getMaxAndLiquidationLtvAndBorrowFactorForPair ### Description Gets the maximum LTV, liquidation LTV, and borrow factor parameters for a collateral/debt token pair. ### Method GET (assumed) ### Endpoint /parameters/{collTokenMint}/{debtTokenMint} ### Parameters #### Path Parameters - **collTokenMint** (Address) - Required - Mint address of the collateral token. - **debtTokenMint** (Address) - Required - Mint address of the debt token. ### Response #### Success Response (200) - **maxLtv** (number) - Maximum LTV ratio (0-1). - **liquidationLtv** (number) - Liquidation threshold (0-1). - **borrowFactor** (number) - Borrow factor multiplier. ### Response Example ```json { "maxLtv": 0.9, "liquidationLtv": 0.95, "borrowFactor": 1.1 } ``` ``` -------------------------------- ### Get Obligations Based on Reserve Filter Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Executes a script to fetch obligations filtered by a specific reserve. ```bash yarn run get-obligations-based-on-reserve-filter ``` -------------------------------- ### Build and Send Repay Loan Transactions Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/08-quickstart-and-patterns.md This snippet demonstrates how to construct and send transactions for repaying a loan. It requires the market, repayment amount, token mint, and user signer. ```typescript const repayAction = await KaminoAction.buildRepayTxns( market, new BN('500000000'), // Repay 0.5 SOL solMint, new VanillaObligation(), userSigner ); const repayTxns = repayAction.buildTransactions(); await sendTransactions(repayTxns, wallet); ``` -------------------------------- ### CLI: Print All Reserve Accounts Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Print raw account data JSONs for all reserves. Use `yarn -s` to skip metadata and pipe to `jq` for processing. ```shell yarn cli print-all-reserve-accounts --rpc ``` ```shell yarn -s cli print-all-reserve-accounts --rpc | jq '.lastUpdate.slot' ``` -------------------------------- ### CLI: Print All Lending Market Accounts Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Print raw account data JSONs for all lending markets. Use `yarn -s` to skip metadata and pipe to `jq` for processing. ```shell yarn cli print-all-lending-market-accounts --rpc ``` ```shell yarn -s cli print-all-lending-market-accounts --rpc | jq '.autodeleverageEnabled' ``` -------------------------------- ### Get Elevation Group Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Retrieves the state of an elevation group by its ID. This is used for managing risk parameters and configurations. ```typescript getElevationGroup(elevationGroup: number): ElevationGroupDescription ``` -------------------------------- ### Get Accumulated Referrer Fees Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Retrieves the total referrer fees that have been accumulated. This represents rewards earned by referrers. ```typescript getAccumulatedReferrerFees(): Decimal ``` -------------------------------- ### Create Mock Kamino Market for Testing Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Creates a mock KaminoMarket instance for testing purposes. Requires mock state data including the market, reserves, and addresses. ```typescript static createMarket( rpc: Rpc, state: LendingMarket, marketAddress: Address, reserves: Map, recentSlotDurationMs: number, programId: Address = PROGRAM_ID ): KaminoMarket ``` -------------------------------- ### Adjust Multiply/Leverage Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a script for adjusting a leveraged position. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE yarn multiply-adjust ``` -------------------------------- ### Get Borrow Fee Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Retrieves the origination fee applied to borrows. This is a one-time fee charged when a borrow is initiated. ```typescript getBorrowFee(): Decimal ``` -------------------------------- ### Required Dependencies for Klend SDK Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/00-INDEX.md Lists the essential npm packages and their versions required to use the Klend SDK, including Solana web3.js, Anchor, and Decimal.js. ```json { "@solana/kit": "^2.3.0", "@solana/web3.js": "latest", "@coral-xyz/anchor": "^0.28.0", "decimal.js": "^10.4.3", "bn.js": "^5.2.1" } ``` -------------------------------- ### getObligationType Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Gets the obligation type by providing the Kamino market, obligation type tag, and optional mint addresses. ```APIDOC ## getObligationType ### Description Gets obligation type from tag and seeds. ### Signature ```typescript function getObligationType( kaminoMarket: KaminoMarket, obligationTag: ObligationTypeTag, mintAddress1?: Option
, mintAddress2?: Option
): ObligationType ``` ``` -------------------------------- ### Get Obligation Type from Loaded Obligation Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Derives the obligation type directly from a loaded Kamino obligation object. ```typescript function getObligationTypeFromObligation( kaminoMarket: KaminoMarket, obligation: KaminoObligation ): ObligationType ``` -------------------------------- ### Fetch Market Configuration Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Fetches market configurations from the API and logs basic market details. ```APIDOC ## Fetch Market Configuration ### Description Fetches market configurations from the API. ### Usage ```typescript import { getMarketsFromApi } from '@kamino-finance/klend-sdk'; const markets = await getMarketsFromApi(); const market = markets[0]; console.log(`Market: ${market.name}`); console.log(`Address: ${market.lendingMarket}`); ``` ``` -------------------------------- ### Get Solana Keypair Public Key Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Retrieves the public key associated with a given private key file. ```bash solana-keygen pubkey path_to_private_key.json ``` -------------------------------- ### Perform Lending Actions (Deposit) Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Build and send transactions for lending actions like depositing assets. Requires an initialized Kamino market and environment. ```typescript const kaminoAction = await KaminoAction.buildDepositTxns( kaminoMarket, amountBase, symbol, new VanillaObligation(PROGRAM_ID), ); const env = await initEnv('mainnet-beta'); await sendTransactionFromAction(env, sendTransaction); // sendTransaction from wallet adapter or custom ``` -------------------------------- ### Download Kamino Market Reserve Configuration Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Retrieve the latest configuration for a specific reserve to facilitate updates. The 'staging' flag targets staging programs. ```shell yarn kamino-manager download-reserve-config --reserve reserve_address --staging ``` -------------------------------- ### Get All Obligations for Market Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Retrieves all active obligations within the market. An optional tag can be provided to filter by obligation type. ```typescript async getAllObligationsForMarket(tag?: number): Promise ``` -------------------------------- ### Fetch Market Configuration Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Fetches all available markets from the API and logs their names and lending market addresses. ```typescript import { getMarketsFromApi } from '@kamino-finance/klend-sdk'; const markets = await getMarketsFromApi(); const market = markets[0]; console.log(`Market: ${market.name}`); console.log(`Address: ${market.lendingMarket}`); ``` -------------------------------- ### Get Withdrawal Cap Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Retrieves the maximum withdrawal limit for the reserve. This cap restricts the total amount of assets that can be withdrawn. ```typescript getWithdrawalCap(): BN ``` -------------------------------- ### Execute Transactions Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/00-INDEX.md Build and send the prepared transactions to the network. This completes the action initiated by the user. ```javascript const txns = action.buildTransactions() await sendTransactions(txns, wallet) ``` -------------------------------- ### Initialize and Read Market Data Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Initialize the Kamino market and read reserve data. Refresh reserves and all cached data as needed. ```typescript // There are three levels of data you can request (and cache) about the lending market. // 1. Initalize market with parameters and metadata const market = await KaminoMarket.load( connection, address("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF") // main market address. Defaults to 'Main' market ); console.log(market.reserves.map((reserve) => reserve.config.loanToValueRatio)); // 2. Refresh reserves await market.loadReserves(); const usdcReserve = market.getReserve("USDC"); console.log(usdcReserve?.stats.totalDepositsWads.toString()); // Refresh all cached data market.refreshAll(); const obligation = market.getObligationByWallet("WALLET_PK"); console.log(obligation.stats.borrowLimit); ``` -------------------------------- ### Get Borrow Cap Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Retrieves the maximum borrowable amount for the reserve. This cap limits the total amount of assets that can be borrowed. ```typescript getBorrowCap(): BN ``` -------------------------------- ### buildDepositWithLeverageIxs Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/07-leverage-and-advanced.md Constructs all necessary instructions for executing a leveraged deposit. This function aggregates the required on-chain instructions, potentially including swap and collateral management steps. ```APIDOC ## buildDepositWithLeverageIxs ### Description Builds all instructions needed for a leveraged deposit. This function is responsible for generating the sequence of on-chain instructions required to successfully execute a deposit with leverage. ### Method ```typescript async function buildDepositWithLeverageIxs( kaminoMarket: KaminoMarket, debtReserve: KaminoReserve, collReserve: KaminoReserve, owner: TransactionSigner, obligation: KaminoObligation | ObligationType, referrer: Option
, currentSlot: Slot, depositTokenIsSol: boolean, scopeRefreshIx?: Instruction, calcs?: DepositLeverageCalcsResult, budgetAndPriorityFeeIxs?: Instruction[], swapsAndLookupTables?: Array<{ preActionIxs: Instruction[]; swapIxs: Instruction[]; lookupTables: Address[]; quote: { priceAInB: Decimal; quoteResponse?: any }; }>, useV2Ixs?: boolean, elevationGroupOverride?: number, ): Promise; ``` ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response `Promise` - An array of instruction outputs required for the leveraged deposit. #### Response Example N/A ``` -------------------------------- ### Get Liquidation Threshold Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Returns the liquidation threshold for the reserve. This is the LTV ratio at which a collateral position becomes eligible for liquidation. ```typescript getLiquidationThreshold(): Decimal ``` -------------------------------- ### Get Loan-to-Value Ratio Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Retrieves the loan-to-value (LTV) ratio for the reserve. This ratio determines the maximum amount that can be borrowed against a collateral. ```typescript getLoanToValueRatio(): Decimal ``` -------------------------------- ### Withdraw Multiply/Leverage Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a script for withdrawing collateral from a leveraged position. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE yarn multiply-withdraw ``` -------------------------------- ### Build and Execute Deposit Transaction Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/00-INDEX.md Shows how to build a deposit transaction using KaminoAction and then execute it. This involves specifying the market, amount, mint, obligation type, and user signer. ```typescript const action = await KaminoAction.buildDepositTxns( market, amount, mint, new VanillaObligation(), userSigner ); const txns = action.buildTransactions(); const signatures = await sendTransactions(txns, wallet); ``` -------------------------------- ### Get Pending Referrer Fees Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Returns referrer fees that are pending withdrawal. These are earned fees that have not yet been claimed by the referrer. ```typescript getPendingReferrerFees(): Decimal ``` -------------------------------- ### Create Solana Keypair Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Generates a new Solana keypair. The private key should be kept secure, and the public key can be shared. ```bash solana-keygen new -o path_to_private_key.json ``` -------------------------------- ### Get Accumulated Protocol Fees Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Returns the total protocol fees that have been accumulated. This metric represents the platform's earnings. ```typescript getAccumulatedProtocolFees(): Decimal ``` -------------------------------- ### CLI: Deposit Assets Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Use the CLI to deposit assets into lending markets. Specify the RPC URL, owner keypair, token symbol, and amount. ```shell yarn cli deposit --url --owner ./keypair.json --token USDH --amount 10 yarn cli deposit --url --owner ./keypair.json --token SOL --amount 10 ``` -------------------------------- ### buildComputeBudgetIx Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Builds a compute budget instruction, which allows for specifying the computational units and micro-lamports per unit for a transaction. ```APIDOC ## buildComputeBudgetIx ### Description Builds compute budget instruction. ### Method (Not specified, likely a utility function) ### Parameters - **units** (number) - Description not specified. - **microLamportsPerUnit** (number) - Description not specified. ### Returns - **Instruction** - Compute budget instruction. ``` -------------------------------- ### Get all borrows in an obligation Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/03-KaminoObligation.md Retrieves an array of all borrow positions within the KaminoObligation. Use this to see all assets a user has borrowed. ```typescript getBorrows(): Array ``` -------------------------------- ### KaminoMarket.createMarket Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Creates a mock KaminoMarket instance for testing purposes. It requires an RPC connection, market state, market address, reserves map, and recent slot duration. ```APIDOC ## KaminoMarket.createMarket ### Description Creates a mock market for testing purposes. ### Method `static createMarket` ### Parameters #### Path Parameters - **rpc** (Rpc) - Required - RPC connection with required API methods - **state** (LendingMarket) - Required - The lending market state - **marketAddress** (Address) - Required - The public key address of the market - **reserves** (Map) - Required - A map of reserve addresses to KaminoReserve objects - **recentSlotDurationMs** (number) - Required - Duration in milliseconds for recent slot estimation #### Query Parameters - **programId** (Address) - Optional - Program ID of the klend protocol (Default: PROGRAM_ID) ### Returns `KaminoMarket` - A market instance for testing. ``` -------------------------------- ### Get all deposits in an obligation Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/03-KaminoObligation.md Retrieves an array of all deposit positions within the KaminoObligation. Use this to see all assets a user has deposited. ```typescript getDeposits(): Array ``` -------------------------------- ### Parse Token Symbol Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Extracts a token symbol from a string, typically removing zero padding. For example, it can convert 'USDC\x00\x00\x00' to 'USDC'. ```typescript function parseTokenSymbol(name: string): string ``` -------------------------------- ### Validate Solana Address Format Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/09-errors-and-validation.md Demonstrates creating and validating Solana public keys using the '@solana/kit' library. Includes checks for null or default public keys. ```typescript import { address, Address } from '@solana/kit'; // Create from string const validAddress = address('EPzP1QwUfW8yy5gVDJKQDCwVY8Sm5z8zLVZvh1RG6Qo5'); // Validate before use const isValid = validAddress !== null; // Check for default/null key import { isNotNullPubkey, DEFAULT_PUBLIC_KEY } from '@kamino-finance/klend-sdk'; if (!isNotNullPubkey(someAddress)) { console.error('Address is not set'); } ``` -------------------------------- ### Deposit in Reserve to Mint cTokens Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a script to deposit tokens into a reserve, minting cTokens in return. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE yarn run deposit-mint-ctokens ``` -------------------------------- ### KaminoAction.initialize Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/02-KaminoAction.md Creates and initializes a KaminoAction instance for a specific lending operation. This is the entry point for building complex transaction sequences. ```APIDOC ## KaminoAction.initialize ### Description Creates and initializes a KaminoAction instance for a specific lending operation. This is the entry point for building complex transaction sequences. ### Method `static async initialize( action: ActionType, amount: string | BN, mint: Address, owner: TransactionSigner, kaminoMarket: KaminoMarket, obligation: KaminoObligation | ObligationType, referrer?: Option
, currentSlot?: Slot, payer?: TransactionSigner ): Promise` ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters Table | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | action | ActionType | — | Type of operation to perform | | amount | string \| BN | — | Amount in token base units (lamports) | | mint | Address | — | Token mint address | | owner | TransactionSigner | — | Owner of the obligation | | kaminoMarket | KaminoMarket | — | Market instance | | obligation | KaminoObligation \| ObligationType | — | User's obligation or type | | referrer | Option
| none() | Optional referrer address | | currentSlot | Slot | 0n | Current slot number | | payer | TransactionSigner | owner | Transaction payer (defaults to owner) | ### Returns `Promise` - Initialized action ready to build instructions. ### Request Example ```typescript import { KaminoAction, VanillaObligation, address } from '@kamino-finance/klend-sdk'; import BN from 'bn.js'; const action = await KaminoAction.initialize( 'deposit', new BN('1000000000'), usdcMint, ownerSigner, market, new VanillaObligation() ); ``` ``` -------------------------------- ### Get All Obligations by Deposited Reserve Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Retrieves all obligations that have deposits in a specified reserve. This is useful for analyzing obligations with exposure to a particular asset. ```typescript async getAllObligationsByDepositedReserve(reserve: Address): Promise ``` -------------------------------- ### Build Compute Budget Instruction Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/06-utilities.md Builds a Compute Budget instruction to set the compute unit limit and the micro-lamports per unit for transaction execution. ```typescript function buildComputeBudgetIx( units: number, microLamportsPerUnit: number ): Instruction ``` -------------------------------- ### Get All Obligations by Tag Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/01-KaminoMarket.md Fetches all obligations that are associated with a specific tag within a given market. Requires both the tag and the market address. ```typescript async getAllObligationsByTag(tag: number, market: Address): Promise ``` -------------------------------- ### Get Borrow Factor Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Retrieves the borrow factor, a multiplier applied to borrows. This can be used to adjust borrowing limits or risk parameters. ```typescript getBorrowFactor(): Decimal ``` -------------------------------- ### Initialize KaminoManager Class Source: https://github.com/kamino-finance/klend-sdk/blob/master/README_KAMINO_MANAGER.md Initializes the KaminoManager class with a connection object and optional program IDs. Defaults to production programs if IDs are omitted. ```typescript const connection = new anchor.web3.Connection("rpc.url"); const kaminoManager = new KaminoManager(connection, kLendProgramId, kVaultProgramId); ``` -------------------------------- ### Get Borrow APR Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/04-KaminoReserve.md Returns the borrow annual percentage rate (APR). Use this for a simple interest rate calculation on borrows. ```typescript getBorrowAPR(): Decimal ``` -------------------------------- ### CLI: Print All Obligation Accounts Source: https://github.com/kamino-finance/klend-sdk/blob/master/README.md Print raw account data JSONs for all obligations. Use `yarn -s` and `jq --stream` for efficient processing of the JSON stream. ```shell yarn cli print-all-obligation-accounts --rpc ``` ```shell yarn -s cli print-all-obligation-accounts --rpc | jq -cn --stream 'fromstream(1|truncate_stream(inputs)) | .lastUpdate.slot' ``` -------------------------------- ### Deposit in Obligation Source: https://github.com/kamino-finance/klend-sdk/blob/master/examples/README.md Sets the keypair file and executes a script to deposit collateral into an obligation. Ensure KEYPAIR_FILE is set. ```bash export KEYPAIR_FILE=YOUR_PATH_TO_YOUR_KEYPAIR_FILE yarn run deposit-obligation ``` -------------------------------- ### Troubleshoot 'ATA doesn't exist' Source: https://github.com/kamino-finance/klend-sdk/blob/master/_autodocs/08-quickstart-and-patterns.md The 'ATA doesn't exist' error indicates that associated token accounts need to be created. Check the setup instructions within the `KaminoAction` to ensure ATA creation is included. ```typescript const action = await KaminoAction.buildDepositTxns(...); const txns = action.buildTransactions(); // First transaction should have ATA creation in setupIxs console.log(`Setup instructions: ${action.setupIxs.length}`); ```