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

    Provides pool API reads, Move transaction commands, and pool-specific Move error tables for AftermathApi.

    Most methods only build commands. The fetchBuild* methods also select the caller's coin objects and may register a referrer before returning a Transaction.

    Implements

    Index
    • Creates the provider-side pool metadata and Move error table.

      This constructor does not make a network request. It requires both pool package addresses and referral-vault addresses. DAO-fee commands are available only when the provider also supplies DAO-fee addresses.

      Parameters

      Returns PoolsApi

      Error when pool or referral-vault addresses are missing.

    addresses: {
        daoFeePools?: DaoFeePoolsAddresses;
        pools: PoolsAddresses;
        referralVault: ReferralVaultAddresses;
    }

    Addresses of the pool, referral-vault, and optional DAO-fee packages.

    Type Declaration

    buildDaoFeePoolUpdateFeeBpsTx: (
        inputs: { walletAddress: string } & Omit<
            {
                daoFeePoolId: string;
                daoFeePoolOwnerCapId: string;
                lpCoinType: string;
                newFeeBps: bigint;
                tx: Transaction;
            },
            "tx",
        >,
    ) => Transaction = ...

    Builds a standalone transaction that updates a DAO fee in basis points.

    The helper creates a Transaction, sets its sender from walletAddress, and delegates to daoFeePoolUpdateFeeBpsTx.

    buildDaoFeePoolUpdateFeeRecipientTx: (
        inputs: { walletAddress: string } & Omit<
            {
                daoFeePoolId: string;
                daoFeePoolOwnerCapId: string;
                lpCoinType: string;
                newFeeRecipient: string;
                tx: Transaction;
            },
            "tx",
        >,
    ) => Transaction = ...

    Builds a standalone transaction that updates a DAO fee recipient.

    The helper creates a Transaction, sets its sender from walletAddress, and delegates to daoFeePoolUpdateFeeRecipientTx.

    eventTypes: {
        deposit: string;
        depositV2: string;
        trade: string;
        tradeV2: string;
        withdraw: string;
        withdrawV2: string;
    }

    Fully qualified event types recognized by pool indexer reads.

    Type Declaration

    • deposit: string

      The original pool deposit event type.

    • depositV2: string

      The version-two pool deposit event type.

    • trade: string

      The original pool swap event type.

    • tradeV2: string

      The version-two pool swap event type.

    • withdraw: string

      The original pool withdrawal event type.

    • withdrawV2: string

      The version-two pool withdrawal event type.

    moveErrors: MoveErrors

    Move errors grouped by package, module, and numeric error code.

    objectTypes: { daoFeePool?: string; daoFeePoolOwnerCap?: string; pool: string }

    Fully qualified object types recognized by pool object reads.

    Type Declaration

    • OptionaldaoFeePool?: string

      The optional DAO fee pool object type.

    • OptionaldaoFeePoolOwnerCap?: string

      The optional DAO fee owner-cap object type.

    • pool: string

      The on-chain Pool<L> object type prefix.

    • Withdraws all coins from a liquidity pool.

      Parameters

      • inputs: {
            coinTypes: string[];
            lpCoinId: string | TransactionObjectArgument;
            lpCoinType: string;
            poolId: string;
            tx: Transaction;
            withTransfer?: boolean;
        }

        The inputs required for the transaction.

        • coinTypes: string[]

          An array of coin types.

        • lpCoinId: string | TransactionObjectArgument

          The ID of the LP coin.

        • lpCoinType: string

          The type of the LP coin.

        • poolId: string
        • tx: Transaction

          The transaction block. poolId identifies the liquidity pool.

        • OptionalwithTransfer?: boolean

          Whether or not to include a transfer.

      Returns TransactionObjectArgument[]

      An array of transaction objects.

    • Creates a transaction to create a new pool.

      Parameters

      • inputs: {
            coinsInfo: {
                coinId: string | TransactionObjectArgument;
                coinType: string;
                decimals?: number;
                depositFee: bigint;
                tradeFeeIn: bigint;
                tradeFeeOut: bigint;
                weight: bigint;
                withdrawFee: bigint;
            }[];
            createPoolCapId: string
            | TransactionObjectArgument;
            forceLpDecimals?: number;
            lpCoinDescription: string;
            lpCoinIconUrl: string;
            lpCoinMetadata: PoolCreationLpCoinMetadata;
            lpCoinType: string;
            poolFlatness: bigint;
            poolName: string;
            respectDecimals: boolean;
            tx: Transaction;
            withTransfer?: boolean;
        }

        An object containing the necessary inputs to create the pool.

      Returns TransactionObjectArgument[]

      A transaction block to create the pool.

    • Withdraws all coins from a liquidity pool.

      Parameters

      • inputs: {
            coinTypes: string[];
            daoFeePoolId: string;
            lpCoinId: string | TransactionObjectArgument;
            lpCoinType: string;
            tx: Transaction;
        }

        The inputs required for the transaction.

        • coinTypes: string[]

          An array of coin types.

        • daoFeePoolId: string
        • lpCoinId: string | TransactionObjectArgument

          The ID of the LP coin.

        • lpCoinType: string

          The type of the LP coin.

        • tx: Transaction

          The transaction block. poolId identifies the liquidity pool.

      Returns TransactionObjectArgument[]

      An array of transaction objects.

    • Creates a transaction object argument for depositing multiple coins into a pool.

      Parameters

      • inputs: {
            coinIds: string[] | TransactionObjectArgument[];
            coinTypes: string[];
            daoFeePoolId: string;
            expectedLpRatio: bigint;
            lpCoinType: string;
            slippage: number;
            tx: Transaction;
        }

        An object containing the necessary parameters for the deposit transaction.

      Returns TransactionObjectArgument

      A transaction object argument representing the deposit transaction.

    • Adds a DAO fee pool creation command to a transaction.

      The command wraps an existing pool, stores feeBps in basis points, and stores feeRecipient as a Sui address. It is available only when the provider has DAO-fee package addresses.

      Parameters

      • inputs: {
            feeBps: bigint;
            feeRecipient: string;
            lpCoinType: string;
            poolId: string | TransactionObjectArgument;
            tx: Transaction;
        }

        The transaction, pool object, LP type, fee, and recipient.

      Returns TransactionResult

      The transaction result for the Move pool::new call.

      Error when DAO-fee addresses are not configured.

    • Executes a trade transaction on the specified pool.

      Parameters

      • inputs: {
            coinInId: string | TransactionObjectArgument;
            coinInType: string;
            coinOutType: string;
            daoFeePoolId: string;
            expectedCoinOutAmount: bigint;
            lpCoinType: string;
            slippage: number;
            tx: Transaction;
        }

        An object containing the necessary inputs for the trade transaction.

      Returns TransactionObjectArgument

      A TransactionObjectArgument representing the trade transaction.

    • Adds a DAO fee basis-point update command to a transaction.

      The caller must provide the owner-cap object for the DAO fee pool. The newFeeBps value is encoded as Move u16 basis points, where 100 is 1%.

      Parameters

      • inputs: {
            daoFeePoolId: string;
            daoFeePoolOwnerCapId: string;
            lpCoinType: string;
            newFeeBps: bigint;
            tx: Transaction;
        }

        The transaction, owner cap, DAO fee pool, LP type, and new fee.

      Returns TransactionResult

      The transaction result for the Move pool::update_fee_bps call.

      Error when DAO-fee addresses are not configured.

    • Adds a DAO fee recipient update command to a transaction.

      The caller must provide the owner-cap object for the DAO fee pool. The new recipient is encoded as a Sui address by the Move command.

      Parameters

      • inputs: {
            daoFeePoolId: string;
            daoFeePoolOwnerCapId: string;
            lpCoinType: string;
            newFeeRecipient: string;
            tx: Transaction;
        }

        The transaction, owner cap, DAO fee pool, LP type, and recipient.

      Returns TransactionResult

      The transaction result for the Move pool::update_fee_recipient call.

      Error when DAO-fee addresses are not configured.

    • Appends an exact-input pool swap to an existing transaction.

      The method uses coinInAmount and the local Pool math to calculate the expected output, then passes the supplied coin object to tradeTx. It does not select or merge coin objects and does not serialize the transaction.

      Parameters

      • inputs: {
            coinInAmount: bigint;
            coinInId: string | TransactionObjectArgument;
            coinInType: string;
            coinOutType: string;
            pool: Pool;
            referrer?: string;
            slippage: number;
            tx: Transaction;
        }

        The existing transaction, input coin, pool, types, amount, and slippage.

      Returns TransactionObjectArgument

      The output coin transaction argument produced by the swap command.

      When local AMM math rejects the requested trade.

    • Fetches a transaction block that withdraws all coins from a pool in exchange for the corresponding LP tokens.

      Parameters

      • inputs: { lpCoinAmount: bigint; pool: Pool; referrer?: string; walletAddress: string }

        An object containing the wallet address, pool, LP coin amount, and optional referrer.

      Returns Promise<Transaction>

      A promise that resolves to a Transaction object.

    • Fetches a transaction block for depositing in a pool.

      Parameters

      • inputs: {
            amountsIn: CoinsToBalance;
            isSponsoredTx?: boolean;
            pool: Pool;
            referrer?: string;
            slippage: number;
            walletAddress: string;
        }
        • amountsIn: CoinsToBalance

          The amounts of coins being deposited.

        • OptionalisSponsoredTx?: boolean

          Whether the transaction is sponsored.

        • pool: Pool

          The pool to deposit in.

        • Optionalreferrer?: string

          The referrer of the deposit.

        • slippage: number

          The slippage of the deposit.

        • walletAddress: string

          The wallet address of the user depositing in the pool.

      Returns Promise<Transaction>

      A promise that resolves to the fetched transaction block.

    • Fetches a transaction block for trading in a pool.

      Parameters

      • inputs: {
            coinInAmount: bigint;
            coinInType: string;
            coinOutType: string;
            isSponsoredTx?: boolean;
            pool: Pool;
            referrer?: string;
            slippage: number;
            walletAddress: string;
        }
        • coinInAmount: bigint

          The amount of the coin being traded in.

        • coinInType: string

          The coin type of the coin being traded in.

        • coinOutType: string

          The coin type of the coin being traded out.

        • OptionalisSponsoredTx?: boolean

          Whether the transaction is sponsored.

        • pool: Pool

          The pool to trade in.

        • Optionalreferrer?: string

          The referrer of the trade.

        • slippage: number

          The slippage of the trade.

        • walletAddress: string

          The wallet address of the user trading in the pool.

      Returns Promise<Transaction>

      A promise that resolves to the fetched transaction block.

    • Fetches a transaction block for withdrawing from a pool.

      Parameters

      • inputs: {
            amountsOutDirection: CoinsToBalance;
            lpCoinAmount: bigint;
            pool: Pool;
            referrer?: string;
            slippage: number;
            walletAddress: string;
        }
        • amountsOutDirection: CoinsToBalance

          The amounts of coins being withdrawn.

        • lpCoinAmount: bigint

          The amount of LP tokens being withdrawn.

        • pool: Pool

          The pool to withdraw from.

        • Optionalreferrer?: string

          The referrer of the withdrawal.

        • slippage: number

          The slippage of the withdrawal.

        • walletAddress: string

          The wallet address of the user withdrawing from the pool.

      Returns Promise<Transaction>

      A promise that resolves to the fetched transaction block.

    • Creates a transaction object argument for depositing multiple coins into a pool.

      Parameters

      • inputs: {
            coinIds: string[] | TransactionObjectArgument[];
            coinTypes: string[];
            expectedLpRatio: bigint;
            lpCoinType: string;
            poolId: string;
            slippage: number;
            tx: Transaction;
            withTransfer?: boolean;
        }

        An object containing the necessary parameters for the deposit transaction.

      Returns TransactionObjectArgument

      A transaction object argument representing the deposit transaction.

    • Withdraws multiple coins from a pool.

      Parameters

      • inputs: {
            coinTypes: string[];
            expectedAmountsOut: bigint[];
            lpCoinId: string | TransactionObjectArgument;
            lpCoinType: string;
            poolId: string;
            slippage: number;
            tx: Transaction;
            withTransfer?: boolean;
        }

        An object containing the necessary parameters for the transaction.

      Returns TransactionObjectArgument

      A TransactionObjectArgument representing the transaction.

    • Returns the pool object ID for a given LP coin type transaction.

      Parameters

      • inputs: { lpCoinType: string; tx: Transaction }

        An object containing the transaction block and LP coin type.

      Returns TransactionResult

      The pool object ID.

    • Publishes a transaction block for creating a liquidity pool coin.

      Parameters

      • inputs: { lpCoinDecimals: number; tx: Transaction }

        An object containing the transaction block and the decimal value of the liquidity pool coin.

      Returns TransactionResult

      A promise that resolves to the result of the transaction publishing.

    • Executes a trade transaction on the specified pool.

      Parameters

      • inputs: {
            coinInId: string | TransactionObjectArgument;
            coinInType: string;
            coinOutType: string;
            expectedCoinOutAmount: bigint;
            lpCoinType: string;
            poolId: string;
            slippage: number;
            tx: Transaction;
            withTransfer?: boolean;
        }

        An object containing the necessary inputs for the trade transaction.

      Returns TransactionObjectArgument

      A TransactionObjectArgument representing the trade transaction.