Registry

Manage different kind of pricers

Functions

registerPricer

function registerPricer(
    uint256 id,
    address addr
) public returns (bool)

Register a new pricer to registry.

Only owner of registry can register a new pricer. Each id can only be assigned to one pricer, and assigned once, with no modification allowed.

parameters:

NameTypeDescription

id

uint256

Pricer id to assign

addr

address

Pricer contract address

getAmountOut

function getAmountOut(
    uint256 amountIn,
    uint256 fee,
    uint256 id,
    address treasury,
    address tokenIn,
    address tokenOut
) public view returns (uint amountOut)

Calculate amount of output token, given amount of input token, fee ratio, pricer id, treasury address, and input and output token address.

parameters:

NameTypeDescription

amountIn

uint256

Amount of input token

fee

uint256

Fee ratio, in basis point. e.g. 100 means 1% fee

id

unit256

Pricer whose logic would be applied for computation

treasury

address

Treasury address where to read asset balance from, as input of computation

tokenIn

address

Input token

tokenOut

address

Output token

getAmountIn

function getAmountIn(
    uint256 amountOut,
    uint256 fee,
    uint256 id,
    address treasury,
    address tokenIn,
    address tokenOut
) public view returns (uint amountIn)

Calculate amount of input token, given amount of output token, fee ratio, pricer id, treasury address, and input and output token address.

parameters:

NameTypeDescription

amountOut

uint256

Amount of output token

fee

uint256

Fee ratio, in basis point. e.g. 100 means 1% fee

id

unit256

Pricer whose logic would be applied for computation

treasury

address

Treasury address where to read asset balance from, as input of computation

tokenIn

address

Input token

tokenOut

address

Output token

Last updated