📑Contracts

This page contains the main Nether.Fi contracts on Base mainnet

Addresses

Swap

To execute a swap

// Approve the Router contract for the token and amount you would like to swap
// call
Router.swap(
    address[] memory _path,  // [tokenIn, tokenOut],
    uint256 _amountIn,       // amount of tokenIn to swap,
    uint256 _minOut,         // minimum expected output amount,
    address _receiver        // address of the receiver of tokenOut
)

// function will revert if the amount of tokenOut is less than _minOut

Get swap amounts before execution

// call
Reader.getMaxAmountIn(
    address _vault,       // Vault address
    address _tokenIn,     // address of token that will be given
    address _tokenOut,    // address of token to be received
)

// returns the max amount of tokenIn that can be swapped
// call
Reader.getAmountOut(
    address _vault,       // Vault address
    address _tokenIn,     // address of token that will be given
    address _tokenOut,    // address of token to be received
    uint256 _amountIn     // amount of tokenIn to swap
)

// returns 2 values - [amountOut after fees, fee amount]
// fee amount will be in terms of _tokenOut

Tokens have a usdgAmount in the Vault contract used for some calculations, this amount is updated on minting of NLP, redemption of NLP and swaps based on the price of the token at the time. Due to price fluctuations this value may drift slightly from the actual USD value of the tokens in the pool, the usdgAmount is periodically updated to re-align values.

Last updated