# 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 --- |-----------|`\
&#x20;     `|`\
&#x20;     `|`\
`_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`: Locks `IdeaTokens` for a specified duration
  * `address ideaToken`: The address of the `IdeaToken` to be locked
  * `uint amount`: The amount of `IdeaTokens` to lock
  * `uint duration`: The duration in seconds to lock the `IdeaTokens`
  * `address recipient`: The account to credit the locked `IdeaTokens`
* `withdraw`: Withdraw `IdeaTokens` which have exceeded their locking period
  * `address ideaToken`: The address of the `IdeaToken` to withdraw
  * `uint[] 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 the `IdeaTokens`
* `getLockedEntries`: Returns an array of all locked entries for an account and `IdeaToken`
  * `address ideaToken`: The `IdeaToken` for which to return the locked entries
  * `address user`: The address of the user for which to return the locked entries
  * `uint maxEntries`: The maximum number of entries to return


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ideamarket.io/contracts/ideatokenvault.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
