@drift-labs/sdk 2.87.0-beta.9 → 2.88.0-beta.0

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 CHANGED
@@ -1 +1 @@
1
- 2.87.0-beta.9
1
+ 2.88.0-beta.0
@@ -41,6 +41,8 @@ export declare class AdminClient extends DriftClient {
41
41
  getResetPerpMarketAmmOracleTwapIx(perpMarketIndex: number): Promise<TransactionInstruction>;
42
42
  depositIntoPerpMarketFeePool(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
43
43
  getDepositIntoPerpMarketFeePoolIx(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionInstruction>;
44
+ depositIntoSpotMarketVault(spotMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
45
+ getDepositIntoSpotMarketVaultIx(spotMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionInstruction>;
44
46
  updateAdmin(admin: PublicKey): Promise<TransactionSignature>;
45
47
  getUpdateAdminIx(admin: PublicKey): Promise<TransactionInstruction>;
46
48
  updatePerpMarketCurveUpdateIntensity(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionSignature>;
@@ -433,6 +433,30 @@ class AdminClient extends driftClient_1.DriftClient {
433
433
  },
434
434
  });
435
435
  }
436
+ async depositIntoSpotMarketVault(spotMarketIndex, amount, sourceVault) {
437
+ const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault);
438
+ const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
439
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
440
+ return txSig;
441
+ }
442
+ async getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault) {
443
+ const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
444
+ const remainingAccounts = [];
445
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
446
+ const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
447
+ return await this.program.instruction.depositIntoSpotMarketVault(amount, {
448
+ accounts: {
449
+ admin: this.isSubscribed
450
+ ? this.getStateAccount().admin
451
+ : this.wallet.publicKey,
452
+ state: await this.getStatePublicKey(),
453
+ sourceVault,
454
+ spotMarket: spotMarket.pubkey,
455
+ spotMarketVault: spotMarket.vault,
456
+ tokenProgram,
457
+ },
458
+ });
459
+ }
436
460
  async updateAdmin(admin) {
437
461
  const updateAdminIx = await this.getUpdateAdminIx(admin);
438
462
  const tx = await this.buildTransaction(updateAdminIx);
@@ -71,4 +71,4 @@ exports.IDLE_TIME_SLOTS = 9000;
71
71
  exports.SLOT_TIME_ESTIMATE_MS = 400;
72
72
  exports.DUST_POSITION_SIZE = exports.QUOTE_PRECISION.divn(100); // Dust position is any position smaller than 1c
73
73
  exports.FUEL_WINDOW = new __1.BN(60 * 60 * 24 * 28); // 28 days
74
- exports.FUEL_START_TS = new __1.BN(1722384000); // unix timestamp
74
+ exports.FUEL_START_TS = new __1.BN(1723075200); // unix timestamp
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Commitment, PublicKey, TransactionSignature } from '@solana/web3.js';
3
- import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord, SwapRecord } from '../index';
3
+ import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord, SwapRecord, SpotMarketVaultDepositRecord } from '../index';
4
4
  import { EventEmitter } from 'events';
5
5
  export type EventSubscriptionOptions = {
6
6
  address?: PublicKey;
@@ -40,9 +40,10 @@ export type EventMap = {
40
40
  InsuranceFundStakeRecord: Event<InsuranceFundStakeRecord>;
41
41
  CurveRecord: Event<CurveRecord>;
42
42
  SwapRecord: Event<SwapRecord>;
43
+ SpotMarketVaultDepositRecord: Event<SpotMarketVaultDepositRecord>;
43
44
  };
44
45
  export type EventType = keyof EventMap;
45
- export type DriftEvent = Event<DepositRecord> | Event<FundingPaymentRecord> | Event<LiquidationRecord> | Event<FundingRateRecord> | Event<OrderRecord> | Event<OrderActionRecord> | Event<SettlePnlRecord> | Event<NewUserRecord> | Event<LPRecord> | Event<InsuranceFundRecord> | Event<SpotInterestRecord> | Event<InsuranceFundStakeRecord> | Event<CurveRecord> | Event<SwapRecord>;
46
+ export type DriftEvent = Event<DepositRecord> | Event<FundingPaymentRecord> | Event<LiquidationRecord> | Event<FundingRateRecord> | Event<OrderRecord> | Event<OrderActionRecord> | Event<SettlePnlRecord> | Event<NewUserRecord> | Event<LPRecord> | Event<InsuranceFundRecord> | Event<SpotInterestRecord> | Event<InsuranceFundStakeRecord> | Event<CurveRecord> | Event<SwapRecord> | Event<SpotMarketVaultDepositRecord>;
46
47
  export interface EventSubscriberEvents {
47
48
  newEvent: (event: WrappedEvent<EventType>) => void;
48
49
  }
@@ -17,6 +17,7 @@ exports.DefaultEventSubscriptionOptions = {
17
17
  'InsuranceFundStakeRecord',
18
18
  'CurveRecord',
19
19
  'SwapRecord',
20
+ 'SpotMarketVaultDepositRecord',
20
21
  ],
21
22
  maxEventsPerType: 4096,
22
23
  orderBy: 'blockchain',
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.86.0",
2
+ "version": "2.87.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -3403,6 +3403,27 @@
3403
3403
  }
3404
3404
  ]
3405
3405
  },
3406
+ {
3407
+ "name": "initializePredictionMarket",
3408
+ "accounts": [
3409
+ {
3410
+ "name": "admin",
3411
+ "isMut": false,
3412
+ "isSigner": true
3413
+ },
3414
+ {
3415
+ "name": "state",
3416
+ "isMut": false,
3417
+ "isSigner": false
3418
+ },
3419
+ {
3420
+ "name": "perpMarket",
3421
+ "isMut": true,
3422
+ "isSigner": false
3423
+ }
3424
+ ],
3425
+ "args": []
3426
+ },
3406
3427
  {
3407
3428
  "name": "deleteInitializedPerpMarket",
3408
3429
  "accounts": [
@@ -3634,6 +3655,47 @@
3634
3655
  }
3635
3656
  ]
3636
3657
  },
3658
+ {
3659
+ "name": "depositIntoSpotMarketVault",
3660
+ "accounts": [
3661
+ {
3662
+ "name": "state",
3663
+ "isMut": false,
3664
+ "isSigner": false
3665
+ },
3666
+ {
3667
+ "name": "spotMarket",
3668
+ "isMut": true,
3669
+ "isSigner": false
3670
+ },
3671
+ {
3672
+ "name": "admin",
3673
+ "isMut": false,
3674
+ "isSigner": true
3675
+ },
3676
+ {
3677
+ "name": "sourceVault",
3678
+ "isMut": true,
3679
+ "isSigner": false
3680
+ },
3681
+ {
3682
+ "name": "spotMarketVault",
3683
+ "isMut": true,
3684
+ "isSigner": false
3685
+ },
3686
+ {
3687
+ "name": "tokenProgram",
3688
+ "isMut": false,
3689
+ "isSigner": false
3690
+ }
3691
+ ],
3692
+ "args": [
3693
+ {
3694
+ "name": "amount",
3695
+ "type": "u64"
3696
+ }
3697
+ ]
3698
+ },
3637
3699
  {
3638
3700
  "name": "depositIntoSpotMarketRevenuePool",
3639
3701
  "accounts": [
@@ -10148,6 +10210,9 @@
10148
10210
  },
10149
10211
  {
10150
10212
  "name": "Future"
10213
+ },
10214
+ {
10215
+ "name": "Prediction"
10151
10216
  }
10152
10217
  ]
10153
10218
  }
@@ -11400,6 +11465,46 @@
11400
11465
  "index": false
11401
11466
  }
11402
11467
  ]
11468
+ },
11469
+ {
11470
+ "name": "SpotMarketVaultDepositRecord",
11471
+ "fields": [
11472
+ {
11473
+ "name": "ts",
11474
+ "type": "i64",
11475
+ "index": false
11476
+ },
11477
+ {
11478
+ "name": "marketIndex",
11479
+ "type": "u16",
11480
+ "index": false
11481
+ },
11482
+ {
11483
+ "name": "depositBalance",
11484
+ "type": "u128",
11485
+ "index": false
11486
+ },
11487
+ {
11488
+ "name": "cumulativeDepositInterestBefore",
11489
+ "type": "u128",
11490
+ "index": false
11491
+ },
11492
+ {
11493
+ "name": "cumulativeDepositInterestAfter",
11494
+ "type": "u128",
11495
+ "index": false
11496
+ },
11497
+ {
11498
+ "name": "depositTokenAmountBefore",
11499
+ "type": "u64",
11500
+ "index": false
11501
+ },
11502
+ {
11503
+ "name": "amount",
11504
+ "type": "u64",
11505
+ "index": false
11506
+ }
11507
+ ]
11403
11508
  }
11404
11509
  ],
11405
11510
  "errors": [
package/lib/types.d.ts CHANGED
@@ -674,6 +674,15 @@ export type SwapRecord = {
674
674
  inOraclePrice: BN;
675
675
  fee: BN;
676
676
  };
677
+ export type SpotMarketVaultDepositRecord = {
678
+ ts: BN;
679
+ marketIndex: number;
680
+ depositBalance: BN;
681
+ cumulativeDepositInterestBefore: BN;
682
+ cumulativeDepositInterestAfter: BN;
683
+ depositTokenAmountBefore: BN;
684
+ amount: BN;
685
+ };
677
686
  export type StateAccount = {
678
687
  admin: PublicKey;
679
688
  exchangeStatus: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.87.0-beta.9",
3
+ "version": "2.88.0-beta.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -999,6 +999,49 @@ export class AdminClient extends DriftClient {
999
999
  });
1000
1000
  }
1001
1001
 
1002
+ public async depositIntoSpotMarketVault(
1003
+ spotMarketIndex: number,
1004
+ amount: BN,
1005
+ sourceVault: PublicKey
1006
+ ): Promise<TransactionSignature> {
1007
+ const depositIntoPerpMarketFeePoolIx =
1008
+ await this.getDepositIntoSpotMarketVaultIx(
1009
+ spotMarketIndex,
1010
+ amount,
1011
+ sourceVault
1012
+ );
1013
+
1014
+ const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
1015
+
1016
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1017
+
1018
+ return txSig;
1019
+ }
1020
+
1021
+ public async getDepositIntoSpotMarketVaultIx(
1022
+ spotMarketIndex: number,
1023
+ amount: BN,
1024
+ sourceVault: PublicKey
1025
+ ): Promise<TransactionInstruction> {
1026
+ const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
1027
+
1028
+ const remainingAccounts = [];
1029
+ this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
1030
+ const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
1031
+ return await this.program.instruction.depositIntoSpotMarketVault(amount, {
1032
+ accounts: {
1033
+ admin: this.isSubscribed
1034
+ ? this.getStateAccount().admin
1035
+ : this.wallet.publicKey,
1036
+ state: await this.getStatePublicKey(),
1037
+ sourceVault,
1038
+ spotMarket: spotMarket.pubkey,
1039
+ spotMarketVault: spotMarket.vault,
1040
+ tokenProgram,
1041
+ },
1042
+ });
1043
+ }
1044
+
1002
1045
  public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
1003
1046
  const updateAdminIx = await this.getUpdateAdminIx(admin);
1004
1047
 
@@ -108,4 +108,4 @@ export const SLOT_TIME_ESTIMATE_MS = 400;
108
108
  export const DUST_POSITION_SIZE = QUOTE_PRECISION.divn(100); // Dust position is any position smaller than 1c
109
109
 
110
110
  export const FUEL_WINDOW = new BN(60 * 60 * 24 * 28); // 28 days
111
- export const FUEL_START_TS = new BN(1722384000); // unix timestamp
111
+ export const FUEL_START_TS = new BN(1723075200); // unix timestamp
@@ -14,6 +14,7 @@ import {
14
14
  InsuranceFundStakeRecord,
15
15
  CurveRecord,
16
16
  SwapRecord,
17
+ SpotMarketVaultDepositRecord,
17
18
  } from '../index';
18
19
  import { EventEmitter } from 'events';
19
20
 
@@ -47,6 +48,7 @@ export const DefaultEventSubscriptionOptions: EventSubscriptionOptions = {
47
48
  'InsuranceFundStakeRecord',
48
49
  'CurveRecord',
49
50
  'SwapRecord',
51
+ 'SpotMarketVaultDepositRecord',
50
52
  ],
51
53
  maxEventsPerType: 4096,
52
54
  orderBy: 'blockchain',
@@ -89,6 +91,7 @@ export type EventMap = {
89
91
  InsuranceFundStakeRecord: Event<InsuranceFundStakeRecord>;
90
92
  CurveRecord: Event<CurveRecord>;
91
93
  SwapRecord: Event<SwapRecord>;
94
+ SpotMarketVaultDepositRecord: Event<SpotMarketVaultDepositRecord>;
92
95
  };
93
96
 
94
97
  export type EventType = keyof EventMap;
@@ -107,7 +110,8 @@ export type DriftEvent =
107
110
  | Event<SpotInterestRecord>
108
111
  | Event<InsuranceFundStakeRecord>
109
112
  | Event<CurveRecord>
110
- | Event<SwapRecord>;
113
+ | Event<SwapRecord>
114
+ | Event<SpotMarketVaultDepositRecord>;
111
115
 
112
116
  export interface EventSubscriberEvents {
113
117
  newEvent: (event: WrappedEvent<EventType>) => void;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.86.0",
2
+ "version": "2.87.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -3403,6 +3403,27 @@
3403
3403
  }
3404
3404
  ]
3405
3405
  },
3406
+ {
3407
+ "name": "initializePredictionMarket",
3408
+ "accounts": [
3409
+ {
3410
+ "name": "admin",
3411
+ "isMut": false,
3412
+ "isSigner": true
3413
+ },
3414
+ {
3415
+ "name": "state",
3416
+ "isMut": false,
3417
+ "isSigner": false
3418
+ },
3419
+ {
3420
+ "name": "perpMarket",
3421
+ "isMut": true,
3422
+ "isSigner": false
3423
+ }
3424
+ ],
3425
+ "args": []
3426
+ },
3406
3427
  {
3407
3428
  "name": "deleteInitializedPerpMarket",
3408
3429
  "accounts": [
@@ -3634,6 +3655,47 @@
3634
3655
  }
3635
3656
  ]
3636
3657
  },
3658
+ {
3659
+ "name": "depositIntoSpotMarketVault",
3660
+ "accounts": [
3661
+ {
3662
+ "name": "state",
3663
+ "isMut": false,
3664
+ "isSigner": false
3665
+ },
3666
+ {
3667
+ "name": "spotMarket",
3668
+ "isMut": true,
3669
+ "isSigner": false
3670
+ },
3671
+ {
3672
+ "name": "admin",
3673
+ "isMut": false,
3674
+ "isSigner": true
3675
+ },
3676
+ {
3677
+ "name": "sourceVault",
3678
+ "isMut": true,
3679
+ "isSigner": false
3680
+ },
3681
+ {
3682
+ "name": "spotMarketVault",
3683
+ "isMut": true,
3684
+ "isSigner": false
3685
+ },
3686
+ {
3687
+ "name": "tokenProgram",
3688
+ "isMut": false,
3689
+ "isSigner": false
3690
+ }
3691
+ ],
3692
+ "args": [
3693
+ {
3694
+ "name": "amount",
3695
+ "type": "u64"
3696
+ }
3697
+ ]
3698
+ },
3637
3699
  {
3638
3700
  "name": "depositIntoSpotMarketRevenuePool",
3639
3701
  "accounts": [
@@ -10148,6 +10210,9 @@
10148
10210
  },
10149
10211
  {
10150
10212
  "name": "Future"
10213
+ },
10214
+ {
10215
+ "name": "Prediction"
10151
10216
  }
10152
10217
  ]
10153
10218
  }
@@ -11400,6 +11465,46 @@
11400
11465
  "index": false
11401
11466
  }
11402
11467
  ]
11468
+ },
11469
+ {
11470
+ "name": "SpotMarketVaultDepositRecord",
11471
+ "fields": [
11472
+ {
11473
+ "name": "ts",
11474
+ "type": "i64",
11475
+ "index": false
11476
+ },
11477
+ {
11478
+ "name": "marketIndex",
11479
+ "type": "u16",
11480
+ "index": false
11481
+ },
11482
+ {
11483
+ "name": "depositBalance",
11484
+ "type": "u128",
11485
+ "index": false
11486
+ },
11487
+ {
11488
+ "name": "cumulativeDepositInterestBefore",
11489
+ "type": "u128",
11490
+ "index": false
11491
+ },
11492
+ {
11493
+ "name": "cumulativeDepositInterestAfter",
11494
+ "type": "u128",
11495
+ "index": false
11496
+ },
11497
+ {
11498
+ "name": "depositTokenAmountBefore",
11499
+ "type": "u64",
11500
+ "index": false
11501
+ },
11502
+ {
11503
+ "name": "amount",
11504
+ "type": "u64",
11505
+ "index": false
11506
+ }
11507
+ ]
11403
11508
  }
11404
11509
  ],
11405
11510
  "errors": [
@@ -12827,4 +12932,4 @@
12827
12932
  "metadata": {
12828
12933
  "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
12829
12934
  }
12830
- }
12935
+ }
package/src/types.ts CHANGED
@@ -576,6 +576,16 @@ export type SwapRecord = {
576
576
  fee: BN;
577
577
  };
578
578
 
579
+ export type SpotMarketVaultDepositRecord = {
580
+ ts: BN;
581
+ marketIndex: number;
582
+ depositBalance: BN;
583
+ cumulativeDepositInterestBefore: BN;
584
+ cumulativeDepositInterestAfter: BN;
585
+ depositTokenAmountBefore: BN;
586
+ amount: BN;
587
+ };
588
+
579
589
  export type StateAccount = {
580
590
  admin: PublicKey;
581
591
  exchangeStatus: number;