diff --git a/CHANGELOG.md b/CHANGELOG.md index eb4598132c..2721cb65b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes - [2315](https://github.com/umee-network/umee/pull/2215) Improve reliability of MaxBorrow, MaxWithdraw when special asset pairs present. +- [2346](https://github.com/umee-network/umee/pull/2346) Fix an issue where metokens were not included in historic data. ### Improvements diff --git a/x/oracle/abci.go b/x/oracle/abci.go index ccd14f89a8..f0becd24b8 100644 --- a/x/oracle/abci.go +++ b/x/oracle/abci.go @@ -77,16 +77,23 @@ func CalcPrices(ctx sdk.Context, params types.Params, k keeper.Keeper) error { } // save the exchange rate to store with denom and timestamp k.SetExchangeRate(ctx, denom, exchangeRate) + } - if k.IsPeriodLastBlock(ctx, params.HistoricStampPeriod) { - k.AddHistoricPrice(ctx, denom, exchangeRate) - } - - // Calculate and stamp median/median deviation if median stamp period has passed - if k.IsPeriodLastBlock(ctx, params.MedianStampPeriod) { - if err = k.CalcAndSetHistoricMedian(ctx, denom); err != nil { - return err - } + if k.IsPeriodLastBlock(ctx, params.HistoricStampPeriod) { + k.IterateExchangeRates(ctx, func(denom string, exgRate sdk.Dec, _ time.Time) (stop bool) { + k.AddHistoricPrice(ctx, denom, exgRate) + return false + }) + } + // Calculate and stamp median/median deviation if median stamp period has passed + if k.IsPeriodLastBlock(ctx, params.MedianStampPeriod) { + var err error + k.IterateExchangeRates(ctx, func(denom string, _ sdk.Dec, _ time.Time) (stop bool) { + err = k.CalcAndSetHistoricMedian(ctx, denom) + return err != nil + }) + if err != nil { + return err } }