Closed The-3D closed 3 years ago
uint16
for _reservesCount
? it should only hold up to 128, so uint8
could be used, giving more room for _maxBorrowStableRatePercent
_maxNumberOfReserves
need not be uint256
when the _reservesCount
is smaller. If both _maxNumberOfReserves
and _reservesCount
is uint8
, they could be in the same slot as well.i left uint16
for _reservesCount
to leave more margin - we can potentially extend the reserve configuration infinitely by adding more uints in the future. uint16
allows for 16536 max reserves without much impact on the storage size
furthermore _maxBorrowStableRatePercent
is a percentage with 2 decimal precision so it can't be bigger than 10000
Regarding _maxNumberOfReserves
, this should be handled differently - this storage variable is not needed at all. I opened another issue on this https://github.com/aave/aave-v3-core/issues/237
The _addressesProvider
is only set once in the initialize, is there a reason that we are not using an immutable here instead? The only reason I can think of is from V2 to reuse the implementation across different markets
We can make the _addressesProvider
immutable. Please open another issue for that
Identified by: Aave team
Scope:
In the storage layout of the
PoolStorage
contract, various optimizations are possible:_reservesCount
does not need to beuint256
; can be auint16
and paired with the_addressesProvider
and the_maxBorrowStableRatePercent
(which can also be reduced to auint64
) to save two SLOAD inborrow
andflashloan
and one SLOAD inwithdraw
,liquidationCall
_flashloanPremiumTotal
and_flashloanPremiumToProtocol
can be reduced to uint128 to save one SLOAD inflashloan
,flashloanSimple