# coefficients math mistakenly calculates the coefficient diff with the same value

Allora rewards math copies coefficients into oldCoefficients before diffing, so coeffDiff is always zero and the minStakeFraction adjustment never applies, skewing reputer rewards.

- Payout: Contest reward
- Severity: medium
- Program: Allora
- Credited: 0x3b
- Disclosed: 2024-06-24
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-06-allora-judging/issues/93
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-allora%3AM-22
- Tags: domain:web3 impact:integrity kind:contest platform:sherlock sev:medium tech:go technique:source-review vuln:business-logic vuln:reward-distribution

**Target:** emissions module rewards calculation (rewards_internal.go GetAllReputersOutput)
**Root cause:** oldCoefficients is populated via copy(oldCoefficients, coefficients) from the same array before computing coeffDiff, so coefficients[l].Sub(oldCoefficients[l]) is always zero.
**Steps:**
1. Read GetAllReputersOutput in allora-chain/x/emissions/module/rewards/rewards_internal.go
2. Observe `copy(oldCoefficients, coefficients)` at line ~458 makes both arrays identical
3. Observe `coeffDiff, err := coefficients[l].Sub(oldCoefficients[l])` at line ~548 yields 0
4. Trace that coeffDiffTimesListenedDiff and coefDiffTimesListenedDiffOverStakedFracDiff become 0
5. Conclude the `listenedStakeFraction < minStakeFraction` branch sets coefficients[l] = oldCoefficients[l], no adjustment
**How found:** Code reading of the gradient-descent loop; noticed the copy of coefficients into oldCoefficients happens before the diff, making the subtraction trivially zero.
**Insight:** In iterative numeric loops, verify that 'old' snapshots are taken before mutation of the source array; a copy() from the same slice silently nullifies any delta computation and disables conditional adjustment branches.
