> For the complete documentation index, see [llms.txt](https://docs.koi.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.koi.finance/mute-switch-api/router.md).

# Router

## wETH

```solidity
// Returns address of the wETH contract.
function wETH() external view returns (address);
```

## factory

```solidity
// Returns address of the factory contract.
function factory() external view returns (address);
```

## addLiquidity

```solidity
// Adds (or creates) liquidity to pool.
    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        uint feeType,
        bool stable
    ) external returns (uint amountA, uint amountB, uint liquidity);
```

## addLiquidityETH

```solidity
// Adds (or creates) liquidity to pool.
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        uint feeType,
        bool stable
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
```

## removeLiquidity

```solidity
// Removes liquidity from existing pool.
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool stable
    ) external returns (uint amountA, uint amountB);
```

## removeLiquidityETH

```solidity
// Removes liquidity from existing pool.
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool stable
    ) external returns (uint amountToken, uint amountETH);
```

## removeLiquidityETHSupportingFeeOnTransferTokens

```solidity
// Removes liquidity from existing pool for tokens with fee transfer.
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool stable
    ) external returns (uint amountToken, uint amountETH);
```

## swapExactTokensForTokens

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

## swapExactETHForTokens

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

## swapExactTokensForETH

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

## swapExactETHForTokensSupportingFeeOnTransferTokens

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

## swapExactTokensForETHSupportingFeeOnTransferTokens

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

## swapExactTokensForTokensSupportingFeeOnTransferTokens

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

## quote

```solidity
// Gets reserve quotes
    function quote(uint amountA, uint reserveA, uint reserveB) 
            external pure returns (uint amountB);
```

## getAmountOut

```solidity
// Calculates the best price through both stable and normal pools
    function getAmountOut(
                uint amountIn, 
                uint tokenIn, 
                uint tokenOut
    ) external view returns (uint amountOut, bool stable, uint fee);

```

## getAmountsOutExpanded

```solidity
// Calculates the best prices for path. Returns amounts, pool types, and pool fees for route
    function getAmountsOutExpanded(
                uint amountIn, 
                address[] calldata path
    ) external view returns (uint[] memory amounts, bool[] memory stable, uint[] memory fees);

```

## getAmountsOut

```solidity
// Calculates price best on path and pool type (stable, normal)
    function getAmountsOut(
                uint amountIn, 
                address[] calldata path, 
                bool[] calldata stable
    ) external view returns (uint[] memory amounts);
```

## getPairInfo

```solidity
// Returns pair info
    function getPairInfo(
                    address[] calldata path, 
                    bool stable
    ) external view returns(address tokenA, address tokenB, address pair, uint reserveA, uint reserveB, uint fee)

```

## pairFor

```solidity
// Returns pair address
    function pairFor(address tokenA, address tokenB, bool stable)
      external view returns(address pair);

```

\
\
\ <br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.koi.finance/mute-switch-api/router.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
