Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: metoken medians #2346

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 16 additions & 9 deletions x/oracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Loading