Skip to main content

Fetching a pool

Caches the pool’s account data, mints, and token programs in one call. Refresh it after a change you expect to have landed on-chain (e.g. before building a deposit against a possibly stale activeBinId):

Swapping and quoting

swapExactIn/swapExactOut/quoteExactIn/quoteExactOut/sync never take a bin-array-count parameter. The quote methods always quote against the protocol’s max traversal window (6 bin arrays) internally; the matching swap method then trims the bin-array set down to only what the quote says it actually needs, plus a one-array drift margin — so you never pay for more accounts than the trade is likely to touch.
Pool.sync(user, desiredBinId) repositions the pool’s active bin toward desiredBinId across empty bins only — also always uses the max traversal window, no count parameter:
The quote engine internally replicates the exact same dynamic-fee decay/accumulate state machine the on-chain program runs, bin by bin — see Fees. This is why quoteExactIn/quoteExactOut need pool.activeBinId and the pool’s live dynamic-fee state, not just a static fee rate.

Handling quote failures

quoteExactIn/quoteExactOut/swapExactIn/swapExactOut reject with a real thrown Error when the underlying quote can’t be filled — catch it rather than assuming a quote always succeeds for a nonzero amount:

Fee rates

Returns the base/dynamic/total fee rate the pool would charge for a swap right now — it decays the dynamic fee state first, the same “clock sim” the on-chain program runs immediately before pricing a real swap, so this reflects what a swap would actually pay rather than a raw, potentially stale, stored volatility accumulator.

Transfer fees

Resolves each mint’s active Token-2022 transfer-fee config from cached mint data. undefined per side means that mint has no TransferFeeConfig extension at all — not that the fee is zero.

Transfer hooks

If either mint carries an active Token-2022 TransferHook, swapExactIn()/swapExactOut() (and every position method) resolve and append its extra accounts automatically — nothing to configure. Pool.resolveTransferHookAccountsX(transferAccounts)/resolveTransferHookAccountsY(transferAccounts) are exposed publicly if you need to resolve them yourself for a custom instruction outside the SDK’s own builders.