@drift-labs/sdk 2.12.0-beta.2 → 2.12.0

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.
Files changed (57) hide show
  1. package/lib/accounts/bulkAccountLoader.js +3 -3
  2. package/lib/accounts/fetch.js +2 -2
  3. package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
  4. package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
  5. package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
  6. package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
  7. package/lib/accounts/webSocketAccountSubscriber.js +1 -1
  8. package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
  9. package/lib/addresses/marketAddresses.js +1 -1
  10. package/lib/addresses/pda.js +1 -5
  11. package/lib/adminClient.js +57 -61
  12. package/lib/dlob/DLOB.d.ts +8 -8
  13. package/lib/dlob/DLOB.js +91 -84
  14. package/lib/dlob/DLOBNode.js +7 -7
  15. package/lib/dlob/NodeList.js +2 -2
  16. package/lib/driftClient.d.ts +3 -3
  17. package/lib/driftClient.js +83 -87
  18. package/lib/events/eventSubscriber.js +2 -2
  19. package/lib/events/pollingLogProvider.js +1 -1
  20. package/lib/examples/makeTradeExample.js +9 -9
  21. package/lib/factory/bigNum.js +9 -9
  22. package/lib/factory/oracleClient.js +2 -2
  23. package/lib/idl/drift.json +1 -1
  24. package/lib/index.js +1 -5
  25. package/lib/math/amm.js +23 -23
  26. package/lib/math/auction.js +6 -6
  27. package/lib/math/exchangeStatus.js +2 -2
  28. package/lib/math/funding.js +2 -2
  29. package/lib/math/margin.js +5 -5
  30. package/lib/math/market.js +12 -12
  31. package/lib/math/oracles.js +1 -1
  32. package/lib/math/orders.js +23 -23
  33. package/lib/math/position.js +5 -5
  34. package/lib/math/repeg.js +1 -1
  35. package/lib/math/spotBalance.js +7 -7
  36. package/lib/math/spotPosition.js +3 -3
  37. package/lib/math/trade.d.ts +35 -3
  38. package/lib/math/trade.js +225 -47
  39. package/lib/oracles/oracleClientCache.js +1 -1
  40. package/lib/oracles/pythClient.js +1 -1
  41. package/lib/tokenFaucet.js +1 -5
  42. package/lib/tx/retryTxSender.js +1 -1
  43. package/lib/tx/utils.d.ts +1 -1
  44. package/lib/tx/utils.js +7 -4
  45. package/lib/types.d.ts +4 -0
  46. package/lib/user.js +47 -47
  47. package/lib/userMap/userMap.js +1 -1
  48. package/lib/userMap/userStatsMap.js +3 -3
  49. package/lib/userStats.js +2 -2
  50. package/package.json +1 -1
  51. package/src/dlob/DLOB.ts +34 -26
  52. package/src/driftClient.ts +11 -4
  53. package/src/idl/drift.json +1 -1
  54. package/src/math/trade.ts +322 -16
  55. package/src/tx/utils.ts +11 -3
  56. package/src/types.ts +5 -0
  57. package/tests/dlob/test.ts +307 -38
@@ -23,7 +23,7 @@ import {
23
23
  } from '../../src';
24
24
 
25
25
  import { mockPerpMarkets, mockSpotMarkets, mockStateAccount } from './helpers';
26
- import { isVariant } from '../../lib';
26
+ import { isVariant, TWO } from '../../lib';
27
27
  import { DLOBOrdersCoder } from '../../src/dlob/DLOBOrders';
28
28
 
29
29
  function insertOrderToDLOB(
@@ -40,7 +40,8 @@ function insertOrderToDLOB(
40
40
  auctionEndPrice: BN,
41
41
  slot?: BN,
42
42
  maxTs = ZERO,
43
- oraclePriceOffset = new BN(0)
43
+ oraclePriceOffset = new BN(0),
44
+ postOnly = false
44
45
  ) {
45
46
  dlob.insertOrder(
46
47
  {
@@ -61,7 +62,7 @@ function insertOrderToDLOB(
61
62
  triggerPrice: new BN(0),
62
63
  triggerCondition: OrderTriggerCondition.ABOVE,
63
64
  existingPositionDirection: PositionDirection.LONG,
64
- postOnly: false,
65
+ postOnly,
65
66
  immediateOrCancel: false,
66
67
  oraclePriceOffset: oraclePriceOffset.toNumber(),
67
68
  auctionDuration: 10,
@@ -1509,7 +1510,11 @@ describe('DLOB Perp Tests', () => {
1509
1510
  BASE_PRECISION, // quantity
1510
1511
  PositionDirection.LONG,
1511
1512
  vBid,
1512
- vAsk
1513
+ vAsk,
1514
+ undefined,
1515
+ undefined,
1516
+ undefined,
1517
+ true
1513
1518
  );
1514
1519
  insertOrderToDLOB(
1515
1520
  dlob,
@@ -1522,7 +1527,11 @@ describe('DLOB Perp Tests', () => {
1522
1527
  BASE_PRECISION, // quantity
1523
1528
  PositionDirection.LONG,
1524
1529
  vBid,
1525
- vAsk
1530
+ vAsk,
1531
+ undefined,
1532
+ undefined,
1533
+ undefined,
1534
+ true
1526
1535
  );
1527
1536
  insertOrderToDLOB(
1528
1537
  dlob,
@@ -1535,7 +1544,11 @@ describe('DLOB Perp Tests', () => {
1535
1544
  BASE_PRECISION, // quantity
1536
1545
  PositionDirection.LONG,
1537
1546
  vBid,
1538
- vAsk
1547
+ vAsk,
1548
+ undefined,
1549
+ undefined,
1550
+ undefined,
1551
+ true
1539
1552
  );
1540
1553
 
1541
1554
  // should have no crossing orders
@@ -1638,7 +1651,11 @@ describe('DLOB Perp Tests', () => {
1638
1651
  BASE_PRECISION, // quantity
1639
1652
  PositionDirection.SHORT,
1640
1653
  vBid,
1641
- vAsk
1654
+ vAsk,
1655
+ undefined,
1656
+ undefined,
1657
+ undefined,
1658
+ true
1642
1659
  );
1643
1660
  insertOrderToDLOB(
1644
1661
  dlob,
@@ -1651,7 +1668,11 @@ describe('DLOB Perp Tests', () => {
1651
1668
  BASE_PRECISION, // quantity
1652
1669
  PositionDirection.SHORT,
1653
1670
  vBid,
1654
- vAsk
1671
+ vAsk,
1672
+ undefined,
1673
+ undefined,
1674
+ undefined,
1675
+ true
1655
1676
  );
1656
1677
  insertOrderToDLOB(
1657
1678
  dlob,
@@ -1664,7 +1685,11 @@ describe('DLOB Perp Tests', () => {
1664
1685
  BASE_PRECISION, // quantity
1665
1686
  PositionDirection.SHORT,
1666
1687
  vBid,
1667
- vAsk
1688
+ vAsk,
1689
+ undefined,
1690
+ undefined,
1691
+ undefined,
1692
+ true
1668
1693
  );
1669
1694
 
1670
1695
  // auction over
@@ -1778,7 +1803,11 @@ describe('DLOB Perp Tests', () => {
1778
1803
  BASE_PRECISION, // quantity
1779
1804
  PositionDirection.SHORT,
1780
1805
  vBid,
1781
- vAsk
1806
+ vAsk,
1807
+ undefined,
1808
+ undefined,
1809
+ undefined,
1810
+ true
1782
1811
  );
1783
1812
  insertOrderToDLOB(
1784
1813
  dlob,
@@ -1791,7 +1820,11 @@ describe('DLOB Perp Tests', () => {
1791
1820
  BASE_PRECISION, // quantity
1792
1821
  PositionDirection.SHORT,
1793
1822
  vBid,
1794
- vAsk
1823
+ vAsk,
1824
+ undefined,
1825
+ undefined,
1826
+ undefined,
1827
+ true
1795
1828
  );
1796
1829
  insertOrderToDLOB(
1797
1830
  dlob,
@@ -1804,7 +1837,11 @@ describe('DLOB Perp Tests', () => {
1804
1837
  new BN(3).mul(BASE_PRECISION), // quantity
1805
1838
  PositionDirection.SHORT,
1806
1839
  vBid,
1807
- vAsk
1840
+ vAsk,
1841
+ undefined,
1842
+ undefined,
1843
+ undefined,
1844
+ true
1808
1845
  );
1809
1846
 
1810
1847
  const nodesToFillBefore = dlob.findNodesToFill(
@@ -2255,7 +2292,8 @@ describe('DLOB Perp Tests', () => {
2255
2292
  vAsk,
2256
2293
  new BN(slot),
2257
2294
  ZERO,
2258
- new BN(1).mul(PRICE_PRECISION)
2295
+ new BN(1).mul(PRICE_PRECISION),
2296
+ true
2259
2297
  );
2260
2298
  insertOrderToDLOB(
2261
2299
  dlob,
@@ -2271,7 +2309,8 @@ describe('DLOB Perp Tests', () => {
2271
2309
  vAsk,
2272
2310
  new BN(slot),
2273
2311
  ZERO,
2274
- new BN(1).mul(PRICE_PRECISION)
2312
+ new BN(1).mul(PRICE_PRECISION),
2313
+ true
2275
2314
  );
2276
2315
  insertOrderToDLOB(
2277
2316
  dlob,
@@ -2287,7 +2326,8 @@ describe('DLOB Perp Tests', () => {
2287
2326
  vAsk,
2288
2327
  new BN(slot),
2289
2328
  ZERO,
2290
- new BN(1).mul(PRICE_PRECISION)
2329
+ new BN(1).mul(PRICE_PRECISION),
2330
+ true
2291
2331
  );
2292
2332
 
2293
2333
  // should have no crossing orders
@@ -2562,7 +2602,8 @@ describe('DLOB Perp Tests', () => {
2562
2602
  vAsk,
2563
2603
  new BN(slot),
2564
2604
  ZERO,
2565
- new BN(-4).mul(PRICE_PRECISION) // second best bid, but worse than vBid (8): 7.5
2605
+ new BN(-4).mul(PRICE_PRECISION), // second best bid, but worse than vBid (8): 7.5
2606
+ true
2566
2607
  );
2567
2608
  insertOrderToDLOB(
2568
2609
  dlob,
@@ -2578,7 +2619,8 @@ describe('DLOB Perp Tests', () => {
2578
2619
  vAsk,
2579
2620
  new BN(slot),
2580
2621
  ZERO,
2581
- new BN(-1).mul(PRICE_PRECISION) // best price: 10.5
2622
+ new BN(-1).mul(PRICE_PRECISION), // best price: 10.5
2623
+ true
2582
2624
  );
2583
2625
  insertOrderToDLOB(
2584
2626
  dlob,
@@ -2594,7 +2636,8 @@ describe('DLOB Perp Tests', () => {
2594
2636
  vAsk,
2595
2637
  new BN(slot),
2596
2638
  ZERO,
2597
- new BN(-5).mul(PRICE_PRECISION) // third best bid, worse than vBid (8): 6.5
2639
+ new BN(-5).mul(PRICE_PRECISION), // third best bid, worse than vBid (8): 6.5
2640
+ true
2598
2641
  );
2599
2642
 
2600
2643
  // should have no crossing orders
@@ -2733,7 +2776,8 @@ describe('DLOB Perp Tests', () => {
2733
2776
  vAsk,
2734
2777
  new BN(slot),
2735
2778
  ZERO,
2736
- new BN(-4).mul(PRICE_PRECISION) // second best bid, but worse than vBid (8): 7.5
2779
+ new BN(-4).mul(PRICE_PRECISION), // second best bid, but worse than vBid (8): 7.5
2780
+ true
2737
2781
  );
2738
2782
  insertOrderToDLOB(
2739
2783
  dlob,
@@ -2749,7 +2793,8 @@ describe('DLOB Perp Tests', () => {
2749
2793
  vAsk,
2750
2794
  new BN(slot),
2751
2795
  ZERO,
2752
- new BN(-1).mul(PRICE_PRECISION) // best price: 10.5
2796
+ new BN(-1).mul(PRICE_PRECISION), // best price: 10.5
2797
+ true
2753
2798
  );
2754
2799
  insertOrderToDLOB(
2755
2800
  dlob,
@@ -2765,7 +2810,8 @@ describe('DLOB Perp Tests', () => {
2765
2810
  vAsk,
2766
2811
  new BN(slot),
2767
2812
  ZERO,
2768
- new BN(-5).mul(PRICE_PRECISION) // third best bid, worse than vBid (8): 6.5
2813
+ new BN(-5).mul(PRICE_PRECISION), // third best bid, worse than vBid (8): 6.5
2814
+ true
2769
2815
  );
2770
2816
 
2771
2817
  console.log('DLOB state before fill:');
@@ -2943,7 +2989,7 @@ describe('DLOB Perp Tests', () => {
2943
2989
  expect(nodesToFillBefore.length).to.equal(0);
2944
2990
 
2945
2991
  // auction ends now
2946
- const afterAuctionSlot = 10 * slot;
2992
+ const afterAuctionSlot = 11 + slot;
2947
2993
  const afterAuctionTs = 10 * ts;
2948
2994
 
2949
2995
  const nodesToFillAfter = dlob.findNodesToFill(
@@ -3022,7 +3068,9 @@ describe('DLOB Perp Tests', () => {
3022
3068
  vAsk,
3023
3069
  vBid,
3024
3070
  new BN(slot),
3025
- new BN(200)
3071
+ new BN(200),
3072
+ undefined,
3073
+ true
3026
3074
  );
3027
3075
  // insert a buy above the vBid
3028
3076
  insertOrderToDLOB(
@@ -3037,7 +3085,7 @@ describe('DLOB Perp Tests', () => {
3037
3085
  PositionDirection.LONG,
3038
3086
  vBid,
3039
3087
  vAsk,
3040
- new BN(slot + 1), // later order becomes taker
3088
+ new BN(slot - 1), // later order becomes taker
3041
3089
  new BN(200)
3042
3090
  );
3043
3091
 
@@ -3105,7 +3153,9 @@ describe('DLOB Perp Tests', () => {
3105
3153
  vBid,
3106
3154
  vAsk,
3107
3155
  new BN(slot),
3108
- new BN(200)
3156
+ new BN(200),
3157
+ undefined,
3158
+ true
3109
3159
  );
3110
3160
 
3111
3161
  // market sell into the resting bid
@@ -3160,6 +3210,173 @@ describe('DLOB Perp Tests', () => {
3160
3210
  'wrong maker orderId'
3161
3211
  ).to.equal(2);
3162
3212
  });
3213
+
3214
+ it('Test vamm ask/bid bounds on maker orders', () => {
3215
+ const vAsk = new BN(20).mul(PRICE_PRECISION);
3216
+ const vBid = new BN(5).mul(PRICE_PRECISION);
3217
+
3218
+ const user0 = Keypair.generate();
3219
+ const user1 = Keypair.generate();
3220
+ const user2 = Keypair.generate();
3221
+ const user3 = Keypair.generate();
3222
+
3223
+ const dlob = new DLOB();
3224
+ const marketIndex = 0;
3225
+
3226
+ const slot = 12;
3227
+ const oracle = {
3228
+ price: vBid.add(vAsk).div(new BN(2)), // 11.5
3229
+ slot: new BN(slot),
3230
+ confidence: new BN(1),
3231
+ hasSufficientNumberOfDataPoints: true,
3232
+ };
3233
+
3234
+ // insert a sell that crosses amm bid
3235
+ insertOrderToDLOB(
3236
+ dlob,
3237
+ user0.publicKey,
3238
+ OrderType.LIMIT,
3239
+ MarketType.PERP,
3240
+ 1, // orderId
3241
+ marketIndex,
3242
+ vBid.sub(PRICE_PRECISION),
3243
+ new BN(1).mul(BASE_PRECISION), // quantity
3244
+ PositionDirection.SHORT,
3245
+ vAsk,
3246
+ vBid,
3247
+ new BN(slot),
3248
+ new BN(200),
3249
+ undefined
3250
+ );
3251
+
3252
+ // Market buy right above amm bid. crosses limit sell but can't be used
3253
+ insertOrderToDLOB(
3254
+ dlob,
3255
+ user3.publicKey,
3256
+ OrderType.MARKET,
3257
+ MarketType.PERP,
3258
+ 2, // orderId
3259
+ marketIndex,
3260
+ new BN(0), // price
3261
+ new BN(1).mul(BASE_PRECISION), // quantity
3262
+ PositionDirection.LONG,
3263
+ vBid.add(PRICE_PRECISION),
3264
+ vAsk,
3265
+ new BN(slot),
3266
+ new BN(200)
3267
+ );
3268
+
3269
+ // insert a limit buy above the amm ask
3270
+ insertOrderToDLOB(
3271
+ dlob,
3272
+ user1.publicKey,
3273
+ OrderType.LIMIT,
3274
+ MarketType.PERP,
3275
+ 3, // orderId
3276
+ marketIndex,
3277
+ vAsk.add(PRICE_PRECISION), // price,
3278
+ new BN(8768).mul(BASE_PRECISION).div(new BN(10000)), // quantity
3279
+ PositionDirection.LONG,
3280
+ vBid,
3281
+ vAsk,
3282
+ new BN(slot)
3283
+ );
3284
+
3285
+ // Market sell right below amm ask. crosses limit buy but can't be used
3286
+ insertOrderToDLOB(
3287
+ dlob,
3288
+ user2.publicKey,
3289
+ OrderType.MARKET,
3290
+ MarketType.PERP,
3291
+ 4, // orderId
3292
+ marketIndex,
3293
+ new BN(0), // price
3294
+ new BN(1).mul(BASE_PRECISION), // quantity
3295
+ PositionDirection.SHORT,
3296
+ vAsk.sub(PRICE_PRECISION),
3297
+ vBid,
3298
+ new BN(slot),
3299
+ new BN(200)
3300
+ );
3301
+
3302
+ console.log(`Book state before fill:`);
3303
+ printBookState(dlob, marketIndex, vBid, vAsk, slot, oracle);
3304
+
3305
+ const nodesToFillBefore = dlob.findMarketNodesToFill(
3306
+ marketIndex,
3307
+ slot,
3308
+ MarketType.PERP,
3309
+ oracle,
3310
+ false,
3311
+ vAsk,
3312
+ vBid
3313
+ );
3314
+
3315
+ expect(nodesToFillBefore.length).to.equal(0);
3316
+
3317
+ // insert a sell right above amm bid
3318
+ insertOrderToDLOB(
3319
+ dlob,
3320
+ user0.publicKey,
3321
+ OrderType.LIMIT,
3322
+ MarketType.PERP,
3323
+ 5, // orderId
3324
+ marketIndex,
3325
+ vBid.add(PRICE_PRECISION.div(TWO)),
3326
+ new BN(1).mul(BASE_PRECISION), // quantity
3327
+ PositionDirection.SHORT,
3328
+ vAsk,
3329
+ vBid,
3330
+ new BN(slot),
3331
+ new BN(200)
3332
+ );
3333
+
3334
+ // insert a buy below the amm ask
3335
+ insertOrderToDLOB(
3336
+ dlob,
3337
+ user1.publicKey,
3338
+ OrderType.LIMIT,
3339
+ MarketType.PERP,
3340
+ 6, // orderId
3341
+ marketIndex,
3342
+ vAsk.sub(PRICE_PRECISION.div(TWO)), // price,
3343
+ new BN(8768).mul(BASE_PRECISION).div(new BN(10000)), // quantity
3344
+ PositionDirection.LONG,
3345
+ vBid,
3346
+ vAsk,
3347
+ new BN(slot)
3348
+ );
3349
+
3350
+ const nodesToFillAfter = dlob.findMarketNodesToFill(
3351
+ marketIndex,
3352
+ slot,
3353
+ MarketType.PERP,
3354
+ oracle,
3355
+ false,
3356
+ vAsk,
3357
+ vBid
3358
+ );
3359
+
3360
+ expect(nodesToFillAfter.length).to.equal(2);
3361
+
3362
+ expect(
3363
+ nodesToFillAfter[0].node.order?.orderId,
3364
+ 'wrong taker orderId'
3365
+ ).to.equal(4);
3366
+ expect(
3367
+ nodesToFillAfter[0].makerNode?.order?.orderId,
3368
+ 'wrong maker orderId'
3369
+ ).to.equal(6);
3370
+
3371
+ expect(
3372
+ nodesToFillAfter[1].node.order?.orderId,
3373
+ 'wrong taker orderId'
3374
+ ).to.equal(2);
3375
+ expect(
3376
+ nodesToFillAfter[1].makerNode?.order?.orderId,
3377
+ 'wrong maker orderId'
3378
+ ).to.equal(5);
3379
+ });
3163
3380
  });
3164
3381
 
3165
3382
  describe('DLOB Spot Tests', () => {
@@ -3797,7 +4014,11 @@ describe('DLOB Spot Tests', () => {
3797
4014
  BASE_PRECISION, // quantity
3798
4015
  PositionDirection.LONG,
3799
4016
  vBid,
3800
- vAsk
4017
+ vAsk,
4018
+ undefined,
4019
+ undefined,
4020
+ undefined,
4021
+ true
3801
4022
  );
3802
4023
  insertOrderToDLOB(
3803
4024
  dlob,
@@ -3810,7 +4031,11 @@ describe('DLOB Spot Tests', () => {
3810
4031
  BASE_PRECISION, // quantity
3811
4032
  PositionDirection.LONG,
3812
4033
  vBid,
3813
- vAsk
4034
+ vAsk,
4035
+ undefined,
4036
+ undefined,
4037
+ undefined,
4038
+ true
3814
4039
  );
3815
4040
  insertOrderToDLOB(
3816
4041
  dlob,
@@ -3823,7 +4048,11 @@ describe('DLOB Spot Tests', () => {
3823
4048
  BASE_PRECISION, // quantity
3824
4049
  PositionDirection.LONG,
3825
4050
  vBid,
3826
- vAsk
4051
+ vAsk,
4052
+ undefined,
4053
+ undefined,
4054
+ undefined,
4055
+ true
3827
4056
  );
3828
4057
 
3829
4058
  // should have no crossing orders
@@ -3929,7 +4158,11 @@ describe('DLOB Spot Tests', () => {
3929
4158
  BASE_PRECISION, // quantity
3930
4159
  PositionDirection.SHORT,
3931
4160
  vBid,
3932
- vAsk
4161
+ vAsk,
4162
+ undefined,
4163
+ undefined,
4164
+ undefined,
4165
+ true
3933
4166
  );
3934
4167
  insertOrderToDLOB(
3935
4168
  dlob,
@@ -3942,7 +4175,11 @@ describe('DLOB Spot Tests', () => {
3942
4175
  BASE_PRECISION, // quantity
3943
4176
  PositionDirection.SHORT,
3944
4177
  vBid,
3945
- vAsk
4178
+ vAsk,
4179
+ undefined,
4180
+ undefined,
4181
+ undefined,
4182
+ true
3946
4183
  );
3947
4184
  insertOrderToDLOB(
3948
4185
  dlob,
@@ -3955,7 +4192,11 @@ describe('DLOB Spot Tests', () => {
3955
4192
  BASE_PRECISION, // quantity
3956
4193
  PositionDirection.SHORT,
3957
4194
  vBid,
3958
- vAsk
4195
+ vAsk,
4196
+ undefined,
4197
+ undefined,
4198
+ undefined,
4199
+ true
3959
4200
  );
3960
4201
 
3961
4202
  // should have no crossing orders
@@ -4057,7 +4298,11 @@ describe('DLOB Spot Tests', () => {
4057
4298
  BASE_PRECISION, // quantity
4058
4299
  PositionDirection.SHORT,
4059
4300
  vBid,
4060
- vAsk
4301
+ vAsk,
4302
+ undefined,
4303
+ undefined,
4304
+ undefined,
4305
+ true
4061
4306
  );
4062
4307
  insertOrderToDLOB(
4063
4308
  dlob,
@@ -4070,7 +4315,11 @@ describe('DLOB Spot Tests', () => {
4070
4315
  BASE_PRECISION, // quantity
4071
4316
  PositionDirection.SHORT,
4072
4317
  vBid,
4073
- vAsk
4318
+ vAsk,
4319
+ undefined,
4320
+ undefined,
4321
+ undefined,
4322
+ true
4074
4323
  );
4075
4324
  insertOrderToDLOB(
4076
4325
  dlob,
@@ -4083,7 +4332,11 @@ describe('DLOB Spot Tests', () => {
4083
4332
  new BN(3).mul(BASE_PRECISION), // quantity
4084
4333
  PositionDirection.SHORT,
4085
4334
  vBid,
4086
- vAsk
4335
+ vAsk,
4336
+ undefined,
4337
+ undefined,
4338
+ undefined,
4339
+ true
4087
4340
  );
4088
4341
 
4089
4342
  // should have no crossing orders
@@ -4194,7 +4447,11 @@ describe('DLOB Spot Tests', () => {
4194
4447
  BASE_PRECISION, // quantity
4195
4448
  PositionDirection.SHORT,
4196
4449
  vBid,
4197
- vAsk
4450
+ vAsk,
4451
+ undefined,
4452
+ undefined,
4453
+ undefined,
4454
+ true
4198
4455
  );
4199
4456
  insertOrderToDLOB(
4200
4457
  dlob,
@@ -4207,7 +4464,11 @@ describe('DLOB Spot Tests', () => {
4207
4464
  BASE_PRECISION, // quantity
4208
4465
  PositionDirection.SHORT,
4209
4466
  vBid,
4210
- vAsk
4467
+ vAsk,
4468
+ undefined,
4469
+ undefined,
4470
+ undefined,
4471
+ true
4211
4472
  );
4212
4473
 
4213
4474
  // should have no crossing orders
@@ -4354,7 +4615,11 @@ describe('DLOB Spot Tests', () => {
4354
4615
  BASE_PRECISION, // quantity
4355
4616
  PositionDirection.LONG,
4356
4617
  vBid,
4357
- vAsk
4618
+ vAsk,
4619
+ undefined,
4620
+ undefined,
4621
+ undefined,
4622
+ true
4358
4623
  );
4359
4624
  insertOrderToDLOB(
4360
4625
  dlob,
@@ -4367,7 +4632,11 @@ describe('DLOB Spot Tests', () => {
4367
4632
  BASE_PRECISION, // quantity
4368
4633
  PositionDirection.LONG,
4369
4634
  vBid,
4370
- vAsk
4635
+ vAsk,
4636
+ undefined,
4637
+ undefined,
4638
+ undefined,
4639
+ true
4371
4640
  );
4372
4641
 
4373
4642
  const nodesToFillAfter = dlob.findNodesToFill(