Skip to content

FluidCappedRateBase ​

Git Source

Inherits:CappedRateInternals, CappedRateAdmin, IFluidCappedRate

This contract stores an exchange rate with caps in intervals to optimize gas cost.

Properly implements all interfaces for use as IFluidCenterPrice and IFluidOracle.

Functions ​

validAddress ​

Validates that an address is not the zero address

solidity
modifier validAddress(address value_);

constructor ​

solidity
constructor(CappedRateConstructorParams memory params_)
    validAddress(params_.liquidity)
    validAddress(params_.rateSource);

getExchangeRate ​

Deprecated. Use getExchangeRateOperate() and getExchangeRateLiquidate() instead. Only implemented for backwards compatibility.

solidity
function getExchangeRate() public view virtual returns (uint256 exchangeRate_);

getExchangeRateOperate ​

Get the exchangeRate_ between the underlying asset and the peg asset in 1e27 for operates

solidity
function getExchangeRateOperate() public view virtual returns (uint256 exchangeRate_);

getExchangeRateLiquidate ​

Get the exchangeRate_ between the underlying asset and the peg asset in 1e27 for liquidations

solidity
function getExchangeRateLiquidate() public view virtual returns (uint256 exchangeRate_);

getExchangeRateOperateDebt ​

Get the operate() exchange rate for debt asset side, with no cap upwards and capped decrease

solidity
function getExchangeRateOperateDebt() public view virtual returns (uint256 exchangeRate_);

getExchangeRateLiquidateDebt ​

Get the liquidate() exchange rate for debt asset side, with max APR cap upwards, and capped decrease

solidity
function getExchangeRateLiquidateDebt() public view virtual returns (uint256 exchangeRate_);

rebalance ​

Rebalance the stored rates according to the newly fetched rate from the external source.

The rate is only updated if the difference between the current rate and the new rate is greater than or equal to the minimum update difference percentage for either rate or maxRate OR if the heartbeat is reached

solidity
function rebalance() external;

getRatesAndCaps ​

Returns rates: capped and uncapped, and current cap status

solidity
function getRatesAndCaps()
    public
    view
    returns (
        uint256 rate_,
        uint256 maxReachedRate_,
        uint256 maxUpCappedRateDebt_,
        bool isRateBelowMaxReached_,
        bool isUpMaxAPRCapped_,
        uint256 downCappedRateCol_,
        uint256 downCappedRateDebt_,
        bool isDownCappedCol_,
        bool isDownCappedDebt_,
        bool isUpCapped_
    );

Returns

NameTypeDescription
rate_uint256The rate_ value: last fetched value from external source with no cap up and no cap down as in storage
maxReachedRate_uint256The maximum reached upward capped rate for col: within APR percent limit as in storage
maxUpCappedRateDebt_uint256The maximum reached upward capped rate for debt: up to maxReachedRate_ + maxDebtUpCapPercent on top
isRateBelowMaxReached_boolIndicates if the rate is currently below the maximum reached APR capped rate flag as in storage
isUpMaxAPRCapped_boolIndicates if the rate is currently capped due to exceeding the maximum APR limit flag as in storage
downCappedRateCol_uint256The capped downward rate on col side
downCappedRateDebt_uint256The capped downward rate on debt side
isDownCappedCol_boolIndicates if the rate is currently getting downward capped on col side
isDownCappedDebt_boolIndicates if the rate is currently getting downward capped on debt side
isUpCapped_boolIndicates if the rate is currently getting upward capped

configPercentDiff ​

returns how much the new rate OR new max rate would be different from current value in storage in percent (10000 = 1%, 1 = 0.0001%).

solidity
function configPercentDiff() public view virtual returns (uint256 configPercentDiff_);

configData ​

returns all config vars, last update timestamp, and external rate source oracle address

solidity
function configData()
    external
    view
    returns (
        address liquidity_,
        uint16 minUpdateDiffPercent_,
        uint24 minHeartbeat_,
        uint40 lastUpdateTime_,
        address rateSource_,
        bool invertCenterPrice_,
        bool avoidForcedLiquidationsCol_,
        bool avoidForcedLiquidationsDebt_,
        uint256 maxAPRPercent_,
        uint24 maxDownFromMaxReachedPercentCol_,
        uint24 maxDownFromMaxReachedPercentDebt_,
        uint256 maxDebtUpCapPercent_
    );

isHeartbeatTrigger ​

returns true if last update timestamp is > min heart time update time ago so heartbeat update should trigger

solidity
function isHeartbeatTrigger() public view returns (bool);

Structs ​

CappedRateConstructorParams ​

solidity
struct CappedRateConstructorParams {
    string infoName;
    address liquidity;
    address rateSource;
    uint256 rateMultiplier;
    bool invertCenterPrice;
    uint256 minUpdateDiffPercent;
    uint256 minHeartbeat;
    bool avoidForcedLiquidationsCol;
    bool avoidForcedLiquidationsDebt;
    uint256 maxAPRPercent;
    uint256 maxDownFromMaxReachedPercentCol;
    uint256 maxDownFromMaxReachedPercentDebt;
    uint256 maxDebtUpCapPercent;
}