FluidVaultResolver ​
Inherits:Helpers
Fluid Vault protocol resolver Implements various view-only methods to give easy access to Vault protocol data.
Functions ​
constructor ​
constructor(address factory_, address liquidityResolver_) Helpers(factory_, liquidityResolver_);
getVaultAddress ​
Get the address of a vault.
function getVaultAddress(uint256 vaultId_) public view returns (address vault_);
Parameters
Name | Type | Description |
---|---|---|
vaultId_ | uint256 | The ID of the vault. |
Returns
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
getVaultType ​
Get the type of a vault.
function getVaultType(address vault_) public view returns (uint256 vaultType_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
vaultType_ | uint256 | The type of the vault. 0 if not a Fluid vault. |
getVaultId ​
Get the ID of a vault.
function getVaultId(address vault_) public view returns (uint256 id_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
id_ | uint256 | The ID of the vault. |
getTokenConfig ​
Get the token configuration.
function getTokenConfig(uint256 nftId_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
nftId_ | uint256 | The ID of the NFT. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The token configuration. |
getVaultVariablesRaw ​
Get the raw variables of a vault.
function getVaultVariablesRaw(address vault_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw variables of the vault. |
getVaultVariables2Raw ​
Get the raw variables of a vault.
function getVaultVariables2Raw(address vault_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw variables of the vault. |
getAbsorbedLiquidityRaw ​
Get the absorbed liquidity of a vault.
function getAbsorbedLiquidityRaw(address vault_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The absorbed liquidity of the vault. |
getPositionDataRaw ​
Get the position data of a vault.
function getPositionDataRaw(address vault_, uint256 positionId_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
positionId_ | uint256 | The ID of the position. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The position data of the vault. |
getTickDataRaw ​
Get the raw tick data of a vault.
function getTickDataRaw(address vault_, int256 tick_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
tick_ | int256 | The tick value. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw tick data of the vault. |
getTickHasDebtRaw ​
Get the raw tick data of a vault.
function getTickHasDebtRaw(address vault_, int256 key_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
key_ | int256 | The tick key. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw tick data of the vault. |
getTickIdDataRaw ​
Get the raw tick data of a vault.
function getTickIdDataRaw(address vault_, int256 tick_, uint256 id_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
tick_ | int256 | The tick value. |
id_ | uint256 | The ID of the tick. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw tick data of the vault. |
getBranchDataRaw ​
Get the raw branch data of a vault.
function getBranchDataRaw(address vault_, uint256 branch_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
branch_ | uint256 | The branch value. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw branch data of the vault. |
getRateRaw ​
Get the raw rate of a vault.
function getRateRaw(address vault_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The raw rate of the vault. |
getRebalancer ​
Get the rebalancer of a vault.
function getRebalancer(address vault_) public view returns (address);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The rebalancer of the vault. |
getAbsorbedDustDebt ​
Get the absorbed dust debt of a vault.
function getAbsorbedDustDebt(address vault_) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The absorbed dust debt of the vault. |
getDexFromAddress ​
Get the DEX from address of a vault.
function getDexFromAddress(address vault_) public view returns (address);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The DEX from address of the vault. |
getTotalVaults ​
Get the total number of vaults.
function getTotalVaults() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total number of vaults. |
getAllVaultsAddresses ​
Get the addresses of all the vaults.
function getAllVaultsAddresses() public view returns (address[] memory vaults_);
Returns
Name | Type | Description |
---|---|---|
vaults_ | address[] | The addresses of all the vaults. |
getContractForDeployerIndex ​
Get the contract for deployer index of a vault.
function getContractForDeployerIndex(address vault_, uint256 index_) public view returns (address);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
index_ | uint256 | The index of the deployer. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The contract for deployer index of the vault. |
_getVaultConstants ​
Get the constants of a vault.
function _getVaultConstants(address vault_, uint256 vaultType_)
internal
view
returns (IFluidVault.ConstantViews memory constants_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
vaultType_ | uint256 | The type of the vault. |
Returns
Name | Type | Description |
---|---|---|
constants_ | IFluidVault.ConstantViews | The constants of the vault. |
_getVaultConfig ​
Get the configuration of a vault.
function _getVaultConfig(address vault_, uint256 vaultType_) internal view returns (Configs memory configs_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
vaultType_ | uint256 | The type of the vault. |
Returns
Name | Type | Description |
---|---|---|
configs_ | Configs | The configuration of the vault. |
_getExchangePricesAndRates ​
Next 30 bits => 92-121 => bits to calculate address of oracle Next 33 bits => 122-154 => last update timestamp
Get the exchange prices and rates of a vault.
function _getExchangePricesAndRates(
address vault_,
uint256 vaultType_,
Configs memory configs_,
uint256 liquiditySupplyRate_,
uint256 liquidityBorrowRate_
) internal view returns (ExchangePricesAndRates memory exchangePricesAndRates_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
vaultType_ | uint256 | The type of the vault. |
configs_ | Configs | The configuration of the vault. |
liquiditySupplyRate_ | uint256 | The liquidity supply rate, only set in case of NOT smart collateral. |
liquidityBorrowRate_ | uint256 | The liquidity borrow rate, only set in case of NOT smart debt. |
Returns
Name | Type | Description |
---|---|---|
exchangePricesAndRates_ | ExchangePricesAndRates | The exchange prices and rates of the vault. |
_getTotalSupplyAndBorrow ​
Get the total supply and borrow of a vault.
function _getTotalSupplyAndBorrow(
address vault_,
ExchangePricesAndRates memory exchangePricesAndRates_,
IFluidVault.ConstantViews memory constantsVariables_
) internal view returns (TotalSupplyAndBorrow memory totalSupplyAndBorrow_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
exchangePricesAndRates_ | ExchangePricesAndRates | The exchange prices and rates of the vault. |
constantsVariables_ | IFluidVault.ConstantViews | The constants and variables of the vault. |
Returns
Name | Type | Description |
---|---|---|
totalSupplyAndBorrow_ | TotalSupplyAndBorrow | The total supply and borrow of the vault. |
_getLimitsAndAvailability ​
Calculates limits and availability for a user's vault operations.
function _getLimitsAndAvailability(
ExchangePricesAndRates memory exchangePricesAndRates_,
IFluidVault.ConstantViews memory constantsVariables_,
uint256 withdrawalGapConfig_,
uint256 borrowLimit_,
uint256 borrowLimitUtilization_,
uint256 borrowableUntilLimit_
) internal view returns (LimitsAndAvailability memory limitsAndAvailability_);
Parameters
Name | Type | Description |
---|---|---|
exchangePricesAndRates_ | ExchangePricesAndRates | Exchange prices and rates for the vault. |
constantsVariables_ | IFluidVault.ConstantViews | Constants and variables for the vault. |
withdrawalGapConfig_ | uint256 | Configuration for the withdrawal gap. |
borrowLimit_ | uint256 | The borrow limit for the user. Only set if not smart debt. |
borrowLimitUtilization_ | uint256 | The utilization of the borrow limit. Only set if not smart debt. |
borrowableUntilLimit_ | uint256 | The limit until which borrowing is allowed. Only set if not smart debt. |
Returns
Name | Type | Description |
---|---|---|
limitsAndAvailability_ | LimitsAndAvailability | The calculated limits and availability for the user's vault operations. |
getVaultState ​
Retrieves the state of a given vault.
function getVaultState(address vault_) public view returns (VaultState memory vaultState_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault to retrieve the state for. |
Returns
Name | Type | Description |
---|---|---|
vaultState_ | VaultState | The state of the vault, including top tick, current and total branches, total supply and borrow, total positions, and current branch state. |
getVaultEntireData ​
Retrieves the entire data for a given vault.
function getVaultEntireData(address vault_) public view returns (VaultEntireData memory vaultData_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault to retrieve the data for. |
Returns
Name | Type | Description |
---|---|---|
vaultData_ | VaultEntireData | The entire data of the vault. |
getVaultsEntireData ​
Retrieves the entire data for a list of vaults.
function getVaultsEntireData(address[] memory vaults_) external view returns (VaultEntireData[] memory vaultsData_);
Parameters
Name | Type | Description |
---|---|---|
vaults_ | address[] | The list of vault addresses. |
Returns
Name | Type | Description |
---|---|---|
vaultsData_ | VaultEntireData[] | An array of VaultEntireData structures containing the data for each vault. |
getVaultsEntireData ​
Retrieves the entire data for all vaults.
function getVaultsEntireData() external view returns (VaultEntireData[] memory vaultsData_);
Returns
Name | Type | Description |
---|---|---|
vaultsData_ | VaultEntireData[] | An array of VaultEntireData structures containing the data for each vault. |
positionByNftId ​
Retrieves the position data for a given NFT ID and the corresponding vault data.
function positionByNftId(uint256 nftId_)
public
view
returns (UserPosition memory userPosition_, VaultEntireData memory vaultData_);
Parameters
Name | Type | Description |
---|---|---|
nftId_ | uint256 | The NFT ID for which to retrieve the position data. |
Returns
Name | Type | Description |
---|---|---|
userPosition_ | UserPosition | The UserPosition structure containing the position data. |
vaultData_ | VaultEntireData | The VaultEntireData structure containing the vault data. |
positionsNftIdOfUser ​
Returns an array of NFT IDs for all positions of a given user.
function positionsNftIdOfUser(address user_) public view returns (uint256[] memory nftIds_);
Parameters
Name | Type | Description |
---|---|---|
user_ | address | The address of the user for whom to fetch positions. |
Returns
Name | Type | Description |
---|---|---|
nftIds_ | uint256[] | An array of NFT IDs representing the user's positions. |
vaultByNftId ​
Returns the vault address associated with a given NFT ID.
function vaultByNftId(uint256 nftId_) public view returns (address vault_);
Parameters
Name | Type | Description |
---|---|---|
nftId_ | uint256 | The NFT ID for which to fetch the vault address. |
Returns
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault associated with the NFT ID. |
positionsByUser ​
Fetches all positions and their corresponding vault data for a given user.
function positionsByUser(address user_)
external
view
returns (UserPosition[] memory userPositions_, VaultEntireData[] memory vaultsData_);
Parameters
Name | Type | Description |
---|---|---|
user_ | address | The address of the user for whom to fetch positions and vault data. |
Returns
Name | Type | Description |
---|---|---|
userPositions_ | UserPosition[] | An array of UserPosition structs representing the user's positions. |
vaultsData_ | VaultEntireData[] | An array of VaultEntireData structs representing the vault data for each position. |
totalPositions ​
Returns the total number of positions across all users.
function totalPositions() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total number of positions. |
getVaultLiquidation ​
fetches available liquidations
function getVaultLiquidation(address vault_, uint256 tokenInAmt_)
public
returns (LiquidationStruct memory liquidationData_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | address of vault for which to fetch |
tokenInAmt_ | uint256 | token in aka debt to payback, leave 0 to get max |
Returns
Name | Type | Description |
---|---|---|
liquidationData_ | LiquidationStruct | liquidation related data. Check out structs.sol |
_decodeLiquidationResult ​
helper method to decode liquidation result revert data
function _decodeLiquidationResult(bytes memory lowLevelData_) internal pure returns (uint256 amtIn_, uint256 amtOut_);
getMultipleVaultsLiquidation ​
Retrieves liquidation data for multiple vaults.
function getMultipleVaultsLiquidation(address[] memory vaults_, uint256[] memory tokensInAmt_)
external
returns (LiquidationStruct[] memory liquidationsData_);
Parameters
Name | Type | Description |
---|---|---|
vaults_ | address[] | The array of vault addresses. |
tokensInAmt_ | uint256[] | The array of token amounts to liquidate. |
Returns
Name | Type | Description |
---|---|---|
liquidationsData_ | LiquidationStruct[] | An array of LiquidationStruct containing the liquidation data for each vault. |
getAllVaultsLiquidation ​
Retrieves liquidation data for all vaults.
function getAllVaultsLiquidation() external returns (LiquidationStruct[] memory liquidationsData_);
Returns
Name | Type | Description |
---|---|---|
liquidationsData_ | LiquidationStruct[] | An array of LiquidationStruct containing the liquidation data for all vaults. |
getVaultAbsorb ​
DEPRECATED, only works for vaults v1.0.0: Retrieves absorb data for a single vault.
function getVaultAbsorb(address vault_) public returns (AbsorbStruct memory absorbData_);
Parameters
Name | Type | Description |
---|---|---|
vault_ | address | The address of the vault. |
Returns
Name | Type | Description |
---|---|---|
absorbData_ | AbsorbStruct | The AbsorbStruct containing the absorb data for the vault. |
getVaultsAbsorb ​
DEPRECATED, only works for vaults v1.0.0: Retrieves absorb data for multiple vaults.
function getVaultsAbsorb(address[] memory vaults_) public returns (AbsorbStruct[] memory absorbData_);
Parameters
Name | Type | Description |
---|---|---|
vaults_ | address[] | The array of vault addresses. |
Returns
Name | Type | Description |
---|---|---|
absorbData_ | AbsorbStruct[] | An array of AbsorbStruct containing the absorb data for each vault. |
getVaultsAbsorb ​
DEPRECATED, only works for vaults v1.0.0: Retrieves absorb data for all vaults.
function getVaultsAbsorb() public returns (AbsorbStruct[] memory absorbData_);
Returns
Name | Type | Description |
---|---|---|
absorbData_ | AbsorbStruct[] | An array of AbsorbStruct containing the absorb data for all vaults. |