Skip to content

Commit

Permalink
Merge pull request #8965 from vegaprotocol/8962-pegged-iceberg-fix
Browse files Browse the repository at this point in the history
8962 pegged iceberg fix
  • Loading branch information
jeremyletang authored Aug 3, 2023
2 parents 4d10ca8 + b4c125b commit b13e4eb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
50 changes: 50 additions & 0 deletions core/matching/iceberg_orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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])
}
1 change: 1 addition & 0 deletions core/matching/orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b13e4eb

Please sign in to comment.