Skip to content

Latest commit

 

History

History
357 lines (243 loc) · 10.2 KB

File metadata and controls

357 lines (243 loc) · 10.2 KB

Solidity API

EscrowDelegateCheckpoints

This contract is used to manage checkpoints in the system.

MAX_TIME

int128 MAX_TIME

Maximum time for a checkpoint

CLOCK_UNIT

uint48 CLOCK_UNIT

Unit of time for the clock

EscrowDelegateStore

struct EscrowDelegateStore {
  struct Checkpoints.Trace _globalCheckpoints;
  mapping(uint256 => int128) globalSlopeChanges;
  mapping(uint256 => struct Checkpoints.Trace) _escrowCheckpoints;
  mapping(address => struct Checkpoints.Trace) _delegateCheckpoints;
  mapping(uint256 => struct Checkpoints.TraceAddress) _escrowDelegateeAddress;
  mapping(address => mapping(uint256 => int128)) delegateeSlopeChanges;
}

CheckpointGlobal

event CheckpointGlobal(uint48 timestamp, int128 slope, int128 bias, int128 permanent)

CheckpointDelegate

event CheckpointDelegate(address delegatee, uint48 timestamp, int128 slope, int128 bias, int128 permanent)

CheckpointEscrow

event CheckpointEscrow(uint256 escrowId, uint48 timestamp, int128 slope, int128 bias, int128 permanent)

clock

function clock() public view returns (uint48)

Clock used for flagging checkpoints.

Return Values

Name Type Description
[0] uint48 Current timestamp

globalClock

function globalClock() public view returns (uint48)

Clock used for flagging global checkpoints.

Return Values

Name Type Description
[0] uint48 Current timestamp rounded to the nearest clock unit

toGlobalClock

function toGlobalClock(uint256 timestamp) internal pure returns (uint48)

Converts a timestamp to a global clock value.

Parameters

Name Type Description
timestamp uint256 The timestamp to convert

Return Values

Name Type Description
[0] uint48 The converted global clock value

checkpoint

function checkpoint(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint256 escrowId, int128 uOldAmount, int128 uNewAmount, uint256 uOldEndTime, uint256 uNewEndTime) external

Record global and per-escrow data to checkpoints. Used by VotingEscrow system.

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore The EscrowDelegateStore struct containing all the storage mappings.
escrowId uint256 NFT escrow lock ID. No escrow checkpoint if 0
uOldAmount int128 Locked amount from last checkpoint
uNewAmount int128 Locked amount from current checkpoint
uOldEndTime uint256 Last checkpoint time
uNewEndTime uint256 Current checkpoint time

globalCheckpoint

function globalCheckpoint(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_) external

Function to update global checkpoint

globalCheckpoint

function globalCheckpoint(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint256 escrowId, struct Checkpoints.Point uOldPoint, struct Checkpoints.Point uNewPoint) public

Function to update global checkpoint with new points

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
escrowId uint256 The ID of the escrow lock - If
uOldPoint struct Checkpoints.Point The old point to be updated
uNewPoint struct Checkpoints.Point The new point to be updated

getAdjustedVotes

function getAdjustedVotes(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, address _delegateeAddress, uint48 timestamp) external view returns (uint256)

Function to calculate total voting power at some point in the past

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
_delegateeAddress address The address of the delegatee
timestamp uint48 Time to calculate the total voting power at

Return Values

Name Type Description
[0] uint256 Total voting power at that time

_getAdjustedVotesCheckpoint

function _getAdjustedVotesCheckpoint(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, address _delegateeAddress, uint48 timestamp) internal view returns (struct Checkpoints.Point)

Function to get delegated votes checkpoint at some point in the past

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
_delegateeAddress address The address of the delegatee
timestamp uint48 Time to calculate the total voting power at

Return Values

Name Type Description
[0] struct Checkpoints.Point Total voting power at that time

getEscrowDelegatee

function getEscrowDelegatee(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint256 escrowId) external view returns (address)

Public function to get the delegatee of an escrow lock

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
escrowId uint256 The ID of the escrow

Return Values

Name Type Description
[0] address The address of the delegate

getEscrowDelegateeAtTime

function getEscrowDelegateeAtTime(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint256 escrowId, uint48 timestamp) public view returns (address)

Public function to get the delegatee of an escrow lock

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
escrowId uint256 The ID of the escrow lock
timestamp uint48 The timestamp to get the delegate at

Return Values

Name Type Description
[0] address The address of the delegate

delegate

function delegate(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint256 escrowId, address delegatee, uint256 endTime) external returns (address oldDelegatee, address newDelegatee)

Function to record escrow delegation checkpoints. Used by voting system.

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
escrowId uint256 The ID of the escrow lock
delegatee address The address of the delegatee
endTime uint256 The end time of the delegation

_checkpointDelegatee

function _checkpointDelegatee(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, address delegateeAddress, struct Checkpoints.Point escrowPoint, uint256 endTime, bool increase) internal

Function to update delegatee's delegatedBalance by balance. Only updates if delegating to a new delegatee.

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
delegateeAddress address The address of the delegatee
escrowPoint struct Checkpoints.Point The point of the escrow
endTime uint256 The end time of the delegation
increase bool Whether to increase or decrease the balance

baseCheckpointDelegatee

function baseCheckpointDelegatee(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, address delegateeAddress) public returns (struct Checkpoints.Point lastPoint, uint48 lastCheckpoint)

Function to update delegatee's checkpoint

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
delegateeAddress address The address of the delegatee

Return Values

Name Type Description
lastPoint struct Checkpoints.Point The last point of the delegatee
lastCheckpoint uint48 The last checkpoint time of the delegatee

getAdjustedGlobalVotes

function getAdjustedGlobalVotes(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint48 timestamp) external view returns (uint256)

Function to calculate total voting power at some point in the past

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
timestamp uint48 Time to calculate the total voting power at

Return Values

Name Type Description
[0] uint256 Total voting power at that time

_getAdjustedCheckpoint

function _getAdjustedCheckpoint(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint48 timestamp) internal view returns (struct Checkpoints.Point)

Function to get latest checkpoint of some point in the past

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
timestamp uint48 Time to calculate the total voting power at

Return Values

Name Type Description
[0] struct Checkpoints.Point Total voting power at that time

getAdjustedEscrowBias

function getAdjustedEscrowBias(struct EscrowDelegateCheckpoints.EscrowDelegateStore store_, uint256 escrowId, uint256 timestamp) external view returns (uint256)

Get the current bias for escrowId at timestamp

Adheres to the ERC20 balanceOf interface for Aragon compatibility Fetches last escrow point prior to a certain timestamp, then walks forward to timestamp.

Parameters

Name Type Description
store_ struct EscrowDelegateCheckpoints.EscrowDelegateStore
escrowId uint256 NFT for lock
timestamp uint256 Epoch time to return bias power at

Return Values

Name Type Description
[0] uint256 NFT bias