code-423n4 / 2021-12-pooltogether-findings

0 stars 0 forks source link

TwarbRewards: don't use the onlyPromotionCreator modifier to save gas #77

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

GiveMeTestEther

Vulnerability details

Impact

cancelPromotion() and its modifier both call _getPromotion() to get the Promotion struct. We can save one such call by removing the modifier and do the check of the modifier at the beginning of the cancelPromotion() block to save storage reads.

Proof of Concept

https://github.com/pooltogether/v4-periphery/blob/b520faea26bcf60371012f6cb246aa149abd3c7d/contracts/TwabRewards.sol#L119

Tools Used

Recommended Mitigation Steps