Skip to main content

VotingEscrow

VotingEscrow

WEEK

uint256 WEEK

MAXTIME

uint256 MAXTIME

MULTIPLIER

uint256 MULTIPLIER

p12Token

address p12Token

totalLockedP12

uint256 totalLockedP12

locked

mapping(address => struct VotingEscrow.LockedBalance) locked

epoch

uint256 epoch

expired

bool expired

pointHistory

mapping(uint256 => struct VotingEscrow.Point) pointHistory

userPointHistory

mapping(address => mapping(uint256 => struct VotingEscrow.Point)) userPointHistory

userPointEpoch

mapping(address => uint256) userPointEpoch

slopeChanges

mapping(uint256 => int256) slopeChanges

name

string name

symbol

string symbol

decimals

uint256 decimals

OperationType

enum OperationType {
DEPOSIT_FOR_TYPE,
CREATE_LOCK_TYPE,
INCREASE_LOCK_AMOUNT,
INCREASE_UNLOCK_TIME
}

Expired

event Expired(address addr, uint256 timestamp)

Deposit

event Deposit(address provider, uint256 value, uint256 lockTime, enum VotingEscrow.OperationType t, uint256 ts)

Withdraw

event Withdraw(address provider, uint256 value, uint256 ts)

TotalLocked

event TotalLocked(uint256 prevTotalLockedP12, uint256 totalLockedP12)

Point

struct Point {
int256 bias;
int256 slope;
uint256 ts;
uint256 blk;
}

LockedBalance

struct LockedBalance {
int256 amount;
uint256 end;
}

CheckPointState

struct CheckPointState {
int256 oldDslope;
int256 newDslope;
uint256 _epoch;
}

constructor

constructor(address owner_, address p12TokenAddr_, string name_, string symbol_) public

Contract constructor

NameTypeDescription
owner_address
p12TokenAddr_addressERC20P12 token address
name_stringToken name
symbol_stringToken symbol

expire

function expire() external

getLastUserSlope

function getLastUserSlope(address addr) external view returns (int256)

Get the most recently recorded rate of voting power decrease for addr

NameTypeDescription
addraddressAddress of the user wallet
NameTypeDescription
[0]int256Value of the slope

userPointHistoryTs

function userPointHistoryTs(address addr, uint256 idx) external view returns (uint256)

Get the timestamp for checkpoint idx for addr

NameTypeDescription
addraddressUser wallet address
idxuint256User epoch number
NameTypeDescription
[0]uint256Epoch time of the checkpoint

lockedEnd

function lockedEnd(address addr) external view returns (uint256)

Get timestamp when addr's lock finishes

NameTypeDescription
addraddressUser wallet
NameTypeDescription
[0]uint256Epoch time of the lock end

checkPoint

function checkPoint() external

Record global data to checkpoint

depositFor

function depositFor(address addr, uint256 value) external

Deposit value tokens for addr and add to the lock

Anyone (even a smart contract) can deposit for someone else, but cannot extend their lockTime and deposit for a brand new user

NameTypeDescription
addraddressUser's wallet address
valueuint256Amount to add to user's lock

createLock

function createLock(uint256 value, uint256 unlockTime) external

Deposit value tokens for msg.sender and lock until unlock_time

NameTypeDescription
valueuint256Amount to deposit
unlockTimeuint256Epoch time when tokens unlock, rounded down to whole weeks

increaseAmount

function increaseAmount(uint256 value) external

Deposit value additional tokens for msg.sender without modifying the unlock time

NameTypeDescription
valueuint256Amount of tokens to deposit and add to the lock

increaseUnlockTime

function increaseUnlockTime(uint256 unlockTime) external

Extend the unlock time for msg.sender to unlock_time

NameTypeDescription
unlockTimeuint256New epoch time for unlocking

withdraw

function withdraw() external

Withdraw all tokens for msg.sender

Only possible if the lock has expired or contract expired

balanceOf

function balanceOf(address addr) external view returns (int256)

Get the current voting power for msg.sender

Adheres to the ERC20 balanceOf interface for Aragon compatibility

NameTypeDescription
addraddressUser wallet address
NameTypeDescription
[0]int256User voting power

balanceOfAt

function balanceOfAt(address addr, uint256 blk) external view returns (int256)

Measure voting power of addr at block height _block

Adheres to MiniMe balanceOfAt interface: https://github.com/Giveth/minime

NameTypeDescription
addraddressUser's wallet address
blkuint256Block to calculate the voting power at
NameTypeDescription
[0]int256Voting power

totalSupply

function totalSupply() external view returns (uint256)

Calculate total voting power

Adheres to the ERC20 totalSupply interface for Aragon compatibility

NameTypeDescription
[0]uint256Total voting power

totalSupplyAt

function totalSupplyAt(uint256 blk) external view returns (uint256)

Calculate total voting power at some point in the past

NameTypeDescription
blkuint256Block to calculate the total voting power at
NameTypeDescription
[0]uint256Total voting power at _block

pause

function pause() public

unpause

function unpause() public

findBlockEpoch

function findBlockEpoch(uint256 blk, uint256 maxEpoch) public view returns (uint256)

Binary search to estimate timestamp for block number

NameTypeDescription
blkuint256Block to find
maxEpochuint256Don't go beyond this epoch
NameTypeDescription
[0]uint256Approximate timestamp for block

_checkPoint

function _checkPoint(address addr, struct VotingEscrow.LockedBalance oldLocked, struct VotingEscrow.LockedBalance newLocked) internal

Record global and per-user data to checkpoint

NameTypeDescription
addraddressUser's wallet address. No user checkpoint if 0x0
oldLockedstruct VotingEscrow.LockedBalancePrevious locked amount / end lock time for the user
newLockedstruct VotingEscrow.LockedBalanceNew locked amount / end lock time for the user

_depositFor

function _depositFor(address addr, uint256 value, uint256 unlockTime, struct VotingEscrow.LockedBalance lockedBalance, enum VotingEscrow.OperationType t) internal

Deposit and lock tokens for a user

NameTypeDescription
addraddressUser's wallet address
valueuint256Amount to deposit
unlockTimeuint256New time when to unlock the tokens, or 0 if unchanged
lockedBalancestruct VotingEscrow.LockedBalancePrevious locked amount / timestamp
tenum VotingEscrow.OperationTypeOperation type

supplyAt

function supplyAt(struct VotingEscrow.Point point, uint256 t) internal view returns (uint256)

Calculate total voting power at some point in the past

NameTypeDescription
pointstruct VotingEscrow.PointThe point (bias/slope) to start search from
tuint256Time to calculate the total voting power at
NameTypeDescription
[0]uint256Total voting power at that time

_checkContractNotExpired

function _checkContractNotExpired() private view

throw error if the contract is stopped

contractNotExpired

modifier contractNotExpired()