Skip to content

FluidLendingRewardsRateModel ​

Git Source

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)

solidity
modifier onlyConfigurator();

constructor ​

Sets variables for rewards rate configuration based on input parameters.

solidity
constructor(
    address configurator_,
    address fToken_,
    address fToken2_,
    address fToken3_,
    uint256 startTvl_,
    uint256 rewardAmount_,
    uint256 duration_,
    uint256 startTime_
);

Parameters

NameTypeDescription
configurator_addressThe address with authority to configure rewards.
fToken_addressThe address of the associated fToken contract.
fToken2_addressThe address of the associated fToken contract 2, optional.
fToken3_addressThe address of the associated fToken contract 3, optional.
startTvl_uint256The TVL threshold below which the reward rate is 0.
rewardAmount_uint256The total amount of underlying assets to be distributed as rewards.
duration_uint256The duration (in seconds) for which the rewards will run.
startTime_uint256The 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.

solidity
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)

solidity
function getRate(uint256 totalAssets_) public view returns (uint256 rate_, bool ended_, uint256 startTime_);

Parameters

NameTypeDescription
totalAssets_uint256amount of assets in the lending

Returns

NameTypeDescription
rate_uint256rewards rate percentage per year with 1e12 RATE_PRECISION, e.g. 1e12 = 1%, 1e14 = 100%
ended_boolflag to signal that rewards have ended (always 0 going forward)
startTime_uint256start time of rewards to compare against last update timestamp

stopRewards ​

stops current ongoing rewards instantly.

solidity
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

solidity
function startRewards(uint256 rewardAmount_, uint256 duration_, uint256 startTime_) public onlyConfigurator;

cancelQueuedRewards ​

cancels currently queued rewards

solidity
function cancelQueuedRewards() external onlyConfigurator;

queueNextRewards ​

queues next rewards which can be come active after current ongoing rewards.

solidity
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.

solidity
function transitionToNextRewards() public;