Comment on page
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.
- Name : ISlimRouter
- Solidity Version : ^0.8.0
- SPDX License-Identifier : GPL-2.0-or-later
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
IPool pool;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint256 sqrtPriceLimitD18;
}
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.
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
IPool pool;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}
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.
Retrieves the address of the WETH9 token.
function WETH9() external view returns (IWETH9);
- Returns :
IWETH9
: An instance of theIWETH9
interface representing the WETH9 token.
Swaps
amountIn
of one token for as much as possible of another token.function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
- Parameters :
params
: The parameters necessary for the swap, encoded asExactInputSingleParams
structure in calldata.
- Returns :
amountOut
: The amount of the received tokenuint256
.
Swaps as little as possible of one token for
amountOut
of another token.function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);
- Parameters :
params
: The parameters necessary for the swap, encoded asExactOutputSingleParams
structure in calldata.
- Returns:
amountIn
: The amount of the input tokenuint256
.
Unwraps the contract's
WETH9
balance and sends it to the specified recipient as ETH
.function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;
- Parameters:
amountMinimum
: Theminimum amount
ofWETH9
to unwrap.recipient
: Theaddress
receiving ETH.
Refunds any
ETH
balance held by this contract to the msg.sender
.function refundETH() external payable;
Transfers the full amount of a specified token held by this contract to the recipient.
function sweepToken(IERC20 token, uint256 amountMinimum, address recipient) external payable;
- 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 modified 5mo ago