Skip to content

Commit

Permalink
refactor(perp): rename amm.MarkPrice -> amm.InstMarkPrice to reflect …
Browse files Browse the repository at this point in the history
…that it's instantaneous
  • Loading branch information
Unique-Divine committed Sep 13, 2023
1 parent c23b000 commit 27d1821
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions x/perp/v2/types/amm.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (amm AMM) SettlementPrice() (price sdk.Dec, newAmm AMM, err error) {
// bias: open interest (base) skew in the AMM.
bias := amm.Bias()
if bias.IsZero() {
return amm.MarkPrice(), amm, nil
return amm.InstMarkPrice(), amm, nil
}

Check warning on line 59 in x/perp/v2/types/amm.go

View check run for this annotation

Codecov / codecov/patch

x/perp/v2/types/amm.go#L54-L59

Added lines #L54 - L59 were not covered by tests

var dir Direction
Expand Down Expand Up @@ -185,10 +185,10 @@ func (amm AMM) GetQuoteReserveAmt(
return quoteReserveDelta, nil
}

// MarkPrice: Returns the instantaneous mark price of the trading pair.
// InstMarkPrice: Returns the instantaneous mark price of the trading pair.
// This is the price if the AMM has zero slippage, or equivalently, if there's
// infinite liquidity depth with the same ratio of reserves.
func (amm AMM) MarkPrice() sdk.Dec {
func (amm AMM) InstMarkPrice() sdk.Dec {
if amm.BaseReserve.IsNil() || amm.BaseReserve.IsZero() ||
amm.QuoteReserve.IsNil() || amm.QuoteReserve.IsZero() {
return sdk.ZeroDec()
Expand Down
4 changes: 2 additions & 2 deletions x/perp/v2/types/amm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestSwapBaseAsset(t *testing.T) {
TotalLong: tc.expectedTotalLong,
TotalShort: tc.expectedTotalShort,
}, *amm)
assert.Equal(t, tc.expectedMarkPrice, amm.MarkPrice())
assert.Equal(t, tc.expectedMarkPrice, amm.InstMarkPrice())
}
})
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestSwapQuoteAsset(t *testing.T) {
TotalLong: tc.expectedTotalLong,
TotalShort: tc.expectedTotalShort,
}, *amm)
assert.Equal(t, tc.expectedMarkPrice, amm.MarkPrice())
assert.Equal(t, tc.expectedMarkPrice, amm.InstMarkPrice())
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/binding/cw_struct/cw_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func NewMarket(appMarket perpv2types.Market, appAmm perpv2types.AMM, indexPrice,
MaintenanceMarginRatio: appMarket.MaintenanceMarginRatio,
MaxLeverage: appMarket.MaxLeverage,
},
MarkPrice: appAmm.MarkPrice(),
MarkPrice: appAmm.InstMarkPrice(),
IndexPrice: indexPrice,
TwapMark: twapMark,
BlockNumber: sdk.NewInt(blockNumber),
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/binding/cw_struct/cw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *TestSuiteBindingJsonTypes) TestToAppMarket() {
ammMarket.Market,
ammMarket.Amm,
"index price",
ammMarket.Amm.MarkPrice().String(),
ammMarket.Amm.InstMarkPrice().String(),
dummyBlockHeight,
)

Expand Down
2 changes: 1 addition & 1 deletion x/wasm/binding/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (perpExt *PerpQuerier) AllMarkets(
MaintenanceMarginRatio: pbMarket.Market.MaintenanceMarginRatio,
MaxLeverage: pbMarket.Market.MaxLeverage,
},
MarkPrice: pbMarket.Amm.MarkPrice(),
MarkPrice: pbMarket.Amm.InstMarkPrice(),
// IndexPrice: pbPrice.IndexPrice,
// TwapMark: pbPrice.TwapMark,
BlockNumber: sdk.NewInt(ctx.BlockHeight()),
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/binding/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (s *TestSuiteQuerier) TestQueryAllMarkets() {
s.Assert().EqualValues(marketAmm.Amm.TotalLong, cwMarket.TotalLong)
s.Assert().EqualValues(marketAmm.Amm.TotalShort, cwMarket.TotalShort)
s.Assert().EqualValues(marketAmm.Amm.PriceMultiplier.String(), cwMarket.PegMult.String())
s.Assert().EqualValues(marketAmm.Amm.MarkPrice().String(), cwMarket.MarkPrice.String())
s.Assert().EqualValues(marketAmm.Amm.InstMarkPrice().String(), cwMarket.MarkPrice.String())
s.Assert().EqualValues(s.ctx.BlockHeight(), cwMarket.BlockNumber.Int64())
}
}
Expand Down

0 comments on commit 27d1821

Please sign in to comment.