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
Name | Type | Description |
---|---|---|
owner_ | address | |
p12TokenAddr_ | address | ERC20P12 token address |
name_ | string | Token name |
symbol_ | string | Token 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
Name | Type | Description |
---|---|---|
addr | address | Address of the user wallet |
Name | Type | Description |
---|---|---|
[0] | int256 | Value of the slope |
userPointHistoryTs
function userPointHistoryTs(address addr, uint256 idx) external view returns (uint256)
Get the timestamp for checkpoint idx
for addr
Name | Type | Description |
---|---|---|
addr | address | User wallet address |
idx | uint256 | User epoch number |
Name | Type | Description |
---|---|---|
[0] | uint256 | Epoch time of the checkpoint |
lockedEnd
function lockedEnd(address addr) external view returns (uint256)
Get timestamp when addr
's lock finishes
Name | Type | Description |
---|---|---|
addr | address | User wallet |
Name | Type | Description |
---|---|---|
[0] | uint256 | Epoch 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
Name | Type | Description |
---|---|---|
addr | address | User's wallet address |
value | uint256 | Amount 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
Name | Type | Description |
---|---|---|
value | uint256 | Amount to deposit |
unlockTime | uint256 | Epoch 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
Name | Type | Description |
---|---|---|
value | uint256 | Amount 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
Name | Type | Description |
---|---|---|
unlockTime | uint256 | New 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
Name | Type | Description |
---|---|---|
addr | address | User wallet address |
Name | Type | Description |
---|---|---|
[0] | int256 | User 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
Name | Type | Description |
---|---|---|
addr | address | User's wallet address |
blk | uint256 | Block to calculate the voting power at |
Name | Type | Description |
---|---|---|
[0] | int256 | Voting power |
totalSupply
function totalSupply() external view returns (uint256)
Calculate total voting power
Adheres to the ERC20 totalSupply
interface for Aragon compatibility
Name | Type | Description |
---|---|---|
[0] | uint256 | Total voting power |
totalSupplyAt
function totalSupplyAt(uint256 blk) external view returns (uint256)
Calculate total voting power at some point in the past
Name | Type | Description |
---|---|---|
blk | uint256 | Block to calculate the total voting power at |
Name | Type | Description |
---|---|---|
[0] | uint256 | Total 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
Name | Type | Description |
---|---|---|
blk | uint256 | Block to find |
maxEpoch | uint256 | Don't go beyond this epoch |
Name | Type | Description |
---|---|---|
[0] | uint256 | Approximate 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
Name | Type | Description |
---|---|---|
addr | address | User's wallet address. No user checkpoint if 0x0 |
oldLocked | struct VotingEscrow.LockedBalance | Previous locked amount / end lock time for the user |
newLocked | struct VotingEscrow.LockedBalance | New 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
Name | Type | Description |
---|---|---|
addr | address | User's wallet address |
value | uint256 | Amount to deposit |
unlockTime | uint256 | New time when to unlock the tokens, or 0 if unchanged |
lockedBalance | struct VotingEscrow.LockedBalance | Previous locked amount / timestamp |
t | enum VotingEscrow.OperationType | Operation type |
supplyAt
function supplyAt(struct VotingEscrow.Point point, uint256 t) internal view returns (uint256)
Calculate total voting power at some point in the past
Name | Type | Description |
---|---|---|
point | struct VotingEscrow.Point | The point (bias/slope) to start search from |
t | uint256 | Time to calculate the total voting power at |
Name | Type | Description |
---|---|---|
[0] | uint256 | Total voting power at that time |
_checkContractNotExpired
function _checkContractNotExpired() private view
throw error if the contract is stopped
contractNotExpired
modifier contractNotExpired()