HistoricalBalance

Inherits: ERC20Votes, IHistoricalBalance

Adds support for tracking historical balance on ERC20Votes (not just historical voting power) and adds support for contributing and retrieving incentives pro-rata of historical balanceOf.

Uses a timestamp-based clock for checkpoints as opposed to the default OZ implementation that is blocknumber based.

State Variables

_balanceOfCheckpoints

mapping(address account => Checkpoints.Trace208) private _balanceOfCheckpoints;

Functions

getPastBalanceOf

This function retrieves the historical balance of an account at a specific point in time.

function getPastBalanceOf(address account, uint256 timepoint) public view returns (uint256 balance);

Parameters

NameTypeDescription

account

address

The address of the account for which to retrieve the historical balance.

timepoint

uint256

The timepoint (block number or timestamp depending on implementation) at which to query the balance (uint256).

Returns

NameTypeDescription

balance

uint256

The balance of the account at the specified timepoint.

_update

function _update(address from, address to, uint256 amount) internal virtual override;

clock

function clock() public view override returns (uint48);

CLOCK_MODE

Machine-readable description of the clock as specified in ERC-6372.

function CLOCK_MODE() public pure override returns (string memory);

__push

function __push(Checkpoints.Trace208 storage store, function(uint208, uint208) view returns (uint208) op, uint208 delta)
    private
    returns (uint208, uint208);

__add

function __add(uint208 a, uint208 b) private pure returns (uint208);

__subtract

function __subtract(uint208 a, uint208 b) private pure returns (uint208);

Last updated