@drift-labs/sdk 2.37.1-beta.1 → 2.37.1-beta.11
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/VERSION +1 -1
- package/lib/adminClient.d.ts +1 -0
- package/lib/adminClient.js +10 -0
- package/lib/constants/perpMarkets.js +20 -0
- package/lib/idl/drift.json +73 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/math/auction.js +1 -1
- package/lib/orderSubscriber/OrderSubscriber.d.ts +5 -1
- package/lib/orderSubscriber/OrderSubscriber.js +10 -0
- package/lib/orderSubscriber/types.d.ts +5 -0
- package/lib/tx/baseTxSender.d.ts +30 -0
- package/lib/tx/baseTxSender.js +176 -0
- package/lib/tx/fastSingleTxSender.d.ts +27 -0
- package/lib/tx/fastSingleTxSender.js +83 -0
- package/lib/tx/retryTxSender.d.ts +5 -14
- package/lib/tx/retryTxSender.js +7 -158
- package/lib/types.d.ts +18 -0
- package/lib/types.js +1 -0
- package/lib/user.d.ts +12 -3
- package/lib/user.js +261 -73
- package/package.json +2 -2
- package/src/adminClient.ts +18 -0
- package/src/constants/perpMarkets.ts +20 -0
- package/src/idl/drift.json +73 -8
- package/src/index.ts +1 -0
- package/src/marinade/types.ts +70 -70
- package/src/math/auction.ts +1 -1
- package/src/orderSubscriber/OrderSubscriber.ts +19 -2
- package/src/orderSubscriber/types.ts +11 -0
- package/src/tx/baseTxSender.ts +276 -0
- package/src/tx/fastSingleTxSender.ts +142 -0
- package/src/tx/retryTxSender.ts +9 -235
- package/src/types.ts +19 -0
- package/src/user.ts +455 -119
- package/tests/amm/test.ts +83 -39
- package/tests/dlob/helpers.ts +2 -0
- package/tests/dlob/test.ts +19 -17
package/src/marinade/types.ts
CHANGED
|
@@ -57,7 +57,7 @@ export type MarinadeFinance = {
|
|
|
57
57
|
name: 'msolLeg';
|
|
58
58
|
isMut: false;
|
|
59
59
|
isSigner: false;
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
61
|
];
|
|
62
62
|
},
|
|
63
63
|
{
|
|
@@ -74,7 +74,7 @@ export type MarinadeFinance = {
|
|
|
74
74
|
name: 'rent';
|
|
75
75
|
isMut: false;
|
|
76
76
|
isSigner: false;
|
|
77
|
-
}
|
|
77
|
+
},
|
|
78
78
|
];
|
|
79
79
|
args: [
|
|
80
80
|
{
|
|
@@ -82,7 +82,7 @@ export type MarinadeFinance = {
|
|
|
82
82
|
type: {
|
|
83
83
|
defined: 'InitializeData';
|
|
84
84
|
};
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
86
|
];
|
|
87
87
|
},
|
|
88
88
|
{
|
|
@@ -97,7 +97,7 @@ export type MarinadeFinance = {
|
|
|
97
97
|
name: 'adminAuthority';
|
|
98
98
|
isMut: false;
|
|
99
99
|
isSigner: true;
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
101
|
];
|
|
102
102
|
args: [
|
|
103
103
|
{
|
|
@@ -105,7 +105,7 @@ export type MarinadeFinance = {
|
|
|
105
105
|
type: {
|
|
106
106
|
defined: 'ChangeAuthorityData';
|
|
107
107
|
};
|
|
108
|
-
}
|
|
108
|
+
},
|
|
109
109
|
];
|
|
110
110
|
},
|
|
111
111
|
{
|
|
@@ -155,13 +155,13 @@ export type MarinadeFinance = {
|
|
|
155
155
|
name: 'systemProgram';
|
|
156
156
|
isMut: false;
|
|
157
157
|
isSigner: false;
|
|
158
|
-
}
|
|
158
|
+
},
|
|
159
159
|
];
|
|
160
160
|
args: [
|
|
161
161
|
{
|
|
162
162
|
name: 'score';
|
|
163
163
|
type: 'u32';
|
|
164
|
-
}
|
|
164
|
+
},
|
|
165
165
|
];
|
|
166
166
|
},
|
|
167
167
|
{
|
|
@@ -191,7 +191,7 @@ export type MarinadeFinance = {
|
|
|
191
191
|
name: 'operationalSolAccount';
|
|
192
192
|
isMut: true;
|
|
193
193
|
isSigner: false;
|
|
194
|
-
}
|
|
194
|
+
},
|
|
195
195
|
];
|
|
196
196
|
args: [
|
|
197
197
|
{
|
|
@@ -201,7 +201,7 @@ export type MarinadeFinance = {
|
|
|
201
201
|
{
|
|
202
202
|
name: 'validatorVote';
|
|
203
203
|
type: 'publicKey';
|
|
204
|
-
}
|
|
204
|
+
},
|
|
205
205
|
];
|
|
206
206
|
},
|
|
207
207
|
{
|
|
@@ -221,7 +221,7 @@ export type MarinadeFinance = {
|
|
|
221
221
|
name: 'validatorList';
|
|
222
222
|
isMut: true;
|
|
223
223
|
isSigner: false;
|
|
224
|
-
}
|
|
224
|
+
},
|
|
225
225
|
];
|
|
226
226
|
args: [
|
|
227
227
|
{
|
|
@@ -235,7 +235,7 @@ export type MarinadeFinance = {
|
|
|
235
235
|
{
|
|
236
236
|
name: 'score';
|
|
237
237
|
type: 'u32';
|
|
238
|
-
}
|
|
238
|
+
},
|
|
239
239
|
];
|
|
240
240
|
},
|
|
241
241
|
{
|
|
@@ -250,13 +250,13 @@ export type MarinadeFinance = {
|
|
|
250
250
|
name: 'managerAuthority';
|
|
251
251
|
isMut: false;
|
|
252
252
|
isSigner: true;
|
|
253
|
-
}
|
|
253
|
+
},
|
|
254
254
|
];
|
|
255
255
|
args: [
|
|
256
256
|
{
|
|
257
257
|
name: 'extraRuns';
|
|
258
258
|
type: 'u32';
|
|
259
|
-
}
|
|
259
|
+
},
|
|
260
260
|
];
|
|
261
261
|
},
|
|
262
262
|
{
|
|
@@ -316,13 +316,13 @@ export type MarinadeFinance = {
|
|
|
316
316
|
name: 'tokenProgram';
|
|
317
317
|
isMut: false;
|
|
318
318
|
isSigner: false;
|
|
319
|
-
}
|
|
319
|
+
},
|
|
320
320
|
];
|
|
321
321
|
args: [
|
|
322
322
|
{
|
|
323
323
|
name: 'lamports';
|
|
324
324
|
type: 'u64';
|
|
325
|
-
}
|
|
325
|
+
},
|
|
326
326
|
];
|
|
327
327
|
},
|
|
328
328
|
{
|
|
@@ -402,13 +402,13 @@ export type MarinadeFinance = {
|
|
|
402
402
|
name: 'stakeProgram';
|
|
403
403
|
isMut: false;
|
|
404
404
|
isSigner: false;
|
|
405
|
-
}
|
|
405
|
+
},
|
|
406
406
|
];
|
|
407
407
|
args: [
|
|
408
408
|
{
|
|
409
409
|
name: 'validatorIndex';
|
|
410
410
|
type: 'u32';
|
|
411
|
-
}
|
|
411
|
+
},
|
|
412
412
|
];
|
|
413
413
|
},
|
|
414
414
|
{
|
|
@@ -463,13 +463,13 @@ export type MarinadeFinance = {
|
|
|
463
463
|
name: 'tokenProgram';
|
|
464
464
|
isMut: false;
|
|
465
465
|
isSigner: false;
|
|
466
|
-
}
|
|
466
|
+
},
|
|
467
467
|
];
|
|
468
468
|
args: [
|
|
469
469
|
{
|
|
470
470
|
name: 'msolAmount';
|
|
471
471
|
type: 'u64';
|
|
472
|
-
}
|
|
472
|
+
},
|
|
473
473
|
];
|
|
474
474
|
},
|
|
475
475
|
{
|
|
@@ -519,13 +519,13 @@ export type MarinadeFinance = {
|
|
|
519
519
|
name: 'tokenProgram';
|
|
520
520
|
isMut: false;
|
|
521
521
|
isSigner: false;
|
|
522
|
-
}
|
|
522
|
+
},
|
|
523
523
|
];
|
|
524
524
|
args: [
|
|
525
525
|
{
|
|
526
526
|
name: 'lamports';
|
|
527
527
|
type: 'u64';
|
|
528
|
-
}
|
|
528
|
+
},
|
|
529
529
|
];
|
|
530
530
|
},
|
|
531
531
|
{
|
|
@@ -585,13 +585,13 @@ export type MarinadeFinance = {
|
|
|
585
585
|
name: 'tokenProgram';
|
|
586
586
|
isMut: false;
|
|
587
587
|
isSigner: false;
|
|
588
|
-
}
|
|
588
|
+
},
|
|
589
589
|
];
|
|
590
590
|
args: [
|
|
591
591
|
{
|
|
592
592
|
name: 'tokens';
|
|
593
593
|
type: 'u64';
|
|
594
|
-
}
|
|
594
|
+
},
|
|
595
595
|
];
|
|
596
596
|
},
|
|
597
597
|
{
|
|
@@ -606,7 +606,7 @@ export type MarinadeFinance = {
|
|
|
606
606
|
name: 'adminAuthority';
|
|
607
607
|
isMut: false;
|
|
608
608
|
isSigner: true;
|
|
609
|
-
}
|
|
609
|
+
},
|
|
610
610
|
];
|
|
611
611
|
args: [
|
|
612
612
|
{
|
|
@@ -614,7 +614,7 @@ export type MarinadeFinance = {
|
|
|
614
614
|
type: {
|
|
615
615
|
defined: 'ConfigLpParams';
|
|
616
616
|
};
|
|
617
|
-
}
|
|
617
|
+
},
|
|
618
618
|
];
|
|
619
619
|
},
|
|
620
620
|
{
|
|
@@ -629,7 +629,7 @@ export type MarinadeFinance = {
|
|
|
629
629
|
name: 'adminAuthority';
|
|
630
630
|
isMut: false;
|
|
631
631
|
isSigner: true;
|
|
632
|
-
}
|
|
632
|
+
},
|
|
633
633
|
];
|
|
634
634
|
args: [
|
|
635
635
|
{
|
|
@@ -637,7 +637,7 @@ export type MarinadeFinance = {
|
|
|
637
637
|
type: {
|
|
638
638
|
defined: 'ConfigMarinadeParams';
|
|
639
639
|
};
|
|
640
|
-
}
|
|
640
|
+
},
|
|
641
641
|
];
|
|
642
642
|
},
|
|
643
643
|
{
|
|
@@ -682,13 +682,13 @@ export type MarinadeFinance = {
|
|
|
682
682
|
name: 'tokenProgram';
|
|
683
683
|
isMut: false;
|
|
684
684
|
isSigner: false;
|
|
685
|
-
}
|
|
685
|
+
},
|
|
686
686
|
];
|
|
687
687
|
args: [
|
|
688
688
|
{
|
|
689
689
|
name: 'msolAmount';
|
|
690
690
|
type: 'u64';
|
|
691
|
-
}
|
|
691
|
+
},
|
|
692
692
|
];
|
|
693
693
|
},
|
|
694
694
|
{
|
|
@@ -723,7 +723,7 @@ export type MarinadeFinance = {
|
|
|
723
723
|
name: 'systemProgram';
|
|
724
724
|
isMut: false;
|
|
725
725
|
isSigner: false;
|
|
726
|
-
}
|
|
726
|
+
},
|
|
727
727
|
];
|
|
728
728
|
args: [];
|
|
729
729
|
},
|
|
@@ -799,13 +799,13 @@ export type MarinadeFinance = {
|
|
|
799
799
|
name: 'stakeProgram';
|
|
800
800
|
isMut: false;
|
|
801
801
|
isSigner: false;
|
|
802
|
-
}
|
|
802
|
+
},
|
|
803
803
|
];
|
|
804
804
|
args: [
|
|
805
805
|
{
|
|
806
806
|
name: 'validatorIndex';
|
|
807
807
|
type: 'u32';
|
|
808
|
-
}
|
|
808
|
+
},
|
|
809
809
|
];
|
|
810
810
|
},
|
|
811
811
|
{
|
|
@@ -873,14 +873,14 @@ export type MarinadeFinance = {
|
|
|
873
873
|
name: 'tokenProgram';
|
|
874
874
|
isMut: false;
|
|
875
875
|
isSigner: false;
|
|
876
|
-
}
|
|
876
|
+
},
|
|
877
877
|
];
|
|
878
878
|
},
|
|
879
879
|
{
|
|
880
880
|
name: 'validatorList';
|
|
881
881
|
isMut: true;
|
|
882
882
|
isSigner: false;
|
|
883
|
-
}
|
|
883
|
+
},
|
|
884
884
|
];
|
|
885
885
|
args: [
|
|
886
886
|
{
|
|
@@ -890,7 +890,7 @@ export type MarinadeFinance = {
|
|
|
890
890
|
{
|
|
891
891
|
name: 'validatorIndex';
|
|
892
892
|
type: 'u32';
|
|
893
|
-
}
|
|
893
|
+
},
|
|
894
894
|
];
|
|
895
895
|
},
|
|
896
896
|
{
|
|
@@ -958,7 +958,7 @@ export type MarinadeFinance = {
|
|
|
958
958
|
name: 'tokenProgram';
|
|
959
959
|
isMut: false;
|
|
960
960
|
isSigner: false;
|
|
961
|
-
}
|
|
961
|
+
},
|
|
962
962
|
];
|
|
963
963
|
},
|
|
964
964
|
{
|
|
@@ -970,13 +970,13 @@ export type MarinadeFinance = {
|
|
|
970
970
|
name: 'systemProgram';
|
|
971
971
|
isMut: false;
|
|
972
972
|
isSigner: false;
|
|
973
|
-
}
|
|
973
|
+
},
|
|
974
974
|
];
|
|
975
975
|
args: [
|
|
976
976
|
{
|
|
977
977
|
name: 'stakeIndex';
|
|
978
978
|
type: 'u32';
|
|
979
|
-
}
|
|
979
|
+
},
|
|
980
980
|
];
|
|
981
981
|
},
|
|
982
982
|
{
|
|
@@ -1051,7 +1051,7 @@ export type MarinadeFinance = {
|
|
|
1051
1051
|
name: 'stakeProgram';
|
|
1052
1052
|
isMut: false;
|
|
1053
1053
|
isSigner: false;
|
|
1054
|
-
}
|
|
1054
|
+
},
|
|
1055
1055
|
];
|
|
1056
1056
|
args: [
|
|
1057
1057
|
{
|
|
@@ -1061,7 +1061,7 @@ export type MarinadeFinance = {
|
|
|
1061
1061
|
{
|
|
1062
1062
|
name: 'validatorIndex';
|
|
1063
1063
|
type: 'u32';
|
|
1064
|
-
}
|
|
1064
|
+
},
|
|
1065
1065
|
];
|
|
1066
1066
|
},
|
|
1067
1067
|
{
|
|
@@ -1106,7 +1106,7 @@ export type MarinadeFinance = {
|
|
|
1106
1106
|
name: 'stakeProgram';
|
|
1107
1107
|
isMut: false;
|
|
1108
1108
|
isSigner: false;
|
|
1109
|
-
}
|
|
1109
|
+
},
|
|
1110
1110
|
];
|
|
1111
1111
|
args: [
|
|
1112
1112
|
{
|
|
@@ -1116,7 +1116,7 @@ export type MarinadeFinance = {
|
|
|
1116
1116
|
{
|
|
1117
1117
|
name: 'validatorIndex';
|
|
1118
1118
|
type: 'u32';
|
|
1119
|
-
}
|
|
1119
|
+
},
|
|
1120
1120
|
];
|
|
1121
1121
|
},
|
|
1122
1122
|
{
|
|
@@ -1191,7 +1191,7 @@ export type MarinadeFinance = {
|
|
|
1191
1191
|
name: 'stakeProgram';
|
|
1192
1192
|
isMut: false;
|
|
1193
1193
|
isSigner: false;
|
|
1194
|
-
}
|
|
1194
|
+
},
|
|
1195
1195
|
];
|
|
1196
1196
|
args: [
|
|
1197
1197
|
{
|
|
@@ -1205,7 +1205,7 @@ export type MarinadeFinance = {
|
|
|
1205
1205
|
{
|
|
1206
1206
|
name: 'desiredUnstakeAmount';
|
|
1207
1207
|
type: 'u64';
|
|
1208
|
-
}
|
|
1208
|
+
},
|
|
1209
1209
|
];
|
|
1210
1210
|
},
|
|
1211
1211
|
{
|
|
@@ -1265,7 +1265,7 @@ export type MarinadeFinance = {
|
|
|
1265
1265
|
name: 'stakeProgram';
|
|
1266
1266
|
isMut: false;
|
|
1267
1267
|
isSigner: false;
|
|
1268
|
-
}
|
|
1268
|
+
},
|
|
1269
1269
|
];
|
|
1270
1270
|
args: [
|
|
1271
1271
|
{
|
|
@@ -1279,9 +1279,9 @@ export type MarinadeFinance = {
|
|
|
1279
1279
|
{
|
|
1280
1280
|
name: 'validatorIndex';
|
|
1281
1281
|
type: 'u32';
|
|
1282
|
-
}
|
|
1282
|
+
},
|
|
1283
1283
|
];
|
|
1284
|
-
}
|
|
1284
|
+
},
|
|
1285
1285
|
];
|
|
1286
1286
|
accounts: [
|
|
1287
1287
|
{
|
|
@@ -1361,7 +1361,7 @@ export type MarinadeFinance = {
|
|
|
1361
1361
|
{
|
|
1362
1362
|
name: 'circulatingTicketBalance';
|
|
1363
1363
|
docs: [
|
|
1364
|
-
'total lamports amount of generated and not claimed yet tickets'
|
|
1364
|
+
'total lamports amount of generated and not claimed yet tickets',
|
|
1365
1365
|
];
|
|
1366
1366
|
type: 'u64';
|
|
1367
1367
|
},
|
|
@@ -1384,7 +1384,7 @@ export type MarinadeFinance = {
|
|
|
1384
1384
|
{
|
|
1385
1385
|
name: 'emergencyCoolingDown';
|
|
1386
1386
|
type: 'u64';
|
|
1387
|
-
}
|
|
1387
|
+
},
|
|
1388
1388
|
];
|
|
1389
1389
|
};
|
|
1390
1390
|
},
|
|
@@ -1408,10 +1408,10 @@ export type MarinadeFinance = {
|
|
|
1408
1408
|
{
|
|
1409
1409
|
name: 'createdEpoch';
|
|
1410
1410
|
type: 'u64';
|
|
1411
|
-
}
|
|
1411
|
+
},
|
|
1412
1412
|
];
|
|
1413
1413
|
};
|
|
1414
|
-
}
|
|
1414
|
+
},
|
|
1415
1415
|
];
|
|
1416
1416
|
types: [
|
|
1417
1417
|
{
|
|
@@ -1442,7 +1442,7 @@ export type MarinadeFinance = {
|
|
|
1442
1442
|
{
|
|
1443
1443
|
name: 'lpLiquidityTarget';
|
|
1444
1444
|
docs: [
|
|
1445
|
-
'Liquidity target. If the Liquidity reach this amount, the fee reaches lp_min_discount_fee'
|
|
1445
|
+
'Liquidity target. If the Liquidity reach this amount, the fee reaches lp_min_discount_fee',
|
|
1446
1446
|
];
|
|
1447
1447
|
type: 'u64';
|
|
1448
1448
|
},
|
|
@@ -1478,7 +1478,7 @@ export type MarinadeFinance = {
|
|
|
1478
1478
|
{
|
|
1479
1479
|
name: 'liquiditySolCap';
|
|
1480
1480
|
type: 'u64';
|
|
1481
|
-
}
|
|
1481
|
+
},
|
|
1482
1482
|
];
|
|
1483
1483
|
};
|
|
1484
1484
|
},
|
|
@@ -1506,7 +1506,7 @@ export type MarinadeFinance = {
|
|
|
1506
1506
|
{
|
|
1507
1507
|
name: 'copiedCount';
|
|
1508
1508
|
type: 'u32';
|
|
1509
|
-
}
|
|
1509
|
+
},
|
|
1510
1510
|
];
|
|
1511
1511
|
};
|
|
1512
1512
|
},
|
|
@@ -1530,7 +1530,7 @@ export type MarinadeFinance = {
|
|
|
1530
1530
|
{
|
|
1531
1531
|
name: 'isEmergencyUnstaking';
|
|
1532
1532
|
type: 'u8';
|
|
1533
|
-
}
|
|
1533
|
+
},
|
|
1534
1534
|
];
|
|
1535
1535
|
};
|
|
1536
1536
|
},
|
|
@@ -1560,7 +1560,7 @@ export type MarinadeFinance = {
|
|
|
1560
1560
|
{
|
|
1561
1561
|
name: 'slotsForStakeDelta';
|
|
1562
1562
|
docs: [
|
|
1563
|
-
'set by admin, how much slots before the end of the epoch, stake-delta can start'
|
|
1563
|
+
'set by admin, how much slots before the end of the epoch, stake-delta can start',
|
|
1564
1564
|
];
|
|
1565
1565
|
type: 'u64';
|
|
1566
1566
|
},
|
|
@@ -1569,7 +1569,7 @@ export type MarinadeFinance = {
|
|
|
1569
1569
|
docs: [
|
|
1570
1570
|
'Marks the start of stake-delta operations, meaning that if somebody starts a delayed-unstake ticket',
|
|
1571
1571
|
'after this var is set with epoch_num the ticket will have epoch_created = current_epoch+1',
|
|
1572
|
-
'(the user must wait one more epoch, because their unstake-delta will be execute in this epoch)'
|
|
1572
|
+
'(the user must wait one more epoch, because their unstake-delta will be execute in this epoch)',
|
|
1573
1573
|
];
|
|
1574
1574
|
type: 'u64';
|
|
1575
1575
|
},
|
|
@@ -1581,10 +1581,10 @@ export type MarinadeFinance = {
|
|
|
1581
1581
|
name: 'extraStakeDeltaRuns';
|
|
1582
1582
|
docs: [
|
|
1583
1583
|
'can be set by validator-manager-auth to allow a second run of stake-delta to stake late stakers in the last minute of the epoch',
|
|
1584
|
-
"so we maximize user's rewards"
|
|
1584
|
+
"so we maximize user's rewards",
|
|
1585
1585
|
];
|
|
1586
1586
|
type: 'u32';
|
|
1587
|
-
}
|
|
1587
|
+
},
|
|
1588
1588
|
];
|
|
1589
1589
|
};
|
|
1590
1590
|
},
|
|
@@ -1614,7 +1614,7 @@ export type MarinadeFinance = {
|
|
|
1614
1614
|
{
|
|
1615
1615
|
name: 'duplicationFlagBumpSeed';
|
|
1616
1616
|
type: 'u8';
|
|
1617
|
-
}
|
|
1617
|
+
},
|
|
1618
1618
|
];
|
|
1619
1619
|
};
|
|
1620
1620
|
},
|
|
@@ -1645,10 +1645,10 @@ export type MarinadeFinance = {
|
|
|
1645
1645
|
{
|
|
1646
1646
|
name: 'autoAddValidatorEnabled';
|
|
1647
1647
|
docs: [
|
|
1648
|
-
'allow & auto-add validator when a user deposits a stake-account of a non-listed validator'
|
|
1648
|
+
'allow & auto-add validator when a user deposits a stake-account of a non-listed validator',
|
|
1649
1649
|
];
|
|
1650
1650
|
type: 'u8';
|
|
1651
|
-
}
|
|
1651
|
+
},
|
|
1652
1652
|
];
|
|
1653
1653
|
};
|
|
1654
1654
|
},
|
|
@@ -1660,7 +1660,7 @@ export type MarinadeFinance = {
|
|
|
1660
1660
|
{
|
|
1661
1661
|
name: 'basisPoints';
|
|
1662
1662
|
type: 'u32';
|
|
1663
|
-
}
|
|
1663
|
+
},
|
|
1664
1664
|
];
|
|
1665
1665
|
};
|
|
1666
1666
|
},
|
|
@@ -1704,7 +1704,7 @@ export type MarinadeFinance = {
|
|
|
1704
1704
|
{
|
|
1705
1705
|
name: 'slotsForStakeDelta';
|
|
1706
1706
|
type: 'u64';
|
|
1707
|
-
}
|
|
1707
|
+
},
|
|
1708
1708
|
];
|
|
1709
1709
|
};
|
|
1710
1710
|
},
|
|
@@ -1734,7 +1734,7 @@ export type MarinadeFinance = {
|
|
|
1734
1734
|
type: {
|
|
1735
1735
|
defined: 'Fee';
|
|
1736
1736
|
};
|
|
1737
|
-
}
|
|
1737
|
+
},
|
|
1738
1738
|
];
|
|
1739
1739
|
};
|
|
1740
1740
|
},
|
|
@@ -1766,7 +1766,7 @@ export type MarinadeFinance = {
|
|
|
1766
1766
|
type: {
|
|
1767
1767
|
option: 'publicKey';
|
|
1768
1768
|
};
|
|
1769
|
-
}
|
|
1769
|
+
},
|
|
1770
1770
|
];
|
|
1771
1771
|
};
|
|
1772
1772
|
},
|
|
@@ -1804,7 +1804,7 @@ export type MarinadeFinance = {
|
|
|
1804
1804
|
defined: 'Fee';
|
|
1805
1805
|
};
|
|
1806
1806
|
};
|
|
1807
|
-
}
|
|
1807
|
+
},
|
|
1808
1808
|
];
|
|
1809
1809
|
};
|
|
1810
1810
|
},
|
|
@@ -1862,7 +1862,7 @@ export type MarinadeFinance = {
|
|
|
1862
1862
|
type: {
|
|
1863
1863
|
option: 'bool';
|
|
1864
1864
|
};
|
|
1865
|
-
}
|
|
1865
|
+
},
|
|
1866
1866
|
];
|
|
1867
1867
|
};
|
|
1868
1868
|
},
|
|
@@ -1954,10 +1954,10 @@ export type MarinadeFinance = {
|
|
|
1954
1954
|
},
|
|
1955
1955
|
{
|
|
1956
1956
|
name: 'InvalidValidator';
|
|
1957
|
-
}
|
|
1957
|
+
},
|
|
1958
1958
|
];
|
|
1959
1959
|
};
|
|
1960
|
-
}
|
|
1960
|
+
},
|
|
1961
1961
|
];
|
|
1962
1962
|
};
|
|
1963
1963
|
|
package/src/math/auction.ts
CHANGED
|
@@ -79,7 +79,7 @@ export function getAuctionPriceForOracleOffsetAuction(
|
|
|
79
79
|
const deltaNumerator = BN.min(slotsElapsed, deltaDenominator);
|
|
80
80
|
|
|
81
81
|
if (deltaDenominator.eq(ZERO)) {
|
|
82
|
-
return
|
|
82
|
+
return oraclePrice.add(order.auctionEndPrice);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
let priceOffsetDelta;
|
|
@@ -4,14 +4,17 @@ import { getUserFilter, getUserWithOrderFilter } from '../memcmp';
|
|
|
4
4
|
import { PublicKey, RpcResponseAndContext } from '@solana/web3.js';
|
|
5
5
|
import { Buffer } from 'buffer';
|
|
6
6
|
import { DLOB } from '../dlob/DLOB';
|
|
7
|
-
import { OrderSubscriberConfig } from './types';
|
|
7
|
+
import { OrderSubscriberConfig, OrderSubscriberEvents } from './types';
|
|
8
8
|
import { PollingSubscription } from './PollingSubscription';
|
|
9
9
|
import { WebsocketSubscription } from './WebsocketSubscription';
|
|
10
|
+
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
11
|
+
import { EventEmitter } from 'events';
|
|
10
12
|
|
|
11
13
|
export class OrderSubscriber {
|
|
12
14
|
driftClient: DriftClient;
|
|
13
15
|
usersAccounts = new Map<string, { slot: number; userAccount: UserAccount }>();
|
|
14
16
|
subscription: PollingSubscription | WebsocketSubscription;
|
|
17
|
+
eventEmitter: StrictEventEmitter<EventEmitter, OrderSubscriberEvents>;
|
|
15
18
|
|
|
16
19
|
fetchPromise?: Promise<void>;
|
|
17
20
|
fetchPromiseResolver: () => void;
|
|
@@ -29,6 +32,7 @@ export class OrderSubscriber {
|
|
|
29
32
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
30
33
|
});
|
|
31
34
|
}
|
|
35
|
+
this.eventEmitter = new EventEmitter();
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
public async subscribe(): Promise<void> {
|
|
@@ -106,7 +110,20 @@ export class OrderSubscriber {
|
|
|
106
110
|
'User',
|
|
107
111
|
buffer
|
|
108
112
|
) as UserAccount;
|
|
109
|
-
|
|
113
|
+
const newOrders = userAccount.orders.filter(
|
|
114
|
+
(order) =>
|
|
115
|
+
order.slot.toNumber() > (slotAndUserAccount?.slot ?? 0) &&
|
|
116
|
+
order.slot.toNumber() <= slot
|
|
117
|
+
);
|
|
118
|
+
if (newOrders.length > 0) {
|
|
119
|
+
this.eventEmitter.emit(
|
|
120
|
+
'onUpdate',
|
|
121
|
+
userAccount,
|
|
122
|
+
newOrders,
|
|
123
|
+
new PublicKey(key),
|
|
124
|
+
slot
|
|
125
|
+
);
|
|
126
|
+
}
|
|
110
127
|
if (userAccount.hasOpenOrder) {
|
|
111
128
|
this.usersAccounts.set(key, { slot, userAccount });
|
|
112
129
|
} else {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { Order, UserAccount } from '../types';
|
|
1
3
|
import { DriftClient } from '../driftClient';
|
|
2
4
|
|
|
3
5
|
export type OrderSubscriberConfig = {
|
|
@@ -12,3 +14,12 @@ export type OrderSubscriberConfig = {
|
|
|
12
14
|
skipInitialLoad?: boolean;
|
|
13
15
|
};
|
|
14
16
|
};
|
|
17
|
+
|
|
18
|
+
export interface OrderSubscriberEvents {
|
|
19
|
+
onUpdate: (
|
|
20
|
+
account: UserAccount,
|
|
21
|
+
updatedOrders: Order[],
|
|
22
|
+
pubkey: PublicKey,
|
|
23
|
+
slot: number
|
|
24
|
+
) => void;
|
|
25
|
+
}
|