Alert Source Discuss
⚠️ Draft Standards Track: ERC

ERC-7425: 代币化储备金

链上透明的储备基金,利益相关者可以参与。

Authors Jimmy Debe (@jimstir)
Created 2023-06-30
Discussion Link https://ethereum-magicians.org/t/eip-7425-tokenized-reserve/15297
Requires EIP-20, EIP-4626

摘要

本规范解释了一种代币化储备机制标准。当前的智能合约记录交易并公开。该储备将实现附加功能,允许利益相关者主动审计合约。使用 ERC-4626,利益相关者可以创建份额来表示对合约中行为的支持。

动机

代币化金库存储 ERC-20 代币,这些代币由金库合约中的份额表示。实现可以遵循 ERC-4626 标准,为金库提供存款、取款和读取余额的基本功能。随着代币化变得越来越流行,应用程序应该使用一种代币化金库的形式来存储资产,并允许所有各方跟踪绩效。

本规范介绍了一种链上储备金的标准,该储备金使用代币化金库来表示储备金的利益相关者。核心功能是 ERC-4626 的扩展,将通过在金库中存款和取款来为利益相关者提供代表权。其他 ERC-20 资产的交易记录应该易于任何一方访问以进行审计。

在代币化储备金中,利益相关者通过从金库中铸造份额来表示。目标是创建一个类似于现实世界中用作实体应急准备金的储备金。在大多数情况下,实体会遵循诸如常规资金不足之类的标准来利用储备金。在去中心化环境中,实体应将利益相关者纳入标准。与储备金相关的资产及其来源在去中心化环境中会有所不同,因此需要透明的审计。

规范

本文档中的关键词 “MUST”(必须)、”MUST NOT”(禁止)、”REQUIRED”(必需)、”SHALL”(应)、”SHALL NOT”(不得)、”SHOULD”(应该)、”SHOULD NOT”(不应该)、”RECOMMENDED”(推荐)、”NOT RECOMMENDED”(不推荐)、”MAY”(可以)和 “OPTIONAL”(可选)应按照 RFC 2119 和 RFC 8174 中的描述进行解释。

定义:

- owner: 储备金的创建者
- user: 参与策略的利益相关者
- reserve: 合约上持有的除 underlying token 以外的资产
- policies: 由储备金所有者创建以鼓励利益相关者参与的策略

构造函数:

- name: ERC-20 代币名称 - ticker: ERC-20 代码 - asset: ERC-4626 underlying ERC-20 地址
- rAuth: 授权用户,用于利用多个所有者/限制所有者提款的情况
- rOwner: 储备金的所有者

接口

// SPDX-License-Identifier: CC0-1.0

import "./ERC4626.sol";
    
interface TokenReserve is ERC4626{

	/**
	* @dev Event emitted after a new policy is created
	* @dev 创建新策略后发出的事件
	*/
	event policies(
	    	address indexed token,
	    	uint256 indexed policyNum,
	    	uint256 indexed amount,
		address recipient
	);

	/**
	* @dev Event emitted after a new deposit is made by the owner
	* @dev 所有者进行新的存款后发出的事件
	*/
	event depositR(
		address indexed token,
	    	uint256 indexed amount,
	    	uint256 indexed time,
	    	uint256 count
	);

	/** 
	* @dev Get time a deposit/withdrawal was made by the owner
	* @dev 获取所有者进行存款/取款的时间
	* @param count Number for deposit count
	* @param count 存款计数的数字
	* @return block.timestamp format
	* @return block.timestamp 格式
	*/
	function ownerTime(uint256 count) external view returns (uint256)

	/** 
	* @dev Get amount deposited to reserve by owner
	* @dev 获取所有者存入储备金的金额
	* @param count Number for deposit count
	* @param count 存款计数的数字
	* @param policy The policy number to deposit to
	* @param policy 要存入的策略编号
	* @return uint256 Amount of an asset that was deposited
	* @return uint256 存入的资产数量
	*/
	function ownerDeposit(uint256 count, uint256 policy) external view returns(uint256)

	/**
	* @dev Amount withdrawn for a opened policy by the owner
	* @dev 所有者为已开启的策略提取的金额
	* @param policy The policy number
	* @param policy 策略编号
	* @return Amount of ERC20
	* @return ERC20 的数量
	*/
	function ownerWithdrawals(uint256 policy) external view returns(uint256)

	/**
	* @dev Token type deposited to reserve by owner
	* @dev 所有者存入储备金的代币类型
	* - MUST be an address of ERC20 token
	* - 必须是 ERC20 代币的地址
	* @param count Number of deposit count
	* @param count 存款计数的数字
	* @return address Address of ERC20 token
	* @return address ERC20 代币的地址
	*/
	function tokenDeposit(uint256 count) external view returns(address)

	/**
	* @dev Amount deposited to a policy for shares
	* @dev 存入策略以换取份额的金额
	* - MUST be an ERC20 token
	* - 必须是 ERC20 代币
	* @param user Address of user
	* @param user 用户的地址
	* @param policy The policy number the user deposited to
	* @param policy 用户存入的策略编号
	* @return uint256 Amount of ERC20 deposited
	* @return uint256 存入的 ERC20 数量
	*/
	function userDeposit(address user, uint256 policy) external view returns(uint256)

	/**
    	* @dev Amount withdrawn from a policy by the user
	* @dev 用户从策略中提取的金额
	* @param user The address of user
	* @param user 用户的地址
    	* @param policy The policy number for user withdrawal
	* @param policy 用户提款的策略编号
	* @param uint256 Amount of ERC20
	* @param uint256 ERC20 的数量
    	*/
    	function userWithdrawals(address user, uint256 policy) public view returns(uint256)

	/**
	* @dev Token type withdrawn for an opened policy by the owner
	* @dev 所有者为已开启的策略提取的代币类型
	* - MUST be ERC20 address
	* - 必须是 ERC20 地址
	* @param policy The policy number for the token used
	* @param policy 所用代币的策略编号
	* @return Token ERC20 address
	* @return Token ERC20 地址
	*/
	function policyToken(uint256 policy) external view returns(address)

	/**
	* @dev Make a deposit to a policy creating new shares using deposit function from ERC4626
	* @dev 使用 ERC4626 中的存款功能,存款到策略以创建新的份额
	* - MUST be opened policy
	* - 必须是已开启的策略
	* - MUST NOT be opened policy that was closed
	* - 不得是已关闭的已开启策略
	* - SHOULD be only method to deposit to ERC4626 vault
	* - 应该是存入 ERC4626 金库的唯一方法
	* NOTE: using the deposit() will cause assets to not be accounted for in a policy (see Security Considerations section)
	* 注意:使用 deposit() 将导致资产无法在策略中进行核算(请参阅“安全注意事项”部分)
	* @param assets Amount being deposited
	* @param assets 存入的金额
	* @param receiver Address of depositor
	* @param receiver 存款人的地址
	* @param policy The number associated policy
	* @param policy 与策略关联的编号
	* @return Amount of shares minted 
	* @return 铸造的份额数量
	*/
	function policyDeposit(uint256 assets, address receiver, uint256 policy) external virtual returns(uint256)

	/**
	* @dev Burn shares, receive 1 to 1 value of shares using withdraw function from ERC4626
	* @dev 销毁份额,使用 ERC4626 中的提款功能接收 1 比 1 的份额价值
	* - MUST have userDeposit greater than or equal to userWithdrawal
	* - 必须有 userDeposit 大于或等于 userWithdrawal
	* - SHOULD be only method for withdrawing from ERC4626 vault
	* - 应该是从 ERC4626 金库提款的唯一方法
	* @param assets Amount being deposited
	* @param assets 存入的金额
	* @param receiver Address of receiver
	* @param receiver 接收者的地址
	* @param owner Address of token owner
	* @param owner 代币所有者的地址
	* @param policy Number associated policy
	* @param policy 与策略关联的编号
	* @return Amount of the asset
	* @return 资产数量
	*/
	function withdrawPolicy(uint256 assets, address receiver, address owner, uint256 policy)external virtual returns(uint256)

	/**
	* @dev Issue new policy
	* @dev 发布新策略
	* - MUST create new policy number
	* - 必须创建新的策略编号
	* - MUST account for amount withdrawn
	* - 必须核算提款金额
	* - MUST be only method to withdraw ERC20 tokens (excluding underlying ERC4626 token)
	* - 必须是提取 ERC20 代币的唯一方法(不包括 underlying ERC4626 代币)
	* - MUST be owner
	* - 必须是所有者
	* - SHOULD emit policies event
	* - 应该发出策略事件
	* @param token Address of ERC-20 token
	* @param token ERC-20 代币的地址
	* @param amount Token amount being withdrawn
	* @param amount 提取的代币数量
	* @param receiver Address of token recipient
	* @param receiver 代币接收者的地址
	* @return The policy number
	* @return 策略编号
	*/
	function openPolicy(address token, uint256 amount, address receiver) external virtual returns (uint256)

	/**
	* @dev Make a deposit and/or close an opened policy
	* @dev 存款和/或关闭已开启的策略
	* - MUST be owner
	* - 必须是所有者
	* - MUST account for amount received
	* - 必须核算收到的金额
	* - SHOULD emit policies event
	* - 应该发出策略事件
	* @param token Address of ERC-20 token
	* @param token ERC-20 代币的地址
	* @param policy Number of the desired policy
	* @param policy 所需策略的编号
	* @param amount Token amount being deposited to the reserve
	* @param amount 存入储备金的代币数量
	* @param close Choose to close the policy
	* @param close 选择关闭策略
	* @return True for closed policy 
	* @return 如果策略已关闭,则为 True
	*/
	function closePolicy(address token, uint256 policy, uint256 amount, bool close) external virtual returns (bool)

	/**
	* @dev Accounting for tokens deposited by owner
	* @dev 核算所有者存入的代币
	* - MUST be reserve owner
	* - 必须是储备金所有者
	* - SHOULD emit depositR event
	* - 应该发出 depositR 事件
	* NOTE: No shares are issued, funds can not be redeemed and no policy is opened. Withdrawnal made with openPolicy function.
	* 注意:不发行份额,资金无法赎回,并且不开启策略。使用 openPolicy 函数进行提款。
	* @param token Address of ERC-20 token being deposited
	* @param token 存入的 ERC-20 代币的地址
	* @param sender Address of token sender
	* @param sender 代币发送者的地址
	* @param amount Token amount being deposited 
	* @param amount 存入的代币数量
	*/
	function depositReserve(address token, address sender, uint256 amount) external virtual
}
    

理由

这项提出的标准旨在成为代币化储备金接口的核心实现。其他未指定的条件应根据具体情况处理。每个储备金使用 ERC-20 标准作为份额,并使用 ERC-4626 创建份额。储备金代币应被视为 ERC-4626 金库的底层 asset,或者是在存入金库时创建的份额。ERC-4626 用于创建透明的储备金利益相关者。储备金中必须有利益相关者的代表。实施者可以决定如何根据用户加入和离开金库的情况来处理代表权。例如,可以强制用户不在多个策略中使用相同的代币,以允许公平地分配份额。

向后兼容性

代币化储备金与 ERC-20ERC-4626 兼容。

安全注意事项

代币化储备金与 ERC-20ERC-4626 共享相同的安全注意事项。

  1. 所有者提取的资产不受金库保护。
    • 利益相关者应该意识到,所有者可以不受限制或无需授权方(例如要求 rAuth)提取底层 asset。根据授权实施情况,所有者仍然可以提取 asset

推荐的实施方式:

  • openPolicy 必须明确限制底层 asset 的转移。
  • 如果底层资产是储备金的一部分而不是金库,则储备金必须提供一种避免用户 asset 损失的方法。

版权

根据 CC0 放弃版权和相关权利。

Citation

Please cite this document as:

Jimmy Debe (@jimstir), "ERC-7425: 代币化储备金 [DRAFT]," Ethereum Improvement Proposals, no. 7425, June 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7425.