NativePool

Native AMM or PMM Pool

Functions

getAmountIn

function getAmountIn(
    uint256 amountOut,
    address _tokenIn,
    address _tokenOut
) public view returns (uint amountIn)

Call the Registry contract to get the amount of output token based on input amount

NameTypeDescription

amountOut

uint256

Amount of output token

tokenIn

address

Input token

tokenOut

address

Output token

getAmountOut

function getAmountOut(
    uint256 amountIn,
    address _tokenIn,
    address _tokenOut
) public view returns (uint amountOut)

Call the Registry contract to get the amount of input token based on output amount

NameTypeDescription

amountIn

uint256

Amount of input token

tokenIn

address

Input token

tokenOut

address

Output token

pairExists

function pairExist(address tokenIn, address tokenOut) public view
    returns (bool exist)

Check if the pair exists

NameTypeDescription

tokenIn

address

The token address of one side of the pair

tokenOut

address

The token address of the other side of the pair

getPairFee

function getPairFee(address tokenIn, address tokenOut) public view 
    returns (uint256 fee)

Get fees for the given pair config

NameTypeDescription

tokenIn

address

The token address of one side of the pair

tokenOut

address

The token address of the

other side of the pair

updatePairs

function updatePairs(
    uint256[] calldata _fees,
    address[] calldata _tokenAs,
    address[] calldata _tokenBs,
    uint256[] calldata _pricingModelIds
) public

Update the pairs of this pool. In the form of array to update multiple pairs

Native V1 only supports 1 pair for each Pool. Will support multiple pairs soon.

NameTypeDescription

_fees

uint256[]

Swap fee of the pair

_tokenAs

address[]

The token address of one side of the pair

_tokenBs

address[]

The token address of the other side of the pair

_pricingModelIds

uint256[]

Pricing model ID this pair is using

removePair

function removePair(address tokenIn, address tokenOut) public

Remove the pair by specifying the token

NameTypeDescription

tokenIn

address

The token address of one side of the pair

tokenOut

address

The token address of the other side of the pair

swap

function swap(
    bytes memory order,
    bytes calldata signature,
    int256 flexibleAmount,
    address recipient,
    bytes calldata callback
) external returns (int256, int256)

It can only be called by the Router contract.

  1. Verify signature, order not expired, valid nonce, pair is whitelisted, valid amount input

  2. Get firm quote based on pricing ID

  3. Actually execute the swap and transfer the funds between user, Router, Pool and Treasury

NameTypeDescription

order

bytes

Contains the data in an order. Including signer, buyer/seller address, expected deadline, buy/sell token/amount, etc.

signature

bytes

Signature generated by the signer

flexibleAmount

int256

The

recipient

address

Fund recipient of the swap (could be Router for multi-hop swaps)

callback

bytes

Callback data after at the end of the swap

setRouter

function setRouter(address _router) external

Set the router address allowed to call the swap function

NameTypeDescription

_router

address

The router address

addSigner

function addSigner(address _signer) external

Whitelist new signer for the Pool

NameTypeDescription

_signer

address

The signer address

removeSigner

function removeSigner(address _signer) external

Remove existing signer from the whitelist

NameTypeDescription

_signer

address

The signer address

getNonce

function getNonce(address seller) public view returns (uint256)

Get the nonce for the specific seller

NameTypeDescription

seller

address

The seller address

increaseNonce

function increaseNonce(address seller) public returns (uint256)

Increase the nonce by 1 for the specific seller

NameTypeDescription

seller

address

The seller address

Last updated