Skip to content

TokenInterface ​

balanceOf ​

solidity
function balanceOf(address) external view returns (uint256)

DexFactoryViews ​

Abstract contract providing view functions for DEX factory-related operations

getPoolAddress ​

solidity
function getPoolAddress(uint256 poolId_) public view returns (address pool_)

Get the address of a Pool given its ID

Parameters ​

NameTypeDescription
poolId_uint256The ID of the Pool

Return Values ​

NameTypeDescription
pool_addressThe address of the Pool

getTotalPools ​

solidity
function getTotalPools() public view returns (uint256)

Get the total number of Pools

Return Values ​

NameTypeDescription
[0]uint256The total number of Pools

getAllPoolAddresses ​

solidity
function getAllPoolAddresses() public view returns (address[] pools_)

Get an array of all Pool addresses

Return Values ​

NameTypeDescription
pools_address[]An array containing all Pool addresses

DexPublicViews ​

Abstract contract providing view functions for DEX public data

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 in token decimals amounts

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

getDexCollateralReservesAdjusted ​

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

Get the collateral reserves for a DEX scaled to 1e12

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 in token decimals amounts

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

getDexDebtReservesAdjusted ​

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

Get the debt reserves for a DEX scaled to 1e12

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

DexConstantsViews ​

Abstract contract providing view functions for DEX constants

getPoolConstantsView ​

solidity
function getPoolConstantsView(address pool_) public view returns (struct IFluidDexT1.ConstantViews constantsView_)

returns all Pool constants

getPoolConstantsView2 ​

solidity
function getPoolConstantsView2(address pool_) public view returns (struct IFluidDexT1.ConstantViews2 constantsView2_)

returns all Pool constants 2

getPoolTokens ​

solidity
function getPoolTokens(address pool_) public view returns (address token0_, address token1_)

Get the addresses of the tokens in a Pool

Parameters ​

NameTypeDescription
pool_addressThe address of the Pool

Return Values ​

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

DexSwapLimits ​

getDexLimits ​

solidity
function getDexLimits(address dex_) public view returns (struct Structs.DexLimits limits_)

get the swap limits for a DEX

Parameters ​

NameTypeDescription
dex_addressThe address of the DEX

Return Values ​

NameTypeDescription
limits_struct Structs.DexLimitsA struct containing the swap limits for the DEX

DexActionEstimates ​

EstimateMemoryVars ​

solidity
struct EstimateMemoryVars {
  uint256 colTokenInImaginaryReserves;
  uint256 colTokenOutImaginaryReserves;
  uint256 debtTokenInImaginaryReserves;
  uint256 debtTokenOutImaginaryReserves;
  uint256 amountOutCollateralAdjusted;
  uint256 amountOutDebtAdjusted;
  uint256 amountInCollateralAdjusted;
  uint256 amountInDebtAdjusted;
}

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

_decodeLowLevelUint1x ​

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

FluidDexReservesResolver ​

Fluid Dex Reserves resolver Implements various view-only methods to give easy access to Dex protocol reserves data.

constructor ​

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

getPool ​

solidity
function getPool(uint256 poolId_) public view returns (struct Structs.Pool pool_)

Get a Pool's address and its token addresses

Parameters ​

NameTypeDescription
poolId_uint256The ID of the Pool

Return Values ​

NameTypeDescription
pool_struct Structs.PoolThe Pool data

getPoolFee ​

solidity
function getPoolFee(address pool_) public view returns (uint256 fee_)

Get a Pool's fee

Parameters ​

NameTypeDescription
pool_addressThe Pool address

Return Values ​

NameTypeDescription
fee_uint256The Pool fee as 1% = 10000

getAllPools ​

solidity
function getAllPools() public view returns (struct Structs.Pool[] pools_)

Get an array of all Pool addresses and their token addresses

Return Values ​

NameTypeDescription
pools_struct Structs.Pool[]An array containing all Pool data

getPoolReserves ​

solidity
function getPoolReserves(address pool_) public returns (struct Structs.PoolWithReserves poolReserves_)

Get the token addresses, collateral reserves, and debt reserves for a given Pool address

expected to be called via callStatic

Parameters ​

NameTypeDescription
pool_addressThe Pool address

Return Values ​

NameTypeDescription
poolReserves_struct Structs.PoolWithReservesThe Pool data with reserves.

getPoolsReserves ​

solidity
function getPoolsReserves(address[] pools_) public returns (struct Structs.PoolWithReserves[] poolsReserves_)

Get an array of Pool addresses, their token addresses, collateral reserves, and debt reserves for a given array of Pool addresses

expected to be called via callStatic

Parameters ​

NameTypeDescription
pools_address[]The array of Pool addresses

Return Values ​

NameTypeDescription
poolsReserves_struct Structs.PoolWithReserves[]An array containing all Pool data with reserves

getAllPoolsReserves ​

solidity
function getAllPoolsReserves() public returns (struct Structs.PoolWithReserves[] poolsReserves_)

Get an array of all Pool addresses, their token addresses, collateral reserves, and debt reserves

expected to be called via callStatic

Return Values ​

NameTypeDescription
poolsReserves_struct Structs.PoolWithReserves[]An array containing all Pool data with reserves

getPoolReservesAdjusted ​

solidity
function getPoolReservesAdjusted(address pool_) public returns (struct Structs.PoolWithReserves poolReserves_)

Get the token addresses, adjusted collateral reserves, and adjusted debt reserves for a given Pool address

expected to be called via callStatic

Parameters ​

NameTypeDescription
pool_addressThe Pool address

Return Values ​

NameTypeDescription
poolReserves_struct Structs.PoolWithReservesThe Pool data with adjusted reserves scaled to 1e12. balanceTokens are in token decimals.

getPoolsReservesAdjusted ​

solidity
function getPoolsReservesAdjusted(address[] pools_) public returns (struct Structs.PoolWithReserves[] poolsReserves_)

Get an array of Pool addresses, their token addresses, adjusted collateral reserves, and adjusted debt reserves for a given array of Pool addresses

expected to be called via callStatic

Parameters ​

NameTypeDescription
pools_address[]The array of Pool addresses

Return Values ​

NameTypeDescription
poolsReserves_struct Structs.PoolWithReserves[]An array containing all Pool data with adjusted reserves scaled to 1e12

getAllPoolsReservesAdjusted ​

solidity
function getAllPoolsReservesAdjusted() public returns (struct Structs.PoolWithReserves[] poolsReserves_)

Get an array of all Pool addresses, their token addresses, adjusted collateral reserves, and adjusted debt reserves

expected to be called via callStatic

Return Values ​

NameTypeDescription
poolsReserves_struct Structs.PoolWithReserves[]An array containing all Pool data with adjusted reserves scaled to 1e12