@drift-labs/sdk 2.0.13 → 2.0.15
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.
- package/README.md +3 -3
- package/lib/accounts/pollingDriftClientAccountSubscriber.js +0 -3
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +0 -3
- package/lib/adminClient.d.ts +2 -0
- package/lib/adminClient.js +16 -0
- package/lib/constants/numericConstants.d.ts +2 -0
- package/lib/constants/numericConstants.js +3 -1
- package/lib/dlob/DLOB.d.ts +8 -8
- package/lib/dlob/DLOB.js +227 -246
- package/lib/driftClient.d.ts +19 -0
- package/lib/driftClient.js +32 -0
- package/lib/idl/drift.json +65 -7
- package/lib/math/amm.d.ts +3 -2
- package/lib/math/amm.js +61 -27
- package/lib/math/oracles.d.ts +2 -0
- package/lib/math/oracles.js +23 -1
- package/lib/math/orders.d.ts +1 -2
- package/lib/math/orders.js +4 -20
- package/lib/math/utils.d.ts +1 -0
- package/lib/math/utils.js +5 -1
- package/lib/types.d.ts +6 -2
- package/lib/user.js +10 -6
- package/package.json +1 -1
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +0 -4
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +0 -4
- package/src/adminClient.ts +28 -0
- package/src/constants/numericConstants.ts +3 -0
- package/src/dlob/DLOB.ts +444 -345
- package/src/driftClient.ts +41 -0
- package/src/idl/drift.json +65 -7
- package/src/math/amm.ts +126 -42
- package/src/math/oracles.ts +52 -0
- package/src/math/orders.ts +5 -22
- package/src/math/utils.ts +4 -0
- package/src/types.ts +6 -2
- package/src/user.ts +17 -6
- package/tests/dlob/helpers.ts +4 -2
- package/tests/dlob/test.ts +547 -63
package/tests/dlob/test.ts
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
1693
|
-
const nodesToFillBefore = dlob.findCrossingNodesToFill(
|
|
1797
|
+
const nodesToFillBefore = dlob.findNodesToFill(
|
|
1694
1798
|
marketIndex,
|
|
1695
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
);
|
|
@@ -4214,6 +4448,258 @@ describe('DLOB Spot Tests', () => {
|
|
|
4214
4448
|
expect(nodesToFillAfter[1].makerNode?.order?.orderId).to.equal(3);
|
|
4215
4449
|
});
|
|
4216
4450
|
|
|
4451
|
+
it('Test market orders skipping maker with same authority', () => {
|
|
4452
|
+
const vAsk = new BN(15);
|
|
4453
|
+
const vBid = new BN(8);
|
|
4454
|
+
|
|
4455
|
+
const mockUserMap = new MockUserMap();
|
|
4456
|
+
const user0 = Keypair.generate();
|
|
4457
|
+
const userAuth0 = Keypair.generate();
|
|
4458
|
+
const user1 = Keypair.generate();
|
|
4459
|
+
const userAuth1 = Keypair.generate();
|
|
4460
|
+
|
|
4461
|
+
mockUserMap.addUserAccountAuthority(user0.publicKey, userAuth0.publicKey);
|
|
4462
|
+
mockUserMap.addUserAccountAuthority(user1.publicKey, userAuth1.publicKey);
|
|
4463
|
+
|
|
4464
|
+
const dlob = new DLOB(
|
|
4465
|
+
mockPerpMarkets,
|
|
4466
|
+
mockSpotMarkets,
|
|
4467
|
+
mockStateAccount,
|
|
4468
|
+
mockUserMap,
|
|
4469
|
+
false
|
|
4470
|
+
);
|
|
4471
|
+
const marketIndex = 0;
|
|
4472
|
+
|
|
4473
|
+
const slot = 12;
|
|
4474
|
+
const oracle = {
|
|
4475
|
+
price: vBid.add(vAsk).div(new BN(2)),
|
|
4476
|
+
slot: new BN(slot),
|
|
4477
|
+
confidence: new BN(1),
|
|
4478
|
+
hasSufficientNumberOfDataPoints: true,
|
|
4479
|
+
};
|
|
4480
|
+
|
|
4481
|
+
// insert some limit sells below vAMM ask, above bid
|
|
4482
|
+
insertOrderToDLOB(
|
|
4483
|
+
dlob,
|
|
4484
|
+
user0.publicKey,
|
|
4485
|
+
OrderType.LIMIT,
|
|
4486
|
+
MarketType.PERP,
|
|
4487
|
+
1, // orderId
|
|
4488
|
+
marketIndex,
|
|
4489
|
+
new BN(14), // price
|
|
4490
|
+
BASE_PRECISION, // quantity
|
|
4491
|
+
PositionDirection.SHORT,
|
|
4492
|
+
vBid,
|
|
4493
|
+
vAsk
|
|
4494
|
+
);
|
|
4495
|
+
insertOrderToDLOB(
|
|
4496
|
+
dlob,
|
|
4497
|
+
user1.publicKey,
|
|
4498
|
+
OrderType.LIMIT,
|
|
4499
|
+
MarketType.PERP,
|
|
4500
|
+
2, // orderId
|
|
4501
|
+
marketIndex,
|
|
4502
|
+
new BN(13), // price
|
|
4503
|
+
BASE_PRECISION, // quantity
|
|
4504
|
+
PositionDirection.SHORT,
|
|
4505
|
+
vBid,
|
|
4506
|
+
vAsk
|
|
4507
|
+
);
|
|
4508
|
+
|
|
4509
|
+
// should have no crossing orders
|
|
4510
|
+
const nodesToFillBefore = dlob.findNodesToFill(
|
|
4511
|
+
marketIndex,
|
|
4512
|
+
undefined,
|
|
4513
|
+
undefined,
|
|
4514
|
+
12, // auction over
|
|
4515
|
+
Date.now(),
|
|
4516
|
+
MarketType.PERP,
|
|
4517
|
+
oracle
|
|
4518
|
+
);
|
|
4519
|
+
expect(nodesToFillBefore.length).to.equal(0);
|
|
4520
|
+
|
|
4521
|
+
// place two market buy orders to eat the best ask
|
|
4522
|
+
insertOrderToDLOB(
|
|
4523
|
+
dlob,
|
|
4524
|
+
user1.publicKey,
|
|
4525
|
+
OrderType.MARKET,
|
|
4526
|
+
MarketType.PERP,
|
|
4527
|
+
3, // orderId
|
|
4528
|
+
marketIndex,
|
|
4529
|
+
new BN(0), // price
|
|
4530
|
+
BASE_PRECISION, // quantity
|
|
4531
|
+
PositionDirection.LONG,
|
|
4532
|
+
vBid,
|
|
4533
|
+
vAsk
|
|
4534
|
+
);
|
|
4535
|
+
insertOrderToDLOB(
|
|
4536
|
+
dlob,
|
|
4537
|
+
user0.publicKey,
|
|
4538
|
+
OrderType.MARKET,
|
|
4539
|
+
MarketType.PERP,
|
|
4540
|
+
4, // orderId
|
|
4541
|
+
marketIndex,
|
|
4542
|
+
new BN(0), // price
|
|
4543
|
+
BASE_PRECISION, // quantity
|
|
4544
|
+
PositionDirection.LONG,
|
|
4545
|
+
vBid,
|
|
4546
|
+
vAsk
|
|
4547
|
+
);
|
|
4548
|
+
|
|
4549
|
+
const nodesToFillAfter = dlob.findNodesToFill(
|
|
4550
|
+
marketIndex,
|
|
4551
|
+
undefined,
|
|
4552
|
+
undefined,
|
|
4553
|
+
slot, // auction over
|
|
4554
|
+
Date.now(),
|
|
4555
|
+
MarketType.PERP,
|
|
4556
|
+
oracle
|
|
4557
|
+
);
|
|
4558
|
+
|
|
4559
|
+
printBookState(dlob, marketIndex, vBid, vAsk, slot, oracle);
|
|
4560
|
+
|
|
4561
|
+
for (const n of nodesToFillAfter) {
|
|
4562
|
+
console.log(
|
|
4563
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNode?.order?.orderId.toString()}: BAA: ${n.makerNode?.order?.baseAssetAmountFilled.toString()}/${n.makerNode?.order?.baseAssetAmount.toString()}`
|
|
4564
|
+
);
|
|
4565
|
+
}
|
|
4566
|
+
expect(nodesToFillAfter.length).to.equal(2);
|
|
4567
|
+
|
|
4568
|
+
// taker should fill completely with best maker
|
|
4569
|
+
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(3);
|
|
4570
|
+
expect(nodesToFillAfter[0].makerNode?.order?.orderId).to.equal(1);
|
|
4571
|
+
|
|
4572
|
+
// taker should fill completely with second best maker
|
|
4573
|
+
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(4);
|
|
4574
|
+
expect(nodesToFillAfter[1].makerNode?.order?.orderId).to.equal(2);
|
|
4575
|
+
});
|
|
4576
|
+
|
|
4577
|
+
it('Test limit orders skipping maker with same authority', () => {
|
|
4578
|
+
const vAsk = new BN(15);
|
|
4579
|
+
const vBid = new BN(8);
|
|
4580
|
+
|
|
4581
|
+
const mockUserMap = new MockUserMap();
|
|
4582
|
+
const user0 = Keypair.generate();
|
|
4583
|
+
const userAuth0 = Keypair.generate();
|
|
4584
|
+
const user1 = Keypair.generate();
|
|
4585
|
+
const userAuth1 = Keypair.generate();
|
|
4586
|
+
|
|
4587
|
+
mockUserMap.addUserAccountAuthority(user0.publicKey, userAuth0.publicKey);
|
|
4588
|
+
mockUserMap.addUserAccountAuthority(user1.publicKey, userAuth1.publicKey);
|
|
4589
|
+
|
|
4590
|
+
const dlob = new DLOB(
|
|
4591
|
+
mockPerpMarkets,
|
|
4592
|
+
mockSpotMarkets,
|
|
4593
|
+
mockStateAccount,
|
|
4594
|
+
mockUserMap,
|
|
4595
|
+
false
|
|
4596
|
+
);
|
|
4597
|
+
const marketIndex = 0;
|
|
4598
|
+
|
|
4599
|
+
const slot = 12;
|
|
4600
|
+
const oracle = {
|
|
4601
|
+
price: vBid.add(vAsk).div(new BN(2)),
|
|
4602
|
+
slot: new BN(slot),
|
|
4603
|
+
confidence: new BN(1),
|
|
4604
|
+
hasSufficientNumberOfDataPoints: true,
|
|
4605
|
+
};
|
|
4606
|
+
|
|
4607
|
+
// insert some limit sells below vAMM ask, above bid
|
|
4608
|
+
insertOrderToDLOB(
|
|
4609
|
+
dlob,
|
|
4610
|
+
user0.publicKey,
|
|
4611
|
+
OrderType.LIMIT,
|
|
4612
|
+
MarketType.PERP,
|
|
4613
|
+
1, // orderId
|
|
4614
|
+
marketIndex,
|
|
4615
|
+
new BN(14), // price
|
|
4616
|
+
BASE_PRECISION, // quantity
|
|
4617
|
+
PositionDirection.SHORT,
|
|
4618
|
+
vBid,
|
|
4619
|
+
vAsk
|
|
4620
|
+
);
|
|
4621
|
+
insertOrderToDLOB(
|
|
4622
|
+
dlob,
|
|
4623
|
+
user1.publicKey,
|
|
4624
|
+
OrderType.LIMIT,
|
|
4625
|
+
MarketType.PERP,
|
|
4626
|
+
2, // orderId
|
|
4627
|
+
marketIndex,
|
|
4628
|
+
new BN(13), // price
|
|
4629
|
+
BASE_PRECISION, // quantity
|
|
4630
|
+
PositionDirection.SHORT,
|
|
4631
|
+
vBid,
|
|
4632
|
+
vAsk
|
|
4633
|
+
);
|
|
4634
|
+
|
|
4635
|
+
// should have no crossing orders
|
|
4636
|
+
const nodesToFillBefore = dlob.findNodesToFill(
|
|
4637
|
+
marketIndex,
|
|
4638
|
+
undefined,
|
|
4639
|
+
undefined,
|
|
4640
|
+
12, // auction over
|
|
4641
|
+
Date.now(),
|
|
4642
|
+
MarketType.PERP,
|
|
4643
|
+
oracle
|
|
4644
|
+
);
|
|
4645
|
+
expect(nodesToFillBefore.length).to.equal(0);
|
|
4646
|
+
|
|
4647
|
+
// place two market buy orders to eat the best ask
|
|
4648
|
+
insertOrderToDLOB(
|
|
4649
|
+
dlob,
|
|
4650
|
+
user1.publicKey,
|
|
4651
|
+
OrderType.LIMIT,
|
|
4652
|
+
MarketType.PERP,
|
|
4653
|
+
3, // orderId
|
|
4654
|
+
marketIndex,
|
|
4655
|
+
new BN(15), // price
|
|
4656
|
+
BASE_PRECISION, // quantity
|
|
4657
|
+
PositionDirection.LONG,
|
|
4658
|
+
vBid,
|
|
4659
|
+
vAsk
|
|
4660
|
+
);
|
|
4661
|
+
insertOrderToDLOB(
|
|
4662
|
+
dlob,
|
|
4663
|
+
user0.publicKey,
|
|
4664
|
+
OrderType.LIMIT,
|
|
4665
|
+
MarketType.PERP,
|
|
4666
|
+
4, // orderId
|
|
4667
|
+
marketIndex,
|
|
4668
|
+
new BN(14), // price
|
|
4669
|
+
BASE_PRECISION, // quantity
|
|
4670
|
+
PositionDirection.LONG,
|
|
4671
|
+
vBid,
|
|
4672
|
+
vAsk
|
|
4673
|
+
);
|
|
4674
|
+
|
|
4675
|
+
const nodesToFillAfter = dlob.findNodesToFill(
|
|
4676
|
+
marketIndex,
|
|
4677
|
+
undefined,
|
|
4678
|
+
undefined,
|
|
4679
|
+
slot, // auction over
|
|
4680
|
+
Date.now(),
|
|
4681
|
+
MarketType.PERP,
|
|
4682
|
+
oracle
|
|
4683
|
+
);
|
|
4684
|
+
|
|
4685
|
+
printBookState(dlob, marketIndex, vBid, vAsk, slot, oracle);
|
|
4686
|
+
|
|
4687
|
+
for (const n of nodesToFillAfter) {
|
|
4688
|
+
console.log(
|
|
4689
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNode?.order?.orderId.toString()}: BAA: ${n.makerNode?.order?.baseAssetAmountFilled.toString()}/${n.makerNode?.order?.baseAssetAmount.toString()}`
|
|
4690
|
+
);
|
|
4691
|
+
}
|
|
4692
|
+
expect(nodesToFillAfter.length).to.equal(2);
|
|
4693
|
+
|
|
4694
|
+
// taker should fill completely with best maker
|
|
4695
|
+
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(2);
|
|
4696
|
+
expect(nodesToFillAfter[0].makerNode?.order?.orderId).to.equal(4);
|
|
4697
|
+
|
|
4698
|
+
// taker should fill completely with second best maker
|
|
4699
|
+
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(1);
|
|
4700
|
+
expect(nodesToFillAfter[1].makerNode?.order?.orderId).to.equal(3);
|
|
4701
|
+
});
|
|
4702
|
+
|
|
4217
4703
|
it('Test trigger orders', () => {
|
|
4218
4704
|
const vAsk = new BN(15);
|
|
4219
4705
|
const vBid = new BN(8);
|
|
@@ -4477,10 +4963,8 @@ describe('DLOB Spot Tests', () => {
|
|
|
4477
4963
|
oracle.price,
|
|
4478
4964
|
MarketType.SPOT
|
|
4479
4965
|
);
|
|
4480
|
-
console.log(`nodesToTriggeR: ${nodesToTrigger.length}`);
|
|
4481
4966
|
for (const [idx, n] of nodesToTrigger.entries()) {
|
|
4482
4967
|
expect(n.node.order?.orderId).to.equal(orderIdsToTrigger[idx]);
|
|
4483
|
-
console.log(`nodeToTrigger: ${n.node.order?.orderId}`);
|
|
4484
4968
|
}
|
|
4485
4969
|
});
|
|
4486
4970
|
|