FluidLendingRewardsRateModel ​
Inherits:Variables, IFluidLendingRewardsRateModel, Events, Error
Title: LendingRewardsRateModel
Calculates rewards rate used for an fToken based on a rewardAmount over a given duration. Rewards start according to the configurator triggers and only accrue above a certain startTVL. Max rate cap is at 50%.
Functions ​
onlyConfigurator ​
Validates that an address is the configurator (team multisig)
modifier onlyConfigurator() ;constructor ​
Sets variables for rewards rate configuration based on input parameters.
constructor(
address configurator_,
address fToken_,
address fToken2_,
address fToken3_,
uint256 startTvl_,
uint256 rewardAmount_,
uint256 duration_,
uint256 startTime_
) ;Parameters
| Name | Type | Description |
|---|---|---|
configurator_ | address | The address with authority to configure rewards. |
fToken_ | address | The address of the associated fToken contract. |
fToken2_ | address | The address of the associated fToken contract 2, optional. |
fToken3_ | address | The address of the associated fToken contract 3, optional. |
startTvl_ | uint256 | The TVL threshold below which the reward rate is 0. |
rewardAmount_ | uint256 | The total amount of underlying assets to be distributed as rewards. |
duration_ | uint256 | The duration (in seconds) for which the rewards will run. |
startTime_ | uint256 | The timestamp when rewards are scheduled to start; must be 0 or a future time. |
getConfig ​
Returns config constants for rewards rate model
function getConfig()
external
view
returns (
uint256 duration_,
uint256 startTime_,
uint256 endTime_,
uint256 startTvl_,
uint256 maxRate_,
uint256 rewardAmount_,
address configurator_
);getRate ​
Calculates the current rewards rate (APR)
function getRate(uint256 totalAssets_) public view returns (uint256 rate_, bool ended_, uint256 startTime_);Parameters
| Name | Type | Description |
|---|---|---|
totalAssets_ | uint256 | amount of assets in the lending |
Returns
| Name | Type | Description |
|---|---|---|
rate_ | uint256 | rewards rate percentage per year with 1e12 RATE_PRECISION, e.g. 1e12 = 1%, 1e14 = 100% |
ended_ | bool | flag to signal that rewards have ended (always 0 going forward) |
startTime_ | uint256 | start time of rewards to compare against last update timestamp |
getRateV2 ​
Same as getRate but additionally returns the endTime_ of the reported rewards phase, and rate_ stays the actual phase rate even when ended_ is true. This allows fTokens to accrue rewards exactly up to endTime_ instead of losing the tail since their last exchange price update.
function getRateV2(uint256 totalAssets_)
public
view
returns (int256 rate_, bool ended_, uint256 startTime_, uint256 endTime_);Parameters
| Name | Type | Description |
|---|---|---|
totalAssets_ | uint256 | amount of assets in the lending |
Returns
| Name | Type | Description |
|---|---|---|
rate_ | int256 | rewards rate percentage per year with 1e12 RATE_PRECISION, e.g. 1e12 = 1%, 1e14 = 100%. Signed for a shared ABI with the static offset model; this streaming model always returns >= 0. |
ended_ | bool | flag to signal that rewards have ended |
startTime_ | uint256 | start time of rewards to compare against last update timestamp |
endTime_ | uint256 | end time of the reported rewards phase |
_getRate ​
Same logic as legacy getRate, but additionally returns endTime_ of the reported rewards phase and keeps the actual phase rate_ even when ended_ is true, so new fTokens (via getRateV2) can settle rewards accrual exactly up to endTime_ instead of losing the tail since their last exchange price update.
function _getRate(uint256 totalAssets_)
internal
view
returns (uint256 rate_, bool ended_, uint256 startTime_, uint256 endTime_);stopRewards ​
stops current ongoing rewards instantly.
function stopRewards() external onlyConfigurator;startRewards ​
start new rewards. LendingRewards must be an auth at the LendingFactory! set startTime set to 0 for using block.timestamp
function startRewards(uint256 rewardAmount_, uint256 duration_, uint256 startTime_) public onlyConfigurator;cancelQueuedRewards ​
cancels currently queued rewards
function cancelQueuedRewards() external onlyConfigurator;queueNextRewards ​
queues next rewards which can be come active after current ongoing rewards.
function queueNextRewards(uint256 rewardAmount_, uint256 duration_) external onlyConfigurator;transitionToNextRewards ​
transitions to next queued rewards after current ongoing rewards ended. Callable by anyone.
Note triggering this is not required for queued rewards to start accruing as that happens anyway in the getRate view method, but it cleans up the status here in storage and gas optimizes the getRate() call.
function transitionToNextRewards() public;