Vault Resolver

IFluidVaultResolver

vaultByNftId

function vaultByNftId(uint256 nftId_) external view returns (address vault_)

positionByNftId

function positionByNftId(uint256 nftId_) external view returns (struct Structs.UserPosition userPosition_, struct Structs.VaultEntireData vaultData_)

getVaultVariablesRaw

function getVaultVariablesRaw(address vault_) external view returns (uint256)

getAllVaultsAddresses

function getAllVaultsAddresses() external view returns (address[] vaults_)

getVaultLiquidation

function getVaultLiquidation(address vault_, uint256 tokenInAmt_) external returns (struct Structs.LiquidationStruct liquidationData_)

getVaultEntireData

function getVaultEntireData(address vault_) external view returns (struct Structs.VaultEntireData vaultData_)

Helpers

normalSlot

function normalSlot(uint256 slot_) public pure returns (bytes32)

calculateStorageSlotUintMapping

function calculateStorageSlotUintMapping(uint256 slot_, uint256 key_) public pure returns (bytes32)

Calculating the slot ID for Liquidity contract for single mapping

calculateStorageSlotIntMapping

function calculateStorageSlotIntMapping(uint256 slot_, int256 key_) public pure returns (bytes32)

Calculating the slot ID for Liquidity contract for single mapping

calculateDoubleIntUintMapping

function calculateDoubleIntUintMapping(uint256 slot_, int256 key1_, uint256 key2_) public pure returns (bytes32)

Calculating the slot ID for Liquidity contract for double mapping

tickHelper

function tickHelper(uint256 tickRaw_) public pure returns (int256 tick)

constructor

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

Structs

Configs

struct Configs {
  uint16 supplyRateMagnifier;
  uint16 borrowRateMagnifier;
  uint16 collateralFactor;
  uint16 liquidationThreshold;
  uint16 liquidationMaxLimit;
  uint16 withdrawalGap;
  uint16 liquidationPenalty;
  uint16 borrowFee;
  address oracle;
  uint256 oraclePrice;
  address rebalancer;
}

ExchangePricesAndRates

struct ExchangePricesAndRates {
  uint256 lastStoredLiquiditySupplyExchangePrice;
  uint256 lastStoredLiquidityBorrowExchangePrice;
  uint256 lastStoredVaultSupplyExchangePrice;
  uint256 lastStoredVaultBorrowExchangePrice;
  uint256 liquiditySupplyExchangePrice;
  uint256 liquidityBorrowExchangePrice;
  uint256 vaultSupplyExchangePrice;
  uint256 vaultBorrowExchangePrice;
  uint256 supplyRateVault;
  uint256 borrowRateVault;
  uint256 supplyRateLiquidity;
  uint256 borrowRateLiquidity;
  uint256 rewardsRate;
}

TotalSupplyAndBorrow

struct TotalSupplyAndBorrow {
  uint256 totalSupplyVault;
  uint256 totalBorrowVault;
  uint256 totalSupplyLiquidity;
  uint256 totalBorrowLiquidity;
  uint256 absorbedSupply;
  uint256 absorbedBorrow;
}

LimitsAndAvailability

struct LimitsAndAvailability {
  uint256 withdrawLimit;
  uint256 withdrawableUntilLimit;
  uint256 withdrawable;
  uint256 borrowLimit;
  uint256 borrowableUntilLimit;
  uint256 borrowable;
  uint256 minimumBorrowing;
}

CurrentBranchState

struct CurrentBranchState {
  uint256 status;
  int256 minimaTick;
  uint256 debtFactor;
  uint256 partials;
  uint256 debtLiquidity;
  uint256 baseBranchId;
  int256 baseBranchMinima;
}

VaultState

struct VaultState {
  uint256 totalPositions;
  int256 topTick;
  uint256 currentBranch;
  uint256 totalBranch;
  uint256 totalBorrow;
  uint256 totalSupply;
  struct Structs.CurrentBranchState currentBranchState;
}

VaultEntireData

struct VaultEntireData {
  address vault;
  struct IFluidVaultT1.ConstantViews constantVariables;
  struct Structs.Configs configs;
  struct Structs.ExchangePricesAndRates exchangePricesAndRates;
  struct Structs.TotalSupplyAndBorrow totalSupplyAndBorrow;
  struct Structs.LimitsAndAvailability limitsAndAvailability;
  struct Structs.VaultState vaultState;
  struct Structs.UserSupplyData liquidityUserSupplyData;
  struct Structs.UserBorrowData liquidityUserBorrowData;
}

UserPosition

struct UserPosition {
  uint256 nftId;
  address owner;
  bool isLiquidated;
  bool isSupplyPosition;
  int256 tick;
  uint256 tickId;
  uint256 beforeSupply;
  uint256 beforeBorrow;
  uint256 beforeDustBorrow;
  uint256 supply;
  uint256 borrow;
  uint256 dustBorrow;
}

LiquidationStruct

liquidation related data Liquidity in Two will always be >= One. Sometimes One can provide better swaps, sometimes Two can provide better swaps. But available in Two will always be >= One

Parameters

NameTypeDescription
struct LiquidationStruct {
  address vault;
  address tokenIn;
  address tokenOut;
  uint256 tokenInAmtOne;
  uint256 tokenOutAmtOne;
  uint256 tokenInAmtTwo;
  uint256 tokenOutAmtTwo;
}

AbsorbStruct

struct AbsorbStruct {
  address vault;
  bool absorbAvailable;
}

FluidVaultResolver

Fluid Vault protocol resolver Implements various view-only methods to give easy access to Vault protocol data.

getVaultAddress

function getVaultAddress(uint256 vaultId_) public view returns (address vault_)

getVaultId

function getVaultId(address vault_) public view returns (uint256 id_)

getTokenConfig

function getTokenConfig(uint256 nftId_) public view returns (uint256)

getVaultVariablesRaw

function getVaultVariablesRaw(address vault_) public view returns (uint256)

getVaultVariables2Raw

function getVaultVariables2Raw(address vault_) public view returns (uint256)

getAbsorbedLiquidityRaw

function getAbsorbedLiquidityRaw(address vault_) public view returns (uint256)

getPositionDataRaw

function getPositionDataRaw(address vault_, uint256 positionId_) public view returns (uint256)

getTickHasDebtRaw

function getTickHasDebtRaw(address vault_, int256 key_) public view returns (uint256)

getTickDataRaw

function getTickDataRaw(address vault_, int256 tick_) public view returns (uint256)

getTickIdDataRaw

function getTickIdDataRaw(address vault_, int256 tick_, uint256 id_) public view returns (uint256)

getBranchDataRaw

function getBranchDataRaw(address vault_, uint256 branch_) public view returns (uint256)

getRateRaw

function getRateRaw(address vault_) public view returns (uint256)

getRebalancer

function getRebalancer(address vault_) public view returns (address)

getTotalVaults

function getTotalVaults() public view returns (uint256)

getAllVaultsAddresses

function getAllVaultsAddresses() public view returns (address[] vaults_)

getVaultConstants

function getVaultConstants(address vault_) internal view returns (struct IFluidVaultT1.ConstantViews constants_)

getVaultConfig

function getVaultConfig(address vault_) internal view returns (struct Structs.Configs configs_)

getExchangePricesAndRates

function getExchangePricesAndRates(address vault_, struct Structs.Configs configs_, struct Structs.OverallTokenData liquiditySupplytokenData_, struct Structs.OverallTokenData liquidityBorrowtokenData_) internal view returns (struct Structs.ExchangePricesAndRates exchangePricesAndRates_)

getTotalSupplyAndBorrow

function getTotalSupplyAndBorrow(address vault_, struct Structs.ExchangePricesAndRates exchangePricesAndRates_, struct IFluidVaultT1.ConstantViews constantsVariables_) internal view returns (struct Structs.TotalSupplyAndBorrow totalSupplyAndBorrow_)

getLimitsAndAvailability

function getLimitsAndAvailability(struct Structs.TotalSupplyAndBorrow totalSupplyAndBorrow_, struct Structs.ExchangePricesAndRates exchangePricesAndRates_, struct IFluidVaultT1.ConstantViews constantsVariables_, struct Structs.Configs configs_) internal view returns (struct Structs.LimitsAndAvailability limitsAndAvailability_)

getVaultState

function getVaultState(address vault_) public view returns (struct Structs.VaultState vaultState_)

getVaultEntireData

function getVaultEntireData(address vault_) public view returns (struct Structs.VaultEntireData vaultData_)

getVaultsEntireData

function getVaultsEntireData(address[] vaults_) external view returns (struct Structs.VaultEntireData[] vaultsData_)

getVaultsEntireData

function getVaultsEntireData() external view returns (struct Structs.VaultEntireData[] vaultsData_)

positionByNftId

function positionByNftId(uint256 nftId_) public view returns (struct Structs.UserPosition userPosition_, struct Structs.VaultEntireData vaultData_)

positionsNftIdOfUser

function positionsNftIdOfUser(address user_) public view returns (uint256[] nftIds_)

vaultByNftId

function vaultByNftId(uint256 nftId_) public view returns (address vault_)

positionsByUser

function positionsByUser(address user_) external view returns (struct Structs.UserPosition[] userPositions_, struct Structs.VaultEntireData[] vaultsData_)

totalPositions

function totalPositions() external view returns (uint256)

getVaultLiquidation

function getVaultLiquidation(address vault_, uint256 tokenInAmt_) public returns (struct Structs.LiquidationStruct liquidationData_)

fetches available liquidations

Parameters

NameTypeDescription
vault_addressaddress of vault for which to fetch
tokenInAmt_uint256token in aka debt to payback, leave 0 to get max

Return Values

NameTypeDescription
liquidationData_struct Structs.LiquidationStructliquidation related data. Check out structs.sol

getMultipleVaultsLiquidation

function getMultipleVaultsLiquidation(address[] vaults_, uint256[] tokensInAmt_) external returns (struct Structs.LiquidationStruct[] liquidationsData_)

getAllVaultsLiquidation

function getAllVaultsLiquidation() external returns (struct Structs.LiquidationStruct[] liquidationsData_)

constructor

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

getVaultAbsorb

function getVaultAbsorb(address vault_) public returns (struct Structs.AbsorbStruct absorbData_)

getVaultsAbsorb

function getVaultsAbsorb(address[] vaults_) public returns (struct Structs.AbsorbStruct[] absorbData_)

getVaultsAbsorb

function getVaultsAbsorb() public returns (struct Structs.AbsorbStruct[] absorbData_)