Each slot saved can avoid an extra Gsset (20000 gas) for the first setting. Subsequent reads as well as writes have smaller gas savings.
Instance (1):
Let's understand one by one all:
address and IERC20 uses 20 bytes of data.
uint256 uses 1 complete slot of 32 bytes.
State enum consists of 4 members with each member using uint8 meaning 1 byte of data. So total size of s_state is 4 bytes.
Recommendation:
As you can clearly see, State can easily be packed with any address or IERC20 by moving up as they have 12 bytes left.
Also, i_price in all practical usecase won't be big enough to keep it uint256. Option to keep it uint96 which gives good enough range of more than 79 Billion Tokens in case of 18 decimal tokens. If both i_price and i_arbiterFee can be make uint96 then both of them can be packed with couple of addresses.
Because of these optimizations, Contract can save on 3 complete storage slots and save 60000 gas.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.