Write Functions

There is the implementation of a single function named execute() that consolidates all actions like Swap, Liquidity, Vote, Bribe, and Reward claim into one convenient transaction. This design makes it straightforward and user-friendly.

For users who are not accustomed to this approach, we have included additional functions compatible with the commonly used Solidly router interface. These functions allow you to specify Token A/B and choose between Volatile or Stable pairs for swaps and adding liquidity, utilizing familiar commands.

For more advanced actions or to optimize gas costs by combining multiple actions in a single transaction, the execute() function is available and is also integrated into our frontend interface. Comprehensive instructions for its usage are provided at the end of the document.

ABI file :

1. Getting pair address for two tokens.

  • Pool itself is a Gauge.

  • We DON'T USE WETH. Use address(0) as token address to find native ETH pairs.

function pairFor(address tokenA, address tokenB, bool stable) public view returns (address pair);

address(0) could be returned when the corresponding pair isn't created yet.

2. Quote swap

Note that it is not a 'view' but in a form of 'write function'. so that you should query with staticCall() to get the result, not just call().

Use address(0) for ETH pairs instead of WETH address

struct route {
       address from;
       address to;
       bool stable;
   }
function getAmountsOut(uint256 amountIn, route[] memory routes) external returns (uint256[] memory amounts);
  • We support all these 3 interface for the swap.

  • Again, We DON'T USE WETH. Use address(0) as token address to use route including native ETH pairs.

3. Execute Swap

function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        route[] calldata routes,
        address to,
        uint256 deadline
    ) external returns (uint256);
function swapExactETHForTokens(
        uint256 amountOutMin, 
        route[] calldata routes, 
        address to, 
        uint256 deadline)
        external
        payable returns (uint256);
function swapExactTokensForETH(
        uint256 amountIn,
        uint256 amountOutMin,
        route[] calldata routes,
        address to,
        uint256 deadline
    ) external returns (uint256);
  1. Add Liquidity

function quoteAddLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 amountADesired,
        uint256 amountBDesired
    ) external view returns (uint256 amountA, uint256 amountB, uint256 liquidity);
    
function addLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);

 function addLiquidityETH(
        address token,
        bool stable,
        uint256 amountTokenDesired,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    )
        external
        payable
        returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
  1. Remove Liquidity

function quoteRemoveLiquidity(address tokenA, address tokenB, bool stable, uint256 liquidity)
        external
        view
        returns (uint256 amountA, uint256 amountB)
function removeLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) public returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
        address token,
        bool stable,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) public returns (uint256 amountToken, uint256 amountETH);

Last updated