SDK Reference
A fully typed, modular TypeScript SDK for interacting with the TAPP Decentralized Exchange on the Aptos blockchain.
This SDK simplifies tasks such as:
Pool discovery and querying
Swaps (AMM, CLMM, Stable pools)
Creating, adding and removing liquidity (AMM, CLMM, Stable pools)
Collecting fees
📚 Table of Contents
Installation
Initialization
The Tapp TypeScript SDK provides a convenient helper function initTappSDK to initialize the SDK. (Currently only supports MAINNET)
Pool
Get Pool List
Fetches a paginated list of available pools, optionally sorted by TVL or other fields.
Use sdk.Pool.getPools method.
Available params
page:numberThe page number to fetch (defaults to 1).size:numberNumber of items per page (defaults to 10).sortBy:stringField to sort by (defaults to "tvl").type:stringOptional pool type filter. (AMM, CLMM, STABLE)
Get Specific Pool Info
Retrieves detailed information about a specific pool by its ID.
Swap
Estimate Swap Amount
Estimates the amount received or needed for a swap, depending on input direction.
Params
amount:numberThe amount for estimation (used as input or desired output depending onfield).poolId:stringThe identifier of the pool.pair:[number, number]A tuple of token indexes to swap, e.g.,[0, 1]means token at index 0 is being swapped for token at index 1.a2b:booleanSwap direction —truefor token atpair[0]topair[1],falseforpair[1]topair[0].field(optional):input | outputIndicates ifamountis an"input"or"output"amount (defaults to"input").
Get Swap Route
Retrieves the pool route information between two tokens.
Use sdk.Swap.getRoute method
Example
AMM Swap
Creates a swap payload for an AMM pool
Use sdk.Swap.swapAMMTransactionPayload method
Params:
poolId:stringThe address of the pool in which the swap is performed.a2b:booleanDirection of the swap;truefor token A to B,falsefor B to A.fixedAmountIn:booleanWhether the input amount is fixed (defaults totrue).amount0:numberAmount of token A.amount1:numberAmount of token B.
CLMM Swap
Creates a swap payload for a CLMM pool
Params:
poolId:stringThe address of the CLMM pool.amountIn:numberThe input token amount for the swap.minAmountOut:numberThe minimum acceptable output amount.a2b:booleanDirection of the swap;truefor token A to B,falsefor B to A.fixedAmountIn:booleanIndicates whetheramountInis fixed (true).targetSqrtPrice:numberThe target square root price.
Stable Swap
Creates a swap payload for a Stable pool
Params:
poolId:stringThe address of the Stable pool.tokenIn:numberThe Index of the token to swap from.tokenOut:numberThe Index of the token to swap to.amountIn:numberThe input token amount for the swap.minAmountOut:numberThe minimum amount of output tokens.
Liquidity
Create Pool and Add Liquidity
AMM
Creates an AMM pool and adds initial liquidity.
Params
tokenAddress:string[]An array of token addresses.fee:numberThe fee traders will pay to use your pool's liquidity.amounts:number[]The initial token amounts.
CLMM
Creates a CLMM pool and adds initial liquidity.
Params:
tokenAddress:string[]An array of token addresses.fee:numberThe fee traders will pay to Use your pool's liquidity.amounts:number[]The initial token amounts.initialPrice:numberStarting price for liquidity.minPrice:numberThe lower bound price of the liquidity range.maxPrice:numberThe upper bound price of the liquidity range.isMaxAmountB:numberWhether the second token amount (amountB) is flexible based on slippage.
Stable
Creates a Stable pool and adds initial liquidity.
Params:
tokenAddress:string[]An array of token addresses.fee:numberThe fee traders will pay to Use your pool's liquidity.amounts:number[]The initial token amounts.amplificationFactor:numberAmplification factor.offpeg_fee_multiplier:numberOptional. Multiplier applied to fee when assets are off-peg. Defaults to20_000_000_000.
Remove Liquidity
AMM
Removes liquidity from single or multiple AMM positions.
Single Params:
poolId:stringThe ID of the AMM pool.positionAddr:stringThe address of the liquidity position.mintedShare:numberThe amount of share tokens to burn.minAmount0:numberMinimum amount of token0.minAmount1:numberMinimum amount of token1.
Multiple Params:
poolId: The ID of the pool.positions: An array of position objects, each containing:positionAddr: The address of the liquidity position.mintedShare: The amount of share tokens to burn.minAmount0: Minimum amount token0.minAmount1: Minimum amount token1.
CLMM
Removes liquidity from single or multiple CLMM positions.
Single Use sdk.Position.removeSingleCLMMLiquidity method
Params:
poolId:stringThe ID of the CLMM pool.positionAddr:stringThe address of the liquidity position.mintedShare:numberThe amount of share tokens to burn.minAmount0:numberMinimum amount of token0.minAmount1:numberMinimum amount of token1.
Multiple
Use sdk.Position.removeMultipleCLMMLiquidity method
Params:
poolId:stringThe ID of the CLMM pool.positions: An array of objects, each describing a position with:positionAddr:stringThe address of the liquidity position.mintedShare:numberThe amount of share tokens to burn.minAmount0:numberMinimum amount of token0.minAmount1:numberMinimum amount of token1.
Stable
Removes liquidity from single or multiple STABLE positions.
There are 3 types when removing liquidity:
Remove Liquidity One Coin (type = 0) When you want to remove all liquidity and get 1 coin in return, please use this type. Specify the token index for the token you want to retrieve.
Remove Liquidity Imbalance (type = 1) When you want to remove liquidity and retrieve a specific amount for each coin index, please use this type. When using this type, you need to pass the maximum liquidity amount that you want to burn.
Remove Liquidity Ratio (type = 2) Use this type when you want to retrieve amounts based on the current pool liquidity ratio.
Single
Use sdk.Position.removeSingleStableLiquidity method
Params:
poolId:stringThe ID of the stable pool.liquidityType:LiquidityType.LiquidityType.SingleAsset: Single asset withdrawalLiquidityType.Imbalance: Imbalance withdrawalLiquidityType.Ratio: Ratio Withdrawal
position: The position object with (whenliquidityType == LiquidityType.SingleAsset):positionAddr:stringThe address of the individual liquidity position.amount:numberThe minimum token amount to receivemintedShare:numberThe amount of share tokens to burn.tokenOutIndex:numberThe token index to receive.
position: The position object with (whenliquidityType == LiquidityType.Imbalance):positionAddr:stringThe address of the individual liquidity position.maxMintedShare:numberThe maximum amount of share tokens to burn.amounts:number[]The minimum token amounts to receive. The number of items in the amounts must be the same as the number of coins in the pool.
position: The position object with (whenliquidityType == LiquidityType.Ratio):positionAddr:stringThe address of the individual liquidity position.mintedShare:numberThe amount of share tokens to burn.amounts:number[]The minimum token amounts to receive. The number of items in the amounts must be the same as the number of coins in the pool.
Multiple
Use sdk.Position.removeMultipleStableLiquidity method
Params
poolId:stringThe ID of the stable pool.liquidityType:LiquidityType.LiquidityType.SingleAsset: Single asset withdrawalLiquidityType.Imbalance: Imbalance withdrawalLiquidityType.Ratio: Ratio Withdrawal
positions: An array of position objects, each containing (whenliquidityType == LiquidityType.SingleAsset):positionAddr:stringThe address of the individual liquidity position.amount:numberThe minimum token amount to receivemintedShare:numberThe amount of share tokens to burn.tokenOutIndex:numberThe token index to receive.
positions: An array of position objects, each containing (whenliquidityType == LiquidityType.Imbalance):positionAddr:stringThe address of the individual liquidity position.maxMintedShare:numberThe maximum amount of share tokens to burn.amounts:number[]The minimum token amounts to receive.
positions: An array of position objects, each containing (whenliquidityType == LiquidityType.Ratio):positionAddr:stringThe address of the individual liquidity position.mintedShare:numberThe amount of share tokens to burn.amounts:number[]The minimum token amounts to receive.
Add Liquidity to Existing Pools
AMM
Adds liquidity to an AMM pool.
Params
poolId:stringThe ID of the AMM pool.amountA:numberThe amount of token A to add as liquidity.amountB:numberThe amount of token B to add as liquidity.
CLMM
Adds liquidity to a CLMM pool.
Params
poolId:stringThe unique identifier of the CLMM pool.amountA:numberThe amount of token A to add.amountB:numberThe amount of token B to add.fee:numberThe fee tier of the pool.isMaxAmountB:booleanWhether the second token amount (amountB) is flexible based on slippage (e.g. if true, it means amountB can be less than specified due to price movement).minPrice:numberThe minimum price the liquidity range.maxPrice:numberThe maximum price the liquidity range.
Stable
Adds liquidity to a stable pool.
Params
poolId:stringThe ID of the stable pool.amounts:number[]An array of token amounts.
Collect Fee
Collects fees from a specific liquidity position in a given pool.
Use sdk.Position.collectFee method. Params
poolId:stringThe address of the pool from which to collect fees.positionAddr:stringThe address of the liquidity position.
Position
Position
Retrieves a paginated list of liquidity positions for a given user address.
Use sdk.Position.getPositions method.
Params:
userAddr:stringThe user's wallet address to fetch positions for.page(optional):numberThe page number for pagination (defaults to 1).size(optional):numberThe number of results per page (defaults to 10).
Last updated