Open code423n4 opened 2 years ago
Great report by this warden, he should get extra points.
[S] Changing unnecessary storage variables to immutable can save gas
Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/1
[S] SafeMath is no longer needed
Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/11
[S] _tokenAddress() can be changed to immutable to save gas from unnecessary external calls
Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/19
Excellent report that was clearly composed with sponsor empathy in mind.
[S]: Suggested optimation, save a decent amount of gas without compromising readability;
[M]: Minor optimation, the amount of gas saved is minor, change when you see fit;
[N]: Non-preferred, the amount of gas saved is at cost of readability, only apply when gas saving is a top priority.
[S] Changing unnecessary storage variables to immutable can save gas
https://github.com/pooltogether/aave-v3-yield-source/blob/e63d1b0e396a5bce89f093630c282ca1c6627e44/contracts/AaveV3YieldSource.sol#L127
Considering that
aToken
will never change, changing it to immutable variable instead of a storage variable can save gas.[S] SafeMath is no longer needed
SafeMath
is no longer needed starting with Solidity 0.8. The compiler now has built in overflow checking.Removing
SafeMath
can save some gas.[S]
_tokenAddress()
can be changed toimmutable
to save gas from unnecessary external callshttps://github.com/pooltogether/aave-v3-yield-source/blob/e63d1b0e396a5bce89f093630c282ca1c6627e44/contracts/AaveV3YieldSource.sol#L231-L235
Since
_underlyingAssetAddress
will never change, it can be change to aimmutable
variable in theconstructor()
and save a decent of gas from the unnecessary external calls in everysupplyTokenTo()
andredeemToken()
txs.