@1hive/apps-time-lock 中文文档教程

发布于 3年前 浏览 30 更新于 3年前

Time Lock

CircleCI覆盖状态Crytic Status

1Hive 的 Time Lock 应用程序允许 Aragon 组织通过将令牌发送到 Time Lock 应用程序一段可配置的时间来要求用户锁定令牌,以便转发意图. 例如,组织可能要求用户在创建新投票之前锁定 100 个代币 1 个月。 用户将能够在一个月内回来并领取他们锁定的代币。

Project stage: development

Time Lock 应用程序仍在开发中,第一个实现已发布到 time-lock.open.aragonpm.eth。 如果您有兴趣参与贡献,请查看我们未解决的问题

Security review status: Contracts updated as of commit 57d4d5eaef9f4ade3218527e8942bf17d588bcc3

此 repo 中的代码未经审计。

How does it work?

Time Lock 应用程序是一个转发器。 通过授予 Time Lock 应用程序类似Create Votes 的权限,系统将提示用户并要求用户在转发用户意图之前锁定令牌。

我们会跟踪何时以及由谁进行锁定,以便用户只能在持续时间结束后收回他们进行的锁定。

我们建议(但不要求)将锁定功能与 Token Balance Oracle 一起使用,以限制应用程序的使用该组织的成员。 这就是我们的演示模板。 这允许 Oracle 在授予 canForward() 功能。 这意味着为了提交提案,必须锁定代币,并且为了锁定代币,必须是 DAO 的成员。

Initialization

Time Lock 应用程序使用 _token_lockDuration_lockAmount_spamPenaltyFactor 参数进行初始化,这些参数确定令牌是锁定,代币被锁定多长时间,要锁定的代币数量和垃圾邮件提议的惩罚百分比。 在初始化时,_token 参数可以设置为 ERC20 令牌。 它不能改变。 如果需要进行更改,用户可以安装新实例并更改组织中的权限以反映更改。

Roles

Time Lock 应用程序实现了以下角色:

  • Change Duration: This allows for changing the configured duration.
  • Change Lock Amount: This allows for changing the amount of tokens required to lock.
  • Change Spam Penalty: This allows for changing the spam penalty factor for subsequent locks.
  • Lock Tokens: This should be granted to Any Entity and paramaterized using the ACL Token Oracle or similar contract.

Interface

Time Lock 应用程序为用户提供了一个界面,可以查看他们所做的任何锁定,以及他们可以重新申请锁定的时间。 它还显示了他们当前可收回的总解锁余额。

Time Lock 应用程序不提供用于更改持续时间或锁定量的界面。 这可以通过 aragonCLI 或直接与合约交互来完成。

How to run Time Lock app locally

首先确保您已安装并运行 node、npm 和 aragonCLI。 可以在此处找到关于如何设置的说明。 您还需要启用 Metamask 或某种网络钱包才能在浏览器中签署交易。

Git 克隆这个仓库。

git clone https://github.com/1Hive/time-lock-app.git

导航到 time-lock-app 目录。

cd time-lock-app

安装 npm 依赖项。

npm i

在您的本地环境中部署一个带有 Time Lock 应用程序的 dao。

npm run start:template

如果一切正常,您的新 DAO 将被部署,您的浏览器将打开 http://localhost:3000/#/YOUR-DAO-ADDRESS。 它应该看起来像这样:

Newly deploy DAO with lock app

您还将在终端中看到本地部署的配置。 它应该看起来像这样:

    Ethereum Node: ws://localhost:8545
    ENS registry: 0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1
    APM registry: aragonpm.eth
    DAO address: YOUR-DAO-ADDRESS

Template

Time Lock 应用程序初始化为 1:30 分钟的 _lockDuration、20 个 LKT 令牌的 _lockAmount_spamPenaltyFactor 的 100%。 该应用程序具有创建投票的权限,因此如果您尝试从 tokens 应用程序中为自己铸造一些代币,它会首先提示您批准 Time Lock 应用程序将 20 LKT 代币转移到您的合约代表。 执行转发后,您应该能够看到当前锁和一个计时器,指示您可以重新领取 20 个 LKT 代币的时间。

Re-claiming your tokens

一旦您的余额被解锁,您就可以通过提款按钮取回您的代币。 您将必须输入您要收回的锁的数量,并且它们将以 FIFO 的方式被撤销(先进先出)

Aragon DAO Installation

TODO:将时间锁部署到 rinkeby

要部署到组织,您可以使用 aragonCLI

aragon dao install <dao-address> time-lock.open.aragonpm.eth --app-init-args <token-address> <lock-duration> <lock-amount>

您必须根据您的要求设置权限,以便用户在转发意图之前锁定令牌。 因此,例如,如果您想要要求用户在创建投票之前锁定令牌,您应该授予 Time Lock 应用程序在投票应用程序上创建投票的角色。

:warning: 目前,Time Lock 应用程序必须是交易路径中的第一个转发器,以便正确提示您对所需数量的代币执行批准

Contributing

我们欢迎社区贡献!

请查看我们的未解决的问题以开始使用。

如果您发现可能影响安全的事情,请立即通知我们。 联系我们的最快方式是通过我们的team Keybase chat 中的#dev 频道。 只要打个招呼,你发现了一个潜在的安全漏洞,我们就会私信给你讨论细节。

Time Lock

CircleCICoverage StatusCrytic Status

1Hive's Time Lock app allows an Aragon organization to require users to lock tokens by sending them to the Time Lock app for a configurable period of time in order to forward an intent. For example the organization may require users to lock 100 tokens for 1 month before creating a new vote. The user would be able to come back in a month and claim their locked tokens.

???? Project stage: development

The Time Lock app is still in development, a first implementation was published to time-lock.open.aragonpm.eth. If you are interested in contributing please see our open issues.

???? Security review status: Contracts updated as of commit 57d4d5eaef9f4ade3218527e8942bf17d588bcc3

The code in this repo has not been audited.

How does it work?

The Time Lock app is a forwarder. By granting the Time Lock app a permission like Create Votes the user will be prompted and required to lock tokens before the user's intent can be forwarded.

We keep track of when locks are made and by whom so that users are only able to re-claim locks that they have made after the duration has elapsed.

We recommend (but do not require) that the lock function is used with the Token Balance Oracle to restrict use of the application to members of the organization. This is how permissions are set up in our demo template. This allows the Oracle to check if the msg.sender of a proposal has tokens (and thus is a member of the DAO who's qualified to create proposals) before granting the canForward() functionality. This means that in order to submit a proposal one must lock tokens, and in order to lock tokens one must be a member of the DAO.

Initialization

The Time Lock app is initialized with a _token, _lockDuration, _lockAmount and _spamPenaltyFactor parameters which determines the token to be locked, how long tokens are locked, the amount of tokens to lock and a penalty percentage for spamming proposals. At initialization the _token parameter can be set to an ERC20 token. It cannot be changed. If a change is necessary the user can install a new instance and change permissions in the organization to reflect the change.

Roles

The Time Lock app implements the following roles:

  • Change Duration: This allows for changing the configured duration.
  • Change Lock Amount: This allows for changing the amount of tokens required to lock.
  • Change Spam Penalty: This allows for changing the spam penalty factor for subsequent locks.
  • Lock Tokens: This should be granted to Any Entity and paramaterized using the ACL Token Oracle or similar contract.

Interface

The Time Lock app provides an interface for a user to see any locks they have made, and how much time until they can re-claim the lock. It also shows the total unlocked balance they currently have for re-claim.

The Time Lock app does not provide an interface for changing the duration or lock amount. This can be done via the aragonCLI or directly interacting with the contract.

How to run Time Lock app locally

First make sure that you have node, npm, and the aragonCLI installed and working. Instructions on how to set that up can be found here. You'll also need to have Metamask or some kind of web wallet enabled to sign transactions in the browser.

Git clone this repo.

git clone https://github.com/1Hive/time-lock-app.git

Navigate into the time-lock-app directory.

cd time-lock-app

Install npm dependencies.

npm i

Deploy a dao with Time Lock app installed on your local environment.

npm run start:template

If everything is working correctly, your new DAO will be deployed and your browser will open http://localhost:3000/#/YOUR-DAO-ADDRESS. It should look something like this:

Newly deploy DAO with lock app

You will also see the configuration for your local deployment in the terminal. It should look something like this:

    Ethereum Node: ws://localhost:8545
    ENS registry: 0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1
    APM registry: aragonpm.eth
    DAO address: YOUR-DAO-ADDRESS

Template

The Time Lock app is initialized with a _lockDuration of 1:30 minutes, a _lockAmount of 20 LKT tokens and a _spamPenaltyFactor of 100%. The app has the permission to create votes, so if you try to mint yourself some tokens from the tokens app it will first prompt you to approve the Time Lock app to transfer 20 LKT tokens to the contract on your behalf. Once the forwarding is performed you should be able to see the current lock and a timer indicating how much time until you can re-claim your 20 LKT tokens.

Re-claiming your tokens

Once your balance is unlocked you will be able to re-claim your tokens via the withdraw button. You will have to input how many locks you'll re-claim and they'll be withdrawn on a FIFO basis (first in first out)

Aragon DAO Installation

TODO: Deploy Time Lock to rinkeby

To deploy to an organization you can use the aragonCLI.

aragon dao install <dao-address> time-lock.open.aragonpm.eth --app-init-args <token-address> <lock-duration> <lock-amount>

You have to set up permissions depending on your requirements for users to lock tokens before forwarding an intent. So for example if you want to require users to lock tokens before creating votes you should grant the Time Lock app the role to create votes on the Voting app.

:warning: Currently the Time Lock app has to be the first forwarder in the transaction pathing in order to properly prompt you to perform an approve for the required amount of tokens

Contributing

We welcome community contributions!

Please check out our open Issues to get started.

If you discover something that could potentially impact security, please notify us immediately. The quickest way to reach us is via the #dev channel in our team Keybase chat. Just say hi and that you discovered a potential security vulnerability and we'll DM you to discuss details.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文