IdeaTokenVault
Used to voluntarily lock IdeaTokens for a specified duration.
This contract uses a doubly linked list to keep track of locked tokens and allow for iteration. For each (IdeaToken, owner) combination a linked list is stored where new entries to the list are inserted at the head:
|-----------| --- next ---> |-----------|
| LLEntry | | LLEntry | ---- >
|-----------| <--- prev --- |-----------|
|
|
_llHead[IdeaToken][owner]
Each LLEntry has an until field which is the timestamp when the tokens in this entry will be unlocked. A (IdeaToken, owner, until) combination uniquely identifies a LLEntry. Thus the until also often serves as an ID.
Since (IdeaToken, owner, until) is unique, the storage location of each LLEntry is calculated as keccak256(abi.encode(ideaToken, owner, until)).
lock: LocksIdeaTokensfor a specified durationaddress ideaToken: The address of theIdeaTokento be lockeduint amount: The amount ofIdeaTokensto lockuint duration: The duration in seconds to lock theIdeaTokensaddress recipient: The account to credit the lockedIdeaTokens
withdraw: WithdrawIdeaTokenswhich have exceeded their locking periodaddress ideaToken: The address of theIdeaTokento withdrawuint[] untils: An array of timestamps which corresponds to the end of the locking period of the entries to be withdrawn.address recipient: The account which will receive theIdeaTokens
getLockedEntries: Returns an array of all locked entries for an account andIdeaTokenaddress ideaToken: TheIdeaTokenfor which to return the locked entriesaddress user: The address of the user for which to return the locked entriesuint maxEntries: The maximum number of entries to return
Last updated
Was this helpful?