# 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 :

{% file src="/files/pjEt4KDp3KelwD58CTnm" %}

**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.

```solidity
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***

```solidity
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**

```solidity
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);
```

4. **Add Liquidity**&#x20;

```solidity
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);
```

5. **Remove Liquidity**

```solidity
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);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vedex.gitbook.io/docs/technical-docs/concept/write-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
