Skip to content

Conversation

0xGorilla
Copy link
Owner

No description provided.

Copy link
Owner Author

@0xGorilla 0xGorilla left a comment

Choose a reason for hiding this comment

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

GREAT JOB!! You went ahead and completed the challenge and all of the bonuses, well done.

Regarding the tests, I believe you could have done them a bit tidier, maybe by separating e2e from unit tests. There is a library that we developed in-house that may help your with simplifying your tests: https://github.com/defi-wonderland/smock

I left you some comments all over, most of them are not a must, they are just for your personal improvement.

Again, great great job 👏

hardhat: {
forking: {
url: urlAlchemy,
block: 13006453
Copy link
Owner Author

Choose a reason for hiding this comment

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

What if 2 tests would require to fork a different block number? I would prefer to do enable: false here and to reset it independently in each test

@@ -0,0 +1,19 @@
/**
* @type import('hardhat/config').HardhatUserConfig
Copy link
Owner Author

Choose a reason for hiding this comment

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

I see you like types, why not using typescript then?


require("@nomiclabs/hardhat-waffle");
// require("hardhat-gas-reporter");
let { urlAlchemy } = require("./secrets.json");
Copy link
Owner Author

Choose a reason for hiding this comment

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

usually, you want to create a secrets.example.json that is not gitignored, so the people can know what is the structure of the file without actually looking at the code

*/

require("@nomiclabs/hardhat-waffle");
// require("hardhat-gas-reporter");
Copy link
Owner Author

Choose a reason for hiding this comment

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

Why not using the reporter finally?

@@ -0,0 +1,10 @@
//SPDX-License-Identifier: Unlicense
Copy link
Owner Author

Choose a reason for hiding this comment

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

It's a good practice to keep the name of the file the same as the name of the contract, in this case GenericERC20.sol


if (balanceFromToken > 0) {
fromTokenBalances.set(key, 0);
uint256 balanceToToken = fromTokenBalances.get(key);
Copy link
Owner Author

Choose a reason for hiding this comment

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

How does this work? You just set the balance to 0 in the previous line...
Maybe you meant toTokenBalances

whaleSigner2 = await ethers.getSigner(whaleAddress2);

//Deploy library
this.IterableMapping = await ethers.getContractFactory("IterableMapping");
Copy link
Owner Author

Choose a reason for hiding this comment

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

Is it worth the headache using the IterableMapping in this case? Just asking...

await this.swapper.connect(whaleSigner).swap();
let balanceAfterSwapFromToken = ethers.utils.formatUnits(await this.swapper.connect(whaleSigner).viewBalanceFromToken());
let balanceAfterSwapToToken = ethers.utils.formatUnits(await this.swapper.connect(whaleSigner).viewBalanceToToken());
expect(Number(balanceAfterSwapFromToken)).equal(0);
Copy link
Owner Author

Choose a reason for hiding this comment

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

hardhat-waffle supports comparisson with big numbers, I don't think you need any Number(...)


using IterableMapping for IterableMapping.Map;

address public DAI;
Copy link
Owner Author

Choose a reason for hiding this comment

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

all variables should be camelCase, except for constants that should be all caps

function work(uint256 deadline) public {
require(workable(), "You can't execute now");
SwapperUNIV2.swap(deadline);
Keep3r.receipt(Keep3rAddress, msg.sender, 1 * 10 ** 18);
Copy link
Owner Author

Choose a reason for hiding this comment

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

You can just do 1 ether instead of 1 * 10 ** 18

return count;
}

function provide(uint256 amount, bool isNativeETH) external payable {
Copy link
Owner Author

Choose a reason for hiding this comment

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

You could create two overloaded functions, for example:
function provide(uint256 amount) external
and
function provide() external payable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant