⚙️
Native Developers
  • Native V1
    • Overview
    • Operations
      • Single-Hop Transaction: Off-chain Pricing
      • Single-Hop Transaction: On-chain Pricing
      • Multi-Hop Transaction
      • L1 Token Swap
      • Creating a Pool
      • Updating a Pool
    • System Components
      • GUI
      • Native Backend
      • Pricer
      • Registry
      • Signer
      • Pool
      • Pool Factory
      • Treasury
      • Router
    • Smart Contracts
      • Core
        • Registry
        • NativePool
        • NativePoolFactory
        • NativeRouter
      • Liquidity Pools
    • Contract Address
    • API References
      • GET /v1/indicative-quote
      • GET /v1/orderbook
      • GET v1/firm-quote
      • GET v1/firm-quote/calldata
    • Guide
      • Get quote for ETH to USDT
      • Execute ETH to USDT swap on Native
    • Routing
  • Market Maker Integration
    • WebSocket Connection
Powered by GitBook
On this page
  • Functions
  • exactInputSingle
  • exactInput
  • swapCallback
  1. Native V1
  2. Smart Contracts
  3. Core

NativeRouter

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

Name
Type
Description

params

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 slippage for the transaction is within specified amount

Name
Type
Description

params

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

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

PreviousNativePoolFactoryNextLiquidity Pools

Last updated 1 year ago

ExactInputSingleParams
ExactInputParams