Skip to content

Commit

Permalink
fix(perp): emit MarketUpdatedEvents even in the absence of index price (
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang authored Oct 8, 2023
1 parent 7d1adb0 commit 40f8e71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions x/perp/v2/module/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 40f8e71

Please sign in to comment.