View Functions
1. Get Decimals Scales
- Function:
get_decimals_scales<X, Y, Curve>() -> (u64, u64) - Purpose: Retrieves decimal scale factors for the pool’s assets. Which is used in pricing calculations or when displaying token amounts.
2. Get Cumulative Prices
- Function:
get_cumulative_prices<X, Y, Curve>() -> (u128, u128, u64) - Purpose: Fetches the cumulative prices and timestamp for the pool. Which is essential for tracking price changes and calculating time-weighted averages (TWAP).
3. Get Reserves
- Function:
get_reserves_size<X, Y, Curve>() -> (u64, u64) - Purpose: Returns the current reserve sizes for the pool. Which is useful for determining pool health and trade impact.
4. Get Fees Configuration
- Function:
get_fees_config<X, Y, Curve>() -> (u64, u64) - Purpose: Fetches the numerator and denominator of the pool’s fee rate.
5. Get Fee
- Function:
get_fee<X, Y, Curve>() -> u64 - Purpose: Get fee for specific pool
6. Get Dao Fee Configuration
- Function:
get_dao_fees_config<X, Y, Curve>() -> (u64, u64) - Purpose: Get DAO fee for specific pool together with denominator (numerator, denominator).
7. Get Dao Fee
- Function:
get_dao_fee<X, Y, Curve>() -> u64 - Purpose: Get Dao fee for specific pool
8. Check Pool Existence
- Function:
is_swap_exists<X, Y, Curve>() -> bool - Purpose: Checks if a pool exists for the given asset pair.
9. Calculate Optimal Coin Values
- Function:
calc_optimal_coin_values<X, Y, Curve>(x_desired: u64, y_desired: u64, x_min: u64, y_min: u64) -> (u64, u64) - Purpose: Calculates optimal amounts of X and Y for adding liquidity. Call this before
add_liquidityto guide users.
10. Get Amount Out
- Function:
get_amount_out<X, Y, Curve>(amount_in: u64) -> u64 - Purpose: Calculates the output amount for a given input.
11. Get Amount In
- Function:
get_amount_in<X, Y, Curve>(amount_out: u64) -> u64 - Purpose: Calculates the input amount required for a specific output.
12. Get Reserves For LP Coins
- Function:
get_reserves_for_lp_coins<X, Y, Curve>(lp_to_burn_val: u64)-> (u64, u64) - Purpose: Useful to calculate the amount of X,Y coins the user receives after removing liquidity.
Note: All the interfaces mentioned functions are interact with the router module
X and Y represent two different types of tokens:
- Coin: Refers to cryptocurrencies or tokens that are typically used for transactions or value storage.
- Curve: Represents a pair of tokens designed for liquidity pools, categorized into:
- Uncorrelated: Tokens with unrelated price movements (e.g., ETH/USDC).
{contract_address}::curves::Uncorrelated - Stable: Tokens with closely related or fixed values (e.g., USDT/USDC).
{contract_address}::curves::Stable
- Uncorrelated: Tokens with unrelated price movements (e.g., ETH/USDC).