Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added erc 4626 token standard example (#538) #602

Merged
merged 17 commits into from
Dec 12, 2023

Conversation

ebadiere
Copy link
Contributor

@ebadiere ebadiere commented Nov 20, 2023

OZ ERC-4626 TokenVault example.

Related issue(s): #538

Fixes #538

Notes for reviewer:
The test coverage in this PR checks the encoded transaction data coming back in the receipt query response. Local node PR 457 needs to be merged into the local node in order for the contract revert reasons to the test correctly.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@ebadiere ebadiere added the enhancement New feature or request label Nov 20, 2023
@ebadiere ebadiere added this to the 0.7.0 milestone Nov 20, 2023
@ebadiere ebadiere self-assigned this Nov 20, 2023
Copy link

github-actions bot commented Nov 20, 2023

Test Results

  18 files  +  4    86 suites  +21   9m 56s ⏱️ + 2m 35s
214 tests +  8  205 ✔️ +  7    6 💤 ±0  3 +1 
260 runs  +54  246 ✔️ +48  10 💤 +4  4 +2 

For more details on these failures, see this check.

Results for commit 54d0d41. ± Comparison against base commit 8190545.

♻️ This comment has been updated with latest results.

Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG overall but still some comments

return shareHolders[_user];
}

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line at EOF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

// Calculate the total asset amount as the sum of the share amount plus 10% of the share amount.
uint256 assets = _shares + percent;
// calling the redeem function from the ERC-4626 library to perform all the necessary functionality
redeem(assets, _receiver, msg.sender);
Copy link
Member

@quiet-node quiet-node Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this redeem method sending assets to msg.sender? If so I think a checks-effects-interactions approach would be better in this case to avoid reentrant attacks. Just simply swap the line 49 with this line 47 should fix it I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -14,8 +14,4 @@ contract Main is Base {
function returnSuper() public view virtual returns (string memory) {
return super.classIdentifier();
}

function destroyContract(address recipient) public {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to removed this last time iirc, and Nana told me that we should still keep this until new Cancun EVM release which will remove the support for selfdestruct opcode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this got into the review. I may have run a rebase, but I didn't work on that contract.

const { ethers } = require("hardhat");
const Constants = require('../../constants')

describe("TokenVault Contract", function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the unit test flag to @OZTokenValut or @OZerc4626 or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

});
});

});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line at EOF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: ebadiere <[email protected]>
quiet-node
quiet-node previously approved these changes Nov 28, 2023
Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG. Just 1 nit which I think can be addressed in next PR

const { ethers } = require("hardhat");
const Constants = require('../../constants')

describe("@OZTokenValut TokenVault Contract", function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The OZ flag has a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@ebadiere ebadiere marked this pull request as ready for review December 6, 2023 18:10
…they

may be confusing depending on what node they are running against.

Signed-off-by: ebadiere <[email protected]>
Signed-off-by: ebadiere <[email protected]>
@ebadiere ebadiere changed the title 538 erc 4626 token standard example feat: 538 erc 4626 token standard example Dec 11, 2023
Copy link
Member

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a couple of nits

const { ethers } = require("hardhat");
const Constants = require('../../constants')

describe("@OZ TokenVault Contract", function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should be @OZTokenVault


beforeEach(async function () {
ERC20Mock = await ethers.getContractFactory("contracts/erc-20/ERC20Mock.sol:ERC20Mock");
asset = await ERC20Mock.deploy("MockToken", "MTK", Constants.GAS_LIMIT_1_000_000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make "MockToken" and "MTK" constant variables as I see them being reused around in the contract

@quiet-node quiet-node changed the title feat: 538 erc 4626 token standard example feat: added erc 4626 token standard example (#538) Dec 12, 2023
@quiet-node quiet-node merged commit 81df819 into main Dec 12, 2023
22 of 24 checks passed
@quiet-node quiet-node deleted the 538-ERC-4626-token-standard-example branch December 12, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add OZ ERC 4626 token standard example
2 participants