INablaRouter

Swap

event Swap(address sender, uint256 amountIn, uint256 amountOut, address tokenIn, address tokenOut, address to)

Emitted on each swap

SwapPoolRegistered

event SwapPoolRegistered(address sender, address pool, address asset)

Emitted when a new pool is registered

SwapPoolUnregistered

event SwapPoolUnregistered(address sender, address asset)

Emitted when a pool gets unregistered

OracleAdapterSet

event OracleAdapterSet(address sender, address oracleAdapter)

Emitted when a new OracleAdapter (price oracle) is set

oracleAdapter

function oracleAdapter() external view returns (contract IPriceOracleGetter)

poolByAsset

function poolByAsset(address asset) external view returns (contract ISwapPoolPermissioned)

swapExactTokensForTokens

function swapExactTokensForTokens(uint256 _amountIn, uint256 _amountOutMin, address[] _tokenInOut, address _to, uint256 _deadline, bytes[] _priceUpdateData) external payable returns (uint256[] _amounts)

Swap some _fromToken tokens for _toToken tokens, ensures _amountOutMin and _deadline, sends funds to _to address msg.sender needs to grant the chef contract a sufficient allowance beforehand

By calling this function the price feed gets be updated (IPriceOracleAdapter.updatePriceFeeds)

Parameters

NameTypeDescription

_amountIn

uint256

The amount of input tokens to swap

_amountOutMin

uint256

The minimum amount that the user will accept

_tokenInOut

address[]

Array of size two, indicating the in and out token

_to

address

The recipient of the output tokens

_deadline

uint256

Unix timestamp after which the transaction will revert

_priceUpdateData

bytes[]

Array of price update data

Return Values

NameTypeDescription

_amounts

uint256[]

Array of size two, containing the input and output amount

getAmountOut

function getAmountOut(uint256 _amountIn, address[] _tokenInOut, uint256[] _tokenPrices) external view returns (uint256 _amountOut, uint256 _swapFee)

Get a quote for how many _toToken tokens _amountIn many tokenIn tokens can currently be swapped for.

Parameters

NameTypeDescription

_amountIn

uint256

The amount of input tokens to swap

_tokenInOut

address[]

Array of size two, indicating the in and out token

_tokenPrices

uint256[]

Array of size two, indicating the in and out token prices fetched off-chain

Return Values

NameTypeDescription

_amountOut

uint256

Number of _toToken tokens that such a swap would yield right now

_swapFee

uint256

The fee that is charged for the swap (in _toToken tokens)

Last updated