Closed sherlock-admin2 closed 10 months ago
1 comment(s) were left on this issue during the judging contest.
panprog commented:
invalid, because keepers are rewarded based on actual gas spent (via kept modifier), so no need to count number of accounts settled
agree with panprog -- keep
measures the aggregate gas and calldata cost of the method and should reward accordingly.
Emmanuel
medium
Current
KeeperFactory#settle
logic is not entirely correct: Keepers that input lower maxCounts earn more keeper fees than those that input larger maxCountsSummary
With the current
KeeperFactory#settle
logic, either:Vulnerability Detail
When
settle
ing accounts that a Market requested a new oracle version for, the caller is allowed to enter amaxCount
parameter, which means thatmaxCount
number of accounts within the callback array will be settled.settle
ing an account pays the caller a predetermined amount based on the settleKeepConfig() values. So, irrespective of the number of accounts that gets settled in a singleKeeperFactory#settle
call, the caller receives the same amount.For example, if Alice calls
KeeperFactory#settle
with a maxCount of 10, and Bob calls the function with a maxCount of 1, they both get paid the same amount of keeper fees.This incentivizes a keeper to call
KeeperFactory#settle
with a maxCount of 1, n times,(rather than inputting a maxCount of n) so that they get more keeper fees. This will lead to significant loss of keeper fees overtime as many users interact with a Market.Consider the following scenario:
KeeperFactory#settle
(based on settleKeepConfig), is 1 DSUKeeperFactory#settle
with a maxCount of 200, keeper would have received 1 DSU as feeKeeperFactory#settle
with a maxCount of 1, 200 times in a loop, which will make him receive 200*1=200 DSU as feesImpact
User can enter small maxCount for a market multiple times to use up more keeper fees than keepers that input larger maxCount. This leads to wastage of keeper fees
Code Snippet
https://github.com/sherlock-audit/2023-10-perennial/blob/main/perennial-v2/packages/perennial-oracle/contracts/keeper/KeeperFactory.sol#L202-L217
Tool used
Manual Review
Recommendation
Consider implementing any of these:
Keepers should be rewarded according to the number of accounts they settled, to make it fair for all keepers.
There should be a minimum number of accounts that a keeper is allowed to settle. This will reduce wastage of the fees. Within KeeperOracle#settle: