Skip to content

FluidLendingRewardsRateModel ​

Git Source

Inherits:IFluidLendingRewardsRateModel, Error

Calculates rewards rate used for an fToken based on a rewardAmount over a given duration. Rewards start once the allowed initiator address triggers start() and only accrue above a certain startTVL. Max rate cap is at 50%.

State Variables ​

RATE_PRECISION ​

precision decimals for rewards rate

solidity
uint256 internal constant RATE_PRECISION = 1e12;

SECONDS_PER_YEAR ​

solidity
uint256 internal constant SECONDS_PER_YEAR = 365 days;

MAX_RATE ​

maximum rewards rate is 50%. no config higher than this should be possible.

solidity
uint256 internal constant MAX_RATE = 50 * RATE_PRECISION;

START_TVL ​

tvl below which rewards rate is 0

solidity
uint256 internal immutable START_TVL;

DURATION ​

for how long rewards should run

solidity
uint256 internal immutable DURATION;

YEARLY_REWARD ​

annualized reward based on constructor input params (duration, rewardAmount)

solidity
uint256 internal immutable YEARLY_REWARD;

REWARD_AMOUNT ​

total amounts to be distributed. not needed but stored for easier tracking via getConfig

solidity
uint256 internal immutable REWARD_AMOUNT;

INITIATOR ​

address which has access to call start() which kickstarts the rewards

solidity
address internal immutable INITIATOR;

PREVIOUS_MODEL ​

address of the previously active lending rewards rate model for smooth transition. Can be zero address if none.

solidity
IFluidLendingRewardsRateModel public immutable PREVIOUS_MODEL;

PREVIOUS_MODEL_END_TIME ​

end time of previous lending rewards rate model. 0 if there is no previous model.

solidity
uint256 internal immutable PREVIOUS_MODEL_END_TIME;

startTime ​

when rewards got started

solidity
uint96 internal startTime;

endTime ​

when rewards will get over

solidity
uint96 internal endTime;

Functions ​

validAddress ​

Validates that an address is not the zero address

solidity
modifier validAddress(address value_);

constructor ​

sets immutable vars for rewards rate config based on input params.

solidity
constructor(
    uint256 duration_,
    uint256 startTvl_,
    uint256 rewardAmount_,
    address initiator_,
    IFluidLendingRewardsRateModel previousModel_
);

Parameters

NameTypeDescription
duration_uint256for how long rewards should run
startTvl_uint256tvl below which rate is 0
rewardAmount_uint256total amount of underlying asset to be distributed as rewards
initiator_addressaddress which has access to kickstart the rewards, if previousModel is address zero
previousModel_IFluidLendingRewardsRateModeladdress of previously active lendingRewardsRateModel. can be zero address if none.

getConfig ​

Returns config constants for rewards rate model

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

start ​

solidity
function start() external;

Events ​

LogRewardsStarted ​

Emitted when rewards are started

solidity
event LogRewardsStarted(uint256 startTime, uint256 endTime);