Skip to main content
The package exports DlmmProClient plus pure helpers for quoting, liquidity shapes, ticks, PDAs, fees and activation. Every builder returns an unsigned transaction with the fee payer set and no recent blockhash. You sign it and send it. Each section starts with a summary table of what it contains. An entry for every function follows, with its signature, each parameter and its default, the return value, an example and notes on behaviour and thrown errors.

Dependencies

Program IDs

DLMM_PRO_PROGRAM_ID is the same on mainnet and devnet. For another deployment, pass its address as the programId argument of the DlmmProClient constructor. The SDK rewrites the IDL address and the pool authority PDA to match.

Creating a Client

Builder Conventions

  • Builders return { tx, ... }. tx is an unsigned Transaction with feePayer set and no recent blockhash. sendAndConfirmTransaction(connection, tx, signers) fills in the blockhash.
  • User token accounts are optional. Each defaults to the associated token account of the wallet its parameter names.
  • The builder creates a missing associated token account, funded by the fee payer. An account you pass explicitly is used as is.
  • For native SOL, the builder wraps the shortfall of the amount being paid from the owner’s lamports and closes the owner’s wrapped SOL account at the end, so the owner signs. A delegate withdrawing native SOL leaves that account open. initializeLaunchPool wraps 1 lamport when its SOL proof account is empty.
  • Token 2022 transfer-hook accounts are resolved from the mint for every transfer. Pass transferHookX, transferHookY, transferHookReferral or transferHookReward to override (openLimitOrder takes a single transferHook). An explicit array, including [], is sent as given.
  • Builders read the accounts they need (pool, mints, transfer-hook accounts) at the client’s commitment.
  • state.fetchTokenBadge always reads ACCESS_REGISTRY_PROGRAM_ID.
  • Operator and admin instructions are not wrapped. Build them with client.program.methods.<instruction>(...).instruction() or .transaction(). The program has a read-only provider and cannot send.
createDlmmProProgram(connection, programId?) and createAccessRegistryProgram(connection) return the Anchor programs the client uses, each with a read-only provider.

DlmmProClient

Entry point. Holds the connection, the Anchor program, and one service per area. Function
Parameters
Returns
Example
Notes
  • Builders return { tx, ... }. tx is an unsigned Transaction with feePayer set and no recent blockhash; each builder lists its signers. sendAndConfirmTransaction(connection, tx, signers) fills in the blockhash.
  • User token accounts are optional and default to the associated token account of the wallet each parameter names. The builder creates a missing associated token account, with the fee payer funding it. For native SOL it also wraps the shortfall of the amount being paid from the owner’s lamports and closes the owner’s wrapped-SOL account at the end, so the owner signs. A delegate withdrawing native SOL leaves that account open. An account passed explicitly is used as is. initializeLaunchPool wraps 1 lamport when its SOL proof account is empty.
  • Builders read the accounts they need (pool, mints, transfer-hook accounts) at the client’s commitment.
  • state.fetchTokenBadge always reads ACCESS_REGISTRY_PROGRAM_ID.
  • Operator and admin instructions are not wrapped. Build them with client.program.methods.<instruction>(...).instruction() or .transaction(); the program has a read-only provider and cannot send.

createDlmmProProgram

Function
Parameters
Returns An Anchor Program with a read-only provider. Notes
  • For another deployment, the IDL’s address and the pool-authority PDA it embeds are rewritten to programId.

createAccessRegistryProgram

Function
Parameters
Returns An Anchor Program for ACCESS_REGISTRY_PROGRAM_ID with a read-only provider.

Pool Service

client.pool. The three initializers return { tx, pool, oracle, reserveX, reserveY, tickArrayBitmapExtension, tokenXProgram, tokenYProgram, tokenBadgeX, tokenBadgeY }. openPosition, expandPosition and openLimitOrder create the tick arrays they need, so call initializeTickArray only to create one ahead of time. A mint needs a token badge from the access registry when it is a Token 2022 mint with an extension other than a transfer fee, metadata, or a transfer hook with neither a program nor an authority. Pass tokenBadgeX or tokenBadgeY from deriveTokenBadge. A config with DynamicConfigPermission.CreatePoolWithoutMintValidation skips the badge check. On an OnlyY pool, token Y must be wrapped SOL or USDC, or have a token badge. The three initializers throw InvalidTokenBadge when it is neither wrapped SOL nor USDC and no tokenBadgeY is passed.

Quote Then Swap

quoteExactIn returns the tick arrays the quote used. Pass them to swap only when quote.amountLeft is zero. Otherwise the program reverts with NotConsumingFullAmountIn. The dynamic fee and scheduled base fees can change before the swap lands, so set minimumOutputAmount below transferFeeExcludedOutAmount. To pay the host fee to a referrer, pass referral to swap: a token account for the fee token, which is the output mint, or token Y on an OnlyY pool. Pass hasReferral: true to the quote to see the same fee split. The swapper’s output does not change.

Pool Parameters with a Dynamic Config

initializePoolWithDynamicConfig and initializeLaunchPool take InitializePoolWithDynamicParameters. The builder checks the fee schedule, dynamic fee, tick spacing, price, extensions and activation parameters before building, and throws a PoolError on the first violation. Mint and token badge rules are checked by the program, apart from the OnlyY rule above. With the ActivationAccess extension, poolActivation is required and activationPoint defaults to the current slot or timestamp. Without it, both must be null.

quoteExactIn

Quotes an exact-in swap from the current on-chain state and returns the accounts swap needs. Function
Parameters
Returns
Example
Notes
  • quote.amountLeft > 0 means the loaded tick arrays ran out of liquidity. A swap of that input reverts with NotConsumingFullAmountIn; raise maxTickArrays or lower inputAmount.
  • The quote uses the clock at read time. The dynamic fee and scheduled base fees can change before the swap lands, so set minimumOutputAmount below transferFeeExcludedOutAmount.
  • hasReferral changes only how the protocol fee is split (hostFee, protocolFee, partnerFee), not what the swapper receives.
  • Throws AmountIsZero for a zero input, InvalidActivationAccess when swaps are disabled or the pool is not yet active for swapper, and LiquidityIsZero when no initialized tick array lies in the swap direction.

swap

Builds an exact-in swap. Function
Parameters
Returns { tx }. Signer: user. Example
Notes
  • Pass the tickArrays and tickArrayBitmapExtension of a quote whose amountLeft is zero. The program reverts with NotConsumingFullAmountIn unless the swap consumes all of inputAmount.
  • The program takes the direction from the mint of userTokenOut; the builder uses swapForY to pick the default accounts and resolve the transfer-hook accounts of each leg.
  • referral must hold the fee token: the output mint, or token Y on a pool with CollectFeeMode.OnlyY. It may be the swapper’s own account.
  • Throws AmountIsZero for a zero inputAmount.

initializePoolWithStaticConfig

Creates a pool from a static config, which fixes the fees, tick spacing, collect-fee mode, activation type, and extensions. Function
Parameters
Returns
Signers: payer, and the config’s poolCreatorAuthority when it is not the default key. Example
Notes
  • A mint needs a token badge from the access registry when it is a Token 2022 mint with an extension other than a transfer fee, metadata, or a transfer hook with neither a program nor an authority (UnsupportedMint without it). Token Y also needs one on a CollectFeeMode.OnlyY pool unless it is in WHITELISTED_QUOTE_MINTS (InvalidTokenBadge).
  • The program creates the bitmap extension with the pool when the initial tick lies outside the inline bitmap.
  • Throws InvalidParameters for identical mints or an initialSqrtPrice outside MIN_SQRT_PRICE..=MAX_SQRT_PRICE, and InvalidTokenBadge on an OnlyY config when token Y is not in WHITELISTED_QUOTE_MINTS and tokenBadgeY is not passed.

initializePoolWithDynamicConfig

Creates a pool from a dynamic config with caller-chosen fees, tick spacing, activation, and extensions. Function
Parameters
Returns InitializePoolResult, as for initializePoolWithStaticConfig. Signers: payer and poolCreatorAuthority. Example
Notes
  • The builder validates parameters before building (fee schedule and bounds, dynamic fee, tick spacing, price, extensions, activation slots) and throws a PoolError on the first violation. See Base Fee and Activation Builders and Dynamic Fee. With the ActivationAccess extension it reads the clock to check the activation points.
  • With the ActivationAccess extension, poolActivation is required and activationPoint defaults to the current slot or timestamp. Without it, both must be null.
  • Token badges as for initializePoolWithStaticConfig; a config with DynamicConfigPermission.CreatePoolWithoutMintValidation skips the badge and Token 2022 extension checks; the Token 2022 native mint is still rejected and OnlyY still needs a badge for token Y.

initializeLaunchPool

Creates a launch pool: a dynamic pool keyed by its mint pair, with no config. Function
Parameters
Returns InitializePoolResult; pool is deriveLaunchPool(tokenXMint, tokenYMint). Signer: payer. Notes
  • userTokenX and userTokenY prove that payer holds both tokens; nothing is transferred. The program fails with InvalidTokenOwnerProof when either balance is zero.
  • The protocol takes MM_LAUNCH_POOL_PROTOCOL_FEE_BPS of the market-maker fee on a launch pool instead of MM_PROTOCOL_FEE_BPS.
  • Parameter validation and token badges as for initializePoolWithDynamicConfig.

initializeTickArray

Creates the tick array account for one index. Function
Parameters
Returns { tx, tickArray }. Signer: funder. Example
Notes
  • openPosition, expandPosition, and openLimitOrder create the tick arrays they need; call this only to create one ahead of time.
  • The program rejects an index with no tick inside MIN_TICK_ID..=MAX_TICK_ID (InvalidParameters).

initializeTickBitmapExtension

Creates the pool’s tick array bitmap extension. Function
Parameters
Returns { tx, tickArrayBitmapExtension }. Signer: funder. Notes
  • The inline bitmap tracks tick array indexes -512..511. Liquidity or limit orders in an array outside that range need the extension; without it the program fails with TickArrayBitmapExtensionAccountIsNotProvided.

increaseOracleLength

Grows the pool’s oracle by lengthToAdd observations. Function
Parameters
Returns { tx, oracle }. Signer: payer. Notes
  • The program caps the oracle at MAX_OBSERVATION_LENGTH (500) observations (InvalidParameters).

claimPartnerFee

Withdraws the pool partner’s accrued fees. Function
Parameters
Returns { tx }. Signer: signer. Example
Notes
  • The program transfers the lesser of the pending fee and the cap on each side, and rejects a signer other than poolState.poolPartner.partner (InvalidAuthority).

Position Service

client.position. A position is a Token 2022 NFT plus a position array of up to POSITION_MAX_RANGE (45) slots. Each slot is a TickRange ([tickLowerId, tickUpperId)) with its own liquidity, fees and rewards.

Slots, Bitmaps and Layout Version

Instructions that act on some slots take a bitmap of slot indexes (liquidityBitmap) and the tickRanges of those slots. The builder passes the tick arrays of those ranges to the program. Slot i of a new position is tickRanges[i]. expandPosition and removePosition change the slot layout and increase the position’s layoutVersion. Instructions that take expectedLayoutVersion fail with InvalidLayoutVersion when it no longer matches. Pass the layoutVersion you read the slots with, or null to skip the check. The owner can approve a delegate on the NFT account with a Token 2022 approve of amount 0, then grant permissions with updatePositionDelegatePermission. When a delegate signs an instruction that pays out tokens, each account receiving a non-zero amount must be the owner’s associated token account, or the program fails with IncorrectATA. The liquidity builders share these account fields:

Deposit by Weight

buildLiquidityShape gives every tick column a weight and groups the columns into position ranges. multiplierFromAmounts sizes the deposit to your token budgets, and encodeAddLiquidityByWeight builds the parameters.
A position is a Token 2022 NFT plus a position array of up to POSITION_MAX_RANGE (45) slots. Each slot is a TickRange ([tickLowerId, tickUpperId)) with its own liquidity, fees, and rewards. Instructions that act on some slots take a bitmap of slot indexes (liquidityBitmap) and the tickRanges of those slots, whose tick arrays the builder passes to the program. expandPosition and removePosition change the slot layout and increase the position’s layoutVersion. Instructions that take expectedLayoutVersion fail with InvalidLayoutVersion when it no longer matches; pass the layoutVersion you read the slots with, or null to skip the check. The owner can approve a delegate on the NFT account (a Token 2022 approve of amount 0; the program rejects any other amount with DelegatedAmountNonZero) and grant it permissions with updatePositionDelegatePermission. When a delegate signs an instruction that pays out tokens, each account receiving a non-zero amount must be the owner’s associated token account (IncorrectATA). The liquidity builders share these fields:
The examples in this section use these values:

openPosition

Mints a position NFT and creates its position array with the given ranges. Function
Parameters
Returns { tx, position, nftAccount }, where position is derivePosition(nftMint). Signers: payer and the nftMint keypair. Example
Notes
  • The position opens empty; deposit with addLiquidity, addLiquidityByWeight, or addLiquidityImbalance.
  • The program creates missing tick arrays of the range endpoints, paid by payer.
  • Throws InvalidParameters for no ranges, more than POSITION_MAX_RANGE, a range with tickLowerId >= tickUpperId, or a tick that is not a usable tick of the pool’s spacing (isUsableTickId).

addLiquidity

Deposits explicit liquidity into selected slots. Function
Parameters
Returns { tx, position }. Signer: signer. Example
Notes
  • The program fails with ExceededSlippage when a side’s deposit plus its transfer fee exceeds maxAmountX / maxAmountY.
  • A delegate needs PositionDelegatePermission.AddLiquidity and pays from its own token accounts.
  • Throws InvalidParameters when liquidities does not have one entry per selected slot, LiquidityIsZero for a zero entry, and LiquidityIsTooHigh above i128::MAX.

addLiquidityByWeight

Deposits multiplier * weight liquidity into each selected slot. Function
Parameters
encodeAddLiquidityByWeight builds parameters from a liquidity shape. Returns { tx, position }. Signer: signer. Example
Notes
  • ExceededSlippage and delegate rules as for addLiquidity.
  • Throws LiquidityIsZero for a zero multiplier or weight, InvalidParameters when the weight count differs from the selected slot count, and LiquidityIsTooHigh when multiplier * weight exceeds i128::MAX.

addLiquidityImbalance

Deposits into one slot from the wallet balances at execution, capped per side. Function
Parameters
tickRanges holds the range of slot index. Returns { tx, position }. Signer: signer. Example
Notes
  • The program uses the lesser of each cap and the userTokenX / userTokenY balance, and deposits the largest liquidity both sides fund at the current price.
  • A null side fails with ExceededSlippage unless the slot needs none of that token at the current price (the range lies entirely on the other side). The price band and minLiquidity also fail with ExceededSlippage.
  • Throws InvalidParameters when both caps are null, the price band is inverted or outside MIN_SQRT_PRICE..=MAX_SQRT_PRICE, or index is not below POSITION_MAX_RANGE, and AmountIsZero for a zero cap.

removeLiquidity

Withdraws explicit liquidity from selected slots. Function
Parameters
Returns { tx, position }. Signer: signer. Example
Notes
  • Only unlocked liquidity can be withdrawn; permanently locked and unvested liquidity stays.
  • The program fails with ExceededSlippage when a side receives less than its minimum.
  • A delegate needs PositionDelegatePermission.RemoveLiquidity and can only pay into the owner’s associated token accounts, the defaults.
  • Same liquidities checks as addLiquidity.

removeLiquidityByBps

Withdraws a share of the unlocked liquidity of selected slots. Function
Parameters
Returns { tx, position }. Signer: signer. Example
Notes
  • tickRanges must cover every selected slot that has unlocked liquidity; the ranges of all selected slots always do.
  • The program releases vested liquidity first, then withdraws unlockedLiquidity * bps / 10000 from each selected slot.
  • Slippage and delegate rules as for removeLiquidity.
  • Throws InvalidParameters for bps outside 1..=10000.

claimFee

Refreshes the selected slots and transfers the position’s pending fees. Function
Parameters
tickRanges must cover every selected slot that holds liquidity; the refresh skips the others. Returns { tx } holding the refresh and the claim. Signer: signer. Example
Notes
  • Fees accrue to a slot when it is refreshed; select every slot whose fees you want. Unselected slots pay out only what is already pending.
  • A delegate needs PositionDelegatePermission.ClaimFee and can only pay into the owner’s associated token accounts, the defaults.

getClaimableFees

Computes what claimFee would transfer for bitmap, from the current pool and tick state. Function
Parameters
Returns
Example
Notes
  • Swaps that land after the read add fees the result does not include.
  • Throws InvalidParameters when bitmap selects a slot the position does not have, and an Error when the position belongs to another pool.

compoundFees

Refreshes and claims fees, then redeposits them into one slot, in one transaction. Function
Parameters
Returns { tx, position, claimable, parameters }: claimable is the getClaimableFees result the caps come from, and parameters the addLiquidityImbalance input of the deposit. Signer: signer. Example
Notes
  • The deposit is addLiquidityImbalance into slot index. With the default caps it uses only what the claim delivers, leaving existing wallet balances alone.
  • A side that earned nothing defaults to null, which fails with ExceededSlippage unless the slot needs none of that token at the current price. To compound into a slot that needs both tokens, pass a wallet-funded cap for that side.
  • A delegate signer needs the ClaimFee and AddLiquidity permissions and an SPL token approve from the owner on userTokenX and userTokenY: the claim pays into the owner’s associated token accounts and the deposit spends from them with signer as the transfer authority. Approve only the amount to compound.
  • Throws InvalidParameters when index is not a slot of the position, and AmountIsZero when neither cap is given and the claim delivers nothing.

expandPosition

Appends slots to a position. Function
Parameters
Returns { tx, position }. Signers: signer and payer. Example
Notes
  • New slots follow the existing ones. The program rejects a total above POSITION_MAX_RANGE slots (InvalidParameters), creates missing tick arrays, paid by payer, and increases layoutVersion.
  • Same range checks as openPosition.

removePosition

Deletes empty slots from a position. Function
Parameters
Returns { tx, position }. Signer: signer. Example
Notes
  • The program fails with PositionIsNotEmpty for a slot with liquidity, pending fees, or pending rewards, and with InvalidParameters when bitmap selects every slot; use closePosition for that. It increases layoutVersion.
  • Throws InvalidPermission when a delegate names anyone but the owner as rentReceiver.

closePosition

Closes an empty position and burns its NFT. Function
Parameters
Returns { tx, position }. Signer: owner. Example
Notes
  • The program fails with PositionIsNotEmpty while any slot holds liquidity, pending fees, or pending rewards. Withdraw and claim first.

lockPermanentPosition

Permanently locks a share of the position’s unlocked liquidity. Locked liquidity keeps earning fees and rewards. Function
Parameters
Returns { tx }. Signer: owner. Notes
  • Owner only; delegates cannot lock.
  • Throws InvalidParameters for bps outside 1..=10000.

lockVestingPosition

Locks a share of the position’s unlocked liquidity and releases it on a cliff-plus-periods schedule. Function
Parameters
Returns { tx }. Signer: owner. Example
Notes
  • cliffUnlockBps + bpsPerPeriod * numberOfPeriod must equal 10000, and periodFrequency, bpsPerPeriod, and numberOfPeriod are all set or all zero (InvalidParameters).
  • The program rejects a cliffPoint in the past, and a schedule whose cliff delay plus periodFrequency * numberOfPeriod exceeds MAX_VESTING_DURATION seconds, or MAX_VESTING_DURATION_SLOT slots on a slot-activated pool.
  • One schedule per position; a second fails with PositionAlreadyHadVesting. Owner only.

refreshFeesAndRewards

Brings the fee and reward checkpoints of selected slots up to date without transferring anything. Function
Parameters
Returns { tx }. Signer: signer. Example
Notes
  • claimFee and claimReward include this refresh.
  • A delegate needs no specific permission.

updatePositionDelegatePermission

Sets the permissions of the position’s approved delegate. Function
Parameters
Returns { tx }. Signer: owner. Example
Notes
  • The delegate itself is set by a Token 2022 approve of amount 0 on the NFT account.
  • Throws InvalidPermission for a mask above MAX_POSITION_DELEGATE_PERMISSION.

Limit Order Service

client.limitOrder. A limit order is a Token 2022 NFT plus a limit-order account holding up to LIMIT_ORDER_MAX_TICK (25) ticks, all on one side. An ask (isAskSide: true) sells token X at ticks strictly above the current tick. A bid buys token X with token Y at ticks at or below it. A swap fills the orders at a tick once the price reaches it. On cancel the owner receives the unfilled amount, the filled proceeds and the order’s share of the limit-order fee. With relativeTick set, each ticks[].id is an offset, in tick-spacing units, from the current tick aligned down to the spacing at execution. The program rejects the order with ExceededSlippage when that aligned tick has left [spacingAlignedMinTickId, spacingAlignedMaxTickId]. Without relativeTick, ticks[].id are absolute tick ids. relativeTickFromSlippage builds the band and limitOrderTicksFromShape builds the ticks from a liquidity shape. A limit order is a Token 2022 NFT plus a limit-order account holding up to LIMIT_ORDER_MAX_TICK (25) ticks, all on one side. An ask sells token X at ticks above the current tick; a bid buys token X with token Y at ticks at or below it. A swap fills the orders at a tick once the price reaches it. On cancel the owner receives the unfilled amount, the filled proceeds, and the order’s share of the limit-order fee. With relativeTick set, each ticks[].id is an offset, in tick-spacing units, from the current tick aligned down to the spacing at execution, and the program rejects the order with ExceededSlippage when that aligned tick has left [spacingAlignedMinTickId, spacingAlignedMaxTickId]. Without it, ticks[].id are absolute tick ids. The owner can approve a delegate on the NFT account (a Token 2022 approve of amount 0) and grant LimitOrderDelegatePermission.CancelLimitOrder with updateLimitOrderDelegatePermission. A delegate canceling an order can only pay into the owner’s associated token accounts, the defaults.

openLimitOrder

Mints a limit-order NFT and places the order. Function
Parameters
Returns { tx, limitOrder, nftAccount }, where limitOrder is deriveLimitOrder(nftMint). Signers: payer, owner, and the nftMint keypair. Example
Notes
  • Ask ticks must lie strictly above the current tick and bid ticks at or below it, on usable ticks of the pool’s spacing (InvalidParameters). The builder checks the tick list, the band, and the alignment before sending.
  • The program fails with ExceededSlippage when the deposit plus its transfer fee exceeds maxAmount.
  • The program creates missing tick arrays, paid by payer. For a relative order the default tickArrays cover every array the band can resolve the ticks to.

cancelLimitOrder

Cancels the order at the given ticks and withdraws what they hold. Function
Parameters
Returns { tx }. Signer: signer. Example
Notes
  • LIMIT_ORDER_REFERRAL_FEE_BPS of the order’s fee goes to referralToken when the order has a referral, the referral is not the NFT owner, and referralToken is owned by it; otherwise the owner keeps the whole fee. referralToken must hold the mint the fee is paid in.
  • When the builder reads the order to default tickIds, it throws InvalidParameters if nothing is left to cancel.

closeLimitOrder

Closes a fully canceled limit order and burns its NFT. Function
Parameters
Returns { tx, limitOrder }. Signer: owner. Notes
  • The program fails with LimitOrderIsNotEmpty until every tick is canceled.

updateLimitOrderDelegatePermission

Sets the permissions of the limit order’s approved delegate. Function
Parameters
Returns { tx }. Signer: owner. Example
Notes
  • Throws InvalidPermission for a mask above MAX_LIMIT_ORDER_DELEGATE_PERMISSION.

Reward Service

client.reward. Rewards need the PoolExtension.LiquidityMining extension. Without it the program fails with InvalidPoolType. A pool has NUM_REWARDS (2) reward slots. The pool creator initializes slot CREATOR_REWARD_INDEX (0) and assigns its reward authority. Operator-managed slots are set up with client.program.methods. Rewards need the pool’s PoolExtension.LiquidityMining extension; without it the program fails with InvalidPoolType. A pool has NUM_REWARDS (2) reward slots. The pool creator initializes slot CREATOR_REWARD_INDEX (0) and assigns its reward authority; operator-managed slots are set up with client.program.methods. A slot’s reward authority funds it with setRewardEmission and withdraws its ineligible reward.

initializeReward

Initializes the creator’s reward slot with a mint and an authority. Function
Parameters
Returns { tx, rewardVault }, where rewardVault is deriveRewardVault(pool, CREATOR_REWARD_INDEX). Signers: creator and payer. Example
Notes
  • Without a tokenBadge the program rejects a reward mint with a freeze authority, or a Token 2022 mint with an extension other than a transfer fee, metadata, or a transfer hook with neither a program nor an authority (UnsupportedMint). Mints in WHITELISTED_QUOTE_MINTS are always accepted.
  • The program fails with InvalidRewardState when the slot is already initialized and InvalidPermission when creator is not the pool creator.

updateRewardAuthority

Replaces the authority of the creator’s reward slot. Function
Parameters
Returns { tx }. Signer: creator. Notes
  • The program fails with RewardUninitialized for an uninitialized slot and InvalidParameters when newAuthority is the current authority.

setRewardEmission

Funds a reward slot and starts its emission. Function
Parameters
Returns { tx, rewardVault }. Signers: funder and authority. Example
Notes
  • The program transfers calculateRewardAmount(endTime - openTime, emissionPerSecond, Rounding.Up) plus the mint’s transfer fee, and fails with ExceededSlippage when that exceeds maxAmount. For a transfer-fee mint, cap with calculateTransferFeeIncludedAmount(mint, epoch, amount).amount.
  • The program requires openTime between now and now plus MAX_REWARD_START_DELAY, and endTime - openTime within MIN_REWARD_DURATION..=MAX_REWARD_DURATION (InvalidParameters). openTime: null starts the emission when the transaction executes, so the duration shrinks by the time the transaction takes to land; pass an explicit future openTime when the duration is near the minimum.
  • The slot must be idle: never funded, or brought up to endTime with no ineligible reward left (InvalidRewardState). After an emission ends, call withdrawIneligibleRewards before funding the slot again; it does both.
  • The program fails with InvalidPermission when authority is not the slot’s reward authority.

claimReward

Refreshes the selected slots and transfers the position’s pending reward from one reward slot. Function
Parameters
Returns { tx } holding the refresh and the claim. Signer: signer. Example
Notes
  • Rewards accrue to a slot when it is refreshed, as with claimFee.
  • A delegate can only pay into the owner’s associated token account, the default userTokenAccount (IncorrectATA).

withdrawIneligibleRewards

Withdraws the reward a slot emitted while the pool had no liquidity. Function
Parameters
Returns { tx }. Signer: authority. Notes
  • The program refreshes the slot and fails with InvalidRewardState until its emission has ended. It transfers calculateRewardAmount(cumulativeSecondsWithEmptyLiquidityReward, emissionPerSecond, Rounding.Down); a zero amount succeeds without a transfer.
  • The program fails with InvalidPermission when authority is not the slot’s reward authority.

State Service

client.state fetches and decodes program accounts at the client’s commitment. Each method throws an Error when the account does not exist or is not owned by the program. The fetch* methods return the Anchor-decoded account. Pool, position-array, tick-array, limit-order and oracle accounts also carry a variable tail that the *With* and decode* methods decode. withReward must match the pool’s liquidity mining extension, because it changes the size of each position and tick. client.state fetches and decodes program accounts at the client’s commitment. Each method throws an Error when the account does not exist or is not owned by the program. The fetch* methods return the Anchor-decoded account; pool, position-array, tick-array, limit-order, and oracle accounts also carry a variable tail that the *With* and decode* methods decode. withReward must match the pool’s liquidity-mining extension, because it changes the size of each position and tick.

fetchPool

Function
Parameters
Returns The Pool account: mints and token flags, reserves, tickSpacing, tickCurrentId, sqrtPrice, liquidity, fee configuration and dynamic fee state, poolStatus, extensions, the inline tick-array bitmap, and the partner’s state. Example

fetchPoolWithExtensions

Function
Parameters
Returns
Example

fetchPositionArrayWithPositions

Function
Parameters
Returns The header and one entry per slot, in slot order.

fetchTickArraysWithTicks

Fetches several tick arrays in one RPC call. Function
Parameters
Returns One entry per address, in the given order.
Example
Notes
  • Throws an Error when any address is missing or not owned by the program.

decodeLimitOrderData

Function
Parameters
Returns One entry per tick the order was placed on.

decodeObservations

Function
Parameters
Returns

fetchTokenBadge

Fetches a token badge from the access-registry program. Function
Parameters
Returns The TokenBadge account: tokenMint and mintScore. Example
Notes
  • Throws an Error when the badge does not exist or is not owned by the access-registry program. Badges are created by access-registry operators.

Other State Methods

Each returns a Promise of the value shown.

Quote Helpers

client.pool.quoteExactIn reads the accounts for you. The pure quoteExactIn export runs the program’s exact-in swap over accounts you already hold, for example from a subscription. It applies dynamic and scheduled fees, market-maker and limit-order liquidity, the collect-fee mode, the protocol, host and partner fee split, and Token 2022 transfer fees. Nothing is fetched. Pass the swap’s tick arrays in traversal order: descending indexes when swapForY, ascending otherwise. tickArraysForSwap returns the first maxTickArrays (default 3) arrays with liquidity from the current tick onward. With amountLeft zero, the quoted input and output amounts match what swap produces against the same accounts and clock. The pure quote throws InvalidParameters when a Token 2022 side has no unpacked mint, and BitmapExtensionAccountIsNotProvided when the traversal leaves the inline bitmap without bitmapExtension. QuoteExactInResult fields:

quoteExactIn (pure)

Runs the program’s exact-in swap over accounts you already hold: dynamic and scheduled fees, market-maker and limit-order liquidity, collect-fee mode, the protocol, host, and partner fee split, and Token 2022 transfer fees. Nothing is fetched. Function
Parameters
Returns
Example
Notes
  • client.pool.quoteExactIn does these reads for you. Call this directly when you already hold the accounts, for example from a subscription.
  • With amountLeft zero, the amounts match what swap produces against the same accounts and clock. The inputs are not modified, so quote consecutive swaps from fresh account state.
  • Throws InvalidParameters when a Token 2022 side has no unpacked mint, a mint does not match the pool, or an ActivationAccess pool has no poolActivation, and BitmapExtensionAccountIsNotProvided when the traversal leaves the inline bitmap without bitmapExtension. Other errors as for client.pool.quoteExactIn.

tickArraysForSwap

Selects the initialized tick arrays a swap traverses, in the order the swap instruction reads them. Function
Parameters
Returns The first maxTickArrays tick arrays with liquidity, from the current tick’s array onward in the swap direction: descending indexes when swapForY, ascending otherwise. requiresBitmapExtension is true when the pool has a bitmap extension, which the swap then needs as tickArrayBitmapExtension. Notes
  • Throws BitmapExtensionAccountIsNotProvided when the pool has an extension and extensionState is missing, and InvalidParameters for a maxTickArrays below 1.

calculateTransferFeeExcludedAmount

Function
Parameters
Returns

calculateTransferFeeIncludedAmount

Function
Parameters
Returns TransferFeeAmount: the amount to send so that transferFeeExcludedAmount arrives, and the fee. Example
Notes
  • Throws MathOverflow when the result does not fit in a u64.

Liquidity Shape Helpers

A liquidity shape gives every tick column [tickId, tickId + tickSpacing) an integer weight up to MAX_LIQUIDITY_WEIGHT (255) and groups the columns into position ranges. addLiquidityByWeight deposits multiplier * weight liquidity into each range, so the weights set the profile and the multiplier sets the size. Spot weighs every column equally. Curve is heaviest at the column holding the current tick and BidAsk is lightest there. LiquidityLayout.Vertical (default) merges adjacent columns of equal weight into side-by-side ranges. Horizontal stacks overlapping ranges, which usually needs fewer ranges for Curve and BidAsk. maxRanges coarsens the weights until the ranges fit. A shape needing more than POSITION_MAX_RANGE ranges throws InvalidParameters. limitOrderTicksFromShape takes unitAmount or totalAmount, not both. From totalAmount the unit is totalAmount / totalWeight rounded down, so up to totalWeight - 1 stays unspent. The returned amount excludes the transfer fee. A liquidity shape gives every tick column [tickId, tickId + tickSpacing) an integer weight up to MAX_LIQUIDITY_WEIGHT (255) and groups the columns into position ranges. The columns run from minTickId to maxTickId, except for StrategyType.Custom, where weights alone defines them. addLiquidityByWeight deposits multiplier * weight liquidity into each range, so the weights set the liquidity profile and the multiplier sets the size. limitOrderTicksFromShape turns the same columns into limit-order ticks.

buildLiquidityShape

Function
Parameters
Returns
Example
Notes
  • Spot weighs every column equally. Curve is heaviest at the column holding the current tick and falls off away from it; BidAsk is lightest there and rises away from it. With the current tick outside the range, Curve is heaviest and BidAsk lightest at the nearest edge. Custom takes weights for usable tick ids, without duplicates; a zero weight leaves a gap. Weights above 255 are scaled down.
  • Vertical merges adjacent columns of equal weight into side-by-side ranges. Horizontal stacks overlapping ranges, one per run of columns at or above each weight level, which usually needs fewer ranges for Curve and BidAsk. Both give every column the same total weight.
  • maxRanges coarsens the weights, in either layout, until the ranges fit; columns then show the reduced weights. Without it, a shape needing more than POSITION_MAX_RANGE ranges throws InvalidParameters, as does a shape that cannot fit maxRanges.
  • Throws InvalidParameters for an unusable tick, minTickId above maxTickId, missing or invalid Custom weights, all-zero weights, or a last column ending past MAX_TICK_ID.

multiplierFromAmounts

Finds the largest multiplier whose deposit fits both token budgets. Function
Parameters
Returns The multiplier for encodeAddLiquidityByWeight. Its deposit, from amountsFromShape, plus transfer fees fits amountX and amountY. Notes
  • Also bounded by the program’s per-tick liquidity cap, assuming the range boundaries hold no liquidity yet; existing liquidity there lowers the cap.
  • Throws InvalidParameters for a weight outside 1..=255, an inverted or unusable range, or budgets too small to fund a multiplier of 1.

encodeAddLiquidityByWeight

Builds the parameters of addLiquidityByWeight from shape ranges. Function
Parameters
Returns { maxAmountX, maxAmountY, expectedLayoutVersion, bitmap, multiplier, liquidities } with one weight byte per slot in ascending slot order. Notes
  • Pass positionIndexes when the ranges go into existing slots other than 0..ranges.length - 1, for example after expandPosition.
  • Throws InvalidParameters for no ranges or more than POSITION_MAX_RANGE, a non-positive multiplier, a weight outside 1..=255, or positionIndexes that do not match the ranges, and LiquidityIsTooHigh when multiplier * weight exceeds i128::MAX.

amountsFromShape

Computes the deposit of each range for a multiplier. Function
Parameters
Returns
Notes
  • Amounts exclude transfer fees. Throws LiquidityIsTooHigh when a range’s liquidity exceeds i128::MAX.

limitOrderTicksFromShape

Turns the columns of one side of a shape into limit-order ticks. Function
Parameters
Returns
Notes
  • An ask takes the weighted columns above the current tick; a bid takes those below the column holding the current tick, plus that column with includeActiveTick.
  • Each tick gets unitAmount * weight. From totalAmount the unit is totalAmount / totalWeight rounded down, so up to totalWeight - 1 stays unspent.
  • amount excludes the transfer fee. For a transfer-fee mint, set maxAmount to calculateTransferFeeIncludedAmount(mint, epoch, amount).amount.
  • Throws InvalidParameters when both or neither amount is given, the unit rounds to zero, or the side has no columns or more than LIMIT_ORDER_MAX_TICK.

relativeTickFromSlippage

Builds the relativeTick band of openLimitOrder. Function
Parameters
Returns { spacingAlignedMinTickId, spacingAlignedMaxTickId }: the current tick aligned down to tickSpacing, minus and plus slippageTicks. Notes
  • Throws InvalidParameters for a tickSpacing outside 1..=MAX_TICK_SPACING or a slippageTicks that is negative or not a multiple of tickSpacing.

tickPrice

Function
Parameters
Returns The price at the tick in atoms of token Y per atom of token X, as a decimal.js Decimal.

tickUiPrice

Function
Parameters
Returns Whole tokens Y per whole token X: tickPrice(tickId) * 10^(decimalsX - decimalsY). Example

Liquidity and Position Helpers

MAX_POSITION_DELEGATE_PERMISSION and MAX_LIMIT_ORDER_DELEGATE_PERMISSION are the masks of every permission. A larger mask throws InvalidPermission. For a transfer-fee mint, pass calculateTransferFeeExcludedAmount(...).amount as the budget to getLiquidityFromAmounts, because maxAmountX and maxAmountY of addLiquidity include the fee.

getLiquidityFromAmounts

Computes the largest liquidity two token budgets fund in a range at the current price. Function
Parameters
Returns The liquidity: from token X alone when the range is above the current tick, from token Y alone when it is at or below, and the smaller of the two when the range contains the current tick. Notes
  • The budgets are pool-side. For a transfer-fee mint, pass calculateTransferFeeExcludedAmount(mint, epoch, budget).amount, because maxAmountX / maxAmountY of addLiquidity include the fee.
  • Throws LiquidityIsZero when the budgets fund no liquidity.

getAmountsFromLiquidity

Computes the token amounts a liquidity change moves in a range at the current price. Function
Parameters
Returns Pool-side amounts, before transfer fees: rounded up for a deposit, down for a withdrawal. Example

liquidityBitmap

Function
Parameters
Returns The slot bitmap the position instructions take. Example
Notes
  • Throws InvalidParameters for an empty list, a duplicate, or an index outside 0..POSITION_MAX_RANGE - 1.

positionIndexesFromBitmap

Function
Parameters
Returns The slot indexes set in bitmap, ascending. Notes
  • Throws InvalidParameters for a zero or negative bitmap, or one with bits at or above POSITION_MAX_RANGE.

positionTotalLiquidity

Function
Parameters
Returns unlockedLiquidity + permanentLockedLiquidity + vestingLiquidity, the liquidity that earns fees.

positionDelegatePermissionMask

Function
Parameters
Returns The mask for updatePositionDelegatePermission. MAX_POSITION_DELEGATE_PERMISSION is the mask of every permission. Notes
  • Throws InvalidPermission for an unknown permission.

limitOrderDelegatePermissionMask

Function
Parameters
Returns The mask for updateLimitOrderDelegatePermission. MAX_LIMIT_ORDER_DELEGATE_PERMISSION is the mask of every permission. Notes
  • Throws InvalidPermission for an unknown permission.

calculateRewardAmount

Function
Parameters
Returns timeDelta * emissionPerSecond / 2^64, rounded as requested, as the program computes reward amounts. Notes
  • Throws TypeCastFailed when the result does not fit in a u64.

Tick Helpers

Tick i has price 1.0001^i (token Y per token X, in atoms), stored as a Q64.64 sqrt price. A tick is usable by a pool when it is a multiple of the pool’s tick spacing within MIN_TICK_ID and MAX_TICK_ID. Tick array n covers the MAX_TICKS_PER_ARRAY (128) usable ticks starting at n * 128 * tickSpacing. Tick i has price 1.0001^i (token Y per token X, in atoms), stored as a Q64.64 sqrt price. A tick is usable by a pool when it is a multiple of the pool’s tick spacing within MIN_TICK_ID..=MAX_TICK_ID. Tick array n covers the MAX_TICKS_PER_ARRAY (128) usable ticks starting at n * 128 * tickSpacing.

getSqrtPriceFromTickId

Function
Parameters
Returns The tick’s Q64.64 sqrt price, sqrt(1.0001^tickId) * 2^64. Example
Notes
  • Throws InvalidParameters for a tick id that is not an integer or lies outside MIN_TICK_ID..=MAX_TICK_ID.

tickIdFromSqrtPrice

Function
Parameters
Returns The tick T with getSqrtPriceFromTickId(T) <= sqrtPrice < getSqrtPriceFromTickId(T + 1). Notes
  • Throws InvalidParameters outside MIN_SQRT_PRICE..=MAX_SQRT_PRICE.

tickIndexFromId

Function
Parameters
Returns The index of the tick array holding tickId. Example
Notes
  • Throws InvalidParameters for a tick spacing outside 1..=MAX_TICK_SPACING.

isUsableTickId

Function
Parameters
Returns Whether tickId is a multiple of tickSpacing within MIN_TICK_ID..=MAX_TICK_ID.

tickArrayIndexesForTickIds

Function
Parameters
Returns The indexes of the tick arrays holding tickIds, deduplicated and ascending.

tickArraysForTickIds

Function
Parameters
Returns The tick arrays holding tickIds, deduplicated and ascending by index: the tickArrays order of the limit-order builders.

tickArraysForRanges

Function
Parameters
Returns The tick arrays of every range endpoint, deduplicated and ascending by index: the arrays the position builders pass. A swap uses tickArraysForSwap instead.

PDA Helpers

Each helper returns the address only. The optional last programId argument defaults to the program in the last column. deriveStaticConfig and deriveDynamicConfig take the index as a BN or a number. deriveRewardVault throws InvalidRewardIndex for an index outside 0 to NUM_REWARDS - 1. For an access-registry operator, pass ACCESS_REGISTRY_PROGRAM_ID to deriveOperator.

Account Helpers

getExtraAccountMetasForTransferHook takes a TransferHookLeg with mint, source, destination and authority. The authority is the user, or derivePoolAuthority() for a transfer out of the pool. The accounts are resolved for a transfer amount of zero. For a hook whose extra accounts depend on the amount, pass the transferHook* array to the builder yourself.

findNftAccount

Function
Parameters
Returns The owner’s Token 2022 associated token account for the NFT, the default nftAccount of every builder.

getTokenProgram

Function
Parameters
Returns TOKEN_PROGRAM_ID for TokenProgramFlags.TokenProgram, TOKEN_2022_PROGRAM_ID for TokenProgramFlags.TokenProgram2022. Example
Notes
  • Throws TypeCastFailed for any other flag.

wrapSOLInstruction

Function
Parameters
Returns A transfer of amount lamports and a sync-native instruction.

unwrapSOLInstruction

Function
Parameters
Returns A close of the owner’s wrapped SOL account.

readClock

Function
Parameters
Returns The Clock sysvar’s slot, unix timestamp, and epoch: the chain time the program checks activation points, reward windows, and transfer-fee epochs against.

getExtraAccountMetasForTransferHook

Resolves the extra accounts a Token 2022 transfer-hook program needs for one transfer. The builders call it for every transfer whose transferHook* array you omit. Function
Parameters
Returns The accounts that follow source, mint, destination, and authority in a Token 2022 transferChecked for this transfer, the slice the program reads from the remaining accounts. Empty for an SPL Token mint or a Token 2022 mint without a hook. Example
Notes
  • The accounts are resolved for a transfer amount of zero. For a hook whose extra accounts depend on the amount, pass the transferHookX, transferHookY, transferHookReferral, or transferHookReward array to the builder yourself.
  • A builder sends an explicit array, including [], as given.

Account Codec Helpers

The raw decoders read the variable tail of account data, for example from an onAccountChange subscription. Each throws an Error when the data is not that account type.

encodePoolExtensions

Function
Parameters
Returns The extensions bitmask for pool initialization. Notes
  • Throws InvalidParameters for an unknown extension.

isSupportExtension

Function
Parameters
Returns Whether extension is set in extensions. Example

Raw Account Decoders

These decode the variable tail of raw account data, for example from an onAccountChange subscription. Each throws an Error when the data is not that account type. Example

Base Fee and Activation Builders

A pool’s base fee is a BaseFeeMode plus 31 bytes of data. The builders take fees in basis points and return the whole baseFeeParameter. They reject schedules pool initialization would reject, with InvalidParameters. The raw encoders produce only data and check that each field fits its integer width. Fee numerators are over FEE_DENOMINATOR (1,000,000,000), so 1,000,000 is 0.1%. Pool initialization requires every fee the schedule can reach to lie within MIN_FEE_NUMERATOR and MAX_FEE_NUMERATOR (0.01% to 99%). TimeSchedulerBpsParams and MarketCapSchedulerBpsParams need startingBaseFeeBps above endingBaseFeeBps, both integers from 1 to 9900, and a non-zero numberOfPeriod. The time scheduler adds totalDuration in slots or seconds per the pool’s activation type. The market cap scheduler adds priceMultiple above 1 and schedulerExpirationDuration. For a constant fee use fixedBaseFeeParameters. A pool with the ActivationAccess extension has two activation slots and three whitelisted wallets (poolActivation). A swap, deposit or withdrawal is allowed only when both slots allow it, unless the swapper, or the position or order owner, is the matching whitelisted wallet. Pool initialization accepts these slot pairs, in this order: Open + Open, Open + BondingCurve, Open + TimeBased, and BondingCurve + TimeBased. Without a TimeBased slot, pass activationPoint: null. A BondingCurve slot needs a whitelistedAddLiquidity other than the default key, since nobody else can deposit before the target. Each TimeBased point must fall between now and now plus MAX_TIME_BUFFER seconds, or MAX_SLOT_BUFFER slots on a slot-activated pool. A pool’s base fee is a BaseFeeMode plus 31 bytes of data. The builders below take fees in basis points and return the whole baseFeeParameter (mode and data); they reject schedules pool initialization would reject (InvalidParameters). The raw encoders produce only data and check that each field fits its integer width. Fee numerators are over FEE_DENOMINATOR (1,000,000,000), so 1,000,000 is 0.1%. Pool initialization requires every fee the schedule can reach to lie within MIN_FEE_NUMERATOR..=MAX_FEE_NUMERATOR (0.01% to 99%). A pool with the ActivationAccess extension has two activation slots and three whitelisted wallets (poolActivation). A swap, deposit, or withdrawal is allowed only when both slots allow it, unless the swapper, or the position or order owner, is the matching whitelisted wallet. Pool initialization accepts these slot pairs, in this order: Open + Open, Open + BondingCurve, Open + TimeBased, BondingCurve + TimeBased. Without a TimeBased slot, activationPoint must be the current point; pass null.

bpsToFeeNumerator

Function
Parameters
Returns The fee over FEE_DENOMINATOR; 1 bps is 100,000.

baseFeeParameters

Picks the builder from baseFeeMode. Equivalent of the damm-v2 SDK’s getBaseFeeParams, with each mode’s fields at the top level instead of in a per-mode sub-object. Function
Parameters
Returns The baseFeeParameter from fixedBaseFeeParameters, timeSchedulerBaseFeeParameters or marketCapSchedulerBaseFeeParameters. Example
Notes
  • The params type is a union keyed on baseFeeMode, so TypeScript requires the fields of the chosen mode.
  • Throws InvalidBaseFeeMode for an unknown mode; other errors come from the chosen builder.

fixedBaseFeeParameters

Function
Parameters
Returns The baseFeeParameter for BaseFeeMode.Fixed. Example

timeSchedulerBaseFeeParameters

A fee that starts at startingBaseFeeBps at the activation point and settles at about endingBaseFeeBps after totalDuration. Equivalent of the damm-v2 SDK’s getFeeTimeSchedulerParams. Function
Parameters
Returns The baseFeeParameter for the chosen time scheduler mode. Example
Notes
  • The starting fee must be above the ending fee; for a constant fee use fixedBaseFeeParameters.
  • The period length is floor(totalDuration / numberOfPeriod), so the fee settles at or before totalDuration.
  • Linear reduction is floored, so the settled fee is at or above the ending fee. Exponential reductionFactor is whole basis points, so the settled fee is at or just above endingBaseFeeBps.
  • Throws InvalidParameters if reductionFactor rounds to zero (too many periods for the fee range).

marketCapSchedulerBaseFeeParameters

A fee that falls as the spot price rises above the initial price, settling at about endingBaseFeeBps at priceMultiple or after schedulerExpirationDuration, whichever comes first. Equivalent of the damm-v2 SDK’s getFeeMarketCapSchedulerParams. Function
Parameters
Returns The baseFeeParameter for the chosen market cap scheduler mode. Example
Notes
  • The starting fee must be above the ending fee; for a constant fee use fixedBaseFeeParameters.
  • The sqrt-price step is floor((sqrt(priceMultiple) - 1) * 10000 / numberOfPeriod) bps, so the fee settles at or before priceMultiple. Throws InvalidParameters if the step rounds to zero.
  • Reduction rounding is as for timeSchedulerBaseFeeParameters.

encodeFixedBaseFeeData

Function
Parameters
Returns data for BaseFeeMode.Fixed.

encodeTimeSchedulerBaseFeeData

A fee that starts at cliffFeeNumerator at the activation point and steps down every periodFrequency slots or seconds. Function
Parameters
Returns data for BaseFeeMode.TimeSchedulerLinear or BaseFeeMode.TimeSchedulerExponential. Example
Notes
  • After n periods the fee is cliffFeeNumerator - reductionFactor * n (linear) or cliffFeeNumerator * (1 - reductionFactor / 10000)^n (exponential), with n capped at numberOfPeriod. Before the activation point the settled fee applies.
  • Pool initialization rejects a zero periodFrequency, reductionFactor, or numberOfPeriod.

encodeMarketCapSchedulerBaseFeeData

A fee that starts at cliffFeeNumerator and steps down as the sqrt price rises above its initial value. Function
Parameters
Returns data for BaseFeeMode.MarketCapSchedulerLinear or BaseFeeMode.MarketCapSchedulerExponential. Notes
  • The step count is (sqrtPrice - initSqrtPrice) * 10000 / initSqrtPrice / sqrtPriceStepBps, capped at numberOfPeriod, and the fee per step follows the time scheduler’s formulas. Before activation and after activationPoint + schedulerExpirationDuration the settled fee applies.
  • Pool initialization rejects a zero reductionFactor, sqrtPriceStepBps, schedulerExpirationDuration, or numberOfPeriod.

getBaseFeeNumerator

Evaluates a pool’s base fee the way the program does. Function
Parameters
Returns The base fee numerator over FEE_DENOMINATOR. A swap adds the dynamic fee, when enabled, and caps the total at MAX_FEE_NUMERATOR. Example
Notes
  • Throws InvalidBaseFeeMode for an unknown mode.

openActivationParameters

Function
Returns An activation slot that allows swaps, deposits, and withdrawals from pool creation.

bondingCurveActivationParameters

Function
Parameters
Returns An activation slot that allows swaps from creation, and deposits and withdrawals once a swap takes the sqrt price to initSqrtPrice * targetIncreaseBps / 10000. The slot stays open after that. Example
Notes
  • Pool initialization requires a whitelistedAddLiquidity other than the default key, since nobody else can deposit before the target, and a target sqrt price no higher than that of MAX_TICK_ID aligned to the tick spacing.

timeBasedActivationParameters

Function
Parameters
Returns An activation slot that opens each action at its point. Example
Notes
  • Pool initialization requires each point between now and now plus MAX_TIME_BUFFER seconds, or MAX_SLOT_BUFFER slots on a slot-activated pool.
  • Throws InvalidParameters for a negative point or one above 2^40 - 1.

Dynamic Fee

getDynamicFeeParams(baseFeeBps, minDeltaTickForSignificantSwap, options?) returns the dynamicFeeParameter for pool initialization. The variable fee stays within 20% of baseFeeBps. Filter, decay and reduction use DYNAMIC_FEE_FILTER_PERIOD, DYNAMIC_FEE_DECAY_PERIOD and DYNAMIC_FEE_REDUCTION_FACTOR. Pass null as dynamicFeeParameter to disable the dynamic fee. getDynamicFeeParams returns the dynamicFeeParameter for pool initialization. The variable fee stays within 20% of baseFeeBps. The volatility cap defaults to a 15% price move (DYNAMIC_FEE_MAX_PRICE_CHANGE_BPS); filter, decay and reduction are DYNAMIC_FEE_FILTER_PERIOD (10 s), DYNAMIC_FEE_DECAY_PERIOD (120 s) and DYNAMIC_FEE_REDUCTION_FACTOR (5,000, 50%).

getDynamicFeeParams

Function
Parameters
Returns The dynamicFeeParameter for poolFees. Example
Notes
  • variableFeeControl is the largest value whose fee at the volatility cap is still within 20% of baseFeeBps.
  • When maxVolatilityAccumulator is set, maxPriceChangeBps is ignored.
  • Throws InvalidParameters when baseFeeBps is outside 0..=10000, minDeltaTickForSignificantSwap is not a non-zero u16, maxPriceChangeBps is outside 1..=10000, or the volatility cap or variableFeeControl does not fit in a u24.

Enums

Values are numbered from 0 in the order listed.

Constants

Core Types

Account and instruction types derived from the IDL, such as Pool, TickRange and SwapParameters, are exported from the package root.

Errors

Builders and helpers throw PoolError for input they can reject before sending. The message names the argument that failed and its constraint. PoolErrorCode uses the program’s error numbering, so the custom error code of a failed transaction maps to the same name. See DLMM Pro program errors for the full list.

Examples

Runnable flows for pools, positions, swaps and limit orders.

Full Function Reference

Every function with all parameters, return types and thrown errors.