Skip to content

Commit 80c7a3e

Browse files
committed
Rename ERC20TokenizedVault to ERC4626 (#3467)
(cherry picked from commit a55b7d1) Signed-off-by: Hadrien Croubois <[email protected]>
1 parent e30ea41 commit 80c7a3e

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* `TimelockController`: Migrate `_call` to `_execute` and allow inheritance and overriding similar to `Governor`. ([#3317](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3317))
66
* `CrossChainEnabledPolygonChild`: replace the `require` statement with the custom error `NotCrossChainCall`. ([#3380](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3380))
77
* `ERC20FlashMint`: Add customizable flash fee receiver. ([#3327](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3327))
8-
* `ERC20TokenizedVault`: add an extension of `ERC20` that implements the ERC4626 Tokenized Vault Standard. ([#3171](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3171))
8+
* `ERC4626`: add an extension of `ERC20` that implements the ERC4626 Tokenized Vault Standard. ([#3171](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3171))
99
* `SafeERC20`: add `safePermit` as mitigation against phantom permit functions. ([#3280](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3280))
1010
* `Math`: add a `mulDiv` function that can round the result either up or down. ([#3171](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3171))
1111
* `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))

contracts/mocks/ERC20TokenizedVaultMock.sol renamed to contracts/mocks/ERC4626Mock.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
pragma solidity ^0.8.0;
44

5-
import "../token/ERC20/extensions/ERC20TokenizedVault.sol";
5+
import "../token/ERC20/extensions/ERC4626.sol";
66

77
// mock class using ERC20
8-
contract ERC20TokenizedVaultMock is ERC20TokenizedVault {
8+
contract ERC4626Mock is ERC4626 {
99
constructor(
1010
IERC20Metadata asset,
1111
string memory name,
1212
string memory symbol
13-
) ERC20(name, symbol) ERC20TokenizedVault(asset) {}
13+
) ERC20(name, symbol) ERC4626(asset) {}
1414

1515
function mockMint(address account, uint256 amount) public {
1616
_mint(account, amount);

contracts/token/ERC20/README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Additionally there are multiple custom extensions, including:
2424
* {ERC20Votes}: support for voting and vote delegation.
2525
* {ERC20VotesComp}: support for voting and vote delegation (compatible with Compound's token, with uint96 restrictions).
2626
* {ERC20Wrapper}: wrapper to create an ERC20 backed by another ERC20, with deposit and withdraw methods. Useful in conjunction with {ERC20Votes}.
27-
* {ERC20TokenizedVault}: tokenized vault that manages shares (represented as ERC20) that are backed by assets (another ERC20).
27+
* {ERC4626}: tokenized vault that manages shares (represented as ERC20) that are backed by assets (another ERC20).
2828
2929
Finally, there are some utilities to interact with ERC20 contracts in various ways.
3030

@@ -63,7 +63,7 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel
6363

6464
{{ERC20FlashMint}}
6565

66-
{{ERC20TokenizedVault}}
66+
{{ERC4626}}
6767

6868
== Draft EIPs
6969

contracts/token/ERC20/extensions/ERC20TokenizedVault.sol renamed to contracts/token/ERC20/extensions/ERC4626.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "../../../utils/math/Math.sol";
1919
*
2020
* _Available since v4.7._
2121
*/
22-
abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
22+
abstract contract ERC4626 is ERC20, IERC4626 {
2323
using Math for uint256;
2424

2525
IERC20Metadata private immutable _asset;
@@ -93,7 +93,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
9393

9494
/** @dev See {IERC4262-deposit} */
9595
function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {
96-
require(assets <= maxDeposit(receiver), "ERC20TokenizedVault: deposit more than max");
96+
require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max");
9797

9898
uint256 shares = previewDeposit(assets);
9999
_deposit(_msgSender(), receiver, assets, shares);
@@ -103,7 +103,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
103103

104104
/** @dev See {IERC4262-mint} */
105105
function mint(uint256 shares, address receiver) public virtual override returns (uint256) {
106-
require(shares <= maxMint(receiver), "ERC20TokenizedVault: mint more than max");
106+
require(shares <= maxMint(receiver), "ERC4626: mint more than max");
107107

108108
uint256 assets = previewMint(shares);
109109
_deposit(_msgSender(), receiver, assets, shares);
@@ -117,7 +117,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
117117
address receiver,
118118
address owner
119119
) public virtual override returns (uint256) {
120-
require(assets <= maxWithdraw(owner), "ERC20TokenizedVault: withdraw more than max");
120+
require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max");
121121

122122
uint256 shares = previewWithdraw(assets);
123123
_withdraw(_msgSender(), receiver, owner, assets, shares);
@@ -131,7 +131,7 @@ abstract contract ERC20TokenizedVault is ERC20, IERC4626 {
131131
address receiver,
132132
address owner
133133
) public virtual override returns (uint256) {
134-
require(shares <= maxRedeem(owner), "ERC20TokenizedVault: redeem more than max");
134+
require(shares <= maxRedeem(owner), "ERC4626: redeem more than max");
135135

136136
uint256 assets = previewRedeem(shares);
137137
_withdraw(_msgSender(), receiver, owner, assets, shares);

test/token/ERC20/extensions/ERC20TokenizedVault.test.js renamed to test/token/ERC20/extensions/ERC4626.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test
22
const { expect } = require('chai');
33

44
const ERC20DecimalsMock = artifacts.require('ERC20DecimalsMock');
5-
const ERC20TokenizedVaultMock = artifacts.require('ERC20TokenizedVaultMock');
5+
const ERC4626Mock = artifacts.require('ERC4626Mock');
66

77
const parseToken = (token) => (new BN(token)).mul(new BN('1000000000000'));
88
const parseShare = (share) => (new BN(share)).mul(new BN('1000000000000000000'));
99

10-
contract('ERC20TokenizedVault', function (accounts) {
10+
contract('ERC4626', function (accounts) {
1111
const [ holder, recipient, spender, other, user1, user2 ] = accounts;
1212

1313
const name = 'My Token';
1414
const symbol = 'MTKN';
1515

1616
beforeEach(async function () {
1717
this.token = await ERC20DecimalsMock.new(name, symbol, 12);
18-
this.vault = await ERC20TokenizedVaultMock.new(this.token.address, name + ' Vault', symbol + 'V');
18+
this.vault = await ERC4626Mock.new(this.token.address, name + ' Vault', symbol + 'V');
1919

2020
await this.token.mint(holder, web3.utils.toWei('100'));
2121
await this.token.approve(this.vault.address, constants.MAX_UINT256, { from: holder });
@@ -227,7 +227,7 @@ contract('ERC20TokenizedVault', function (accounts) {
227227
await expectRevert.unspecified(this.vault.previewDeposit(parseToken(1)));
228228
await expectRevert(
229229
this.vault.deposit(parseToken(1), recipient, { from: holder }),
230-
'ERC20TokenizedVault: deposit more than max',
230+
'ERC4626: deposit more than max',
231231
);
232232
});
233233

@@ -400,7 +400,7 @@ contract('ERC20TokenizedVault', function (accounts) {
400400
it('multiple mint, deposit, redeem & withdrawal', async function () {
401401
// test designed with both asset using similar decimals
402402
this.token = await ERC20DecimalsMock.new(name, symbol, 18);
403-
this.vault = await ERC20TokenizedVaultMock.new(this.token.address, name + ' Vault', symbol + 'V');
403+
this.vault = await ERC4626Mock.new(this.token.address, name + ' Vault', symbol + 'V');
404404

405405
await this.token.mint(user1, 4000);
406406
await this.token.mint(user2, 7001);

0 commit comments

Comments
 (0)