diff --git a/CHANGELOG.md b/CHANGELOG.md index c3590d742..7f3a17466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump `bufbuild/buf-setup-action` from 1.26.1 to 1.27.0 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624)) - Bump `stefanzweifel/git-auto-commit-action` from 4 to 5 ([#1625](https://github.com/NibiruChain/nibiru/pull/1625)) +### Bug Fixes + +* [#1606](https://github.com/NibiruChain/nibiru/pull/1606) - fix(perp): emit `MarketUpdatedEvent` in the absence of index price + ## [v0.21.10] ### Features diff --git a/x/perp/v2/module/abci.go b/x/perp/v2/module/abci.go index 8b9edb281..6326700dc 100644 --- a/x/perp/v2/module/abci.go +++ b/x/perp/v2/module/abci.go @@ -37,18 +37,19 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate { continue } - indexTwap, err := k.OracleKeeper.GetExchangeRateTwap(ctx, amm.Pair) - if err != nil { - k.Logger(ctx).Error("failed to fetch twap index price", "market.Pair", market.Pair, "error", err) - continue - } - if markTwap.IsNil() || markTwap.IsZero() { k.Logger(ctx).Error("mark price is zero", "market.Pair", market.Pair) continue } - if indexTwap.IsNil() || indexTwap.IsZero() { + var indexTwap sdk.Dec + indexTwap, err = k.OracleKeeper.GetExchangeRateTwap(ctx, amm.Pair) + if err != nil { + k.Logger(ctx).Error("failed to fetch twap index price", "market.Pair", market.Pair, "error", err) + indexTwap = sdk.OneDec().Neg() + } + + if indexTwap.IsNil() { k.Logger(ctx).Error("index price is zero", "market.Pair", market.Pair) continue }