TokenSwapCalcsModule

Git Source

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

NameTypeDescription
_currentBalanceuint256The current balance of the token to swap.
_uniswapV3PoolAddressaddressThe address of the UniswapV3 pool to use for the swap.
_tokenOutAddressaddressThe address of the token to receive from the swap.
_slippageToleranceuint16The slippage tolerance for the swap.

Returns

NameTypeDescription
minOutuint256The minimum amount of tokens to receive from the swap.