Skip to content

Structs ​

Git Source

Structs ​

Configs ​

solidity
struct Configs {
    // can be supplyRate instead if Vault Type is smart col. in that case if 1st bit == 1 then positive else negative
    uint16 supplyRateMagnifier;
    // can be borrowRate instead if Vault Type is smart debt. in that case if 1st bit == 1 then positive else negative
    uint16 borrowRateMagnifier;
    uint16 collateralFactor;
    uint16 liquidationThreshold;
    uint16 liquidationMaxLimit;
    uint16 withdrawalGap;
    uint16 liquidationPenalty;
    uint16 borrowFee;
    address oracle;
    // Oracle price is always debt per col, i.e. amount of debt for 1 col.
    // In case of Dex this price can be used to resolve shares values w.r.t. token0 or token1:
    // - T2: debt token per 1 col share
    // - T3: debt shares per 1 col token
    // - T4: debt shares per 1 col share
    uint256 oraclePriceOperate;
    uint256 oraclePriceLiquidate;
    address rebalancer;
    uint256 lastUpdateTimestamp;
}

ExchangePricesAndRates ​

solidity
struct ExchangePricesAndRates {
    uint256 lastStoredLiquiditySupplyExchangePrice; // 0 in case of smart col
    uint256 lastStoredLiquidityBorrowExchangePrice; // 0 in case of smart debt
    uint256 lastStoredVaultSupplyExchangePrice;
    uint256 lastStoredVaultBorrowExchangePrice;
    uint256 liquiditySupplyExchangePrice; // set to 1e12 in case of smart col
    uint256 liquidityBorrowExchangePrice; // set to 1e12 in case of smart debt
    uint256 vaultSupplyExchangePrice;
    uint256 vaultBorrowExchangePrice;
    uint256 supplyRateLiquidity; // set to 0 in case of smart col. Must get per token through DexEntireData
    uint256 borrowRateLiquidity; // set to 0 in case of smart debt. Must get per token through DexEntireData
    // supplyRateVault or borrowRateVault:
    // - when normal col / debt: rate at liquidity + diff rewards or fee through magnifier (rewardsOrFeeRate below)
    // - when smart col / debt: rewards or fee rate at the vault itself. always == rewardsOrFeeRate below.
    // to get the full rates for vault when smart col / debt, combine with data from DexResolver:
    // - rateAtLiquidity for token0 or token1 (DexResolver)
    // - the rewards or fee rate at the vault (VaultResolver)
    // - the Dex APR (currently off-chain compiled through tracking swap events at the DEX)
    int256 supplyRateVault; // can be negative in case of smart col (meaning pay to supply)
    int256 borrowRateVault; // can be negative in case of smart debt (meaning get paid to borrow)
    // rewardsOrFeeRateSupply: rewards or fee rate in percent 1e2 precision (1% = 100, 100% = 10000).
    // positive rewards, negative fee.
    // for smart col vaults: absolute percent, supplyRateVault == rewardsOrFeeRateSupply.
    // for normal col vaults: relative percent to supplyRateLiquidity, e.g.:
    // when rewards: supplyRateLiquidity = 4%, rewardsOrFeeRateSupply = 20%, supplyRateVault = 4.8%.
    // when fee: supplyRateLiquidity = 4%, rewardsOrFeeRateSupply = -30%, supplyRateVault = 2.8%.
    int256 rewardsOrFeeRateSupply;
    // rewardsOrFeeRateBorrow: rewards or fee rate in percent 1e2 precision (1% = 100, 100% = 10000).
    // negative rewards, positive fee.
    // for smart debt vaults: absolute percent, borrowRateVault == rewardsOrFeeRateBorrow.
    // for normal debt vaults: relative percent to borrowRateLiquidity, e.g.:
    // when rewards: borrowRateLiquidity = 4%, rewardsOrFeeRateBorrow = -20%, borrowRateVault = 3.2%.
    // when fee: borrowRateLiquidity = 4%, rewardsOrFeeRateBorrow = 30%, borrowRateVault = 5.2%.
    int256 rewardsOrFeeRateBorrow;
}

TotalSupplyAndBorrow ​

solidity
struct TotalSupplyAndBorrow {
    uint256 totalSupplyVault;
    uint256 totalBorrowVault;
    uint256 totalSupplyLiquidityOrDex;
    uint256 totalBorrowLiquidityOrDex;
    uint256 absorbedSupply;
    uint256 absorbedBorrow;
}

LimitsAndAvailability ​

solidity
struct LimitsAndAvailability {
    // in case of DEX: withdrawable / borrowable amount of vault at DEX, BUT there could be that DEX can not withdraw
    // that much at Liquidity! So for DEX this must be combined with returned data in DexResolver.
    uint256 withdrawLimit;
    uint256 withdrawableUntilLimit;
    uint256 withdrawable;
    uint256 borrowLimit;
    uint256 borrowableUntilLimit; // borrowable amount until any borrow limit (incl. max utilization limit)
    uint256 borrowable; // actual currently borrowable amount (borrow limit - already borrowed) & considering balance, max utilization
    uint256 borrowLimitUtilization; // borrow limit for `maxUtilization` config at Liquidity
    uint256 minimumBorrowing;
}

CurrentBranchState ​

solidity
struct CurrentBranchState {
    uint256 status; // if 0 then not liquidated, if 1 then liquidated, if 2 then merged, if 3 then closed
    int256 minimaTick;
    uint256 debtFactor;
    uint256 partials;
    uint256 debtLiquidity;
    uint256 baseBranchId;
    int256 baseBranchMinima;
}

VaultState ​

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

VaultEntireData ​

solidity
struct VaultEntireData {
    address vault;
    bool isSmartCol; // true if col token is a Fluid Dex
    bool isSmartDebt; // true if debt token is a Fluid Dex
    IFluidVault.ConstantViews constantVariables;
    Configs configs;
    ExchangePricesAndRates exchangePricesAndRates;
    TotalSupplyAndBorrow totalSupplyAndBorrow;
    LimitsAndAvailability limitsAndAvailability;
    VaultState vaultState;
    // liquidity related data such as supply amount, limits, expansion etc.
    // Also set for Dex, limits are in shares and same things apply as noted for LimitsAndAvailability above!
    FluidLiquidityResolverStructs.UserSupplyData liquidityUserSupplyData;
    // liquidity related data such as borrow amount, limits, expansion etc.
    // Also set for Dex, limits are in shares and same things apply as noted for LimitsAndAvailability above!
    FluidLiquidityResolverStructs.UserBorrowData liquidityUserBorrowData;
}

UserPosition ​

solidity
struct UserPosition {
    uint256 nftId;
    address owner;
    bool isLiquidated;
    bool isSupplyPosition; // if true that means borrowing is 0
    int256 tick;
    uint256 tickId;
    uint256 beforeSupply;
    uint256 beforeBorrow;
    uint256 beforeDustBorrow;
    uint256 supply;
    uint256 borrow;
    uint256 dustBorrow;
}

LiquidationStruct ​

liquidation related data

Liquidity in with absirb will always be >= without asborb. Sometimes without asborb can provide better swaps, sometimes with absirb can provide better swaps. But available in with absirb will always be >= One

solidity
struct LiquidationStruct {
    address vault;
    address token0In;
    address token0Out;
    address token1In;
    address token1Out;
    // amounts in case of smart debt are in shares, otherwise token amounts.
    // smart col can not be liquidated so to exchange inAmt always use DexResolver DexState.tokenPerDebtShare
    // and tokenPerColShare for outAmt when Vault is smart col.
    uint256 inAmt;
    uint256 outAmt;
    uint256 inAmtWithAbsorb;
    uint256 outAmtWithAbsorb;
    bool absorbAvailable;
}

Properties

NameTypeDescription
vaultaddressaddress of vault
token0Inaddressaddress of token in
token0Outaddressaddress of token out
token1Inaddressaddress of token in (if smart debt)
token1Outaddressaddress of token out (if smart col)
inAmtuint256(without absorb liquidity) minimum of available liquidation
outAmtuint256(without absorb liquidity) expected token out, collateral to withdraw
inAmtWithAbsorbuint256(absorb liquidity included) minimum of available liquidation. In most cases it'll be same as inAmt but sometimes can be bigger.
outAmtWithAbsorbuint256(absorb liquidity included) expected token out, collateral to withdraw. In most cases it'll be same as outAmt but sometimes can be bigger.
absorbAvailablebooltrue if absorb is available

AbsorbStruct ​

solidity
struct AbsorbStruct {
    address vault;
    bool absorbAvailable;
}