FluidLendingRewardsRateModel ​
Inherits:Variables, IFluidLendingRewardsRateModel, Events, Error
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
initiator_ is actually the configurator who has access to manage the rewards. named as is for backwards-compatibility reasons.
function getConfig()
external
view
returns (
uint256 duration_,
uint256 startTime_,
uint256 endTime_,
uint256 startTvl_,
uint256 maxRate_,
uint256 rewardAmount_,
address initiator_
);
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 |
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;