TokenInterface ​
balanceOf ​
function balanceOf(address) external view returns (uint256)
DexFactoryViews ​
Abstract contract providing view functions for DEX factory-related operations
getPoolAddress ​
function getPoolAddress(uint256 poolId_) public view returns (address pool_)
Get the address of a Pool given its ID
Parameters ​
Name | Type | Description |
---|---|---|
poolId_ | uint256 | The ID of the Pool |
Return Values ​
Name | Type | Description |
---|---|---|
pool_ | address | The address of the Pool |
getTotalPools ​
function getTotalPools() public view returns (uint256)
Get the total number of Pools
Return Values ​
Name | Type | Description |
---|---|---|
[0] | uint256 | The total number of Pools |
getAllPoolAddresses ​
function getAllPoolAddresses() public view returns (address[] pools_)
Get an array of all Pool addresses
Return Values ​
Name | Type | Description |
---|---|---|
pools_ | address[] | An array containing all Pool addresses |
DexPublicViews ​
Abstract contract providing view functions for DEX public data
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 in token decimals amounts
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 |
getDexCollateralReservesAdjusted ​
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 ​
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 in token decimals amounts
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 |
getDexDebtReservesAdjusted ​
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 ​
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 |
DexConstantsViews ​
Abstract contract providing view functions for DEX constants
getPoolConstantsView ​
function getPoolConstantsView(address pool_) public view returns (struct IFluidDexT1.ConstantViews constantsView_)
returns all Pool constants
getPoolConstantsView2 ​
function getPoolConstantsView2(address pool_) public view returns (struct IFluidDexT1.ConstantViews2 constantsView2_)
returns all Pool constants 2
getPoolTokens ​
function getPoolTokens(address pool_) public view returns (address token0_, address token1_)
Get the addresses of the tokens in a Pool
Parameters ​
Name | Type | Description |
---|---|---|
pool_ | address | The address of the Pool |
Return Values ​
Name | Type | Description |
---|---|---|
token0_ | address | The address of token0 in the Pool |
token1_ | address | The address of token1 in the Pool |
DexSwapLimits ​
getDexLimits ​
function getDexLimits(address dex_) public view returns (struct Structs.DexLimits limits_)
get the swap limits for a DEX
Parameters ​
Name | Type | Description |
---|---|---|
dex_ | address | The address of the DEX |
Return Values ​
Name | Type | Description |
---|---|---|
limits_ | struct Structs.DexLimits | A struct containing the swap limits for the DEX |
DexActionEstimates ​
EstimateMemoryVars ​
struct EstimateMemoryVars {
uint256 colTokenInImaginaryReserves;
uint256 colTokenOutImaginaryReserves;
uint256 debtTokenInImaginaryReserves;
uint256 debtTokenOutImaginaryReserves;
uint256 amountOutCollateralAdjusted;
uint256 amountOutDebtAdjusted;
uint256 amountInCollateralAdjusted;
uint256 amountInDebtAdjusted;
}
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 |
_decodeLowLevelUint1x ​
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 ​
constructor(address factory_, address liquidity_, address liquidityResolver_) public
getPool ​
function getPool(uint256 poolId_) public view returns (struct Structs.Pool pool_)
Get a Pool's address and its token addresses
Parameters ​
Name | Type | Description |
---|---|---|
poolId_ | uint256 | The ID of the Pool |
Return Values ​
Name | Type | Description |
---|---|---|
pool_ | struct Structs.Pool | The Pool data |
getPoolFee ​
function getPoolFee(address pool_) public view returns (uint256 fee_)
Get a Pool's fee
Parameters ​
Name | Type | Description |
---|---|---|
pool_ | address | The Pool address |
Return Values ​
Name | Type | Description |
---|---|---|
fee_ | uint256 | The Pool fee as 1% = 10000 |
getAllPools ​
function getAllPools() public view returns (struct Structs.Pool[] pools_)
Get an array of all Pool addresses and their token addresses
Return Values ​
Name | Type | Description |
---|---|---|
pools_ | struct Structs.Pool[] | An array containing all Pool data |
getPoolReserves ​
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 ​
Name | Type | Description |
---|---|---|
pool_ | address | The Pool address |
Return Values ​
Name | Type | Description |
---|---|---|
poolReserves_ | struct Structs.PoolWithReserves | The Pool data with reserves. |
getPoolsReserves ​
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 ​
Name | Type | Description |
---|---|---|
pools_ | address[] | The array of Pool addresses |
Return Values ​
Name | Type | Description |
---|---|---|
poolsReserves_ | struct Structs.PoolWithReserves[] | An array containing all Pool data with reserves |
getAllPoolsReserves ​
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 ​
Name | Type | Description |
---|---|---|
poolsReserves_ | struct Structs.PoolWithReserves[] | An array containing all Pool data with reserves |
getPoolReservesAdjusted ​
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 ​
Name | Type | Description |
---|---|---|
pool_ | address | The Pool address |
Return Values ​
Name | Type | Description |
---|---|---|
poolReserves_ | struct Structs.PoolWithReserves | The Pool data with adjusted reserves scaled to 1e12. balanceTokens are in token decimals. |
getPoolsReservesAdjusted ​
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 ​
Name | Type | Description |
---|---|---|
pools_ | address[] | The array of Pool addresses |
Return Values ​
Name | Type | Description |
---|---|---|
poolsReserves_ | struct Structs.PoolWithReserves[] | An array containing all Pool data with adjusted reserves scaled to 1e12 |
getAllPoolsReservesAdjusted ​
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 ​
Name | Type | Description |
---|---|---|
poolsReserves_ | struct Structs.PoolWithReserves[] | An array containing all Pool data with adjusted reserves scaled to 1e12 |