-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
…n(); Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: ebadiere <[email protected]>
… node. Signed-off-by: ebadiere <[email protected]>
Signed-off-by: ebadiere <[email protected]>
…til a solution for returning the contract revert reason is found. Signed-off-by: ebadiere <[email protected]>
Test Results 18 files + 4 86 suites +21 9m 56s ⏱️ + 2m 35s 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. |
…nReceipt Signed-off-by: ebadiere <[email protected]>
There was a problem hiding this 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
contracts/oz/erc-4626/TokenVault.sol
Outdated
return shareHolders[_user]; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra line at EOF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
contracts/oz/erc-4626/TokenVault.sol
Outdated
// 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
test/oz/erc-4626/TokenVault.js
Outdated
const { ethers } = require("hardhat"); | ||
const Constants = require('../../constants') | ||
|
||
describe("TokenVault Contract", function () { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/oz/erc-4626/TokenVault.js
Outdated
}); | ||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line at EOF
There was a problem hiding this comment.
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]>
There was a problem hiding this 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
test/oz/erc-4626/TokenVault.js
Outdated
const { ethers } = require("hardhat"); | ||
const Constants = require('../../constants') | ||
|
||
describe("@OZTokenValut TokenVault Contract", function () { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Signed-off-by: ebadiere <[email protected]>
Signed-off-by: ebadiere <[email protected]>
…they may be confusing depending on what node they are running against. Signed-off-by: ebadiere <[email protected]>
Signed-off-by: ebadiere <[email protected]>
There was a problem hiding this 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 () { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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