Эх сурвалжийг харах

Rename ERC20TokenizedVault to ERC4626 (#3467)

(cherry picked from commit a55b7d13722e7ce850b626da2313f3e66ca1d101)
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Hadrien Croubois 3 жил өмнө
parent
commit
80c7a3ef43

+ 1 - 1
CHANGELOG.md

@@ -5,7 +5,7 @@
  * `TimelockController`: Migrate `_call` to `_execute` and allow inheritance and overriding similar to `Governor`. ([#3317](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3317))
  * `CrossChainEnabledPolygonChild`: replace the `require` statement with the custom error `NotCrossChainCall`. ([#3380](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3380))
  * `ERC20FlashMint`: Add customizable flash fee receiver. ([#3327](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3327))
- * `ERC20TokenizedVault`: add an extension of `ERC20` that implements the ERC4626 Tokenized Vault Standard. ([#3171](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3171))
+ * `ERC4626`: add an extension of `ERC20` that implements the ERC4626 Tokenized Vault Standard. ([#3171](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3171))
  * `SafeERC20`: add `safePermit` as mitigation against phantom permit functions. ([#3280](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3280))
  * `Math`: add a `mulDiv` function that can round the result either up or down. ([#3171](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3171))
  * `Math`: Add a `sqrt` function to compute square roots of integers, rounding either up or down. ([#3242](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3242))

+ 3 - 3
contracts/mocks/ERC20TokenizedVaultMock.sol → contracts/mocks/ERC4626Mock.sol

@@ -2,15 +2,15 @@
 
 pragma solidity ^0.8.0;
 
-import "../token/ERC20/extensions/ERC20TokenizedVault.sol";
+import "../token/ERC20/extensions/ERC4626.sol";
 
 // mock class using ERC20
-contract ERC20TokenizedVaultMock is ERC20TokenizedVault {
+contract ERC4626Mock is ERC4626 {
     constructor(
         IERC20Metadata asset,
         string memory name,
         string memory symbol
-    ) ERC20(name, symbol) ERC20TokenizedVault(asset) {}
+    ) ERC20(name, symbol) ERC4626(asset) {}
 
     function mockMint(address account, uint256 amount) public {
         _mint(account, amount);

+ 2 - 2
contracts/token/ERC20/README.adoc

@@ -24,7 +24,7 @@ Additionally there are multiple custom extensions, including:
 * {ERC20Votes}: support for voting and vote delegation.
 * {ERC20VotesComp}: support for voting and vote delegation (compatible with Compound's token, with uint96 restrictions).
 * {ERC20Wrapper}: wrapper to create an ERC20 backed by another ERC20, with deposit and withdraw methods. Useful in conjunction with {ERC20Votes}.
-* {ERC20TokenizedVault}: tokenized vault that manages shares (represented as ERC20) that are backed by assets (another ERC20).
+* {ERC4626}: tokenized vault that manages shares (represented as ERC20) that are backed by assets (another ERC20).
 
 Finally, there are some utilities to interact with ERC20 contracts in various ways.
 
@@ -63,7 +63,7 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel
 
 {{ERC20FlashMint}}
 
-{{ERC20TokenizedVault}}
+{{ERC4626}}
 
 == Draft EIPs
 

+ 5 - 5
contracts/token/ERC20/extensions/ERC20TokenizedVault.sol → contracts/token/ERC20/extensions/ERC4626.sol

@@ -19,7 +19,7 @@ import "../../../utils/math/Math.sol";
  *
  * _Available since v4.7._
  */
-abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
+abstract contract ERC4626 is ERC20, IERC4626 {
     using Math for uint256;
 
     IERC20Metadata private immutable _asset;
@@ -93,7 +93,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
 
     /** @dev See {IERC4262-deposit} */
     function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {
-        require(assets <= maxDeposit(receiver), "ERC20TokenizedVault: deposit more than max");
+        require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max");
 
         uint256 shares = previewDeposit(assets);
         _deposit(_msgSender(), receiver, assets, shares);
@@ -103,7 +103,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
 
     /** @dev See {IERC4262-mint} */
     function mint(uint256 shares, address receiver) public virtual override returns (uint256) {
-        require(shares <= maxMint(receiver), "ERC20TokenizedVault: mint more than max");
+        require(shares <= maxMint(receiver), "ERC4626: mint more than max");
 
         uint256 assets = previewMint(shares);
         _deposit(_msgSender(), receiver, assets, shares);
@@ -117,7 +117,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
         address receiver,
         address owner
     ) public virtual override returns (uint256) {
-        require(assets <= maxWithdraw(owner), "ERC20TokenizedVault: withdraw more than max");
+        require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max");
 
         uint256 shares = previewWithdraw(assets);
         _withdraw(_msgSender(), receiver, owner, assets, shares);
@@ -131,7 +131,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
         address receiver,
         address owner
     ) public virtual override returns (uint256) {
-        require(shares <= maxRedeem(owner), "ERC20TokenizedVault: redeem more than max");
+        require(shares <= maxRedeem(owner), "ERC4626: redeem more than max");
 
         uint256 assets = previewRedeem(shares);
         _withdraw(_msgSender(), receiver, owner, assets, shares);

+ 5 - 5
test/token/ERC20/extensions/ERC20TokenizedVault.test.js → test/token/ERC20/extensions/ERC4626.test.js

@@ -2,12 +2,12 @@ const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test
 const { expect } = require('chai');
 
 const ERC20DecimalsMock = artifacts.require('ERC20DecimalsMock');
-const ERC20TokenizedVaultMock = artifacts.require('ERC20TokenizedVaultMock');
+const ERC4626Mock = artifacts.require('ERC4626Mock');
 
 const parseToken = (token) => (new BN(token)).mul(new BN('1000000000000'));
 const parseShare = (share) => (new BN(share)).mul(new BN('1000000000000000000'));
 
-contract('ERC20TokenizedVault', function (accounts) {
+contract('ERC4626', function (accounts) {
   const [ holder, recipient, spender, other, user1, user2 ] = accounts;
 
   const name = 'My Token';
@@ -15,7 +15,7 @@ contract('ERC20TokenizedVault', function (accounts) {
 
   beforeEach(async function () {
     this.token = await ERC20DecimalsMock.new(name, symbol, 12);
-    this.vault = await ERC20TokenizedVaultMock.new(this.token.address, name + ' Vault', symbol + 'V');
+    this.vault = await ERC4626Mock.new(this.token.address, name + ' Vault', symbol + 'V');
 
     await this.token.mint(holder, web3.utils.toWei('100'));
     await this.token.approve(this.vault.address, constants.MAX_UINT256, { from: holder });
@@ -227,7 +227,7 @@ contract('ERC20TokenizedVault', function (accounts) {
       await expectRevert.unspecified(this.vault.previewDeposit(parseToken(1)));
       await expectRevert(
         this.vault.deposit(parseToken(1), recipient, { from: holder }),
-        'ERC20TokenizedVault: deposit more than max',
+        'ERC4626: deposit more than max',
       );
     });
 
@@ -400,7 +400,7 @@ contract('ERC20TokenizedVault', function (accounts) {
   it('multiple mint, deposit, redeem & withdrawal', async function () {
     // test designed with both asset using similar decimals
     this.token = await ERC20DecimalsMock.new(name, symbol, 18);
-    this.vault = await ERC20TokenizedVaultMock.new(this.token.address, name + ' Vault', symbol + 'V');
+    this.vault = await ERC4626Mock.new(this.token.address, name + ' Vault', symbol + 'V');
 
     await this.token.mint(user1, 4000);
     await this.token.mint(user2, 7001);