Price, Bin ID and Sqrt Price
import { BinUtils } from '@cetusprotocol/dlmm-sdk'
// Convert price to bin ID
const binId = BinUtils.getBinIdFromPrice(
'1040.07', // price
2, // bin step
true, // is base coin A
6, // decimals for coin A
9 // decimals for coin B
)
// Convert bin ID to price
const price = BinUtils.getPriceFromBinId(
-4787, // bin ID
2, // bin step
6, // decimals for coin A
9 // decimals for coin B
)
// Get Q price from bin ID
const q_price = BinUtils.getQPriceFromId(
-4400, // bin ID
100 // bin step
)
// Get price per lamport from Q price
const price_per_lamport = BinUtils.getPricePerLamportFromQPrice(q_price)
// Get liquidity from amounts
const liquidity = BinUtils.getLiquidity('0', '266666', '18431994054197767090')
// Get amount A from liquidity
const amountA = BinUtils.getAmountAFromLiquidity('4101094304427826916657468', '18461505896777422276')
// Get amount B from liquidity
const amountB = BinUtils.getAmountBFromLiquidity('4919119455159831291232256')
// Split bin liquidity info
const split_bin_infos = BinUtils.splitBinLiquidityInfo(bin_infos, 0, 70)
// Get position count between bin ranges
const positionCount = BinUtils.getPositionCount(-750, 845)
// Find min/max bin ID for a given bin step
const { minBinId, maxBinId } = BinUtils.findMinMaxBinId(10)Last updated