Skip to content

DexActionEstimates ​

Git Source

State Variables ​

ADDRESS_DEAD ​

solidity
address private constant ADDRESS_DEAD = 0x000000000000000000000000000000000000dEaD;

Functions ​

estimateSwapIn ​

estimates swap IN tokens execution

solidity
function estimateSwapIn(address dex_, bool swap0to1_, uint256 amountIn_, uint256 amountOutMin_)
    public
    payable
    returns (uint256 amountOut_);

Parameters

NameTypeDescription
dex_addressDex pool
swap0to1_boolDirection of swap. If true, swaps token0 for token1; if false, swaps token1 for token0
amountIn_uint256The exact amount of input tokens to swap
amountOutMin_uint256The minimum amount of output tokens the user is willing to accept

Returns

NameTypeDescription
amountOut_uint256The amount of output tokens received from the swap

estimateSwapOut ​

estimates swap OUT tokens execution

solidity
function estimateSwapOut(address dex_, bool swap0to1_, uint256 amountOut_, uint256 amountInMax_)
    public
    payable
    returns (uint256 amountIn_);

Parameters

NameTypeDescription
dex_addressDex pool
swap0to1_boolDirection of swap. If true, swaps token0 for token1; if false, swaps token1 for token0
amountOut_uint256The exact amount of tokens to receive after swap
amountInMax_uint256Maximum amount of tokens to swap in

Returns

NameTypeDescription
amountIn_uint256The amount of input tokens used for the swap

estimateDepositPerfect ​

Estimate deposit tokens in equal proportion to the current pool ratio

solidity
function estimateDepositPerfect(address dex_, uint256 shares_, uint256 maxToken0Deposit_, uint256 maxToken1Deposit_)
    public
    payable
    returns (uint256 token0Amt_, uint256 token1Amt_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
shares_uint256The number of shares to mint
maxToken0Deposit_uint256Maximum amount of token0 to deposit
maxToken1Deposit_uint256Maximum amount of token1 to deposit

Returns

NameTypeDescription
token0Amt_uint256Estimated amount of token0 to deposit
token1Amt_uint256Estimated amount of token1 to deposit

estimateWithdrawPerfect ​

Estimate withdrawal of a perfect amount of collateral liquidity

solidity
function estimateWithdrawPerfect(address dex_, uint256 shares_, uint256 minToken0Withdraw_, uint256 minToken1Withdraw_)
    public
    returns (uint256 token0Amt_, uint256 token1Amt_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
shares_uint256The number of shares to withdraw
minToken0Withdraw_uint256The minimum amount of token0 the user is willing to accept
minToken1Withdraw_uint256The minimum amount of token1 the user is willing to accept

Returns

NameTypeDescription
token0Amt_uint256Estimated amount of token0 to be withdrawn
token1Amt_uint256Estimated amount of token1 to be withdrawn

estimateBorrowPerfect ​

Estimate borrowing tokens in equal proportion to the current debt pool ratio

solidity
function estimateBorrowPerfect(address dex_, uint256 shares_, uint256 minToken0Borrow_, uint256 minToken1Borrow_)
    public
    returns (uint256 token0Amt_, uint256 token1Amt_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
shares_uint256The number of shares to borrow
minToken0Borrow_uint256Minimum amount of token0 to borrow
minToken1Borrow_uint256Minimum amount of token1 to borrow

Returns

NameTypeDescription
token0Amt_uint256Estimated amount of token0 to be borrowed
token1Amt_uint256Estimated amount of token1 to be borrowed

estimatePaybackPerfect ​

Estimate paying back borrowed tokens in equal proportion to the current debt pool ratio

solidity
function estimatePaybackPerfect(address dex_, uint256 shares_, uint256 maxToken0Payback_, uint256 maxToken1Payback_)
    public
    payable
    returns (uint256 token0Amt_, uint256 token1Amt_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
shares_uint256The number of shares to pay back
maxToken0Payback_uint256Maximum amount of token0 to pay back
maxToken1Payback_uint256Maximum amount of token1 to pay back

Returns

NameTypeDescription
token0Amt_uint256Estimated amount of token0 to be paid back
token1Amt_uint256Estimated amount of token1 to be paid back

estimateDeposit ​

Estimate deposit of tokens

solidity
function estimateDeposit(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_)
    public
    payable
    returns (uint256 shares_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
token0Amt_uint256Amount of token0 to deposit
token1Amt_uint256Amount of token1 to deposit
minSharesAmt_uint256Minimum amount of shares to receive

Returns

NameTypeDescription
shares_uint256Estimated amount of shares to be minted

estimateWithdraw ​

Estimate withdrawal of tokens

solidity
function estimateWithdraw(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_)
    public
    returns (uint256 shares_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
token0Amt_uint256Amount of token0 to withdraw
token1Amt_uint256Amount of token1 to withdraw
maxSharesAmt_uint256Maximum amount of shares to burn

Returns

NameTypeDescription
shares_uint256Estimated amount of shares to be burned

estimateBorrow ​

Estimate borrowing of tokens

solidity
function estimateBorrow(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_)
    public
    returns (uint256 shares_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
token0Amt_uint256Amount of token0 to borrow
token1Amt_uint256Amount of token1 to borrow
maxSharesAmt_uint256Maximum amount of shares to mint

Returns

NameTypeDescription
shares_uint256Estimated amount of shares to be minted

estimatePayback ​

Estimate paying back of borrowed tokens

solidity
function estimatePayback(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_)
    public
    payable
    returns (uint256 shares_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
token0Amt_uint256Amount of token0 to pay back
token1Amt_uint256Amount of token1 to pay back
minSharesAmt_uint256Minimum amount of shares to burn

Returns

NameTypeDescription
shares_uint256Estimated amount of shares to be burned

estimateWithdrawPerfectInOneToken ​

Estimate withdrawal of a perfect amount of collateral liquidity in one token

solidity
function estimateWithdrawPerfectInOneToken(address dex_, uint256 shares_, uint256 minToken0_, uint256 minToken1_)
    public
    returns (uint256 withdrawAmt_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
shares_uint256The number of shares to withdraw
minToken0_uint256The minimum amount of token0 the user is willing to accept
minToken1_uint256The minimum amount of token1 the user is willing to accept

Returns

NameTypeDescription
withdrawAmt_uint256Estimated amount of tokens to be withdrawn

estimatePaybackPerfectInOneToken ​

Estimate paying back of a perfect amount of borrowed tokens in one token

solidity
function estimatePaybackPerfectInOneToken(address dex_, uint256 shares_, uint256 maxToken0_, uint256 maxToken1_)
    public
    payable
    returns (uint256 paybackAmt_);

Parameters

NameTypeDescription
dex_addressThe address of the DEX contract
shares_uint256The number of shares to pay back
maxToken0_uint256Maximum amount of token0 to pay back
maxToken1_uint256Maximum amount of token1 to pay back

Returns

NameTypeDescription
paybackAmt_uint256Estimated amount of tokens to be paid back

_decodeLowLevelUint2x ​

solidity
function _decodeLowLevelUint2x(bytes memory lowLevelData_, bytes4 targetErrorSelector_)
    internal
    pure
    returns (uint256 value1_, uint256 value2_);

_decodeLowLevelUint1x ​

solidity
function _decodeLowLevelUint1x(bytes memory lowLevelData_, bytes4 targetErrorSelector_)
    internal
    pure
    returns (uint256 value1_);