NativeRouter

Router for stateless execution of swaps

Functions

exactInputSingle

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

  • Call Pool swap() function

  • Check the slippage for the transaction is within specified amount

NameTypeDescription

params

ExactInputSingleParams

Order parameters

exactInput

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

  • Check to make sure slippage for the transaction is within specified amount

NameTypeDescription

params

ExactInputParams

Order parameters

swapCallback

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

  • 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

NameTypeDescription

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

Last updated