Shell Protocol - Jorgect's results

A set of EVM-based smart contracts on Arbitrum One. In a nutshell it is DeFi made simple.

General Information

Platform: Code4rena

Start Date: 21/08/2023

Pot Size: $36,500 USDC

Total HM: 1

Participants: 43

Period: 7 days

Judge: Dravee

Id: 277

League: ETH

Shell Protocol

Findings Distribution

Researcher Performance

Rank: 30/43

Findings: 1

Award: $22.46

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

bug
G (Gas Optimization)
grade-b
sufficient quality report
G-12

Awards

22.4575 USDC - $22.46

External Links

GAS OPTMIZATION.

[G-01] Save one multiplication in _getUtility function

The contract can applied Common Factor of a polynomial to save gas, see the next example to undertand what is the common Factor of a polynomial:

a*(b+c) = a*b + a*c

See the implementation:

function _getUtility(int256 x, int256 y) internal view returns (int256 utility) { ... int256 r0 = (-bQuad * MULTIPLIER + disc * MULTIPLIER) / aQuad.mul(two).muli(MULTIPLIER); int256 r1 = (-bQuad * MULTIPLIER - disc * MULTIPLIER) / aQuad.mul(two).muli(MULTIPLIER); ... }

https://github.com/code-423n4/2023-08-shell/blob/c61cf0e01bada04c3d6055acb81f61955ed600aa/src/proteus/EvolvingProteus.sol#L717C9-L718C93

We can implement the common factor of the above code to save gas avoiding adiccionals multiplication:

function _getUtility(int256 x, int256 y) internal view returns (int256 utility) { ... int256 r0 = ((-bQuad + disc) * MULTIPLIER) / aQuad.mul(two).muli(MULTIPLIER); int256 r1 = ((-bQuad - disc) * MULTIPLIER) / aQuad.mul(two).muli(MULTIPLIER); ... }

#0 - c4-pre-sort

2023-08-30T01:13:42Z

0xRobocop marked the issue as sufficient quality report

#1 - c4-judge

2023-09-11T20:12:44Z

JustDravee marked the issue as grade-b

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