TokenSwapCalcsModule
Inherits: ITokenSwapCalcsModule
Author: EridianAlpha
This contract contains the functions for SimpleSwap to swap tokens using UniswapV3.
State Variables
VERSION
The version of the contract.
Contract is upgradeable so the version is a constant set on each implementation contract.
string public constant VERSION = "0.0.1";
Functions
uniswapV3CalculateMinOut
Calculates the minimum amount of tokens to receive from a UniswapV3 swap.
Uses the current pool price ratio and a predefined slippage tolerance to calculate the minimum amount.
function uniswapV3CalculateMinOut(
uint256 _currentBalance,
address _uniswapV3PoolAddress,
address _tokenOutAddress,
uint16 _slippageTolerance
) external view returns (uint256 minOut);
Parameters
Name | Type | Description |
---|---|---|
_currentBalance | uint256 | The current balance of the token to swap. |
_uniswapV3PoolAddress | address | The address of the UniswapV3 pool to use for the swap. |
_tokenOutAddress | address | The address of the token to receive from the swap. |
_slippageTolerance | uint16 | The slippage tolerance for the swap. |
Returns
Name | Type | Description |
---|---|---|
minOut | uint256 | The minimum amount of tokens to receive from the swap. |