SlimRouter
This documentation provides an overview of the ISlimRouter.sol contract, which defines the functions & events for conducting token swaps & managing token balances. The IRouter inherits this contract.
Table of Contents
Contract Details
Name : ISlimRouter
Solidity Version : ^0.8.0
SPDX License-Identifier : GPL-2.0-or-later
Code: Github
Structs
ExactInputSingleParams
tokenIn
: The address of the token to be swapped.tokenOut
: The address of the desired token to receive in the swap.pool
: An instance of the IPool interface representing the pool to perform the swap in.recipient
: The address where the swapped tokens will be sent.deadline
: The deadline timestamp for the swap to be executed before it expires.amountIn
: The amount of tokenIn token to be swapped.amountOutMinimum
: The minimum amount of tokenOut tokens expected to be received from the swap.sqrtPriceLimitD18
: The square root of the price limit for the swap, represented with 18 decimal places.
ExactOutputSingleParams
tokenIn
: The address of the token to be used as input in the swap.tokenOut
: The address of the token to be received as output in the swap.pool
: An instance of the IPool interface representing the pool to perform the swap in.recipient
: The address where the swapped tokens will be sent.deadline
: The deadline timestamp for the swap to be executed before it expires.amountOut
: The desired amount of tokenOut tokens to be received from the swap.amountInMaximum
: The maximum amount of tokenIn tokens to be used for the swap.
Functions
WETH9()
Retrieves the address of the WETH9 token.
Returns :
IWETH9
: An instance of theIWETH9
interface representing the WETH9 token.
exactInputSingle()
Swaps amountIn
of one token for as much as possible of another token.
Parameters :
params
: The parameters necessary for the swap, encoded asExactInputSingleParams
structure in calldata.
Returns :
amountOut
: The amount of the received tokenuint256
.
exactOutputSingle()
Swaps as little as possible of one token for amountOut
of another token.
Parameters :
params
: The parameters necessary for the swap, encoded asExactOutputSingleParams
structure in calldata.
Returns:
amountIn
: The amount of the input tokenuint256
.
unwrapWETH9()
Unwraps the contract's WETH9
balance and sends it to the specified recipient as ETH
.
Parameters:
amountMinimum
: Theminimum amount
ofWETH9
to unwrap.recipient
: Theaddress
receiving ETH.
refundETH()
Refunds any ETH
balance held by this contract to the msg.sender
.
sweepToken()
Transfers the full amount of a specified token held by this contract to the recipient.
Parameters:
token
: The contractaddress
of the token to be transferred.amountMinimum
: Theminimum amount
of tokenuint256
required for the transfer.recipient
: The destinationaddress
of the token.
Last updated