Open code423n4 opened 2 years ago
[S] Move lockUntil from Delegation to TWABDelegator can save gas from external call
The lockUntil
value is specific to each delegation so it can't live in the TWABDelegator contract.
[M] Use custom error may save gas
Duplicate of https://github.com/code-423n4/2022-02-pooltogether-findings/issues/30
For the other issues, duplicate of https://github.com/code-423n4/2022-02-pooltogether-findings/issues/15
[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] Move
lockUntil
fromDelegation
toTWABDelegator
can save gas from external callThe
lockUntil
of aDelegation
is currently stored on theDelegation
contract and usually used by theTWABDelegator
contract through an external call (_delegation.lockUntil()
).https://github.com/pooltogether/v4-twab-delegator/blob/21bb53b2ea54a248bbd1d3170dbadd3a0c83d874/contracts/TWABDelegator.sol#L624-L626
In comparison to storing the
lockUntil
onTWABDelegator
contract, this creates an overhead of one external call.[M] Use custom error may save gas
https://github.com/pooltogether/v4-twab-delegator/blob/21bb53b2ea54a248bbd1d3170dbadd3a0c83d874/contracts/Delegation.sol#L30-L30
[M] ++i is more gas efficient than i++
https://github.com/pooltogether/v4-twab-delegator/blob/21bb53b2ea54a248bbd1d3170dbadd3a0c83d874/contracts/Delegation.sol#L42-L42
[N] "> 0" is less efficient than "!= 0" for unsigned integers
https://github.com/pooltogether/v4-twab-delegator/blob/21bb53b2ea54a248bbd1d3170dbadd3a0c83d874/contracts/TWABDelegator.sol#L601-L601