DexActionEstimates ​
State Variables ​
ADDRESS_DEAD ​
address private constant ADDRESS_DEAD = 0x000000000000000000000000000000000000dEaD;
Functions ​
estimateSwapIn ​
estimates swap IN tokens execution
function estimateSwapIn(address dex_, bool swap0to1_, uint256 amountIn_, uint256 amountOutMin_)
public
payable
returns (uint256 amountOut_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | Dex pool |
swap0to1_ | bool | Direction of swap. If true, swaps token0 for token1; if false, swaps token1 for token0 |
amountIn_ | uint256 | The exact amount of input tokens to swap |
amountOutMin_ | uint256 | The minimum amount of output tokens the user is willing to accept |
Returns
Name | Type | Description |
---|---|---|
amountOut_ | uint256 | The amount of output tokens received from the swap |
estimateSwapOut ​
estimates swap OUT tokens execution
function estimateSwapOut(address dex_, bool swap0to1_, uint256 amountOut_, uint256 amountInMax_)
public
payable
returns (uint256 amountIn_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | Dex pool |
swap0to1_ | bool | Direction of swap. If true, swaps token0 for token1; if false, swaps token1 for token0 |
amountOut_ | uint256 | The exact amount of tokens to receive after swap |
amountInMax_ | uint256 | Maximum amount of tokens to swap in |
Returns
Name | Type | Description |
---|---|---|
amountIn_ | uint256 | The amount of input tokens used for the swap |
estimateDepositPerfect ​
Estimate deposit tokens in equal proportion to the current pool ratio
function estimateDepositPerfect(address dex_, uint256 shares_, uint256 maxToken0Deposit_, uint256 maxToken1Deposit_)
public
payable
returns (uint256 token0Amt_, uint256 token1Amt_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
shares_ | uint256 | The number of shares to mint |
maxToken0Deposit_ | uint256 | Maximum amount of token0 to deposit |
maxToken1Deposit_ | uint256 | Maximum amount of token1 to deposit |
Returns
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to deposit |
token1Amt_ | uint256 | Estimated amount of token1 to deposit |
estimateWithdrawPerfect ​
Estimate withdrawal of a perfect amount of collateral liquidity
function estimateWithdrawPerfect(address dex_, uint256 shares_, uint256 minToken0Withdraw_, uint256 minToken1Withdraw_)
public
returns (uint256 token0Amt_, uint256 token1Amt_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
shares_ | uint256 | The number of shares to withdraw |
minToken0Withdraw_ | uint256 | The minimum amount of token0 the user is willing to accept |
minToken1Withdraw_ | uint256 | The minimum amount of token1 the user is willing to accept |
Returns
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to be withdrawn |
token1Amt_ | uint256 | Estimated amount of token1 to be withdrawn |
estimateBorrowPerfect ​
Estimate borrowing tokens in equal proportion to the current debt pool ratio
function estimateBorrowPerfect(address dex_, uint256 shares_, uint256 minToken0Borrow_, uint256 minToken1Borrow_)
public
returns (uint256 token0Amt_, uint256 token1Amt_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
shares_ | uint256 | The number of shares to borrow |
minToken0Borrow_ | uint256 | Minimum amount of token0 to borrow |
minToken1Borrow_ | uint256 | Minimum amount of token1 to borrow |
Returns
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to be borrowed |
token1Amt_ | uint256 | Estimated amount of token1 to be borrowed |
estimatePaybackPerfect ​
Estimate paying back borrowed tokens in equal proportion to the current debt pool ratio
function estimatePaybackPerfect(address dex_, uint256 shares_, uint256 maxToken0Payback_, uint256 maxToken1Payback_)
public
payable
returns (uint256 token0Amt_, uint256 token1Amt_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
shares_ | uint256 | The number of shares to pay back |
maxToken0Payback_ | uint256 | Maximum amount of token0 to pay back |
maxToken1Payback_ | uint256 | Maximum amount of token1 to pay back |
Returns
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to be paid back |
token1Amt_ | uint256 | Estimated amount of token1 to be paid back |
estimateDeposit ​
Estimate deposit of tokens
function estimateDeposit(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_)
public
payable
returns (uint256 shares_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
token0Amt_ | uint256 | Amount of token0 to deposit |
token1Amt_ | uint256 | Amount of token1 to deposit |
minSharesAmt_ | uint256 | Minimum amount of shares to receive |
Returns
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be minted |
estimateWithdraw ​
Estimate withdrawal of tokens
function estimateWithdraw(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_)
public
returns (uint256 shares_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
token0Amt_ | uint256 | Amount of token0 to withdraw |
token1Amt_ | uint256 | Amount of token1 to withdraw |
maxSharesAmt_ | uint256 | Maximum amount of shares to burn |
Returns
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be burned |
estimateBorrow ​
Estimate borrowing of tokens
function estimateBorrow(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_)
public
returns (uint256 shares_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
token0Amt_ | uint256 | Amount of token0 to borrow |
token1Amt_ | uint256 | Amount of token1 to borrow |
maxSharesAmt_ | uint256 | Maximum amount of shares to mint |
Returns
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be minted |
estimatePayback ​
Estimate paying back of borrowed tokens
function estimatePayback(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_)
public
payable
returns (uint256 shares_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
token0Amt_ | uint256 | Amount of token0 to pay back |
token1Amt_ | uint256 | Amount of token1 to pay back |
minSharesAmt_ | uint256 | Minimum amount of shares to burn |
Returns
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be burned |
estimateWithdrawPerfectInOneToken ​
Estimate withdrawal of a perfect amount of collateral liquidity in one token
function estimateWithdrawPerfectInOneToken(address dex_, uint256 shares_, uint256 minToken0_, uint256 minToken1_)
public
returns (uint256 withdrawAmt_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
shares_ | uint256 | The number of shares to withdraw |
minToken0_ | uint256 | The minimum amount of token0 the user is willing to accept |
minToken1_ | uint256 | The minimum amount of token1 the user is willing to accept |
Returns
Name | Type | Description |
---|---|---|
withdrawAmt_ | uint256 | Estimated amount of tokens to be withdrawn |
estimatePaybackPerfectInOneToken ​
Estimate paying back of a perfect amount of borrowed tokens in one token
function estimatePaybackPerfectInOneToken(address dex_, uint256 shares_, uint256 maxToken0_, uint256 maxToken1_)
public
payable
returns (uint256 paybackAmt_);
Parameters
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX contract |
shares_ | uint256 | The number of shares to pay back |
maxToken0_ | uint256 | Maximum amount of token0 to pay back |
maxToken1_ | uint256 | Maximum amount of token1 to pay back |
Returns
Name | Type | Description |
---|---|---|
paybackAmt_ | uint256 | Estimated amount of tokens to be paid back |
_decodeLowLevelUint2x ​
function _decodeLowLevelUint2x(bytes memory lowLevelData_, bytes4 targetErrorSelector_)
internal
pure
returns (uint256 value1_, uint256 value2_);
_decodeLowLevelUint1x ​
function _decodeLowLevelUint1x(bytes memory lowLevelData_, bytes4 targetErrorSelector_)
internal
pure
returns (uint256 value1_);