FCTExt_TokensValidator

Smart contract that adds the ability to compare values within FCT execution

The values ins and value out supports decimals, making it easy to support various ERC20 tokens.

The comparison is done with normalized values, meaning that 2 USCD (2,000,000 at the blockchain level) will be bigger than 1 Kiro (1,000,000,000,000,000,000 at the blockchain level), because USDC's decimal is 6, comparing to 18 in case of KIRO.

Main Functions

greaterThan

function greaterThan(
        uint256 amount1,
        uint256 decimals1,
        uint256 amount2,
        uint256 decimals2,
        uint256 decimalsOut
 )

Reverts when amount1/(10^decimals) <= amount2/(10^decimals) Returns amount1 - amount2 normalized to decimalsOut otherwise

greaterThanEqual

function greaterEqual(
        uint256 amount1,
        uint256 decimals1,
        uint256 amount2,
        uint256 decimals2,
        uint256 decimalsOut
 )

Reverts when amount1/(10^decimals) < amount2/(10^decimals) Returns amount1 - amount2 normalized to decimalsOut otherwise

lessThan

function lessThan(
        uint256 amount1,
        uint256 decimals1,
        uint256 amount2,
        uint256 decimals2,
        uint256 decimalsOut
 )

Reverts when amount1/(10^decimals) >= amount2/(10^decimals) Returns amount2 - amount1 normalized to decimalsOut otherwise

lessEqual

function lessEqual(
        uint256 amount1,
        uint256 decimals1,
        uint256 amount2,
        uint256 decimals2,
        uint256 decimalsOut
)

Reverts when amount1/(10^decimals) > amount2/(10^decimals) Returns amount2 - amount1 normalized to decimalsOut otherwise

between

function between(
        uint256 minAmount,
        uint256 minDecimals,
        uint256 maxAmount,
        uint256 maxDecimals,
        uint256 amountIn,
        uint256 decimalsIn,
        uint256 decimalsOut
    )

Reverts when amountIn/(10^decimals) <= minAmount/(10^decimals) or amountIn/(10^decimals) > =maxAmount/(10^decimals) Returns amountMax - amountMin normalized to decimalsOut otherwise

betweenEqual

function betweenEqual(
        uint256 minAmount,
        uint256 minDecimals,
        uint256 maxAmount,
        uint256 maxDecimals,
        uint256 amountIn,
        uint256 decimalsIn,
        uint256 decimalsOut
    )

Reverts when amountIn/(10^decimals) < minAmount/(10^decimals) or amountIn/(10^decimals) > maxAmount/(10^decimals) Returns amountMax - amountMin normalized to decimalsOut otherwise

equal

function equal(
        uint256 amount1,
        uint256 decimals1,
        uint256 amount2,
        uint256 decimals2,
        uint256 decimalsOut
    )

Reverts when amount1/(10^decimals) != amount2/(10^decimals) Returns amount1 normalized to decimalsOut otherwise

Last updated