import { AnyNumber, Network, InputEntryFunctionData } from '@aptos-labs/ts-sdk'; import { Axios } from 'axios'; declare class TradeSizeExceedsError extends Error { maxAmountIn: string; constructor(_maxAmountIn: string); } type PoolSortBy = "tvl"; declare enum PoolType { AMM = "AMM", CLMM = "CLMM", STABLE = "STABLE" } interface GetPoolsParams { page?: number; size?: number; sortBy?: PoolSortBy; type?: PoolType; } interface PoolToken { addr: string; amount: string; img: string; reserve: string; symbol: string; verified: boolean; } interface GetPools { apr: string; createdAt: string; fee: string; feeTier: string; poolId: string; poolType: PoolType; tokens: PoolToken[]; tvl: string; txns: number; volume: string; volumeData: { volume24h: string; volume30d: string; volume7d: string; volumeprev24h: string; }; volumePercentage24h: string; volumePercentage30d: string; volumePercentage7d: string; } interface PoolInfo { feeTier: string; poolId: string; poolType: PoolType; sqrtPrice: string; tickSpacing: number; tokens: { addr: string; decimals: number; reserve: number; ticker: string; verified: boolean; }[]; totalShare: string; } type PaginatedResult = { data: TData[]; total: number; }; type SimpleResult = TData; type RequestResult = { id: number; jsonrpc: string; method: string; result: TData; usIn: number; usOut: number; usDiff: number; }; type Nullable = T | undefined | null; declare class PoolModule { protected _sdk: TappSDK; constructor(sdk: TappSDK); /** * Fetches a paginated list of liquidity pools from the public API. * * @param params - Optional parameters to control pagination and sorting. * - `page`: The page number to fetch (defaults to 1). * - `size`: Number of items per page (defaults to 10). * - `sortBy`: Field to sort by (defaults to "tvl"). * - `type`: Optional pool type filter. * * @returns {Promise>} A Promise resolving to a paginated result of pools. */ getPools(params?: GetPoolsParams): Promise>; /** * * Retrieves detailed information for a specific liquidity pool. * * @param poolId The unique identifier of the pool to retrieve. * @returns {Promise} A Promise that resolves to the pool information. * @throws ErrorNotFound if the pool does not exist or cannot be found. */ getInfo(poolId: string): Promise; } declare enum LiquidityType { SingleAsset = 0, Imbalance = 1, Ratio = 2 } interface PositionToRemove { positionAddr: string; mintedShare: AnyNumber; minAmount0: AnyNumber; minAmount1: AnyNumber; } interface RemoveSingleAMMLiquidityParams extends PositionToRemove { poolId: string; } interface RemoveMultipleAMMLiquidityParams { poolId: string; positions: PositionToRemove[]; } interface RemoveSingleCLMMLiquidityParams extends PositionToRemove { poolId: string; } interface RemoveMultipleCLMMLiquidityParams { poolId: string; positions: PositionToRemove[]; } interface DefaultWithdrawalParams { positionAddr: string; mintedShare: AnyNumber; amounts: AnyNumber[]; } interface SingleAssetWithdrawalParams { positionAddr: string; mintedShare: AnyNumber; tokenOutIndex: AnyNumber; amount: number; } interface ImbalancedWithdrawalParams { positionAddr: string; maxMintedShare: AnyNumber; amounts: AnyNumber[]; } interface RemoveSingleStableLiquidityParams { poolId: string; liquidityType: LiquidityType; position: DefaultWithdrawalParams | SingleAssetWithdrawalParams | ImbalancedWithdrawalParams; } interface RemoveMultipleStableLiquidityParams { poolId: string; liquidityType: LiquidityType; positions: DefaultWithdrawalParams[] | SingleAssetWithdrawalParams[] | ImbalancedWithdrawalParams[]; } interface AddAMMLiquidityParams { poolId: string; amountA: number; amountB: number; } interface AddCLMMLiquidityParams { poolId: string; minPrice: number; maxPrice: number; amountA: number; amountB: number; fee: number; isMaxAmountB: boolean; } interface AddStableLiquidityParams { poolId: string; amounts: number[]; } interface CreateAMMPoolAndAddLiquidityParams { tokenAddress: string[]; fee: number; amounts: number[]; } interface CreateCLMMPoolAndAddLiquidityParams { tokenAddress: string[]; fee: number; amounts: number[]; initialPrice: number; minPrice: number; maxPrice: number; isMaxAmountB: boolean; } interface CreateStablePoolAndAddLiquidityParams { tokenAddress: string[]; fee: number; amounts: number[]; amplificationFactor: number; offpeg_fee_multiplier?: number; } interface CollectFeeParams { poolId: string; positionAddr: string; } interface GetPositionParams { userAddr: string; page?: number; size?: number; } interface GetPositions { apr: PositionApr; collectedFees: string; estimatedCollectFees: PositionToken[]; estimatedIncentives: PositionToken[]; estimatedWithdrawals: PositionToken[]; feeTier: string; initialDeposits: PositionToken[]; max: string; min: string; mintedShare: string; poolId: string; poolType: string; positionAddr: string; positionIdx: string; shareOfPool: string; sqrtPrice: string; totalEarnings: PositionToken[]; tvl: string; userAddr: string; volume24h: string; } interface PositionApr { boostedAprPercentage: string; campaignAprs: PositionCampaignApr[]; feeAprPercentage: string; totalAprPercentage: string; } interface PositionCampaignApr { apr_percentage: number; campaign_id: string; token_address: string; token_symbol: string; img: string; } interface PositionToken { addr: string; amount: string; decimals: number; idx: number; img: string; symbol: string; usd: string; verified: boolean; } interface SDKConfig { network: Network; url: string; contractAddress: string; sorContractAddress: string; } declare class PositionModule { protected _sdk: TappSDK; constructor(sdk: TappSDK); /** * Creates the input data for removing liquidity from a single AMM pool. * * @param params - Parameters required to remove liquidity, including: * - `poolId`: The ID of the pool to remove liquidity from. * - `positionAddr`: The address of the liquidity position. * - `mintedShare`: The amount of share tokens to burn. * - `minAmount0`: Minimum amount of token0 to receive. * - `minAmount1`: Minimum amount of token1 to receive. * * @returns {InputEntryFunctionData} An object containing the target function identifier and serialized arguments, * which can be used to call the smart contract. */ removeSingleAMMLiquidity(params: RemoveSingleAMMLiquidityParams): InputEntryFunctionData; /** * Creates the input data for removing liquidity from multiple AMM positions in a single transaction. * * @param params - Parameters required to remove multiple liquidity positions, including: * - `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 of token0 to receive. * - `minAmount1`: Minimum amount of token1 to receive. * * @returns {InputEntryFunctionData} An object containing the target function identifier and serialized arguments, * which can be used to call the smart contract. */ removeMultipleAMMLiquidity(params: RemoveMultipleAMMLiquidityParams): InputEntryFunctionData; /** * Creates the input data for removing liquidity from a single CLMM (Concentrated Liquidity Market Maker) position. * * @param params - Parameters required to remove liquidity from a CLMM pool, including: * - `poolId`: The ID of the CLMM pool. * - `positionAddr`: The address of the specific liquidity position. * - `mintedShare`: The amount of share tokens to burn. * - `minAmount0`: Minimum amount of token0 to receive. * - `minAmount1`: Minimum amount of token1 to receive. * * @returns {InputEntryFunctionData} An object containing the function identifier and serialized arguments * used to invoke the `remove_liquidity` function on-chain. */ removeSingleCLMMLiquidity(params: RemoveSingleCLMMLiquidityParams): InputEntryFunctionData; /** * Creates the input data for removing liquidity from multiple CLMM (Concentrated Liquidity Market Maker) positions * in a single transaction. * * @param params - Parameters required to remove multiple liquidity positions, including: * - `poolId`: The ID of the CLMM pool. * - `positions`: An array of objects, each describing a position with: * - `positionAddr`: The address of the liquidity position. * - `mintedShare`: The amount of share tokens to burn. * - `minAmount0`: Minimum amount of token0 to receive. * - `minAmount1`: Minimum amount of token1 to receive. * * @returns {InputEntryFunctionData} An object containing the contract function identifier and serialized arguments * for removing multiple liquidity positions on-chain. */ removeMultipleCLMMLiquidity(params: RemoveMultipleCLMMLiquidityParams): InputEntryFunctionData; /** * Creates the input data for removing liquidity from a single StableSwap-style pool position. * Supports multiple liquidity removal types via a `liquidityType` switch. * * @param params - Parameters required to remove stable liquidity, including: * - `poolId`: The ID of the stable pool. * - `position`: The position object with: * - `positionAddr`: The address of the liquidity position. * - `mintedShare`: (Used for default case) The amount of share tokens to burn. * - `amounts`: (Used for default case) Minimum amounts expected to receive. * - `liquidityType`: Indicates the removal method: * - `0`: Single asset withdrawal. * - `1`: Imbalanced withdrawal. * - Default: Proportional withdrawal using `mintedShare` and `amounts`. * * @returns {InputEntryFunctionData} An object containing the contract function identifier and serialized arguments * for smart contract execution. */ removeSingleStableLiquidity(params: RemoveSingleStableLiquidityParams): InputEntryFunctionData; /** * Creates the input data for removing liquidity from multiple StableSwap-style pool positions * in a single transaction. Supports multiple liquidity removal strategies via `liquidityType`. * * @param params - Parameters for bulk stable liquidity removal, including: * - `poolId`: The ID of the stable pool. * - `positions`: An array of position objects, each containing: * - `positionAddr`: The address of the individual liquidity position. * - `mintedShare`: (Used in default case) The amount of share tokens to burn. * - `amounts`: (Used in default case) The expected minimum token amounts to receive. * - `liquidityType`: Defines the method of liquidity removal: * - `0`: Single asset withdrawal (currently not implemented). * - `1`: Imbalanced withdrawal (currently not implemented). * - Default: Proportional withdrawal using `mintedShare` and `amounts`. * * @returns {InputEntryFunctionData} An object with the smart contract function identifier and the serialized arguments, * allowing the user to remove multiple positions' liquidity on-chain. */ removeMultipleStableLiquidity(params: RemoveMultipleStableLiquidityParams): InputEntryFunctionData; /** * Creates the input data required to add liquidity to an AMM (Automated Market Maker) pool. * * @param params - Parameters used when adding liquidity, including: * - `poolId`: The ID of the AMM pool. * - `amountA`: The amount of token A to add as liquidity. * - `amountB`: The amount of token B to add as liquidity. * * @returns {InputEntryFunctionData} An object containing the contract function string and serialized arguments * required to perform the liquidity addition on-chain. */ addAMMLiquidity(params: AddAMMLiquidityParams): InputEntryFunctionData; /** * Constructs input data for adding liquidity to a CLMM (Concentrated Liquidity Market Maker) pool. * This function encodes amounts, price ranges, and tick information based on pool configuration and input. * * @param params - The parameters needed to add liquidity: * - `poolId`: The unique identifier of the CLMM pool. * - `amountA`: The amount of token A to add. * - `amountB`: The amount of token B to add. * - `fee`: The fee tier of the pool (used to compute tick spacing). * - `isMaxAmountB`: If true, treats `amountB` as the maximum and increases `amountA` by 10%. * - `minPrice`: The minimum price boundary of the liquidity range. * - `maxPrice`: The maximum price boundary of the liquidity range. * * @returns {InputEntryFunctionData} An object containing the target function identifier and serialized arguments * for executing the liquidity addition on-chain. */ addCLMMLiquidity(params: AddCLMMLiquidityParams): InputEntryFunctionData; /** * Constructs the input required to add liquidity to a **Stable Pool**. * Used in cases where multiple assets are pooled together with minimal slippage (e.g., stablecoins). * * @param params - The parameters needed to add liquidity: * - `poolId`: The ID of the stable pool. * - `amounts`: An array of token amounts corresponding to the pool's asset composition. * * @returns {InputEntryFunctionData} An object containing: * - The contract function identifier string. * - A serialized byte array of the input data suitable for blockchain invocation. */ addStableLiquidity(params: AddStableLiquidityParams): InputEntryFunctionData; /** * Creates a new AMM pool and simultaneously adds initial liquidity to it. * * @param params - The parameters required for pool creation and liquidity addition: * - `tokenAddress`: An array of token addresses to be included in the pool. * - `fee`: The fee tier to apply to this pool (typically determines tick spacing and swap cost). * - `amounts`: An array of token amounts to provide as initial liquidity. * * @returns {InputEntryFunctionData} An object containing: * - `function`: The full identifier of the smart contract function being called. * - `functionArguments`: A serialized byte array containing the input data formatted for the contract call. */ createAMMPoolAndAddLiquidity(params: CreateAMMPoolAndAddLiquidityParams): InputEntryFunctionData; /** * Creates a CLMM (Concentrated Liquidity Market Maker) pool and adds initial liquidity in a single transaction. * * @param params - Configuration object containing: * - `tokenAddress`: An array of token addresses involved in the pool. * - `fee`: The fee tier for the pool, which determines tick spacing. * - `amounts`: The initial token amounts to deposit. * - `initialPrice`: The square root price at which the pool starts (used for initialization). * - `minPrice`: The lower bound price of the liquidity range. * - `maxPrice`: The upper bound price of the liquidity range. * - `isMaxAmountB`: Whether the second token amount (`amountB`) is flexible based on slippage. * * @returns {InputEntryFunctionData} An object ready to be used for blockchain interaction, * including the function path and serialized parameters. */ createCLMMPoolAndAddLiquidity(params: CreateCLMMPoolAndAddLiquidityParams): InputEntryFunctionData; /** * Creates a stable swap pool and adds initial liquidity in a single transaction. * * @param params - The configuration object containing: * - `tokenAddress`: An array of token addresses in the pool. * - `fee`: The base swap fee (as a percentage, e.g. `0.003` for 0.3%). * - `amounts`: The initial token amounts to deposit. * - `amplificationFactor`: Amplification factor controlling curve stability (used for low-slippage swaps). * - `offpeg_fee_multiplier`: Optional. Multiplier applied to fee when assets are off-peg. Defaults to `20_000_000_000`. * * @returns {InputEntryFunctionData} An object with the function identifier and encoded arguments * for executing the `create_pool_add_liquidity` function. */ createStablePoolAndAddLiquidity(params: CreateStablePoolAndAddLiquidityParams): InputEntryFunctionData; /** * Collects accrued fees from a specific liquidity position in a given pool. * * @param params - The configuration object containing: * - `poolId`: The address of the pool from which to collect fees. * - `positionAddr`: The address of the liquidity position. * * @returns {InputEntryFunctionData} An object containing: * - `function`: The fully qualified name of the entry function. * - `functionArguments`: A byte array representing the serialized arguments. */ collectFee(params: CollectFeeParams): InputEntryFunctionData; /** * Retrieves a paginated list of liquidity positions for a given user address. * * @param params - An object containing the following: * - `userAddr`: The user's wallet address to fetch positions for. * - `page` (optional): The page number for pagination (defaults to 1). * - `size` (optional): The number of results per page (defaults to 10). * * @returns {Promise>} A object containing: * - `data`: The list of position entries. * - `total`: The total number of positions available. */ getPositions(params: GetPositionParams): Promise>; } declare class RequestModule { protected _http: Axios; constructor(http: Axios); post(method: string, query?: Record): Promise; private _reqId; } interface SwapAMMParams { poolId: string; a2b: boolean; fixedAmountIn?: boolean; amount0: AnyNumber; amount1: AnyNumber; } interface SwapCLMMParams { poolId: string; amountIn: AnyNumber; minAmountOut: AnyNumber; a2b: boolean; fixedAmountIn: boolean; targetSqrtPrice: AnyNumber; } interface SwapStableParams { poolId: string; tokenIn: number; tokenOut: number; amountIn: AnyNumber; minAmountOut: AnyNumber; } type SwapSourceField = "input" | "output"; interface GetEstSwapParams { amount: number; poolId: string; pair: [number, number]; a2b: boolean; field?: SwapSourceField; } interface EstSwapResult { amount: number; estAmount: number; field: SwapSourceField; error?: Error; } interface SwapSORParams { routeMatrix: RouteMatrix[]; amounts: string[]; slippage?: number; } interface GetSOREstSwapParams { poolId?: string; amount: number; fromAddr: string; toAddr: string; field?: SwapSourceField; } interface RouteMatrix { plainPool: PlainPool; fromIdx: number; toIdx: number; } interface PlainPool { poolId: string; tokens: Token[]; sqrtPrice: string; feeTier: string; totalShare: string; liquidity: string; poolType: "CLMM" | "AMM" | "STABLE"; tickSpacing: number; amp: string; offpegFeeMultiplier: string; } interface Token { tokenAddr: string; tokenIdx: number; reserve: string; decimals: number; isVerified: boolean; img: string; ticker: string; color: string; } interface SOREstSwapResult { sourceAmount: string; destAmount: string; sourceField: SwapSourceField; destField: SwapSourceField; amounts: string[]; error?: Error; routeIdx: number; prices: string[]; priceImpact: string; estPriceImpact: string; isExceed: boolean; routeMatrix: RouteMatrix[]; } declare class SwapModule { protected _sdk: TappSDK; constructor(sdk: TappSDK); /** * Creates a transaction payload for executing a swap on an AMM pool. * * @param params - An object containing: * - `poolId`: The address of the pool in which the swap is performed. * - `a2b`: Direction of the swap; `true` for token A to B, `false` for B to A. * - `fixedAmountIn` (optional): Whether the input amount is fixed (defaults to `true`). * - `amount0`: Amount of token A. * - `amount1`: Amount of token B. * * @returns {InputEntryFunctionData} An object representing the transaction payload. */ swapAMMTransactionPayload({ poolId, a2b, fixedAmountIn, amount0, amount1, }: SwapAMMParams): InputEntryFunctionData; /** * Creates a transaction payload for executing a swap on a CLMM (Concentrated Liquidity Market Maker) pool. * * @param params - An object containing: * - `poolId`: The address of the CLMM pool. * - `amountIn`: The input token amount for the swap. * - `minAmountOut`: The minimum acceptable output amount (slippage protection). * - `a2b`: Direction of the swap; `true` for token A to B, `false` for B to A. * - `fixedAmountIn` (optional): Indicates whether `amountIn` is fixed (`true`) or calculated from `minAmountOut` (`false`). Defaults to `true`. * - `targetSqrtPrice`: The target square root price to stop the swap at. * * @returns {InputEntryFunctionData} An object representing the transaction payload to be submitted. */ swapCLMMTransactionPayload({ poolId, amountIn, minAmountOut, a2b, fixedAmountIn, targetSqrtPrice, }: SwapCLMMParams): InputEntryFunctionData; /** * Creates a transaction payload for executing a swap on a Stable pool. * * @param params - An object containing: * - `poolId`: The address of the Stable pool. * - `tokenIn`: The index of the input token in the pool. * - `tokenOut`: The index of the output token in the pool. * - `amountIn`: The input token amount for the swap. * - `minAmountOut`: The minimum acceptable output amount to protect against slippage. * * @returns {InputEntryFunctionData} An object representing the serialized transaction payload. */ swapStableTransactionPayload({ poolId, tokenIn, tokenOut, amountIn, minAmountOut, }: SwapStableParams): InputEntryFunctionData; /** * Estimates the swap output or required input amount for a given pool using the on-chain order book. * * @param params - An object containing: * - `amount`: The amount for estimation (used as input or desired output depending on `field`). * - `poolId`: The identifier of the pool. * - `pair`: 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`: Swap direction — `true` for token at `pair[0]` to `pair[1]`, `false` for `pair[1]` to `pair[0]`. * - `field` (optional): Indicates if `amount` is an `"input"` or `"output"` amount (defaults to `"input"`). * * @returns {Promise}. * * @throws Will throw an error if the order book is missing or malformed. */ getEstSwapAmount(params: GetEstSwapParams): Promise; /** * Retrieves the pool route information between two tokens. * * @param tokenAddr0 - The address of the first token. * @param tokenAddr1 - The address of the second token. * * @returns {Promise} object containing route details between the two tokens. * * @throws {ErrorNotFound} If no route is found between the given tokens. */ getRoute(tokenAddr0: string, tokenAddr1: string): Promise; getSOREstSwapAmount(params: GetSOREstSwapParams): Promise; swapSORTransactionPayload({ routeMatrix, amounts, slippage, }: SwapSORParams): InputEntryFunctionData; } declare class TappSDK { protected _pool: PoolModule; protected _swap: SwapModule; protected _position: PositionModule; protected _sdkConfig: SDKConfig; protected _request: RequestModule; /** * Initializes the SDK with the given configuration. * * @param config - The configuration object containing base URL and other settings. * * Sets up internal modules for: * - HTTP request * - Pool * - Swap * - Position * */ constructor(config: SDKConfig); get Pool(): PoolModule; get Swap(): SwapModule; get Position(): PositionModule; get sdkConfig(): SDKConfig; get request(): RequestModule; } interface InitTappSDKConfig { network?: Network.MAINNET | Network.TESTNET; url?: string; } declare const initTappSDK: (initConfig?: InitTappSDKConfig) => TappSDK; export { type AddAMMLiquidityParams, type AddCLMMLiquidityParams, type AddStableLiquidityParams, type CollectFeeParams, type CreateAMMPoolAndAddLiquidityParams, type CreateCLMMPoolAndAddLiquidityParams, type CreateStablePoolAndAddLiquidityParams, type DefaultWithdrawalParams, type GetPools, type GetPoolsParams, type GetPositionParams, type GetPositions, type ImbalancedWithdrawalParams, LiquidityType, type Nullable, type PaginatedResult, type PoolInfo, type PoolSortBy, type PoolToken, PoolType, type PositionApr, type PositionToken, type RemoveMultipleAMMLiquidityParams, type RemoveMultipleCLMMLiquidityParams, type RemoveMultipleStableLiquidityParams, type RemoveSingleAMMLiquidityParams, type RemoveSingleCLMMLiquidityParams, type RemoveSingleStableLiquidityParams, type RequestResult, type SDKConfig, type SimpleResult, type SingleAssetWithdrawalParams, TradeSizeExceedsError, initTappSDK };