From b6e5e4d5747ef924cac5b65dc5cb2d34d2d4e22f Mon Sep 17 00:00:00 2001 From: 0xahzam Date: Sat, 7 Feb 2026 15:24:33 +0530 Subject: [PATCH 1/3] remove same slot restriction for swift limit fills --- programs/drift/src/math/matching.rs | 6 +-- programs/drift/src/math/matching/tests.rs | 49 +++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/programs/drift/src/math/matching.rs b/programs/drift/src/math/matching.rs index ece67124de..f9655e6168 100644 --- a/programs/drift/src/math/matching.rs +++ b/programs/drift/src/math/matching.rs @@ -17,10 +17,8 @@ pub fn is_maker_for_taker( taker_order: &Order, slot: u64, ) -> DriftResult { - // Maker and taker order not allowed to match if both were placed in the current slot - if slot == maker_order.slot && slot == taker_order.slot && !maker_order.is_jit_maker() { - return Ok(false); - }; + // Self match protection handled upstream via maker_key != taker_key check. + // Removed slot equality restriction to enable same slot fills for swift limit orders. // taker cant be post only and maker must be resting limit order if taker_order.post_only || !maker_order.is_resting_limit_order(slot)? { diff --git a/programs/drift/src/math/matching/tests.rs b/programs/drift/src/math/matching/tests.rs index be22f480c7..9a0fb1716d 100644 --- a/programs/drift/src/math/matching/tests.rs +++ b/programs/drift/src/math/matching/tests.rs @@ -177,6 +177,55 @@ mod is_maker_for_taker { assert_eq!(is_maker_for_taker(&maker, &taker, slot).unwrap(), true); } + + #[test] + fn same_slot_maker_taker_non_resting() { + let slot = 0; + + // Taker market order + let taker = Order { + post_only: false, + order_type: OrderType::Market, + slot: 0, + ..Default::default() + }; + + // Maker resting with 0 auction + let maker = Order { + post_only: false, + order_type: OrderType::Limit, + slot: 0, + auction_duration: 0, + ..Default::default() + }; + + assert_eq!(is_maker_for_taker(&maker, &taker, slot).unwrap(), true); + } + + #[test] + fn same_slot_maker_taker_both_resting() { + let slot = 20; + + // Resting taker order + let taker = Order { + post_only: false, + order_type: OrderType::Limit, + slot: 10, + auction_duration: 5, + ..Default::default() + }; + + // Resting maker order (older) + let maker = Order { + post_only: false, + order_type: OrderType::Limit, + slot: 5, + auction_duration: 2, + ..Default::default() + }; + + assert_eq!(is_maker_for_taker(&maker, &taker, slot).unwrap(), true); + } } #[test] From 6e1472a05a3b65feb41a48cb0c314a51f71e6753 Mon Sep 17 00:00:00 2001 From: 0xahzam Date: Sun, 8 Feb 2026 00:21:44 +0530 Subject: [PATCH 2/3] update comment --- programs/drift/src/math/matching.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/drift/src/math/matching.rs b/programs/drift/src/math/matching.rs index f9655e6168..053b9e2159 100644 --- a/programs/drift/src/math/matching.rs +++ b/programs/drift/src/math/matching.rs @@ -18,7 +18,7 @@ pub fn is_maker_for_taker( slot: u64, ) -> DriftResult { // Self match protection handled upstream via maker_key != taker_key check. - // Removed slot equality restriction to enable same slot fills for swift limit orders. + // Removed slot equality restriction to enable same slot fills. // taker cant be post only and maker must be resting limit order if taker_order.post_only || !maker_order.is_resting_limit_order(slot)? { From 2caa09e9c259cec46b072127d697fc3eba8280c5 Mon Sep 17 00:00:00 2001 From: 0xahzam Date: Mon, 9 Feb 2026 23:48:15 +0530 Subject: [PATCH 3/3] add changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa0327d5dd..db2f00578c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- program: remove same slot matching restriction [#2104](https://github.com/drift-labs/protocol-v2/pull/2104) + ### Fixes ### Breaking @@ -47,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixes ### Breaking + - sdk: `channelOptions` in the GrpcConfigs type has been updated to work with new grpc lib ## [2.153.0] - 2025-12-30 @@ -104,11 +107,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixes ### Breaking + - program: add DepositRecord::spot_balance_after [#2034](https://github.com/drift-labs/protocol-v2/pull/2034) ## [2.149.0] - 2025-11-19 ### Features + - sdk: allow deposit from external authority directly to drift account ### Fixes @@ -171,7 +176,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features -- program: use-5min-for-target-expiry-price ([#1967](https://github.com/drift-labs/protocol-v2/pull/1967)) +- program: use-5min-for-target-expiry-price ([#1967](https://github.com/drift-labs/protocol-v2/pull/1967)) ### Fixes