OikosEscrow¶
Description¶
This contract holds the OKS which were escrowed at the time of the original token sale, releasing them according to a defined schedule.
The contract was subject to an eight week setup period during which the vesting schedules were set up.
This contract is augmented by the EscrowChecker
contract, which is able to return vesting schedules as an array rather than one at a time.
Source: OikosEscrow.sol
Architecture¶
Inheritance Graph¶
Libraries¶
SafeMath
foruint
Variables¶
oikos
¶
The address of the main Oikos
contract.
Type: Oikos public
vestingSchedules
¶
Stores the vesting schedule for each for each account. Each schedule is a list of (vesting timestamp, quantity)
pairs in ascending time order.
Type: mapping(address => uint[2][]) public
totalVestedAccountBalance
¶
The quantity of remaining tokens for a given account; it saves the recomputation involved in summing over vestingSchedules
entries.
Type: mapping(address => uint) public
totalVestedBalance
¶
The total remaining vested balance in this contract.
Type: uint public
TIME_INDEX
¶
The vesting timestamp is the first entry in vesting schedule entry pairs.
Type: uint constant
Value: 0
QUANTITY_INDEX
¶
The vesting quantity is the second entry in vesting schedule entry pairs.
Type: uint constant
.
Value: 1
MAX_VESTING_ENTRIES
¶
This constant limits vesting schedules to be shorter than twenty entries long so that iteration is bounded.
Type: uint constant
.
Value: 20
Functions¶
constructor
¶
Initialises the Oikos
contract address, and the inherited Owned
instance.
setOikos
¶
Sets the address of the Oikos
contract, so that escrowed OKS can be transferred to accounts claiming them.
Details
Signature
setOikos(Synthetix _oikos) external
Modifiers
Emits
balanceOf
¶
An alias to totalVestedAccountBalance[account]
for ERC20 integration.
Details
Signature
balanceOf(address account) public view returns (uint)
numVestingEntries
¶
The number of entries in an account's vesting schedule, including those already claimed.
Details
Signature
numVestingEntries(account) public view returns (uint)
.
getVestingScheduleEntry
¶
Returns a particular schedule entry for an account, which is a pair of uints: (vesting timestamp, OKS quantity)
.
This is here because the public function generated for vestingSchedules
awkwardly requires the index into the pair as its third argument.
Details
Signature
getVestingScheduleEntry(address account, uint index) public view returns (uint[2])
getVestingTime
¶
Returns the time at which a given schedule entry will vest.
Details
Signature
getVestingTime(address account, uint index) public view returns (uint)
getVestingQuantity
¶
Returns the quantity of OKS a given schedule entry will yield.
Details
Signature
getVestingQuantity(address account, uint index) public view returns (uint)
getNextVestingIndex
¶
Returns the index of the next vesting entry that will vest for a given account. Returns one past the end if there are none remaining.
The function iterates until it finds the first nonzero vesting entry timestamp, so the gas cost increases slightly as more entries vest.
Details
Signature
getNextVestingIndex(address account) public view returns (uint)
getNextVestingEntry
¶
Returns the next vesting entry in the same manner as getNextVestingIndex
. Returns [0,0]
if there is no next vesting entry.
Details
Signature
getNextVestingEntry(address account) public view returns (uint[2])
getNextVestingTime
¶
Returns the timestamp of the next vesting entry. Returns 0
if there is no such entry.
Details
Signature
getNextVestingTime(address account) public view returns (uint)
getNextVestingQuantity
¶
Returns the OKS quantity of the next vesting entry. Returns 0
if there is no such entry.
Details
Signature
getNextVestingQuantity(address account) public view returns (uint)
withdrawOikos
¶
Transfers a quantity of OKS back to the Oikos contract.
This was callable by the owner during the setup period in case too much OKS was deposited into the escrow contract.
Details
Signature
withdrawOikos(uint quantity) external
Modifiers
purgeAccount
¶
In case a vesting schedule was incorrectly set up, this function deletes all vesting information associated with a given account and updates relevant totals. purgeAccount
was only callable by the owner, during the setup period.
Details
Signature
purgeAccount(address account)
Modifiers
appendVestingEntry
¶
Allows new entry to be added to the given account's vesting schedule by the owner during the setup period.
Details
Signature
appendVestingEntry(address account, uint time, uint quantity) public
Modifiers
Preconditions
time
must be in the future.quantity
must be nonzero.- The balance of OKS in the escrow contract must be sufficient to supply the new vesting entry.
- The given account's existing schedule length must be less than
MAX_VESTING_ENTRIES
. time
must be after the last vesting entry's timestamp, if such an entry exists.
addVestingSchedule
¶
During the setup period, allows the contract owner to add an entire vesting schedule to the given account by calling appendVestingEntry
in a loop. If a schedule already exists, the new one is concatenated to the old one.
Caution
Beware that no checking is done that the lengths of the times
and quantities
input arrays are equal. If times
is shorter than quantities
, the extra quantities are ignored; if it is longer, the transaction reverts since past-the-end quantities will be 0 (but don't rely on this).
Details
Signature
addVestingSchedule(address account, uint[] times, uint[] quantities) external
Modifiers
Preconditions
times
must be a strictly increasing sequence.- Each entry in
quantities
must be nonzero.
vest
¶
Finds all vesting schedule entries that have come due for the caller and transfers the total quantity of tokens to them. Vested entries are overwritten with [0,0]
.
Details
Signature
vest() external
Emits
Vested(msg.sender, now, total)
Where total
is the sum of the quantities of this user's schedule entries with timestamps no later than the current time. That is, if multiple vesting entries were claimed, only one Vested
event is emitted. No event is emitted if total
is 0.
Events¶
OikosUpdated
¶
Records that the OKS contract address was altered.
Signature: OikosUpdated(address newSynthetix)
Vested
¶
Records that an account vested a quantity of tokens.
Signature: Vested(address indexed beneficiary, uint time, uint value)