New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@jup-ag/lend-read

Package Overview
Dependencies
Maintainers
11
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jup-ag/lend-read

utils for jup lend

latest
npmnpm
Version
0.0.14
Version published
Weekly downloads
834
-36.82%
Maintainers
11
Weekly downloads
 
Created
Source

Jupiter Lend Read SDK

Read-only TypeScript SDK for Jupiter Lend on-chain programs. Provides typed access to Liquidity pools, Lending (jlToken) markets, Vaults, and the DEX on Solana.

Installation

pnpm add @jup-ag/lend-read
# or
npm install @jup-ag/lend-read

Quick Start

import { Client } from "@jup-ag/lend-read";
import { PublicKey } from "@solana/web3.js";

// Initialize with default mainnet RPC
const client = new Client();

// Or use a custom RPC endpoint
const client = new Client("https://your-rpc-url.com");

// Or pass an existing Connection
import { Connection } from "@solana/web3.js";
const connection = new Connection("https://your-rpc-url.com");
const client = new Client(connection);

Using Individual Modules

import { Liquidity, Lending, Vault, Dex } from "@jup-ag/lend-read";

const liquidity = new Liquidity("https://your-rpc-url.com");
const lending = new Lending("https://your-rpc-url.com");
const vault = new Vault("https://your-rpc-url.com");
const dex = new Dex("https://your-rpc-url.com");

Liquidity Module

Access liquidity pool data, interest rates, and user supply/borrow positions.

Usage Examples

const USDC = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const SOL = new PublicKey("So11111111111111111111111111111111111111112");
const user = new PublicKey("YOUR_ADDRESS");

// List all supported tokens
const tokens = await client.liquidity.listedTokens();

// Get market data for a token
const data = await client.liquidity.getOverallTokenData(USDC);

// Batch fetch multiple tokens
const allData = await client.liquidity.getOverallTokensData([USDC, SOL]);

// Get user supply position
const { userSupplyData } = await client.liquidity.getUserSupplyData(user, USDC);

// Get user borrow position
const { userBorrowData } = await client.liquidity.getUserBorrowData(user, USDC);

// Get combined supply + borrow across multiple tokens
const combined = await client.liquidity.getUserMultipleBorrowSupplyData(
  user,
  [USDC, SOL], // supply tokens
  [USDC], // borrow tokens
);

Methods

MethodParametersReturnsDescription
listedTokens()-PublicKey[]All token mints with reserves in the liquidity program
getLiquidityAccount()-LiquidityAccountMain liquidity account with authority, auths, and guardians
getRevenueCollector()-PublicKeyRevenue collector address
getRevenue(token)token: PublicKeyBNCalculated revenue for a token
getOverallTokenData(token)token: PublicKeyOverallTokenDataComplete market data for a single token
getOverallTokensData(tokens)tokens: PublicKey[]OverallTokenData[]Batch market data for multiple tokens
getAllOverallTokensData()-OverallTokenData[]Market data for all listed tokens
getExchangePricesAndConfig(token)token: PublicKeyExchangePricesAndConfigExchange prices and rate configuration
getRateConfig(token)token: PublicKeyRateModelAccount | nullInterest rate model parameters
getTotalAmounts(token)token: PublicKeyTotalAmounts | nullTotal supply/borrow amounts
getUserSupply(user, token)user: PublicKey, token: PublicKeyUserSupplyPositionAccount | BNRaw user supply position (BN(0) if none)
getUserBorrow(user, token)user: PublicKey, token: PublicKeyUserBorrowPositionAccount | BNRaw user borrow position (BN(0) if none)
getUserSupplyData(user, token)user: PublicKey, token: PublicKey{ userSupplyData, overallTokenData }Processed user supply with market context
getUserBorrowData(user, token)user: PublicKey, token: PublicKey{ userBorrowData, overallTokenData }Processed user borrow with market context
getUserMultipleSupplyData(user, tokens)user: PublicKey, tokens: PublicKey[]{ userSuppliesData, overallTokensData }Batch supply data across tokens
getUserMultipleBorrowData(user, tokens)user: PublicKey, tokens: PublicKey[]{ userBorrowingsData, overallTokensData }Batch borrow data across tokens
getUserMultipleBorrowSupplyData(user, supplyTokens, borrowTokens)user, supplyTokens[], borrowTokens[]Combined supply + borrow dataEfficient batch fetch for both
getAllUserPositions()-Array<{ user, supply, borrow }>All user positions across the protocol
calculateExchangePrice(config)config: ExchangePricesAndConfigExchangePriceResultCalculate current exchange prices

Return Types

OverallTokenData

FieldTypeDescription
rateDataRateDataInterest rate model configuration
supplyExchangePriceBNCurrent supply exchange price (scales raw amounts to actual)
borrowExchangePriceBNCurrent borrow exchange price
borrowRateBNCurrent borrow interest rate
supplyRateBNCurrent supply interest rate
feeBNProtocol fee on interest (basis points)
lastStoredUtilizationBNLast stored utilization percentage
lastUpdateTimestampBNUnix timestamp of last on-chain update
maxUtilizationBNMaximum allowed utilization (basis points, e.g. 9500 = 95%)
supplyRawInterestBNTotal raw supply with interest
supplyInterestFreeBNTotal supply without interest
borrowRawInterestBNTotal raw borrow with interest
borrowInterestFreeBNTotal borrow without interest
totalSupplyBNTotal supply (interest + interest-free, exchange-price adjusted)
totalBorrowBNTotal borrow (interest + interest-free, exchange-price adjusted)
revenueBNProtocol revenue (balance + borrow - claims - supply)

UserSupplyData

FieldTypeDescription
modeWithInterestbooleanWhether position accrues interest
supplyBNCurrent supply amount (exchange-price adjusted)
withdrawalLimitBNCurrent withdrawal limit
lastUpdateTimestampBNLast position update timestamp
expandPercentBNRate at which withdrawal limit expands
expandDurationBNDuration over which limit fully expands
baseWithdrawalLimitBNBase withdrawal limit before expansion
withdrawableUntilLimitBNAmount withdrawable up to the current limit
withdrawableBNActual withdrawable amount (capped by available liquidity)

UserBorrowData

FieldTypeDescription
modeWithInterestbooleanWhether position accrues interest
borrowBNCurrent borrow amount (exchange-price adjusted)
borrowLimitBNCurrent borrow/debt ceiling
lastUpdateTimestampBNLast position update timestamp
expandPercentBNRate at which borrow limit expands
expandDurationBNDuration over which limit fully expands
baseBorrowLimitBNBase borrow limit before expansion
maxBorrowLimitBNHard cap on borrow limit
borrowLimitUtilizationBNBorrow limit based on pool utilization
borrowableUntilLimitBNAmount borrowable up to the limit
borrowableBNActual borrowable amount (capped by available liquidity)

ExchangePricesAndConfig

FieldTypeDescription
supplyExchangePriceBNExchange price for supply (raw -> actual)
borrowExchangePriceBNExchange price for borrow (raw -> actual)
borrowRateBNCurrent borrow rate
feeBNFee on interest
lastStoredUtilizationBNLast stored utilization
lastUpdateTimestampBNLast update timestamp
maxUtilizationBNMax utilization cap
supplyRatioBN?Supply ratio between interest/interest-free
borrowRatioBN?Borrow ratio between interest/interest-free

Lending Module

Access jlToken (Jupiter Lend token) markets, exchange prices, rewards, and user positions.

Usage Examples

const USDC = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const user = new PublicKey("YOUR_ADDRESS");

// Get all jlToken mints
const jlTokens = await client.lending.getAllJlTokens();

// Get jlToken details (rates, supply, conversion)
const details = await client.lending.getJlTokenDetails(USDC);

// Get all jlToken details at once
const allDetails = await client.lending.getAllJlTokenDetails();

// Get user position
const position = await client.lending.getUserPosition(USDC, user);

// Get all user positions
const allPositions = await client.lending.getUserPositions(user);

// Preview deposit/withdraw
import BN from "bn.js";
const previews = await client.lending.getPreviews(
  USDC,
  new BN(1_000_000), // 1 USDC
  new BN(0),
);

// Get rewards config
const rewardsConfig = await client.lending.getJlTokenRewardsRateModelConfig(
  USDC,
);

// Get latest exchange price (via on-chain simulation)
const price = await client.lending.getExchangePrice(USDC);

Methods

MethodParametersReturnsDescription
getAllJlTokens()-PublicKey[]All jlToken mint addresses
getJlTokenDetails(mint)mint: PublicKeyJlTokenDetailsComplete jlToken market data
getAllJlTokenDetails()-JlTokenDetails[]All jlToken details in one call
getJlTokenInternalData(mint)mint: PublicKeyJlTokenInternalDataInternal jlToken data (programs, balances, prices)
getExchangePrice(mint)mint: PublicKeyBNLatest exchange price (simulation with fallback)
getLatestExchangePriceView(mint)mint: PublicKey{ tokenExchangePrice, liquidityExchangePrice } | nullExchange price via on-chain simulation
getUserPosition(mint, user)mint: PublicKey, user: PublicKeyUserPositionUser's jlToken position
getUserPositions(user)user: PublicKeyJlTokenDetailsUserPosition[]All user positions across jlTokens
getJlTokenRewards(mint)mint: PublicKey[PublicKey, BN]Rewards rate model address and current rate
getJlTokenRewardsRateModelConfig(mint)mint: PublicKeyRewardsRateModelConfigRewards configuration
getPreviews(mint, assets, shares)mint, assets: BN, shares: BNPreviewDataPreview deposit/mint/withdraw/redeem
getLendingAdminData()-DecodedLendingAdminAccountAdmin account data
getLendingAdminAuthority()-PublicKeyAdmin authority
getLendingAdminRebalancer()-PublicKeyRebalancer address
getLendingAdminAuths()-PublicKey[]Authorized addresses
isLendingAuth(auth)auth: PublicKeybooleanCheck if address is authorized

Return Types

JlTokenDetails

FieldTypeDescription
tokenAddressPublicKeyjlToken mint address
namestringToken name (e.g. "JupLend USDC")
symbolstringToken symbol
decimalsnumberToken decimal places
underlyingAddressPublicKeyUnderlying token mint
totalAssetsBNTotal underlying assets backing jlTokens
totalSupplyBNTotal jlToken supply (shares)
conversionRateToSharesBNAssets -> jlToken shares conversion rate
conversionRateToAssetsBNjlToken shares -> assets conversion rate
rewardsRateBNCurrent rewards APR
supplyRateBNBase supply rate from liquidity pool
rebalanceDifferenceBNDifference between liquidity balance and total assets
userSupplyDataUserSupplyDataLending protocol's supply position on liquidity

UserPosition (Lending)

FieldTypeDescription
jlTokenSharesBNUser's jlToken balance (shares)
underlyingAssetsBNValue in underlying tokens
underlyingBalanceBNUser's underlying token wallet balance
allowanceBNToken allowance

PreviewData

FieldTypeDescription
previewDepositBNShares received for depositing assets
previewMintBNAssets needed to mint shares
previewWithdrawBNShares burned to withdraw assets
previewRedeemBNAssets received for redeeming shares

RewardsRateModelConfig

FieldTypeDescription
durationBNRewards program duration (seconds)
startTimeBNRewards start timestamp
endTimeBNRewards end timestamp
startTvlBNMinimum TVL for rewards to activate
maxRateBNMaximum rewards rate cap
rewardAmountBNTotal reward amount for the period

JlTokenInternalData

FieldTypeDescription
liquidityPublicKeyLiquidity program PDA
lendingFactoryPublicKeyLending admin PDA
lendingRewardsRateModelPublicKeyRewards rate model address
rebalancerPublicKeyRebalancer address
liquidityBalanceBNCurrent liquidity pool balance
liquidityExchangePriceBNLiquidity exchange price
tokenExchangePriceBNjlToken exchange price

Vault Module

Access vault configurations, positions, exchange prices, liquidation data, and risk metrics.

Usage Examples

const vaultId = 1;

// Get total vaults
const total = await client.vault.getTotalVaults();

// Get vault config and state
const config = await client.vault.getVaultConfig(vaultId);
const state = await client.vault.getVaultState(vaultId);

// Get comprehensive vault data (config + state + rates + limits)
const data = await client.vault.getVaultByVaultId(vaultId);

// Get all vaults
const allVaults = await client.vault.getAllVaults();

// Get a user position
const position = await client.vault.getUserPosition({ vaultId, positionId: 1 });

// Get position by NFT ID with vault context (T1 vaults only)
const { vault, ...userPosition } = await client.vault.getPositionByVaultId(
  vaultId,
  1,
);

// Smart-vault-aware variants (T1–T4). On a smart leg the amounts are DEX
// shares (9 decimals), not token amounts: `supply` when `vault.isSmartCol`,
// `borrow`/`dustBorrow` when `vault.isSmartDebt`.
const positionV2 = await client.vault.getPositionByVaultIdV2(vaultId, 1);
const userPositionsV2 = await client.vault.getAllUserPositionsV2(user);
const vaultV2 = await client.vault.getVaultEntireDataV2(vaultId);
const allVaultsV2 = await client.vault.getAllVaultsV2();

// Get all positions with risk ratios
const positions = await client.vault.getAllPositionsWithRiskRatio(vaultId);

// Simulate position changes
import BN from "bn.js";
const final = await client.vault.getFinalPosition({
  vaultId,
  positionId: 1,
  newColAmount: new BN(1_000_000),
  newDebtAmount: new BN(500_000),
});

// Get oracle price
const oracle = config.oracle;
const prices = await client.vault.getOraclePrice(oracle);

Methods

MethodParametersReturnsDescription
getTotalVaults()-numberTotal number of vaults
getVaultConfig(vaultId)vaultId: numberVaultConfigVault configuration (tokens, rates, thresholds)
getVaultState(vaultId)vaultId: numberVaultStateCurrent vault state (supply, borrow, branches)
getVaultByVaultId(vaultId)vaultId: numberVaultEntireDataComplete vault data in one call
getAllVaults()-VaultEntireData[]All vaults data with bounded concurrency
getVaultEntireDataV2(vaultId)vaultId: numberVaultEntireDataV2Smart-vault-aware vault data (T1–T4)
getAllVaultsV2()-VaultEntireDataV2[]All vaults, smart-vault-aware
getVaultAdmin()-VaultAdmin | nullVault admin account
getUserPosition({ vaultId, positionId }){ vaultId, positionId }UserPosition | nullSingle user position
batchGetUserPositions(positions)Array<{ vaultId, positionId }>Array<UserPosition | null>Batch fetch positions
getCurrentPositionState({ vaultId, position }){ vaultId, position }UserPositionWithDebtCurrent position with debt/liquidation
getFinalPosition({ vaultId, positionId, newColAmount, newDebtAmount })See paramsUserPositionWithDebtSimulate position after changes
calculateFinalPosition({ vaultId, currentPosition, newColAmount, newDebtAmount })See paramsUserPositionWithDebtCalculate final position from current state
getAllPositionsWithRiskRatio(vaultId)vaultId: numberArray<NftPosition & { riskRatio }>All positions with borrow/supply risk ratio
getAllPositionIdsForVault(vaultId)vaultId: numbernumber[]All position IDs for a vault
getPositionByVaultId(vaultId, nftId)vaultId: number, nftId: numberNftPosition & { vault: VaultEntireData }Position + vault data by NFT ID (T1 only)
getPositionByVaultIdV2(vaultId, nftId)vaultId: number, nftId: numberNftPosition & { vault: VaultEntireDataV2 }Position + vault data, smart-vault-aware
getAllUserPositions(user)user: PublicKeyArray<NftPosition & { vault: VaultEntireData }>All position NFTs held by user (T1 only)
getAllUserPositionsV2(user)user: PublicKeyArray<NftPosition & { vault: VaultEntireDataV2 }>All position NFTs held by user, smart-vault-aware
getNftOwner(mint)mint: PublicKeyPublicKeyOwner of a position NFT
getOraclePrice(oracle)oracle: PublicKey{ operatePrice, liquidatePrice }Oracle prices
getVaultMetadata({ vaultId }){ vaultId }VaultMetadata | nullVault metadata (cached)
getTick({ vaultId, tick }){ vaultId, tick }TickData | nullTick data for a vault
batchGetTicks(ticks)Array<{ vaultId, tick }>Array<TickData | null>Batch fetch ticks
getBranch({ vaultId, branchId }){ vaultId, branchId }BranchData | nullBranch data
batchGetBranches(branches)Array<{ vaultId, branchId }>Array<BranchData | null>Batch fetch branches
getAllBranches({ vaultId }){ vaultId }BranchData[]All branches for a vault
updateExchangePrices(...)Supply/borrow mints + prices{ vaultSupplyExchangePrice, vaultBorrowExchangePrice }Calculate updated vault exchange prices

Return Types

VaultEntireData

FieldTypeDescription
vaultPublicKeyVault config PDA
isSmartColbooleanSmart collateral enabled
isSmartDebtbooleanSmart debt enabled
constantViewsConstantViewsStatic vault addresses and IDs
configsConfigsRate magnifiers, thresholds, oracle
exchangePricesAndRatesExchangePricesAndRatesAll exchange prices and interest rates
limitsAndAvailabilityLimitsAndAvailabilityWithdrawal/borrow limits and availability
liquidityUserSupplyDataUserSupplyDataVault's supply position on liquidity
liquidityUserBorrowDataUserBorrowDataVault's borrow position on liquidity
vaultStateVaultStateCurrent vault state
totalSupplyAndBorrowTotalSupplyAndBorrowAggregated supply/borrow amounts

VaultConfig

FieldTypeDescription
vaultIdnumberVault identifier
supplyTokenPublicKeyCollateral token mint
borrowTokenPublicKeyDebt token mint
supplyRateMagnifiernumberSupply rate multiplier
borrowRateMagnifiernumberBorrow rate multiplier
collateralFactornumberMax LTV ratio
liquidationThresholdnumberLiquidation trigger threshold
liquidationMaxLimitnumberMaximum liquidation amount
liquidationPenaltynumberPenalty on liquidation
withdrawGapnumberWithdrawal gap buffer
borrowFeenumberFee on new borrows (basis points)
oraclePublicKeyPrice oracle address
rebalancerPublicKeyRebalancer address

VaultState

FieldTypeDescription
topTicknumberHighest active tick
currentBranchnumberActive branch ID
totalBranchnumberTotal branches created
totalSupplyBNTotal raw supply
totalBorrowBNTotal raw borrow
totalPositionsnumberNumber of positions
nextPositionIdnumberNext available position ID
branchLiquidatedbooleanWhether current branch is liquidated
currentBranchStateCurrentBranchState?Current branch details
vaultSupplyExchangePriceBNVault supply exchange price
vaultBorrowExchangePriceBNVault borrow exchange price
liquiditySupplyExchangePriceBNLiquidity supply exchange price
liquidityBorrowExchangePriceBNLiquidity borrow exchange price
absorbedDebtAmountBNDebt absorbed from liquidations
absorbedColAmountBNCollateral absorbed from liquidations

ExchangePricesAndRates

FieldTypeDescription
lastStoredLiquiditySupplyExchangePriceBNLast stored liquidity supply price
lastStoredLiquidityBorrowExchangePriceBNLast stored liquidity borrow price
lastStoredVaultSupplyExchangePriceBNLast stored vault supply price
lastStoredVaultBorrowExchangePriceBNLast stored vault borrow price
liquiditySupplyExchangePriceBNCurrent liquidity supply price
liquidityBorrowExchangePriceBNCurrent liquidity borrow price
vaultSupplyExchangePriceBNCurrent vault supply price
vaultBorrowExchangePriceBNCurrent vault borrow price
supplyRateLiquidityBNLiquidity supply APR
borrowRateLiquidityBNLiquidity borrow APR
supplyRateVaultBNVault supply APR
borrowRateVaultBNVault borrow APR
rewardsOrFeeRateSupplyBNSupply-side rewards or fee rate
rewardsOrFeeRateBorrowBNBorrow-side rewards or fee rate

LimitsAndAvailability

FieldTypeDescription
withdrawLimitBNMaximum withdrawal limit
withdrawableUntilLimitBNAmount withdrawable before hitting limit
withdrawableBNActual withdrawable (capped by liquidity)
borrowLimitBNMaximum borrow limit
borrowLimitUtilizationBNBorrow limit from pool utilization
borrowableUntilLimitBNAmount borrowable before hitting limit
borrowableBNActual borrowable (capped by liquidity)
minimumBorrowingBNMinimum borrow amount

UserPosition (Vault)

FieldTypeDescription
vaultIdnumberVault ID
nftIdnumberPosition NFT ID
positionMintPublicKeyPosition NFT mint
isSupplyOnlyPositionnumber | booleanWhether supply-only (no debt)
ticknumberTick representing collateral-to-debt ratio
tickIdnumberID within the tick
supplyAmountBNRaw collateral amount
dustDebtAmountBNSmall residual debt

NftPosition

FieldTypeDescription
nftIdnumberPosition NFT ID
ownerPublicKeyPosition owner
isSupplyPositionbooleanWhether supply-only
supplyBNCollateral (exchange-price adjusted)
beforeSupplyBNRaw collateral before adjustment
borrowBNDebt (exchange-price adjusted)
beforeBorrowBNRaw debt before adjustment
dustBorrowBNDust debt (exchange-price adjusted)
beforeDustBorrowBNRaw dust debt
ticknumberCurrent tick
tickIdnumberTick ID
isLiquidatedbooleanWhether position was liquidated

UserPositionWithDebt

FieldTypeDescription
ticknumberPosition tick
tickIdnumberTick ID
colRawBNRaw collateral
debtRawBNRaw debt
dustDebtRawBNRaw dust debt
finalAmountBNNet collateral after debt
isSupplyOnlyPositionbooleanWhether supply-only
userLiquidationStatusboolean?Whether position was liquidated
postLiquidationBranchIdnumber?Branch ID after liquidation

DEX Module

Access DEX pool configuration, prices, collateral/debt reserves, swap limits, per-protocol positions, and pure off-chain swap / liquidity estimates.

A pool is identified by a numeric dexId (1..getTotalDexes()) and trades a token0 / token1 pair. A pool can enable smart collateral (isSmartCollateralEnabled) and/or smart debt (isSmartDebtEnabled); collateralReserves is null when smart collateral is off, and debtReserves is null when smart debt is off. All numeric values are BN. On Solana a pool's "users" are the child protocols that supply/borrow against it (e.g. T2/T3/T4 vaults), keyed by their protocol PublicKey.

Pools with an external center-price source have their center price fetched automatically from the oracle program (via a read-only simulateTransaction); internal-center-price pools skip that call. Estimates are computed fully off-chain from a single pool snapshot and mirror the on-chain program's rounding bit-for-bit.

new Dex(rpc?, opts?, market?, simulationPayer?);

simulationPayer is the fee payer used for the read-only oracle simulation. It only needs to be a funded, system-owned account (no signature/lamports are spent) and defaults to a long-lived mainnet account; override it for other clusters.

Usage Examples

import BN from "bn.js";
import { PublicKey } from "@solana/web3.js";

const dexId = 1;

// Enumerate pools
const total = await client.dex.getTotalDexes();
const addresses = await client.dex.getAllDexAddresses();
const { token0, token1 } = await client.dex.getDexTokens(dexId);

// Complete pool data (configs + prices + reserves + state + swap limits)
const data = await client.dex.getDexEntireData(dexId);
const all = await client.dex.getAllDexEntireDatas();

// Targeted reads
const configs = await client.dex.getDexConfigs(dexId);
const pex = await client.dex.getDexPricesAndExchangePrices(dexId);
const colReserves = await client.dex.getDexCollateralReserves(dexId); // null if smart-col off
const debtReserves = await client.dex.getDexDebtReserves(dexId); // null if smart-debt off
const state = await client.dex.getDexState(dexId);
const limits = await client.dex.getDexSwapLimitsAndAvailability(dexId);

// Per-protocol (e.g. a vault) position on the pool
const protocol = new PublicKey("...");
const supply = await client.dex.getUserSupplyData(dexId, protocol);
const borrow = await client.dex.getUserBorrowData(dexId, protocol);

// Swap estimates (pure, off-chain)
const swapIn = await client.dex.estimateSwapIn(dexId, true, new BN(1_000_000));
const swapOut = await client.dex.estimateSwapOut(
  dexId,
  true,
  new BN(1_000_000),
);

// Liquidity estimates
const shares = await client.dex.estimateDeposit(
  dexId,
  new BN(1_000_000),
  new BN(1_000_000),
);
const { token0Amt, token1Amt } = await client.dex.estimateDepositPerfect(
  dexId,
  new BN(1_000_000),
);
const oneToken = await client.dex.estimateWithdrawPerfectInOneToken(
  dexId,
  new BN(1_000_000),
  true,
);

// Reuse one snapshot for many pure computations
const snap = await client.dex.snapshot(dexId);

Methods

MethodParametersReturnsDescription
getTotalDexes()-numberTotal pools created (ids 1..N)
getAllDexAddresses()-PublicKey[]Addresses of all pools
getDexAddress(dexId)dexId: numberPublicKeyPool PDA
getDexMetadataAddress(dexId)dexId: numberPublicKeyPool metadata PDA
getDexAdmin()-DexAdminDEX factory/admin account
getDexTokens(dexId)dexId: number{ token0, token1 }Pool token mints
snapshot(dexId, opts?)dexId: number, { externalCenterPrice?: BN, nowSeconds?: number }DexSnapshotFetch + decode a pool; base for all reads
getDexPricesAndExchangePrices(dexId)dexId: numberPricesAndExchangePriceCenter price, ranges, exchange prices
getDexCollateralReserves(dexId)dexId: numberCollateralReserves | nullCollateral reserves (null if smart-col off)
getDexDebtReserves(dexId)dexId: numberDebtReserves | nullDebt reserves (null if smart-debt off)
getDexConfigs(dexId)dexId: numberDexConfigsFee, ranges, thresholds, limits
getDexState(dexId)dexId: numberDexStateLive prices, shifts, per-share reserves
getDexSwapLimitsAndAvailability(dexId)dexId: numberSwapLimitsAndAvailabilityLiquidity limits + utilization headroom
getDexEntireData(dexId)dexId: numberDexEntireDataComplete pool data in one call
getDexEntireDatas(dexIds)dexIds: number[]DexEntireData[]Complete data for several pools
getAllDexEntireDatas()-DexEntireData[]Complete data for every pool
getUserSupplyData(dexId, protocol, nowSeconds?)dexId, protocol: PublicKey, nowSeconds?DexUserSupplyDataA protocol's supply position on the pool
getUserBorrowData(dexId, protocol, nowSeconds?)dexId, protocol: PublicKey, nowSeconds?DexUserBorrowDataA protocol's borrow position on the pool
getUserSupplyDatas(dexId, protocols, nowSeconds?)dexId, protocols: PublicKey[]DexUserSupplyData[]Supply data for several protocols
getUserBorrowDatas(dexId, protocols, nowSeconds?)dexId, protocols: PublicKey[]DexUserBorrowData[]Borrow data for several protocols
getUserBorrowSupplyDatas(dexId, protocols, nowSeconds?)dexId, protocols: PublicKey[]{ supply: [], borrow: [] }Both supply + borrow for several protocols
estimateSwapIn(dexId, swap0to1, amountIn, amountOutMin?)dexId, swap0to1: boolean, amountIn: BN, amountOutMin?: BNSwapResultExact-input swap estimate
estimateSwapOut(dexId, swap0to1, amountOut, amountInMax?)dexId, swap0to1: boolean, amountOut: BN, amountInMax?: BNSwapResultExact-output swap estimate
estimateDeposit(dexId, token0Amt, token1Amt)dexId, token0Amt: BN, token1Amt: BNBNShares minted for a token deposit
estimateDepositPerfect(dexId, shares)dexId, shares: BN{ token0Amt, token1Amt }Tokens required to mint exact shares
estimateWithdraw(dexId, token0Amt, token1Amt)dexId, token0Amt: BN, token1Amt: BNBNShares burned for a token withdraw
estimateWithdrawPerfect(dexId, shares)dexId, shares: BN{ token0Amt, token1Amt }Tokens out for burning exact shares
estimateWithdrawPerfectInOneToken(dexId, shares, inToken0)dexId, shares: BN, inToken0: booleanBNSingle-token amount out for exact shares
estimateBorrow(dexId, token0Amt, token1Amt)dexId, token0Amt: BN, token1Amt: BNBNShares minted for a token borrow
estimateBorrowPerfect(dexId, shares)dexId, shares: BN{ token0Amt, token1Amt }Tokens out for borrowing exact shares
estimatePayback(dexId, token0Amt, token1Amt)dexId, token0Amt: BN, token1Amt: BNBNShares burned for a token payback
estimatePaybackPerfect(dexId, shares)dexId, shares: BN{ token0Amt, token1Amt }Tokens required to burn exact shares
estimatePaybackPerfectInOneToken(dexId, shares, inToken0)dexId, shares: BN, inToken0: booleanBNSingle-token amount to pay exact shares
fetchExternalCenterPrice(oracle)oracle: PublicKeyBNCenter price from the oracle program (0 on fail)

Return Types

DexEntireData

FieldTypeDescription
dexPublicKeyPool PDA
dexIdnumberPool identifier
token0PublicKeytoken0 mint
token1PublicKeytoken1 mint
configsDexConfigsFee, ranges, thresholds, limits
pricesAndExchangePricesPricesAndExchangePricePrices + exchange prices
collateralReservesCollateralReserves | nullCollateral reserves (null if col off)
debtReservesDebtReserves | nullDebt reserves (null if debt off)
dexStateDexStateLive pool state
limitsAndAvailabilitySwapLimitsAndAvailabilityLiquidity limits + utilization headroom

DexConfigs

FieldTypeDescription
isSmartCollateralEnabledbooleanSmart collateral enabled
isSmartDebtEnabledbooleanSmart debt enabled
feeBNSwap fee (4-dec, 1% = 10000)
revenueCutBNRevenue cut of fee
upperRangeBNUpper price range
lowerRangeBNLower price range
upperShiftThresholdBNUpper rebalance threshold
lowerShiftThresholdBNLower rebalance threshold
shiftingTimeBNRange shift duration
centerPriceAddressPublicKeyExternal center-price oracle (or default)
maxCenterPriceBNCenter-price upper bound
minCenterPriceBNCenter-price lower bound
utilizationLimitToken0BNtoken0 utilization cap (1e3 = 100%)
utilizationLimitToken1BNtoken1 utilization cap (1e3 = 100%)
maxSupplySharesBNMax supply shares
maxBorrowSharesBNMax borrow shares

PricesAndExchangePrice

FieldTypeDescription
lastStoredPriceBNPool price after the most recent swap
centerPriceBNCenter price (ranges derive from this)
upperRangeBNUpper price range
lowerRangeBNLower price range
geometricMeanBNGeometric mean of the range
exchangePricesExchangePricestoken0/1 supply + borrow exchange prices

CollateralReserves / DebtReserves

FieldTypeDescription
token0RealReservesBNtoken0 real reserves
token1RealReservesBNtoken1 real reserves
token0ImaginaryReservesBNtoken0 imaginary reserves
token1ImaginaryReservesBNtoken1 imaginary reserves
token0Debt*BNtoken0 debt (DebtReserves only)
token1Debt*BNtoken1 debt (DebtReserves only)

SwapResult

FieldTypeDescription
amountOutBNTotal output amount
amountInBNTotal input amount
colWithdrawBNOutput routed via collateral pool
debtBorrowBNOutput routed via debt pool
colDepositBNInput routed into collateral pool
debtPaybackBNInput routed into debt pool
newPriceBNPool price after the swap
centerPriceBNCenter price used

DexState

FieldTypeDescription
lastToLastStoredPriceBNPrice two swaps ago
lastStoredPriceBNPrice after the most recent swap
centerPriceBNStored center price
lastUpdateTimestampBNLast update unix time
lastUpdateSlotBNLast update slot
totalSupplySharesBNTotal supply shares
totalBorrowSharesBNTotal borrow shares
isSwapAndArbitragePausedbooleanWhether swaps/arbitrage are paused
shiftsShiftChangesActive range/threshold/center-price shifts
token0PerSupplyShareBNtoken0 per 1e9 supply shares
token1PerSupplyShareBNtoken1 per 1e9 supply shares
token0PerBorrowShareBNtoken0 per 1e9 borrow shares
token1PerBorrowShareBNtoken1 per 1e9 borrow shares

SwapLimitsAndAvailability

FieldTypeDescription
liquiditySupplyToken0 / ...Token1BNLiquidity-layer total supply per token
liquidityBorrowToken0 / ...Token1BNLiquidity-layer total borrow per token
liquidityWithdrawableToken0 / ...Token1BNWithdrawable from liquidity per token
liquidityBorrowableToken0 / ...Token1BNBorrowable from liquidity per token
utilizationLimitToken0 / ...Token1BNConfigured utilization cap amount
withdrawableUntilUtilizationLimitToken0 / ...Token1BNWithdrawable before utilization cap
borrowableUntilUtilizationLimitToken0 / ...Token1BNBorrowable before utilization cap
liquidityUserSupplyDataToken0 / ...Token1UserSupplyDataPool's supply position on liquidity
liquidityUserBorrowDataToken0 / ...Token1UserBorrowDataPool's borrow position on liquidity
liquidityTokenData0 / ...Data1OverallTokenDataLiquidity token data per token

DexUserSupplyData

FieldTypeDescription
isAllowedbooleanWhether the protocol's supply is active
supplyBNSupply shares
withdrawalLimitBNCurrent expanded withdrawal limit
lastUpdateTimestampBNLast update unix time
expandPercentBNWithdrawal-limit expand percent
expandDurationBNWithdrawal-limit expand duration
baseWithdrawalLimitBNBase withdrawal limit
withdrawableUntilLimitBNShares withdrawable before the limit
withdrawableBNWithdrawable shares
liquidityUserSupplyDataToken0 / ...Token1UserSupplyDataPool's supply on liquidity per token
liquidityTokenData0 / ...Data1OverallTokenDataLiquidity token data per token

DexUserBorrowData

FieldTypeDescription
isAllowedbooleanWhether the protocol's borrow is active
borrowBNBorrow shares
borrowLimitBNCurrent expanded borrow limit
lastUpdateTimestampBNLast update unix time
expandPercentBNBorrow-limit expand percent
expandDurationBNBorrow-limit expand duration
baseBorrowLimitBNBase borrow limit (debt ceiling)
maxBorrowLimitBNMax borrow limit
borrowableUntilLimitBNShares borrowable before the limit
borrowableBNBorrowable shares
liquidityUserBorrowDataToken0 / ...Token1UserBorrowDataPool's borrow on liquidity per token
liquidityTokenData0 / ...Data1OverallTokenDataLiquidity token data per token

Program IDs (Mainnet)

ProgramAddress
LiquidityjupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC
Lendingjup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9
Lending Reward Rate Modeljup7TthsMgcR9Y3L277b8Eo9uboVSmu1utkuXHNUKar
Vaultsjupr81YtYssSyPt8jbnGuiWon5f6x9TcDEFxYe3Bdzi
DEXjupZ4m2GqUCJ5iueMfzQf8khFfH31d4XAQt3RzCT9Vd
Oraclejupnw4B6Eqs7ft6rxpzYLJZYSnrpRgPcr589n5Kv4oc
FlashloanjupgfSgfuAXv4B6R2Uxu85Z1qdzgju79s6MfZekN6XS

All modules are read-only -- they fetch and decode on-chain accounts via RPC but never submit transactions.

FAQs

Package last updated on 04 Sep 2026

Related posts