Notional x Index Coop - Tomio's results

A collaboration between Notional and Index Coop to create fixed rate yield index tokens.

General Information

Platform: Code4rena

Start Date: 07/06/2022

Pot Size: $75,000 USDC

Total HM: 11

Participants: 77

Period: 7 days

Judge: gzeon

Total Solo HM: 7

Id: 124

League: ETH

Notional

Findings Distribution

Researcher Performance

Rank: 65/77

Findings: 1

Award: $49.06

🌟 Selected for report: 0

🚀 Solo Findings: 0

Title: Using multiple require instead && can save gas

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashLogic.sol#L116-L123

Recommended Mitigation Steps:

require(msg.sender == address(NotionalV2),"Invalid"); require(_id == fCashID,"Invalid"); require(int256(_value) > 0,"Invalid");

========================================================================

Title: Using != is more gas efficient

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashLogic.sol#L121 https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashERC4626.sol#L23 https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L395

Recommended Mitigation Steps: Change from > 0 to != 0

========================================================================

Title: Gas savings for using solidity 0.8.10

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L19

Recommended Mitigation Steps: Consider to upgrade pragma to at least 0.8.10.

Solidity 0.8.10 has a useful change which reduced gas costs of external calls Reference: https://blog.soliditylang.org/2021/11/09/solidity-0.8.10-release-announcement/

========================================================================

Title: Use custom rrrors instead of revert strings to save gas

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L169 https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L199 https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L378

Recommended Mitigation Steps: Consider shortening the revert strings to fit in 32 bytes, or using custom errors

========================================================================

Title: Using unchecked and prefix increment is more effective for gas saving:

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L393 https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L605

Recommended Mitigation Steps:

for(uint256 i = 0; i < positionsLength;) { // Check that the given position is an equity position if(positions[i].unit > 0) { address component = positions[i].component; if(_isWrappedFCash(component)) { numFCashPositions++; } } unchecked{ ++i; //@audit-info: Place here with unchecked } }

========================================================================

Title: Calldata instead of memory for read only function

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashBase.sol#L125

Recommended Mitigation Steps: Change memory to `calldata

========================================================================

Title: Comparison operators

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L449 https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L485 https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashLogic.sol#L316

Recommended Mitigation Steps: Replace <= with <, and >= with > for gas opt

========================================================================

Title: Default value init

Proof of Concept: https://github.com/code-423n4/2022-06-notional-coop/blob/main/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L519

Recommended Mitigation Steps: Remove explicit initialization for default values.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter