@drift-labs/sdk 2.10.0-beta.1 → 2.10.0-beta.3
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/pollingDriftClientAccountSubscriber.js +12 -3
- package/lib/accounts/types.d.ts +5 -4
- package/lib/adminClient.js +96 -34
- 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 +4 -4
- package/lib/dlob/DLOBNode.d.ts +2 -2
- package/lib/dlob/DLOBOrders.d.ts +2 -2
- package/lib/dlob/NodeList.d.ts +1 -1
- package/lib/driftClient.d.ts +4 -3
- package/lib/driftClient.js +105 -64
- package/lib/driftClientConfig.d.ts +3 -3
- package/lib/events/fetchLogs.d.ts +2 -2
- package/lib/events/types.d.ts +13 -13
- package/lib/factory/bigNum.js +4 -4
- package/lib/idl/drift.json +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/math/amm.d.ts +1 -1
- package/lib/math/amm.js +15 -6
- package/lib/math/oracles.js +2 -2
- package/lib/math/repeg.d.ts +1 -1
- package/lib/math/repeg.js +46 -19
- package/lib/math/trade.d.ts +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/testClient.d.ts +8 -0
- package/lib/testClient.js +22 -0
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/types.d.ts +1 -1
- package/lib/types.d.ts +43 -43
- package/lib/user.d.ts +1 -0
- package/lib/user.js +10 -6
- package/lib/userConfig.d.ts +2 -2
- package/lib/userMap/userMap.js +3 -0
- package/lib/userMap/userStatsMap.js +3 -0
- package/lib/userStatsConfig.d.ts +2 -2
- package/package.json +1 -1
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +26 -3
- package/src/adminClient.ts +301 -169
- package/src/driftClient.ts +199 -118
- package/src/driftClientConfig.ts +1 -1
- package/src/idl/drift.json +1 -1
- package/src/index.ts +1 -0
- package/src/math/amm.ts +27 -12
- package/src/math/oracles.ts +6 -4
- package/src/math/repeg.ts +54 -26
- package/src/testClient.ts +40 -0
- package/src/user.ts +5 -0
- package/src/userMap/userMap.ts +2 -0
- package/src/userMap/userStatsMap.ts +2 -0
- package/src/assert/assert.js +0 -9
- package/src/examples/makeTradeExample.js +0 -157
- package/src/token/index.js +0 -38
- package/src/tx/types.js +0 -2
- package/src/tx/utils.js +0 -17
- package/src/util/computeUnits.js +0 -27
- package/src/util/getTokenAddress.js +0 -9
- package/src/util/promiseTimeout.js +0 -14
- package/src/util/tps.js +0 -27
package/src/adminClient.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class AdminClient extends DriftClient {
|
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
const { txSig: initializeTxSig } = await
|
|
63
|
+
const { txSig: initializeTxSig } = await super.sendTransaction(
|
|
64
64
|
initializeTx,
|
|
65
65
|
[],
|
|
66
66
|
this.opts
|
|
@@ -132,7 +132,7 @@ export class AdminClient extends DriftClient {
|
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
134
|
|
|
135
|
-
const { txSig } = await this.
|
|
135
|
+
const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
|
|
136
136
|
|
|
137
137
|
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
138
138
|
await this.accountSubscriber.addOracle({
|
|
@@ -158,7 +158,7 @@ export class AdminClient extends DriftClient {
|
|
|
158
158
|
serumMarket
|
|
159
159
|
);
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
const tx = await this.program.transaction.initializeSerumFulfillmentConfig(
|
|
162
162
|
marketIndex,
|
|
163
163
|
{
|
|
164
164
|
accounts: {
|
|
@@ -176,6 +176,9 @@ export class AdminClient extends DriftClient {
|
|
|
176
176
|
},
|
|
177
177
|
}
|
|
178
178
|
);
|
|
179
|
+
|
|
180
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
181
|
+
return txSig;
|
|
179
182
|
}
|
|
180
183
|
|
|
181
184
|
public async initializePerpMarket(
|
|
@@ -191,9 +194,10 @@ export class AdminClient extends DriftClient {
|
|
|
191
194
|
activeStatus = true,
|
|
192
195
|
name = DEFAULT_MARKET_NAME
|
|
193
196
|
): Promise<TransactionSignature> {
|
|
197
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
194
198
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
195
199
|
this.program.programId,
|
|
196
|
-
|
|
200
|
+
currentPerpMarketIndex
|
|
197
201
|
);
|
|
198
202
|
|
|
199
203
|
const nameBuffer = encodeName(name);
|
|
@@ -220,15 +224,17 @@ export class AdminClient extends DriftClient {
|
|
|
220
224
|
},
|
|
221
225
|
}
|
|
222
226
|
);
|
|
223
|
-
const { txSig } = await this.
|
|
227
|
+
const { txSig } = await this.sendTransaction(
|
|
224
228
|
initializeMarketTx,
|
|
225
229
|
[],
|
|
226
230
|
this.opts
|
|
227
231
|
);
|
|
228
232
|
|
|
229
|
-
|
|
230
|
-
this.
|
|
231
|
-
|
|
233
|
+
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
234
|
+
await this.fetchAccounts();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
await this.accountSubscriber.addPerpMarket(currentPerpMarketIndex);
|
|
232
238
|
await this.accountSubscriber.addOracle({
|
|
233
239
|
source: oracleSource,
|
|
234
240
|
publicKey: priceOracle,
|
|
@@ -252,7 +258,7 @@ export class AdminClient extends DriftClient {
|
|
|
252
258
|
sqrtK = squareRootBN(baseAssetReserve.mul(quoteAssetReserve));
|
|
253
259
|
}
|
|
254
260
|
|
|
255
|
-
|
|
261
|
+
const tx = await this.program.transaction.moveAmmPrice(
|
|
256
262
|
baseAssetReserve,
|
|
257
263
|
quoteAssetReserve,
|
|
258
264
|
sqrtK,
|
|
@@ -264,13 +270,16 @@ export class AdminClient extends DriftClient {
|
|
|
264
270
|
},
|
|
265
271
|
}
|
|
266
272
|
);
|
|
273
|
+
|
|
274
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
275
|
+
return txSig;
|
|
267
276
|
}
|
|
268
277
|
|
|
269
278
|
public async updateK(
|
|
270
279
|
perpMarketIndex: number,
|
|
271
280
|
sqrtK: BN
|
|
272
281
|
): Promise<TransactionSignature> {
|
|
273
|
-
|
|
282
|
+
const tx = await this.program.transaction.updateK(sqrtK, {
|
|
274
283
|
accounts: {
|
|
275
284
|
state: await this.getStatePublicKey(),
|
|
276
285
|
admin: this.wallet.publicKey,
|
|
@@ -281,6 +290,9 @@ export class AdminClient extends DriftClient {
|
|
|
281
290
|
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
282
291
|
},
|
|
283
292
|
});
|
|
293
|
+
|
|
294
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
295
|
+
return txSig;
|
|
284
296
|
}
|
|
285
297
|
|
|
286
298
|
public async updatePerpMarketConcentrationScale(
|
|
@@ -329,7 +341,7 @@ export class AdminClient extends DriftClient {
|
|
|
329
341
|
perpMarketIndex
|
|
330
342
|
);
|
|
331
343
|
|
|
332
|
-
|
|
344
|
+
const tx = await this.program.transaction.moveAmmPrice(
|
|
333
345
|
newBaseAssetAmount,
|
|
334
346
|
newQuoteAssetAmount,
|
|
335
347
|
perpMarket.amm.sqrtK,
|
|
@@ -341,6 +353,9 @@ export class AdminClient extends DriftClient {
|
|
|
341
353
|
},
|
|
342
354
|
}
|
|
343
355
|
);
|
|
356
|
+
|
|
357
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
358
|
+
return txSig;
|
|
344
359
|
}
|
|
345
360
|
|
|
346
361
|
public async repegAmmCurve(
|
|
@@ -353,7 +368,7 @@ export class AdminClient extends DriftClient {
|
|
|
353
368
|
);
|
|
354
369
|
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
355
370
|
|
|
356
|
-
|
|
371
|
+
const tx = await this.program.transaction.repegAmmCurve(newPeg, {
|
|
357
372
|
accounts: {
|
|
358
373
|
state: await this.getStatePublicKey(),
|
|
359
374
|
admin: this.wallet.publicKey,
|
|
@@ -361,6 +376,8 @@ export class AdminClient extends DriftClient {
|
|
|
361
376
|
perpMarket: perpMarketPublicKey,
|
|
362
377
|
},
|
|
363
378
|
});
|
|
379
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
380
|
+
return txSig;
|
|
364
381
|
}
|
|
365
382
|
|
|
366
383
|
public async updatePerpMarketAmmOracleTwap(
|
|
@@ -408,30 +425,39 @@ export class AdminClient extends DriftClient {
|
|
|
408
425
|
): Promise<TransactionSignature> {
|
|
409
426
|
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
410
427
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
this.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
428
|
+
const tx = await this.program.transaction.depositIntoPerpMarketFeePool(
|
|
429
|
+
amount,
|
|
430
|
+
{
|
|
431
|
+
accounts: {
|
|
432
|
+
admin: this.wallet.publicKey,
|
|
433
|
+
state: await this.getStatePublicKey(),
|
|
434
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
435
|
+
this.program.programId,
|
|
436
|
+
perpMarketIndex
|
|
437
|
+
),
|
|
438
|
+
sourceVault,
|
|
439
|
+
driftSigner: this.getSignerPublicKey(),
|
|
440
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
441
|
+
spotMarketVault: spotMarket.vault,
|
|
442
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
443
|
+
},
|
|
444
|
+
}
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
448
|
+
return txSig;
|
|
426
449
|
}
|
|
427
450
|
|
|
428
451
|
public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
|
|
429
|
-
|
|
452
|
+
const tx = await this.program.transaction.updateAdmin(admin, {
|
|
430
453
|
accounts: {
|
|
431
454
|
admin: this.wallet.publicKey,
|
|
432
455
|
state: await this.getStatePublicKey(),
|
|
433
456
|
},
|
|
434
457
|
});
|
|
458
|
+
|
|
459
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
460
|
+
return txSig;
|
|
435
461
|
}
|
|
436
462
|
|
|
437
463
|
public async updatePerpMarketCurveUpdateIntensity(
|
|
@@ -461,7 +487,7 @@ export class AdminClient extends DriftClient {
|
|
|
461
487
|
marginRatioInitial: number,
|
|
462
488
|
marginRatioMaintenance: number
|
|
463
489
|
): Promise<TransactionSignature> {
|
|
464
|
-
|
|
490
|
+
const tx = await this.program.transaction.updatePerpMarketMarginRatio(
|
|
465
491
|
marginRatioInitial,
|
|
466
492
|
marginRatioMaintenance,
|
|
467
493
|
{
|
|
@@ -475,6 +501,9 @@ export class AdminClient extends DriftClient {
|
|
|
475
501
|
},
|
|
476
502
|
}
|
|
477
503
|
);
|
|
504
|
+
|
|
505
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
506
|
+
return txSig;
|
|
478
507
|
}
|
|
479
508
|
|
|
480
509
|
public async updatePerpMarketImfFactor(
|
|
@@ -502,32 +531,44 @@ export class AdminClient extends DriftClient {
|
|
|
502
531
|
perpMarketIndex: number,
|
|
503
532
|
baseSpread: number
|
|
504
533
|
): Promise<TransactionSignature> {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
this.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
534
|
+
const tx = await this.program.transaction.updatePerpMarketBaseSpread(
|
|
535
|
+
baseSpread,
|
|
536
|
+
{
|
|
537
|
+
accounts: {
|
|
538
|
+
admin: this.wallet.publicKey,
|
|
539
|
+
state: await this.getStatePublicKey(),
|
|
540
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
541
|
+
this.program.programId,
|
|
542
|
+
perpMarketIndex
|
|
543
|
+
),
|
|
544
|
+
},
|
|
545
|
+
}
|
|
546
|
+
);
|
|
547
|
+
|
|
548
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
549
|
+
return txSig;
|
|
515
550
|
}
|
|
516
551
|
|
|
517
552
|
public async updateAmmJitIntensity(
|
|
518
553
|
perpMarketIndex: number,
|
|
519
554
|
ammJitIntensity: number
|
|
520
555
|
): Promise<TransactionSignature> {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
this.
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
556
|
+
const tx = await this.program.transaction.updateAmmJitIntensity(
|
|
557
|
+
ammJitIntensity,
|
|
558
|
+
{
|
|
559
|
+
accounts: {
|
|
560
|
+
admin: this.wallet.publicKey,
|
|
561
|
+
state: await this.getStatePublicKey(),
|
|
562
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
563
|
+
this.program.programId,
|
|
564
|
+
perpMarketIndex
|
|
565
|
+
),
|
|
566
|
+
},
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
571
|
+
return txSig;
|
|
531
572
|
}
|
|
532
573
|
|
|
533
574
|
public async updatePerpMarketName(
|
|
@@ -536,7 +577,7 @@ export class AdminClient extends DriftClient {
|
|
|
536
577
|
): Promise<TransactionSignature> {
|
|
537
578
|
const nameBuffer = encodeName(name);
|
|
538
579
|
|
|
539
|
-
|
|
580
|
+
const tx = await this.program.transaction.updatePerpMarketName(nameBuffer, {
|
|
540
581
|
accounts: {
|
|
541
582
|
admin: this.wallet.publicKey,
|
|
542
583
|
state: await this.getStatePublicKey(),
|
|
@@ -546,6 +587,9 @@ export class AdminClient extends DriftClient {
|
|
|
546
587
|
),
|
|
547
588
|
},
|
|
548
589
|
});
|
|
590
|
+
|
|
591
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
592
|
+
return txSig;
|
|
549
593
|
}
|
|
550
594
|
|
|
551
595
|
public async updateSpotMarketName(
|
|
@@ -587,23 +631,32 @@ export class AdminClient extends DriftClient {
|
|
|
587
631
|
public async updatePerpFeeStructure(
|
|
588
632
|
feeStructure: FeeStructure
|
|
589
633
|
): Promise<TransactionSignature> {
|
|
590
|
-
|
|
634
|
+
const tx = this.program.transaction.updatePerpFeeStructure(feeStructure, {
|
|
591
635
|
accounts: {
|
|
592
636
|
admin: this.wallet.publicKey,
|
|
593
637
|
state: await this.getStatePublicKey(),
|
|
594
638
|
},
|
|
595
639
|
});
|
|
640
|
+
|
|
641
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
642
|
+
return txSig;
|
|
596
643
|
}
|
|
597
644
|
|
|
598
645
|
public async updateSpotFeeStructure(
|
|
599
646
|
feeStructure: FeeStructure
|
|
600
647
|
): Promise<TransactionSignature> {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
648
|
+
const tx = await this.program.transaction.updateSpotFeeStructure(
|
|
649
|
+
feeStructure,
|
|
650
|
+
{
|
|
651
|
+
accounts: {
|
|
652
|
+
admin: this.wallet.publicKey,
|
|
653
|
+
state: await this.getStatePublicKey(),
|
|
654
|
+
},
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
659
|
+
return txSig;
|
|
607
660
|
}
|
|
608
661
|
|
|
609
662
|
public async updateInitialPctToLiquidate(
|
|
@@ -637,12 +690,18 @@ export class AdminClient extends DriftClient {
|
|
|
637
690
|
public async updateOracleGuardRails(
|
|
638
691
|
oracleGuardRails: OracleGuardRails
|
|
639
692
|
): Promise<TransactionSignature> {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
693
|
+
const tx = await this.program.transaction.updateOracleGuardRails(
|
|
694
|
+
oracleGuardRails,
|
|
695
|
+
{
|
|
696
|
+
accounts: {
|
|
697
|
+
admin: this.wallet.publicKey,
|
|
698
|
+
state: await this.getStatePublicKey(),
|
|
699
|
+
},
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
|
|
703
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
704
|
+
return txSig;
|
|
646
705
|
}
|
|
647
706
|
|
|
648
707
|
public async updateStateSettlementDuration(
|
|
@@ -663,7 +722,7 @@ export class AdminClient extends DriftClient {
|
|
|
663
722
|
spotMarketIndex: number,
|
|
664
723
|
withdrawGuardThreshold: BN
|
|
665
724
|
): Promise<TransactionSignature> {
|
|
666
|
-
|
|
725
|
+
const tx = await this.program.transaction.updateWithdrawGuardThreshold(
|
|
667
726
|
withdrawGuardThreshold,
|
|
668
727
|
{
|
|
669
728
|
accounts: {
|
|
@@ -676,6 +735,9 @@ export class AdminClient extends DriftClient {
|
|
|
676
735
|
},
|
|
677
736
|
}
|
|
678
737
|
);
|
|
738
|
+
|
|
739
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
740
|
+
return txSig;
|
|
679
741
|
}
|
|
680
742
|
|
|
681
743
|
public async updateSpotMarketIfFactor(
|
|
@@ -683,7 +745,7 @@ export class AdminClient extends DriftClient {
|
|
|
683
745
|
userIfFactor: BN,
|
|
684
746
|
totalIfFactor: BN
|
|
685
747
|
): Promise<TransactionSignature> {
|
|
686
|
-
|
|
748
|
+
const tx = await this.program.transaction.updateSpotMarketIfFactor(
|
|
687
749
|
spotMarketIndex,
|
|
688
750
|
userIfFactor,
|
|
689
751
|
totalIfFactor,
|
|
@@ -698,32 +760,39 @@ export class AdminClient extends DriftClient {
|
|
|
698
760
|
},
|
|
699
761
|
}
|
|
700
762
|
);
|
|
763
|
+
|
|
764
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
765
|
+
return txSig;
|
|
701
766
|
}
|
|
702
767
|
|
|
703
768
|
public async updateSpotMarketRevenueSettlePeriod(
|
|
704
769
|
spotMarketIndex: number,
|
|
705
770
|
revenueSettlePeriod: BN
|
|
706
771
|
): Promise<TransactionSignature> {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
772
|
+
const tx =
|
|
773
|
+
await this.program.transaction.updateSpotMarketRevenueSettlePeriod(
|
|
774
|
+
revenueSettlePeriod,
|
|
775
|
+
{
|
|
776
|
+
accounts: {
|
|
777
|
+
admin: this.wallet.publicKey,
|
|
778
|
+
state: await this.getStatePublicKey(),
|
|
779
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
780
|
+
this.program.programId,
|
|
781
|
+
spotMarketIndex
|
|
782
|
+
),
|
|
783
|
+
},
|
|
784
|
+
}
|
|
785
|
+
);
|
|
786
|
+
|
|
787
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
788
|
+
return txSig;
|
|
720
789
|
}
|
|
721
790
|
|
|
722
791
|
public async updateSpotMarketMaxTokenDeposits(
|
|
723
792
|
spotMarketIndex: number,
|
|
724
793
|
maxTokenDeposits: BN
|
|
725
794
|
): Promise<TransactionSignature> {
|
|
726
|
-
|
|
795
|
+
const tx = this.program.transaction.updateSpotMarketMaxTokenDeposits(
|
|
727
796
|
maxTokenDeposits,
|
|
728
797
|
{
|
|
729
798
|
accounts: {
|
|
@@ -736,36 +805,49 @@ export class AdminClient extends DriftClient {
|
|
|
736
805
|
},
|
|
737
806
|
}
|
|
738
807
|
);
|
|
808
|
+
|
|
809
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
810
|
+
return txSig;
|
|
739
811
|
}
|
|
740
812
|
|
|
741
813
|
public async updateInsuranceFundUnstakingPeriod(
|
|
742
814
|
spotMarketIndex: number,
|
|
743
815
|
insuranceWithdrawEscrowPeriod: BN
|
|
744
816
|
): Promise<TransactionSignature> {
|
|
745
|
-
|
|
746
|
-
|
|
817
|
+
const tx =
|
|
818
|
+
await this.program.transaction.updateInsuranceFundUnstakingPeriod(
|
|
819
|
+
insuranceWithdrawEscrowPeriod,
|
|
820
|
+
{
|
|
821
|
+
accounts: {
|
|
822
|
+
admin: this.wallet.publicKey,
|
|
823
|
+
state: await this.getStatePublicKey(),
|
|
824
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
825
|
+
this.program.programId,
|
|
826
|
+
spotMarketIndex
|
|
827
|
+
),
|
|
828
|
+
},
|
|
829
|
+
}
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
833
|
+
return txSig;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
public async updateLpCooldownTime(
|
|
837
|
+
cooldownTime: BN
|
|
838
|
+
): Promise<TransactionSignature> {
|
|
839
|
+
const tx = await this.program.transaction.updateLpCooldownTime(
|
|
840
|
+
cooldownTime,
|
|
747
841
|
{
|
|
748
842
|
accounts: {
|
|
749
843
|
admin: this.wallet.publicKey,
|
|
750
844
|
state: await this.getStatePublicKey(),
|
|
751
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
752
|
-
this.program.programId,
|
|
753
|
-
spotMarketIndex
|
|
754
|
-
),
|
|
755
845
|
},
|
|
756
846
|
}
|
|
757
847
|
);
|
|
758
|
-
}
|
|
759
848
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
): Promise<TransactionSignature> {
|
|
763
|
-
return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
|
|
764
|
-
accounts: {
|
|
765
|
-
admin: this.wallet.publicKey,
|
|
766
|
-
state: await this.getStatePublicKey(),
|
|
767
|
-
},
|
|
768
|
-
});
|
|
849
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
850
|
+
return txSig;
|
|
769
851
|
}
|
|
770
852
|
|
|
771
853
|
public async updatePerpMarketOracle(
|
|
@@ -773,27 +855,9 @@ export class AdminClient extends DriftClient {
|
|
|
773
855
|
oracle: PublicKey,
|
|
774
856
|
oracleSource: OracleSource
|
|
775
857
|
): Promise<TransactionSignature> {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
state: await this.getStatePublicKey(),
|
|
780
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
781
|
-
this.program.programId,
|
|
782
|
-
perpMarketIndex
|
|
783
|
-
),
|
|
784
|
-
oracle: oracle,
|
|
785
|
-
},
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
public async updatePerpMarketStepSizeAndTickSize(
|
|
790
|
-
perpMarketIndex: number,
|
|
791
|
-
stepSize: BN,
|
|
792
|
-
tickSize: BN
|
|
793
|
-
): Promise<TransactionSignature> {
|
|
794
|
-
return await this.program.rpc.updatePerpMarketStepSizeAndTickSize(
|
|
795
|
-
stepSize,
|
|
796
|
-
tickSize,
|
|
858
|
+
const tx = await this.program.transaction.updatePerpMarketOracle(
|
|
859
|
+
oracle,
|
|
860
|
+
oracleSource,
|
|
797
861
|
{
|
|
798
862
|
accounts: {
|
|
799
863
|
admin: this.wallet.publicKey,
|
|
@@ -802,9 +866,38 @@ export class AdminClient extends DriftClient {
|
|
|
802
866
|
this.program.programId,
|
|
803
867
|
perpMarketIndex
|
|
804
868
|
),
|
|
869
|
+
oracle: oracle,
|
|
805
870
|
},
|
|
806
871
|
}
|
|
807
872
|
);
|
|
873
|
+
|
|
874
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
875
|
+
return txSig;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
public async updatePerpMarketStepSizeAndTickSize(
|
|
879
|
+
perpMarketIndex: number,
|
|
880
|
+
stepSize: BN,
|
|
881
|
+
tickSize: BN
|
|
882
|
+
): Promise<TransactionSignature> {
|
|
883
|
+
const tx =
|
|
884
|
+
await this.program.transaction.updatePerpMarketStepSizeAndTickSize(
|
|
885
|
+
stepSize,
|
|
886
|
+
tickSize,
|
|
887
|
+
{
|
|
888
|
+
accounts: {
|
|
889
|
+
admin: this.wallet.publicKey,
|
|
890
|
+
state: await this.getStatePublicKey(),
|
|
891
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
892
|
+
this.program.programId,
|
|
893
|
+
perpMarketIndex
|
|
894
|
+
),
|
|
895
|
+
},
|
|
896
|
+
}
|
|
897
|
+
);
|
|
898
|
+
|
|
899
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
900
|
+
return txSig;
|
|
808
901
|
}
|
|
809
902
|
|
|
810
903
|
public async updatePerpMarketMinOrderSize(
|
|
@@ -942,23 +1035,32 @@ export class AdminClient extends DriftClient {
|
|
|
942
1035
|
public async updateWhitelistMint(
|
|
943
1036
|
whitelistMint?: PublicKey
|
|
944
1037
|
): Promise<TransactionSignature> {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1038
|
+
const tx = await this.program.transaction.updateWhitelistMint(
|
|
1039
|
+
whitelistMint,
|
|
1040
|
+
{
|
|
1041
|
+
accounts: {
|
|
1042
|
+
admin: this.wallet.publicKey,
|
|
1043
|
+
state: await this.getStatePublicKey(),
|
|
1044
|
+
},
|
|
1045
|
+
}
|
|
1046
|
+
);
|
|
1047
|
+
|
|
1048
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1049
|
+
return txSig;
|
|
951
1050
|
}
|
|
952
1051
|
|
|
953
1052
|
public async updateDiscountMint(
|
|
954
1053
|
discountMint: PublicKey
|
|
955
1054
|
): Promise<TransactionSignature> {
|
|
956
|
-
|
|
1055
|
+
const tx = await this.program.transaction.updateDiscountMint(discountMint, {
|
|
957
1056
|
accounts: {
|
|
958
1057
|
admin: this.wallet.publicKey,
|
|
959
1058
|
state: await this.getStatePublicKey(),
|
|
960
1059
|
},
|
|
961
1060
|
});
|
|
1061
|
+
|
|
1062
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1063
|
+
return txSig;
|
|
962
1064
|
}
|
|
963
1065
|
|
|
964
1066
|
public async updateSpotMarketMarginWeights(
|
|
@@ -1015,75 +1117,105 @@ export class AdminClient extends DriftClient {
|
|
|
1015
1117
|
spotMarketIndex: number,
|
|
1016
1118
|
assetTier: AssetTier
|
|
1017
1119
|
): Promise<TransactionSignature> {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
this.
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1120
|
+
const tx = await this.program.transaction.updateSpotMarketAssetTier(
|
|
1121
|
+
assetTier,
|
|
1122
|
+
{
|
|
1123
|
+
accounts: {
|
|
1124
|
+
admin: this.wallet.publicKey,
|
|
1125
|
+
state: await this.getStatePublicKey(),
|
|
1126
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1127
|
+
this.program.programId,
|
|
1128
|
+
spotMarketIndex
|
|
1129
|
+
),
|
|
1130
|
+
},
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
1133
|
+
|
|
1134
|
+
const { txSig } = await this.sendTransaction(tx);
|
|
1135
|
+
return txSig;
|
|
1028
1136
|
}
|
|
1029
1137
|
|
|
1030
1138
|
public async updateSpotMarketStatus(
|
|
1031
1139
|
spotMarketIndex: number,
|
|
1032
1140
|
marketStatus: MarketStatus
|
|
1033
1141
|
): Promise<TransactionSignature> {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
this.
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1142
|
+
const tx = await this.program.transaction.updateSpotMarketStatus(
|
|
1143
|
+
marketStatus,
|
|
1144
|
+
{
|
|
1145
|
+
accounts: {
|
|
1146
|
+
admin: this.wallet.publicKey,
|
|
1147
|
+
state: await this.getStatePublicKey(),
|
|
1148
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1149
|
+
this.program.programId,
|
|
1150
|
+
spotMarketIndex
|
|
1151
|
+
),
|
|
1152
|
+
},
|
|
1153
|
+
}
|
|
1154
|
+
);
|
|
1155
|
+
|
|
1156
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1157
|
+
return txSig;
|
|
1044
1158
|
}
|
|
1045
1159
|
|
|
1046
1160
|
public async updatePerpMarketStatus(
|
|
1047
1161
|
perpMarketIndex: number,
|
|
1048
1162
|
marketStatus: MarketStatus
|
|
1049
1163
|
): Promise<TransactionSignature> {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
this.
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1164
|
+
const tx = await this.program.transaction.updatePerpMarketStatus(
|
|
1165
|
+
marketStatus,
|
|
1166
|
+
{
|
|
1167
|
+
accounts: {
|
|
1168
|
+
admin: this.wallet.publicKey,
|
|
1169
|
+
state: await this.getStatePublicKey(),
|
|
1170
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1171
|
+
this.program.programId,
|
|
1172
|
+
perpMarketIndex
|
|
1173
|
+
),
|
|
1174
|
+
},
|
|
1175
|
+
}
|
|
1176
|
+
);
|
|
1177
|
+
|
|
1178
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1179
|
+
return txSig;
|
|
1060
1180
|
}
|
|
1061
1181
|
|
|
1062
1182
|
public async updatePerpMarketContractTier(
|
|
1063
1183
|
perpMarketIndex: number,
|
|
1064
1184
|
contractTier: ContractTier
|
|
1065
1185
|
): Promise<TransactionSignature> {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
this.
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1186
|
+
const tx = await this.program.transaction.updatePerpMarketContractTier(
|
|
1187
|
+
contractTier,
|
|
1188
|
+
{
|
|
1189
|
+
accounts: {
|
|
1190
|
+
admin: this.wallet.publicKey,
|
|
1191
|
+
state: await this.getStatePublicKey(),
|
|
1192
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1193
|
+
this.program.programId,
|
|
1194
|
+
perpMarketIndex
|
|
1195
|
+
),
|
|
1196
|
+
},
|
|
1197
|
+
}
|
|
1198
|
+
);
|
|
1199
|
+
|
|
1200
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1201
|
+
return txSig;
|
|
1076
1202
|
}
|
|
1077
1203
|
|
|
1078
1204
|
public async updateExchangeStatus(
|
|
1079
1205
|
exchangeStatus: ExchangeStatus
|
|
1080
1206
|
): Promise<TransactionSignature> {
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1207
|
+
const tx = await this.program.transaction.updateExchangeStatus(
|
|
1208
|
+
exchangeStatus,
|
|
1209
|
+
{
|
|
1210
|
+
accounts: {
|
|
1211
|
+
admin: this.wallet.publicKey,
|
|
1212
|
+
state: await this.getStatePublicKey(),
|
|
1213
|
+
},
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
|
|
1217
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1218
|
+
return txSig;
|
|
1087
1219
|
}
|
|
1088
1220
|
|
|
1089
1221
|
public async updatePerpAuctionDuration(
|