Closed sherlock-admin4 closed 3 months ago
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
Rewards are not correctly calculated
The protocol team fixed this issue in the following PRs/commits: https://github.com/allora-network/allora-chain/pull/424
imsrybr0
High
Broken invariant : the sum of all (delegateRewardsPerShare * delegated stake - reward debt) = the balance of the /x/bank AlloraPendingRewardForDelegatorAccountName module account when calculating reputer and delegator rewards
Note
I did not find this issue on my own, I only saw it being fixed on the main repository in this PR.
Summary
Broken invariant : the sum of all (delegateRewardsPerShare * delegated stake - reward debt) = the balance of the /x/bank AlloraPendingRewardForDelegatorAccountName module account when calculating reputer and delegator rewards.
Vulnerability Detail
When calculating reputer and delegators rewards :
There are two issues in how this calculation is done : 1) The delegate reward per share is calculated base on the untrimmed total delegate reward, but only the trimmed total delegate reward end up being sent to the AlloraPendingRewardForDelegatorAccountName module account 2) The remaining rewards for the reputer are also calculated based the untrimmed total delegate rewards and will also be trimmed afterwards.
To illustrate this, let's assume we have a reputer that have equal stakes of 1uallo from the reputer itself and another delegate staker (50%/50%).
If the total rewards is 9 :
Impact
Code Snippet
GetRewardForReputerFromTotalReward
Tool used
Manual Review
Recommendation
Use the trimmed delegateRewards as basis for the calculation
Duplicate of #74