Skip to main content
Helpful?

RewardMath

Allows computing rewards given some parameters of stakes and incentives

Functions

computeRewardAmount

  function computeRewardAmount(
uint256 totalRewardUnclaimed,
uint160 totalSecondsClaimedX128,
uint256 startTime,
uint256 endTime,
uint128 liquidity,
uint160 secondsPerLiquidityInsideInitialX128,
uint160 secondsPerLiquidityInsideX128,
uint256 currentTime
) internal pure returns (uint256 reward, uint160 secondsInsideX128)

Compute the amount of rewards owed given parameters of the incentive and stake

Parameters:

NameTypeDescription
totalRewardUnclaimeduint256The total amount of unclaimed rewards left for an incentive
totalSecondsClaimedX128uint160How many full liquidity-seconds have been already claimed for the incentive
startTimeuint256When the incentive rewards began in epoch seconds
endTimeuint256When rewards are no longer being dripped out in epoch seconds
liquidityuint128The amount of liquidity, assumed to be constant over the period over which the snapshots are measured
secondsPerLiquidityInsideInitialX128uint160The seconds per liquidity of the liquidity tick range as of the beginning of the period
secondsPerLiquidityInsideX128uint160The seconds per liquidity of the liquidity tick range as of the current block timestamp
currentTimeuint256The current block timestamp, which must be greater than or equal to the start time

Return Values:

NameTypeDescription
rewarduint256The amount of rewards owed
secondsInsideX128uint160The total liquidity seconds inside the position's range for the duration of the stake
Helpful?