@drift-labs/sdk 2.20.0-beta.0 → 2.20.0-beta.1
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/lib/accounts/bulkAccountLoader.d.ts +2 -1
- package/lib/accounts/bulkAccountLoader.js +7 -7
- package/lib/accounts/fetch.d.ts +1 -0
- package/lib/accounts/fetch.js +8 -4
- package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
- package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
- package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
- package/lib/accounts/types.d.ts +5 -4
- package/lib/accounts/webSocketAccountSubscriber.js +1 -1
- package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.js +5 -1
- package/lib/adminClient.js +61 -57
- package/lib/config.d.ts +2 -2
- package/lib/constants/perpMarkets.d.ts +1 -1
- package/lib/constants/spotMarkets.d.ts +1 -1
- package/lib/dlob/DLOB.d.ts +6 -5
- package/lib/dlob/DLOB.js +105 -75
- package/lib/dlob/DLOBNode.d.ts +2 -2
- package/lib/dlob/DLOBNode.js +7 -7
- package/lib/dlob/DLOBOrders.d.ts +2 -2
- package/lib/dlob/NodeList.d.ts +1 -1
- package/lib/dlob/NodeList.js +2 -2
- package/lib/driftClient.d.ts +3 -2
- package/lib/driftClient.js +114 -95
- package/lib/driftClientConfig.d.ts +3 -3
- package/lib/events/eventSubscriber.js +2 -2
- package/lib/events/fetchLogs.d.ts +2 -2
- package/lib/events/pollingLogProvider.js +1 -1
- package/lib/events/types.d.ts +14 -14
- package/lib/examples/loadDlob.js +2 -2
- package/lib/examples/makeTradeExample.js +9 -9
- package/lib/factory/bigNum.js +13 -13
- package/lib/factory/oracleClient.js +4 -4
- package/lib/idl/drift.json +1 -1
- package/lib/index.js +5 -1
- package/lib/math/amm.d.ts +1 -1
- package/lib/math/amm.js +23 -23
- package/lib/math/auction.js +6 -6
- package/lib/math/exchangeStatus.js +2 -2
- package/lib/math/funding.js +2 -2
- package/lib/math/margin.js +4 -4
- package/lib/math/market.js +15 -15
- package/lib/math/oracles.js +1 -1
- package/lib/math/orders.js +27 -24
- package/lib/math/position.js +5 -5
- package/lib/math/repeg.js +1 -1
- package/lib/math/spotBalance.js +9 -9
- package/lib/math/spotMarket.js +3 -3
- package/lib/math/spotPosition.js +3 -3
- package/lib/math/trade.d.ts +1 -1
- package/lib/math/trade.js +42 -42
- package/lib/math/utils.js +1 -1
- package/lib/oracles/oracleClientCache.js +1 -1
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/types.d.ts +2 -2
- package/lib/serum/types.d.ts +1 -1
- package/lib/slot/SlotSubscriber.d.ts +1 -1
- package/lib/tokenFaucet.js +5 -1
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +1 -1
- package/lib/tx/types.d.ts +1 -1
- package/lib/types.d.ts +65 -44
- package/lib/user.js +63 -63
- package/lib/userConfig.d.ts +2 -2
- package/lib/userMap/userMap.js +1 -1
- package/lib/userMap/userStatsMap.js +3 -3
- package/lib/userStats.js +2 -2
- package/lib/userStatsConfig.d.ts +2 -2
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.ts +5 -5
- package/src/accounts/fetch.ts +8 -0
- package/src/dlob/DLOB.ts +55 -8
- package/src/driftClient.ts +28 -0
- package/src/idl/drift.json +1 -1
- package/src/math/orders.ts +5 -1
- package/src/types.ts +22 -0
- package/src/userMap/userStatsMap.ts +1 -4
- package/tests/amm/test.ts +24 -28
- package/tests/dlob/test.ts +67 -73
package/tests/dlob/test.ts
CHANGED
|
@@ -191,7 +191,7 @@ function printBookState(
|
|
|
191
191
|
function printCrossedNodes(n: NodeToFill, slot: number) {
|
|
192
192
|
console.log(
|
|
193
193
|
`Cross Found, takerExists: ${n.node.order !== undefined}, makerExists: ${
|
|
194
|
-
n.
|
|
194
|
+
n.makerNodes !== undefined
|
|
195
195
|
}`
|
|
196
196
|
);
|
|
197
197
|
console.log(
|
|
@@ -199,12 +199,14 @@ function printCrossedNodes(n: NodeToFill, slot: number) {
|
|
|
199
199
|
n.node.order!
|
|
200
200
|
)})`
|
|
201
201
|
);
|
|
202
|
-
if (n.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
if (n.makerNodes) {
|
|
203
|
+
for (const makerNode of n.makerNodes) {
|
|
204
|
+
console.log(
|
|
205
|
+
`makerNode: (mkt: ${isMarketOrder(
|
|
206
|
+
makerNode.order
|
|
207
|
+
)}, lim: ${isLimitOrder(makerNode.order)})`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
const printOrder = (o: Order) => {
|
|
@@ -224,13 +226,13 @@ function printCrossedNodes(n: NodeToFill, slot: number) {
|
|
|
224
226
|
console.log(`Taker Order:`);
|
|
225
227
|
printOrder(t);
|
|
226
228
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
|
|
230
|
+
if (n.makerNodes.length === 0) {
|
|
231
|
+
console.log(` maker is vAMM node`);
|
|
232
|
+
} else {
|
|
233
|
+
for (const m of n.makerNodes) {
|
|
232
234
|
console.log(`Maker Order:`);
|
|
233
|
-
printOrder(m);
|
|
235
|
+
printOrder(m.order!);
|
|
234
236
|
}
|
|
235
237
|
}
|
|
236
238
|
}
|
|
@@ -1966,11 +1968,11 @@ describe('DLOB Perp Tests', () => {
|
|
|
1966
1968
|
|
|
1967
1969
|
// first taker should fill with best maker
|
|
1968
1970
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
1969
|
-
expect(nodesToFillAfter[0].
|
|
1971
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
1970
1972
|
|
|
1971
1973
|
// second taker should fill with second best maker
|
|
1972
1974
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(5);
|
|
1973
|
-
expect(nodesToFillAfter[1].
|
|
1975
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(2);
|
|
1974
1976
|
});
|
|
1975
1977
|
|
|
1976
1978
|
it('Test one market orders fills two limit orders', () => {
|
|
@@ -2094,7 +2096,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
2094
2096
|
for (const n of nodesToFillAfter) {
|
|
2095
2097
|
printCrossedNodes(n, endSlot);
|
|
2096
2098
|
}
|
|
2097
|
-
expect(nodesToFillAfter.length).to.equal(
|
|
2099
|
+
expect(nodesToFillAfter.length).to.equal(1);
|
|
2098
2100
|
|
|
2099
2101
|
// taker should fill completely with best maker
|
|
2100
2102
|
expect(
|
|
@@ -2102,17 +2104,12 @@ describe('DLOB Perp Tests', () => {
|
|
|
2102
2104
|
'wrong taker orderId'
|
|
2103
2105
|
).to.equal(4);
|
|
2104
2106
|
expect(
|
|
2105
|
-
nodesToFillAfter[0].
|
|
2107
|
+
nodesToFillAfter[0].makerNodes[0]?.order?.orderId,
|
|
2106
2108
|
'wrong maker orderId'
|
|
2107
2109
|
).to.equal(3);
|
|
2108
2110
|
|
|
2109
|
-
// taker should fill completely with second best maker
|
|
2110
|
-
expect(
|
|
2111
|
-
nodesToFillAfter[1].node.order?.orderId,
|
|
2112
|
-
'wrong taker orderId'
|
|
2113
|
-
).to.equal(4);
|
|
2114
2111
|
expect(
|
|
2115
|
-
nodesToFillAfter[1]
|
|
2112
|
+
nodesToFillAfter[0].makerNodes[1]?.order?.orderId,
|
|
2116
2113
|
'wrong maker orderId'
|
|
2117
2114
|
).to.equal(2);
|
|
2118
2115
|
});
|
|
@@ -2260,11 +2257,11 @@ describe('DLOB Perp Tests', () => {
|
|
|
2260
2257
|
|
|
2261
2258
|
// taker should fill completely with best maker
|
|
2262
2259
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
2263
|
-
expect(nodesToFillAfter[0].
|
|
2260
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
2264
2261
|
|
|
2265
2262
|
// taker should fill completely with second best maker
|
|
2266
2263
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(5);
|
|
2267
|
-
expect(nodesToFillAfter[1].
|
|
2264
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
2268
2265
|
});
|
|
2269
2266
|
|
|
2270
2267
|
it('Test trigger orders', () => {
|
|
@@ -2598,8 +2595,8 @@ describe('DLOB Perp Tests', () => {
|
|
|
2598
2595
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
2599
2596
|
|
|
2600
2597
|
// check that the nodes have no makers
|
|
2601
|
-
expect(nodesToFillAfter[0].
|
|
2602
|
-
expect(nodesToFillAfter[1].
|
|
2598
|
+
expect(nodesToFillAfter[0].makerNodes.length).to.equal(0);
|
|
2599
|
+
expect(nodesToFillAfter[1].makerNodes.length).to.equal(0);
|
|
2603
2600
|
});
|
|
2604
2601
|
|
|
2605
2602
|
it('Test skips vAMM and fills market buy order with floating limit order during auction', () => {
|
|
@@ -2756,19 +2753,18 @@ describe('DLOB Perp Tests', () => {
|
|
|
2756
2753
|
for (const n of nodesToFillAfter) {
|
|
2757
2754
|
printCrossedNodes(n, slot);
|
|
2758
2755
|
}
|
|
2759
|
-
expect(nodesToFillAfter.length).to.equal(
|
|
2756
|
+
expect(nodesToFillAfter.length).to.equal(2);
|
|
2760
2757
|
|
|
2761
2758
|
// taker should fill first order completely with best maker (1/1)
|
|
2762
2759
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
2763
|
-
expect(nodesToFillAfter[0].
|
|
2760
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(1);
|
|
2764
2761
|
|
|
2765
2762
|
// taker should fill partially with second best maker (1/2)
|
|
2766
2763
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(5);
|
|
2767
|
-
expect(nodesToFillAfter[1].
|
|
2764
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(2);
|
|
2768
2765
|
|
|
2769
2766
|
// taker should fill completely with third best maker (2/2)
|
|
2770
|
-
expect(nodesToFillAfter[
|
|
2771
|
-
expect(nodesToFillAfter[2].makerNode?.order?.orderId).to.equal(3);
|
|
2767
|
+
expect(nodesToFillAfter[1].makerNodes[1]?.order?.orderId).to.equal(3);
|
|
2772
2768
|
});
|
|
2773
2769
|
|
|
2774
2770
|
it('Test fills market buy order with better priced vAMM after auction', () => {
|
|
@@ -2910,11 +2906,13 @@ describe('DLOB Perp Tests', () => {
|
|
|
2910
2906
|
|
|
2911
2907
|
// taker should fill completely with best maker
|
|
2912
2908
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
2913
|
-
expect(nodesToFillAfter[0].
|
|
2909
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(1);
|
|
2914
2910
|
|
|
2915
2911
|
// taker should fill the rest with the vAMM
|
|
2916
2912
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(5);
|
|
2917
|
-
expect(nodesToFillAfter[1].
|
|
2913
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(
|
|
2914
|
+
undefined
|
|
2915
|
+
);
|
|
2918
2916
|
});
|
|
2919
2917
|
|
|
2920
2918
|
it('Test skips vAMM and fills market sell order with floating limit buys during auction', () => {
|
|
@@ -3057,7 +3055,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3057
3055
|
for (const n of nodesToFillAfter) {
|
|
3058
3056
|
printCrossedNodes(n, slot);
|
|
3059
3057
|
}
|
|
3060
|
-
expect(nodesToFillAfter.length).to.equal(
|
|
3058
|
+
expect(nodesToFillAfter.length).to.equal(2);
|
|
3061
3059
|
|
|
3062
3060
|
// taker should fill first order completely with best maker (1/1)
|
|
3063
3061
|
expect(
|
|
@@ -3065,7 +3063,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3065
3063
|
'wrong taker orderId'
|
|
3066
3064
|
).to.equal(4);
|
|
3067
3065
|
expect(
|
|
3068
|
-
nodesToFillAfter[0].
|
|
3066
|
+
nodesToFillAfter[0].makerNodes[0]?.order?.orderId,
|
|
3069
3067
|
'wrong maker orderId'
|
|
3070
3068
|
).to.equal(3);
|
|
3071
3069
|
|
|
@@ -3075,17 +3073,13 @@ describe('DLOB Perp Tests', () => {
|
|
|
3075
3073
|
'wrong maker orderId'
|
|
3076
3074
|
).to.equal(5);
|
|
3077
3075
|
expect(
|
|
3078
|
-
nodesToFillAfter[1].
|
|
3076
|
+
nodesToFillAfter[1].makerNodes[0]?.order?.orderId,
|
|
3079
3077
|
'wrong maker orderId'
|
|
3080
3078
|
).to.equal(2);
|
|
3081
3079
|
|
|
3082
3080
|
// taker should fill completely with third best maker (2/2)
|
|
3083
3081
|
expect(
|
|
3084
|
-
nodesToFillAfter[
|
|
3085
|
-
'wrong taker orderId'
|
|
3086
|
-
).to.equal(5);
|
|
3087
|
-
expect(
|
|
3088
|
-
nodesToFillAfter[2].makerNode?.order?.orderId,
|
|
3082
|
+
nodesToFillAfter[1].makerNodes[1]?.order?.orderId,
|
|
3089
3083
|
'wrong maker orderId'
|
|
3090
3084
|
).to.equal(1);
|
|
3091
3085
|
});
|
|
@@ -3240,7 +3234,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3240
3234
|
'wrong taker orderId'
|
|
3241
3235
|
).to.equal(4);
|
|
3242
3236
|
expect(
|
|
3243
|
-
nodesToFillAfter[0].
|
|
3237
|
+
nodesToFillAfter[0].makerNodes[0]?.order?.orderId,
|
|
3244
3238
|
'wrong maker orderId'
|
|
3245
3239
|
).to.equal(3);
|
|
3246
3240
|
|
|
@@ -3250,11 +3244,11 @@ describe('DLOB Perp Tests', () => {
|
|
|
3250
3244
|
'wrong taker orderId'
|
|
3251
3245
|
).to.equal(5);
|
|
3252
3246
|
expect(
|
|
3253
|
-
nodesToFillAfter[1].
|
|
3247
|
+
nodesToFillAfter[1].makerNodes[0]?.order?.orderId,
|
|
3254
3248
|
'wrong maker orderId'
|
|
3255
3249
|
).to.equal(2); // filler should match the DLOB makers, protocol will fill the taker with vAMM if it offers a better price.
|
|
3256
3250
|
|
|
3257
|
-
expect(nodesToFillAfter.length).to.equal(
|
|
3251
|
+
expect(nodesToFillAfter.length).to.equal(2);
|
|
3258
3252
|
});
|
|
3259
3253
|
|
|
3260
3254
|
it('Test fills crossing bids with vAMM after auction ends', () => {
|
|
@@ -3368,7 +3362,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3368
3362
|
'wrong taker orderId'
|
|
3369
3363
|
).to.equal(3);
|
|
3370
3364
|
expect(
|
|
3371
|
-
nodesToFillAfter[0].
|
|
3365
|
+
nodesToFillAfter[0].makerNodes[0]?.order?.orderId,
|
|
3372
3366
|
'wrong maker orderId'
|
|
3373
3367
|
).to.equal(undefined);
|
|
3374
3368
|
|
|
@@ -3377,7 +3371,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3377
3371
|
'wrong taker orderId'
|
|
3378
3372
|
).to.equal(2);
|
|
3379
3373
|
expect(
|
|
3380
|
-
nodesToFillAfter[1].
|
|
3374
|
+
nodesToFillAfter[1].makerNodes[0]?.order?.orderId,
|
|
3381
3375
|
'wrong maker orderId'
|
|
3382
3376
|
).to.equal(undefined);
|
|
3383
3377
|
|
|
@@ -3468,7 +3462,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3468
3462
|
'wrong taker orderId'
|
|
3469
3463
|
).to.equal(2);
|
|
3470
3464
|
expect(
|
|
3471
|
-
nodesToFillBefore[0].
|
|
3465
|
+
nodesToFillBefore[0].makerNodes[0]?.order?.orderId,
|
|
3472
3466
|
'wrong maker orderId'
|
|
3473
3467
|
).to.equal(3);
|
|
3474
3468
|
});
|
|
@@ -3559,7 +3553,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3559
3553
|
'wrong taker orderId'
|
|
3560
3554
|
).to.equal(3);
|
|
3561
3555
|
expect(
|
|
3562
|
-
nodesToFillBefore[0].
|
|
3556
|
+
nodesToFillBefore[0].makerNodes[0]?.order?.orderId,
|
|
3563
3557
|
'wrong maker orderId'
|
|
3564
3558
|
).to.equal(2);
|
|
3565
3559
|
});
|
|
@@ -3732,7 +3726,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3732
3726
|
'wrong taker orderId'
|
|
3733
3727
|
).to.equal(4);
|
|
3734
3728
|
expect(
|
|
3735
|
-
nodesToFillAfter[0].
|
|
3729
|
+
nodesToFillAfter[0].makerNodes[0]?.order?.orderId,
|
|
3736
3730
|
'wrong maker orderId'
|
|
3737
3731
|
).to.equal(6);
|
|
3738
3732
|
|
|
@@ -3741,7 +3735,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3741
3735
|
'wrong taker orderId'
|
|
3742
3736
|
).to.equal(2);
|
|
3743
3737
|
expect(
|
|
3744
|
-
nodesToFillAfter[1].
|
|
3738
|
+
nodesToFillAfter[1].makerNodes[0]?.order?.orderId,
|
|
3745
3739
|
'wrong maker orderId'
|
|
3746
3740
|
).to.equal(5);
|
|
3747
3741
|
});
|
|
@@ -3864,7 +3858,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3864
3858
|
'wrong taker orderId'
|
|
3865
3859
|
).to.equal(4);
|
|
3866
3860
|
expect(
|
|
3867
|
-
nodesToFillAfter[0].
|
|
3861
|
+
nodesToFillAfter[0].makerNodes[0]?.order?.orderId,
|
|
3868
3862
|
'wrong maker orderId'
|
|
3869
3863
|
).to.equal(6);
|
|
3870
3864
|
|
|
@@ -3873,7 +3867,7 @@ describe('DLOB Perp Tests', () => {
|
|
|
3873
3867
|
'wrong taker orderId'
|
|
3874
3868
|
).to.equal(2);
|
|
3875
3869
|
expect(
|
|
3876
|
-
nodesToFillAfter[1].
|
|
3870
|
+
nodesToFillAfter[1].makerNodes[0]?.order?.orderId,
|
|
3877
3871
|
'wrong maker orderId'
|
|
3878
3872
|
).to.equal(5);
|
|
3879
3873
|
});
|
|
@@ -4656,18 +4650,18 @@ describe('DLOB Spot Tests', () => {
|
|
|
4656
4650
|
);
|
|
4657
4651
|
for (const n of nodesToFillAfter) {
|
|
4658
4652
|
console.log(
|
|
4659
|
-
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.
|
|
4653
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
|
|
4660
4654
|
);
|
|
4661
4655
|
}
|
|
4662
4656
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
4663
4657
|
|
|
4664
4658
|
// first taker should fill with best maker
|
|
4665
4659
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
4666
|
-
expect(nodesToFillAfter[0].
|
|
4660
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
4667
4661
|
|
|
4668
4662
|
// second taker should fill with second best maker
|
|
4669
4663
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(5);
|
|
4670
|
-
expect(nodesToFillAfter[1].
|
|
4664
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(2);
|
|
4671
4665
|
});
|
|
4672
4666
|
|
|
4673
4667
|
it('Test one market order fills two limit orders', () => {
|
|
@@ -4787,18 +4781,18 @@ describe('DLOB Spot Tests', () => {
|
|
|
4787
4781
|
);
|
|
4788
4782
|
for (const n of nodesToFillAfter) {
|
|
4789
4783
|
console.log(
|
|
4790
|
-
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.
|
|
4784
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmountFilled.toString()}/${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
|
|
4791
4785
|
);
|
|
4792
4786
|
}
|
|
4793
4787
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
4794
4788
|
|
|
4795
4789
|
// taker should fill completely with best maker
|
|
4796
4790
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
4797
|
-
expect(nodesToFillAfter[0].
|
|
4791
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
4798
4792
|
|
|
4799
4793
|
// taker should fill completely with second best maker
|
|
4800
4794
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(4);
|
|
4801
|
-
expect(nodesToFillAfter[1].
|
|
4795
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(2);
|
|
4802
4796
|
});
|
|
4803
4797
|
|
|
4804
4798
|
it('Test two market orders to fill one limit order', () => {
|
|
@@ -4939,18 +4933,18 @@ describe('DLOB Spot Tests', () => {
|
|
|
4939
4933
|
|
|
4940
4934
|
for (const n of nodesToFillAfter) {
|
|
4941
4935
|
console.log(
|
|
4942
|
-
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.
|
|
4936
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmountFilled.toString()}/${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
|
|
4943
4937
|
);
|
|
4944
4938
|
}
|
|
4945
4939
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
4946
4940
|
|
|
4947
4941
|
// taker should fill completely with best maker
|
|
4948
4942
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
|
|
4949
|
-
expect(nodesToFillAfter[0].
|
|
4943
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
4950
4944
|
|
|
4951
4945
|
// taker should fill completely with second best maker
|
|
4952
4946
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(5);
|
|
4953
|
-
expect(nodesToFillAfter[1].
|
|
4947
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
4954
4948
|
});
|
|
4955
4949
|
|
|
4956
4950
|
it('Test market orders skipping maker with same authority', () => {
|
|
@@ -5065,18 +5059,18 @@ describe('DLOB Spot Tests', () => {
|
|
|
5065
5059
|
|
|
5066
5060
|
for (const n of nodesToFillAfter) {
|
|
5067
5061
|
console.log(
|
|
5068
|
-
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.
|
|
5062
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmountFilled.toString()}/${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
|
|
5069
5063
|
);
|
|
5070
5064
|
}
|
|
5071
5065
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
5072
5066
|
|
|
5073
5067
|
// taker should fill completely with best maker
|
|
5074
5068
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(3);
|
|
5075
|
-
expect(nodesToFillAfter[0].
|
|
5069
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(1);
|
|
5076
5070
|
|
|
5077
5071
|
// taker should fill completely with second best maker
|
|
5078
5072
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(4);
|
|
5079
|
-
expect(nodesToFillAfter[1].
|
|
5073
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(2);
|
|
5080
5074
|
});
|
|
5081
5075
|
|
|
5082
5076
|
it('Test limit orders skipping maker with same authority', () => {
|
|
@@ -5193,18 +5187,18 @@ describe('DLOB Spot Tests', () => {
|
|
|
5193
5187
|
|
|
5194
5188
|
for (const n of nodesToFillAfter) {
|
|
5195
5189
|
console.log(
|
|
5196
|
-
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.
|
|
5190
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmountFilled.toString()}/${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
|
|
5197
5191
|
);
|
|
5198
5192
|
}
|
|
5199
5193
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
5200
5194
|
|
|
5201
5195
|
// taker should fill completely with best maker
|
|
5202
5196
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(2);
|
|
5203
|
-
expect(nodesToFillAfter[0].
|
|
5197
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(4);
|
|
5204
5198
|
|
|
5205
5199
|
// taker should fill completely with second best maker
|
|
5206
5200
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(1);
|
|
5207
|
-
expect(nodesToFillAfter[1].
|
|
5201
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(3);
|
|
5208
5202
|
});
|
|
5209
5203
|
|
|
5210
5204
|
// add back if dlob checks limit order age again
|
|
@@ -5374,18 +5368,18 @@ describe('DLOB Spot Tests', () => {
|
|
|
5374
5368
|
|
|
5375
5369
|
for (const n of nodesToFillAfter) {
|
|
5376
5370
|
console.log(
|
|
5377
|
-
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.
|
|
5371
|
+
`cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmountFilled.toString()}/${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
|
|
5378
5372
|
);
|
|
5379
5373
|
}
|
|
5380
5374
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
5381
5375
|
|
|
5382
5376
|
// taker should fill completely with best maker
|
|
5383
5377
|
expect(nodesToFillAfter[0].node.order?.orderId).to.equal(2);
|
|
5384
|
-
expect(nodesToFillAfter[0].
|
|
5378
|
+
expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(6);
|
|
5385
5379
|
|
|
5386
5380
|
// taker should fill completely with second best maker
|
|
5387
5381
|
expect(nodesToFillAfter[1].node.order?.orderId).to.equal(1);
|
|
5388
|
-
expect(nodesToFillAfter[1].
|
|
5382
|
+
expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(5);
|
|
5389
5383
|
});
|
|
5390
5384
|
|
|
5391
5385
|
it('Test trigger orders', () => {
|
|
@@ -5714,7 +5708,7 @@ describe('DLOB Spot Tests', () => {
|
|
|
5714
5708
|
expect(nodesToFillAfter.length).to.equal(2);
|
|
5715
5709
|
|
|
5716
5710
|
// check that the nodes have no makers
|
|
5717
|
-
expect(nodesToFillAfter[0].
|
|
5718
|
-
expect(nodesToFillAfter[1].
|
|
5711
|
+
expect(nodesToFillAfter[0].makerNodes.length).to.equal(0);
|
|
5712
|
+
expect(nodesToFillAfter[1].makerNodes.length).to.equal(0);
|
|
5719
5713
|
});
|
|
5720
5714
|
});
|