diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c824cb845..4d681f14ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ - [8862](https://github.com/vegaprotocol/vega/issues/8862) - Fix settlement via governance - [8854](https://github.com/vegaprotocol/vega/issues/8854) - Add liquidity `v2` snapshots to the list of providers - [8772](https://github.com/vegaprotocol/vega/issues/8772) - Checkpoint panic on successor markets. +- [8962](https://github.com/vegaprotocol/vega/issues/8962) - Refreshed pegged iceberg orders remain tracked as pegged orders. - [8837](https://github.com/vegaprotocol/vega/issues/8837) - Remove successor entries from snapshot if they will be removed next tick. - [8868](https://github.com/vegaprotocol/vega/issues/8868) - Fix `oracle_specs` table null value error. - [8878](https://github.com/vegaprotocol/vega/issues/8878) - Fix amend to consider market decimals when checking for sufficient funds. diff --git a/core/matching/iceberg_orders_test.go b/core/matching/iceberg_orders_test.go index 190e9ed7ba..56850442a3 100644 --- a/core/matching/iceberg_orders_test.go +++ b/core/matching/iceberg_orders_test.go @@ -23,6 +23,35 @@ import ( "github.com/stretchr/testify/require" ) +func submitPeggedIcebergOrder(t *testing.T, book *tstOB, size, peak, minPeak uint64) (*types.Order, *types.OrderConfirmation) { + t.Helper() + o := &types.Order{ + ID: vgcrypto.RandomHash(), + Status: types.OrderStatusActive, + MarketID: book.marketID, + Party: "A", + Side: types.SideBuy, + Price: num.NewUint(100), + OriginalPrice: num.NewUint(100), + Size: size, + Remaining: size, + TimeInForce: types.OrderTimeInForceGTT, + Type: types.OrderTypeLimit, + ExpiresAt: 10, + PeggedOrder: &types.PeggedOrder{ + Reference: types.PeggedReferenceMid, + Offset: num.UintOne(), + }, + IcebergOrder: &types.IcebergOrder{ + PeakSize: peak, + MinimumVisibleSize: minPeak, + }, + } + confirm, err := book.SubmitOrder(o) + require.NoError(t, err) + return o, confirm +} + func submitIcebergOrder(t *testing.T, book *tstOB, size, peak, minPeak uint64, addToBook bool) (*types.Order, *types.OrderConfirmation) { t.Helper() o := &types.Order{ @@ -569,3 +598,24 @@ func TestIcebergWashTradeAggressiveIcebergPartialFill(t *testing.T) { assert.Equal(t, 1, len(confirm.Trades)) assert.Equal(t, uint64(10), book.getTotalSellVolume()) } + +func TestRefreshedPeggedIcebergStillPegged(t *testing.T) { + market := "testMarket" + book := getTestOrderBook(t, market) + defer book.Finish() + + // create a pegged iceberg order + iceberg, _ := submitPeggedIcebergOrder(t, book, 100, 4, 2) + + // check it is returned as pegged + pegged := book.GetActivePeggedOrderIDs() + assert.Equal(t, iceberg.ID, pegged[0]) + + // submit an order that will trade a cause a refresh + _, confirm := submitCrossedOrder(t, book, 3) + assert.Equal(t, 1, len(confirm.Trades)) + + // check it is still returned as pegged + pegged = book.GetActivePeggedOrderIDs() + assert.Equal(t, iceberg.ID, pegged[0]) +} diff --git a/core/matching/orderbook.go b/core/matching/orderbook.go index 02dfb80d77..688257ad4d 100644 --- a/core/matching/orderbook.go +++ b/core/matching/orderbook.go @@ -1161,6 +1161,7 @@ func (b *OrderBook) icebergRefresh(o *types.Order) { // put it to the back of the line b.getSide(o.Side).addOrder(o) + b.add(o) } // remove removes the given order from all the lookup map.