Lending Rewards Rate Model

IFluidLendingRewardsRateModel

getRate

function getRate(uint256 totalAssets_) external view returns (uint256 rate_, bool ended_, uint256 startTime_)

Calculates the current rewards rate (APR)

Parameters

NameTypeDescription
totalAssets_uint256amount of assets in the lending

Return Values

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

getConfig

function getConfig() external view returns (uint256 duration_, uint256 startTime_, uint256 endTime_, uint256 startTvl_, uint256 maxRate_, uint256 rewardAmount_, address initiator_)

Returns config constants for rewards rate model

FluidLendingRewardsRateModel

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

LogRewardsStarted

event LogRewardsStarted(uint256 startTime, uint256 endTime)

Emitted when rewards are started

RATE_PRECISION

uint256 RATE_PRECISION

precision decimals for rewards rate

SECONDS_PER_YEAR

uint256 SECONDS_PER_YEAR

MAX_RATE

uint256 MAX_RATE

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

START_TVL

uint256 START_TVL

tvl below which rewards rate is 0

DURATION

uint256 DURATION

for how long rewards should run

YEARLY_REWARD

uint256 YEARLY_REWARD

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

REWARD_AMOUNT

uint256 REWARD_AMOUNT

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

INITIATOR

address INITIATOR

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

startTime

uint96 startTime

when rewards got started

endTime

uint96 endTime

when rewards will get over

validAddress

modifier validAddress(address value_)

Validates that an address is not the zero address

constructor

constructor(uint256 duration_, uint256 startTvl_, uint256 rewardAmount_, address initiator_) public

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

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

getConfig

function getConfig() external view returns (uint256 duration_, uint256 startTime_, uint256 endTime_, uint256 startTvl_, uint256 maxRate_, uint256 rewardAmount_, address initiator_)

Returns config constants for rewards rate model

getRate

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

Calculates the current rewards rate (APR)

Parameters

NameTypeDescription
totalAssets_uint256amount of assets in the lending

Return Values

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

function start() external

Events

LogRewardsStarted

Emitted when rewards are started

event LogRewardsStarted(uint256 startTime, uint256 endTime);

ErrorTypes

LendingRewardsRateModel__InvalidParams

| | Lending Rewards Rate Model | |********__********

thrown when invalid params are given as input

uint256 internal constant LendingRewardsRateModel__InvalidParams = 23001;

LendingRewardsRateModel__MaxRate

thrown when calculated rewards rate is exceeding the maximum rate

uint256 internal constant LendingRewardsRateModel__MaxRate = 23002;

LendingRewardsRateModel__NotTheInitiator

thrown when start is called by any other address other than initiator

uint256 internal constant LendingRewardsRateModel__NotTheInitiator = 23003;

LendingRewardsRateModel__AlreadyStarted

thrown when start is called after the rewards are already started

uint256 internal constant LendingRewardsRateModel__AlreadyStarted = 23004;

LendingRewardsRateModel__ZeroAddress

thrown when the provided input param address is zero

uint256 internal constant LendingRewardsRateModel__ZeroAddress = 23005;