BalanceLogicLibrary

Git Source

State Variables

WEEK

uint256 internal constant WEEK = 1 weeks;

Functions

getPastUserPointIndex

Binary search to get the user point index for a token id at or prior to a given timestamp

If a user point does not exist prior to the timestamp, this will return 0.

function getPastUserPointIndex(
    mapping(uint256 => uint256) storage _userPointEpoch,
    mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
        _userPointHistory,
    uint256 _tokenId,
    uint256 _timestamp
) internal view returns (uint256);

Parameters

NameTypeDescription
_userPointEpochmapping(uint256 => uint256)State of all user point epochs
_userPointHistorymapping(uint256 => IVotingEscrow.UserPoint[1000000000])State of all user point history
_tokenIduint256.
_timestampuint256.

Returns

NameTypeDescription
<none>uint256User point index

getPastGlobalPointIndex

Binary search to get the global point index at or prior to a given timestamp

If a checkpoint does not exist prior to the timestamp, this will return 0.

function getPastGlobalPointIndex(
    uint256 _epoch,
    mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
    uint256 _timestamp
) internal view returns (uint256);

Parameters

NameTypeDescription
_epochuint256Current global point epoch
_pointHistorymapping(uint256 => IVotingEscrow.GlobalPoint)State of all global point history
_timestampuint256.

Returns

NameTypeDescription
<none>uint256Global point index

balanceOfNFTAt

Get the current voting power for _tokenId

Adheres to the ERC20 balanceOf interface for Aragon compatibility Although only true of curve, but not solidly and its forks. Fetches last user point prior to a certain timestamp, then walks forward to timestamp.

function balanceOfNFTAt(
    mapping(uint256 => uint256) storage _userPointEpoch,
    mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
        _userPointHistory,
    uint256 _tokenId,
    uint256 _t
) external view returns (uint256);

Parameters

NameTypeDescription
_userPointEpochmapping(uint256 => uint256)State of all user point epochs
_userPointHistorymapping(uint256 => IVotingEscrow.UserPoint[1000000000])State of all user point history
_tokenIduint256NFT for lock
_tuint256Epoch time to return voting power at

Returns

NameTypeDescription
<none>uint256User voting power

supplyAt

Calculate total voting power at some point in the past

function supplyAt(
    mapping(uint256 => int128) storage _slopeChanges,
    mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
    uint256 _epoch,
    uint256 _t
) external view returns (uint256);

Parameters

NameTypeDescription
_slopeChangesmapping(uint256 => int128)State of all slopeChanges
_pointHistorymapping(uint256 => IVotingEscrow.GlobalPoint)State of all global point history
_epochuint256The epoch to start search from
_tuint256Time to calculate the total voting power at

Returns

NameTypeDescription
<none>uint256Total voting power at that time