ERC4626标准允许为代表单一底层ERC-20代币份额的代币金库实现一个标准的API,通过拓展ERC20协议,提供了存入和提取代币以及读取余额的基本功能。(金库标准化)
收益聚合器(例如Yearn、Rari 和Idle)、借贷市场(例如Compound, Aave和 Fuse)和原生收益代币(例如xSUSHI )通常在实施时略有不同。对于需要符合许多标准的协议,这使得在聚合器或插件层的集成变得困难,这迫使每个协议编写Adapter,而这些适配器容易出错并会浪费开发资源。
(1)就是为了使一切变得标准化、简单化,这使得任何有收益的代币都可以与任何 DeFi 应用程序兼容,从而增强多个网络中的收益金库的可组合性和可访问性。
(1)asset: 返回underlyingToken
- name: asset
type: function
stateMutability: view
inputs: []
outputs:
- name: assetTokenAddress
type: address
(2) totalAssets: 返回underlyingToken的总量
- name: totalAssets
type: function
stateMutability: view
inputs: []
outputs:
- name: totalManagedAssets
type: uint256
(3) convertToShares: 在满足所有条件的理想情况下,能换到shareToken的数量
- name: convertToShares
type: function
stateMutability: view
inputs:
- name: assets
type: uint256
outputs:
- name: shares
type: uint256
(4) maxDeposit: 通过存款通知,可以为接收方存入保险库的标的资产的最大数量。
- name: maxDeposit
type: function
stateMutability: view
inputs:
- name: receiver
type: address
outputs:
- name: maxAssets
type: uint256
(5) previewDeposit: 估算 Deposit 的结果
- name: previewDeposit
type: function
stateMutability: view
inputs:
- name: assets
type: uint256
outputs:
- name: shares
type: uint256
(6) maxMint: 从金库发送给接收者铸币的最大数量。
- name: maxMint
type: function
stateMutability: view
inputs:
- name: receiver
type: address
outputs:
- name: maxShares
type: uint256
(7) previewMint: 允许链上或链下用户在给定当前链上条件的情况下模拟其铸币在当前区块的效果
- name: previewMint
type: function
stateMutability: view
inputs:
- name: shares
type: uint256
outputs:
- name: assets
type: uint256
- name: Deposit
type: event
inputs:
- name: sender
indexed: true
type: address
- name: owner
indexed: true
type: address
- name: assets
indexed: false
type: uint256
- name: shares
indexed: false
type: uint256
(2)withdraw
- name: Withdraw
type: event
inputs:
- name: sender
indexed: true
type: address
- name: receiver
indexed: true
type: address
- name: owner
indexed: true
type: address
- name: assets
indexed: false
type: uint256
- name: shares
indexed: false
type: uint256
(1)EOA账户
如果实施者打算直接支持EOA账户访问,他们应该考虑为deposit/mint/withdraw/redeem添加一个额外的函数调用,并有办法适应滑点损失或意外的存款/提款限制,因为他们没有其他办法在没有达到确切的输出金额时恢复交易。
(2)预览方法返回值问题