@drift-labs/sdk 2.75.0-beta.0 → 2.75.0-beta.2
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 +72 -0
- package/lib/adminClient.js +414 -184
- package/lib/constants/perpMarkets.js +10 -0
- package/lib/driftClient.d.ts +2 -2
- package/lib/driftClient.js +11 -7
- package/lib/idl/drift.json +5 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/tx/baseTxSender.d.ts +1 -1
- package/lib/tx/baseTxSender.js +5 -4
- package/lib/tx/fastSingleTxSender.d.ts +1 -1
- package/lib/tx/fastSingleTxSender.js +2 -13
- package/lib/tx/whileValidTxSender.d.ts +35 -0
- package/lib/tx/whileValidTxSender.js +138 -0
- package/package.json +1 -1
- package/src/adminClient.ts +1509 -826
- package/src/constants/perpMarkets.ts +10 -0
- package/src/driftClient.ts +14 -9
- package/src/idl/drift.json +5 -1
- package/src/index.ts +1 -0
- package/src/tx/baseTxSender.ts +12 -4
- package/src/tx/fastSingleTxSender.ts +3 -17
- package/src/tx/whileValidTxSender.ts +215 -0
package/src/adminClient.ts
CHANGED
|
@@ -483,13 +483,27 @@ export class AdminClient extends DriftClient {
|
|
|
483
483
|
public async deleteInitializedPerpMarket(
|
|
484
484
|
marketIndex: number
|
|
485
485
|
): Promise<TransactionSignature> {
|
|
486
|
+
const deleteInitializeMarketIx =
|
|
487
|
+
await this.getDeleteInitializedPerpMarketIx(marketIndex);
|
|
488
|
+
|
|
489
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
490
|
+
|
|
491
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
492
|
+
|
|
493
|
+
return txSig;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
public async getDeleteInitializedPerpMarketIx(
|
|
497
|
+
marketIndex: number
|
|
498
|
+
): Promise<TransactionInstruction> {
|
|
486
499
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
487
500
|
this.program.programId,
|
|
488
501
|
marketIndex
|
|
489
502
|
);
|
|
490
503
|
|
|
491
|
-
|
|
492
|
-
|
|
504
|
+
return await this.program.instruction.deleteInitializedPerpMarket(
|
|
505
|
+
marketIndex,
|
|
506
|
+
{
|
|
493
507
|
accounts: {
|
|
494
508
|
state: await this.getStatePublicKey(),
|
|
495
509
|
admin: this.isSubscribed
|
|
@@ -497,21 +511,36 @@ export class AdminClient extends DriftClient {
|
|
|
497
511
|
: this.wallet.publicKey,
|
|
498
512
|
perpMarket: perpMarketPublicKey,
|
|
499
513
|
},
|
|
500
|
-
}
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
}
|
|
501
517
|
|
|
502
|
-
|
|
518
|
+
public async moveAmmPrice(
|
|
519
|
+
perpMarketIndex: number,
|
|
520
|
+
baseAssetReserve: BN,
|
|
521
|
+
quoteAssetReserve: BN,
|
|
522
|
+
sqrtK?: BN
|
|
523
|
+
): Promise<TransactionSignature> {
|
|
524
|
+
const moveAmmPriceIx = await this.getMoveAmmPriceIx(
|
|
525
|
+
perpMarketIndex,
|
|
526
|
+
baseAssetReserve,
|
|
527
|
+
quoteAssetReserve,
|
|
528
|
+
sqrtK
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
503
532
|
|
|
504
533
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
505
534
|
|
|
506
535
|
return txSig;
|
|
507
536
|
}
|
|
508
537
|
|
|
509
|
-
public async
|
|
538
|
+
public async getMoveAmmPriceIx(
|
|
510
539
|
perpMarketIndex: number,
|
|
511
540
|
baseAssetReserve: BN,
|
|
512
541
|
quoteAssetReserve: BN,
|
|
513
542
|
sqrtK?: BN
|
|
514
|
-
): Promise<
|
|
543
|
+
): Promise<TransactionInstruction> {
|
|
515
544
|
const marketPublicKey = await getPerpMarketPublicKey(
|
|
516
545
|
this.program.programId,
|
|
517
546
|
perpMarketIndex
|
|
@@ -521,7 +550,7 @@ export class AdminClient extends DriftClient {
|
|
|
521
550
|
sqrtK = squareRootBN(baseAssetReserve.mul(quoteAssetReserve));
|
|
522
551
|
}
|
|
523
552
|
|
|
524
|
-
|
|
553
|
+
return await this.program.instruction.moveAmmPrice(
|
|
525
554
|
baseAssetReserve,
|
|
526
555
|
quoteAssetReserve,
|
|
527
556
|
sqrtK,
|
|
@@ -535,19 +564,26 @@ export class AdminClient extends DriftClient {
|
|
|
535
564
|
},
|
|
536
565
|
}
|
|
537
566
|
);
|
|
567
|
+
}
|
|
538
568
|
|
|
539
|
-
|
|
569
|
+
public async updateK(
|
|
570
|
+
perpMarketIndex: number,
|
|
571
|
+
sqrtK: BN
|
|
572
|
+
): Promise<TransactionSignature> {
|
|
573
|
+
const updateKIx = await this.getUpdateKIx(perpMarketIndex, sqrtK);
|
|
574
|
+
|
|
575
|
+
const tx = await this.buildTransaction(updateKIx);
|
|
540
576
|
|
|
541
577
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
542
578
|
|
|
543
579
|
return txSig;
|
|
544
580
|
}
|
|
545
581
|
|
|
546
|
-
public async
|
|
582
|
+
public async getUpdateKIx(
|
|
547
583
|
perpMarketIndex: number,
|
|
548
584
|
sqrtK: BN
|
|
549
|
-
): Promise<
|
|
550
|
-
|
|
585
|
+
): Promise<TransactionInstruction> {
|
|
586
|
+
return await this.program.instruction.updateK(sqrtK, {
|
|
551
587
|
accounts: {
|
|
552
588
|
state: await this.getStatePublicKey(),
|
|
553
589
|
admin: this.isSubscribed
|
|
@@ -560,44 +596,49 @@ export class AdminClient extends DriftClient {
|
|
|
560
596
|
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
561
597
|
},
|
|
562
598
|
});
|
|
599
|
+
}
|
|
563
600
|
|
|
564
|
-
|
|
601
|
+
public async recenterPerpMarketAmm(
|
|
602
|
+
perpMarketIndex: number,
|
|
603
|
+
pegMultiplier: BN,
|
|
604
|
+
sqrtK: BN
|
|
605
|
+
): Promise<TransactionSignature> {
|
|
606
|
+
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmIx(
|
|
607
|
+
perpMarketIndex,
|
|
608
|
+
pegMultiplier,
|
|
609
|
+
sqrtK
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
565
613
|
|
|
566
614
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
567
615
|
|
|
568
616
|
return txSig;
|
|
569
617
|
}
|
|
570
618
|
|
|
571
|
-
public async
|
|
619
|
+
public async getRecenterPerpMarketAmmIx(
|
|
572
620
|
perpMarketIndex: number,
|
|
573
621
|
pegMultiplier: BN,
|
|
574
622
|
sqrtK: BN
|
|
575
|
-
): Promise<
|
|
623
|
+
): Promise<TransactionInstruction> {
|
|
576
624
|
const marketPublicKey = await getPerpMarketPublicKey(
|
|
577
625
|
this.program.programId,
|
|
578
626
|
perpMarketIndex
|
|
579
627
|
);
|
|
580
628
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
{
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
);
|
|
595
|
-
|
|
596
|
-
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
597
|
-
|
|
598
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
599
|
-
|
|
600
|
-
return txSig;
|
|
629
|
+
return await this.program.instruction.recenterPerpMarketAmm(
|
|
630
|
+
pegMultiplier,
|
|
631
|
+
sqrtK,
|
|
632
|
+
{
|
|
633
|
+
accounts: {
|
|
634
|
+
state: await this.getStatePublicKey(),
|
|
635
|
+
admin: this.isSubscribed
|
|
636
|
+
? this.getStateAccount().admin
|
|
637
|
+
: this.wallet.publicKey,
|
|
638
|
+
perpMarket: marketPublicKey,
|
|
639
|
+
},
|
|
640
|
+
}
|
|
641
|
+
);
|
|
601
642
|
}
|
|
602
643
|
|
|
603
644
|
public async updatePerpMarketConcentrationScale(
|
|
@@ -605,20 +646,9 @@ export class AdminClient extends DriftClient {
|
|
|
605
646
|
concentrationScale: BN
|
|
606
647
|
): Promise<TransactionSignature> {
|
|
607
648
|
const updatePerpMarketConcentrationCoefIx =
|
|
608
|
-
await this.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
accounts: {
|
|
612
|
-
state: await this.getStatePublicKey(),
|
|
613
|
-
admin: this.isSubscribed
|
|
614
|
-
? this.getStateAccount().admin
|
|
615
|
-
: this.wallet.publicKey,
|
|
616
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
617
|
-
this.program.programId,
|
|
618
|
-
perpMarketIndex
|
|
619
|
-
),
|
|
620
|
-
},
|
|
621
|
-
}
|
|
649
|
+
await this.getUpdatePerpMarketConcentrationScaleIx(
|
|
650
|
+
perpMarketIndex,
|
|
651
|
+
concentrationScale
|
|
622
652
|
);
|
|
623
653
|
|
|
624
654
|
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
@@ -628,10 +658,47 @@ export class AdminClient extends DriftClient {
|
|
|
628
658
|
return txSig;
|
|
629
659
|
}
|
|
630
660
|
|
|
661
|
+
public async getUpdatePerpMarketConcentrationScaleIx(
|
|
662
|
+
perpMarketIndex: number,
|
|
663
|
+
concentrationScale: BN
|
|
664
|
+
): Promise<TransactionInstruction> {
|
|
665
|
+
return await this.program.instruction.updatePerpMarketConcentrationCoef(
|
|
666
|
+
concentrationScale,
|
|
667
|
+
{
|
|
668
|
+
accounts: {
|
|
669
|
+
state: await this.getStatePublicKey(),
|
|
670
|
+
admin: this.isSubscribed
|
|
671
|
+
? this.getStateAccount().admin
|
|
672
|
+
: this.wallet.publicKey,
|
|
673
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
674
|
+
this.program.programId,
|
|
675
|
+
perpMarketIndex
|
|
676
|
+
),
|
|
677
|
+
},
|
|
678
|
+
}
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
|
|
631
682
|
public async moveAmmToPrice(
|
|
632
683
|
perpMarketIndex: number,
|
|
633
684
|
targetPrice: BN
|
|
634
685
|
): Promise<TransactionSignature> {
|
|
686
|
+
const moveAmmPriceIx = await this.getMoveAmmToPriceIx(
|
|
687
|
+
perpMarketIndex,
|
|
688
|
+
targetPrice
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
692
|
+
|
|
693
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
694
|
+
|
|
695
|
+
return txSig;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
public async getMoveAmmToPriceIx(
|
|
699
|
+
perpMarketIndex: number,
|
|
700
|
+
targetPrice: BN
|
|
701
|
+
): Promise<TransactionInstruction> {
|
|
635
702
|
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
636
703
|
|
|
637
704
|
const [direction, tradeSize, _] = calculateTargetPriceTrade(
|
|
@@ -655,7 +722,7 @@ export class AdminClient extends DriftClient {
|
|
|
655
722
|
perpMarketIndex
|
|
656
723
|
);
|
|
657
724
|
|
|
658
|
-
|
|
725
|
+
return await this.program.instruction.moveAmmPrice(
|
|
659
726
|
newBaseAssetAmount,
|
|
660
727
|
newQuoteAssetAmount,
|
|
661
728
|
perpMarket.amm.sqrtK,
|
|
@@ -669,36 +736,15 @@ export class AdminClient extends DriftClient {
|
|
|
669
736
|
},
|
|
670
737
|
}
|
|
671
738
|
);
|
|
672
|
-
|
|
673
|
-
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
674
|
-
|
|
675
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
676
|
-
|
|
677
|
-
return txSig;
|
|
678
739
|
}
|
|
679
740
|
|
|
680
741
|
public async repegAmmCurve(
|
|
681
742
|
newPeg: BN,
|
|
682
743
|
perpMarketIndex: number
|
|
683
744
|
): Promise<TransactionSignature> {
|
|
684
|
-
const
|
|
685
|
-
this.program.programId,
|
|
686
|
-
perpMarketIndex
|
|
687
|
-
);
|
|
688
|
-
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
689
|
-
|
|
690
|
-
const repegAmmCurveIx = await this.program.instruction.repegAmmCurve(
|
|
745
|
+
const repegAmmCurveIx = await this.getRepegAmmCurveIx(
|
|
691
746
|
newPeg,
|
|
692
|
-
|
|
693
|
-
accounts: {
|
|
694
|
-
state: await this.getStatePublicKey(),
|
|
695
|
-
admin: this.isSubscribed
|
|
696
|
-
? this.getStateAccount().admin
|
|
697
|
-
: this.wallet.publicKey,
|
|
698
|
-
oracle: ammData.oracle,
|
|
699
|
-
perpMarket: perpMarketPublicKey,
|
|
700
|
-
},
|
|
701
|
-
}
|
|
747
|
+
perpMarketIndex
|
|
702
748
|
);
|
|
703
749
|
|
|
704
750
|
const tx = await this.buildTransaction(repegAmmCurveIx);
|
|
@@ -708,26 +754,33 @@ export class AdminClient extends DriftClient {
|
|
|
708
754
|
return txSig;
|
|
709
755
|
}
|
|
710
756
|
|
|
711
|
-
public async
|
|
757
|
+
public async getRepegAmmCurveIx(
|
|
758
|
+
newPeg: BN,
|
|
712
759
|
perpMarketIndex: number
|
|
713
|
-
): Promise<
|
|
714
|
-
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
760
|
+
): Promise<TransactionInstruction> {
|
|
715
761
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
716
762
|
this.program.programId,
|
|
717
763
|
perpMarketIndex
|
|
718
764
|
);
|
|
765
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
766
|
+
|
|
767
|
+
return await this.program.instruction.repegAmmCurve(newPeg, {
|
|
768
|
+
accounts: {
|
|
769
|
+
state: await this.getStatePublicKey(),
|
|
770
|
+
admin: this.isSubscribed
|
|
771
|
+
? this.getStateAccount().admin
|
|
772
|
+
: this.wallet.publicKey,
|
|
773
|
+
oracle: ammData.oracle,
|
|
774
|
+
perpMarket: perpMarketPublicKey,
|
|
775
|
+
},
|
|
776
|
+
});
|
|
777
|
+
}
|
|
719
778
|
|
|
779
|
+
public async updatePerpMarketAmmOracleTwap(
|
|
780
|
+
perpMarketIndex: number
|
|
781
|
+
): Promise<TransactionSignature> {
|
|
720
782
|
const updatePerpMarketAmmOracleTwapIx =
|
|
721
|
-
await this.
|
|
722
|
-
accounts: {
|
|
723
|
-
state: await this.getStatePublicKey(),
|
|
724
|
-
admin: this.isSubscribed
|
|
725
|
-
? this.getStateAccount().admin
|
|
726
|
-
: this.wallet.publicKey,
|
|
727
|
-
oracle: ammData.oracle,
|
|
728
|
-
perpMarket: perpMarketPublicKey,
|
|
729
|
-
},
|
|
730
|
-
});
|
|
783
|
+
await this.getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
731
784
|
|
|
732
785
|
const tx = await this.buildTransaction(updatePerpMarketAmmOracleTwapIx);
|
|
733
786
|
|
|
@@ -736,26 +789,32 @@ export class AdminClient extends DriftClient {
|
|
|
736
789
|
return txSig;
|
|
737
790
|
}
|
|
738
791
|
|
|
739
|
-
public async
|
|
792
|
+
public async getUpdatePerpMarketAmmOracleTwapIx(
|
|
740
793
|
perpMarketIndex: number
|
|
741
|
-
): Promise<
|
|
794
|
+
): Promise<TransactionInstruction> {
|
|
742
795
|
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
743
796
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
744
797
|
this.program.programId,
|
|
745
798
|
perpMarketIndex
|
|
746
799
|
);
|
|
747
800
|
|
|
801
|
+
return await this.program.instruction.updatePerpMarketAmmOracleTwap({
|
|
802
|
+
accounts: {
|
|
803
|
+
state: await this.getStatePublicKey(),
|
|
804
|
+
admin: this.isSubscribed
|
|
805
|
+
? this.getStateAccount().admin
|
|
806
|
+
: this.wallet.publicKey,
|
|
807
|
+
oracle: ammData.oracle,
|
|
808
|
+
perpMarket: perpMarketPublicKey,
|
|
809
|
+
},
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
public async resetPerpMarketAmmOracleTwap(
|
|
814
|
+
perpMarketIndex: number
|
|
815
|
+
): Promise<TransactionSignature> {
|
|
748
816
|
const resetPerpMarketAmmOracleTwapIx =
|
|
749
|
-
await this.
|
|
750
|
-
accounts: {
|
|
751
|
-
state: await this.getStatePublicKey(),
|
|
752
|
-
admin: this.isSubscribed
|
|
753
|
-
? this.getStateAccount().admin
|
|
754
|
-
: this.wallet.publicKey,
|
|
755
|
-
oracle: ammData.oracle,
|
|
756
|
-
perpMarket: perpMarketPublicKey,
|
|
757
|
-
},
|
|
758
|
-
});
|
|
817
|
+
await this.getResetPerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
759
818
|
|
|
760
819
|
const tx = await this.buildTransaction(resetPerpMarketAmmOracleTwapIx);
|
|
761
820
|
|
|
@@ -764,31 +823,38 @@ export class AdminClient extends DriftClient {
|
|
|
764
823
|
return txSig;
|
|
765
824
|
}
|
|
766
825
|
|
|
826
|
+
public async getResetPerpMarketAmmOracleTwapIx(
|
|
827
|
+
perpMarketIndex: number
|
|
828
|
+
): Promise<TransactionInstruction> {
|
|
829
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
830
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
831
|
+
this.program.programId,
|
|
832
|
+
perpMarketIndex
|
|
833
|
+
);
|
|
834
|
+
|
|
835
|
+
return await this.program.instruction.resetPerpMarketAmmOracleTwap({
|
|
836
|
+
accounts: {
|
|
837
|
+
state: await this.getStatePublicKey(),
|
|
838
|
+
admin: this.isSubscribed
|
|
839
|
+
? this.getStateAccount().admin
|
|
840
|
+
: this.wallet.publicKey,
|
|
841
|
+
oracle: ammData.oracle,
|
|
842
|
+
perpMarket: perpMarketPublicKey,
|
|
843
|
+
},
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
|
|
767
847
|
public async depositIntoPerpMarketFeePool(
|
|
768
848
|
perpMarketIndex: number,
|
|
769
849
|
amount: BN,
|
|
770
850
|
sourceVault: PublicKey
|
|
771
851
|
): Promise<TransactionSignature> {
|
|
772
|
-
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
773
|
-
|
|
774
852
|
const depositIntoPerpMarketFeePoolIx =
|
|
775
|
-
await this.
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
state: await this.getStatePublicKey(),
|
|
781
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
782
|
-
this.program.programId,
|
|
783
|
-
perpMarketIndex
|
|
784
|
-
),
|
|
785
|
-
sourceVault,
|
|
786
|
-
driftSigner: this.getSignerPublicKey(),
|
|
787
|
-
quoteSpotMarket: spotMarket.pubkey,
|
|
788
|
-
spotMarketVault: spotMarket.vault,
|
|
789
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
790
|
-
},
|
|
791
|
-
});
|
|
853
|
+
await this.getDepositIntoPerpMarketFeePoolIx(
|
|
854
|
+
perpMarketIndex,
|
|
855
|
+
amount,
|
|
856
|
+
sourceVault
|
|
857
|
+
);
|
|
792
858
|
|
|
793
859
|
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
794
860
|
|
|
@@ -797,15 +863,34 @@ export class AdminClient extends DriftClient {
|
|
|
797
863
|
return txSig;
|
|
798
864
|
}
|
|
799
865
|
|
|
800
|
-
public async
|
|
801
|
-
|
|
866
|
+
public async getDepositIntoPerpMarketFeePoolIx(
|
|
867
|
+
perpMarketIndex: number,
|
|
868
|
+
amount: BN,
|
|
869
|
+
sourceVault: PublicKey
|
|
870
|
+
): Promise<TransactionInstruction> {
|
|
871
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
872
|
+
|
|
873
|
+
return await this.program.instruction.depositIntoPerpMarketFeePool(amount, {
|
|
802
874
|
accounts: {
|
|
803
875
|
admin: this.isSubscribed
|
|
804
876
|
? this.getStateAccount().admin
|
|
805
877
|
: this.wallet.publicKey,
|
|
806
878
|
state: await this.getStatePublicKey(),
|
|
879
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
880
|
+
this.program.programId,
|
|
881
|
+
perpMarketIndex
|
|
882
|
+
),
|
|
883
|
+
sourceVault,
|
|
884
|
+
driftSigner: this.getSignerPublicKey(),
|
|
885
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
886
|
+
spotMarketVault: spotMarket.vault,
|
|
887
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
807
888
|
},
|
|
808
889
|
});
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
|
|
893
|
+
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
809
894
|
|
|
810
895
|
const tx = await this.buildTransaction(updateAdminIx);
|
|
811
896
|
|
|
@@ -814,28 +899,27 @@ export class AdminClient extends DriftClient {
|
|
|
814
899
|
return txSig;
|
|
815
900
|
}
|
|
816
901
|
|
|
902
|
+
public async getUpdateAdminIx(
|
|
903
|
+
admin: PublicKey
|
|
904
|
+
): Promise<TransactionInstruction> {
|
|
905
|
+
return await this.program.instruction.updateAdmin(admin, {
|
|
906
|
+
accounts: {
|
|
907
|
+
admin: this.isSubscribed
|
|
908
|
+
? this.getStateAccount().admin
|
|
909
|
+
: this.wallet.publicKey,
|
|
910
|
+
state: await this.getStatePublicKey(),
|
|
911
|
+
},
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
|
|
817
915
|
public async updatePerpMarketCurveUpdateIntensity(
|
|
818
916
|
perpMarketIndex: number,
|
|
819
917
|
curveUpdateIntensity: number
|
|
820
918
|
): Promise<TransactionSignature> {
|
|
821
|
-
// assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
|
|
822
|
-
// assert(Number.isInteger(curveUpdateIntensity));
|
|
823
|
-
|
|
824
919
|
const updatePerpMarketCurveUpdateIntensityIx =
|
|
825
|
-
await this.
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
accounts: {
|
|
829
|
-
admin: this.isSubscribed
|
|
830
|
-
? this.getStateAccount().admin
|
|
831
|
-
: this.wallet.publicKey,
|
|
832
|
-
state: await this.getStatePublicKey(),
|
|
833
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
834
|
-
this.program.programId,
|
|
835
|
-
perpMarketIndex
|
|
836
|
-
),
|
|
837
|
-
},
|
|
838
|
-
}
|
|
920
|
+
await this.getUpdatePerpMarketCurveUpdateIntensityIx(
|
|
921
|
+
perpMarketIndex,
|
|
922
|
+
curveUpdateIntensity
|
|
839
923
|
);
|
|
840
924
|
|
|
841
925
|
const tx = await this.buildTransaction(
|
|
@@ -847,57 +931,77 @@ export class AdminClient extends DriftClient {
|
|
|
847
931
|
return txSig;
|
|
848
932
|
}
|
|
849
933
|
|
|
850
|
-
public async
|
|
934
|
+
public async getUpdatePerpMarketCurveUpdateIntensityIx(
|
|
851
935
|
perpMarketIndex: number,
|
|
852
|
-
|
|
853
|
-
): Promise<
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
{
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
936
|
+
curveUpdateIntensity: number
|
|
937
|
+
): Promise<TransactionInstruction> {
|
|
938
|
+
return await this.program.instruction.updatePerpMarketCurveUpdateIntensity(
|
|
939
|
+
curveUpdateIntensity,
|
|
940
|
+
{
|
|
941
|
+
accounts: {
|
|
942
|
+
admin: this.isSubscribed
|
|
943
|
+
? this.getStateAccount().admin
|
|
944
|
+
: this.wallet.publicKey,
|
|
945
|
+
state: await this.getStatePublicKey(),
|
|
946
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
947
|
+
this.program.programId,
|
|
948
|
+
perpMarketIndex
|
|
949
|
+
),
|
|
950
|
+
},
|
|
951
|
+
}
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
public async updatePerpMarketTargetBaseAssetAmountPerLp(
|
|
956
|
+
perpMarketIndex: number,
|
|
957
|
+
targetBaseAssetAmountPerLP: number
|
|
958
|
+
): Promise<TransactionSignature> {
|
|
959
|
+
const updatePerpMarketTargetBaseAssetAmountPerLpIx =
|
|
960
|
+
await this.getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
961
|
+
perpMarketIndex,
|
|
962
|
+
targetBaseAssetAmountPerLP
|
|
963
|
+
);
|
|
964
|
+
|
|
965
|
+
const tx = await this.buildTransaction(
|
|
966
|
+
updatePerpMarketTargetBaseAssetAmountPerLpIx
|
|
967
|
+
);
|
|
874
968
|
|
|
875
969
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
876
970
|
|
|
877
971
|
return txSig;
|
|
878
972
|
}
|
|
879
973
|
|
|
974
|
+
public async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
975
|
+
perpMarketIndex: number,
|
|
976
|
+
targetBaseAssetAmountPerLP: number
|
|
977
|
+
): Promise<TransactionInstruction> {
|
|
978
|
+
return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp(
|
|
979
|
+
targetBaseAssetAmountPerLP,
|
|
980
|
+
{
|
|
981
|
+
accounts: {
|
|
982
|
+
admin: this.isSubscribed
|
|
983
|
+
? this.getStateAccount().admin
|
|
984
|
+
: this.wallet.publicKey,
|
|
985
|
+
state: await this.getStatePublicKey(),
|
|
986
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
987
|
+
this.program.programId,
|
|
988
|
+
perpMarketIndex
|
|
989
|
+
),
|
|
990
|
+
},
|
|
991
|
+
}
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
|
|
880
995
|
public async updatePerpMarketMarginRatio(
|
|
881
996
|
perpMarketIndex: number,
|
|
882
997
|
marginRatioInitial: number,
|
|
883
998
|
marginRatioMaintenance: number
|
|
884
999
|
): Promise<TransactionSignature> {
|
|
885
1000
|
const updatePerpMarketMarginRatioIx =
|
|
886
|
-
await this.
|
|
1001
|
+
await this.getUpdatePerpMarketMarginRatioIx(
|
|
1002
|
+
perpMarketIndex,
|
|
887
1003
|
marginRatioInitial,
|
|
888
|
-
marginRatioMaintenance
|
|
889
|
-
{
|
|
890
|
-
accounts: {
|
|
891
|
-
admin: this.isSubscribed
|
|
892
|
-
? this.getStateAccount().admin
|
|
893
|
-
: this.wallet.publicKey,
|
|
894
|
-
state: await this.getStatePublicKey(),
|
|
895
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
896
|
-
this.program.programId,
|
|
897
|
-
perpMarketIndex
|
|
898
|
-
),
|
|
899
|
-
},
|
|
900
|
-
}
|
|
1004
|
+
marginRatioMaintenance
|
|
901
1005
|
);
|
|
902
1006
|
|
|
903
1007
|
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
@@ -907,27 +1011,39 @@ export class AdminClient extends DriftClient {
|
|
|
907
1011
|
return txSig;
|
|
908
1012
|
}
|
|
909
1013
|
|
|
1014
|
+
public async getUpdatePerpMarketMarginRatioIx(
|
|
1015
|
+
perpMarketIndex: number,
|
|
1016
|
+
marginRatioInitial: number,
|
|
1017
|
+
marginRatioMaintenance: number
|
|
1018
|
+
): Promise<TransactionInstruction> {
|
|
1019
|
+
return await this.program.instruction.updatePerpMarketMarginRatio(
|
|
1020
|
+
marginRatioInitial,
|
|
1021
|
+
marginRatioMaintenance,
|
|
1022
|
+
{
|
|
1023
|
+
accounts: {
|
|
1024
|
+
admin: this.isSubscribed
|
|
1025
|
+
? this.getStateAccount().admin
|
|
1026
|
+
: this.wallet.publicKey,
|
|
1027
|
+
state: await this.getStatePublicKey(),
|
|
1028
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1029
|
+
this.program.programId,
|
|
1030
|
+
perpMarketIndex
|
|
1031
|
+
),
|
|
1032
|
+
},
|
|
1033
|
+
}
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
910
1037
|
public async updatePerpMarketImfFactor(
|
|
911
1038
|
perpMarketIndex: number,
|
|
912
1039
|
imfFactor: number,
|
|
913
1040
|
unrealizedPnlImfFactor: number
|
|
914
1041
|
): Promise<TransactionSignature> {
|
|
915
1042
|
const updatePerpMarketImfFactorIx =
|
|
916
|
-
await this.
|
|
1043
|
+
await this.getUpdatePerpMarketImfFactorIx(
|
|
1044
|
+
perpMarketIndex,
|
|
917
1045
|
imfFactor,
|
|
918
|
-
unrealizedPnlImfFactor
|
|
919
|
-
{
|
|
920
|
-
accounts: {
|
|
921
|
-
admin: this.isSubscribed
|
|
922
|
-
? this.getStateAccount().admin
|
|
923
|
-
: this.wallet.publicKey,
|
|
924
|
-
state: await this.getStatePublicKey(),
|
|
925
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
926
|
-
this.program.programId,
|
|
927
|
-
perpMarketIndex
|
|
928
|
-
),
|
|
929
|
-
},
|
|
930
|
-
}
|
|
1046
|
+
unrealizedPnlImfFactor
|
|
931
1047
|
);
|
|
932
1048
|
|
|
933
1049
|
const tx = await this.buildTransaction(updatePerpMarketImfFactorIx);
|
|
@@ -937,12 +1053,15 @@ export class AdminClient extends DriftClient {
|
|
|
937
1053
|
return txSig;
|
|
938
1054
|
}
|
|
939
1055
|
|
|
940
|
-
public async
|
|
1056
|
+
public async getUpdatePerpMarketImfFactorIx(
|
|
941
1057
|
perpMarketIndex: number,
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1058
|
+
imfFactor: number,
|
|
1059
|
+
unrealizedPnlImfFactor: number
|
|
1060
|
+
): Promise<TransactionInstruction> {
|
|
1061
|
+
return await this.program.instruction.updatePerpMarketImfFactor(
|
|
1062
|
+
imfFactor,
|
|
1063
|
+
unrealizedPnlImfFactor,
|
|
1064
|
+
{
|
|
946
1065
|
accounts: {
|
|
947
1066
|
admin: this.isSubscribed
|
|
948
1067
|
? this.getStateAccount().admin
|
|
@@ -953,7 +1072,16 @@ export class AdminClient extends DriftClient {
|
|
|
953
1072
|
perpMarketIndex
|
|
954
1073
|
),
|
|
955
1074
|
},
|
|
956
|
-
}
|
|
1075
|
+
}
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
public async updatePerpMarketBaseSpread(
|
|
1080
|
+
perpMarketIndex: number,
|
|
1081
|
+
baseSpread: number
|
|
1082
|
+
): Promise<TransactionSignature> {
|
|
1083
|
+
const updatePerpMarketBaseSpreadIx =
|
|
1084
|
+
await this.getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread);
|
|
957
1085
|
|
|
958
1086
|
const tx = await this.buildTransaction(updatePerpMarketBaseSpreadIx);
|
|
959
1087
|
|
|
@@ -962,12 +1090,13 @@ export class AdminClient extends DriftClient {
|
|
|
962
1090
|
return txSig;
|
|
963
1091
|
}
|
|
964
1092
|
|
|
965
|
-
public async
|
|
1093
|
+
public async getUpdatePerpMarketBaseSpreadIx(
|
|
966
1094
|
perpMarketIndex: number,
|
|
967
|
-
|
|
968
|
-
): Promise<
|
|
969
|
-
|
|
970
|
-
|
|
1095
|
+
baseSpread: number
|
|
1096
|
+
): Promise<TransactionInstruction> {
|
|
1097
|
+
return await this.program.instruction.updatePerpMarketBaseSpread(
|
|
1098
|
+
baseSpread,
|
|
1099
|
+
{
|
|
971
1100
|
accounts: {
|
|
972
1101
|
admin: this.isSubscribed
|
|
973
1102
|
? this.getStateAccount().admin
|
|
@@ -978,7 +1107,18 @@ export class AdminClient extends DriftClient {
|
|
|
978
1107
|
perpMarketIndex
|
|
979
1108
|
),
|
|
980
1109
|
},
|
|
981
|
-
}
|
|
1110
|
+
}
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
public async updateAmmJitIntensity(
|
|
1115
|
+
perpMarketIndex: number,
|
|
1116
|
+
ammJitIntensity: number
|
|
1117
|
+
): Promise<TransactionSignature> {
|
|
1118
|
+
const updateAmmJitIntensityIx = await this.getUpdateAmmJitIntensityIx(
|
|
1119
|
+
perpMarketIndex,
|
|
1120
|
+
ammJitIntensity
|
|
1121
|
+
);
|
|
982
1122
|
|
|
983
1123
|
const tx = await this.buildTransaction(updateAmmJitIntensityIx);
|
|
984
1124
|
|
|
@@ -987,14 +1127,13 @@ export class AdminClient extends DriftClient {
|
|
|
987
1127
|
return txSig;
|
|
988
1128
|
}
|
|
989
1129
|
|
|
990
|
-
public async
|
|
1130
|
+
public async getUpdateAmmJitIntensityIx(
|
|
991
1131
|
perpMarketIndex: number,
|
|
992
|
-
|
|
993
|
-
): Promise<
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
await this.program.instruction.updatePerpMarketName(nameBuffer, {
|
|
1132
|
+
ammJitIntensity: number
|
|
1133
|
+
): Promise<TransactionInstruction> {
|
|
1134
|
+
return await this.program.instruction.updateAmmJitIntensity(
|
|
1135
|
+
ammJitIntensity,
|
|
1136
|
+
{
|
|
998
1137
|
accounts: {
|
|
999
1138
|
admin: this.isSubscribed
|
|
1000
1139
|
? this.getStateAccount().admin
|
|
@@ -1005,7 +1144,18 @@ export class AdminClient extends DriftClient {
|
|
|
1005
1144
|
perpMarketIndex
|
|
1006
1145
|
),
|
|
1007
1146
|
},
|
|
1008
|
-
}
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
public async updatePerpMarketName(
|
|
1152
|
+
perpMarketIndex: number,
|
|
1153
|
+
name: string
|
|
1154
|
+
): Promise<TransactionSignature> {
|
|
1155
|
+
const updatePerpMarketNameIx = await this.getUpdatePerpMarketNameIx(
|
|
1156
|
+
perpMarketIndex,
|
|
1157
|
+
name
|
|
1158
|
+
);
|
|
1009
1159
|
|
|
1010
1160
|
const tx = await this.buildTransaction(updatePerpMarketNameIx);
|
|
1011
1161
|
|
|
@@ -1014,25 +1164,33 @@ export class AdminClient extends DriftClient {
|
|
|
1014
1164
|
return txSig;
|
|
1015
1165
|
}
|
|
1016
1166
|
|
|
1167
|
+
public async getUpdatePerpMarketNameIx(
|
|
1168
|
+
perpMarketIndex: number,
|
|
1169
|
+
name: string
|
|
1170
|
+
): Promise<TransactionInstruction> {
|
|
1171
|
+
const nameBuffer = encodeName(name);
|
|
1172
|
+
return await this.program.instruction.updatePerpMarketName(nameBuffer, {
|
|
1173
|
+
accounts: {
|
|
1174
|
+
admin: this.isSubscribed
|
|
1175
|
+
? this.getStateAccount().admin
|
|
1176
|
+
: this.wallet.publicKey,
|
|
1177
|
+
state: await this.getStatePublicKey(),
|
|
1178
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1179
|
+
this.program.programId,
|
|
1180
|
+
perpMarketIndex
|
|
1181
|
+
),
|
|
1182
|
+
},
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1017
1186
|
public async updateSpotMarketName(
|
|
1018
1187
|
spotMarketIndex: number,
|
|
1019
1188
|
name: string
|
|
1020
1189
|
): Promise<TransactionSignature> {
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
accounts: {
|
|
1026
|
-
admin: this.isSubscribed
|
|
1027
|
-
? this.getStateAccount().admin
|
|
1028
|
-
: this.wallet.publicKey,
|
|
1029
|
-
state: await this.getStatePublicKey(),
|
|
1030
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1031
|
-
this.program.programId,
|
|
1032
|
-
spotMarketIndex
|
|
1033
|
-
),
|
|
1034
|
-
},
|
|
1035
|
-
});
|
|
1190
|
+
const updateSpotMarketNameIx = await this.getUpdateSpotMarketNameIx(
|
|
1191
|
+
spotMarketIndex,
|
|
1192
|
+
name
|
|
1193
|
+
);
|
|
1036
1194
|
|
|
1037
1195
|
const tx = await this.buildTransaction(updateSpotMarketNameIx);
|
|
1038
1196
|
|
|
@@ -1041,25 +1199,31 @@ export class AdminClient extends DriftClient {
|
|
|
1041
1199
|
return txSig;
|
|
1042
1200
|
}
|
|
1043
1201
|
|
|
1202
|
+
public async getUpdateSpotMarketNameIx(
|
|
1203
|
+
spotMarketIndex: number,
|
|
1204
|
+
name: string
|
|
1205
|
+
): Promise<TransactionInstruction> {
|
|
1206
|
+
const nameBuffer = encodeName(name);
|
|
1207
|
+
return await this.program.instruction.updateSpotMarketName(nameBuffer, {
|
|
1208
|
+
accounts: {
|
|
1209
|
+
admin: this.isSubscribed
|
|
1210
|
+
? this.getStateAccount().admin
|
|
1211
|
+
: this.wallet.publicKey,
|
|
1212
|
+
state: await this.getStatePublicKey(),
|
|
1213
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1214
|
+
this.program.programId,
|
|
1215
|
+
spotMarketIndex
|
|
1216
|
+
),
|
|
1217
|
+
},
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1044
1221
|
public async updatePerpMarketPerLpBase(
|
|
1045
1222
|
perpMarketIndex: number,
|
|
1046
1223
|
perLpBase: number
|
|
1047
1224
|
): Promise<TransactionSignature> {
|
|
1048
|
-
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1049
|
-
this.program.programId,
|
|
1050
|
-
perpMarketIndex
|
|
1051
|
-
);
|
|
1052
|
-
|
|
1053
1225
|
const updatePerpMarketPerLpBaseIx =
|
|
1054
|
-
await this.
|
|
1055
|
-
accounts: {
|
|
1056
|
-
admin: this.isSubscribed
|
|
1057
|
-
? this.getStateAccount().admin
|
|
1058
|
-
: this.wallet.publicKey,
|
|
1059
|
-
state: await this.getStatePublicKey(),
|
|
1060
|
-
perpMarket: perpMarketPublicKey,
|
|
1061
|
-
},
|
|
1062
|
-
});
|
|
1226
|
+
await this.getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase);
|
|
1063
1227
|
|
|
1064
1228
|
const tx = await this.buildTransaction(updatePerpMarketPerLpBaseIx);
|
|
1065
1229
|
|
|
@@ -1068,25 +1232,32 @@ export class AdminClient extends DriftClient {
|
|
|
1068
1232
|
return txSig;
|
|
1069
1233
|
}
|
|
1070
1234
|
|
|
1071
|
-
public async
|
|
1235
|
+
public async getUpdatePerpMarketPerLpBaseIx(
|
|
1072
1236
|
perpMarketIndex: number,
|
|
1073
|
-
|
|
1074
|
-
): Promise<
|
|
1237
|
+
perLpBase: number
|
|
1238
|
+
): Promise<TransactionInstruction> {
|
|
1075
1239
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1076
1240
|
this.program.programId,
|
|
1077
1241
|
perpMarketIndex
|
|
1078
1242
|
);
|
|
1079
1243
|
|
|
1244
|
+
return await this.program.instruction.updatePerpMarketPerLpBase(perLpBase, {
|
|
1245
|
+
accounts: {
|
|
1246
|
+
admin: this.isSubscribed
|
|
1247
|
+
? this.getStateAccount().admin
|
|
1248
|
+
: this.wallet.publicKey,
|
|
1249
|
+
state: await this.getStatePublicKey(),
|
|
1250
|
+
perpMarket: perpMarketPublicKey,
|
|
1251
|
+
},
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
public async updatePerpMarketMaxSpread(
|
|
1256
|
+
perpMarketIndex: number,
|
|
1257
|
+
maxSpread: number
|
|
1258
|
+
): Promise<TransactionSignature> {
|
|
1080
1259
|
const updatePerpMarketMaxSpreadIx =
|
|
1081
|
-
await this.
|
|
1082
|
-
accounts: {
|
|
1083
|
-
admin: this.isSubscribed
|
|
1084
|
-
? this.getStateAccount().admin
|
|
1085
|
-
: this.wallet.publicKey,
|
|
1086
|
-
state: await this.getStatePublicKey(),
|
|
1087
|
-
perpMarket: perpMarketPublicKey,
|
|
1088
|
-
},
|
|
1089
|
-
});
|
|
1260
|
+
await this.getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread);
|
|
1090
1261
|
|
|
1091
1262
|
const tx = await this.buildTransaction(updatePerpMarketMaxSpreadIx);
|
|
1092
1263
|
|
|
@@ -1095,18 +1266,32 @@ export class AdminClient extends DriftClient {
|
|
|
1095
1266
|
return txSig;
|
|
1096
1267
|
}
|
|
1097
1268
|
|
|
1269
|
+
public async getUpdatePerpMarketMaxSpreadIx(
|
|
1270
|
+
perpMarketIndex: number,
|
|
1271
|
+
maxSpread: number
|
|
1272
|
+
): Promise<TransactionInstruction> {
|
|
1273
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1274
|
+
this.program.programId,
|
|
1275
|
+
perpMarketIndex
|
|
1276
|
+
);
|
|
1277
|
+
|
|
1278
|
+
return await this.program.instruction.updatePerpMarketMaxSpread(maxSpread, {
|
|
1279
|
+
accounts: {
|
|
1280
|
+
admin: this.isSubscribed
|
|
1281
|
+
? this.getStateAccount().admin
|
|
1282
|
+
: this.wallet.publicKey,
|
|
1283
|
+
state: await this.getStatePublicKey(),
|
|
1284
|
+
perpMarket: perpMarketPublicKey,
|
|
1285
|
+
},
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1098
1289
|
public async updatePerpFeeStructure(
|
|
1099
1290
|
feeStructure: FeeStructure
|
|
1100
1291
|
): Promise<TransactionSignature> {
|
|
1101
|
-
const updatePerpFeeStructureIx =
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
admin: this.isSubscribed
|
|
1105
|
-
? this.getStateAccount().admin
|
|
1106
|
-
: this.wallet.publicKey,
|
|
1107
|
-
state: await this.getStatePublicKey(),
|
|
1108
|
-
},
|
|
1109
|
-
});
|
|
1292
|
+
const updatePerpFeeStructureIx = await this.getUpdatePerpFeeStructureIx(
|
|
1293
|
+
feeStructure
|
|
1294
|
+
);
|
|
1110
1295
|
|
|
1111
1296
|
const tx = await this.buildTransaction(updatePerpFeeStructureIx);
|
|
1112
1297
|
|
|
@@ -1115,18 +1300,25 @@ export class AdminClient extends DriftClient {
|
|
|
1115
1300
|
return txSig;
|
|
1116
1301
|
}
|
|
1117
1302
|
|
|
1303
|
+
public async getUpdatePerpFeeStructureIx(
|
|
1304
|
+
feeStructure: FeeStructure
|
|
1305
|
+
): Promise<TransactionInstruction> {
|
|
1306
|
+
return this.program.instruction.updatePerpFeeStructure(feeStructure, {
|
|
1307
|
+
accounts: {
|
|
1308
|
+
admin: this.isSubscribed
|
|
1309
|
+
? this.getStateAccount().admin
|
|
1310
|
+
: this.wallet.publicKey,
|
|
1311
|
+
state: await this.getStatePublicKey(),
|
|
1312
|
+
},
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1118
1316
|
public async updateSpotFeeStructure(
|
|
1119
1317
|
feeStructure: FeeStructure
|
|
1120
1318
|
): Promise<TransactionSignature> {
|
|
1121
|
-
const updateSpotFeeStructureIx =
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
admin: this.isSubscribed
|
|
1125
|
-
? this.getStateAccount().admin
|
|
1126
|
-
: this.wallet.publicKey,
|
|
1127
|
-
state: await this.getStatePublicKey(),
|
|
1128
|
-
},
|
|
1129
|
-
});
|
|
1319
|
+
const updateSpotFeeStructureIx = await this.getUpdateSpotFeeStructureIx(
|
|
1320
|
+
feeStructure
|
|
1321
|
+
);
|
|
1130
1322
|
|
|
1131
1323
|
const tx = await this.buildTransaction(updateSpotFeeStructureIx);
|
|
1132
1324
|
|
|
@@ -1135,21 +1327,24 @@ export class AdminClient extends DriftClient {
|
|
|
1135
1327
|
return txSig;
|
|
1136
1328
|
}
|
|
1137
1329
|
|
|
1330
|
+
public async getUpdateSpotFeeStructureIx(
|
|
1331
|
+
feeStructure: FeeStructure
|
|
1332
|
+
): Promise<TransactionInstruction> {
|
|
1333
|
+
return await this.program.instruction.updateSpotFeeStructure(feeStructure, {
|
|
1334
|
+
accounts: {
|
|
1335
|
+
admin: this.isSubscribed
|
|
1336
|
+
? this.getStateAccount().admin
|
|
1337
|
+
: this.wallet.publicKey,
|
|
1338
|
+
state: await this.getStatePublicKey(),
|
|
1339
|
+
},
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1138
1343
|
public async updateInitialPctToLiquidate(
|
|
1139
1344
|
initialPctToLiquidate: number
|
|
1140
1345
|
): Promise<TransactionSignature> {
|
|
1141
1346
|
const updateInitialPctToLiquidateIx =
|
|
1142
|
-
await this.
|
|
1143
|
-
initialPctToLiquidate,
|
|
1144
|
-
{
|
|
1145
|
-
accounts: {
|
|
1146
|
-
admin: this.isSubscribed
|
|
1147
|
-
? this.getStateAccount().admin
|
|
1148
|
-
: this.wallet.publicKey,
|
|
1149
|
-
state: await this.getStatePublicKey(),
|
|
1150
|
-
},
|
|
1151
|
-
}
|
|
1152
|
-
);
|
|
1347
|
+
await this.getUpdateInitialPctToLiquidateIx(initialPctToLiquidate);
|
|
1153
1348
|
|
|
1154
1349
|
const tx = await this.buildTransaction(updateInitialPctToLiquidateIx);
|
|
1155
1350
|
|
|
@@ -1158,21 +1353,27 @@ export class AdminClient extends DriftClient {
|
|
|
1158
1353
|
return txSig;
|
|
1159
1354
|
}
|
|
1160
1355
|
|
|
1356
|
+
public async getUpdateInitialPctToLiquidateIx(
|
|
1357
|
+
initialPctToLiquidate: number
|
|
1358
|
+
): Promise<TransactionInstruction> {
|
|
1359
|
+
return await this.program.instruction.updateInitialPctToLiquidate(
|
|
1360
|
+
initialPctToLiquidate,
|
|
1361
|
+
{
|
|
1362
|
+
accounts: {
|
|
1363
|
+
admin: this.isSubscribed
|
|
1364
|
+
? this.getStateAccount().admin
|
|
1365
|
+
: this.wallet.publicKey,
|
|
1366
|
+
state: await this.getStatePublicKey(),
|
|
1367
|
+
},
|
|
1368
|
+
}
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1161
1372
|
public async updateLiquidationDuration(
|
|
1162
1373
|
liquidationDuration: number
|
|
1163
1374
|
): Promise<TransactionSignature> {
|
|
1164
1375
|
const updateLiquidationDurationIx =
|
|
1165
|
-
await this.
|
|
1166
|
-
liquidationDuration,
|
|
1167
|
-
{
|
|
1168
|
-
accounts: {
|
|
1169
|
-
admin: this.isSubscribed
|
|
1170
|
-
? this.getStateAccount().admin
|
|
1171
|
-
: this.wallet.publicKey,
|
|
1172
|
-
state: await this.getStatePublicKey(),
|
|
1173
|
-
},
|
|
1174
|
-
}
|
|
1175
|
-
);
|
|
1376
|
+
await this.getUpdateLiquidationDurationIx(liquidationDuration);
|
|
1176
1377
|
|
|
1177
1378
|
const tx = await this.buildTransaction(updateLiquidationDurationIx);
|
|
1178
1379
|
|
|
@@ -1181,20 +1382,28 @@ export class AdminClient extends DriftClient {
|
|
|
1181
1382
|
return txSig;
|
|
1182
1383
|
}
|
|
1183
1384
|
|
|
1385
|
+
public async getUpdateLiquidationDurationIx(
|
|
1386
|
+
liquidationDuration: number
|
|
1387
|
+
): Promise<TransactionInstruction> {
|
|
1388
|
+
return await this.program.instruction.updateLiquidationDuration(
|
|
1389
|
+
liquidationDuration,
|
|
1390
|
+
{
|
|
1391
|
+
accounts: {
|
|
1392
|
+
admin: this.isSubscribed
|
|
1393
|
+
? this.getStateAccount().admin
|
|
1394
|
+
: this.wallet.publicKey,
|
|
1395
|
+
state: await this.getStatePublicKey(),
|
|
1396
|
+
},
|
|
1397
|
+
}
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1184
1401
|
public async updateLiquidationMarginBufferRatio(
|
|
1185
1402
|
updateLiquidationMarginBufferRatio: number
|
|
1186
1403
|
): Promise<TransactionSignature> {
|
|
1187
1404
|
const updateLiquidationMarginBufferRatioIx =
|
|
1188
|
-
await this.
|
|
1189
|
-
updateLiquidationMarginBufferRatio
|
|
1190
|
-
{
|
|
1191
|
-
accounts: {
|
|
1192
|
-
admin: this.isSubscribed
|
|
1193
|
-
? this.getStateAccount().admin
|
|
1194
|
-
: this.wallet.publicKey,
|
|
1195
|
-
state: await this.getStatePublicKey(),
|
|
1196
|
-
},
|
|
1197
|
-
}
|
|
1405
|
+
await this.getUpdateLiquidationMarginBufferRatioIx(
|
|
1406
|
+
updateLiquidationMarginBufferRatio
|
|
1198
1407
|
);
|
|
1199
1408
|
|
|
1200
1409
|
const tx = await this.buildTransaction(
|
|
@@ -1206,18 +1415,28 @@ export class AdminClient extends DriftClient {
|
|
|
1206
1415
|
return txSig;
|
|
1207
1416
|
}
|
|
1208
1417
|
|
|
1209
|
-
public async
|
|
1210
|
-
|
|
1211
|
-
): Promise<
|
|
1212
|
-
|
|
1213
|
-
|
|
1418
|
+
public async getUpdateLiquidationMarginBufferRatioIx(
|
|
1419
|
+
updateLiquidationMarginBufferRatio: number
|
|
1420
|
+
): Promise<TransactionInstruction> {
|
|
1421
|
+
return await this.program.instruction.updateLiquidationMarginBufferRatio(
|
|
1422
|
+
updateLiquidationMarginBufferRatio,
|
|
1423
|
+
{
|
|
1214
1424
|
accounts: {
|
|
1215
1425
|
admin: this.isSubscribed
|
|
1216
1426
|
? this.getStateAccount().admin
|
|
1217
1427
|
: this.wallet.publicKey,
|
|
1218
1428
|
state: await this.getStatePublicKey(),
|
|
1219
1429
|
},
|
|
1220
|
-
}
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
public async updateOracleGuardRails(
|
|
1435
|
+
oracleGuardRails: OracleGuardRails
|
|
1436
|
+
): Promise<TransactionSignature> {
|
|
1437
|
+
const updateOracleGuardRailsIx = await this.getUpdateOracleGuardRailsIx(
|
|
1438
|
+
oracleGuardRails
|
|
1439
|
+
);
|
|
1221
1440
|
|
|
1222
1441
|
const tx = await this.buildTransaction(updateOracleGuardRailsIx);
|
|
1223
1442
|
|
|
@@ -1226,21 +1445,27 @@ export class AdminClient extends DriftClient {
|
|
|
1226
1445
|
return txSig;
|
|
1227
1446
|
}
|
|
1228
1447
|
|
|
1448
|
+
public async getUpdateOracleGuardRailsIx(
|
|
1449
|
+
oracleGuardRails: OracleGuardRails
|
|
1450
|
+
): Promise<TransactionInstruction> {
|
|
1451
|
+
return await this.program.instruction.updateOracleGuardRails(
|
|
1452
|
+
oracleGuardRails,
|
|
1453
|
+
{
|
|
1454
|
+
accounts: {
|
|
1455
|
+
admin: this.isSubscribed
|
|
1456
|
+
? this.getStateAccount().admin
|
|
1457
|
+
: this.wallet.publicKey,
|
|
1458
|
+
state: await this.getStatePublicKey(),
|
|
1459
|
+
},
|
|
1460
|
+
}
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1229
1464
|
public async updateStateSettlementDuration(
|
|
1230
1465
|
settlementDuration: number
|
|
1231
1466
|
): Promise<TransactionSignature> {
|
|
1232
1467
|
const updateStateSettlementDurationIx =
|
|
1233
|
-
await this.
|
|
1234
|
-
settlementDuration,
|
|
1235
|
-
{
|
|
1236
|
-
accounts: {
|
|
1237
|
-
admin: this.isSubscribed
|
|
1238
|
-
? this.getStateAccount().admin
|
|
1239
|
-
: this.wallet.publicKey,
|
|
1240
|
-
state: await this.getStatePublicKey(),
|
|
1241
|
-
},
|
|
1242
|
-
}
|
|
1243
|
-
);
|
|
1468
|
+
await this.getUpdateStateSettlementDurationIx(settlementDuration);
|
|
1244
1469
|
|
|
1245
1470
|
const tx = await this.buildTransaction(updateStateSettlementDurationIx);
|
|
1246
1471
|
|
|
@@ -1249,21 +1474,27 @@ export class AdminClient extends DriftClient {
|
|
|
1249
1474
|
return txSig;
|
|
1250
1475
|
}
|
|
1251
1476
|
|
|
1477
|
+
public async getUpdateStateSettlementDurationIx(
|
|
1478
|
+
settlementDuration: number
|
|
1479
|
+
): Promise<TransactionInstruction> {
|
|
1480
|
+
return await this.program.instruction.updateStateSettlementDuration(
|
|
1481
|
+
settlementDuration,
|
|
1482
|
+
{
|
|
1483
|
+
accounts: {
|
|
1484
|
+
admin: this.isSubscribed
|
|
1485
|
+
? this.getStateAccount().admin
|
|
1486
|
+
: this.wallet.publicKey,
|
|
1487
|
+
state: await this.getStatePublicKey(),
|
|
1488
|
+
},
|
|
1489
|
+
}
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1252
1493
|
public async updateStateMaxNumberOfSubAccounts(
|
|
1253
1494
|
maxNumberOfSubAccounts: number
|
|
1254
1495
|
): Promise<TransactionSignature> {
|
|
1255
1496
|
const updateStateMaxNumberOfSubAccountsIx =
|
|
1256
|
-
await this.
|
|
1257
|
-
maxNumberOfSubAccounts,
|
|
1258
|
-
{
|
|
1259
|
-
accounts: {
|
|
1260
|
-
admin: this.isSubscribed
|
|
1261
|
-
? this.getStateAccount().admin
|
|
1262
|
-
: this.wallet.publicKey,
|
|
1263
|
-
state: await this.getStatePublicKey(),
|
|
1264
|
-
},
|
|
1265
|
-
}
|
|
1266
|
-
);
|
|
1497
|
+
await this.getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts);
|
|
1267
1498
|
|
|
1268
1499
|
const tx = await this.buildTransaction(updateStateMaxNumberOfSubAccountsIx);
|
|
1269
1500
|
|
|
@@ -1272,21 +1503,27 @@ export class AdminClient extends DriftClient {
|
|
|
1272
1503
|
return txSig;
|
|
1273
1504
|
}
|
|
1274
1505
|
|
|
1506
|
+
public async getUpdateStateMaxNumberOfSubAccountsIx(
|
|
1507
|
+
maxNumberOfSubAccounts: number
|
|
1508
|
+
): Promise<TransactionInstruction> {
|
|
1509
|
+
return await this.program.instruction.updateStateMaxNumberOfSubAccounts(
|
|
1510
|
+
maxNumberOfSubAccounts,
|
|
1511
|
+
{
|
|
1512
|
+
accounts: {
|
|
1513
|
+
admin: this.isSubscribed
|
|
1514
|
+
? this.getStateAccount().admin
|
|
1515
|
+
: this.wallet.publicKey,
|
|
1516
|
+
state: await this.getStatePublicKey(),
|
|
1517
|
+
},
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1275
1522
|
public async updateStateMaxInitializeUserFee(
|
|
1276
1523
|
maxInitializeUserFee: number
|
|
1277
1524
|
): Promise<TransactionSignature> {
|
|
1278
1525
|
const updateStateMaxInitializeUserFeeIx =
|
|
1279
|
-
await this.
|
|
1280
|
-
maxInitializeUserFee,
|
|
1281
|
-
{
|
|
1282
|
-
accounts: {
|
|
1283
|
-
admin: this.isSubscribed
|
|
1284
|
-
? this.getStateAccount().admin
|
|
1285
|
-
: this.wallet.publicKey,
|
|
1286
|
-
state: await this.getStatePublicKey(),
|
|
1287
|
-
},
|
|
1288
|
-
}
|
|
1289
|
-
);
|
|
1526
|
+
await this.getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee);
|
|
1290
1527
|
|
|
1291
1528
|
const tx = await this.buildTransaction(updateStateMaxInitializeUserFeeIx);
|
|
1292
1529
|
|
|
@@ -1295,25 +1532,30 @@ export class AdminClient extends DriftClient {
|
|
|
1295
1532
|
return txSig;
|
|
1296
1533
|
}
|
|
1297
1534
|
|
|
1535
|
+
public async getUpdateStateMaxInitializeUserFeeIx(
|
|
1536
|
+
maxInitializeUserFee: number
|
|
1537
|
+
): Promise<TransactionInstruction> {
|
|
1538
|
+
return await this.program.instruction.updateStateMaxInitializeUserFee(
|
|
1539
|
+
maxInitializeUserFee,
|
|
1540
|
+
{
|
|
1541
|
+
accounts: {
|
|
1542
|
+
admin: this.isSubscribed
|
|
1543
|
+
? this.getStateAccount().admin
|
|
1544
|
+
: this.wallet.publicKey,
|
|
1545
|
+
state: await this.getStatePublicKey(),
|
|
1546
|
+
},
|
|
1547
|
+
}
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1298
1551
|
public async updateWithdrawGuardThreshold(
|
|
1299
1552
|
spotMarketIndex: number,
|
|
1300
1553
|
withdrawGuardThreshold: BN
|
|
1301
1554
|
): Promise<TransactionSignature> {
|
|
1302
1555
|
const updateWithdrawGuardThresholdIx =
|
|
1303
|
-
await this.
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
accounts: {
|
|
1307
|
-
admin: this.isSubscribed
|
|
1308
|
-
? this.getStateAccount().admin
|
|
1309
|
-
: this.wallet.publicKey,
|
|
1310
|
-
state: await this.getStatePublicKey(),
|
|
1311
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1312
|
-
this.program.programId,
|
|
1313
|
-
spotMarketIndex
|
|
1314
|
-
),
|
|
1315
|
-
},
|
|
1316
|
-
}
|
|
1556
|
+
await this.getUpdateWithdrawGuardThresholdIx(
|
|
1557
|
+
spotMarketIndex,
|
|
1558
|
+
withdrawGuardThreshold
|
|
1317
1559
|
);
|
|
1318
1560
|
|
|
1319
1561
|
const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
|
|
@@ -1323,29 +1565,37 @@ export class AdminClient extends DriftClient {
|
|
|
1323
1565
|
return txSig;
|
|
1324
1566
|
}
|
|
1325
1567
|
|
|
1568
|
+
public async getUpdateWithdrawGuardThresholdIx(
|
|
1569
|
+
spotMarketIndex: number,
|
|
1570
|
+
withdrawGuardThreshold: BN
|
|
1571
|
+
): Promise<TransactionInstruction> {
|
|
1572
|
+
return await this.program.instruction.updateWithdrawGuardThreshold(
|
|
1573
|
+
withdrawGuardThreshold,
|
|
1574
|
+
{
|
|
1575
|
+
accounts: {
|
|
1576
|
+
admin: this.isSubscribed
|
|
1577
|
+
? this.getStateAccount().admin
|
|
1578
|
+
: this.wallet.publicKey,
|
|
1579
|
+
state: await this.getStatePublicKey(),
|
|
1580
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1581
|
+
this.program.programId,
|
|
1582
|
+
spotMarketIndex
|
|
1583
|
+
),
|
|
1584
|
+
},
|
|
1585
|
+
}
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1326
1589
|
public async updateSpotMarketIfFactor(
|
|
1327
1590
|
spotMarketIndex: number,
|
|
1328
1591
|
userIfFactor: BN,
|
|
1329
1592
|
totalIfFactor: BN
|
|
1330
1593
|
): Promise<TransactionSignature> {
|
|
1331
|
-
const updateSpotMarketIfFactorIx =
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
{
|
|
1337
|
-
accounts: {
|
|
1338
|
-
admin: this.isSubscribed
|
|
1339
|
-
? this.getStateAccount().admin
|
|
1340
|
-
: this.wallet.publicKey,
|
|
1341
|
-
state: await this.getStatePublicKey(),
|
|
1342
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1343
|
-
this.program.programId,
|
|
1344
|
-
spotMarketIndex
|
|
1345
|
-
),
|
|
1346
|
-
},
|
|
1347
|
-
}
|
|
1348
|
-
);
|
|
1594
|
+
const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(
|
|
1595
|
+
spotMarketIndex,
|
|
1596
|
+
userIfFactor,
|
|
1597
|
+
totalIfFactor
|
|
1598
|
+
);
|
|
1349
1599
|
|
|
1350
1600
|
const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
|
|
1351
1601
|
|
|
@@ -1354,25 +1604,38 @@ export class AdminClient extends DriftClient {
|
|
|
1354
1604
|
return txSig;
|
|
1355
1605
|
}
|
|
1356
1606
|
|
|
1607
|
+
public async getUpdateSpotMarketIfFactorIx(
|
|
1608
|
+
spotMarketIndex: number,
|
|
1609
|
+
userIfFactor: BN,
|
|
1610
|
+
totalIfFactor: BN
|
|
1611
|
+
): Promise<TransactionInstruction> {
|
|
1612
|
+
return await this.program.instruction.updateSpotMarketIfFactor(
|
|
1613
|
+
spotMarketIndex,
|
|
1614
|
+
userIfFactor,
|
|
1615
|
+
totalIfFactor,
|
|
1616
|
+
{
|
|
1617
|
+
accounts: {
|
|
1618
|
+
admin: this.isSubscribed
|
|
1619
|
+
? this.getStateAccount().admin
|
|
1620
|
+
: this.wallet.publicKey,
|
|
1621
|
+
state: await this.getStatePublicKey(),
|
|
1622
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1623
|
+
this.program.programId,
|
|
1624
|
+
spotMarketIndex
|
|
1625
|
+
),
|
|
1626
|
+
},
|
|
1627
|
+
}
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1357
1631
|
public async updateSpotMarketRevenueSettlePeriod(
|
|
1358
1632
|
spotMarketIndex: number,
|
|
1359
1633
|
revenueSettlePeriod: BN
|
|
1360
1634
|
): Promise<TransactionSignature> {
|
|
1361
1635
|
const updateSpotMarketRevenueSettlePeriodIx =
|
|
1362
|
-
await this.
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
accounts: {
|
|
1366
|
-
admin: this.isSubscribed
|
|
1367
|
-
? this.getStateAccount().admin
|
|
1368
|
-
: this.wallet.publicKey,
|
|
1369
|
-
state: await this.getStatePublicKey(),
|
|
1370
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1371
|
-
this.program.programId,
|
|
1372
|
-
spotMarketIndex
|
|
1373
|
-
),
|
|
1374
|
-
},
|
|
1375
|
-
}
|
|
1636
|
+
await this.getUpdateSpotMarketRevenueSettlePeriodIx(
|
|
1637
|
+
spotMarketIndex,
|
|
1638
|
+
revenueSettlePeriod
|
|
1376
1639
|
);
|
|
1377
1640
|
|
|
1378
1641
|
const tx = await this.buildTransaction(
|
|
@@ -1384,25 +1647,35 @@ export class AdminClient extends DriftClient {
|
|
|
1384
1647
|
return txSig;
|
|
1385
1648
|
}
|
|
1386
1649
|
|
|
1650
|
+
public async getUpdateSpotMarketRevenueSettlePeriodIx(
|
|
1651
|
+
spotMarketIndex: number,
|
|
1652
|
+
revenueSettlePeriod: BN
|
|
1653
|
+
): Promise<TransactionInstruction> {
|
|
1654
|
+
return await this.program.instruction.updateSpotMarketRevenueSettlePeriod(
|
|
1655
|
+
revenueSettlePeriod,
|
|
1656
|
+
{
|
|
1657
|
+
accounts: {
|
|
1658
|
+
admin: this.isSubscribed
|
|
1659
|
+
? this.getStateAccount().admin
|
|
1660
|
+
: this.wallet.publicKey,
|
|
1661
|
+
state: await this.getStatePublicKey(),
|
|
1662
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1663
|
+
this.program.programId,
|
|
1664
|
+
spotMarketIndex
|
|
1665
|
+
),
|
|
1666
|
+
},
|
|
1667
|
+
}
|
|
1668
|
+
);
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1387
1671
|
public async updateSpotMarketMaxTokenDeposits(
|
|
1388
1672
|
spotMarketIndex: number,
|
|
1389
1673
|
maxTokenDeposits: BN
|
|
1390
1674
|
): Promise<TransactionSignature> {
|
|
1391
1675
|
const updateSpotMarketMaxTokenDepositsIx =
|
|
1392
|
-
this.
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
accounts: {
|
|
1396
|
-
admin: this.isSubscribed
|
|
1397
|
-
? this.getStateAccount().admin
|
|
1398
|
-
: this.wallet.publicKey,
|
|
1399
|
-
state: await this.getStatePublicKey(),
|
|
1400
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1401
|
-
this.program.programId,
|
|
1402
|
-
spotMarketIndex
|
|
1403
|
-
),
|
|
1404
|
-
},
|
|
1405
|
-
}
|
|
1676
|
+
await this.getUpdateSpotMarketMaxTokenDepositsIx(
|
|
1677
|
+
spotMarketIndex,
|
|
1678
|
+
maxTokenDeposits
|
|
1406
1679
|
);
|
|
1407
1680
|
|
|
1408
1681
|
const tx = await this.buildTransaction(updateSpotMarketMaxTokenDepositsIx);
|
|
@@ -1412,25 +1685,35 @@ export class AdminClient extends DriftClient {
|
|
|
1412
1685
|
return txSig;
|
|
1413
1686
|
}
|
|
1414
1687
|
|
|
1688
|
+
public async getUpdateSpotMarketMaxTokenDepositsIx(
|
|
1689
|
+
spotMarketIndex: number,
|
|
1690
|
+
maxTokenDeposits: BN
|
|
1691
|
+
): Promise<TransactionInstruction> {
|
|
1692
|
+
return this.program.instruction.updateSpotMarketMaxTokenDeposits(
|
|
1693
|
+
maxTokenDeposits,
|
|
1694
|
+
{
|
|
1695
|
+
accounts: {
|
|
1696
|
+
admin: this.isSubscribed
|
|
1697
|
+
? this.getStateAccount().admin
|
|
1698
|
+
: this.wallet.publicKey,
|
|
1699
|
+
state: await this.getStatePublicKey(),
|
|
1700
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1701
|
+
this.program.programId,
|
|
1702
|
+
spotMarketIndex
|
|
1703
|
+
),
|
|
1704
|
+
},
|
|
1705
|
+
}
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1415
1709
|
public async updateSpotMarketScaleInitialAssetWeightStart(
|
|
1416
1710
|
spotMarketIndex: number,
|
|
1417
1711
|
scaleInitialAssetWeightStart: BN
|
|
1418
1712
|
): Promise<TransactionSignature> {
|
|
1419
1713
|
const updateSpotMarketScaleInitialAssetWeightStartIx =
|
|
1420
|
-
this.
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
accounts: {
|
|
1424
|
-
admin: this.isSubscribed
|
|
1425
|
-
? this.getStateAccount().admin
|
|
1426
|
-
: this.wallet.publicKey,
|
|
1427
|
-
state: await this.getStatePublicKey(),
|
|
1428
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1429
|
-
this.program.programId,
|
|
1430
|
-
spotMarketIndex
|
|
1431
|
-
),
|
|
1432
|
-
},
|
|
1433
|
-
}
|
|
1714
|
+
await this.getUpdateSpotMarketScaleInitialAssetWeightStartIx(
|
|
1715
|
+
spotMarketIndex,
|
|
1716
|
+
scaleInitialAssetWeightStart
|
|
1434
1717
|
);
|
|
1435
1718
|
|
|
1436
1719
|
const tx = await this.buildTransaction(
|
|
@@ -1442,25 +1725,35 @@ export class AdminClient extends DriftClient {
|
|
|
1442
1725
|
return txSig;
|
|
1443
1726
|
}
|
|
1444
1727
|
|
|
1728
|
+
public async getUpdateSpotMarketScaleInitialAssetWeightStartIx(
|
|
1729
|
+
spotMarketIndex: number,
|
|
1730
|
+
scaleInitialAssetWeightStart: BN
|
|
1731
|
+
): Promise<TransactionInstruction> {
|
|
1732
|
+
return this.program.instruction.updateSpotMarketScaleInitialAssetWeightStart(
|
|
1733
|
+
scaleInitialAssetWeightStart,
|
|
1734
|
+
{
|
|
1735
|
+
accounts: {
|
|
1736
|
+
admin: this.isSubscribed
|
|
1737
|
+
? this.getStateAccount().admin
|
|
1738
|
+
: this.wallet.publicKey,
|
|
1739
|
+
state: await this.getStatePublicKey(),
|
|
1740
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1741
|
+
this.program.programId,
|
|
1742
|
+
spotMarketIndex
|
|
1743
|
+
),
|
|
1744
|
+
},
|
|
1745
|
+
}
|
|
1746
|
+
);
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1445
1749
|
public async updateInsuranceFundUnstakingPeriod(
|
|
1446
1750
|
spotMarketIndex: number,
|
|
1447
1751
|
insuranceWithdrawEscrowPeriod: BN
|
|
1448
1752
|
): Promise<TransactionSignature> {
|
|
1449
1753
|
const updateInsuranceFundUnstakingPeriodIx =
|
|
1450
|
-
await this.
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
accounts: {
|
|
1454
|
-
admin: this.isSubscribed
|
|
1455
|
-
? this.getStateAccount().admin
|
|
1456
|
-
: this.wallet.publicKey,
|
|
1457
|
-
state: await this.getStatePublicKey(),
|
|
1458
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1459
|
-
this.program.programId,
|
|
1460
|
-
spotMarketIndex
|
|
1461
|
-
),
|
|
1462
|
-
},
|
|
1463
|
-
}
|
|
1754
|
+
await this.getUpdateInsuranceFundUnstakingPeriodIx(
|
|
1755
|
+
spotMarketIndex,
|
|
1756
|
+
insuranceWithdrawEscrowPeriod
|
|
1464
1757
|
);
|
|
1465
1758
|
|
|
1466
1759
|
const tx = await this.buildTransaction(
|
|
@@ -1472,18 +1765,33 @@ export class AdminClient extends DriftClient {
|
|
|
1472
1765
|
return txSig;
|
|
1473
1766
|
}
|
|
1474
1767
|
|
|
1475
|
-
public async
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1768
|
+
public async getUpdateInsuranceFundUnstakingPeriodIx(
|
|
1769
|
+
spotMarketIndex: number,
|
|
1770
|
+
insuranceWithdrawEscrowPeriod: BN
|
|
1771
|
+
): Promise<TransactionInstruction> {
|
|
1772
|
+
return await this.program.instruction.updateInsuranceFundUnstakingPeriod(
|
|
1773
|
+
insuranceWithdrawEscrowPeriod,
|
|
1774
|
+
{
|
|
1480
1775
|
accounts: {
|
|
1481
1776
|
admin: this.isSubscribed
|
|
1482
1777
|
? this.getStateAccount().admin
|
|
1483
1778
|
: this.wallet.publicKey,
|
|
1484
1779
|
state: await this.getStatePublicKey(),
|
|
1780
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1781
|
+
this.program.programId,
|
|
1782
|
+
spotMarketIndex
|
|
1783
|
+
),
|
|
1485
1784
|
},
|
|
1486
|
-
}
|
|
1785
|
+
}
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
public async updateLpCooldownTime(
|
|
1790
|
+
cooldownTime: BN
|
|
1791
|
+
): Promise<TransactionSignature> {
|
|
1792
|
+
const updateLpCooldownTimeIx = await this.getUpdateLpCooldownTimeIx(
|
|
1793
|
+
cooldownTime
|
|
1794
|
+
);
|
|
1487
1795
|
|
|
1488
1796
|
const tx = await this.buildTransaction(updateLpCooldownTimeIx);
|
|
1489
1797
|
|
|
@@ -1492,29 +1800,29 @@ export class AdminClient extends DriftClient {
|
|
|
1492
1800
|
return txSig;
|
|
1493
1801
|
}
|
|
1494
1802
|
|
|
1803
|
+
public async getUpdateLpCooldownTimeIx(
|
|
1804
|
+
cooldownTime: BN
|
|
1805
|
+
): Promise<TransactionInstruction> {
|
|
1806
|
+
return await this.program.instruction.updateLpCooldownTime(cooldownTime, {
|
|
1807
|
+
accounts: {
|
|
1808
|
+
admin: this.isSubscribed
|
|
1809
|
+
? this.getStateAccount().admin
|
|
1810
|
+
: this.wallet.publicKey,
|
|
1811
|
+
state: await this.getStatePublicKey(),
|
|
1812
|
+
},
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1495
1816
|
public async updatePerpMarketOracle(
|
|
1496
1817
|
perpMarketIndex: number,
|
|
1497
1818
|
oracle: PublicKey,
|
|
1498
1819
|
oracleSource: OracleSource
|
|
1499
1820
|
): Promise<TransactionSignature> {
|
|
1500
|
-
const updatePerpMarketOracleIx =
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
accounts: {
|
|
1506
|
-
admin: this.isSubscribed
|
|
1507
|
-
? this.getStateAccount().admin
|
|
1508
|
-
: this.wallet.publicKey,
|
|
1509
|
-
state: await this.getStatePublicKey(),
|
|
1510
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
1511
|
-
this.program.programId,
|
|
1512
|
-
perpMarketIndex
|
|
1513
|
-
),
|
|
1514
|
-
oracle: oracle,
|
|
1515
|
-
},
|
|
1516
|
-
}
|
|
1517
|
-
);
|
|
1821
|
+
const updatePerpMarketOracleIx = await this.getUpdatePerpMarketOracleIx(
|
|
1822
|
+
perpMarketIndex,
|
|
1823
|
+
oracle,
|
|
1824
|
+
oracleSource
|
|
1825
|
+
);
|
|
1518
1826
|
|
|
1519
1827
|
const tx = await this.buildTransaction(updatePerpMarketOracleIx);
|
|
1520
1828
|
|
|
@@ -1523,27 +1831,40 @@ export class AdminClient extends DriftClient {
|
|
|
1523
1831
|
return txSig;
|
|
1524
1832
|
}
|
|
1525
1833
|
|
|
1834
|
+
public async getUpdatePerpMarketOracleIx(
|
|
1835
|
+
perpMarketIndex: number,
|
|
1836
|
+
oracle: PublicKey,
|
|
1837
|
+
oracleSource: OracleSource
|
|
1838
|
+
): Promise<TransactionInstruction> {
|
|
1839
|
+
return await this.program.instruction.updatePerpMarketOracle(
|
|
1840
|
+
oracle,
|
|
1841
|
+
oracleSource,
|
|
1842
|
+
{
|
|
1843
|
+
accounts: {
|
|
1844
|
+
admin: this.isSubscribed
|
|
1845
|
+
? this.getStateAccount().admin
|
|
1846
|
+
: this.wallet.publicKey,
|
|
1847
|
+
state: await this.getStatePublicKey(),
|
|
1848
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1849
|
+
this.program.programId,
|
|
1850
|
+
perpMarketIndex
|
|
1851
|
+
),
|
|
1852
|
+
oracle: oracle,
|
|
1853
|
+
},
|
|
1854
|
+
}
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1526
1858
|
public async updatePerpMarketStepSizeAndTickSize(
|
|
1527
1859
|
perpMarketIndex: number,
|
|
1528
1860
|
stepSize: BN,
|
|
1529
1861
|
tickSize: BN
|
|
1530
1862
|
): Promise<TransactionSignature> {
|
|
1531
1863
|
const updatePerpMarketStepSizeAndTickSizeIx =
|
|
1532
|
-
await this.
|
|
1864
|
+
await this.getUpdatePerpMarketStepSizeAndTickSizeIx(
|
|
1865
|
+
perpMarketIndex,
|
|
1533
1866
|
stepSize,
|
|
1534
|
-
tickSize
|
|
1535
|
-
{
|
|
1536
|
-
accounts: {
|
|
1537
|
-
admin: this.isSubscribed
|
|
1538
|
-
? this.getStateAccount().admin
|
|
1539
|
-
: this.wallet.publicKey,
|
|
1540
|
-
state: await this.getStatePublicKey(),
|
|
1541
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
1542
|
-
this.program.programId,
|
|
1543
|
-
perpMarketIndex
|
|
1544
|
-
),
|
|
1545
|
-
},
|
|
1546
|
-
}
|
|
1867
|
+
tickSize
|
|
1547
1868
|
);
|
|
1548
1869
|
|
|
1549
1870
|
const tx = await this.buildTransaction(
|
|
@@ -1555,12 +1876,15 @@ export class AdminClient extends DriftClient {
|
|
|
1555
1876
|
return txSig;
|
|
1556
1877
|
}
|
|
1557
1878
|
|
|
1558
|
-
public async
|
|
1879
|
+
public async getUpdatePerpMarketStepSizeAndTickSizeIx(
|
|
1559
1880
|
perpMarketIndex: number,
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1881
|
+
stepSize: BN,
|
|
1882
|
+
tickSize: BN
|
|
1883
|
+
): Promise<TransactionInstruction> {
|
|
1884
|
+
return await this.program.instruction.updatePerpMarketStepSizeAndTickSize(
|
|
1885
|
+
stepSize,
|
|
1886
|
+
tickSize,
|
|
1887
|
+
{
|
|
1564
1888
|
accounts: {
|
|
1565
1889
|
admin: this.isSubscribed
|
|
1566
1890
|
? this.getStateAccount().admin
|
|
@@ -1571,7 +1895,16 @@ export class AdminClient extends DriftClient {
|
|
|
1571
1895
|
perpMarketIndex
|
|
1572
1896
|
),
|
|
1573
1897
|
},
|
|
1574
|
-
}
|
|
1898
|
+
}
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
public async updatePerpMarketMinOrderSize(
|
|
1903
|
+
perpMarketIndex: number,
|
|
1904
|
+
orderSize: BN
|
|
1905
|
+
): Promise<TransactionSignature> {
|
|
1906
|
+
const updatePerpMarketMinOrderSizeIx =
|
|
1907
|
+
await this.getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize);
|
|
1575
1908
|
|
|
1576
1909
|
const tx = await this.buildTransaction(updatePerpMarketMinOrderSizeIx);
|
|
1577
1910
|
|
|
@@ -1580,27 +1913,37 @@ export class AdminClient extends DriftClient {
|
|
|
1580
1913
|
return txSig;
|
|
1581
1914
|
}
|
|
1582
1915
|
|
|
1916
|
+
public async getUpdatePerpMarketMinOrderSizeIx(
|
|
1917
|
+
perpMarketIndex: number,
|
|
1918
|
+
orderSize: BN
|
|
1919
|
+
): Promise<TransactionInstruction> {
|
|
1920
|
+
return await this.program.instruction.updatePerpMarketMinOrderSize(
|
|
1921
|
+
orderSize,
|
|
1922
|
+
{
|
|
1923
|
+
accounts: {
|
|
1924
|
+
admin: this.isSubscribed
|
|
1925
|
+
? this.getStateAccount().admin
|
|
1926
|
+
: this.wallet.publicKey,
|
|
1927
|
+
state: await this.getStatePublicKey(),
|
|
1928
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1929
|
+
this.program.programId,
|
|
1930
|
+
perpMarketIndex
|
|
1931
|
+
),
|
|
1932
|
+
},
|
|
1933
|
+
}
|
|
1934
|
+
);
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1583
1937
|
public async updateSpotMarketStepSizeAndTickSize(
|
|
1584
1938
|
spotMarketIndex: number,
|
|
1585
1939
|
stepSize: BN,
|
|
1586
1940
|
tickSize: BN
|
|
1587
1941
|
): Promise<TransactionSignature> {
|
|
1588
1942
|
const updateSpotMarketStepSizeAndTickSizeIx =
|
|
1589
|
-
await this.
|
|
1943
|
+
await this.getUpdateSpotMarketStepSizeAndTickSizeIx(
|
|
1944
|
+
spotMarketIndex,
|
|
1590
1945
|
stepSize,
|
|
1591
|
-
tickSize
|
|
1592
|
-
{
|
|
1593
|
-
accounts: {
|
|
1594
|
-
admin: this.isSubscribed
|
|
1595
|
-
? this.getStateAccount().admin
|
|
1596
|
-
: this.wallet.publicKey,
|
|
1597
|
-
state: await this.getStatePublicKey(),
|
|
1598
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1599
|
-
this.program.programId,
|
|
1600
|
-
spotMarketIndex
|
|
1601
|
-
),
|
|
1602
|
-
},
|
|
1603
|
-
}
|
|
1946
|
+
tickSize
|
|
1604
1947
|
);
|
|
1605
1948
|
|
|
1606
1949
|
const tx = await this.buildTransaction(
|
|
@@ -1612,6 +1955,29 @@ export class AdminClient extends DriftClient {
|
|
|
1612
1955
|
return txSig;
|
|
1613
1956
|
}
|
|
1614
1957
|
|
|
1958
|
+
public async getUpdateSpotMarketStepSizeAndTickSizeIx(
|
|
1959
|
+
spotMarketIndex: number,
|
|
1960
|
+
stepSize: BN,
|
|
1961
|
+
tickSize: BN
|
|
1962
|
+
): Promise<TransactionInstruction> {
|
|
1963
|
+
return await this.program.instruction.updateSpotMarketStepSizeAndTickSize(
|
|
1964
|
+
stepSize,
|
|
1965
|
+
tickSize,
|
|
1966
|
+
{
|
|
1967
|
+
accounts: {
|
|
1968
|
+
admin: this.isSubscribed
|
|
1969
|
+
? this.getStateAccount().admin
|
|
1970
|
+
: this.wallet.publicKey,
|
|
1971
|
+
state: await this.getStatePublicKey(),
|
|
1972
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1973
|
+
this.program.programId,
|
|
1974
|
+
spotMarketIndex
|
|
1975
|
+
),
|
|
1976
|
+
},
|
|
1977
|
+
}
|
|
1978
|
+
);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1615
1981
|
public async updateSpotMarketMinOrderSize(
|
|
1616
1982
|
spotMarketIndex: number,
|
|
1617
1983
|
orderSize: BN
|
|
@@ -1637,23 +2003,35 @@ export class AdminClient extends DriftClient {
|
|
|
1637
2003
|
return txSig;
|
|
1638
2004
|
}
|
|
1639
2005
|
|
|
1640
|
-
public async
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
): Promise<
|
|
1644
|
-
|
|
1645
|
-
|
|
2006
|
+
public async getUpdateSpotMarketMinOrderSizeIx(
|
|
2007
|
+
spotMarketIndex: number,
|
|
2008
|
+
orderSize: BN
|
|
2009
|
+
): Promise<TransactionInstruction> {
|
|
2010
|
+
return await this.program.instruction.updateSpotMarketMinOrderSize(
|
|
2011
|
+
orderSize,
|
|
2012
|
+
{
|
|
1646
2013
|
accounts: {
|
|
1647
2014
|
admin: this.isSubscribed
|
|
1648
2015
|
? this.getStateAccount().admin
|
|
1649
2016
|
: this.wallet.publicKey,
|
|
1650
2017
|
state: await this.getStatePublicKey(),
|
|
1651
|
-
|
|
2018
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1652
2019
|
this.program.programId,
|
|
1653
|
-
|
|
2020
|
+
spotMarketIndex
|
|
1654
2021
|
),
|
|
1655
2022
|
},
|
|
1656
|
-
}
|
|
2023
|
+
}
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
public async updatePerpMarketExpiry(
|
|
2028
|
+
perpMarketIndex: number,
|
|
2029
|
+
expiryTs: BN
|
|
2030
|
+
): Promise<TransactionSignature> {
|
|
2031
|
+
const updatePerpMarketExpiryIx = await this.getUpdatePerpMarketExpiryIx(
|
|
2032
|
+
perpMarketIndex,
|
|
2033
|
+
expiryTs
|
|
2034
|
+
);
|
|
1657
2035
|
const tx = await this.buildTransaction(updatePerpMarketExpiryIx);
|
|
1658
2036
|
|
|
1659
2037
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
@@ -1661,29 +2039,34 @@ export class AdminClient extends DriftClient {
|
|
|
1661
2039
|
return txSig;
|
|
1662
2040
|
}
|
|
1663
2041
|
|
|
2042
|
+
public async getUpdatePerpMarketExpiryIx(
|
|
2043
|
+
perpMarketIndex: number,
|
|
2044
|
+
expiryTs: BN
|
|
2045
|
+
): Promise<TransactionInstruction> {
|
|
2046
|
+
return await this.program.instruction.updatePerpMarketExpiry(expiryTs, {
|
|
2047
|
+
accounts: {
|
|
2048
|
+
admin: this.isSubscribed
|
|
2049
|
+
? this.getStateAccount().admin
|
|
2050
|
+
: this.wallet.publicKey,
|
|
2051
|
+
state: await this.getStatePublicKey(),
|
|
2052
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2053
|
+
this.program.programId,
|
|
2054
|
+
perpMarketIndex
|
|
2055
|
+
),
|
|
2056
|
+
},
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
|
|
1664
2060
|
public async updateSpotMarketOracle(
|
|
1665
2061
|
spotMarketIndex: number,
|
|
1666
2062
|
oracle: PublicKey,
|
|
1667
2063
|
oracleSource: OracleSource
|
|
1668
2064
|
): Promise<TransactionSignature> {
|
|
1669
|
-
const updateSpotMarketOracleIx =
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
accounts: {
|
|
1675
|
-
admin: this.isSubscribed
|
|
1676
|
-
? this.getStateAccount().admin
|
|
1677
|
-
: this.wallet.publicKey,
|
|
1678
|
-
state: await this.getStatePublicKey(),
|
|
1679
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1680
|
-
this.program.programId,
|
|
1681
|
-
spotMarketIndex
|
|
1682
|
-
),
|
|
1683
|
-
oracle: oracle,
|
|
1684
|
-
},
|
|
1685
|
-
}
|
|
1686
|
-
);
|
|
2065
|
+
const updateSpotMarketOracleIx = await this.getUpdateSpotMarketOracleIx(
|
|
2066
|
+
spotMarketIndex,
|
|
2067
|
+
oracle,
|
|
2068
|
+
oracleSource
|
|
2069
|
+
);
|
|
1687
2070
|
|
|
1688
2071
|
const tx = await this.buildTransaction(updateSpotMarketOracleIx);
|
|
1689
2072
|
|
|
@@ -1692,25 +2075,38 @@ export class AdminClient extends DriftClient {
|
|
|
1692
2075
|
return txSig;
|
|
1693
2076
|
}
|
|
1694
2077
|
|
|
2078
|
+
public async getUpdateSpotMarketOracleIx(
|
|
2079
|
+
spotMarketIndex: number,
|
|
2080
|
+
oracle: PublicKey,
|
|
2081
|
+
oracleSource: OracleSource
|
|
2082
|
+
): Promise<TransactionInstruction> {
|
|
2083
|
+
return await this.program.instruction.updateSpotMarketOracle(
|
|
2084
|
+
oracle,
|
|
2085
|
+
oracleSource,
|
|
2086
|
+
{
|
|
2087
|
+
accounts: {
|
|
2088
|
+
admin: this.isSubscribed
|
|
2089
|
+
? this.getStateAccount().admin
|
|
2090
|
+
: this.wallet.publicKey,
|
|
2091
|
+
state: await this.getStatePublicKey(),
|
|
2092
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2093
|
+
this.program.programId,
|
|
2094
|
+
spotMarketIndex
|
|
2095
|
+
),
|
|
2096
|
+
oracle: oracle,
|
|
2097
|
+
},
|
|
2098
|
+
}
|
|
2099
|
+
);
|
|
2100
|
+
}
|
|
2101
|
+
|
|
1695
2102
|
public async updateSpotMarketOrdersEnabled(
|
|
1696
2103
|
spotMarketIndex: number,
|
|
1697
2104
|
ordersEnabled: boolean
|
|
1698
2105
|
): Promise<TransactionSignature> {
|
|
1699
2106
|
const updateSpotMarketOrdersEnabledIx =
|
|
1700
|
-
await this.
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
accounts: {
|
|
1704
|
-
admin: this.isSubscribed
|
|
1705
|
-
? this.getStateAccount().admin
|
|
1706
|
-
: this.wallet.publicKey,
|
|
1707
|
-
state: await this.getStatePublicKey(),
|
|
1708
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1709
|
-
this.program.programId,
|
|
1710
|
-
spotMarketIndex
|
|
1711
|
-
),
|
|
1712
|
-
},
|
|
1713
|
-
}
|
|
2107
|
+
await this.getUpdateSpotMarketOrdersEnabledIx(
|
|
2108
|
+
spotMarketIndex,
|
|
2109
|
+
ordersEnabled
|
|
1714
2110
|
);
|
|
1715
2111
|
|
|
1716
2112
|
const tx = await this.buildTransaction(updateSpotMarketOrdersEnabledIx);
|
|
@@ -1720,22 +2116,35 @@ export class AdminClient extends DriftClient {
|
|
|
1720
2116
|
return txSig;
|
|
1721
2117
|
}
|
|
1722
2118
|
|
|
2119
|
+
public async getUpdateSpotMarketOrdersEnabledIx(
|
|
2120
|
+
spotMarketIndex: number,
|
|
2121
|
+
ordersEnabled: boolean
|
|
2122
|
+
): Promise<TransactionInstruction> {
|
|
2123
|
+
return await this.program.instruction.updateSpotMarketOrdersEnabled(
|
|
2124
|
+
ordersEnabled,
|
|
2125
|
+
{
|
|
2126
|
+
accounts: {
|
|
2127
|
+
admin: this.isSubscribed
|
|
2128
|
+
? this.getStateAccount().admin
|
|
2129
|
+
: this.wallet.publicKey,
|
|
2130
|
+
state: await this.getStatePublicKey(),
|
|
2131
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2132
|
+
this.program.programId,
|
|
2133
|
+
spotMarketIndex
|
|
2134
|
+
),
|
|
2135
|
+
},
|
|
2136
|
+
}
|
|
2137
|
+
);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
1723
2140
|
public async updateSerumFulfillmentConfigStatus(
|
|
1724
2141
|
serumFulfillmentConfig: PublicKey,
|
|
1725
2142
|
status: SpotFulfillmentConfigStatus
|
|
1726
2143
|
): Promise<TransactionSignature> {
|
|
1727
2144
|
const updateSerumFulfillmentConfigStatusIx =
|
|
1728
|
-
await this.
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
accounts: {
|
|
1732
|
-
admin: this.isSubscribed
|
|
1733
|
-
? this.getStateAccount().admin
|
|
1734
|
-
: this.wallet.publicKey,
|
|
1735
|
-
state: await this.getStatePublicKey(),
|
|
1736
|
-
serumFulfillmentConfig,
|
|
1737
|
-
},
|
|
1738
|
-
}
|
|
2145
|
+
await this.getUpdateSerumFulfillmentConfigStatusIx(
|
|
2146
|
+
serumFulfillmentConfig,
|
|
2147
|
+
status
|
|
1739
2148
|
);
|
|
1740
2149
|
|
|
1741
2150
|
const tx = await this.buildTransaction(
|
|
@@ -1747,6 +2156,24 @@ export class AdminClient extends DriftClient {
|
|
|
1747
2156
|
return txSig;
|
|
1748
2157
|
}
|
|
1749
2158
|
|
|
2159
|
+
public async getUpdateSerumFulfillmentConfigStatusIx(
|
|
2160
|
+
serumFulfillmentConfig: PublicKey,
|
|
2161
|
+
status: SpotFulfillmentConfigStatus
|
|
2162
|
+
): Promise<TransactionInstruction> {
|
|
2163
|
+
return await this.program.instruction.updateSerumFulfillmentConfigStatus(
|
|
2164
|
+
status,
|
|
2165
|
+
{
|
|
2166
|
+
accounts: {
|
|
2167
|
+
admin: this.isSubscribed
|
|
2168
|
+
? this.getStateAccount().admin
|
|
2169
|
+
: this.wallet.publicKey,
|
|
2170
|
+
state: await this.getStatePublicKey(),
|
|
2171
|
+
serumFulfillmentConfig,
|
|
2172
|
+
},
|
|
2173
|
+
}
|
|
2174
|
+
);
|
|
2175
|
+
}
|
|
2176
|
+
|
|
1750
2177
|
public async updatePhoenixFulfillmentConfigStatus(
|
|
1751
2178
|
phoenixFulfillmentConfig: PublicKey,
|
|
1752
2179
|
status: SpotFulfillmentConfigStatus
|
|
@@ -1771,23 +2198,32 @@ export class AdminClient extends DriftClient {
|
|
|
1771
2198
|
return txSig;
|
|
1772
2199
|
}
|
|
1773
2200
|
|
|
1774
|
-
public async
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
): Promise<
|
|
1778
|
-
|
|
1779
|
-
|
|
2201
|
+
public async getUpdatePhoenixFulfillmentConfigStatusIx(
|
|
2202
|
+
phoenixFulfillmentConfig: PublicKey,
|
|
2203
|
+
status: SpotFulfillmentConfigStatus
|
|
2204
|
+
): Promise<TransactionInstruction> {
|
|
2205
|
+
return await this.program.instruction.phoenixFulfillmentConfigStatus(
|
|
2206
|
+
status,
|
|
2207
|
+
{
|
|
1780
2208
|
accounts: {
|
|
1781
2209
|
admin: this.isSubscribed
|
|
1782
2210
|
? this.getStateAccount().admin
|
|
1783
2211
|
: this.wallet.publicKey,
|
|
1784
2212
|
state: await this.getStatePublicKey(),
|
|
1785
|
-
|
|
1786
|
-
this.program.programId,
|
|
1787
|
-
spotMarketIndex
|
|
1788
|
-
),
|
|
2213
|
+
phoenixFulfillmentConfig,
|
|
1789
2214
|
},
|
|
1790
|
-
}
|
|
2215
|
+
}
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
public async updateSpotMarketExpiry(
|
|
2220
|
+
spotMarketIndex: number,
|
|
2221
|
+
expiryTs: BN
|
|
2222
|
+
): Promise<TransactionSignature> {
|
|
2223
|
+
const updateSpotMarketExpiryIx = await this.getUpdateSpotMarketExpiryIx(
|
|
2224
|
+
spotMarketIndex,
|
|
2225
|
+
expiryTs
|
|
2226
|
+
);
|
|
1791
2227
|
|
|
1792
2228
|
const tx = await this.buildTransaction(updateSpotMarketExpiryIx);
|
|
1793
2229
|
|
|
@@ -1796,18 +2232,30 @@ export class AdminClient extends DriftClient {
|
|
|
1796
2232
|
return txSig;
|
|
1797
2233
|
}
|
|
1798
2234
|
|
|
2235
|
+
public async getUpdateSpotMarketExpiryIx(
|
|
2236
|
+
spotMarketIndex: number,
|
|
2237
|
+
expiryTs: BN
|
|
2238
|
+
): Promise<TransactionInstruction> {
|
|
2239
|
+
return await this.program.instruction.updateSpotMarketExpiry(expiryTs, {
|
|
2240
|
+
accounts: {
|
|
2241
|
+
admin: this.isSubscribed
|
|
2242
|
+
? this.getStateAccount().admin
|
|
2243
|
+
: this.wallet.publicKey,
|
|
2244
|
+
state: await this.getStatePublicKey(),
|
|
2245
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2246
|
+
this.program.programId,
|
|
2247
|
+
spotMarketIndex
|
|
2248
|
+
),
|
|
2249
|
+
},
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
|
|
1799
2253
|
public async updateWhitelistMint(
|
|
1800
2254
|
whitelistMint?: PublicKey
|
|
1801
2255
|
): Promise<TransactionSignature> {
|
|
1802
|
-
const updateWhitelistMintIx =
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
admin: this.isSubscribed
|
|
1806
|
-
? this.getStateAccount().admin
|
|
1807
|
-
: this.wallet.publicKey,
|
|
1808
|
-
state: await this.getStatePublicKey(),
|
|
1809
|
-
},
|
|
1810
|
-
});
|
|
2256
|
+
const updateWhitelistMintIx = await this.getUpdateWhitelistMintIx(
|
|
2257
|
+
whitelistMint
|
|
2258
|
+
);
|
|
1811
2259
|
|
|
1812
2260
|
const tx = await this.buildTransaction(updateWhitelistMintIx);
|
|
1813
2261
|
|
|
@@ -1816,18 +2264,25 @@ export class AdminClient extends DriftClient {
|
|
|
1816
2264
|
return txSig;
|
|
1817
2265
|
}
|
|
1818
2266
|
|
|
2267
|
+
public async getUpdateWhitelistMintIx(
|
|
2268
|
+
whitelistMint?: PublicKey
|
|
2269
|
+
): Promise<TransactionInstruction> {
|
|
2270
|
+
return await this.program.instruction.updateWhitelistMint(whitelistMint, {
|
|
2271
|
+
accounts: {
|
|
2272
|
+
admin: this.isSubscribed
|
|
2273
|
+
? this.getStateAccount().admin
|
|
2274
|
+
: this.wallet.publicKey,
|
|
2275
|
+
state: await this.getStatePublicKey(),
|
|
2276
|
+
},
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
|
|
1819
2280
|
public async updateDiscountMint(
|
|
1820
2281
|
discountMint: PublicKey
|
|
1821
2282
|
): Promise<TransactionSignature> {
|
|
1822
|
-
const updateDiscountMintIx =
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
admin: this.isSubscribed
|
|
1826
|
-
? this.getStateAccount().admin
|
|
1827
|
-
: this.wallet.publicKey,
|
|
1828
|
-
state: await this.getStatePublicKey(),
|
|
1829
|
-
},
|
|
1830
|
-
});
|
|
2283
|
+
const updateDiscountMintIx = await this.getUpdateDiscountMintIx(
|
|
2284
|
+
discountMint
|
|
2285
|
+
);
|
|
1831
2286
|
|
|
1832
2287
|
const tx = await this.buildTransaction(updateDiscountMintIx);
|
|
1833
2288
|
|
|
@@ -1836,6 +2291,19 @@ export class AdminClient extends DriftClient {
|
|
|
1836
2291
|
return txSig;
|
|
1837
2292
|
}
|
|
1838
2293
|
|
|
2294
|
+
public async getUpdateDiscountMintIx(
|
|
2295
|
+
discountMint: PublicKey
|
|
2296
|
+
): Promise<TransactionInstruction> {
|
|
2297
|
+
return await this.program.instruction.updateDiscountMint(discountMint, {
|
|
2298
|
+
accounts: {
|
|
2299
|
+
admin: this.isSubscribed
|
|
2300
|
+
? this.getStateAccount().admin
|
|
2301
|
+
: this.wallet.publicKey,
|
|
2302
|
+
state: await this.getStatePublicKey(),
|
|
2303
|
+
},
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
|
|
1839
2307
|
public async updateSpotMarketMarginWeights(
|
|
1840
2308
|
spotMarketIndex: number,
|
|
1841
2309
|
initialAssetWeight: number,
|
|
@@ -1845,24 +2313,13 @@ export class AdminClient extends DriftClient {
|
|
|
1845
2313
|
imfFactor = 0
|
|
1846
2314
|
): Promise<TransactionSignature> {
|
|
1847
2315
|
const updateSpotMarketMarginWeightsIx =
|
|
1848
|
-
await this.
|
|
2316
|
+
await this.getUpdateSpotMarketMarginWeightsIx(
|
|
2317
|
+
spotMarketIndex,
|
|
1849
2318
|
initialAssetWeight,
|
|
1850
2319
|
maintenanceAssetWeight,
|
|
1851
2320
|
initialLiabilityWeight,
|
|
1852
2321
|
maintenanceLiabilityWeight,
|
|
1853
|
-
imfFactor
|
|
1854
|
-
{
|
|
1855
|
-
accounts: {
|
|
1856
|
-
admin: this.isSubscribed
|
|
1857
|
-
? this.getStateAccount().admin
|
|
1858
|
-
: this.wallet.publicKey,
|
|
1859
|
-
state: await this.getStatePublicKey(),
|
|
1860
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1861
|
-
this.program.programId,
|
|
1862
|
-
spotMarketIndex
|
|
1863
|
-
),
|
|
1864
|
-
},
|
|
1865
|
-
}
|
|
2322
|
+
imfFactor
|
|
1866
2323
|
);
|
|
1867
2324
|
|
|
1868
2325
|
const tx = await this.buildTransaction(updateSpotMarketMarginWeightsIx);
|
|
@@ -1872,6 +2329,35 @@ export class AdminClient extends DriftClient {
|
|
|
1872
2329
|
return txSig;
|
|
1873
2330
|
}
|
|
1874
2331
|
|
|
2332
|
+
public async getUpdateSpotMarketMarginWeightsIx(
|
|
2333
|
+
spotMarketIndex: number,
|
|
2334
|
+
initialAssetWeight: number,
|
|
2335
|
+
maintenanceAssetWeight: number,
|
|
2336
|
+
initialLiabilityWeight: number,
|
|
2337
|
+
maintenanceLiabilityWeight: number,
|
|
2338
|
+
imfFactor = 0
|
|
2339
|
+
): Promise<TransactionInstruction> {
|
|
2340
|
+
return await this.program.instruction.updateSpotMarketMarginWeights(
|
|
2341
|
+
initialAssetWeight,
|
|
2342
|
+
maintenanceAssetWeight,
|
|
2343
|
+
initialLiabilityWeight,
|
|
2344
|
+
maintenanceLiabilityWeight,
|
|
2345
|
+
imfFactor,
|
|
2346
|
+
{
|
|
2347
|
+
accounts: {
|
|
2348
|
+
admin: this.isSubscribed
|
|
2349
|
+
? this.getStateAccount().admin
|
|
2350
|
+
: this.wallet.publicKey,
|
|
2351
|
+
state: await this.getStatePublicKey(),
|
|
2352
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2353
|
+
this.program.programId,
|
|
2354
|
+
spotMarketIndex
|
|
2355
|
+
),
|
|
2356
|
+
},
|
|
2357
|
+
}
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2360
|
+
|
|
1875
2361
|
public async updateSpotMarketBorrowRate(
|
|
1876
2362
|
spotMarketIndex: number,
|
|
1877
2363
|
optimalUtilization: number,
|
|
@@ -1879,22 +2365,11 @@ export class AdminClient extends DriftClient {
|
|
|
1879
2365
|
optimalMaxRate: number
|
|
1880
2366
|
): Promise<TransactionSignature> {
|
|
1881
2367
|
const updateSpotMarketBorrowRateIx =
|
|
1882
|
-
await this.
|
|
2368
|
+
await this.getUpdateSpotMarketBorrowRateIx(
|
|
2369
|
+
spotMarketIndex,
|
|
1883
2370
|
optimalUtilization,
|
|
1884
2371
|
optimalBorrowRate,
|
|
1885
|
-
optimalMaxRate
|
|
1886
|
-
{
|
|
1887
|
-
accounts: {
|
|
1888
|
-
admin: this.isSubscribed
|
|
1889
|
-
? this.getStateAccount().admin
|
|
1890
|
-
: this.wallet.publicKey,
|
|
1891
|
-
state: await this.getStatePublicKey(),
|
|
1892
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1893
|
-
this.program.programId,
|
|
1894
|
-
spotMarketIndex
|
|
1895
|
-
),
|
|
1896
|
-
},
|
|
1897
|
-
}
|
|
2372
|
+
optimalMaxRate
|
|
1898
2373
|
);
|
|
1899
2374
|
|
|
1900
2375
|
const tx = await this.buildTransaction(updateSpotMarketBorrowRateIx);
|
|
@@ -1904,12 +2379,17 @@ export class AdminClient extends DriftClient {
|
|
|
1904
2379
|
return txSig;
|
|
1905
2380
|
}
|
|
1906
2381
|
|
|
1907
|
-
public async
|
|
2382
|
+
public async getUpdateSpotMarketBorrowRateIx(
|
|
1908
2383
|
spotMarketIndex: number,
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
2384
|
+
optimalUtilization: number,
|
|
2385
|
+
optimalBorrowRate: number,
|
|
2386
|
+
optimalMaxRate: number
|
|
2387
|
+
): Promise<TransactionInstruction> {
|
|
2388
|
+
return await this.program.instruction.updateSpotMarketBorrowRate(
|
|
2389
|
+
optimalUtilization,
|
|
2390
|
+
optimalBorrowRate,
|
|
2391
|
+
optimalMaxRate,
|
|
2392
|
+
{
|
|
1913
2393
|
accounts: {
|
|
1914
2394
|
admin: this.isSubscribed
|
|
1915
2395
|
? this.getStateAccount().admin
|
|
@@ -1920,7 +2400,16 @@ export class AdminClient extends DriftClient {
|
|
|
1920
2400
|
spotMarketIndex
|
|
1921
2401
|
),
|
|
1922
2402
|
},
|
|
1923
|
-
}
|
|
2403
|
+
}
|
|
2404
|
+
);
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
public async updateSpotMarketAssetTier(
|
|
2408
|
+
spotMarketIndex: number,
|
|
2409
|
+
assetTier: AssetTier
|
|
2410
|
+
): Promise<TransactionSignature> {
|
|
2411
|
+
const updateSpotMarketAssetTierIx =
|
|
2412
|
+
await this.getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier);
|
|
1924
2413
|
|
|
1925
2414
|
const tx = await this.buildTransaction(updateSpotMarketAssetTierIx);
|
|
1926
2415
|
|
|
@@ -1929,23 +2418,32 @@ export class AdminClient extends DriftClient {
|
|
|
1929
2418
|
return txSig;
|
|
1930
2419
|
}
|
|
1931
2420
|
|
|
2421
|
+
public async getUpdateSpotMarketAssetTierIx(
|
|
2422
|
+
spotMarketIndex: number,
|
|
2423
|
+
assetTier: AssetTier
|
|
2424
|
+
): Promise<TransactionInstruction> {
|
|
2425
|
+
return await this.program.instruction.updateSpotMarketAssetTier(assetTier, {
|
|
2426
|
+
accounts: {
|
|
2427
|
+
admin: this.isSubscribed
|
|
2428
|
+
? this.getStateAccount().admin
|
|
2429
|
+
: this.wallet.publicKey,
|
|
2430
|
+
state: await this.getStatePublicKey(),
|
|
2431
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2432
|
+
this.program.programId,
|
|
2433
|
+
spotMarketIndex
|
|
2434
|
+
),
|
|
2435
|
+
},
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
|
|
1932
2439
|
public async updateSpotMarketStatus(
|
|
1933
2440
|
spotMarketIndex: number,
|
|
1934
2441
|
marketStatus: MarketStatus
|
|
1935
2442
|
): Promise<TransactionSignature> {
|
|
1936
|
-
const updateSpotMarketStatusIx =
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
? this.getStateAccount().admin
|
|
1941
|
-
: this.wallet.publicKey,
|
|
1942
|
-
state: await this.getStatePublicKey(),
|
|
1943
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1944
|
-
this.program.programId,
|
|
1945
|
-
spotMarketIndex
|
|
1946
|
-
),
|
|
1947
|
-
},
|
|
1948
|
-
});
|
|
2443
|
+
const updateSpotMarketStatusIx = await this.getUpdateSpotMarketStatusIx(
|
|
2444
|
+
spotMarketIndex,
|
|
2445
|
+
marketStatus
|
|
2446
|
+
);
|
|
1949
2447
|
|
|
1950
2448
|
const tx = await this.buildTransaction(updateSpotMarketStatusIx);
|
|
1951
2449
|
|
|
@@ -1954,25 +2452,32 @@ export class AdminClient extends DriftClient {
|
|
|
1954
2452
|
return txSig;
|
|
1955
2453
|
}
|
|
1956
2454
|
|
|
2455
|
+
public async getUpdateSpotMarketStatusIx(
|
|
2456
|
+
spotMarketIndex: number,
|
|
2457
|
+
marketStatus: MarketStatus
|
|
2458
|
+
): Promise<TransactionInstruction> {
|
|
2459
|
+
return await this.program.instruction.updateSpotMarketStatus(marketStatus, {
|
|
2460
|
+
accounts: {
|
|
2461
|
+
admin: this.isSubscribed
|
|
2462
|
+
? this.getStateAccount().admin
|
|
2463
|
+
: this.wallet.publicKey,
|
|
2464
|
+
state: await this.getStatePublicKey(),
|
|
2465
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2466
|
+
this.program.programId,
|
|
2467
|
+
spotMarketIndex
|
|
2468
|
+
),
|
|
2469
|
+
},
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
|
|
1957
2473
|
public async updateSpotMarketPausedOperations(
|
|
1958
2474
|
spotMarketIndex: number,
|
|
1959
2475
|
pausedOperations: number
|
|
1960
2476
|
): Promise<TransactionSignature> {
|
|
1961
2477
|
const updateSpotMarketPausedOperationsIx =
|
|
1962
|
-
await this.
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
accounts: {
|
|
1966
|
-
admin: this.isSubscribed
|
|
1967
|
-
? this.getStateAccount().admin
|
|
1968
|
-
: this.wallet.publicKey,
|
|
1969
|
-
state: await this.getStatePublicKey(),
|
|
1970
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
1971
|
-
this.program.programId,
|
|
1972
|
-
spotMarketIndex
|
|
1973
|
-
),
|
|
1974
|
-
},
|
|
1975
|
-
}
|
|
2478
|
+
await this.getUpdateSpotMarketPausedOperationsIx(
|
|
2479
|
+
spotMarketIndex,
|
|
2480
|
+
pausedOperations
|
|
1976
2481
|
);
|
|
1977
2482
|
|
|
1978
2483
|
const tx = await this.buildTransaction(updateSpotMarketPausedOperationsIx);
|
|
@@ -1982,23 +2487,35 @@ export class AdminClient extends DriftClient {
|
|
|
1982
2487
|
return txSig;
|
|
1983
2488
|
}
|
|
1984
2489
|
|
|
1985
|
-
public async
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
): Promise<
|
|
1989
|
-
|
|
1990
|
-
|
|
2490
|
+
public async getUpdateSpotMarketPausedOperationsIx(
|
|
2491
|
+
spotMarketIndex: number,
|
|
2492
|
+
pausedOperations: number
|
|
2493
|
+
): Promise<TransactionInstruction> {
|
|
2494
|
+
return await this.program.instruction.updateSpotMarketPausedOperations(
|
|
2495
|
+
pausedOperations,
|
|
2496
|
+
{
|
|
1991
2497
|
accounts: {
|
|
1992
2498
|
admin: this.isSubscribed
|
|
1993
2499
|
? this.getStateAccount().admin
|
|
1994
2500
|
: this.wallet.publicKey,
|
|
1995
2501
|
state: await this.getStatePublicKey(),
|
|
1996
|
-
|
|
2502
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1997
2503
|
this.program.programId,
|
|
1998
|
-
|
|
2504
|
+
spotMarketIndex
|
|
1999
2505
|
),
|
|
2000
2506
|
},
|
|
2001
|
-
}
|
|
2507
|
+
}
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
public async updatePerpMarketStatus(
|
|
2512
|
+
perpMarketIndex: number,
|
|
2513
|
+
marketStatus: MarketStatus
|
|
2514
|
+
): Promise<TransactionSignature> {
|
|
2515
|
+
const updatePerpMarketStatusIx = await this.getUpdatePerpMarketStatusIx(
|
|
2516
|
+
perpMarketIndex,
|
|
2517
|
+
marketStatus
|
|
2518
|
+
);
|
|
2002
2519
|
|
|
2003
2520
|
const tx = await this.buildTransaction(updatePerpMarketStatusIx);
|
|
2004
2521
|
|
|
@@ -2007,25 +2524,32 @@ export class AdminClient extends DriftClient {
|
|
|
2007
2524
|
return txSig;
|
|
2008
2525
|
}
|
|
2009
2526
|
|
|
2527
|
+
public async getUpdatePerpMarketStatusIx(
|
|
2528
|
+
perpMarketIndex: number,
|
|
2529
|
+
marketStatus: MarketStatus
|
|
2530
|
+
): Promise<TransactionInstruction> {
|
|
2531
|
+
return await this.program.instruction.updatePerpMarketStatus(marketStatus, {
|
|
2532
|
+
accounts: {
|
|
2533
|
+
admin: this.isSubscribed
|
|
2534
|
+
? this.getStateAccount().admin
|
|
2535
|
+
: this.wallet.publicKey,
|
|
2536
|
+
state: await this.getStatePublicKey(),
|
|
2537
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2538
|
+
this.program.programId,
|
|
2539
|
+
perpMarketIndex
|
|
2540
|
+
),
|
|
2541
|
+
},
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2010
2545
|
public async updatePerpMarketPausedOperations(
|
|
2011
2546
|
perpMarketIndex: number,
|
|
2012
2547
|
pausedOperations: number
|
|
2013
2548
|
): Promise<TransactionSignature> {
|
|
2014
2549
|
const updatePerpMarketPausedOperationsIx =
|
|
2015
|
-
await this.
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
accounts: {
|
|
2019
|
-
admin: this.isSubscribed
|
|
2020
|
-
? this.getStateAccount().admin
|
|
2021
|
-
: this.wallet.publicKey,
|
|
2022
|
-
state: await this.getStatePublicKey(),
|
|
2023
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2024
|
-
this.program.programId,
|
|
2025
|
-
perpMarketIndex
|
|
2026
|
-
),
|
|
2027
|
-
},
|
|
2028
|
-
}
|
|
2550
|
+
await this.getUpdatePerpMarketPausedOperationsIx(
|
|
2551
|
+
perpMarketIndex,
|
|
2552
|
+
pausedOperations
|
|
2029
2553
|
);
|
|
2030
2554
|
|
|
2031
2555
|
const tx = await this.buildTransaction(updatePerpMarketPausedOperationsIx);
|
|
@@ -2035,25 +2559,35 @@ export class AdminClient extends DriftClient {
|
|
|
2035
2559
|
return txSig;
|
|
2036
2560
|
}
|
|
2037
2561
|
|
|
2562
|
+
public async getUpdatePerpMarketPausedOperationsIx(
|
|
2563
|
+
perpMarketIndex: number,
|
|
2564
|
+
pausedOperations: number
|
|
2565
|
+
): Promise<TransactionInstruction> {
|
|
2566
|
+
return await this.program.instruction.updatePerpMarketPausedOperations(
|
|
2567
|
+
pausedOperations,
|
|
2568
|
+
{
|
|
2569
|
+
accounts: {
|
|
2570
|
+
admin: this.isSubscribed
|
|
2571
|
+
? this.getStateAccount().admin
|
|
2572
|
+
: this.wallet.publicKey,
|
|
2573
|
+
state: await this.getStatePublicKey(),
|
|
2574
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2575
|
+
this.program.programId,
|
|
2576
|
+
perpMarketIndex
|
|
2577
|
+
),
|
|
2578
|
+
},
|
|
2579
|
+
}
|
|
2580
|
+
);
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2038
2583
|
public async updatePerpMarketContractTier(
|
|
2039
2584
|
perpMarketIndex: number,
|
|
2040
2585
|
contractTier: ContractTier
|
|
2041
2586
|
): Promise<TransactionSignature> {
|
|
2042
2587
|
const updatePerpMarketContractTierIx =
|
|
2043
|
-
await this.
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
accounts: {
|
|
2047
|
-
admin: this.isSubscribed
|
|
2048
|
-
? this.getStateAccount().admin
|
|
2049
|
-
: this.wallet.publicKey,
|
|
2050
|
-
state: await this.getStatePublicKey(),
|
|
2051
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2052
|
-
this.program.programId,
|
|
2053
|
-
perpMarketIndex
|
|
2054
|
-
),
|
|
2055
|
-
},
|
|
2056
|
-
}
|
|
2588
|
+
await this.getUpdatePerpMarketContractTierIx(
|
|
2589
|
+
perpMarketIndex,
|
|
2590
|
+
contractTier
|
|
2057
2591
|
);
|
|
2058
2592
|
|
|
2059
2593
|
const tx = await this.buildTransaction(updatePerpMarketContractTierIx);
|
|
@@ -2063,18 +2597,33 @@ export class AdminClient extends DriftClient {
|
|
|
2063
2597
|
return txSig;
|
|
2064
2598
|
}
|
|
2065
2599
|
|
|
2600
|
+
public async getUpdatePerpMarketContractTierIx(
|
|
2601
|
+
perpMarketIndex: number,
|
|
2602
|
+
contractTier: ContractTier
|
|
2603
|
+
): Promise<TransactionInstruction> {
|
|
2604
|
+
return await this.program.instruction.updatePerpMarketContractTier(
|
|
2605
|
+
contractTier,
|
|
2606
|
+
{
|
|
2607
|
+
accounts: {
|
|
2608
|
+
admin: this.isSubscribed
|
|
2609
|
+
? this.getStateAccount().admin
|
|
2610
|
+
: this.wallet.publicKey,
|
|
2611
|
+
state: await this.getStatePublicKey(),
|
|
2612
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2613
|
+
this.program.programId,
|
|
2614
|
+
perpMarketIndex
|
|
2615
|
+
),
|
|
2616
|
+
},
|
|
2617
|
+
}
|
|
2618
|
+
);
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2066
2621
|
public async updateExchangeStatus(
|
|
2067
2622
|
exchangeStatus: ExchangeStatus
|
|
2068
2623
|
): Promise<TransactionSignature> {
|
|
2069
|
-
const updateExchangeStatusIx =
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
admin: this.isSubscribed
|
|
2073
|
-
? this.getStateAccount().admin
|
|
2074
|
-
: this.wallet.publicKey,
|
|
2075
|
-
state: await this.getStatePublicKey(),
|
|
2076
|
-
},
|
|
2077
|
-
});
|
|
2624
|
+
const updateExchangeStatusIx = await this.getUpdateExchangeStatusIx(
|
|
2625
|
+
exchangeStatus
|
|
2626
|
+
);
|
|
2078
2627
|
|
|
2079
2628
|
const tx = await this.buildTransaction(updateExchangeStatusIx);
|
|
2080
2629
|
|
|
@@ -2083,21 +2632,24 @@ export class AdminClient extends DriftClient {
|
|
|
2083
2632
|
return txSig;
|
|
2084
2633
|
}
|
|
2085
2634
|
|
|
2635
|
+
public async getUpdateExchangeStatusIx(
|
|
2636
|
+
exchangeStatus: ExchangeStatus
|
|
2637
|
+
): Promise<TransactionInstruction> {
|
|
2638
|
+
return await this.program.instruction.updateExchangeStatus(exchangeStatus, {
|
|
2639
|
+
accounts: {
|
|
2640
|
+
admin: this.isSubscribed
|
|
2641
|
+
? this.getStateAccount().admin
|
|
2642
|
+
: this.wallet.publicKey,
|
|
2643
|
+
state: await this.getStatePublicKey(),
|
|
2644
|
+
},
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2086
2648
|
public async updatePerpAuctionDuration(
|
|
2087
2649
|
minDuration: BN | number
|
|
2088
2650
|
): Promise<TransactionSignature> {
|
|
2089
2651
|
const updatePerpAuctionDurationIx =
|
|
2090
|
-
await this.
|
|
2091
|
-
typeof minDuration === 'number' ? minDuration : minDuration.toNumber(),
|
|
2092
|
-
{
|
|
2093
|
-
accounts: {
|
|
2094
|
-
admin: this.isSubscribed
|
|
2095
|
-
? this.getStateAccount().admin
|
|
2096
|
-
: this.wallet.publicKey,
|
|
2097
|
-
state: await this.getStatePublicKey(),
|
|
2098
|
-
},
|
|
2099
|
-
}
|
|
2100
|
-
);
|
|
2652
|
+
await this.getUpdatePerpAuctionDurationIx(minDuration);
|
|
2101
2653
|
|
|
2102
2654
|
const tx = await this.buildTransaction(updatePerpAuctionDurationIx);
|
|
2103
2655
|
|
|
@@ -2106,21 +2658,27 @@ export class AdminClient extends DriftClient {
|
|
|
2106
2658
|
return txSig;
|
|
2107
2659
|
}
|
|
2108
2660
|
|
|
2661
|
+
public async getUpdatePerpAuctionDurationIx(
|
|
2662
|
+
minDuration: BN | number
|
|
2663
|
+
): Promise<TransactionInstruction> {
|
|
2664
|
+
return await this.program.instruction.updatePerpAuctionDuration(
|
|
2665
|
+
typeof minDuration === 'number' ? minDuration : minDuration.toNumber(),
|
|
2666
|
+
{
|
|
2667
|
+
accounts: {
|
|
2668
|
+
admin: this.isSubscribed
|
|
2669
|
+
? this.getStateAccount().admin
|
|
2670
|
+
: this.wallet.publicKey,
|
|
2671
|
+
state: await this.getStatePublicKey(),
|
|
2672
|
+
},
|
|
2673
|
+
}
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2109
2677
|
public async updateSpotAuctionDuration(
|
|
2110
2678
|
defaultAuctionDuration: number
|
|
2111
2679
|
): Promise<TransactionSignature> {
|
|
2112
2680
|
const updateSpotAuctionDurationIx =
|
|
2113
|
-
await this.
|
|
2114
|
-
defaultAuctionDuration,
|
|
2115
|
-
{
|
|
2116
|
-
accounts: {
|
|
2117
|
-
admin: this.isSubscribed
|
|
2118
|
-
? this.getStateAccount().admin
|
|
2119
|
-
: this.wallet.publicKey,
|
|
2120
|
-
state: await this.getStatePublicKey(),
|
|
2121
|
-
},
|
|
2122
|
-
}
|
|
2123
|
-
);
|
|
2681
|
+
await this.getUpdateSpotAuctionDurationIx(defaultAuctionDuration);
|
|
2124
2682
|
|
|
2125
2683
|
const tx = await this.buildTransaction(updateSpotAuctionDurationIx);
|
|
2126
2684
|
|
|
@@ -2129,25 +2687,30 @@ export class AdminClient extends DriftClient {
|
|
|
2129
2687
|
return txSig;
|
|
2130
2688
|
}
|
|
2131
2689
|
|
|
2690
|
+
public async getUpdateSpotAuctionDurationIx(
|
|
2691
|
+
defaultAuctionDuration: number
|
|
2692
|
+
): Promise<TransactionInstruction> {
|
|
2693
|
+
return await this.program.instruction.updateSpotAuctionDuration(
|
|
2694
|
+
defaultAuctionDuration,
|
|
2695
|
+
{
|
|
2696
|
+
accounts: {
|
|
2697
|
+
admin: this.isSubscribed
|
|
2698
|
+
? this.getStateAccount().admin
|
|
2699
|
+
: this.wallet.publicKey,
|
|
2700
|
+
state: await this.getStatePublicKey(),
|
|
2701
|
+
},
|
|
2702
|
+
}
|
|
2703
|
+
);
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2132
2706
|
public async updatePerpMarketMaxFillReserveFraction(
|
|
2133
2707
|
perpMarketIndex: number,
|
|
2134
2708
|
maxBaseAssetAmountRatio: number
|
|
2135
2709
|
): Promise<TransactionSignature> {
|
|
2136
2710
|
const updatePerpMarketMaxFillReserveFractionIx =
|
|
2137
|
-
await this.
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
accounts: {
|
|
2141
|
-
admin: this.isSubscribed
|
|
2142
|
-
? this.getStateAccount().admin
|
|
2143
|
-
: this.wallet.publicKey,
|
|
2144
|
-
state: await this.getStatePublicKey(),
|
|
2145
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2146
|
-
this.program.programId,
|
|
2147
|
-
perpMarketIndex
|
|
2148
|
-
),
|
|
2149
|
-
},
|
|
2150
|
-
}
|
|
2711
|
+
await this.getUpdatePerpMarketMaxFillReserveFractionIx(
|
|
2712
|
+
perpMarketIndex,
|
|
2713
|
+
maxBaseAssetAmountRatio
|
|
2151
2714
|
);
|
|
2152
2715
|
|
|
2153
2716
|
const tx = await this.buildTransaction(
|
|
@@ -2159,20 +2722,35 @@ export class AdminClient extends DriftClient {
|
|
|
2159
2722
|
return txSig;
|
|
2160
2723
|
}
|
|
2161
2724
|
|
|
2162
|
-
public async
|
|
2725
|
+
public async getUpdatePerpMarketMaxFillReserveFractionIx(
|
|
2163
2726
|
perpMarketIndex: number,
|
|
2164
|
-
|
|
2165
|
-
): Promise<
|
|
2166
|
-
|
|
2167
|
-
|
|
2727
|
+
maxBaseAssetAmountRatio: number
|
|
2728
|
+
): Promise<TransactionInstruction> {
|
|
2729
|
+
return await this.program.instruction.updatePerpMarketMaxFillReserveFraction(
|
|
2730
|
+
maxBaseAssetAmountRatio,
|
|
2731
|
+
{
|
|
2168
2732
|
accounts: {
|
|
2169
2733
|
admin: this.isSubscribed
|
|
2170
2734
|
? this.getStateAccount().admin
|
|
2171
2735
|
: this.wallet.publicKey,
|
|
2172
2736
|
state: await this.getStatePublicKey(),
|
|
2173
|
-
perpMarket:
|
|
2737
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2738
|
+
this.program.programId,
|
|
2739
|
+
perpMarketIndex
|
|
2740
|
+
),
|
|
2174
2741
|
},
|
|
2175
|
-
}
|
|
2742
|
+
}
|
|
2743
|
+
);
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
public async updateMaxSlippageRatio(
|
|
2747
|
+
perpMarketIndex: number,
|
|
2748
|
+
maxSlippageRatio: number
|
|
2749
|
+
): Promise<TransactionSignature> {
|
|
2750
|
+
const updateMaxSlippageRatioIx = await this.getUpdateMaxSlippageRatioIx(
|
|
2751
|
+
perpMarketIndex,
|
|
2752
|
+
maxSlippageRatio
|
|
2753
|
+
);
|
|
2176
2754
|
|
|
2177
2755
|
const tx = await this.buildTransaction(updateMaxSlippageRatioIx);
|
|
2178
2756
|
|
|
@@ -2181,27 +2759,34 @@ export class AdminClient extends DriftClient {
|
|
|
2181
2759
|
return txSig;
|
|
2182
2760
|
}
|
|
2183
2761
|
|
|
2762
|
+
public async getUpdateMaxSlippageRatioIx(
|
|
2763
|
+
perpMarketIndex: number,
|
|
2764
|
+
maxSlippageRatio: number
|
|
2765
|
+
): Promise<TransactionInstruction> {
|
|
2766
|
+
return await this.program.instruction.updateMaxSlippageRatio(
|
|
2767
|
+
maxSlippageRatio,
|
|
2768
|
+
{
|
|
2769
|
+
accounts: {
|
|
2770
|
+
admin: this.isSubscribed
|
|
2771
|
+
? this.getStateAccount().admin
|
|
2772
|
+
: this.wallet.publicKey,
|
|
2773
|
+
state: await this.getStatePublicKey(),
|
|
2774
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
2775
|
+
},
|
|
2776
|
+
}
|
|
2777
|
+
);
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2184
2780
|
public async updatePerpMarketUnrealizedAssetWeight(
|
|
2185
2781
|
perpMarketIndex: number,
|
|
2186
2782
|
unrealizedInitialAssetWeight: number,
|
|
2187
2783
|
unrealizedMaintenanceAssetWeight: number
|
|
2188
2784
|
): Promise<TransactionSignature> {
|
|
2189
2785
|
const updatePerpMarketUnrealizedAssetWeightIx =
|
|
2190
|
-
await this.
|
|
2786
|
+
await this.getUpdatePerpMarketUnrealizedAssetWeightIx(
|
|
2787
|
+
perpMarketIndex,
|
|
2191
2788
|
unrealizedInitialAssetWeight,
|
|
2192
|
-
unrealizedMaintenanceAssetWeight
|
|
2193
|
-
{
|
|
2194
|
-
accounts: {
|
|
2195
|
-
admin: this.isSubscribed
|
|
2196
|
-
? this.getStateAccount().admin
|
|
2197
|
-
: this.wallet.publicKey,
|
|
2198
|
-
state: await this.getStatePublicKey(),
|
|
2199
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2200
|
-
this.program.programId,
|
|
2201
|
-
perpMarketIndex
|
|
2202
|
-
),
|
|
2203
|
-
},
|
|
2204
|
-
}
|
|
2789
|
+
unrealizedMaintenanceAssetWeight
|
|
2205
2790
|
);
|
|
2206
2791
|
|
|
2207
2792
|
const tx = await this.buildTransaction(
|
|
@@ -2213,6 +2798,29 @@ export class AdminClient extends DriftClient {
|
|
|
2213
2798
|
return txSig;
|
|
2214
2799
|
}
|
|
2215
2800
|
|
|
2801
|
+
public async getUpdatePerpMarketUnrealizedAssetWeightIx(
|
|
2802
|
+
perpMarketIndex: number,
|
|
2803
|
+
unrealizedInitialAssetWeight: number,
|
|
2804
|
+
unrealizedMaintenanceAssetWeight: number
|
|
2805
|
+
): Promise<TransactionInstruction> {
|
|
2806
|
+
return await this.program.instruction.updatePerpMarketUnrealizedAssetWeight(
|
|
2807
|
+
unrealizedInitialAssetWeight,
|
|
2808
|
+
unrealizedMaintenanceAssetWeight,
|
|
2809
|
+
{
|
|
2810
|
+
accounts: {
|
|
2811
|
+
admin: this.isSubscribed
|
|
2812
|
+
? this.getStateAccount().admin
|
|
2813
|
+
: this.wallet.publicKey,
|
|
2814
|
+
state: await this.getStatePublicKey(),
|
|
2815
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2816
|
+
this.program.programId,
|
|
2817
|
+
perpMarketIndex
|
|
2818
|
+
),
|
|
2819
|
+
},
|
|
2820
|
+
}
|
|
2821
|
+
);
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2216
2824
|
public async updatePerpMarketMaxImbalances(
|
|
2217
2825
|
perpMarketIndex: number,
|
|
2218
2826
|
unrealizedMaxImbalance: BN,
|
|
@@ -2220,22 +2828,11 @@ export class AdminClient extends DriftClient {
|
|
|
2220
2828
|
quoteMaxInsurance: BN
|
|
2221
2829
|
): Promise<TransactionSignature> {
|
|
2222
2830
|
const updatePerpMarketMaxImabalancesIx =
|
|
2223
|
-
await this.
|
|
2831
|
+
await this.getUpdatePerpMarketMaxImbalancesIx(
|
|
2832
|
+
perpMarketIndex,
|
|
2224
2833
|
unrealizedMaxImbalance,
|
|
2225
2834
|
maxRevenueWithdrawPerPeriod,
|
|
2226
|
-
quoteMaxInsurance
|
|
2227
|
-
{
|
|
2228
|
-
accounts: {
|
|
2229
|
-
admin: this.isSubscribed
|
|
2230
|
-
? this.getStateAccount().admin
|
|
2231
|
-
: this.wallet.publicKey,
|
|
2232
|
-
state: await this.getStatePublicKey(),
|
|
2233
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2234
|
-
this.program.programId,
|
|
2235
|
-
perpMarketIndex
|
|
2236
|
-
),
|
|
2237
|
-
},
|
|
2238
|
-
}
|
|
2835
|
+
quoteMaxInsurance
|
|
2239
2836
|
);
|
|
2240
2837
|
|
|
2241
2838
|
const tx = await this.buildTransaction(updatePerpMarketMaxImabalancesIx);
|
|
@@ -2245,25 +2842,39 @@ export class AdminClient extends DriftClient {
|
|
|
2245
2842
|
return txSig;
|
|
2246
2843
|
}
|
|
2247
2844
|
|
|
2845
|
+
public async getUpdatePerpMarketMaxImbalancesIx(
|
|
2846
|
+
perpMarketIndex: number,
|
|
2847
|
+
unrealizedMaxImbalance: BN,
|
|
2848
|
+
maxRevenueWithdrawPerPeriod: BN,
|
|
2849
|
+
quoteMaxInsurance: BN
|
|
2850
|
+
): Promise<TransactionInstruction> {
|
|
2851
|
+
return await this.program.instruction.updatePerpMarketMaxImbalances(
|
|
2852
|
+
unrealizedMaxImbalance,
|
|
2853
|
+
maxRevenueWithdrawPerPeriod,
|
|
2854
|
+
quoteMaxInsurance,
|
|
2855
|
+
{
|
|
2856
|
+
accounts: {
|
|
2857
|
+
admin: this.isSubscribed
|
|
2858
|
+
? this.getStateAccount().admin
|
|
2859
|
+
: this.wallet.publicKey,
|
|
2860
|
+
state: await this.getStatePublicKey(),
|
|
2861
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2862
|
+
this.program.programId,
|
|
2863
|
+
perpMarketIndex
|
|
2864
|
+
),
|
|
2865
|
+
},
|
|
2866
|
+
}
|
|
2867
|
+
);
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2248
2870
|
public async updatePerpMarketMaxOpenInterest(
|
|
2249
2871
|
perpMarketIndex: number,
|
|
2250
2872
|
maxOpenInterest: BN
|
|
2251
2873
|
): Promise<TransactionSignature> {
|
|
2252
2874
|
const updatePerpMarketMaxOpenInterestIx =
|
|
2253
|
-
await this.
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
accounts: {
|
|
2257
|
-
admin: this.isSubscribed
|
|
2258
|
-
? this.getStateAccount().admin
|
|
2259
|
-
: this.wallet.publicKey,
|
|
2260
|
-
state: await this.getStatePublicKey(),
|
|
2261
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2262
|
-
this.program.programId,
|
|
2263
|
-
perpMarketIndex
|
|
2264
|
-
),
|
|
2265
|
-
},
|
|
2266
|
-
}
|
|
2875
|
+
await this.getUpdatePerpMarketMaxOpenInterestIx(
|
|
2876
|
+
perpMarketIndex,
|
|
2877
|
+
maxOpenInterest
|
|
2267
2878
|
);
|
|
2268
2879
|
|
|
2269
2880
|
const tx = await this.buildTransaction(updatePerpMarketMaxOpenInterestIx);
|
|
@@ -2273,25 +2884,35 @@ export class AdminClient extends DriftClient {
|
|
|
2273
2884
|
return txSig;
|
|
2274
2885
|
}
|
|
2275
2886
|
|
|
2887
|
+
public async getUpdatePerpMarketMaxOpenInterestIx(
|
|
2888
|
+
perpMarketIndex: number,
|
|
2889
|
+
maxOpenInterest: BN
|
|
2890
|
+
): Promise<TransactionInstruction> {
|
|
2891
|
+
return await this.program.instruction.updatePerpMarketMaxOpenInterest(
|
|
2892
|
+
maxOpenInterest,
|
|
2893
|
+
{
|
|
2894
|
+
accounts: {
|
|
2895
|
+
admin: this.isSubscribed
|
|
2896
|
+
? this.getStateAccount().admin
|
|
2897
|
+
: this.wallet.publicKey,
|
|
2898
|
+
state: await this.getStatePublicKey(),
|
|
2899
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2900
|
+
this.program.programId,
|
|
2901
|
+
perpMarketIndex
|
|
2902
|
+
),
|
|
2903
|
+
},
|
|
2904
|
+
}
|
|
2905
|
+
);
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2276
2908
|
public async updatePerpMarketFeeAdjustment(
|
|
2277
2909
|
perpMarketIndex: number,
|
|
2278
2910
|
feeAdjustment: number
|
|
2279
2911
|
): Promise<TransactionSignature> {
|
|
2280
2912
|
const updatepPerpMarketFeeAdjustmentIx =
|
|
2281
|
-
await this.
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
accounts: {
|
|
2285
|
-
admin: this.isSubscribed
|
|
2286
|
-
? this.getStateAccount().admin
|
|
2287
|
-
: this.wallet.publicKey,
|
|
2288
|
-
state: await this.getStatePublicKey(),
|
|
2289
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2290
|
-
this.program.programId,
|
|
2291
|
-
perpMarketIndex
|
|
2292
|
-
),
|
|
2293
|
-
},
|
|
2294
|
-
}
|
|
2913
|
+
await this.getUpdatePerpMarketFeeAdjustmentIx(
|
|
2914
|
+
perpMarketIndex,
|
|
2915
|
+
feeAdjustment
|
|
2295
2916
|
);
|
|
2296
2917
|
|
|
2297
2918
|
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
@@ -2301,21 +2922,31 @@ export class AdminClient extends DriftClient {
|
|
|
2301
2922
|
return txSig;
|
|
2302
2923
|
}
|
|
2303
2924
|
|
|
2304
|
-
public async
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2925
|
+
public async getUpdatePerpMarketFeeAdjustmentIx(
|
|
2926
|
+
perpMarketIndex: number,
|
|
2927
|
+
feeAdjustment: number
|
|
2928
|
+
): Promise<TransactionInstruction> {
|
|
2929
|
+
return await this.program.instruction.updatePerpMarketFeeAdjustment(
|
|
2930
|
+
feeAdjustment,
|
|
2309
2931
|
{
|
|
2310
2932
|
accounts: {
|
|
2311
2933
|
admin: this.isSubscribed
|
|
2312
2934
|
? this.getStateAccount().admin
|
|
2313
2935
|
: this.wallet.publicKey,
|
|
2314
2936
|
state: await this.getStatePublicKey(),
|
|
2315
|
-
|
|
2937
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2938
|
+
this.program.programId,
|
|
2939
|
+
perpMarketIndex
|
|
2940
|
+
),
|
|
2316
2941
|
},
|
|
2317
2942
|
}
|
|
2318
2943
|
);
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
public async updateSerumVault(
|
|
2947
|
+
srmVault: PublicKey
|
|
2948
|
+
): Promise<TransactionSignature> {
|
|
2949
|
+
const updateSerumVaultIx = await this.getUpdateSerumVaultIx(srmVault);
|
|
2319
2950
|
|
|
2320
2951
|
const tx = await this.buildTransaction(updateSerumVaultIx);
|
|
2321
2952
|
|
|
@@ -2324,27 +2955,30 @@ export class AdminClient extends DriftClient {
|
|
|
2324
2955
|
return txSig;
|
|
2325
2956
|
}
|
|
2326
2957
|
|
|
2958
|
+
public async getUpdateSerumVaultIx(
|
|
2959
|
+
srmVault: PublicKey
|
|
2960
|
+
): Promise<TransactionInstruction> {
|
|
2961
|
+
return await this.program.instruction.updateSerumVault(srmVault, {
|
|
2962
|
+
accounts: {
|
|
2963
|
+
admin: this.isSubscribed
|
|
2964
|
+
? this.getStateAccount().admin
|
|
2965
|
+
: this.wallet.publicKey,
|
|
2966
|
+
state: await this.getStatePublicKey(),
|
|
2967
|
+
srmVault: srmVault,
|
|
2968
|
+
},
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2327
2972
|
public async updatePerpMarketLiquidationFee(
|
|
2328
2973
|
perpMarketIndex: number,
|
|
2329
2974
|
liquidatorFee: number,
|
|
2330
2975
|
ifLiquidationFee: number
|
|
2331
2976
|
): Promise<TransactionSignature> {
|
|
2332
2977
|
const updatePerpMarketLiquidationFeeIx =
|
|
2333
|
-
await this.
|
|
2978
|
+
await this.getUpdatePerpMarketLiquidationFeeIx(
|
|
2979
|
+
perpMarketIndex,
|
|
2334
2980
|
liquidatorFee,
|
|
2335
|
-
ifLiquidationFee
|
|
2336
|
-
{
|
|
2337
|
-
accounts: {
|
|
2338
|
-
admin: this.isSubscribed
|
|
2339
|
-
? this.getStateAccount().admin
|
|
2340
|
-
: this.wallet.publicKey,
|
|
2341
|
-
state: await this.getStatePublicKey(),
|
|
2342
|
-
perpMarket: await getPerpMarketPublicKey(
|
|
2343
|
-
this.program.programId,
|
|
2344
|
-
perpMarketIndex
|
|
2345
|
-
),
|
|
2346
|
-
},
|
|
2347
|
-
}
|
|
2981
|
+
ifLiquidationFee
|
|
2348
2982
|
);
|
|
2349
2983
|
|
|
2350
2984
|
const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
|
|
@@ -2354,27 +2988,39 @@ export class AdminClient extends DriftClient {
|
|
|
2354
2988
|
return txSig;
|
|
2355
2989
|
}
|
|
2356
2990
|
|
|
2991
|
+
public async getUpdatePerpMarketLiquidationFeeIx(
|
|
2992
|
+
perpMarketIndex: number,
|
|
2993
|
+
liquidatorFee: number,
|
|
2994
|
+
ifLiquidationFee: number
|
|
2995
|
+
): Promise<TransactionInstruction> {
|
|
2996
|
+
return await this.program.instruction.updatePerpMarketLiquidationFee(
|
|
2997
|
+
liquidatorFee,
|
|
2998
|
+
ifLiquidationFee,
|
|
2999
|
+
{
|
|
3000
|
+
accounts: {
|
|
3001
|
+
admin: this.isSubscribed
|
|
3002
|
+
? this.getStateAccount().admin
|
|
3003
|
+
: this.wallet.publicKey,
|
|
3004
|
+
state: await this.getStatePublicKey(),
|
|
3005
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3006
|
+
this.program.programId,
|
|
3007
|
+
perpMarketIndex
|
|
3008
|
+
),
|
|
3009
|
+
},
|
|
3010
|
+
}
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
3013
|
+
|
|
2357
3014
|
public async updateSpotMarketLiquidationFee(
|
|
2358
3015
|
spotMarketIndex: number,
|
|
2359
3016
|
liquidatorFee: number,
|
|
2360
3017
|
ifLiquidationFee: number
|
|
2361
3018
|
): Promise<TransactionSignature> {
|
|
2362
3019
|
const updateSpotMarketLiquidationFeeIx =
|
|
2363
|
-
await this.
|
|
3020
|
+
await this.getUpdateSpotMarketLiquidationFeeIx(
|
|
3021
|
+
spotMarketIndex,
|
|
2364
3022
|
liquidatorFee,
|
|
2365
|
-
ifLiquidationFee
|
|
2366
|
-
{
|
|
2367
|
-
accounts: {
|
|
2368
|
-
admin: this.isSubscribed
|
|
2369
|
-
? this.getStateAccount().admin
|
|
2370
|
-
: this.wallet.publicKey,
|
|
2371
|
-
state: await this.getStatePublicKey(),
|
|
2372
|
-
spotMarket: await getSpotMarketPublicKey(
|
|
2373
|
-
this.program.programId,
|
|
2374
|
-
spotMarketIndex
|
|
2375
|
-
),
|
|
2376
|
-
},
|
|
2377
|
-
}
|
|
3023
|
+
ifLiquidationFee
|
|
2378
3024
|
);
|
|
2379
3025
|
|
|
2380
3026
|
const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
|
|
@@ -2384,20 +3030,32 @@ export class AdminClient extends DriftClient {
|
|
|
2384
3030
|
return txSig;
|
|
2385
3031
|
}
|
|
2386
3032
|
|
|
2387
|
-
public async
|
|
2388
|
-
|
|
2389
|
-
|
|
3033
|
+
public async getUpdateSpotMarketLiquidationFeeIx(
|
|
3034
|
+
spotMarketIndex: number,
|
|
3035
|
+
liquidatorFee: number,
|
|
3036
|
+
ifLiquidationFee: number
|
|
3037
|
+
): Promise<TransactionInstruction> {
|
|
3038
|
+
return await this.program.instruction.updateSpotMarketLiquidationFee(
|
|
3039
|
+
liquidatorFee,
|
|
3040
|
+
ifLiquidationFee,
|
|
3041
|
+
{
|
|
2390
3042
|
accounts: {
|
|
2391
3043
|
admin: this.isSubscribed
|
|
2392
3044
|
? this.getStateAccount().admin
|
|
2393
3045
|
: this.wallet.publicKey,
|
|
2394
3046
|
state: await this.getStatePublicKey(),
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
3047
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
3048
|
+
this.program.programId,
|
|
3049
|
+
spotMarketIndex
|
|
3050
|
+
),
|
|
2399
3051
|
},
|
|
2400
|
-
}
|
|
3052
|
+
}
|
|
3053
|
+
);
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
public async initializeProtocolIfSharesTransferConfig(): Promise<TransactionSignature> {
|
|
3057
|
+
const initializeProtocolIfSharesTransferConfigIx =
|
|
3058
|
+
await this.getInitializeProtocolIfSharesTransferConfigIx();
|
|
2401
3059
|
|
|
2402
3060
|
const tx = await this.buildTransaction(
|
|
2403
3061
|
initializeProtocolIfSharesTransferConfigIx
|
|
@@ -2408,26 +3066,31 @@ export class AdminClient extends DriftClient {
|
|
|
2408
3066
|
return txSig;
|
|
2409
3067
|
}
|
|
2410
3068
|
|
|
3069
|
+
public async getInitializeProtocolIfSharesTransferConfigIx(): Promise<TransactionInstruction> {
|
|
3070
|
+
return await this.program.instruction.initializeProtocolIfSharesTransferConfig(
|
|
3071
|
+
{
|
|
3072
|
+
accounts: {
|
|
3073
|
+
admin: this.isSubscribed
|
|
3074
|
+
? this.getStateAccount().admin
|
|
3075
|
+
: this.wallet.publicKey,
|
|
3076
|
+
state: await this.getStatePublicKey(),
|
|
3077
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3078
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
3079
|
+
protocolIfSharesTransferConfig:
|
|
3080
|
+
getProtocolIfSharesTransferConfigPublicKey(this.program.programId),
|
|
3081
|
+
},
|
|
3082
|
+
}
|
|
3083
|
+
);
|
|
3084
|
+
}
|
|
3085
|
+
|
|
2411
3086
|
public async updateProtocolIfSharesTransferConfig(
|
|
2412
3087
|
whitelistedSigners?: PublicKey[],
|
|
2413
3088
|
maxTransferPerEpoch?: BN
|
|
2414
3089
|
): Promise<TransactionSignature> {
|
|
2415
3090
|
const updateProtocolIfSharesTransferConfigIx =
|
|
2416
|
-
await this.
|
|
2417
|
-
whitelistedSigners
|
|
2418
|
-
maxTransferPerEpoch
|
|
2419
|
-
{
|
|
2420
|
-
accounts: {
|
|
2421
|
-
admin: this.isSubscribed
|
|
2422
|
-
? this.getStateAccount().admin
|
|
2423
|
-
: this.wallet.publicKey,
|
|
2424
|
-
state: await this.getStatePublicKey(),
|
|
2425
|
-
protocolIfSharesTransferConfig:
|
|
2426
|
-
getProtocolIfSharesTransferConfigPublicKey(
|
|
2427
|
-
this.program.programId
|
|
2428
|
-
),
|
|
2429
|
-
},
|
|
2430
|
-
}
|
|
3091
|
+
await this.getUpdateProtocolIfSharesTransferConfigIx(
|
|
3092
|
+
whitelistedSigners,
|
|
3093
|
+
maxTransferPerEpoch
|
|
2431
3094
|
);
|
|
2432
3095
|
|
|
2433
3096
|
const tx = await this.buildTransaction(
|
|
@@ -2439,6 +3102,26 @@ export class AdminClient extends DriftClient {
|
|
|
2439
3102
|
return txSig;
|
|
2440
3103
|
}
|
|
2441
3104
|
|
|
3105
|
+
public async getUpdateProtocolIfSharesTransferConfigIx(
|
|
3106
|
+
whitelistedSigners?: PublicKey[],
|
|
3107
|
+
maxTransferPerEpoch?: BN
|
|
3108
|
+
): Promise<TransactionInstruction> {
|
|
3109
|
+
return await this.program.instruction.updateProtocolIfSharesTransferConfig(
|
|
3110
|
+
whitelistedSigners || null,
|
|
3111
|
+
maxTransferPerEpoch,
|
|
3112
|
+
{
|
|
3113
|
+
accounts: {
|
|
3114
|
+
admin: this.isSubscribed
|
|
3115
|
+
? this.getStateAccount().admin
|
|
3116
|
+
: this.wallet.publicKey,
|
|
3117
|
+
state: await this.getStatePublicKey(),
|
|
3118
|
+
protocolIfSharesTransferConfig:
|
|
3119
|
+
getProtocolIfSharesTransferConfigPublicKey(this.program.programId),
|
|
3120
|
+
},
|
|
3121
|
+
}
|
|
3122
|
+
);
|
|
3123
|
+
}
|
|
3124
|
+
|
|
2442
3125
|
public async initializePrelaunchOracle(
|
|
2443
3126
|
perpMarketIndex: number,
|
|
2444
3127
|
price?: BN,
|