From a2cf22cb74ab3ba3b61225cbabde37aa66ee15d8 Mon Sep 17 00:00:00 2001 From: Teddy Ding Date: Tue, 14 Jan 2025 13:27:04 -0500 Subject: [PATCH] fix workflow --- .../comlink/public/api-documentation.md | 2 +- indexer/services/comlink/public/swagger.json | 3 +-- indexer/services/comlink/src/types.ts | 2 +- protocol/indexer/events/perpetual.go | 2 +- protocol/indexer/events/perpetual_test.go | 17 +++++++------- ...pgrade_isolated_perpetual_to_cross_test.go | 23 ++++++++++--------- .../x/perpetuals/keeper/perpetual_test.go | 10 ++++---- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/indexer/services/comlink/public/api-documentation.md b/indexer/services/comlink/public/api-documentation.md index 88e187ee9f..0aebabb255 100644 --- a/indexer/services/comlink/public/api-documentation.md +++ b/indexer/services/comlink/public/api-documentation.md @@ -5420,7 +5420,7 @@ or |openInterestLowerCap|string|false|none|none| |openInterestUpperCap|string|false|none|none| |baseOpenInterest|string|true|none|none| -|defaultFundingRate1H|string|true|none|none| +|defaultFundingRate1H|string|false|none|none| ## PerpetualMarketResponse diff --git a/indexer/services/comlink/public/swagger.json b/indexer/services/comlink/public/swagger.json index 8f0b42b3be..df26429665 100644 --- a/indexer/services/comlink/public/swagger.json +++ b/indexer/services/comlink/public/swagger.json @@ -1162,8 +1162,7 @@ "stepBaseQuantums", "subticksPerTick", "marketType", - "baseOpenInterest", - "defaultFundingRate1H" + "baseOpenInterest" ], "type": "object", "additionalProperties": false diff --git a/indexer/services/comlink/src/types.ts b/indexer/services/comlink/src/types.ts index e8d5ed5664..7796f0ffc2 100644 --- a/indexer/services/comlink/src/types.ts +++ b/indexer/services/comlink/src/types.ts @@ -352,7 +352,7 @@ export interface PerpetualMarketResponseObject { openInterestLowerCap?: string, openInterestUpperCap?: string, baseOpenInterest: string, - defaultFundingRate1H: string, + defaultFundingRate1H?: string, } /* ------- ORDERBOOK TYPES ------- */ diff --git a/protocol/indexer/events/perpetual.go b/protocol/indexer/events/perpetual.go index beec68d35a..c3f2327b05 100644 --- a/protocol/indexer/events/perpetual.go +++ b/protocol/indexer/events/perpetual.go @@ -5,7 +5,7 @@ import ( perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" ) -// NewUpdatePerpetualEvent creates a UpdatePerpetualEventV2 representing +// NewUpdatePerpetualEvent creates a UpdatePerpetualEventV3 representing // update of a perpetual. func NewUpdatePerpetualEvent( id uint32, diff --git a/protocol/indexer/events/perpetual_test.go b/protocol/indexer/events/perpetual_test.go index 2c7de5966d..c8ff233b69 100644 --- a/protocol/indexer/events/perpetual_test.go +++ b/protocol/indexer/events/perpetual_test.go @@ -17,15 +17,16 @@ func TestNewUpdatePerpetualEvent_Success(t *testing.T) { -8, 2, perptypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_CROSS, - 0, + 100, // defaultFundingPpm ) - expectedUpdatePerpetualEventProto := &UpdatePerpetualEventV2{ - Id: 5, - Ticker: "BTC-ETH", - MarketId: 5, - AtomicResolution: -8, - LiquidityTier: 2, - MarketType: v1types.PerpetualMarketType_PERPETUAL_MARKET_TYPE_CROSS, + expectedUpdatePerpetualEventProto := &UpdatePerpetualEventV3{ + Id: 5, + Ticker: "BTC-ETH", + MarketId: 5, + AtomicResolution: -8, + LiquidityTier: 2, + MarketType: v1types.PerpetualMarketType_PERPETUAL_MARKET_TYPE_CROSS, + DefaultFunding8HrPpm: 100, } require.Equal(t, expectedUpdatePerpetualEventProto, updatePerpetualEvent) } diff --git a/protocol/x/listing/keeper/msg_server_upgrade_isolated_perpetual_to_cross_test.go b/protocol/x/listing/keeper/msg_server_upgrade_isolated_perpetual_to_cross_test.go index bf27627a57..8e3751b3dc 100644 --- a/protocol/x/listing/keeper/msg_server_upgrade_isolated_perpetual_to_cross_test.go +++ b/protocol/x/listing/keeper/msg_server_upgrade_isolated_perpetual_to_cross_test.go @@ -227,16 +227,17 @@ func TestMsgUpgradeIsolatedPerpetualToCross(t *testing.T) { // Verify that expected indexer event was emitted. perpetual, err = perpetualsKeeper.GetPerpetual(ctx, tc.msg.PerpetualId) require.NoError(t, err) - expectedIndexerEvent := &indexerevents.UpdatePerpetualEventV2{ - Id: perpetual.Params.Id, - Ticker: perpetual.Params.Ticker, - MarketId: perpetual.Params.MarketId, - AtomicResolution: perpetual.Params.AtomicResolution, - LiquidityTier: perpetual.Params.LiquidityTier, - MarketType: v1.ConvertToPerpetualMarketType(perpetualtypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_CROSS), + expectedIndexerEvent := &indexerevents.UpdatePerpetualEventV3{ + Id: perpetual.Params.Id, + Ticker: perpetual.Params.Ticker, + MarketId: perpetual.Params.MarketId, + AtomicResolution: perpetual.Params.AtomicResolution, + LiquidityTier: perpetual.Params.LiquidityTier, + MarketType: v1.ConvertToPerpetualMarketType(perpetualtypes.PerpetualMarketType_PERPETUAL_MARKET_TYPE_CROSS), + DefaultFunding8HrPpm: perpetual.Params.DefaultFundingPpm, } emittedIndexerEvents := getUpdatePerpetualEventsFromIndexerBlock(ctx, keeper) - require.Equal(t, emittedIndexerEvents, []*indexerevents.UpdatePerpetualEventV2{expectedIndexerEvent}) + require.Equal(t, emittedIndexerEvents, []*indexerevents.UpdatePerpetualEventV3{expectedIndexerEvent}) }, ) } @@ -246,15 +247,15 @@ func TestMsgUpgradeIsolatedPerpetualToCross(t *testing.T) { func getUpdatePerpetualEventsFromIndexerBlock( ctx sdk.Context, listingKeeper *listingkeeper.Keeper, -) []*indexerevents.UpdatePerpetualEventV2 { +) []*indexerevents.UpdatePerpetualEventV3 { block := listingKeeper.GetIndexerEventManager().ProduceBlock(ctx) - var updatePerpetualEvents []*indexerevents.UpdatePerpetualEventV2 + var updatePerpetualEvents []*indexerevents.UpdatePerpetualEventV3 for _, event := range block.Events { if event.Subtype != indexerevents.SubtypeUpdatePerpetual { continue } if _, ok := event.OrderingWithinBlock.(*indexer_manager.IndexerTendermintEvent_TransactionIndex); ok { - var updatePerpetualEvent indexerevents.UpdatePerpetualEventV2 + var updatePerpetualEvent indexerevents.UpdatePerpetualEventV3 err := proto.Unmarshal(event.DataBytes, &updatePerpetualEvent) if err != nil { panic(err) diff --git a/protocol/x/perpetuals/keeper/perpetual_test.go b/protocol/x/perpetuals/keeper/perpetual_test.go index 851e5e0cbd..306b462f6b 100644 --- a/protocol/x/perpetuals/keeper/perpetual_test.go +++ b/protocol/x/perpetuals/keeper/perpetual_test.go @@ -42,7 +42,7 @@ func TestModifyPerpetual_Success(t *testing.T) { // Create liquidity tiers and perpetuals, perps := keepertest.CreateLiquidityTiersAndNPerpetuals(t, pc.Ctx, pc.PerpetualsKeeper, pc.PricesKeeper, 100) numMarkets := keepertest.GetNumMarkets(t, pc.Ctx, pc.PricesKeeper) - expectedIndexerEvents := make([]*indexerevents.UpdatePerpetualEventV2, len(perps)) + expectedIndexerEvents := make([]*indexerevents.UpdatePerpetualEventV3, len(perps)) for i, item := range perps { // Modify each field arbitrarily and // verify the fields were modified in state. @@ -61,7 +61,7 @@ func TestModifyPerpetual_Success(t *testing.T) { require.NoError(t, err) // Record the indexer event expected to emit from above `ModifyPerpetual`. - expectedIndexerEvents[i] = &indexerevents.UpdatePerpetualEventV2{ + expectedIndexerEvents[i] = &indexerevents.UpdatePerpetualEventV3{ Id: item.Params.Id, Ticker: ticker, MarketId: marketId, @@ -115,15 +115,15 @@ func TestModifyPerpetual_Success(t *testing.T) { func getUpdatePerpetualEventsFromIndexerBlock( ctx sdk.Context, perpetualsKeeper *keeper.Keeper, -) []*indexerevents.UpdatePerpetualEventV2 { +) []*indexerevents.UpdatePerpetualEventV3 { block := perpetualsKeeper.GetIndexerEventManager().ProduceBlock(ctx) - var updatePerpetualEvents []*indexerevents.UpdatePerpetualEventV2 + var updatePerpetualEvents []*indexerevents.UpdatePerpetualEventV3 for _, event := range block.Events { if event.Subtype != indexerevents.SubtypeUpdatePerpetual { continue } if _, ok := event.OrderingWithinBlock.(*indexer_manager.IndexerTendermintEvent_TransactionIndex); ok { - var updatePerpetualEvent indexerevents.UpdatePerpetualEventV2 + var updatePerpetualEvent indexerevents.UpdatePerpetualEventV3 err := proto.Unmarshal(event.DataBytes, &updatePerpetualEvent) if err != nil { panic(err)