Skip to content

DexFactoryViews ​

Abstract contract providing view functions for DEX factory-related operations

getDexAddress ​

solidity
function getDexAddress(uint256 dexId_) public view returns (address dex_)

Get the address of a DEX given its ID

Parameters ​

NameTypeDescription
dexId_uint256The ID of the DEX

Return Values ​

NameTypeDescription
dex_addressThe address of the DEX

getDexId ​

solidity
function getDexId(address dex_) public view returns (uint256 id_)

Get the ID of a DEX given its address

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
id_uint256The ID of the DEX

getTotalDexes ​

solidity
function getTotalDexes() public view returns (uint256)

Get the total number of DEXes

Return Values ​

NameTypeDescription
[0]uint256The total number of DEXes

getAllDexAddresses ​

solidity
function getAllDexAddresses() public view returns (address[] dexes_)

Get an array of all DEX addresses

Return Values ​

NameTypeDescription
dexes_address[]An array containing all DEX addresses

DexStorageVars ​

Abstract contract providing view functions for DEX storage variables

getDexVariablesRaw ​

solidity
function getDexVariablesRaw(address dex_) public view returns (uint256)

Get the raw DEX variables

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The raw DEX variables

getDexVariables2Raw ​

solidity
function getDexVariables2Raw(address dex_) public view returns (uint256)

Get the raw DEX variables2

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The raw DEX variables2

getTotalSupplySharesRaw ​

solidity
function getTotalSupplySharesRaw(address dex_) public view returns (uint256)

Get the total supply shares slot data of a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The total supply shares

getUserSupplyDataRaw ​

solidity
function getUserSupplyDataRaw(address dex_, address user_) public view returns (uint256)

Get the raw user supply data for a specific user and DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX
user_addressThe address of the user

Return Values ​

NameTypeDescription
[0]uint256The raw user supply data

getTotalBorrowSharesRaw ​

solidity
function getTotalBorrowSharesRaw(address dex_) public view returns (uint256)

Get the total borrow shares slot data of a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The total borrow shares

getUserBorrowDataRaw ​

solidity
function getUserBorrowDataRaw(address dex_, address user_) public view returns (uint256)

Get the raw user borrow data for a specific user and DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX
user_addressThe address of the user

Return Values ​

NameTypeDescription
[0]uint256The raw user borrow data

getOracleRaw ​

solidity
function getOracleRaw(address dex_, uint256 index_) public view returns (uint256)

Get the raw oracle data for a specific DEX and index

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX
index_uint256The index of the oracle data

Return Values ​

NameTypeDescription
[0]uint256The raw oracle data

getRangeShiftRaw ​

solidity
function getRangeShiftRaw(address dex_) public view returns (uint256)

Get the raw range shift for a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The raw range shift

getThresholdShiftRaw ​

solidity
function getThresholdShiftRaw(address dex_) public view returns (uint256)

Get the raw threshold shift for a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The raw threshold shift

getCenterPriceShiftRaw ​

solidity
function getCenterPriceShiftRaw(address dex_) public view returns (uint256)

Get the raw center price shift for a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
[0]uint256The raw center price shift

_calculateStorageSlotUintMapping ​

solidity
function _calculateStorageSlotUintMapping(uint256 slot_, uint256 key_) internal pure returns (bytes32)

Calculate the storage slot for a uint mapping

Parameters ​

NameTypeDescription
slot_uint256The base slot of the mapping
key_uint256The key of the mapping

Return Values ​

NameTypeDescription
[0]bytes32The calculated storage slot

DexActionEstimates ​

estimateSwapIn ​

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

estimates swap IN tokens execution

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

Return Values ​

NameTypeDescription
amountOut_uint256The amount of output tokens received from the swap

estimateSwapOut ​

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

estimates swap OUT tokens execution

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

Return Values ​

NameTypeDescription
amountIn_uint256The amount of input tokens used for the swap

estimateDepositPerfect ​

solidity
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 ​

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

Return Values ​

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

estimateWithdrawPerfect ​

solidity
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 ​

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

Return Values ​

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

estimateBorrowPerfect ​

solidity
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 ​

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

Return Values ​

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

estimatePaybackPerfect ​

solidity
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 ​

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

Return Values ​

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

estimateDeposit ​

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

Estimate deposit of tokens

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

Return Values ​

NameTypeDescription
shares_uint256Estimated amount of shares to be minted

estimateWithdraw ​

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

Estimate withdrawal of tokens

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

Return Values ​

NameTypeDescription
shares_uint256Estimated amount of shares to be burned

estimateBorrow ​

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

Estimate borrowing of tokens

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

Return Values ​

NameTypeDescription
shares_uint256Estimated amount of shares to be minted

estimatePayback ​

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

Estimate paying back of borrowed tokens

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

Return Values ​

NameTypeDescription
shares_uint256Estimated amount of shares to be burned

estimateWithdrawPerfectInOneToken ​

solidity
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 ​

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

Return Values ​

NameTypeDescription
withdrawAmt_uint256Estimated amount of tokens to be withdrawn

estimatePaybackPerfectInOneToken ​

solidity
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 ​

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

Return Values ​

NameTypeDescription
paybackAmt_uint256Estimated amount of tokens to be paid back

_decodeLowLevelUint2x ​

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

_decodeLowLevelUint1x ​

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

DexConstantsViews ​

getDexConstantsView ​

solidity
function getDexConstantsView(address dex_) public view returns (struct IFluidDexT1.ConstantViews constantsView_)

returns all Dex constants

getDexConstantsView2 ​

solidity
function getDexConstantsView2(address dex_) public view returns (struct IFluidDexT1.ConstantViews2 constantsView2_)

returns all Dex constants 2

getDexTokens ​

solidity
function getDexTokens(address dex_) public view returns (address token0_, address token1_)

Get the addresses of the tokens in a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
token0_addressThe address of token0 in the DEX
token1_addressThe address of token1 in the DEX

DexPublicViews ​

getDexPricesAndExchangePrices ​

solidity
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 ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
pex_struct IFluidDexT1.PricesAndExchangePriceA struct containing prices and exchange prices

getDexCollateralReserves ​

solidity
function getDexCollateralReserves(address dex_) public returns (struct IFluidDexT1.CollateralReserves reserves_)

Get the collateral reserves for a DEX

expected to be called via callStatic

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
reserves_struct IFluidDexT1.CollateralReservesA struct containing collateral reserve information

getDexDebtReserves ​

solidity
function getDexDebtReserves(address dex_) public returns (struct IFluidDexT1.DebtReserves reserves_)

Get the debt reserves for a DEX

expected to be called via callStatic

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
reserves_struct IFluidDexT1.DebtReservesA struct containing debt reserve information

getDexOraclePrice ​

solidity
function getDexOraclePrice(address dex_, uint256[] secondsAgos_) external view returns (struct IFluidDexT1.Oracle[] twaps_, uint256 currentPrice_)

get Dex oracle price TWAP data

Parameters ​

NameTypeDescription
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 ​

NameTypeDescription
twaps_struct IFluidDexT1.Oracle[]twap price, lowest price (aka minima) & highest price (aka maxima) between secondsAgo checkpoints
currentPrice_uint256price of pool after the most recent swap

_getDexCollateralReserves ​

solidity
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 ​

solidity
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 ​

solidity
function getUserSupplyData(address dex_, address user_) public view returns (struct Structs.UserSupplyData userSupplyData_)

Get user supply data for a specific DEX and user

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX
user_addressThe address of the user

Return Values ​

NameTypeDescription
userSupplyData_struct Structs.UserSupplyDataStruct containing user supply data

getUserSupplyDatas ​

solidity
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 ​

NameTypeDescription
dex_addressThe address of the DEX
users_address[]Array of user addresses

Return Values ​

NameTypeDescription
userSuppliesData_struct Structs.UserSupplyData[]Array of UserSupplyData structs for each user

getUserBorrowData ​

solidity
function getUserBorrowData(address dex_, address user_) public view returns (struct Structs.UserBorrowData userBorrowData_)

Get user borrow data for a specific DEX and user

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX
user_addressThe address of the user

Return Values ​

NameTypeDescription
userBorrowData_struct Structs.UserBorrowDataStruct containing user borrow data

getUserBorrowDatas ​

solidity
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 ​

NameTypeDescription
dex_addressThe address of the DEX
users_address[]Array of user addresses

Return Values ​

NameTypeDescription
userBorrowingsData_struct Structs.UserBorrowData[]Array of UserBorrowData structs for each user

getUserBorrowSupplyDatas ​

solidity
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 ​

NameTypeDescription
dex_addressThe address of the DEX
users_address[]Array of user addresses

Return Values ​

NameTypeDescription
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 ​

solidity
constructor(address factory_, address liquidity_, address liquidityResolver_, address deployer_) public

getDexState ​

solidity
function getDexState(address dex_) public returns (struct Structs.DexState state_)

Get the current state of a DEX

expected to be called via callStatic

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
state_struct Structs.DexStateA struct containing the current state of the DEX

getDexConfigs ​

solidity
function getDexConfigs(address dex_) public view returns (struct Structs.Configs configs_)

Get the current configurations of a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
configs_struct Structs.ConfigsA struct containing the current configurations of the DEX

getDexSwapLimitsAndAvailability ​

solidity
function getDexSwapLimitsAndAvailability(address dex_) public view returns (struct Structs.SwapLimitsAndAvailability limitsAndAvailability_)

Get the swap limits and availability for a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
limitsAndAvailability_struct Structs.SwapLimitsAndAvailabilityA struct containing the swap limits and availability for the DEX

getDexEntireData ​

solidity
function getDexEntireData(address dex_) public returns (struct Structs.DexEntireData data_)

Get the entire data for a DEX

expected to be called via callStatic

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
data_struct Structs.DexEntireDataA struct containing all the data for the DEX

getDexEntireDatas ​

solidity
function getDexEntireDatas(address[] dexes_) public returns (struct Structs.DexEntireData[] datas_)

Get the entire data for multiple DEXes

expected to be called via callStatic

Parameters ​

NameTypeDescription
dexes_address[]An array of DEX addresses

Return Values ​

NameTypeDescription
datas_struct Structs.DexEntireData[]An array of structs containing all the data for each DEX

getAllDexEntireDatas ​

solidity
function getAllDexEntireDatas() external returns (struct Structs.DexEntireData[] datas_)

Get the entire data for all DEXes

expected to be called via callStatic

Return Values ​

NameTypeDescription
datas_struct Structs.DexEntireData[]An array of structs containing all the data for all DEXes

_getDexSwapLimitsAndAvailability ​

solidity
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 ​

NameTypeDescription
dex_addressThe address of the DEX
token0_addressThe address of token0
token1_addressThe address of token1
utilizationLimitToken0Percent_uint256The utilization limit percentage for token0
utilizationLimitToken1Percent_uint256The utilization limit percentage for token1

Return Values ​

NameTypeDescription
limitsAndAvailability_struct Structs.SwapLimitsAndAvailabilityA struct containing the swap limits and availability for the DEX

_getDexState ​

solidity
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