For the complete documentation index, see llms.txt. This page is also available as Markdown.

Smart Contract

Smart Contract

We use a BCS (Binary Canonical Serialization) stream to interact with V2, V3, and Stable pool hooks on Aptos. This documentation provides an overview of the serialization and transaction building process using the Aptos SDK in JavaScript/TypeScript.

📚 Table of Contents


Smart Contract Addresses

Use the following addresses to interact with the smart contract:

Kind
Address

View Address

0xf5840b576a3a6a42464814bc32ae1160c50456fb885c62be389b817e75b2a385

Router Address

0x487e905f899ccb6d46fdaec56ba1e0c4cf119862a16c409904b8c78fab1f5e8a

Use this value when referencing routerAddress in your transactions and viewAddress in your view.


Interaction

Before interacting with the smart contracts, you must:

  • Import required classes such as Serializer and AccountAddress from the Aptos SDK.

  • Initialize a serializer instance before sending any transaction data.

  • The transaction examples below are for position v1. Position v2 is an internal flow and is not documented here.


Create Pool

Function

AMM

📝 Parameters

Name
Type
Description
Serialization

poolType

u8

Pool type (2 = V2)

ser.serializeU8(2);

assets

vector<address>

List of coin types (2 addresses)

ser.serializeVector([AccountAddress.fromString(coinA), AccountAddress.fromString(coinB)]);

fee

u64

Fee in basis points (bps)

ser.serializeU64(fee); e.g. 3000 = 0.3%

💡 Example


CLMM

📝 Parameters

Name
Type
Description
Serialization

poolType

u8

Pool type (3 = V3)

ser.serializeU8(3);

assets

vector<address>

List of coin types (2 addresses)

ser.serializeVector([AccountAddress.fromString(coinA), AccountAddress.fromString(coinB)]);

fee

u64

Fee in basis points (bps)

ser.serializeU64(fee); e.g. 3000 = 0.3%

sqrtPrice

u128

Initial square root price for the pool.

ser.serializeU128(sqrtPrice);

💡 Example


Stable

📝 Parameters

Name
Type
Description
Serialization

poolType

u8

Pool type (4 = Stable)

ser.serializeU8(4);

assets

vector<address>

List of coin types (max 4 addresses)

ser.serializeVector([AccountAddress.fromString(coinA), AccountAddress.fromString(coinB)]);

fee

u64

Fee in basis points (bps)

ser.serializeU64(fee); e.g. 3000 = 0.3%

amp

u256

Amplification factor. Value must be between 100 and 1000.

ser.serializeU256(amp);

offPegMultiplier

u256

off peg multiplier.

ser.serializeU256(offpeg_fee_multiplier);

💡 Example


Add Liquidity

Function

AMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddr

address or Option<address>

Address of existing position or None to create new

AccountAddress.fromString(positionAddr).serialize(ser); or ser.serializeOption(null);

amountA

u64

Desired amount of token A

ser.serializeU64(amountA);

amountB

u64

Desired amount of token B

ser.serializeU64(amountB);

minAmountA

u64

Minimum amount of token A (slippage protection)

ser.serializeU64(0);

minAmountB

u64

Minimum amount of token B (slippage protection)

ser.serializeU64(0);

💡 Example


CLMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddr

address or Option<address>

Address of existing position or None to create new

AccountAddress.fromString(positionAddr).serialize(ser); or ser.serializeOption(null);

amountA

u64

Desired amount of token A

ser.serializeU64(amountA);

amountB

u64

Desired amount of token B

ser.serializeU64(amountB);

fixedAmountA

bool

if true then its expect amountA to be fixed.

ser.serializeBool(fixed_amount_a);

lowerTick

u64

Lower Tick

ser.serializeU64(lower_tick);

upperTick

u64

Upper Tick

ser.serializeU64(upper_tick);

💡 Example


Stable

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddr

address or Option<address>

Address of existing position or None to create new

AccountAddress.fromString(positionAddr).serialize(ser); or ser.serializeOption(null);

amounts

vector<u256>

desired amounts for each coin with maximum 4 coins.

ser.serializeVector(amounts.map(amount => new U256(amount)));

minMintAmount

u256

The minimum LP amount

ser.serializeU256(min_mint_amount);

💡 Example


Create Pool And Add Liquidity

Function

AMM

📝 Parameters

Name
Type
Description
Serialization

poolType

u8

Pool type (2 = V2)

ser.serializeU8(2);

assets

vector<address>

List of coin address (2 addresses)

ser.serializeVector([AccountAddress.fromString(coinA), AccountAddress.fromString(coinB)]);

fee

u64

Fee in basis points (bps)

ser.serializeU64(fee); e.g. 3000 = 0.3%

positionAddr

address or Option<address>

Address of existing position or None to create new

AccountAddress.fromString(positionAddr).serialize(ser); or ser.serializeOption(null);

amountA

u64

Desired amount of token A

ser.serializeU64(amountA);

amountB

u64

Desired amount of token B

ser.serializeU64(amountB);

minAmountA

u64

Minimum amount of token A (slippage protection)

ser.serializeU64(0);

minAmountB

u64

Minimum amount of token B (slippage protection)

ser.serializeU64(0);

💡 Example


CLMM

📝 Parameters

Name
Type
Description
Serialization

poolType

u8

Pool type (3 = V3)

ser.serializeU8(3);

assets

vector<address>

List of coin address (2 addresses)

ser.serializeVector([AccountAddress.fromString(coinA), AccountAddress.fromString(coinB)]);

fee

u64

Fee in basis points (bps)

ser.serializeU64(fee); e.g. 3000 = 0.3%

sqrtPrice

u128

Initial square root price for the pool.

ser.serializeU128(sqrtPrice);

amountA

u64

Desired amount of token A

ser.serializeU64(amountA);

amountB

u64

Desired amount of token B

ser.serializeU64(amountB);

fixedAmountA

bool

if true then its expect amountA to be fixed.

ser.serializeBool(fixed_amount_a);

lowerTick

u64

Lower Tick

ser.serializeU64(lower_tick);

upperTick

u64

Upper Tick

ser.serializeU64(upper_tick);

💡 Example


Stable

📝 Parameters

Name
Type
Description
Serialization

poolType

u8

Pool type (4 = Stable)

ser.serializeU8(4);

assets

vector<address>

List of coin address (max 4 addresses)

ser.serializeVector([AccountAddress.fromString(coinA), AccountAddress.fromString(coinB)]);

fee

u64

Fee in basis points (bps)

ser.serializeU64(fee); e.g. 3000 = 0.3%

amp

u256

Amplification factor. Value must be between 100 and 1000.

ser.serializeU256(amp);

offPegMultiplier

u256

off peg multiplier.

ser.serializeU256(offpeg_fee_multiplier);

amounts

vector<u256>

desired amounts for each coin with maximum 4 coins.

ser.serializeVector(amounts.map(amount => new U256(amount)));

minMintAmount

u256

The minimum LP amount

ser.serializeU256(min_mint_amount);

💡 Example


Swap

Function

AMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

aToB

bool

Set to true when swapping from token0 to token1 in the pool.

ser.serializeBool(aToB);

fixedAmountIn

bool

Indicates whether the input amount will remain fixed during the swap.

ser.serializeBool(fixed_amount_in);

amountIn

u64

Quantity of input tokens to swap

ser.serializeU64(amountIn);

amountOutMin

u64

Minimum quantity of output tokens expected from the swap,

ser.serializeU64(amountOutMin);

💡 Example


CLMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

aToB

bool

Set to true when swapping from token0 to token1 in the pool.

ser.serializeBool(aToB);

fixedAmountIn

bool

Indicates whether the input amount will remain fixed during the swap.

ser.serializeBool(fixed_amount_in);

amountIn

u64

Quantity of input tokens to swap

ser.serializeU64(amountIn);

amountOutMin

u64

Minimum quantity of output tokens expected from the swap,

ser.serializeU64(amountOutMin);

targetSqrtPrice

u128

target square root price after swap.

ser.serializeU128(target_sqrt_price);

💡 Example


Stable

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

tokenIn

u64

token index in.

ser.serializeU64(tokenIn);

tokenOut

u64

token index out.

ser.serializeU64(tokenOut);

amountIn

u256

amount in.

ser.serializeU256(amountIn);

minAmountOut

u256

min amount out,

ser.serializeU256(min_amount_out);

💡 Example

Remove Liquidity

Function

AMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddr

address

Address of existing position

ser.serialize(AccountAddress.fromString(positionAddr));

burnedShares

u128

Amount of liquidity provider (LP) tokens or shares to burn/remove from the pool

ser.serializeU128(burnedShares);

minAmountA

u64

Minimum token A amounts to receive when removing liquidity.

ser.serializeU64(minAmountA);

minAmountB

u64

Minimum token B amounts to receive when removing liquidity.

ser.serializeU64(minAmountB);

💡 Example


CLMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddr

address

Address of existing position

ser.serialize(AccountAddress.fromString(positionAddr));

burnedShares

u128

Amount of liquidity provider (LP) tokens or shares to burn/remove from the pool

ser.serializeU128(burnedShares);

minAmountA

u64

Minimum token A amounts to receive when removing liquidity.

ser.serializeU64(minAmountA);

minAmountB

u64

Minimum token B amounts to receive when removing liquidity.

ser.serializeU64(minAmountB);

💡 Example


Stable

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddr

address

Address of existing position

ser.serialize(AccountAddress.fromString(positionAddr));

Type

u8

1 : remove liquidity one coin, 2 : remove liquidity imbalance, 3 : remove liquidity ratio

ser.serializeU8(3)

burnedShare

u256

Amount of liquidity provider (LP) tokens or shares to burn/remove from the pool

ser.serializeU256(shares);

minAmounts

vector<u256>

Minimum token amounts to receive when removing liquidity.

ser.serializeVector(amounts.map(amount => new U256(amount)));

💡 Example


Remove Multi Liquidity

Function

AMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positions.length

u64

Total number of positions

ser.serializeU64(positions.length);

positions.positionAddress

address

Address of existing position

ser.serialize(AccountAddress.fromString(position.positionAddr));

positions.burnedShares

u128

Amount of liquidity provider (LP) tokens or shares to burn/remove from the pool

ser.serializeU128(position.burnedShares);

positions.minAmountA

u64

Minimum token A amounts to receive when removing liquidity.

ser.serializeU64(position.minAmountA);

positions.minAmountB

u64

Minimum token B amounts to receive when removing liquidity.

ser.serializeU64(position.minAmountB);

💡 Example


CLMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positions.length

u64

Total number of positions

ser.serializeU64(positions.length);

positions.positionAddress

address

Address of existing position

ser.serialize(AccountAddress.fromString(position.positionAddr));

positions.burnedShares

u128

Amount of liquidity provider (LP) tokens or shares to burn/remove from the pool

ser.serializeU128(position.burnedShares);

positions.minAmountA

u64

Minimum token A amounts to receive when removing liquidity.

ser.serializeU64(position.minAmountA);

positions.minAmountB

u64

Minimum token B amounts to receive when removing liquidity.

ser.serializeU64(position.minAmountB);

💡 Example


Stable

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positions.length

u64

Total number of positions

ser.serializeU64(positions.length);

positions.positionAddr

address

Address of existing position

ser.serialize(AccountAddress.fromString(position.positionAddr))

positions.type

u8

1 : remove liquidity one coin, 2 : remove liquidity imbalance, 3 : remove liquidity ratio

ser.serializeU8(position.type);

positions.burnedShare

u256

Amount of liquidity provider (LP) tokens or shares to burn/remove from the pool

ser.serializeU128(position.burnedShare);

positions.minAmounts

vector<u256>

Minimum token amounts to receive when removing liquidity.

ser.serializeVector(position.minAmounts.map(amount => new U256(amount)));

💡 Example


Collect Fee

Function

CLMM

📝 Parameters

Name
Type
Description
Serialization

poolId

address

Address of the pool

ser.serialize(AccountAddress.fromString(poolId));

positionAddress

address

Address of existing position

AccountAddress.fromString(positionAddress).serialize(ser);

💡 Example

Gauge Commit / Uncommit

These are direct entry functions in tapp::ve, not BCS-packed router payloads. gauge_commit claims any owed fees before committing the position, and gauge_uncommit claims any owed gauge rewards before releasing it.

Gauge Commit

Function

📝 Parameters

Name
Type
Description

poolAddr

address

Address of the pool

positionAddr

address

Address of the position to commit

positionIdx

Option<u64>

Position index for position v2. Use none() for position v1 flows.

💡 Example

Gauge Uncommit

Function

📝 Parameters

Name
Type
Description

poolAddr

address

Address of the pool

positionAddr

address

Address of the position to uncommit

positionIdx

Option<u64>

Position index for position v2. Use none() for position v1 flows.

💡 Example

🚀 Submitting the Transaction

Once all arguments are serialized, submit the transaction using the Aptos SDK:


View

This documentation provides read-only access to key on-chain data across multiple pool types, including pool state, user positions, and swap simulations. It is intended for developers and integrators to support analytics, UI rendering, and off-chain logic without modifying blockchain state.

Example Usage

To interact with the View API, you can use the views module provided by the aptos framework. This module contains read-only functions that allow you to query various aspects of the AMM, CLMM, and Stable pools without modifying the on-chain state.

Example usage in JavaScript:


AMM View API

The views::amm_views module provides a collection of read-only view functions designed to interact with and retrieve information from AMM (Automated Market Maker) pools. These functions are useful for frontend queries and off-chain data display.


📊 Reserves & Shares

Function reserve_a(pool_addr: address): u64

Returns the reserve amount of token A in the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function reserve_b(pool_addr: address): u64

Returns the reserve amount of token B in the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function total_shares(pool_addr: address): u128

Returns the total number of LP shares for the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


🧾 Positions

Function get_positions(pool_addr: address): vector<amm::amm::Position>

Returns all positions in a given pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function get_position(pool_addr: address, position_idx: u64): amm::amm::Position

Returns the position information for a specific index.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Index of the position within the pool.

💡 Example


Function position_shares(pool_addr: address, position_idx: u64): u128

Returns the number of shares owned by the position.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Index of the position within the pool.

💡 Example


💸 Fees

Function fee_rate(pool_addr: address): u64

Returns the fee rate for the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function fee_rate_denominator(): u64

Returns the denominator used to calculate the fee percentage.

💡 Example


➕ Liquidity Calculations

Function

calc_optimal_lp_amount(desired_amount_a: u64, desired_amount_b: u64, min_amount_a: u64, min_amount_b: u64)

Calculates optimal token amounts to add liquidity while maintaining ratio.

Params

  • desired_amount_a: u64

  • desired_amount_b: u64

  • min_amount_a: u64

  • min_amount_b: u64

💡 Example


Function compute_lp_from_shares(pool_addr: address, shares: u128): (u64, u64)

Calculates the equivalent amounts of token A and B from given LP shares.

Params

  • pool_addr: address – Pool unique identifier.

  • shares: u128 – Number of LP shares to convert.

💡 Example


🔁 Swap Calculations

Function compute_amount_out(pool_addr: address, amount_in: u64, a2b: bool): u64

Returns the estimated output token amount for a given input and direction.

Params

  • pool_addr: address – Pool unique identifier.

  • amount_in: u64 – Amount of input token.

  • a2b: bool – Direction of swap (true: A to B, false: B to A).

💡 Example


Function compute_amount_in(pool_addr: address, amount_out: u64, a2b: bool): u64

Returns the required input token amount to receive a specific output.

Params

  • pool_addr: address – Pool unique identifier.

  • amount_out: u64 – Desired output token amount.

  • a2b: bool – Direction of swap (true: A to B, false: B to A).

💡 Example


CLMM View API

This module contains read-only view functions for accessing the on-chain state of CLMM (Concentrated Liquidity Market Maker) pools and positions. All methods are non-mutating and safe to call for off-chain querying.


Pool-Level Views

Function current_sqrt_price(pool_addr: address): u128

Returns the current square root price of the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function reserve_a(pool_addr: address): u64

Returns the current reserve amount of token A in the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function reserve_b(pool_addr: address): u64

Returns the current reserve amount of token B in the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function liquidity(pool_addr: address): u128

Returns the total liquidity currently in the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function current_tick_idx(pool_addr: address): u64

Returns the current tick index for the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Position-Level Views

Function get_positions(pool_addr: address): vector<clmm::clmm::Position>

Fetches all position objects within the specified pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function get_position(pool_addr: address, position_idx: u64): clmm::clmm::Position

Fetches a specific position by index from the pool.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Index of the position within the pool.

💡 Example


Function position_liquidity(pool_addr: address, position_idx: u64): u128

Returns the amount of liquidity in a specific position.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Position index.

💡 Example


Function position_tick_idxs(pool_addr: address, position_idx: u64): (u64, u64)

Returns the tick lower and upper indices for a position.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Position index.

💡 Example


Function position_fee_growth_inside(pool_addr: address, position_idx: u64): (u128, u128)

Returns the fee growth inside the tick range of a position.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Position index.

💡 Example


Function position_fee_owed(pool_addr: address, position_idx: u64): (u64, u64)

Returns the amount of fees owed to a position.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Position index.

💡 Example


Fee Views

Function fee_rate(pool_addr: address): u64

Returns the fee rate of the pool.

Params

  • pool_addr: address – Pool unique identifier.

💡 Example


Function fee_denominator(): u64

Returns the fixed denominator used in fee calculation.

💡 Example


Swap Simulation

Function

calculate_swap_result(pool_addr: address, a2b: bool, fixed_amount_in: bool, amount: u64): clmm::clmm::CalculatedSwapResult

Simulates a swap and returns the expected result.

Params

  • pool_addr: address – Pool unique identifier.

  • a2b: bool – Direction of the swap (true: A to B, false: B to A).

  • fixed_amount_in: bool – Whether the input amount is fixed.

  • amount: u64 – The amount to swap.

💡 Example


Liquidity Calculations

Function get_amount_by_liquidity(...): (u64, u64)

Returns the token amounts (A, B) corresponding to a given liquidity amount.

Params

  • tick_lower_index: u64 – Lower bound of tick range.

  • tick_upper_index: u64 – Upper bound of tick range.

  • current_tick_index: u64 – Current tick index.

  • current_sqrt_price: u128 – Current square root price.

  • liquidity: u128 – Amount of liquidity.

  • round_up: bool – Whether to round up in calculation.

💡 Example


Function

get_amount_by_liquidity_of(pool_addr: address, position_idx: u64, liquidity: u128, round_up: bool): (u64, u64)

Returns the token amounts (A, B) corresponding to a given liquidity amount in a specific position.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Index of the position.

  • liquidity: u128 – Amount of liquidity.

  • round_up: bool – Whether to round up in calculation.

💡 Example


Function get_liquidity_by_amount(...): (u128, u64, u64)

Returns the liquidity and actual token amounts (A, B) that can be provided with a given token amount.

Params

  • tick_lower_index: u64 – Lower tick index.

  • tick_upper_index: u64 – Upper tick index.

  • current_tick_index: u64 – Current tick index.

  • current_sqrt_price: u128 – Current square root price.

  • amount: u64 – The fixed token amount.

  • is_fixed_a: bool – Whether the fixed amount is token A.

💡 Example


Function

get_liquidity_by_amount_of(pool_addr: address, tick_lower_index: u64, tick_upper_index: u64, amount: u64, is_fixed_a: bool): (u128, u64, u64)

Returns the liquidity and actual token amounts (A, B) that can be provided with a given token amount in a specific position.

Params

  • pool_addr: address – Pool unique identifier.

  • tick_lower_index: u64 – Lower tick index.

  • tick_upper_index: u64 – Upper tick index.

  • amount: u64 – The fixed token amount.

  • is_fixed_a: bool – Whether the fixed amount is token A.

💡 Example


Function get_position_fee_owned(pool_addr: address, position_idx: u64): (u128, u64, u64)

Returns the total fees owed to a position, including fee growth and amounts.

Params

  • pool_addr: address – Pool unique identifier.

  • position_idx: u64 – Index of the position.

💡 Example


Stable View API

This module provides read-only view functions for accessing on-chain data related to Stable Pools. It allows querying pool state, user positions, and swap simulations without modifying blockchain state.


Function n_coins(pool_addr: address): u64

returns the number of coins in the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function rate_multipliers(pool_addr: address): vector<u256>

returns the rate multipliers for each coin in the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function stored_balances(pool_addr: address): vector<u256>

returns the stored balances of each coin in the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function initial_a(pool_addr: address): u256

returns the initial amplification coefficient (A) of the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function future_a(pool_addr: address): u256

returns the future amplification coefficient (A) of the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function initial_a_time(pool_addr: address): u64

returns the timestamp when the initial amplification coefficient (A) was set.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function future_a_time(pool_addr: address): u64

returns the timestamp when the future amplification coefficient (A) will be set.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function total_shares(pool_addr: address): u256

returns the total number of LP shares for the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function fee_rate(pool_addr: address): u256

returns the fee rate for the pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function fee_denominator(): u256

returns the denominator used to calculate the fee percentage.

💡 Example


Function dynamic_fee(pool_addr: address, i: u64, j: u64): u256

returns the dynamic fee rate for a specific coin pair in the pool.

Params

  • pool_addr: address – The address of the pool.

  • i: u64 – The index of the first coin.

  • j: u64 – The index of the second coin.

💡 Example


Function get_positions(pool_addr: address): vector<stable::stable::Position>

returns all positions in a given pool.

Params

  • pool_addr: address – The address of the pool.

💡 Example


Function get_position(pool_addr: address, position_idx: u64): stable::stable::Position

returns the position information for a specific index.

Params

  • pool_addr: address – The address of the pool.

  • position_idx: u64 – The index of the position within the pool.

💡 Example


Function position_shares(pool_addr: address, position_idx: u64): u256

returns the number of shares owned by the position.

Params

  • pool_addr: address – The address of the pool.

  • position_idx: u64 – The index of the position within the pool.

💡 Example


Function get_dx(pool_addr: address, i: u64, j: u64, dy: u256): u256

this function calculates the required input amount (dx) for a given output amount (dy) in a specific coin pair.

Params

  • pool_addr: address – The address of the pool.

  • i: u64 – The index of the first coin.

  • j: u64 – The index of the second coin.

  • dy: u256 – The output amount for the second coin.

💡 Example


Function get_dy(pool_addr: address, i: u64, j: u64, dx: u256): u256

this function calculates the output amount (dy) for a given input amount (dx) in a specific coin pair.

Params

  • pool_addr: address – The address of the pool.

  • i: u64 – The index of the first coin.

  • j: u64 – The index of the second coin.

  • dx: u256 – The input amount for the first coin.

💡 Example


Function calc_token_amount(pool_addr: address, amounts: vector<u256>, is_deposit: bool): u256

this function calculates the amount of LP shares to mint or burn based on the provided token amounts.

Params

  • pool_addr: address – The address of the pool.

  • amounts: vector<u256> – The amounts of each coin to deposit or withdraw.

  • is_deposit: bool – Whether the operation is a deposit (true) or withdrawal (false).

💡 Example


Function calc_withdraw_one_coin(pool_addr: address, burn_amount: u256, i: u64): u256

this function calculates the amount of a specific coin to withdraw when burning LP shares.

Params

  • pool_addr: address – The address of the pool.

  • burn_amount: u256 – The amount of LP shares to burn.

  • i: u64 – The index of the coin to withdraw.

💡 Example


Function calc_ratio_amounts(pool_addr: address, liquidity: u256): vector<u256>

this function calculates the amounts of each coin based on a given liquidity ratio.

Params

  • pool_addr: address – The address of the pool.

  • liquidity: u256 – The liquidity ratio to use for the calculation.

💡 Example

TAPP View API

This documentation provides read-only access to on-chain data for TAPP protocol integrations, including pool metadata, position details, and calculated incentives. These functions help developers query reward information and render pool/position data in applications without requiring transactions.


Function get_pool_metas(): vector<tapp::hook_factory::PoolMeta>

Returns metadata for all TAPP pools.

Params

  • (no parameters)

💡 Example


Function get_pool_meta(pool_addr: address): tapp::hook_factory::PoolMeta

Returns metadata for a specific TAPP pool.

Params

  • pool_addr: address – The address of the TAPP pool.

💡 Example


Function get_position_meta(position_addr: address): tapp::position::PositionMeta

Returns metadata for a specific TAPP position.

Params

  • position_addr: address – The address of the TAPP position.

💡 Example


Function

calc_incentives(user_address: address, pool_addr: address, position_idx: u64): vector<tapp::hook_factory::IncentiveReward>

Calculates incentives for a specific user position in a TAPP pool.

Params

  • user_address: address – The address of the user.

  • pool_addr: address – The address of the TAPP pool.

  • position_idx: u64 – The index of the position within the pool.

💡 Example


Function

calc_incentives_batch(user_address: address, pool_addrs: vector<address>, position_indices: vector<u64>): vector<vector<tapp::hook_factory::IncentiveReward>>

Calculates incentives for multiple user positions across multiple TAPP pools in a single call. This is more efficient than calling calc_incentives individually for each position.

Params

  • user_address: address – The address of the user.

  • pool_addrs: vector<address> – A vector of TAPP pool addresses.

  • position_indices: vector<u64> – A vector of position indices corresponding to each pool address.

💡 Example


veTAPP Smart Contract

The veTAPP (Voting Escrow TAP) contract manages the locking of TAPP tokens into veNFTs. These NFTs represent voting power and entitle owners to rewards and governance participation.

veTAPP Contract Addresses

Kind
Address

veTAPP Address

0xb0745cc707507e46f7c7510b3cbf0c782dd61530b2135e8ceba7efe39bac861f


Gauge Operations

These helpers belong to the veTAPP flow and interact with gauge rewards and voter emissions. The user-facing claim entrypoints live in ve_tapp::voter from packages/ve_tapp/sources/protocol/voter.move. They call into tapp::ve, which then forwards to the gauge package for reward accounting.

fees_voting_reward::earned

Returns the fee reward amount earned by a veTAPP NFT for a specific pool fee token.

Parameters:

  • pool: address - Pool address.

  • ve_token_addr: address - veTAPP NFT address.

  • fee_token_addr: address - Fee token address.

View Function:


bribe_voting_reward::earned

Returns the bribe reward amount earned by a veTAPP NFT for a specific pool bribe token.

Parameters:

  • pool: address - Pool address.

  • ve_token_addr: address - veTAPP NFT address.

  • bribe_token_addr: address - Bribe token address.

View Function:


claim_fees

Claims fee rewards for one or more pools on behalf of the veTAPP NFT owner.

Parameters:

  • caller: &signer - Caller and recipient of the claimed fees.

  • pools: vector<address> - Pools to claim from, in batch order.

  • tokens: vector<vector<address>> - Fee token sets for each pool.

  • ve_token_addr: address - ve token address used for entitlement.

Entry Function:


claim_bribes

Claims bribe rewards for one or more pools on behalf of the veTAPP NFT owner.

Parameters:

  • caller: &signer - Caller and recipient of the claimed bribes.

  • pools: vector<address> - Pools to claim from, in batch order.

  • tokens: vector<vector<address>> - Bribe token sets for each pool.

  • ve_token_addr: address - ve token address used for entitlement.

Entry Function:


Lock

create_lock

Creates a new voting escrow lock by locking TAPP tokens for a specified duration. This mints a new veNFT to the sender.

Parameters:

  • value: u64 - Amount of TAPP tokens to lock.

  • lock_duration: u64 - Duration of the lock in seconds.

Entry Function:


withdraw

Withdraws the locked TAPP tokens after the lock duration has expired. The veNFT is burned upon withdrawal.

Entry Function:

Note: token_addr is the address of the veNFT object.


increase_amount

Increases the amount of TAPP tokens in an existing lock.

Parameters:

  • token_addr: address - The address of the veNFT.

  • value: u64 - Additional amount of TAPP tokens to lock.

Entry Function:


increase_unlock_time

Extends the unlock time of an existing lock.

Parameters:

  • token_addr: address - The address of the veNFT.

  • lock_duration: u64 - Additional duration in seconds to add to the current lock.

Entry Function:


merge

Merges two veNFTs into one. The source veNFT is burned, and its balance and unlock time are merged into the target veNFT.

Parameters:

  • from_nft_addr: address - The address of the veNFT to merge from (will be burned).

  • to_nft_addr: address - The address of the veNFT to merge into.

Entry Function:


split

Splits a veNFT into two. A new veNFT is minted with the specified amount, and the original veNFT's balance is reduced.

Parameters:

  • nft_addr: address - The address of the veNFT to split.

  • value: u64 - Amount of TAPP tokens to move to the new veNFT.

Entry Function:


create_perm_lock

Creates a permanent lock. Permanent locks do not have an expiration time and cannot be withdrawn unless unlocked first.

Parameters:

  • value: u64 - Amount of TAPP tokens to lock.

  • lock_duration: u64 - Duration of the initial lock in seconds.

Entry Function:


create_lock_for

Creates a voting escrow lock for a recipient address instead of the sender.

Parameters:

  • value: u64 - Amount of TAPP tokens to lock.

  • lock_duration: u64 - Duration of the lock in seconds.

  • recipient: address - Address that receives the veNFT.

Entry Function:


create_perm_lock_for

Creates a permanent voting escrow lock for a recipient address.

Parameters:

  • value: u64 - Amount of TAPP tokens to lock.

  • lock_duration: u64 - Duration of the lock in seconds.

  • recipient: address - Address that receives the veNFT.

Entry Function:


deposit_for

Adds more TAPP to an existing veNFT.

Parameters:

  • token_addr: address - The address of the veNFT.

  • value: u64 - Additional amount of TAPP tokens to lock.

Entry Function:


lock_permanent

Marks an existing veNFT as permanent.

Parameters:

  • token_addr: address - The address of the veNFT.

Entry Function:


unlock_permanent

Converts a permanent lock back to a normal lock with a default expiration.

Parameters:

  • token_addr: address - The address of the veNFT.

Entry Function:


📌 Fee Guide

Fee (bps)
% Fee
Description

100

0.01%

Low volume, tight spread

500

0.05%

Standard for stables

3000

0.3%

Normal volatile pairs

10000

1%

Exotic or risky tokens

Last updated