Platform: Code4rena
Start Date: 27/01/2022
Pot Size: $75,000 USDC
Total HM: 10
Participants: 26
Period: 7 days
Judge: pauliax
Total Solo HM: 5
Id: 81
League: ETH
Rank: 17/26
Findings: 1
Award: $333.65
🌟 Selected for report: 3
🚀 Solo Findings: 0
🌟 Selected for report: Tomio
175.6079 USDC - $175.61
Tomio
Expensive gas
https://github.com/code-423n4/2022-01-notional/blob/main/contracts/sNOTE.sol#L305 // gas cost 24474
Remix
Change to:
AccountCoolDown storage coolDown = accountCoolDown[account]; // gas cost 24185
#0 - jeffywu
2022-02-06T14:16:35Z
Report is unclear, proposed behavior is not what matches the existing code.
#1 - pauliax
2022-02-15T14:08:17Z
I think the warden suggested to change from this:
AccountCoolDown memory coolDown = accountCoolDown[account];
to this:
AccountCoolDown storage coolDown = accountCoolDown[account];
and from my understanding. this might slightly reduce gas costs because accountCoolDown is a storage variable.
🌟 Selected for report: Tomio
Also found by: TomFrenchBlockchain
79.0235 USDC - $79.02
Tomio
The check to make sure account is not in cool down is happening twice, on _mint() and _beforeTokenTransfer(), _beforeTokenTransfer() already has a _requireAccountNotInCoolDown() an the _mint() inside erc20upgradable will call the _beforeTokenTransfer(), this can make unnecessary call in the https://github.com/code-423n4/2022-01-notional/blob/main/contracts/sNOTE.sol#L328.
https://github.com/code-423n4/2022-01-notional/blob/main/contracts/sNOTE.sol#L328.
#0 - pauliax
2022-02-15T13:56:37Z
Valid optimization.
79.0235 USDC - $79.02
Tomio
There is unnecessary if else condition on _redeemAndTransfer(), and can be optimized by removing the inline if else condition on line https://github.com/code-423n4/2022-01-notional/blob/main/contracts/TreasuryAction.sol#L137-L140
https://github.com/code-423n4/2022-01-notional/blob/main/contracts/TreasuryAction.sol#L137-L140
From:
if (underlying.tokenAddress == address(0)) { WETH9(WETH).deposit{value: address(this).balance}(); } address underlyingAddress = underlying.tokenAddress == address(0) ? address(WETH) : underlying.tokenAddress; IERC20(underlyingAddress).safeTransfer(treasuryManagerContract, redeemedExternalUnderlying);
To:
if (underlying.tokenAddress == address(0)) { WETH9(WETH).deposit{value: address(this).balance}(); IERC20(WETH).safeTransfer(treasuryManagerContract, redeemedExternalUnderlying); }else{ IERC20(underlying.tokenAddress).safeTransfer(treasuryManagerContract, redeemedExternalUnderlying); }
#0 - pauliax
2022-02-15T14:04:50Z
Valid optimization.