Platform: Code4rena
Start Date: 04/02/2022
Pot Size: $30,000 USDC
Total HM: 3
Participants: 37
Period: 3 days
Judge: leastwood
Id: 84
League: ETH
Rank: 34/37
Findings: 1
Award: $33.80
🌟 Selected for report: 0
🚀 Solo Findings: 0
33.7964 USDC - $33.80
PostMan56
This is my first time submitting so please let me know if it's bad or poorly explained
Small gas optimization in the function 'getTokenInLimitLeft' and use of uint256 vs uint8
function getTokenInLimitLeft() external view returns (uint256 limitLeft_) { if (totalTokenIn < tokenInLimit) { limitLeft_ = tokenInLimit - totalTokenIn; } }
In gas estimates(before):
"Creation": { "codeDepositCost": "3427600", "executionCost": "3828", "totalCost": "3431428" }
function getTokenInLimitLeft() external view returns (uint256 limitLeft_) { if (totalTokenIn <= tokenInLimit) { limitLeft_ = tokenInLimit - totalTokenIn; } }
In gas estimates(after):
"Creation": { "codeDepositCost": "3427400", "executionCost": "3828", "totalCost": "3431228" }
uint8 can be found in lines: 56, 57, 65, 146
In gas estimates(before):
"Creation": { "codeDepositCost": "3427600", "executionCost": "3828", "totalCost": "3431428" }
In gas estimates(after):
"Creation": { "codeDepositCost": "3394800", "executionCost": "3787", "totalCost": "3398587" }
Remix gas estimates
< & > contains ISZERO opcode making it cost more To negate this add = after < or > to save 200 gas on contract deploy
use of uint256 is cheaper than uint8 in data types
#0 - GalloDaSballo
2022-02-14T13:55:03Z
Appreciate the well thoughtout findindg with POC and math
#1 - GalloDaSballo
2022-02-14T13:55:21Z
The only thing better would be a link to a gist / remix to verify the claims autonomously