Calculate the final utilisation on the Liquidity Layer after a hypothetical deposit.
This guide uses read-only APIs from the Liquidity module. No transactions, keypairs, or ATAs required.
Use the Liquidity module from @jup-ag/lend-read to fetch real-time market data and compute how utilisation would change if you made a deposit.Formula: Utilisation is the ratio of borrowed assets to supplied assets: utilisation = totalBorrow / totalSupply. After a deposit, supply increases while borrow stays the same: newUtilisation = totalBorrow / (totalSupply + depositAmount).Example: If the Liquidity Layer has $500M supplied and $200M borrowed (40% utilisation), a $100M deposit would give new supply $600M and new utilisation 33.33% ($200M / $600M).
import { Client } from "@jup-ag/lend-read";import { Connection, PublicKey } from "@solana/web3.js";import BN from "bn.js";
2
Initialise Connection and Fetch Liquidity Data
Create the RPC connection and client. Use client.liquidity.getOverallTokenData(token) to get totalSupply, totalBorrow, and lastStoredUtilization for the target token (e.g. USDC).
Copy
Ask AI
const RPC_URL = "https://api.mainnet-beta.solana.com";const connection = new Connection(RPC_URL, { commitment: "confirmed" });const client = new Client(connection);const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const data = await client.liquidity.getOverallTokenData(USDC_MINT);const totalSupply = new BN(data.totalSupply.toString());const totalBorrow = new BN(data.totalBorrow.toString());
3
Convert Deposit to Base Units
Express your deposit in the token’s base units. For USDC (6 decimals), $100M = 100_000_000 * 10^6.