基于区块链的毕业设计LDO purchase executor – LDO采购执行人

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计LDO purchase executor – LDO采购执行人 是一篇很好的国外资料

LDO purchase executor

Allows a predefined list of addresses to purchase vested LDO tokens from the DAO treasury in exchange for Ether at the predefined rate. Implements the second approach (one-by-one) from the proposal:

Each participants can execute their part of the deal individually with individually assigned lock/vesting times based on time of the purchase. The opprtunity to participate expires in one month.

The PurchaseExecutor smart contract provides the following interface:

  • __init__(eth_to_ldo_rate: uint256, vesting_start_delay: uint256, vesting_end_delay: uint256, offer_expiration_delay: uint256, ldo_recipients: address[], ldo_allocations: uint256[], ldo_allocations_total: uint256) initializes the contract and sets the immutable offer parameters.
  • start() if the offer is not started yet, starts it, reverting unless the smart contract controls enough LDO to execute all purchases. Can be called by anyone.
  • get_allocation(ldo_receiver: address = msg.sender) -> (ldo_alloc: uint256, eth_cost: uint256) returns the LDO allocation currently available for the given address and its purchase cost in ETH.
  • execute_purchase_for(recipient: address): payable will, if there’s enough ETH for a purchase allocated to the recipient address, assign vested tokens to the recipient by calling the [TokenManager.assignVested] function, and send any ETH change back to the msg.sender. The vesting start is set to the timestamp of the block the transaction is included to. Reverts unless the recipient is a valid LDO recipient, the amount of ETH sent with the call is enough to purchase the whole amount of LDO allocated to the recipient, and the offer is still valid.
  • __default__(): payable does execute_purchase_for(msg.sender).
  • offer_started() -> bool whether the offer has started.
  • offer_expired() -> bool whether the offer is no longer valid.
  • recover_unsold_tokens() given that the offer has expired, transfers all LDO tokens left on the contract to the DAO treasury.

The process is the following:

  1. The DAO votes for granting the ASSIGN_ROLE to the PurchaseExecutor smart contract and trasferring out 100_000_000 LDO to that contract. This will allow the contract to transfer these LDO tokens to any address in a vested state.
  2. Somebody executes the passed vote and calls PurchaseExecutor.start(). Both transactions can be sent from any address.
  3. Each purchasers call the PurchaseExecutor.execute_purchase_for function, sending ETH and receiving the vested LDO tokens. The list of purchasers and their allocated amounts are set during the PurchaseExecutor contract deployment. A purchaser can also send ETH directly without calling the execute_purchase_for, provided that gas limit for the transaction is set to 300,000.
  4. After the offer expires (in one month), PurchaseExecutor.execute_purchase_for or direct ETH transfer always reverts. Unsold LDO tokens can be recovered to the DAO treasury by calling a permissionless function.

Configuration

The offer parameters are set in purchasers.csv and purchase_config.py. The first file contains a list of purchaser addresses and the corresponding LDO wei amounts each address is allowed to purchase. The second file contains the following parameters:

  • OFFER_EXPIRATION_DELAY the delay in seconds between offer start and its expiration.
  • ETH_TO_LDO_RATE the ETH/LDO rate at which all purchases should be made.
  • VESTING_START_DELAY the delay in seconds between the purchase and the start of LDO linear unlock. Before this delay has passed, the purchaser address is not allowed to transfer the purchased tokens.
  • VESTING_END_DELAY the delay in seconds between the purchase and the end of LDO linear unlock. After this delay has passed, the purchaser address is allowed to transfer the full amount of the purchased tokens.
  • ALLOCATIONS_TOTAL the expected sum of all allocations in purchasers.csv.

Checking the deployed executor

To check that configuration of the deployed executor matches the one specified in purchasers.csv and purchase_config.py, run the following command, passing the address of the deployed executor via the environment variable:

EXECUTOR_ADDRESS=... brownie run scripts/check_deployment.py --network mainnet 

The script also allows checking that each of the purchasers will actually be able to purchase their allocation. In order to do this, run the script on a forked network on a block where none of the purchasers had actually bought their tokens yet:

EXECUTOR_ADDRESS=... brownie run scripts/check_deployment.py --network development 

You’ll need to edit brownie-config.yaml and set the networks.development.fork key to an archival node RPC address, optionally suffixed by a @ followed by a block number to set a specific block to fork from, e.g. http://node.address:8545@12345.

Merge pull request


LDO purchase executor

允许预定义的地址列表从DAO资金部购买既得LDO令牌,以预定义的速率交换Ether。实施提案中的第二种方法(一个接一个):

每个参与者都可以根据购买时间分别执行各自分配的锁定/授予时间。参加的机会一个月后到期

PurchaseExecutor智能合约提供以下界面:

  • u initu(ethu tou LDOu rate:uint256,归属开始延迟:uint256,归属结束延迟:uint256,offeru expirationu delay:uint256,LDOu recipients:address[],LDOu分配:uint256[],ldou allocationsu total:uint256)初始化合同并设置不可变的报价参数
  • start()如果报价尚未启动,则启动报价,除非智能合约控制足够的LDO来执行所有购买,否则将恢复。任何人都可以打电话
  • 获取u分配(ldou接收方:address=msg.sender)—&gt(ldou alloc:uint256,ethu cost:uint256)返回给定地址当前可用的ldo分配及其eth购买成本
  • 执行购买(收件人:地址):如果有足够的ETH分配给收件人地址进行购买,则payable将通过调用[TokenManager.AssignEsted]函数向收件人分配归属令牌,并将任何ETH更改发送回msg.sender。授予开始设置为包含事务的块的时间戳。回复除非收件人是有效的LDO收件人,否则随呼叫发送的ETH金额足以购买分配给收件人的全部LDO金额,并且报价仍然有效
  • uu defaultuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
  • 优惠开始()->不管报价是否已经开始
  • 优惠已过期()->bool这个提议是否不再有效
  • 回收未售出的代币(),如果报价已过期,则将合同上剩余的所有LDO代币转移到DAO资金部

过程如下:

  1. DAO投票赞成将ASSIGNu角色授予PurchaseExecutor智能合约,并将10万LDO转移到该合约。这将允许合同将这些LDO令牌转移到归属国的任何地址
  2. 有人执行通过的投票并调用PurchaseExecutor.start()。两个事务都可以从任何地址发送
  3. 每个购买者调用PurchaseExecutor.executeu purchaseu函数,发送ETH并接收已授予的LDO令牌。在PurchaseExecutor合同部署期间设置购买者列表及其分配金额。买方也可以直接发送ETH,而无需致电executeu purchaseu,前提是交易的天然气限额设置为300000
  4. 要约到期后(一个月内),PurchaseExecutor.executeu purchaseu for or direct ETH transfer始终恢复。未售出的LDO令牌可以通过调用无权限函数恢复到DAO库中

配置

在purchases.csv和purchaseu config.py中设置offer参数。第一个文件包含采购商地址列表和每个地址允许采购的相应LDO金额。第二个文件包含以下参数:

  • OFFERu EXPIRATIONu DELAY提供开始和过期之间的延迟(以秒为单位)
  • 授予开始延迟购买和开始LDO线性解锁之间的延迟(以秒为单位)。在该延迟过去之前,购买者地址不允许转移所购买的代币
  • 授予结束延迟购买与LDO线性解锁结束之间的延迟(以秒为单位)。延迟时间过后,购买者地址可以转移所购代币的全部金额
  • 分配u合计purchasers.csv中所有分配的预期总和
  • ALLOCATIONS_TOTAL the expected sum of all allocations in purchasers.csv.

检查部署的执行器

要检查部署的执行器的配置是否与purchasers.csv和purchase_config.py中指定的配置匹配,请运行以下命令,通过环境变量传递已部署执行器的地址:

EXECUTOR_ADDRESS=... brownie run scripts/check_deployment.py --network mainnet 

脚本还允许检查每个购买者是否能够实际购买其分配。要做到这一点,请在分叉网络上的一个块上运行脚本,在该块上没有购买者实际购买了他们的代币:

EXECUTOR_ADDRESS=... brownie run scripts/check_deployment.py --network development 

您需要编辑brownie-config.yaml并将networks.development.fork密钥设置为存档节点RPC地址,可以选择后缀为@,后跟块号,以设置要分叉的特定块,例如。http://node.address:8545@12345.

Merge pull request

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/22048.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计LDO purchase executor – LDO采购执行人

提供最优质的资源集合

立即查看 了解详情