DexFactoryViews ​
Abstract contract providing view functions for DEX factory-related operations
getDexAddress ​
function getDexAddress(uint256 dexId_) public view returns (address dex_)
Get the address of a DEX given its ID
Parameters ​
Name | Type | Description |
---|---|---|
dexId_ | uint256 | The ID of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
getDexId ​
function getDexId(address dex_) public view returns (uint256 id_)
Get the ID of a DEX given its address
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
id_ | uint256 | The ID of the DEX |
getTotalDexes ​
function getTotalDexes() public view returns (uint256)
Get the total number of DEXes
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The total number of DEXes |
getAllDexAddresses ​
function getAllDexAddresses() public view returns (address[] dexes_)
Get an array of all DEX addresses
Return Values ​
Name | Type | Description |
---|---|---|
dexes_ | address[] | An array containing all DEX addresses |
DexStorageVars ​
Abstract contract providing view functions for DEX storage variables
getDexVariablesRaw ​
function getDexVariablesRaw(address dex_) public view returns (uint256)
Get the raw DEX variables
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw DEX variables |
getDexVariables2Raw ​
function getDexVariables2Raw(address dex_) public view returns (uint256)
Get the raw DEX variables2
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw DEX variables2 |
getTotalSupplySharesRaw ​
function getTotalSupplySharesRaw(address dex_) public view returns (uint256)
Get the total supply shares slot data of a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The total supply shares |
getUserSupplyDataRaw ​
function getUserSupplyDataRaw(address dex_, address user_) public view returns (uint256)
Get the raw user supply data for a specific user and DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
user_ | address | The address of the user |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw user supply data |
getTotalBorrowSharesRaw ​
function getTotalBorrowSharesRaw(address dex_) public view returns (uint256)
Get the total borrow shares slot data of a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The total borrow shares |
getUserBorrowDataRaw ​
function getUserBorrowDataRaw(address dex_, address user_) public view returns (uint256)
Get the raw user borrow data for a specific user and DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
user_ | address | The address of the user |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw user borrow data |
getOracleRaw ​
function getOracleRaw(address dex_, uint256 index_) public view returns (uint256)
Get the raw oracle data for a specific DEX and index
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
index_ | uint256 | The index of the oracle data |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw oracle data |
getRangeShiftRaw ​
function getRangeShiftRaw(address dex_) public view returns (uint256)
Get the raw range shift for a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw range shift |
getThresholdShiftRaw ​
function getThresholdShiftRaw(address dex_) public view returns (uint256)
Get the raw threshold shift for a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw threshold shift |
getCenterPriceShiftRaw ​
function getCenterPriceShiftRaw(address dex_) public view returns (uint256)
Get the raw center price shift for a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The raw center price shift |
_calculateStorageSlotUintMapping ​
function _calculateStorageSlotUintMapping(uint256 slot_, uint256 key_) internal pure returns (bytes32)
Calculate the storage slot for a uint mapping
Parameters ​
Name | Type | Description |
---|---|---|
slot_ | uint256 | The base slot of the mapping |
key_ | uint256 | The key of the mapping |
Return Values ​
Name | Type | Description |
---|---|---|
[0] | bytes32 | The calculated storage slot |
DexActionEstimates ​
estimateSwapIn ​
function estimateSwapIn(address dex_, bool swap0to1_, uint256 amountIn_, uint256 amountOutMin_) public payable returns (uint256 amountOut_)
estimates swap IN tokens execution
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 |
Return Values ​
Name | Type | Description |
---|---|---|
amountOut_ | uint256 | The amount of output tokens received from the swap |
estimateSwapOut ​
function estimateSwapOut(address dex_, bool swap0to1_, uint256 amountOut_, uint256 amountInMax_) public payable returns (uint256 amountIn_)
estimates swap OUT tokens execution
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 |
Return Values ​
Name | Type | Description |
---|---|---|
amountIn_ | uint256 | The amount of input tokens used for the swap |
estimateDepositPerfect ​
function estimateDepositPerfect(address dex_, uint256 shares_, uint256 maxToken0Deposit_, uint256 maxToken1Deposit_) public payable returns (uint256 token0Amt_, uint256 token1Amt_)
Estimate deposit tokens in equal proportion to the current pool ratio
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 |
Return Values ​
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to deposit |
token1Amt_ | uint256 | Estimated amount of token1 to deposit |
estimateWithdrawPerfect ​
function estimateWithdrawPerfect(address dex_, uint256 shares_, uint256 minToken0Withdraw_, uint256 minToken1Withdraw_) public returns (uint256 token0Amt_, uint256 token1Amt_)
Estimate withdrawal of a perfect amount of collateral liquidity
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 |
Return Values ​
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to be withdrawn |
token1Amt_ | uint256 | Estimated amount of token1 to be withdrawn |
estimateBorrowPerfect ​
function estimateBorrowPerfect(address dex_, uint256 shares_, uint256 minToken0Borrow_, uint256 minToken1Borrow_) public returns (uint256 token0Amt_, uint256 token1Amt_)
Estimate borrowing tokens in equal proportion to the current debt pool ratio
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 |
Return Values ​
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to be borrowed |
token1Amt_ | uint256 | Estimated amount of token1 to be borrowed |
estimatePaybackPerfect ​
function estimatePaybackPerfect(address dex_, uint256 shares_, uint256 maxToken0Payback_, uint256 maxToken1Payback_) public payable returns (uint256 token0Amt_, uint256 token1Amt_)
Estimate paying back borrowed tokens in equal proportion to the current debt pool ratio
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 |
Return Values ​
Name | Type | Description |
---|---|---|
token0Amt_ | uint256 | Estimated amount of token0 to be paid back |
token1Amt_ | uint256 | Estimated amount of token1 to be paid back |
estimateDeposit ​
function estimateDeposit(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_) public payable returns (uint256 shares_)
Estimate deposit of tokens
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 |
Return Values ​
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be minted |
estimateWithdraw ​
function estimateWithdraw(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_) public returns (uint256 shares_)
Estimate withdrawal of tokens
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 |
Return Values ​
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be burned |
estimateBorrow ​
function estimateBorrow(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 maxSharesAmt_) public returns (uint256 shares_)
Estimate borrowing of tokens
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 |
Return Values ​
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be minted |
estimatePayback ​
function estimatePayback(address dex_, uint256 token0Amt_, uint256 token1Amt_, uint256 minSharesAmt_) public payable returns (uint256 shares_)
Estimate paying back of borrowed tokens
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 |
Return Values ​
Name | Type | Description |
---|---|---|
shares_ | uint256 | Estimated amount of shares to be burned |
estimateWithdrawPerfectInOneToken ​
function estimateWithdrawPerfectInOneToken(address dex_, uint256 shares_, uint256 minToken0_, uint256 minToken1_) public returns (uint256 withdrawAmt_)
Estimate withdrawal of a perfect amount of collateral liquidity in one token
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 |
Return Values ​
Name | Type | Description |
---|---|---|
withdrawAmt_ | uint256 | Estimated amount of tokens to be withdrawn |
estimatePaybackPerfectInOneToken ​
function estimatePaybackPerfectInOneToken(address dex_, uint256 shares_, uint256 maxToken0_, uint256 maxToken1_) public payable returns (uint256 paybackAmt_)
Estimate paying back of a perfect amount of borrowed tokens in one token
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 |
Return Values ​
Name | Type | Description |
---|---|---|
paybackAmt_ | uint256 | Estimated amount of tokens to be paid back |
_decodeLowLevelUint2x ​
function _decodeLowLevelUint2x(bytes lowLevelData_, bytes4 targetErrorSelector_) internal pure returns (uint256 value1_, uint256 value2_)
_decodeLowLevelUint1x ​
function _decodeLowLevelUint1x(bytes lowLevelData_, bytes4 targetErrorSelector_) internal pure returns (uint256 value1_)
DexConstantsViews ​
getDexConstantsView ​
function getDexConstantsView(address dex_) public view returns (struct IFluidDexT1.ConstantViews constantsView_)
returns all Dex constants
getDexConstantsView2 ​
function getDexConstantsView2(address dex_) public view returns (struct IFluidDexT1.ConstantViews2 constantsView2_)
returns all Dex constants 2
getDexTokens ​
function getDexTokens(address dex_) public view returns (address token0_, address token1_)
Get the addresses of the tokens in a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
token0_ | address | The address of token0 in the DEX |
token1_ | address | The address of token1 in the DEX |
DexPublicViews ​
getDexPricesAndExchangePrices ​
function getDexPricesAndExchangePrices(address dex_) public returns (struct IFluidDexT1.PricesAndExchangePrice pex_)
Get the prices and exchange prices for a DEX
expected to be called via callStatic
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
pex_ | struct IFluidDexT1.PricesAndExchangePrice | A struct containing prices and exchange prices |
getDexCollateralReserves ​
function getDexCollateralReserves(address dex_) public returns (struct IFluidDexT1.CollateralReserves reserves_)
Get the collateral reserves for a DEX
expected to be called via callStatic
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
reserves_ | struct IFluidDexT1.CollateralReserves | A struct containing collateral reserve information |
getDexDebtReserves ​
function getDexDebtReserves(address dex_) public returns (struct IFluidDexT1.DebtReserves reserves_)
Get the debt reserves for a DEX
expected to be called via callStatic
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
reserves_ | struct IFluidDexT1.DebtReserves | A struct containing debt reserve information |
getDexOraclePrice ​
function getDexOraclePrice(address dex_, uint256[] secondsAgos_) external view returns (struct IFluidDexT1.Oracle[] twaps_, uint256 currentPrice_)
get Dex oracle price TWAP data
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | |
secondsAgos_ | uint256[] | array of seconds ago for which TWAP is needed. If user sends [10, 30, 60] then twaps_ will return [10-0, 30-10, 60-30] |
Return Values ​
Name | Type | Description |
---|---|---|
twaps_ | struct IFluidDexT1.Oracle[] | twap price, lowest price (aka minima) & highest price (aka maxima) between secondsAgo checkpoints |
currentPrice_ | uint256 | price of pool after the most recent swap |
_getDexCollateralReserves ​
function _getDexCollateralReserves(address dex_, struct IFluidDexT1.ConstantViews2 constantsView2_) internal returns (struct IFluidDexT1.CollateralReserves reserves_)
Get the collateral reserves for a DEX scaled to token decimals
_getDexDebtReserves ​
function _getDexDebtReserves(address dex_, struct IFluidDexT1.ConstantViews2 constantsView2_) internal returns (struct IFluidDexT1.DebtReserves reserves_)
Get the debt reserves for a DEX scaled to token decimals
DexUserViews ​
getUserSupplyData ​
function getUserSupplyData(address dex_, address user_) public view returns (struct Structs.UserSupplyData userSupplyData_)
Get user supply data for a specific DEX and user
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
user_ | address | The address of the user |
Return Values ​
Name | Type | Description |
---|---|---|
userSupplyData_ | struct Structs.UserSupplyData | Struct containing user supply data |
getUserSupplyDatas ​
function getUserSupplyDatas(address dex_, address[] users_) public view returns (struct Structs.UserSupplyData[] userSuppliesData_)
Get user supply data for multiple users in a specific DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
users_ | address[] | Array of user addresses |
Return Values ​
Name | Type | Description |
---|---|---|
userSuppliesData_ | struct Structs.UserSupplyData[] | Array of UserSupplyData structs for each user |
getUserBorrowData ​
function getUserBorrowData(address dex_, address user_) public view returns (struct Structs.UserBorrowData userBorrowData_)
Get user borrow data for a specific DEX and user
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
user_ | address | The address of the user |
Return Values ​
Name | Type | Description |
---|---|---|
userBorrowData_ | struct Structs.UserBorrowData | Struct containing user borrow data |
getUserBorrowDatas ​
function getUserBorrowDatas(address dex_, address[] users_) public view returns (struct Structs.UserBorrowData[] userBorrowingsData_)
Get user borrow data for multiple users in a specific DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
users_ | address[] | Array of user addresses |
Return Values ​
Name | Type | Description |
---|---|---|
userBorrowingsData_ | struct Structs.UserBorrowData[] | Array of UserBorrowData structs for each user |
getUserBorrowSupplyDatas ​
function getUserBorrowSupplyDatas(address dex_, address[] users_) public view returns (struct Structs.UserSupplyData[] userSuppliesData_, struct Structs.UserBorrowData[] userBorrowingsData_)
Get both user supply and borrow data for multiple users in a specific DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
users_ | address[] | Array of user addresses |
Return Values ​
Name | Type | Description |
---|---|---|
userSuppliesData_ | struct Structs.UserSupplyData[] | Array of UserSupplyData structs for each user |
userBorrowingsData_ | struct Structs.UserBorrowData[] | Array of UserBorrowData structs for each user |
FluidDexResolver ​
Fluid Dex protocol resolver Implements various view-only methods to give easy access to Dex protocol data.
constructor ​
constructor(address factory_, address liquidity_, address liquidityResolver_, address deployer_) public
getDexState ​
function getDexState(address dex_) public returns (struct Structs.DexState state_)
Get the current state of a DEX
expected to be called via callStatic
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
state_ | struct Structs.DexState | A struct containing the current state of the DEX |
getDexConfigs ​
function getDexConfigs(address dex_) public view returns (struct Structs.Configs configs_)
Get the current configurations of a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
configs_ | struct Structs.Configs | A struct containing the current configurations of the DEX |
getDexSwapLimitsAndAvailability ​
function getDexSwapLimitsAndAvailability(address dex_) public view returns (struct Structs.SwapLimitsAndAvailability limitsAndAvailability_)
Get the swap limits and availability for a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
limitsAndAvailability_ | struct Structs.SwapLimitsAndAvailability | A struct containing the swap limits and availability for the DEX |
getDexEntireData ​
function getDexEntireData(address dex_) public returns (struct Structs.DexEntireData data_)
Get the entire data for a DEX
expected to be called via callStatic
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
data_ | struct Structs.DexEntireData | A struct containing all the data for the DEX |
getDexEntireDatas ​
function getDexEntireDatas(address[] dexes_) public returns (struct Structs.DexEntireData[] datas_)
Get the entire data for multiple DEXes
expected to be called via callStatic
Parameters ​
Name | Type | Description |
---|---|---|
dexes_ | address[] | An array of DEX addresses |
Return Values ​
Name | Type | Description |
---|---|---|
datas_ | struct Structs.DexEntireData[] | An array of structs containing all the data for each DEX |
getAllDexEntireDatas ​
function getAllDexEntireDatas() external returns (struct Structs.DexEntireData[] datas_)
Get the entire data for all DEXes
expected to be called via callStatic
Return Values ​
Name | Type | Description |
---|---|---|
datas_ | struct Structs.DexEntireData[] | An array of structs containing all the data for all DEXes |
_getDexSwapLimitsAndAvailability ​
function _getDexSwapLimitsAndAvailability(address dex_, address token0_, address token1_, uint256 utilizationLimitToken0Percent_, uint256 utilizationLimitToken1Percent_) internal view returns (struct Structs.SwapLimitsAndAvailability limitsAndAvailability_)
get the swap limits and availability for a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
token0_ | address | The address of token0 |
token1_ | address | The address of token1 |
utilizationLimitToken0Percent_ | uint256 | The utilization limit percentage for token0 |
utilizationLimitToken1Percent_ | uint256 | The utilization limit percentage for token1 |
Return Values ​
Name | Type | Description |
---|---|---|
limitsAndAvailability_ | struct Structs.SwapLimitsAndAvailability | A struct containing the swap limits and availability for the DEX |
_getDexState ​
function _getDexState(address dex_, struct IFluidDexT1.CollateralReserves colReserves_, struct IFluidDexT1.DebtReserves debtReserves_) internal view returns (struct Structs.DexState state_)
Get the current state of a DEX