diff --git a/core/execution/future/market.go b/core/execution/future/market.go index bc59879eec8..c4e19a28b23 100644 --- a/core/execution/future/market.go +++ b/core/execution/future/market.go @@ -670,6 +670,8 @@ func (m *Market) Update(ctx context.Context, config *types.Market, oracleEngine if tickSizeChanged { peggedOrders := m.matching.GetActivePeggedOrderIDs() peggedOrders = append(peggedOrders, m.peggedOrders.GetParkedIDs()...) + + tickSizeInAsset, _ := num.UintFromDecimal(m.mkt.TickSize.ToDecimal().Mul(m.priceFactor)) for _, po := range peggedOrders { order, err := m.matching.GetOrderByID(po) if err != nil { @@ -678,7 +680,9 @@ func (m *Market) Update(ctx context.Context, config *types.Market, oracleEngine continue } } - if !num.UintZero().Mod(order.PeggedOrder.Offset, m.mkt.TickSize).IsZero() { + offsetInAsset, _ := num.UintFromDecimal(order.PeggedOrder.Offset.ToDecimal().Mul(m.priceFactor)) + if !num.UintZero().Mod(order.PeggedOrder.Offset, m.mkt.TickSize).IsZero() || + (order.PeggedOrder.Reference == types.PeggedReferenceMid && offsetInAsset.IsZero() && tickSizeInAsset.IsZero()) { m.cancelOrder(ctx, order.Party, order.ID) } } diff --git a/core/execution/spot/market.go b/core/execution/spot/market.go index 33442260d29..b3d49de3e55 100644 --- a/core/execution/spot/market.go +++ b/core/execution/spot/market.go @@ -297,6 +297,7 @@ func (m *Market) Update(ctx context.Context, config *types.Market) error { m.updateLiquidityFee(ctx) if tickSizeChanged { + tickSizeInAsset, _ := num.UintFromDecimal(m.mkt.TickSize.ToDecimal().Mul(m.priceFactor)) peggedOrders := m.matching.GetActivePeggedOrderIDs() peggedOrders = append(peggedOrders, m.peggedOrders.GetParkedIDs()...) for _, po := range peggedOrders { @@ -307,7 +308,9 @@ func (m *Market) Update(ctx context.Context, config *types.Market) error { continue } } - if !num.UintZero().Mod(order.PeggedOrder.Offset, m.mkt.TickSize).IsZero() { + offsetInAsset, _ := num.UintFromDecimal(order.PeggedOrder.Offset.ToDecimal().Mul(m.priceFactor)) + if !num.UintZero().Mod(order.PeggedOrder.Offset, m.mkt.TickSize).IsZero() || + (order.PeggedOrder.Reference == types.PeggedReferenceMid && offsetInAsset.IsZero() && tickSizeInAsset.IsZero()) { m.cancelOrder(ctx, order.Party, order.ID) } }