Skip to main content

UserEpochTotals

UserEpochTotal​

struct UserEpochTotal {
uint256 totalAmount;
uint256 eligibleAmount;
uint256 checkpointedAt;
}

UserEpochTotals​

InvalidDepositEpoch​

error InvalidDepositEpoch(uint256 epoch)

recordIncrease​

function recordIncrease(struct UserEpochTotal total, uint256 amount) internal

Record an increase of amount in the total. This is counted toward the nextAmount as deposits must be present for an entire epoch to be valid.

Parameters​

NameTypeDescription
totalstruct UserEpochTotalstorage pointer to the UserEpochTotal
amountuint256amount to increase the total by

recordInstantIncrease​

function recordInstantIncrease(struct UserEpochTotal total, uint256 amount, uint256 depositTimestamp) internal

Record an increase of amount instantly based on the time of the deposit. This is counted either:

  1. To just the totalAmount if the deposit was this epoch
  2. To both the totalAmount and eligibleAmount if the deposit was before this epoch

Parameters​

NameTypeDescription
totalstruct UserEpochTotalstorage pointer to the UserEpochTotal
amountuint256amount to increase the total by
depositTimestampuint256

recordDecrease​

function recordDecrease(struct UserEpochTotal total, uint256 amount, uint256 depositTimestamp) internal

Record a decrease of amount in the total. Depending on the depositTimestamp this will withdraw from the total's currentAmount (if it's withdrawn from an already valid deposit) or from the total's nextAmount (if it's withdrawn from a deposit this epoch).

Parameters​

NameTypeDescription
totalstruct UserEpochTotalstorage pointer to the UserEpochTotal
amountuint256amount to decrease the total by
depositTimestampuint256timestamp of the deposit associated with amount

getTotals​

function getTotals(struct UserEpochTotal _total) internal view returns (uint256 current, uint256 next)

Get the up-to-date current and next amount for the _total. UserEpochTotals may have a lastEpochUpdate of long ago. This returns the current and next amounts as if it had been checkpointed just now.

Parameters​

NameTypeDescription
_totalstruct UserEpochTotalstorage pointer to the UserEpochTotal

Return Values​

NameTypeDescription
currentuint256the currentAmount of the UserEpochTotal
nextuint256the nextAmount of the UserEpochTotal

_checkpoint​

function _checkpoint(struct UserEpochTotal total) private