Exchange

This contract implements the trade routing proxy logic and on-chain token swap functionality.

Functions

swapMaxAmountOut

function swapMaxAmountOut(
address poolIn,
address poolOut,
uint maxAmountOut,
uint deadline
)

Swap tokens for tokens. This function calculates a max of poolOut for an input amount of tokens for poolIn. This API executes a swap across two pools and can avoid decimals precise losses of the input amount.

swapExactAmountIn

function swapExactAmountIn(
address poolIn,
address poolOut,
uint exactAmountIn,
uint deadline
)

Swap tokens for tokens. This function calculates a max of poolOut for an input amount of exactAmountIn of poolIn. This legacy swap function is UI-friendly but would cause decimals precise losses.