Creates a local view of a fetched pool object.
The constructor does not make a network request. Supply api when you
need transaction builders. Without it, API-backed transaction methods throw
Error("missing AftermathApi instance").
The fetched PoolObject, including normalized coin balances.
Optionalconfig: CallerConfig
Optional API host, network, and access-token configuration.
Optionalapi: AftermathApi
Optional provider used by transaction builders and referral setup.
Optional ReadonlyapiOptional provider used by transaction builders and referral setup.
The mutable configuration used for subsequent requests.
ReadonlypoolThe fetched PoolObject, including normalized coin balances.
The last statistics object loaded by getStats, or undefined until a
stats read completes. The cache is not refreshed automatically.
Returns the pool coin types in ascending lexicographic order.
An array of coin type strings.
Returns the current DAO fee as a decimal fraction, if configured.
The fee fraction, where 0.01 is 1%, or undefined without a DAO fee pool.
Returns the Sui address that receives the configured DAO fee.
The normalized recipient address, or undefined without a DAO fee pool.
Calculates a proportionate all-coin withdrawal.
Here lpRatio is the fraction of LP supply burned, unlike the retained ratio
accepted by getWithdrawAmountsOut. For example, 0.1 burns 10% and
returns 10% of each pool balance after the configured DAO fee. The referral
flag is accepted for API compatibility but does not alter this local estimate.
Decimal LP fraction to burn. It must be less than 1.
All pool coin amounts in smallest units, after DAO fee adjustment.
Converts an all-coin LP burn amount into the burned pool ratio.
For a supply of 200 and a burn of 50, this method returns 0.25.
LP amount to burn in the LP coin's smallest unit.
The decimal fraction of the pool burned.
Builds a transaction that burns an LP amount and returns every pool coin in proportion to the pool balances.
lpCoinAmount is in LP smallest units. The returned Transaction is
unsigned and not serialized. A configured referrer is registered before the
withdrawal command, but this path does not take a slippage parameter.
Wallet address, LP amount in smallest units, and optional referrer.
An unsigned Transaction containing the all-coin withdrawal.
Calculates the LP result for a fixed-amount liquidity deposit.
lpAmountOut is a smallest-unit LP amount. lpRatio is the decimal
retained-balance scalar used by the CMMM solver. The implementation derives
lpAmountOut as floor(lpCoinSupply * (1 / lpRatio - 1)), so lpRatio is
not itself the minted-LP fraction. The optional referral flag does not alter
this local estimate.
Deposit amounts keyed by coin type in each coin's smallest unit.
The estimated LP smallest-unit amount and the decimal solver ratio.
Builds a transaction that deposits liquidity into this pool.
The method selects the wallet's input coin objects through AftermathApi,
computes an expected LP ratio locally, and adds the Move deposit command.
The returned Transaction is not signed or serialized.
Wallet address, smallest-unit amounts keyed by coin type, and slippage.
An unsigned Transaction containing the deposit commands.
Fetches fee data points for a supported analytics timeframe.
A supported timeframe such as "1D" or "1W".
A promise for API timestamps and numeric fee values.
Fetches deposit and withdrawal events for one wallet in this pool.
cursor and limit are forwarded to the indexer endpoint. When a full
page is returned, the result includes the next numeric cursor.
Wallet address and optional indexer pagination fields.
A promise for paginated PoolDepositEvent and PoolWithdrawEvent values.
Converts a multi-coin LP burn amount into the retained pool ratio.
For a supply of 1_000 and a burn of 100, this method returns 0.9.
LP amount to burn in the LP coin's smallest unit.
The decimal fraction of the pool retained after the burn.
Calculates the instantaneous spot price from one pool coin to another.
The result is a decimal coinIn-per-coinOut ratio adjusted for each
coin's decimal scalar. By default the result excludes swap and DAO fees.
Set withFees to true to include the fee terms used by the local CMMM
calculation.
Input and output coin types, plus the optional fee flag.
The decimal spot-price ratio in coin units, not a smallest-unit bigint.
Fetches the pool's analytics from the Aftermath API and caches the result.
The API returns numeric metrics without a unit conversion in this class.
Inspect the configured API's PoolStats contract for the meaning of each
metric.
A promise for the current PoolStats object. The same object is stored in stats.
Calculates the input for an exact-output swap in this pool.
The input and output are smallest-unit bigint amounts. The local
calculation applies pool, protocol, and DAO fees when reversing the quote.
The referral flag is accepted for API compatibility but does not currently
change this local estimate.
Input type, desired output in smallest units, output type, and optional referral flag.
The required input in coinInType smallest units.
Calculates the output for an exact-input swap in this pool.
The input and return value are smallest-unit bigint amounts. The local
calculation applies the pool swap fees, the protocol fee, and the configured
DAO fee. The referral flag is accepted for API compatibility but does not
currently change this local estimate. A transaction referrer is registered
separately by getTradeTransaction.
Input type, smallest-unit amount, output type, and optional referral flag.
The expected output in coinOutType smallest units.
Builds an unsigned exact-input swap transaction for two pool coin types.
The method computes an expected output in smallest units, selects the input
coin through AftermathApi, registers an optional referrer, and encodes the
expected output with the caller's decimal slippage tolerance. It does not
sign or serialize the returned Transaction.
Wallet address, coin types, input amount in smallest units, and slippage.
An unsigned Transaction containing the swap command.
Builds an unsigned transaction that updates this pool's DAO fee recipient.
The caller must own the daoFeePoolOwnerCapId capability. The recipient is
normalized to a full Sui address before it is encoded in Move.
Wallet address, owner-cap object ID, and new recipient address.
An unsigned Transaction that updates the DAO fee recipient.
Builds an unsigned transaction that updates this pool's DAO fee.
The provider converts newFeePercentage to basis points before encoding the
Move call. The caller must own the daoFeePoolOwnerCapId capability.
Wallet address, owner-cap object ID, and new decimal fee fraction.
An unsigned Transaction that updates the DAO fee in basis points.
Fetches this pool's 24-hour volume from the API.
A promise for the numeric API volume value. This class does not convert its unit.
Fetches volume data points for a supported analytics timeframe.
A supported timeframe such as "1D" or "1W".
A promise for API timestamps and numeric volume values.
Calculates a multi-coin withdrawal for a retained LP ratio and output direction.
lpRatio is the fraction of the original pool balance retained after the
LP burn. For example, 0.9 means that 10% of the LP position is burned.
Positive entries in amountsOutDirection select the direction and relative
amounts. The returned record contains every pool coin in smallest units.
DAO fees are deducted from selected positive outputs. The referral flag is
currently accepted but does not change the local estimate.
Retained LP ratio, output direction, and optional referral flag.
Output amounts keyed by pool coin type, in smallest units.
Estimates a multi-coin withdrawal from an LP amount and selected output types.
The method first estimates each selected coin from the LP share, uses those
amounts as the direction vector, and returns the full pool-coin map produced
by getWithdrawAmountsOut. Amounts are smallest-unit bigint values.
LP amount to burn in smallest units, selected output types, and optional referral flag.
Estimated output amounts keyed by pool coin type, in smallest units.
Builds a transaction that withdraws a fixed LP amount in a selected output direction.
amountsOutDirection describes the relative output direction. The method
computes expected smallest-unit outputs from lpCoinAmount, then encodes
those expectations and slippage in the Move command. The returned
Transaction is unsigned and not serialized.
Wallet address, direction amounts, LP amount in smallest units, and slippage.
An unsigned Transaction containing the withdrawal commands.
Returns [CoinType, PoolCoin] entries sorted by coin type.
An array of coin-type => PoolCoin pairs.
Replaces the local statistics cache without making an API request.
The analytics object to store in stats.
StaticapiReturns the canonical Aftermath API host for a Sui network.
To target a custom or local host, pass baseUrl in CallerConfig to the
constructor instead.
The Sui network whose host to return.
The network's HTTPS or local HTTP API host.
StaticdefaultReturns the canonical Sui fullnode URL for a network.
The network whose fullnode URL to return. undefined
defaults to mainnet.
The network's fullnode URL.
Represents one Aftermath AMM pool and its local math, API reads, and transaction builders.
Coin and LP amounts accepted by this class are
bigintvalues in the corresponding coin's smallest unit. Spot prices are decimalnumberratios. Local calculations use JavaScript floating-point intermediates and can differ from Move by a rounding unit. Transaction builders use the pool estimate as the expected value and pass the caller's slippage to Move for the final check.Example