> For the complete documentation index, see [llms.txt](https://docs.native.org/old/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.native.org/old/native-v1/smart-contracts/core/nativerouter.md).

# NativeRouter

## Functions

### exactInputSingle

```solidity
function exactInputSingle(
    ExactInputSingleParams memory params
) external payable returns (uint256 amountOut)
```

Used for single hop exact input swap. Process as below:

* Verify if the pool exists in the Pool Factory&#x20;
* Call Pool swap() function
* Check the slippage for the transaction is within specified amount&#x20;

| Name         | Type                                                                                 | Description      |
| ------------ | ------------------------------------------------------------------------------------ | ---------------- |
| **`params`** | [ExactInputSingleParams](broken://pages/2Gu7yTQOKRzyxFb0QgPb#exactinputsingleparams) | Order parameters |

### exactInput

```solidity
function exactInput(
    ExactInputParams memory params
) external payable returns (uint256 amountOut) {
```

Used for multi-hop exact input swap. Process as below:

* Loop all orders
* Decode and slice first order
* Call Pool swap() function
* Verify if the pool exists in the Pool Factory&#x20;
* Check to make slippage for the transaction is within specified amount&#x20;

| Name         | Type                                                                     | Description      |
| ------------ | ------------------------------------------------------------------------ | ---------------- |
| **`params`** | [ExactInputParams](broken://pages/2Gu7yTQOKRzyxFb0QgPb#exactinputparams) | Order parameters |

### swapCallback

```solidity
function swapCallback(
    int256 amount0Delta,
    int256 amount1Delta,
    bytes calldata _data
) external
```

Called whenever a swap happens. Process as below:

* Verify if the pool exists in the Pool Factory&#x20;
* Transfer token from user wallet to pool (Single hop) or router to pool (Multi-hop)
  * If user is selling native token, this function will wrap the token before transfering to the pool
  * If user is buying native token, a multiple call transaction will be called: Treasury transfer the wrapped token to Router and from the Router, unwrap the token and transfer it to the user wallet

| Name               | Type   | Description                                                                                                                                                                                                         |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`amount0Delta`** | int256 | The amount of output token that was sent (negative) or input token that must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of input token to the pool. |
| **`amount1Delta`** | int256 | The amount of output token that was sent (negative) or input token that must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of input token to the pool. |
| **`_data`**        | bytes  | Callback bytes data                                                                                                                                                                                                 |
