0.6.5-test2 • Published 5 months ago

@dicksonp/dlmm-sdk v0.6.5-test2

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Example Usage

For now, see src/example.ts for examples. Will add examples once stable.

Available functions

FunctionDescriptionNotes
getLbPairsGet all available LB Pairs
getLbPairGet a specific LB Pair
findLbPairsGiven a X and Y token mint, find corresponding LB Pair(s). Will also find inverse LB Pairs ie desiredTokenX as tokenY and desiredTokenY as tokenX
getBinsAroundActiveBinGet current distribution based on a radius around the active bin. Returns price, bin id, x amount and y amount for each bin
getBinsBetweenMinAndMaxPriceGet bins and corresponding distribution based on a min and max price. Returns price, bin id, x amount and y amount for each bin
getBinsBetweenLowerAndUpperBoundGet bins and corresponding distribution based on a min and max bin ID. Returns price, bin id, x amount and y amount for each bin
getCurrentPriceGet current price for a LB pair
getPriceOfBinByLbPairGet price of a bin by its bin id for a LB pairPrefer getPriceOfBinByBinStep if already have information on bin step to reduce RPC calls
getPriceOfBinByBinStepGet price of a bin by its bin id given a bin stepUse this when necessary but in general getBinsAroundActiveBin, getBinsBetweenMinAndMaxPrice and getBinsBetweenLowerAndUpperBound would already return the prices for each bin
getBinIdFromPriceReturns the bin id given a price
getPositionsByUserGet positions by user pubkey
getPositionsByUserAndLbPairGet positions by user pubkey for a specific LB Pair
getPositionGet detailed information for a specific position. information includes binId, price, positionXAmount, positionYAmount etc+
getEqualWeightageAmountReturns an equal weightage amount of the opposing token based on ratioThis is useful when adding liquidity
initializePositionAndAddLiquidityReturns a yet-to-be sent Transaction as well as position and positionMint. Use this to construct a transaction to add liquidity to a LB PairNote that X and Y distribution values are a percentage (in BPS) of totalX and totalY amount to be deposited. PositionMint will be remove in next iteration.
removeLiquiditywithdraw liquidity from a position
createLbPairCreate a new LB Pair or pool
swapWorks for swaps from X to Y or Y to X. Todo: Handle situation if bin array not yet initializedIf out token account does not exist, will create out token ATA. If out token is SOL, will receive WSOL. Does not handle for WSOL -> SOL