FluidLendingRewardsRateModel
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
uint256 internal constant RATE_PRECISION = 1e12;
SECONDS_PER_YEAR
uint256 internal constant SECONDS_PER_YEAR = 365 days;
MAX_RATE
maximum rewards rate is 50%. no config higher than this should be possible.
uint256 internal constant MAX_RATE = 50 * RATE_PRECISION;
START_TVL
tvl below which rewards rate is 0
uint256 internal immutable START_TVL;
DURATION
for how long rewards should run
uint256 internal immutable DURATION;
YEARLY_REWARD
annualized reward based on constructor input params (duration, rewardAmount)
uint256 internal immutable YEARLY_REWARD;
REWARD_AMOUNT
total amounts to be distributed. not needed but stored for easier tracking via getConfig
uint256 internal immutable REWARD_AMOUNT;
INITIATOR
address which has access to call start() which kickstarts the rewards
address internal immutable INITIATOR;
startTime
when rewards got started
uint96 internal startTime;
endTime
when rewards will get over
uint96 internal endTime;
Functions
validAddress
Validates that an address is not the zero address
modifier validAddress(address value_);
constructor
sets immutable vars for rewards rate config based on input params.
constructor(uint256 duration_, uint256 startTvl_, uint256 rewardAmount_, address initiator_) validAddress(initiator_);
Parameters
Name | Type | Description |
---|---|---|
duration_ | uint256 | for how long rewards should run |
startTvl_ | uint256 | tvl below which rate is 0 |
rewardAmount_ | uint256 | total amount of underlying asset to be distributed as rewards |
initiator_ | address | address which has access to kickstart the rewards |
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 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 |
start
function start() external;
Events
LogRewardsStarted
Emitted when rewards are started
event LogRewardsStarted(uint256 startTime, uint256 endTime);