FluidCappedRateBase ​
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
modifier validAddress(address value_);
constructor ​
constructor(CappedRateConstructorParams memory params_)
validAddress(params_.liquidity)
validAddress(params_.rateSource);
getExchangeRate ​
Deprecated. Use getExchangeRateOperate()
and getExchangeRateLiquidate()
instead. Only implemented for backwards compatibility.
function getExchangeRate() public view virtual returns (uint256 exchangeRate_);
getExchangeRateOperate ​
Get the exchangeRate_
between the underlying asset and the peg asset in 1e27 for operates
function getExchangeRateOperate() public view virtual returns (uint256 exchangeRate_);
getExchangeRateLiquidate ​
Get the exchangeRate_
between the underlying asset and the peg asset in 1e27 for liquidations
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
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
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
function rebalance() external;
getRatesAndCaps ​
Returns rates: capped and uncapped, and current cap status
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
Name | Type | Description |
---|---|---|
rate_ | uint256 | The rate_ value: last fetched value from external source with no cap up and no cap down as in storage |
maxReachedRate_ | uint256 | The maximum reached upward capped rate for col: within APR percent limit as in storage |
maxUpCappedRateDebt_ | uint256 | The maximum reached upward capped rate for debt: up to maxReachedRate_ + maxDebtUpCapPercent on top |
isRateBelowMaxReached_ | bool | Indicates if the rate is currently below the maximum reached APR capped rate flag as in storage |
isUpMaxAPRCapped_ | bool | Indicates if the rate is currently capped due to exceeding the maximum APR limit flag as in storage |
downCappedRateCol_ | uint256 | The capped downward rate on col side |
downCappedRateDebt_ | uint256 | The capped downward rate on debt side |
isDownCappedCol_ | bool | Indicates if the rate is currently getting downward capped on col side |
isDownCappedDebt_ | bool | Indicates if the rate is currently getting downward capped on debt side |
isUpCapped_ | bool | Indicates 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%).
function configPercentDiff() public view virtual returns (uint256 configPercentDiff_);
configData ​
returns all config vars, last update timestamp, and external rate source oracle address
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
function isHeartbeatTrigger() public view returns (bool);
Structs ​
CappedRateConstructorParams ​
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;
}