# OlympusPrice.v2.sol#storePrice: The moving average prices are used recursively for the calculation of the moving average price.

OlympusPrice storePrice feeds the moving-average price back into the cumulative observation update, recursively smoothing prices and masking oracle feed failures.

- Payout: Contest reward
- Severity: high
- Program: Olympus
- Credited: dany.armstrong90
- Disclosed: 2023-11-30
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2023-11-olympus-judging/issues/55
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-11-olympus%3AH-1
- Tags: domain:web3 impact:integrity kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:oracle-manipulation

**Target:** OlympusPrice.v2.sol price oracle module (Solidity)
**Root cause:** storePrice calls _getCurrentPrice which, when asset.useMovingAverage is true, appends asset.cumulativeObs/numObservations to the feed prices; that blended price is then written back into cumulativeObs, so the moving average is computed from itself.
**Steps:**
1. Configure an asset with useMovingAverage=true and storeMovingAverage=true plus oracle feeds.
2. Call storePrice(asset): L319 _getCurrentPrice appends cumulativeObs/numObservations to prices (L160) and returns the strategy-aggregated price.
3. L331 sets cumulativeObs = cumulativeObs + price - oldestPrice using that blended price.
4. Repeat: the moving average now depends on prior moving averages, over-smoothing and continuing to update even if all oracle feeds fail.
**How found:** Code reading of storePrice and _getCurrentPrice: noticed _getCurrentPrice conditionally includes the moving average in its price array, then traced that same returned price back into the cumulativeObs update, revealing the recursive dependency.
**Insight:** When a price function has a flag that injects a derived/stateful value into its output, check every caller that also writes that derived state back — accumulator updates must use raw oracle inputs, not the blended output.
