@drift-labs/sdk 2.0.12 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -245,9 +245,10 @@ describe('DLOB Tests', () => {
245
245
  );
246
246
  const vAsk = new BN(11);
247
247
  const vBid = new BN(10);
248
+ const slot = 12;
248
249
  const oracle = {
249
250
  price: vBid.add(vAsk).div(new BN(2)),
250
- slot: new BN(12),
251
+ slot: new BN(slot),
251
252
  confidence: new BN(1),
252
253
  hasSufficientNumberOfDataPoints: true,
253
254
  };
@@ -258,7 +259,7 @@ describe('DLOB Tests', () => {
258
259
  for (const _ask of dlob.getAsks(
259
260
  market.marketIndex,
260
261
  vAsk,
261
- 0,
262
+ slot,
262
263
  MarketType.PERP,
263
264
  oracle
264
265
  )) {
@@ -387,7 +388,7 @@ describe('DLOB Tests', () => {
387
388
  const bids = dlob.getBids(
388
389
  marketIndex,
389
390
  undefined,
390
- 0,
391
+ slot,
391
392
  MarketType.PERP,
392
393
  oracle
393
394
  );
@@ -525,16 +526,15 @@ describe('DLOB Perp Tests', () => {
525
526
  // ascending order
526
527
  return a.expectedIdx - b.expectedIdx;
527
528
  });
528
- const bids = dlob.getBids(marketIndex, vBid, slot, MarketType.PERP, oracle);
529
-
530
- console.log('The Book Bids:');
531
- const gotBids: Array<DLOBNode> = [];
529
+ const allBids = dlob.getBids(
530
+ marketIndex,
531
+ vBid,
532
+ slot,
533
+ MarketType.PERP,
534
+ oracle
535
+ );
532
536
  let countBids = 0;
533
- for (const bid of bids) {
534
- gotBids.push(bid);
535
- printOrderNode(bid, oracle, slot);
536
- }
537
- for (const bid of gotBids) {
537
+ for (const bid of allBids) {
538
538
  expect(bid.isVammNode(), `expected vAMM node`).to.be.eq(
539
539
  expectedTestCase[countBids].isVamm
540
540
  );
@@ -552,8 +552,61 @@ describe('DLOB Perp Tests', () => {
552
552
  );
553
553
  countBids++;
554
554
  }
555
-
556
555
  expect(countBids).to.equal(testCases.length);
556
+
557
+ const marketBids = dlob.getMarketBids(marketIndex, MarketType.PERP);
558
+ countBids = 0;
559
+ for (const bid of marketBids) {
560
+ expect(bid.isVammNode(), `expected vAMM node`).to.be.eq(
561
+ expectedTestCase.slice(0, 3)[countBids].isVamm
562
+ );
563
+ expect(bid.order?.orderId, `expected orderId`).to.equal(
564
+ expectedTestCase.slice(0, 3)[countBids].orderId
565
+ );
566
+ expect(bid.order?.price.toNumber(), `expected price`).to.equal(
567
+ expectedTestCase.slice(0, 3)[countBids].price?.toNumber()
568
+ );
569
+ expect(bid.order?.direction, `expected order direction`).to.equal(
570
+ expectedTestCase.slice(0, 3)[countBids].direction
571
+ );
572
+ expect(bid.order?.orderType, `expected order type`).to.equal(
573
+ expectedTestCase.slice(0, 3)[countBids].orderType
574
+ );
575
+ countBids++;
576
+ }
577
+ expect(countBids).to.equal(expectedTestCase.slice(0, 3).length);
578
+
579
+ const limitBids = dlob.getLimitBids(
580
+ marketIndex,
581
+ slot,
582
+ MarketType.PERP,
583
+ oracle
584
+ );
585
+ countBids = 0;
586
+ let idx = 0;
587
+ for (const bid of limitBids) {
588
+ if (expectedTestCase.slice(3)[idx].isVamm) {
589
+ idx++;
590
+ }
591
+ expect(bid.isVammNode(), `expected vAMM node`).to.be.eq(
592
+ expectedTestCase.slice(3)[idx].isVamm
593
+ );
594
+ expect(bid.order?.orderId, `expected orderId`).to.equal(
595
+ expectedTestCase.slice(3)[idx].orderId
596
+ );
597
+ expect(bid.order?.price.toNumber(), `expected price`).to.equal(
598
+ expectedTestCase.slice(3)[idx].price?.toNumber()
599
+ );
600
+ expect(bid.order?.direction, `expected order direction`).to.equal(
601
+ expectedTestCase.slice(3)[idx].direction
602
+ );
603
+ expect(bid.order?.orderType, `expected order type`).to.equal(
604
+ expectedTestCase.slice(3)[idx].orderType
605
+ );
606
+ countBids++;
607
+ idx++;
608
+ }
609
+ expect(countBids).to.equal(expectedTestCase.slice(3).length - 1); // subtract one since test case 5 is vAMM node
557
610
  });
558
611
 
559
612
  it('Test proper bids on multiple markets', () => {
@@ -826,20 +879,10 @@ describe('DLOB Perp Tests', () => {
826
879
  // ascending order
827
880
  return a.expectedIdx - b.expectedIdx;
828
881
  });
829
- const asks = dlob.getAsks(marketIndex, vAsk, slot, MarketType.PERP, oracle);
830
882
 
831
- console.log('The Book Asks:');
883
+ const asks = dlob.getAsks(marketIndex, vAsk, slot, MarketType.PERP, oracle);
832
884
  let countAsks = 0;
833
885
  for (const ask of asks) {
834
- console.log(
835
- ` . vAMMNode? ${ask.isVammNode()}, ${JSON.stringify(
836
- ask.order?.orderType
837
- )} , ${ask.order?.orderId.toString()} , vammTestgetPRice: ${ask.getPrice(
838
- oracle,
839
- slot
840
- )}, price: ${ask.order?.price.toString()}, quantity: ${ask.order?.baseAssetAmountFilled.toString()}/${ask.order?.baseAssetAmount.toString()}`
841
- );
842
-
843
886
  expect(ask.isVammNode()).to.be.eq(expectedTestCase[countAsks].isVamm);
844
887
  expect(ask.order?.orderId).to.equal(expectedTestCase[countAsks].orderId);
845
888
  expect(ask.order?.price.toNumber()).to.equal(
@@ -853,8 +896,59 @@ describe('DLOB Perp Tests', () => {
853
896
  );
854
897
  countAsks++;
855
898
  }
856
-
857
899
  expect(countAsks).to.equal(testCases.length);
900
+
901
+ const marketAsks = dlob.getMarketAsks(marketIndex, MarketType.PERP);
902
+ countAsks = 0;
903
+ for (const ask of marketAsks) {
904
+ expect(ask.isVammNode()).to.be.eq(
905
+ expectedTestCase.slice(0, 3)[countAsks].isVamm
906
+ );
907
+ expect(ask.order?.orderId).to.equal(
908
+ expectedTestCase.slice(0, 3)[countAsks].orderId
909
+ );
910
+ expect(ask.order?.price.toNumber()).to.equal(
911
+ expectedTestCase.slice(0, 3)[countAsks].price?.toNumber()
912
+ );
913
+ expect(ask.order?.direction).to.equal(
914
+ expectedTestCase.slice(0, 3)[countAsks].direction
915
+ );
916
+ expect(ask.order?.orderType).to.equal(
917
+ expectedTestCase.slice(0, 3)[countAsks].orderType
918
+ );
919
+ countAsks++;
920
+ }
921
+ expect(countAsks).to.equal(expectedTestCase.slice(0, 3).length);
922
+
923
+ const limitAsks = dlob.getLimitAsks(
924
+ marketIndex,
925
+ slot,
926
+ MarketType.PERP,
927
+ oracle
928
+ );
929
+ countAsks = 0;
930
+ let idx = 0;
931
+ for (const ask of limitAsks) {
932
+ if (expectedTestCase.slice(3)[idx].isVamm) {
933
+ idx++;
934
+ }
935
+ expect(ask.isVammNode()).to.be.eq(expectedTestCase.slice(3)[idx].isVamm);
936
+ expect(ask.order?.orderId).to.equal(
937
+ expectedTestCase.slice(3)[idx].orderId
938
+ );
939
+ expect(ask.order?.price.toNumber()).to.equal(
940
+ expectedTestCase.slice(3)[idx].price?.toNumber()
941
+ );
942
+ expect(ask.order?.direction).to.equal(
943
+ expectedTestCase.slice(3)[idx].direction
944
+ );
945
+ expect(ask.order?.orderType).to.equal(
946
+ expectedTestCase.slice(3)[idx].orderType
947
+ );
948
+ countAsks++;
949
+ idx++;
950
+ }
951
+ expect(countAsks).to.equal(expectedTestCase.slice(3).length - 1); // subtract one since test case includes vAMM node
858
952
  });
859
953
 
860
954
  it('Test insert market orders', () => {
@@ -940,6 +1034,7 @@ describe('DLOB Perp Tests', () => {
940
1034
  expect(asks).to.equal(4); // vamm ask + 3 orders
941
1035
 
942
1036
  let bids = 0;
1037
+ const expectedBidOrderIds = [1, 2, 3];
943
1038
  for (const bid of dlob.getBids(
944
1039
  marketIndex,
945
1040
  vBid,
@@ -947,17 +1042,15 @@ describe('DLOB Perp Tests', () => {
947
1042
  MarketType.PERP,
948
1043
  oracle
949
1044
  )) {
950
- if (bids === 0) {
951
- // vamm node
952
- expect(bid.order).to.equal(undefined);
953
- } else {
954
- // market orders
955
- expect(getVariant(bid.order?.status)).to.equal('open');
956
- expect(getVariant(bid.order?.orderType)).to.equal('market');
957
- expect(getVariant(bid.order?.direction)).to.equal('long');
958
- expect(bid.order?.orderId).to.equal(bids);
959
- }
960
1045
  bids++;
1046
+ if (bid.isVammNode()) {
1047
+ continue;
1048
+ }
1049
+ // market orders
1050
+ expect(getVariant(bid.order?.status)).to.equal('open');
1051
+ expect(getVariant(bid.order?.orderType)).to.equal('market');
1052
+ expect(getVariant(bid.order?.direction)).to.equal('long');
1053
+ expect(bid.order?.orderId).to.equal(expectedBidOrderIds[bids - 1]);
961
1054
  }
962
1055
  expect(bids).to.equal(4); // vamm bid + 3 orders
963
1056
  });
@@ -1405,7 +1498,7 @@ describe('DLOB Perp Tests', () => {
1405
1498
  );
1406
1499
 
1407
1500
  // should have no crossing orders
1408
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
1501
+ const nodesToFillBefore = dlob.findLimitOrderNodesToFill(
1409
1502
  marketIndex,
1410
1503
  12, // auction over
1411
1504
  MarketType.PERP,
@@ -1414,7 +1507,10 @@ describe('DLOB Perp Tests', () => {
1414
1507
  slot: new BN(12),
1415
1508
  confidence: new BN(1),
1416
1509
  hasSufficientNumberOfDataPoints: true,
1417
- }
1510
+ },
1511
+ false,
1512
+ undefined,
1513
+ undefined
1418
1514
  );
1419
1515
  expect(nodesToFillBefore.length).to.equal(0);
1420
1516
 
@@ -1446,9 +1542,12 @@ describe('DLOB Perp Tests', () => {
1446
1542
  vAsk
1447
1543
  );
1448
1544
 
1449
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
1545
+ const nodesToFillAfter = dlob.findNodesToFill(
1450
1546
  marketIndex,
1547
+ undefined,
1548
+ undefined,
1451
1549
  12, // auction over
1550
+ Date.now(),
1452
1551
  MarketType.PERP,
1453
1552
  {
1454
1553
  price: vBid.add(vAsk).div(new BN(2)),
@@ -1544,7 +1643,7 @@ describe('DLOB Perp Tests', () => {
1544
1643
  const endSlot = 12;
1545
1644
 
1546
1645
  // should have no crossing orders
1547
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
1646
+ const nodesToFillBefore = dlob.findLimitOrderNodesToFill(
1548
1647
  marketIndex,
1549
1648
  endSlot,
1550
1649
  MarketType.PERP,
@@ -1553,7 +1652,10 @@ describe('DLOB Perp Tests', () => {
1553
1652
  slot: new BN(endSlot),
1554
1653
  confidence: new BN(1),
1555
1654
  hasSufficientNumberOfDataPoints: true,
1556
- }
1655
+ },
1656
+ false,
1657
+ undefined,
1658
+ undefined
1557
1659
  );
1558
1660
  expect(nodesToFillBefore.length).to.equal(0);
1559
1661
 
@@ -1572,9 +1674,12 @@ describe('DLOB Perp Tests', () => {
1572
1674
  vAsk
1573
1675
  );
1574
1676
 
1575
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
1677
+ const nodesToFillAfter = dlob.findNodesToFill(
1576
1678
  marketIndex,
1679
+ undefined,
1680
+ undefined,
1577
1681
  endSlot,
1682
+ Date.now(),
1578
1683
  MarketType.PERP,
1579
1684
  {
1580
1685
  price: vBid.add(vAsk).div(new BN(2)),
@@ -1689,10 +1794,12 @@ describe('DLOB Perp Tests', () => {
1689
1794
  vAsk
1690
1795
  );
1691
1796
 
1692
- // should have no crossing orders
1693
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
1797
+ const nodesToFillBefore = dlob.findNodesToFill(
1694
1798
  marketIndex,
1695
- 12, // auction over
1799
+ undefined,
1800
+ undefined,
1801
+ slot, // auction over
1802
+ Date.now(),
1696
1803
  MarketType.PERP,
1697
1804
  oracle
1698
1805
  );
@@ -1726,9 +1833,12 @@ describe('DLOB Perp Tests', () => {
1726
1833
  vAsk
1727
1834
  );
1728
1835
 
1729
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
1836
+ const nodesToFillAfter = dlob.findNodesToFill(
1730
1837
  marketIndex,
1838
+ undefined,
1839
+ undefined,
1731
1840
  slot, // auction over
1841
+ Date.now(),
1732
1842
  MarketType.PERP,
1733
1843
  oracle
1734
1844
  );
@@ -2021,7 +2131,6 @@ describe('DLOB Perp Tests', () => {
2021
2131
  console.log(`nodesToTriggeR: ${nodesToTrigger.length}`);
2022
2132
  for (const [idx, n] of nodesToTrigger.entries()) {
2023
2133
  expect(n.node.order?.orderId).to.equal(orderIdsToTrigger[idx]);
2024
- console.log(`nodeToTrigger: ${n.node.order?.orderId.toString()}`);
2025
2134
  }
2026
2135
  });
2027
2136
 
@@ -2397,11 +2506,14 @@ describe('DLOB Perp Tests', () => {
2397
2506
  // should have no crossing orders
2398
2507
  const auctionOverSlot = slot * 10;
2399
2508
  const auctionOverTs = ts * 10;
2400
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
2509
+ const nodesToFillBefore = dlob.findLimitOrderNodesToFill(
2401
2510
  marketIndex,
2402
2511
  auctionOverSlot, // auction over
2403
2512
  MarketType.PERP,
2404
- oracle
2513
+ oracle,
2514
+ false,
2515
+ undefined,
2516
+ undefined
2405
2517
  );
2406
2518
  expect(nodesToFillBefore.length).to.equal(0);
2407
2519
 
@@ -2551,9 +2663,12 @@ describe('DLOB Perp Tests', () => {
2551
2663
  );
2552
2664
 
2553
2665
  // should have no crossing orders
2554
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
2666
+ const nodesToFillBefore = dlob.findNodesToFill(
2555
2667
  marketIndex,
2668
+ undefined,
2669
+ undefined,
2556
2670
  slot,
2671
+ Date.now(),
2557
2672
  MarketType.PERP,
2558
2673
  oracle
2559
2674
  );
@@ -2587,9 +2702,12 @@ describe('DLOB Perp Tests', () => {
2587
2702
  vAsk
2588
2703
  );
2589
2704
 
2590
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
2705
+ const nodesToFillAfter = dlob.findNodesToFill(
2591
2706
  marketIndex,
2707
+ undefined,
2708
+ undefined,
2592
2709
  slot, // auction in progress
2710
+ Date.now(),
2593
2711
  MarketType.PERP,
2594
2712
  oracle
2595
2713
  );
@@ -3127,6 +3245,104 @@ describe('DLOB Perp Tests', () => {
3127
3245
 
3128
3246
  expect(nodesToFillBefore.length).to.equal(0);
3129
3247
  });
3248
+
3249
+ it('Test fills 0 price market order with limit orders better than vAMM', () => {
3250
+ const vAsk = new BN(20).mul(PRICE_PRECISION);
3251
+ const vBid = new BN(5).mul(PRICE_PRECISION);
3252
+
3253
+ const mockUserMap = new MockUserMap();
3254
+ const user0 = Keypair.generate();
3255
+ const user0Auth = Keypair.generate();
3256
+ const user1 = Keypair.generate();
3257
+ const user1Auth = Keypair.generate();
3258
+ mockUserMap.addUserAccountAuthority(user0.publicKey, user0Auth.publicKey);
3259
+ mockUserMap.addUserAccountAuthority(user1.publicKey, user1Auth.publicKey);
3260
+
3261
+ const dlob = new DLOB(
3262
+ mockPerpMarkets,
3263
+ mockSpotMarkets,
3264
+ mockStateAccount,
3265
+ mockUserMap,
3266
+ false
3267
+ );
3268
+ const marketIndex = 0;
3269
+
3270
+ const slot = 12;
3271
+ const ts = 12;
3272
+ const oracle = {
3273
+ price: vBid.add(vAsk).div(new BN(2)),
3274
+ slot: new BN(slot),
3275
+ confidence: new BN(1),
3276
+ hasSufficientNumberOfDataPoints: true,
3277
+ };
3278
+
3279
+ // resting bid above vBid (better)
3280
+ insertOrderToDLOB(
3281
+ dlob,
3282
+ user1.publicKey,
3283
+ OrderType.LIMIT,
3284
+ MarketType.PERP,
3285
+ 2, // orderId
3286
+ marketIndex,
3287
+ new BN(15).mul(PRICE_PRECISION), // price,
3288
+ new BN(10).mul(BASE_PRECISION), // quantity
3289
+ PositionDirection.LONG,
3290
+ vBid,
3291
+ vAsk,
3292
+ new BN(slot),
3293
+ new BN(200)
3294
+ );
3295
+
3296
+ // market sell into the resting bid
3297
+ insertOrderToDLOB(
3298
+ dlob,
3299
+ user0.publicKey,
3300
+ OrderType.MARKET,
3301
+ MarketType.PERP,
3302
+ 3, // orderId
3303
+ marketIndex,
3304
+ new BN(0), // price
3305
+ new BN(1).mul(BASE_PRECISION), // quantity
3306
+ PositionDirection.SHORT,
3307
+ vAsk,
3308
+ vBid,
3309
+ new BN(slot),
3310
+ new BN(200)
3311
+ );
3312
+
3313
+ console.log(`Book state before taker auction ends:`);
3314
+ printBookState(dlob, marketIndex, vBid, vAsk, slot, oracle);
3315
+
3316
+ console.log(``);
3317
+ const auctionEndSlot = slot * 2;
3318
+ console.log(`Book state after taker auction ends:`);
3319
+ printBookState(dlob, marketIndex, vBid, vAsk, auctionEndSlot, oracle);
3320
+
3321
+ const nodesToFillBefore = dlob.findNodesToFill(
3322
+ marketIndex,
3323
+ vBid,
3324
+ vAsk,
3325
+ auctionEndSlot, // auction ends
3326
+ ts,
3327
+ MarketType.PERP,
3328
+ oracle
3329
+ );
3330
+ console.log(`Nodes to fill: ${nodesToFillBefore.length}`);
3331
+ for (const n of nodesToFillBefore) {
3332
+ printCrossedNodes(n, slot);
3333
+ }
3334
+ expect(nodesToFillBefore.length).to.equal(1);
3335
+
3336
+ // first order is maker, second is taker
3337
+ expect(
3338
+ nodesToFillBefore[0].node.order?.orderId,
3339
+ 'wrong taker orderId'
3340
+ ).to.equal(3);
3341
+ expect(
3342
+ nodesToFillBefore[0].makerNode?.order?.orderId,
3343
+ 'wrong maker orderId'
3344
+ ).to.equal(2);
3345
+ });
3130
3346
  });
3131
3347
 
3132
3348
  describe('DLOB Spot Tests', () => {
@@ -3152,35 +3368,35 @@ describe('DLOB Spot Tests', () => {
3152
3368
  };
3153
3369
  const testCases = [
3154
3370
  {
3155
- expectedIdx: 3,
3371
+ expectedIdx: 0,
3156
3372
  orderId: 5,
3157
3373
  price: new BN(0), // will calc 108
3158
3374
  direction: PositionDirection.LONG,
3159
3375
  orderType: OrderType.MARKET,
3160
3376
  },
3161
3377
  {
3162
- expectedIdx: 4,
3378
+ expectedIdx: 1,
3163
3379
  orderId: 6,
3164
3380
  price: new BN(0), // will calc 108
3165
3381
  direction: PositionDirection.LONG,
3166
3382
  orderType: OrderType.MARKET,
3167
3383
  },
3168
3384
  {
3169
- expectedIdx: 5,
3385
+ expectedIdx: 2,
3170
3386
  orderId: 7,
3171
3387
  price: new BN(0), // will calc 108
3172
3388
  direction: PositionDirection.LONG,
3173
3389
  orderType: OrderType.MARKET,
3174
3390
  },
3175
3391
  {
3176
- expectedIdx: 0,
3392
+ expectedIdx: 4,
3177
3393
  orderId: 1,
3178
3394
  price: new BN(110),
3179
3395
  direction: PositionDirection.LONG,
3180
3396
  orderType: OrderType.LIMIT,
3181
3397
  },
3182
3398
  {
3183
- expectedIdx: 1,
3399
+ expectedIdx: 5,
3184
3400
  orderId: 2,
3185
3401
  price: new BN(109),
3186
3402
  direction: PositionDirection.LONG,
@@ -3873,8 +4089,11 @@ describe('DLOB Spot Tests', () => {
3873
4089
  );
3874
4090
 
3875
4091
  // should have no crossing orders
3876
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
4092
+ const nodesToFillBefore = dlob.findNodesToFill(
3877
4093
  marketIndex,
4094
+ undefined,
4095
+ undefined,
4096
+ Date.now(),
3878
4097
  12, // auction over
3879
4098
  MarketType.SPOT,
3880
4099
  {
@@ -3914,9 +4133,12 @@ describe('DLOB Spot Tests', () => {
3914
4133
  vAsk
3915
4134
  );
3916
4135
 
3917
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
4136
+ const nodesToFillAfter = dlob.findNodesToFill(
3918
4137
  marketIndex,
4138
+ undefined,
4139
+ undefined,
3919
4140
  12, // auction over
4141
+ Date.now(),
3920
4142
  MarketType.SPOT,
3921
4143
  {
3922
4144
  price: vBid.add(vAsk).div(new BN(2)),
@@ -4011,9 +4233,12 @@ describe('DLOB Spot Tests', () => {
4011
4233
  );
4012
4234
 
4013
4235
  // should have no crossing orders
4014
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
4236
+ const nodesToFillBefore = dlob.findNodesToFill(
4015
4237
  marketIndex,
4238
+ undefined,
4239
+ undefined,
4016
4240
  12, // auction over
4241
+ Date.now(),
4017
4242
  MarketType.SPOT,
4018
4243
  {
4019
4244
  price: vBid.add(vAsk).div(new BN(2)),
@@ -4039,9 +4264,12 @@ describe('DLOB Spot Tests', () => {
4039
4264
  vAsk
4040
4265
  );
4041
4266
 
4042
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
4267
+ const nodesToFillAfter = dlob.findNodesToFill(
4043
4268
  marketIndex,
4269
+ undefined,
4270
+ undefined,
4044
4271
  12, // auction over
4272
+ Date.now(),
4045
4273
  MarketType.SPOT,
4046
4274
  {
4047
4275
  price: vBid.add(vAsk).div(new BN(2)),
@@ -4147,9 +4375,12 @@ describe('DLOB Spot Tests', () => {
4147
4375
  );
4148
4376
 
4149
4377
  // should have no crossing orders
4150
- const nodesToFillBefore = dlob.findCrossingNodesToFill(
4378
+ const nodesToFillBefore = dlob.findNodesToFill(
4151
4379
  marketIndex,
4380
+ undefined,
4381
+ undefined,
4152
4382
  12, // auction over
4383
+ Date.now(),
4153
4384
  MarketType.SPOT,
4154
4385
  oracle
4155
4386
  );
@@ -4183,9 +4414,12 @@ describe('DLOB Spot Tests', () => {
4183
4414
  vAsk
4184
4415
  );
4185
4416
 
4186
- const nodesToFillAfter = dlob.findCrossingNodesToFill(
4417
+ const nodesToFillAfter = dlob.findNodesToFill(
4187
4418
  marketIndex,
4419
+ undefined,
4420
+ undefined,
4188
4421
  slot, // auction over
4422
+ Date.now(),
4189
4423
  MarketType.SPOT,
4190
4424
  oracle
4191
4425
  );
@@ -4477,10 +4711,8 @@ describe('DLOB Spot Tests', () => {
4477
4711
  oracle.price,
4478
4712
  MarketType.SPOT
4479
4713
  );
4480
- console.log(`nodesToTriggeR: ${nodesToTrigger.length}`);
4481
4714
  for (const [idx, n] of nodesToTrigger.entries()) {
4482
4715
  expect(n.node.order?.orderId).to.equal(orderIdsToTrigger[idx]);
4483
- console.log(`nodeToTrigger: ${n.node.order?.orderId}`);
4484
4716
  }
4485
4717
  });
4486
4718