# UnifiRouter.sol

**Primary Uses** - The uTrade V2 Router is the 'brain' of uTrade. The router finds the optimal path for exchanging one token for another. Whenever a trade is made, your wallet sends funds to the router address. The router will then carry out as many transactions as necessary to acquire the desired token. The router also handles adding liquidity to liquidity pools, and sending the corresponding LP tokens to liquidity providers.

## uTrade V2 Router Code / Interfaces

|                                             |                                                                                                                                   |
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| uTrade V2 Router (Solidity)                 | [Etherscan Verified](https://etherscan.io/address/0x79F12D68631eC6396aAB3CdF31F07C90D0023c9A#code)                                |
| uTrade V2 Router Interface as JSON          | [GitHub](https://github.com/unifiprotocol/uTradeV2-core/blob/52d66be2a472b9697a577757a0446076b6c32001/ABI/JSON/IUnifiRouter.json) |
| uTrade V2 Router Interface as Typescript    | [GitHub](https://github.com/unifiprotocol/uTradeV2-core/blob/52d66be2a472b9697a577757a0446076b6c32001/ABI/TS/IUnifiRouter.ts)     |
| Import statement codeblock (when available) |                                                                                                                                   |

## uTrade V2 Router Contract Addresses

| Network              | Address                                                                                                                                |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| ETH Main Net         | `0x79F12D68631eC6396aAB3CdF31F07C90D0023c9A`([Link](https://etherscan.io/address/0x79F12D68631eC6396aAB3CdF31F07C90D0023c9A))          |
| ETH Ropsten Test Net | `0x2521aaB15347C4C0D7658B5e18e31955Cb496d3B` ([Link](https://ropsten.etherscan.io/address/0x2521aaB15347C4C0D7658B5e18e31955Cb496d3B)) |

## Read-Only Functions <a href="#read-only-functions" id="read-only-functions"></a>

### factory

```
function factory() external pure returns (address);
```

A call to the `factory` function returns the address of the current Factory used by uTrade v2. The current factory address for uTrade V2 on Ethereum is `0x08e7974CacF66C5a92a37c221A15D3c30C7d97e0`.

### WETH

```
function WETH() external pure returns (address);
```

A call to the `WETH` function returns the address of Wrapped ETH (WETH) on Ethereum. As this address does not change, it will always return `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2`.

### quote

```
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
```

A call to the `quote` function returns the amount of *tokenB* that will be received for an amount of *tokenA*. This can be used to calculate the exchange rate between two tokens without factoring in slippage or fees. By entering the amount of *tokenA,* the total amount of reserves of *tokenA* as *reserveA,* and the total amount of reserves of *tokenB* as *reserveB*, the call will return the equivalent amount of *tokenB*.

### getAmountOut

```
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut, uint fee) external pure returns (uint amountOut);
```

A call to the `getAmountOut`function with the amount of the token being sent will return the maximum amount of a token to be received, accounting for fees and the total amount of reserves.

### getAmountIn

```
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut, uint fee) external pure returns (uint amountIn);
```

A call to the `getAmountIn` function with the amount of the token you wish to receive will return the minimum amount required of the token you wish to send, accounting for fees and the total amount of reserves.

### getAmountsOut

```
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
```

A call to the `getAmountsOut` function with the amount of the token being sent will return the maximum amount to be received of multiple different tokens. By entering multiple LP addresses in the *address* array, the function will return the maximum amount of each token that will be received. A call to this function uses the `getReserves` function from [UnifiPair.sol](https://docs.unifiprotocol.com/utrade-v2/ethereum/unifipair.sol) to determine the reserves of the liquidity pool. Then, it calls the `getAmountOut` function to determine the amount of each token in the array that will be received for the *amountIn* value of a token.

### getAmountsIn <a href="#getamountsin" id="getamountsin"></a>

```
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
```

A call to the `getAmountsIn` function with the desired amount of the token to be received will return the minimum amount required to be sent of multiple tokens. By entering multiple LP addresses in the *address* array, the function will return the minimum amount of each token that will need to be sent to receive the desired amount of a token. A call to this function uses the `getReserves` function from [UnifiPair.sol](https://docs.unifiprotocol.com/utrade-v2/ethereum/unifipair.sol) to determine the reserves of the liquidity pool. Then, it calls the `getAmountIn` function to determine the amount of each token in the array that will need to be sent for the *amountOut* value of a token.&#x20;

## State-Changing Functions - Liquidity <a href="#state-changing-functions" id="state-changing-functions"></a>

### addLiquidity

```
function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
```

The `addLiquidity` function adds the two tokens that make up the liquidity pool - *tokenA* and *tokenB* - at the proper ratio based on the reserves of the pool. For example, if the pool contains 3000 USDT / 2 ETH, a user's liquidity will be added at the ratio of 1500 USDT to 1 ETH, provided there is no price movements in the pair between when the user broadcasts the transaction to when it is mined. In the event of a price movement, the *amountADesired*, *amountBDesired*, *amountAMin*, and *amountBMin* act as a security measure against an adverse price movement. After the liquidity is added, the function sends the corresponding LP tokens to the sender.

In the case of a pool not existing for the two assets, one will be created using [UnifiFactory.sol](https://docs.unifiprotocol.com/utrade-v2/ethereum/unififactory.sol) at the ratio of the assets supplied.

#### Function Parameters Breakdown

| Parameter        | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *tokenA*         | address | Token address of the first asset in the token pair.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| *tokenB*         | address | Token address of the second asset in the token pair.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| *amountADesired* | uint    | The amount of *tokenA* to be added to liquidity if the value of *tokenA* goes down in comparison to *tokenB*.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| *amountBDesired* | uint    | The amount of *tokenB* to be added to liquidity if the value of *tokenB* goes down in comparison to *tokenA.*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| *amountAMin*     | uint    | <p>Sets the minimum amount of <em>tokenA</em> that can added to the pool before the transaction reverts. This acts as a safeguard. <br></p><ul><li>If the value of <em>tokenA</em> rapidly increases in comparison to <em>tokenB</em>, the user will require less of <em>tokenA</em> to be added to the pool to maintain the original value of the submitted liquidity.</li><li>A user could potentially be adding liquidity during an outlier spike in value. If the amount of <em>tokenA</em> required falls below this value, the transaction will revert.</li><li>This value must be less than or equal to <em>amountADesired</em>.</li></ul>    |
| *amountBMin*     | uint    | <p>Sets the minimum amount of <em>tokenB</em> that can added to the pool before the transaction reverts. This acts as a safeguard.</p><p></p><ul><li>If the value of <em>tokenB</em> rapidly increases in comparison to <em>tokenA</em>, the user will require less of <em>tokenB</em> to be added to the pool to maintain the original value of the submitted liquidity.</li><li> A user could potentially be adding liquidity during an outlier spike in value. If the amount of <em>tokenB</em> required falls below this value, the transaction will revert.</li><li>This value must be less than or equal to <em>amountBDesired</em>.</li></ul> |
| *to*             | address | The address to which the LP tokens for the uTrade V2 pool will be sent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| *deadline*       | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

#### Function Return Parameter Breakdown

| Parameter   | Type | Description                                                                                                |
| ----------- | ---- | ---------------------------------------------------------------------------------------------------------- |
| *amountA*   | uint | The exact amount of *tokenA* that was sent to the pool.                                                    |
| *amountB*   | uint | The exact amount of *tokenB* that was sent to the pool.                                                    |
| *liquidity* | uint | The exact amount of liquidity tokens minted and sent to the address provided in the *to* paramete&#x72;*.* |

### addLiquidityETH

```
function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
```

The `addLiquidityEth` function is similar to the `addLiquidity` function except it accounts for one token being a native asset. In the case of Ethereum, this native asset would be ETH. This function will convert ETH to WETH, will pair that WETH with the supplied other token, and add the liquidity to the pool. This function will add at the ideal ratio based on when the transaction is mined.\
\
In the case of a pool not existing for WETH and the token provided, one will be created using [UnifiFactory.sol](https://docs.unifiprotocol.com/utrade-v2/ethereum/unififactory.sol) at the ratio of the assets supplied.

* This function requires a *msg.value* with the amount of ETH to be added.&#x20;
  * The *msg.value* acts as the amountETHDesired. As in, if the ratio between ETH and the token being paired with it change, this is the number of ETH that will be added to the pool.
  * Any leftover ETH is returned to the *msg.sender* address.

#### Function Parameter Breakdown

| Parameter                      | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *token*                        | address | The address of the supplied token for the liquidity pool. In other words, the asset that ETH is paired with.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| *amountTokenDesired*           | uint    | The amount of the supplied token to be added to liquidity if the value of token goes down in comparison to ETH.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| (*amountETHDesired*) msg.value | uint    | Sent as the msg.value, the amount of ETH to be added to liquidity if the value of ETH goes down in comparison to token.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| *amountTokenMin*               | uint    | <p>Sets the minimum amount of the supplied token that can added to the pool before the transaction reverts. This acts as a safeguard. </p><p></p><ul><li>If the value of supplied token rapidly increases in comparison to ETH, the user will require less of the token to be added to the pool to maintain the original value of the submitted liquidity.</li><li>A user could potentially be adding liquidity during an outlier spike in value. If the amount of the supplied token required falls below this value, the transaction will revert.</li><li>This value must be less than or equal to <em>amountTokenDesired</em>.</li></ul> |
| *amountETHMin*                 | uint    | <p></p><p>Sets the minimum amount of ETH that can added to the pool before the transaction reverts. This acts as a safeguard. </p><p></p><ul><li>If the value of ETH increases in comparison to the supplied token, the user will require less ETH to be added to the pool to maintain the original value of the submitted liquidity.</li><li>A user could potentially be adding liquidity during an outlier spike in value. If the amount of ETH required falls below this value, the transaction will revert.</li><li>This value must be less than or equal to <em>amountETHDesired</em>.</li></ul>                                       |
| *to*                           | address | The address to which the LP tokens for the uTrade V2 pool will be sent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| *deadline*                     | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

#### Function Return Parameter Breakdown

| Parameter     | Type | Description                                                                                                |
| ------------- | ---- | ---------------------------------------------------------------------------------------------------------- |
| *amountToken* | uint | The exact amount of the supplied token sent to the pool.                                                   |
| *amountETH*   | uint | The exact amount of ETH converted to WETH, and then added to the pool.                                     |
| *liquidity*   | uint | The exact amount of liquidity tokens minted and sent to the address provided in the *to* paramete&#x72;*.* |

### removeLiquidity

```
function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
) external returns (uint amountA, uint amountB);
```

The `removeLiquidity` function removes the two tokens that make up liquidity from a pool. In other words, this function is used when the pool consists of two ERC-20 tokens.

* In the event one of the assets is paired with ETH, ETH will have been wrapped and paired with WETH (Wrapped Ether). If the user wishes to withdraw WETH instead of withdrawing as ETH, this function should be used instead of `removeLiquidityETH` .

#### Function Parameter Breakdown

| Parameter    | Type    | Description                                                                                                                                                                                                              |
| ------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| *tokenA*     | address | Token address of the first asset in the pair.                                                                                                                                                                            |
| *tokenB*     | address | Token address of the second asset in the pair.                                                                                                                                                                           |
| *liquidity*  | uint    | The amount of liquidity tokens to be redeemed and removed.                                                                                                                                                               |
| *amountAMin* | uint    | Sets the minimum amount of *tokenA* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *amountBMin* | uint    | Sets the minimum amount of *tokenB* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *to*         | address | The address to where the redeemed tokens will be sent.                                                                                                                                                                   |
| *deadline*   | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                           |

#### Function Return Parameter Breakdown

| Parameter | Title | Description                                                                      |
| --------- | ----- | -------------------------------------------------------------------------------- |
| *amountA* | uint  | The exact amount of *tokenA* sent to the address provided in the *to* parameter. |
| *amountB* | uint  | The exact amount of *tokenB* sent to the address provided in the *to* parameter. |

### removeLiquidityETH

```
function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
) external returns (uint amountToken, uint amountETH);
```

The `removeLiquidityETH` function removes ETH as well as the corresponding paired token in the liquidity pool. In other words, this function is used when the pool consists of WETH and an ERC-20 token.

* In the event one of the assets is paired with ETH, ETH has been wrapped into WETH (Wrapped Ether). This function will unwrap the WETH as the liquidity removed. If the user wishes to withdraw WETH instead of withdrawing as ETH, the `removeLiquidity` function should be used.

#### Function Parameter Breakdown

| Parameter        | Type    | Description                                                                                                                                                                                                             |
| ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *token*          | address | Token address of the ERC-20 asset in the pair.                                                                                                                                                                          |
| *liquidity*      | uint    | The amount of liquidity tokens to be redeemed and removed.                                                                                                                                                              |
| *amountTokenMin* | uint    | Sets the minimum amount of *token* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *amountETHMin*   | uint    | Sets the minimum amount of ETH to be removed from the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts.         |
| *to*             | address | The address to where ETH and token will be sent.                                                                                                                                                                        |
| *deadline*       | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                          |

#### Function Return Parameter Breakdown

| Parameter     | Value | Description                                                                     |
| ------------- | ----- | ------------------------------------------------------------------------------- |
| *amountToken* | uint  | The exact amount of *token* sent to the address provided in the *to* parameter. |
| *amountETH*   | uint  | The exact amount of ETH sent to the address provided in the *to* parameter.     |

### removeLiquidityWithPermit

```
function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
```

The `removeLiquidityWithPermit` functions removes the two tokens that make up liquidity from a pool. In other words, this function is used when the pool consists of two ERC-20 tokens. This function operates similarly to the `removeLiquidity` function with the added benefit of not requiring pre-approvals using permit.

* In the event one of the assets is paired with ETH, ETH will have been wrapped and paired with WETH (Wrapped ETH). If the user wishes to withdraw WETH instead of withdrawing as ETH, this function should be used instead of `removeLiquidityETHWithPermit` .

#### Function Parameter Breakdown

| Parameter    | Type    | Description                                                                                                                                                                                                              |
| ------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| *tokenA*     | address | Token address of the first asset in the pair.                                                                                                                                                                            |
| *tokenB*     | address | Token address of the second asset in the pair.                                                                                                                                                                           |
| *liquidity*  | uint    | The amount of liquidity tokens to be redeemed and removed.                                                                                                                                                               |
| *amountAMin* | uint    | Sets the minimum amount of *tokenA* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *amountBMin* | uint    | Sets the minimum amount of *tokenB* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *to*         | address | The address to where the redeemed tokens will be sent.                                                                                                                                                                   |
| *deadline*   | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                           |
| *approveMax* | bool    | Sets a true or false value on if approval amount in the signature is for liquidity or for uint(-1).                                                                                                                      |
| *v*          | uint8   | The v value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                         |
| *r*          | bytes32 | The r value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                         |
| *s*          | bytes32 | The s value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                         |

#### Function Return Parameter Breakdown

| Parameter | Title | Description                                                                      |
| --------- | ----- | -------------------------------------------------------------------------------- |
| *amountA* | uint  | The exact amount of *tokenA* sent to the address provided in the *to* parameter. |
| *amountB* | uint  | The exact amount of *tokenB* sent to the address provided in the *to* parameter. |

### removeLiquidityETHWithPermit

```
function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
    
```

The `removeLiquidityETHWithPermit` function removes ETH as well as the corresponding paired token in the liquidity pool. In other words, this function is used when the pool consists of WETH and a ERC-20 token. This function operates similarly to the `removeLiquidityETH`function with the added benefit of not requiring pre-approvals using permit.

* In the event one of the assets is paired with ETH, ETH has been wrapped into WETH (Wrapped Ether). This function will unwrap the WETH as the liquidity removed. If the user wishes to withdraw WETH instead of withdrawing as ETH, the `removeLiquidityWithPermit` function should be used.

#### Function Parameter Breakdown

| Parameter        | Type    | Description                                                                                                                                                                                                             |
| ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *token*          | address | Token address of the ERC-20 asset in the pair.                                                                                                                                                                          |
| *liquidity*      | uint    | The amount of liquidity tokens to be redeemed and removed.                                                                                                                                                              |
| *amountTokenMin* | uint    | Sets the minimum amount of *token* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *amountETHMin*   | uint    | Sets the minimum amount of ETH to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts.     |
| *to*             | address | The address to where ETH and token will be sent.                                                                                                                                                                        |
| *deadline*       | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                          |
| *v*              | uint8   | The v value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                        |
| *r*              | bytes32 | The r value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                        |
| *s*              | bytes32 | The s value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                        |

#### Function Return Parameter Breakdown

| Parameter     | Value | Description                                                                     |
| ------------- | ----- | ------------------------------------------------------------------------------- |
| *amountToken* | uint  | The exact amount of *token* sent to the address provided in the *to* parameter. |
| *amountETH*   | uint  | The exact amount of ETH sent to the address provided in the *to* parameter.     |

### removeLiquidityETHSupportingFeeOnTransferTokens

```
function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
) external returns (uint amountETH);
```

The `removeLiquidityETHSupportingFeeOnTransferTokens`function is similar to the `removeLiquidityETH` function, and contains the same call parameters. This function removes ETH as well as the corresponding paired token in the liquidity pool. In other words, this function is used when the pool consists of WETH and a ERC-20 token.&#x20;

However, this function allows for fee on transfer tokens, such as PAXG, to be used on uTrade.&#x20;

#### Function Parameter Breakdown

| Parameter        | Type    | Description                                                                                                                                                                                                             |
| ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *token*          | address | Token address of the ERC-20 asset in the pair.                                                                                                                                                                          |
| *liquidity*      | uint    | The amount of liquidity tokens to be redeemed and removed.                                                                                                                                                              |
| *amountTokenMin* | uint    | Sets the minimum amount of *token* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *amountETHMin*   | uint    | Sets the minimum amount of ETH to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts.     |
| *to*             | address | The address to where ETH and the paired token will be sent.                                                                                                                                                             |
| *deadline*       | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                          |

#### Function Return Parameter Breakdown

| Parameter   | Value | Description                                                                                                                                                                                                                   |
| ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountETH* | uint  | The exact amount of ETH sent to the address provided in the *to* parameter. Note that the *amountToken* parameter is not returned. The amount of fee on transfer that a token may have is not available prior to transaction. |

### removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

```
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
```

The `removeLiquidityETHWithPermitSupportingFeeOnTransferTokens`function is similar to the `removeLiquidityETHWithPermit`function. This function removes ETH as well as the corresponding paired token in the liquidity pool. In other words, this function is used when the pool consists of WETH and an ERC-20 token. This function operates similarly to the `removeLiquidityETHfunction` with the added benefit of not requiring pre-approvals using permit. In addition, this function allows for fee on transfer tokens, such as PAXG, to be used on uTrade.&#x20;

#### Function Parameter Breakdown

| Parameter        | Type    | Description                                                                                                                                                                                                             |
| ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *token*          | address | Token address of the ERC-20 asset in the pair.                                                                                                                                                                          |
| *liquidity*      | uint    | The amount of liquidity tokens to be redeemed and removed.                                                                                                                                                              |
| *amountTokenMin* | uint    | Sets the minimum amount of *token* to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts. |
| *amountETHMin*   | uint    | Sets the minimum amount of ETH to be removed from the the pool. This acts as a safeguard against removing liquidity during a spike in value. If the removed amount falls below this value, the transaction reverts.     |
| *to*             | address | The address to where ETH and token will be sent.                                                                                                                                                                        |
| *deadline*       | uint    | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                          |
| *v*              | uint8   | The v value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                        |
| *r*              | bytes32 | The r value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                        |
| *s*              | bytes32 | The s value of the permit. This is one of the three values that makes up the approval signature.                                                                                                                        |

#### Function Return Parameter Breakdown

| Parameter   | Value | Description                                                                                                                                                                                                                   |
| ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountETH* | uint  | The exact amount of ETH sent to the address provided in the *to* parameter. Note that the *amountToken* parameter is not returned. The amount of fee on transfer that a token may have is not available prior to transaction. |

## State-Changing Functions - Swap

### swapExactTokensForTokens

```
function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
) external returns (uint[] memory amounts);
```

The `swapExactTokensForTokens` function sends an exact amount of tokens for the maximum amount of another token.&#x20;

#### Function Parameter Breakdown

| Parameter      | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountIn*     | uint                | The amount of tokens being sent to swap into another token                                                                                                                                                                                                                                                                                                                                                                             |
| *amountOutMin* | uint                | Sets the minimum amount of the desired token to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                                    |
| *path*         | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p> |
| *to*           | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                   |
| *deadline*     | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                         |

#### Function Return Parameter Breakdown

| Parameter | Type           | Description                                                                                                |
| --------- | -------------- | ---------------------------------------------------------------------------------------------------------- |
| *amounts* | uint\[] memory | The exact amount of tokens sent into the swap, as well as the exact return amount of all subsequent swaps. |

### swapTokensForExactTokens

```
function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
) external returns (uint[] memory amounts);
```

The `swapTokensForExactTokens` function sends the minimum amount of tokens for the exact amount of another token.&#x20;

#### Function Parameter Breakdown

| Parameter     | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountOut*   | uint                | The exact amount of the desired tokens to be received.                                                                                                                                                                                                                                                                                                                                                                                 |
| *amountInMax* | uint                | Sets the maximum amount of token to be sent in. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be sent rises above this value, the transaction reverts.                                                                                                                                                                                                                                 |
| *path*        | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p> |
| *to*          | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                   |
| *deadline*    | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                         |

#### Function Return Parameter Breakdown

| Parameter | Type           | Description                                                                                                |
| --------- | -------------- | ---------------------------------------------------------------------------------------------------------- |
| *amounts* | uint\[] memory | The exact amount of tokens sent into the swap, as well as the exact return amount of all subsequent swaps. |

### swapExactETHForTokens

```
function swapExactETHForTokens(
        uint amountOutMin, 
        address[] calldata path, 
        address to, 
        uint deadline)
        external
        payable
returns (uint[] memory amounts);
```

The `swapExactETHForTokens` function sends an exact amount of ETH for a desired token.

#### Function Parameter Breakdown

| Parameter                                           | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><em>(amountIn)</em></p><p><em>msg.value</em></p> | uint                | Sent as the msg.value, the amount of ETH to be swapped.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| *amountOutMin*                                      | uint                | Sets the minimum amount of the desired token to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                                                                                                                            |
| *path*                                              | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p><p></p><p>As the first swap is swapping ETH to WETH, the first address must be WETH.</p> |
| *to*                                                | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| *deadline*                                          | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                                                                                                                 |

#### Function Return Parameter Breakdown

| Parameter | Type           | Description                                                                                             |
| --------- | -------------- | ------------------------------------------------------------------------------------------------------- |
| *amounts* | uint\[] memory | The exact amount of ETH sent into the swap, as well as the exact return amount of all subsequent swaps. |

### swapTokensForExactETH

```
function swapTokensForExactETH(
        uint amountOut, 
        uint amountInMax, 
        address[] calldata path, 
        address to, 
        uint deadline)
        external
        returns (uint[] memory amounts);
```

The `swapTokensForExactETH` function sends an amount of tokens for an exact amount of ETH.

#### Function Parameter Breakdown

| Parameter     | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountOut*   | uint                | The exact amount of the ETH to be received.                                                                                                                                                                                                                                                                                                                                                                                            |
| *amountInMax* | uint                | Sets the maximum amount of token to be sent in. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be sent rises above this value, the transaction reverts.                                                                                                                                                                                                                                 |
| *path*        | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p> |
| *to*          | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                   |
| *deadline*    | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                         |

#### Function Return Parameter Breakdown

| Parameter | Type           | Description                                                                                         |
| --------- | -------------- | --------------------------------------------------------------------------------------------------- |
| *amounts* | uint\[] memory | The exact amount of tokens sent into the swap, as well as the exact amount of all subsequent swaps. |

### swapExactTokensForETH

```
function swapExactTokensForETH(
        uint amountIn, 
        uint amountOutMin, 
        address[] calldata path, 
        address to, 
        uint deadline)
        external
        returns (uint[] memory amounts);
```

The `swapExactTokensForETH` function sends an exact amount of tokens for ETH.

#### Function Parameter Breakdown

| Parameter      | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountIn*     | uint                | The amount of tokens being sent to swap into ETH.                                                                                                                                                                                                                                                                                                                                                                                      |
| *amountOutMin* | uint                | Sets the minimum amount of the ETH to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                                              |
| *path*         | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p> |
| *to*           | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                   |
| *deadline*     | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                         |

#### Function Parameter Return Breakdown

| Parameter | Type           | Description                                                                                         |
| --------- | -------------- | --------------------------------------------------------------------------------------------------- |
| *amounts* | uint\[] memory | The exact amount of tokens sent into the swap, as well as the exact amount of all subsequent swaps. |

### swapETHForExactTokens

```
function swapETHForExactTokens(
        uint amountOut, 
        address[] calldata path, 
        address to, 
        uint deadline)
        external
        payable
        returns (uint[] memory amounts);
```

The `swapETHForExactTokens` function swaps an exact amount of ETH for an amount of the desired token.

#### Function Parameter Breakdown

| Parameter                                           | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><em>(amountIn)</em></p><p><em>msg.value</em></p> | uint                | Sent as the msg.value, the amount of ETH to be swapped.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| *amountOutMin*                                      | uint                | Sets the minimum amount of the desired token to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                                                                                                                            |
| *path*                                              | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p><p></p><p>As the first swap is swapping ETH to WETH, the first address must be WETH.</p> |
| *to*                                                | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| *deadline*                                          | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                                                                                                                 |

#### Function Return Parameter Breakdown

| Parameter | Type           | Description                                                                                             |
| --------- | -------------- | ------------------------------------------------------------------------------------------------------- |
| *amounts* | uint\[] memory | The exact amount of ETH sent into the swap, as well as the exact return amount of all subsequent swaps. |

### swapExactTokensForTokensSupportingFeeOnTransferTokens

```
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
) external;
```

The `swapExactTokensForTokensSupportingFeeOnTransferTokens` function is similar to `swapExactTokensForTokens` as it swaps one ERC-20 token for another ERC-20 token. In addition, this function allows for fee on transfer tokens, such as PAXG, to be used on uTrade.

#### Function Parameter Breakdown

| Name           | Type                |                                                                                                                                                                                                                                                                                                                                                                                                                              |
| -------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountIn*     | uint                | The amount of tokens being sent to swap into another token.                                                                                                                                                                                                                                                                                                                                                                  |
| *amountOutMin* | uint                | Sets the minimum amount of the desired token to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                          |
| *path*         | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The path represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required.</p> |
| *to*           | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                         |
| *deadline*     | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                               |

### swapExactETHForTokensSupportingFeeOnTransferTokens

```
function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
 ) external payable;
```

The `swapExactETHForTokensSupportingFeeOnTransferTokens`function  is similar to `swapExactETHForTokens` function as it swaps an exact amount of ETH for ERC-20 tokens. In addition, this function allows for fee on transfer tokens, such as PAXG, to be used on uTrade.&#x20;

#### Function Parameter Breakdown

| Parameter                                           | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><em>(amountIn)</em></p><p><em>msg.value</em></p> | uint                | Sent as the msg.value, the exact amount of ETH to be swapped.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| *amountOutMin*                                      | uint                | Sets the minimum amount of the desired token to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                                                                                                                            |
| *path*                                              | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p><p></p><p>As the first swap is swapping ETH to WETH, the first address must be WETH.</p> |
| *to*                                                | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| *deadline*                                          | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                                                                                                                 |

### swapExactTokensForETHSupportingFeeOnTransferTokens <a href="#swapexacttokensforethsupportingfeeontransfertokens" id="swapexacttokensforethsupportingfeeontransfertokens"></a>

```
function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
) external;
```

The function `swapExactTokensForETHSupportingFeeOnTransferTokens`is similar to the `swapExactTokensForETH`function, as it swaps an exact amount of ERC-20 tokens for ETH. In addition, this function allows for fee on transfer tokens, such as PAXG, to be used on uTrade.

#### Function Parameter Breakdown

| Parameter      | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *amountIn*     | uint                | The amount of tokens being sent to swap into ETH.                                                                                                                                                                                                                                                                                                                                                                                      |
| *amountOutMin* | uint                | Sets the minimum amount of the ETH to receive. This acts as a safeguard against removing liquidity during a spike in value. If the amount to be received falls below this value, the transaction reverts.                                                                                                                                                                                                                              |
| *path*         | address\[] calldata | <p>The pathway to change one token to another, consisting of an array of addresses. Each token must have an existing liquidity pool, as well as have liquidity.<br></p><p>The <em>path</em> represents the pathway from one token to another. If a pair exists for the two tokens you wish to exchange, this will contain two values inside of an array. However, if there is no direct pair, multiple addresses may be required. </p> |
| *to*           | address             | The address to where the desired token will be sent.                                                                                                                                                                                                                                                                                                                                                                                   |
| *deadline*     | uint                | The UNIX timestamp for which this transaction must be completed. If the transaction is mined after this deadline, the transaction will revert.                                                                                                                                                                                                                                                                                         |

## Interface Code

```
interface IUnifiRouter01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut, uint fee) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut, uint fee) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

interface IUnifiRouter02 is IUnifiRouter01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}
```


---

# 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://docs.unifiprotocol.com/utrade-v2/ethereum/unifirouter.sol.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.
