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
Rank: 30/43
Findings: 1
Award: $22.46
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: lsaudit
Also found by: 0x11singh99, 0x4non, 0xAnah, 0xSmartContract, 0xhacksmithh, JP_Courses, Jorgect, MrPotatoMagic, Sathish9098, epistkr, pfapostol, pontifex
22.4575 USDC - $22.46
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); ... }
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