aftermath-ts-sdk - v3.3.3
    Preparing search index...

    Wraps one NFT AMM market with NFT reads, unsigned transaction builders, and pool-based quote calculations.

    The class does not sign or execute transactions. Its transaction methods return unsigned Transaction objects that the caller must sign and submit with a wallet that owns the required input objects.

    Hierarchy (View Summary)

    Index
    config: CallerConfig

    The mutable configuration used for subsequent requests.

    Market object and public on-chain market fields.

    pool: Pool

    Pool facade constructed from market.pool for local quote calculations.

    • Calculates the pool spot price from asset coin to fractionalized coin.

      The result is a JavaScript number adjusted for both coins' decimal scalars, not a raw Balance. Set withFees to include pool fees in the spot price; omit it to use the pool calculation's default fee behavior.

      Parameters

      • Optionalinputs: { withFees: boolean }

        Optional withFees flag.

      Returns number

      Fractionalized-coin output units per asset-coin input unit.

    • Calculates the asset-coin amount required to buy a number of NFTs.

      The requested fractionalized output equals nftsCount multiplied by the market's fractionalized amount per NFT. The result is in the asset coin's smallest unit. A defined referral flag enables referral-aware pool math.

      Parameters

      • inputs: { nftsCount: number; referral?: boolean }

        NFT count and optional referral flag.

      Returns bigint

      Required asset-coin input in smallest units.

      Error when the requested trade exceeds pool limits or produces no output.

    • Builds an unsigned transaction that buys the selected NFTs from this market.

      The builder selects the required asset coin from walletAddress, sets that address as the transaction sender, and appends the NFT AMM buy call. The wallet must own enough of the market's asset coin and must sign the returned transaction before execution.

      Parameters

      • inputs: ApiNftAmmBuyBody

        Market ID, wallet address, NFT IDs, decimal slippage, and optional referrer.

      Returns Promise<Transaction>

      An unsigned Sui Transaction with the sender set.

      Error when this facade has no AftermathApi instance.

      AftermathTransportError when coin selection or the API request fails.

    • Calculates LP output for depositing an asset-coin amount.

      The returned lpAmountOut is in LP-coin smallest units. lpRatio is the pool's local JavaScript-number ratio and is not itself a coin amount.

      Parameters

      • inputs: { assetCoinAmountIn: bigint; referral?: boolean }

        Asset-coin amount in smallest units and optional referral flag.

      Returns { lpAmountOut: bigint; lpRatio: number }

      LP amount and the calculated local LP ratio.

      Error when the pool cannot calculate a valid deposit ratio.

    • Builds an unsigned transaction that deposits an asset coin and NFTs into this market.

      The asset amount is in the asset coin's smallest unit. The builder selects that amount from walletAddress, calculates the expected LP ratio, and appends the deposit call. The wallet must own the asset coin and NFT inputs and must sign the returned transaction.

      Parameters

      • inputs: ApiNftAmmDepositBody

        Market ID, wallet address, asset amount, NFT IDs, decimal slippage, and optional referrer.

      Returns Promise<Transaction>

      An unsigned Sui Transaction with the sender set.

      Error when this facade has no AftermathApi instance.

      AftermathTransportError when coin selection or the API request fails.

    • Calculates the pool spot price from fractionalized coin to asset coin.

      The result is a JavaScript number adjusted for both coins' decimal scalars, not a raw Balance. Set withFees to include pool fees in the spot price; omit it to use the pool calculation's default fee behavior.

      Parameters

      • Optionalinputs: { withFees: boolean }

        Optional withFees flag.

      Returns number

      Asset-coin output units per fractionalized-coin input unit.

    • Fetches one page of NFTs stored in the market's dynamic-field table.

      The method uses market.objectId as the dynamic-field parent and defaults limit to 25. cursor is the object ID returned by the previous page's nextCursor; a null result cursor means that the table is exhausted.

      Parameters

      • inputs: { cursor?: string; limit?: number }

        Optional page cursor and maximum number of NFTs.

      Returns Promise<DynamicFieldObjectsWithCursor<Nft>>

      A page of Nft objects and a nullable next cursor.

      Error when this facade was created without an AftermathApi instance.

      AftermathTransportError when dynamic fields or NFT resolution fails.

    • Estimates the spot price of one NFT in asset-coin smallest units.

      The calculation multiplies the pool's asset-to-fractionalized-coin spot price by market.fractionalizedCoinAmount and converts the JavaScript number result to bigint. The conversion therefore has the precision limits of the intermediate number calculation.

      Parameters

      • Optionalinputs: { withFees: boolean }

        Optional withFees flag passed to the pool spot-price calculation.

      Returns bigint

      The estimated asset-coin amount for one NFT, in smallest units.

    • Calculates the asset-coin amount received for selling a number of NFTs.

      The fractionalized input equals nftsCount multiplied by the market's fractionalized amount per NFT. The result is in the asset coin's smallest unit. A defined referral flag enables referral-aware pool math.

      Parameters

      • inputs: { nftsCount: number; referral?: boolean }

        NFT count and optional referral flag.

      Returns bigint

      Asset-coin output in smallest units.

      Error when the requested trade exceeds pool limits or produces no output.

    • Builds an unsigned transaction that sells the selected NFTs to this market.

      The wallet identified by walletAddress must own the NFT objects supplied in nftObjectIds. The returned transaction transfers the calculated asset coin output to that sender when the Move call executes.

      Parameters

      • inputs: ApiNftAmmSellBody

        Market ID, wallet address, NFT IDs, decimal slippage, and optional referrer.

      Returns Promise<Transaction>

      An unsigned Sui Transaction with the sender set.

      Error when this facade has no AftermathApi instance.

    • Estimates the fractionalized-coin output for an LP withdrawal.

      The method converts lpCoinAmount to the pool's local withdrawal ratio and requests a fractionalized-coin output direction equal to one NFT's fractionalized amount. The returned value is in fractionalized-coin smallest units. A defined referral flag enables referral-aware pool math.

      Parameters

      • inputs: { lpCoinAmount: bigint; referral?: boolean }

        LP-coin amount in smallest units and optional referral flag.

      Returns bigint

      Fractionalized-coin output in smallest units.

      Error when the pool withdrawal calculation fails or exceeds limits.

    • Estimates how many whole NFTs correspond to an LP withdrawal.

      The method divides the estimated fractionalized-coin output by the market's fractionalized amount per NFT using bigint integer division, so any partial NFT amount is discarded. The underlying withdrawal calculation may throw when the requested LP amount is outside the pool's supported range.

      Parameters

      • inputs: { lpCoinAmount: bigint; referral?: boolean }

        LP-coin amount in smallest units and optional referral flag.

      Returns bigint

      The minimum whole NFT count as a bigint.

      Error when the underlying withdrawal calculation cannot converge or exceeds pool limits.

    • Builds an unsigned transaction that withdraws LP liquidity and selected NFTs.

      lpCoinAmount is in the LP coin's smallest unit. The builder selects that LP coin from walletAddress, estimates the asset-coin minimum output, and appends the withdraw call. The wallet must own the LP coin and must sign the returned transaction.

      Parameters

      • inputs: ApiNftAmmWithdrawBody

        Market ID, wallet address, LP amount, NFT IDs, decimal slippage, and optional referrer.

      Returns Promise<Transaction>

      An unsigned Sui Transaction with the sender set.

      Error when this facade has no AftermathApi instance.

      AftermathTransportError when coin selection or the API request fails.

    • Returns the canonical Aftermath API host for a Sui network.

      To target a custom or local host, pass baseUrl in CallerConfig to the constructor instead.

      Parameters

      • network: SuiNetwork

        The Sui network whose host to return.

      Returns string

      The network's HTTPS or local HTTP API host.