@drift-labs/sdk-browser 2.139.0-beta.9 → 2.140.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.139.0-beta.9
1
+ 2.140.0-beta.0
@@ -1,6 +1,6 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
3
- import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus, IfRebalanceConfigParams } from './types';
3
+ import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus, IfRebalanceConfigParams, TxParams } from './types';
4
4
  import { BN } from '@coral-xyz/anchor';
5
5
  import { DriftClient } from './driftClient';
6
6
  export declare class AdminClient extends DriftClient {
@@ -236,6 +236,10 @@ export declare class AdminClient extends DriftClient {
236
236
  getZeroMMOracleFieldsIx(marketIndex: number): Promise<TransactionInstruction>;
237
237
  updateFeatureBitFlagsMMOracle(enable: boolean): Promise<TransactionSignature>;
238
238
  getUpdateFeatureBitFlagsMMOracleIx(enable: boolean): Promise<TransactionInstruction>;
239
+ updateFeatureBitFlagsMedianTriggerPrice(enable: boolean): Promise<TransactionSignature>;
240
+ getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable: boolean): Promise<TransactionInstruction>;
239
241
  updateDelegateUserGovTokenInsuranceStake(authority: PublicKey, delegate: PublicKey): Promise<TransactionSignature>;
240
242
  getUpdateDelegateUserGovTokenInsuranceStakeIx(authority: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>;
243
+ depositIntoInsuranceFundStake(marketIndex: number, amount: BN, userStatsPublicKey: PublicKey, insuranceFundStakePublicKey: PublicKey, userTokenAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
244
+ getDepositIntoInsuranceFundStakeIx(marketIndex: number, amount: BN, userStatsPublicKey: PublicKey, insuranceFundStakePublicKey: PublicKey, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
241
245
  }
@@ -2155,6 +2155,22 @@ class AdminClient extends driftClient_1.DriftClient {
2155
2155
  },
2156
2156
  });
2157
2157
  }
2158
+ async updateFeatureBitFlagsMedianTriggerPrice(enable) {
2159
+ const updateFeatureBitFlagsMedianTriggerPriceIx = await this.getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable);
2160
+ const tx = await this.buildTransaction(updateFeatureBitFlagsMedianTriggerPriceIx);
2161
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
2162
+ return txSig;
2163
+ }
2164
+ async getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable) {
2165
+ return await this.program.instruction.updateFeatureBitFlagsMedianTriggerPrice(enable, {
2166
+ accounts: {
2167
+ admin: this.useHotWalletAdmin
2168
+ ? this.wallet.publicKey
2169
+ : this.getStateAccount().admin,
2170
+ state: await this.getStatePublicKey(),
2171
+ },
2172
+ });
2173
+ }
2158
2174
  async updateDelegateUserGovTokenInsuranceStake(authority, delegate) {
2159
2175
  const updateDelegateUserGovTokenInsuranceStakeIx = await this.getUpdateDelegateUserGovTokenInsuranceStakeIx(authority, delegate);
2160
2176
  const tx = await this.buildTransaction(updateDelegateUserGovTokenInsuranceStakeIx);
@@ -2178,5 +2194,27 @@ class AdminClient extends driftClient_1.DriftClient {
2178
2194
  });
2179
2195
  return ix;
2180
2196
  }
2197
+ async depositIntoInsuranceFundStake(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey, txParams) {
2198
+ const tx = await this.buildTransaction(await this.getDepositIntoInsuranceFundStakeIx(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey), txParams);
2199
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
2200
+ return txSig;
2201
+ }
2202
+ async getDepositIntoInsuranceFundStakeIx(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey) {
2203
+ const spotMarket = this.getSpotMarketAccount(marketIndex);
2204
+ return await this.program.instruction.depositIntoInsuranceFundStake(marketIndex, amount, {
2205
+ accounts: {
2206
+ signer: this.wallet.publicKey,
2207
+ state: await this.getStatePublicKey(),
2208
+ spotMarket: spotMarket.pubkey,
2209
+ insuranceFundStake: insuranceFundStakePublicKey,
2210
+ userStats: userStatsPublicKey,
2211
+ spotMarketVault: spotMarket.vault,
2212
+ insuranceFundVault: spotMarket.insuranceFund.vault,
2213
+ userTokenAccount: userTokenAccountPublicKey,
2214
+ tokenProgram: this.getTokenProgramForSpotMarket(spotMarket),
2215
+ driftSigner: this.getSignerPublicKey(),
2216
+ },
2217
+ });
2218
+ }
2181
2219
  }
2182
2220
  exports.AdminClient = AdminClient;
@@ -92,6 +92,17 @@ exports.DevnetSpotMarkets = [
92
92
  pythFeedId: '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
93
93
  pythLazerId: 7,
94
94
  },
95
+ {
96
+ symbol: 'GLXY',
97
+ marketIndex: 7,
98
+ poolId: 0,
99
+ oracle: new web3_js_1.PublicKey('4wFrjUQHzRBc6qjVtMDbt28aEVgn6GaNiWR6vEff4KxR'),
100
+ oracleSource: types_1.OracleSource.Prelaunch,
101
+ mint: new web3_js_1.PublicKey('2vVfXmcWXEaFzp7iaTVnQ4y1gR41S6tJQQMo1S5asJyC'),
102
+ precision: new anchor_1.BN(10).pow(numericConstants_1.SIX),
103
+ precisionExp: numericConstants_1.SIX,
104
+ pythFeedId: '0x67e031d1723e5c89e4a826d80b2f3b41a91b05ef6122d523b8829a02e0f563aa',
105
+ },
95
106
  ];
96
107
  exports.MainnetSpotMarkets = [
97
108
  {
@@ -3516,10 +3516,8 @@ class DriftClient {
3516
3516
  useMarketLastSlotCache: false,
3517
3517
  readablePerpMarketIndex: marketIndex,
3518
3518
  });
3519
+ const isDelegateSigner = takerInfo.signingAuthority.equals(takerInfo.takerUserAccount.delegate);
3519
3520
  const borshBuf = Buffer.from(signedSignedMsgOrderParams.orderParams.toString(), 'hex');
3520
- const isDelegateSigner = borshBuf
3521
- .slice(0, 8)
3522
- .equals(Uint8Array.from(Buffer.from((0, sha256_1.sha256)('global' + ':' + 'SignedMsgOrderParamsDelegateMessage')).slice(0, 8)));
3523
3521
  try {
3524
3522
  const { signedMsgOrderParams } = this.decodeSignedMsgOrderParamsMessage(borshBuf, isDelegateSigner);
3525
3523
  if ((0, orderParams_1.isUpdateHighLeverageMode)(signedMsgOrderParams.bitFlags)) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.138.0",
2
+ "version": "2.139.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -1573,31 +1573,6 @@
1573
1573
  }
1574
1574
  ]
1575
1575
  },
1576
- {
1577
- "name": "updateUserAdvancedLp",
1578
- "accounts": [
1579
- {
1580
- "name": "user",
1581
- "isMut": true,
1582
- "isSigner": false
1583
- },
1584
- {
1585
- "name": "authority",
1586
- "isMut": false,
1587
- "isSigner": true
1588
- }
1589
- ],
1590
- "args": [
1591
- {
1592
- "name": "subAccountId",
1593
- "type": "u16"
1594
- },
1595
- {
1596
- "name": "advancedLp",
1597
- "type": "bool"
1598
- }
1599
- ]
1600
- },
1601
1576
  {
1602
1577
  "name": "updateUserProtectedMakerOrders",
1603
1578
  "accounts": [
@@ -2092,32 +2067,6 @@
2092
2067
  ],
2093
2068
  "args": []
2094
2069
  },
2095
- {
2096
- "name": "updateUserOpenOrdersCount",
2097
- "accounts": [
2098
- {
2099
- "name": "state",
2100
- "isMut": false,
2101
- "isSigner": false
2102
- },
2103
- {
2104
- "name": "authority",
2105
- "isMut": false,
2106
- "isSigner": true
2107
- },
2108
- {
2109
- "name": "filler",
2110
- "isMut": true,
2111
- "isSigner": false
2112
- },
2113
- {
2114
- "name": "user",
2115
- "isMut": true,
2116
- "isSigner": false
2117
- }
2118
- ],
2119
- "args": []
2120
- },
2121
2070
  {
2122
2071
  "name": "adminDisableUpdatePerpBidAskTwap",
2123
2072
  "accounts": [
@@ -3141,6 +3090,42 @@
3141
3090
  ],
3142
3091
  "args": []
3143
3092
  },
3093
+ {
3094
+ "name": "updateDelegateUserGovTokenInsuranceStake",
3095
+ "accounts": [
3096
+ {
3097
+ "name": "spotMarket",
3098
+ "isMut": true,
3099
+ "isSigner": false
3100
+ },
3101
+ {
3102
+ "name": "insuranceFundStake",
3103
+ "isMut": false,
3104
+ "isSigner": false
3105
+ },
3106
+ {
3107
+ "name": "userStats",
3108
+ "isMut": true,
3109
+ "isSigner": false
3110
+ },
3111
+ {
3112
+ "name": "admin",
3113
+ "isMut": false,
3114
+ "isSigner": true
3115
+ },
3116
+ {
3117
+ "name": "insuranceFundVault",
3118
+ "isMut": true,
3119
+ "isSigner": false
3120
+ },
3121
+ {
3122
+ "name": "state",
3123
+ "isMut": false,
3124
+ "isSigner": false
3125
+ }
3126
+ ],
3127
+ "args": []
3128
+ },
3144
3129
  {
3145
3130
  "name": "initializeInsuranceFundStake",
3146
3131
  "accounts": [
@@ -3390,62 +3375,79 @@
3390
3375
  ]
3391
3376
  },
3392
3377
  {
3393
- "name": "transferProtocolIfShares",
3378
+ "name": "beginInsuranceFundSwap",
3394
3379
  "accounts": [
3395
3380
  {
3396
- "name": "signer",
3381
+ "name": "state",
3397
3382
  "isMut": false,
3383
+ "isSigner": false
3384
+ },
3385
+ {
3386
+ "name": "authority",
3387
+ "isMut": true,
3398
3388
  "isSigner": true
3399
3389
  },
3400
3390
  {
3401
- "name": "transferConfig",
3391
+ "name": "outInsuranceFundVault",
3402
3392
  "isMut": true,
3403
3393
  "isSigner": false
3404
3394
  },
3405
3395
  {
3406
- "name": "state",
3407
- "isMut": false,
3396
+ "name": "inInsuranceFundVault",
3397
+ "isMut": true,
3408
3398
  "isSigner": false
3409
3399
  },
3410
3400
  {
3411
- "name": "spotMarket",
3401
+ "name": "outTokenAccount",
3412
3402
  "isMut": true,
3413
3403
  "isSigner": false
3414
3404
  },
3415
3405
  {
3416
- "name": "insuranceFundStake",
3406
+ "name": "inTokenAccount",
3417
3407
  "isMut": true,
3418
3408
  "isSigner": false
3419
3409
  },
3420
3410
  {
3421
- "name": "userStats",
3411
+ "name": "ifRebalanceConfig",
3422
3412
  "isMut": true,
3423
3413
  "isSigner": false
3424
3414
  },
3425
3415
  {
3426
- "name": "authority",
3416
+ "name": "tokenProgram",
3427
3417
  "isMut": false,
3428
- "isSigner": true
3418
+ "isSigner": false
3429
3419
  },
3430
3420
  {
3431
- "name": "insuranceFundVault",
3421
+ "name": "driftSigner",
3432
3422
  "isMut": false,
3433
3423
  "isSigner": false
3424
+ },
3425
+ {
3426
+ "name": "instructions",
3427
+ "isMut": false,
3428
+ "isSigner": false,
3429
+ "docs": [
3430
+ "Instructions Sysvar for instruction introspection"
3431
+ ]
3434
3432
  }
3435
3433
  ],
3436
3434
  "args": [
3437
3435
  {
3438
- "name": "marketIndex",
3436
+ "name": "inMarketIndex",
3439
3437
  "type": "u16"
3440
3438
  },
3441
3439
  {
3442
- "name": "shares",
3443
- "type": "u128"
3440
+ "name": "outMarketIndex",
3441
+ "type": "u16"
3442
+ },
3443
+ {
3444
+ "name": "amountIn",
3445
+ "type": "u64"
3444
3446
  }
3445
3447
  ]
3446
3448
  },
3447
3449
  {
3448
- "name": "beginInsuranceFundSwap",
3450
+ "name": "endInsuranceFundSwap",
3449
3451
  "accounts": [
3450
3452
  {
3451
3453
  "name": "state",
@@ -3509,15 +3511,11 @@
3509
3511
  {
3510
3512
  "name": "outMarketIndex",
3511
3513
  "type": "u16"
3512
- },
3513
- {
3514
- "name": "amountIn",
3515
- "type": "u64"
3516
3514
  }
3517
3515
  ]
3518
3516
  },
3519
3517
  {
3520
- "name": "endInsuranceFundSwap",
3518
+ "name": "transferProtocolIfSharesToRevenuePool",
3521
3519
  "accounts": [
3522
3520
  {
3523
3521
  "name": "state",
@@ -3530,22 +3528,12 @@
3530
3528
  "isSigner": true
3531
3529
  },
3532
3530
  {
3533
- "name": "outInsuranceFundVault",
3534
- "isMut": true,
3535
- "isSigner": false
3536
- },
3537
- {
3538
- "name": "inInsuranceFundVault",
3539
- "isMut": true,
3540
- "isSigner": false
3541
- },
3542
- {
3543
- "name": "outTokenAccount",
3531
+ "name": "insuranceFundVault",
3544
3532
  "isMut": true,
3545
3533
  "isSigner": false
3546
3534
  },
3547
3535
  {
3548
- "name": "inTokenAccount",
3536
+ "name": "spotMarketVault",
3549
3537
  "isMut": true,
3550
3538
  "isSigner": false
3551
3539
  },
@@ -3563,42 +3551,44 @@
3563
3551
  "name": "driftSigner",
3564
3552
  "isMut": false,
3565
3553
  "isSigner": false
3566
- },
3567
- {
3568
- "name": "instructions",
3569
- "isMut": false,
3570
- "isSigner": false,
3571
- "docs": [
3572
- "Instructions Sysvar for instruction introspection"
3573
- ]
3574
3554
  }
3575
3555
  ],
3576
3556
  "args": [
3577
3557
  {
3578
- "name": "inMarketIndex",
3558
+ "name": "marketIndex",
3579
3559
  "type": "u16"
3580
3560
  },
3581
3561
  {
3582
- "name": "outMarketIndex",
3583
- "type": "u16"
3562
+ "name": "amount",
3563
+ "type": "u64"
3584
3564
  }
3585
3565
  ]
3586
3566
  },
3587
3567
  {
3588
- "name": "transferProtocolIfSharesToRevenuePool",
3568
+ "name": "depositIntoInsuranceFundStake",
3589
3569
  "accounts": [
3590
3570
  {
3591
- "name": "state",
3571
+ "name": "signer",
3592
3572
  "isMut": false,
3573
+ "isSigner": true
3574
+ },
3575
+ {
3576
+ "name": "state",
3577
+ "isMut": true,
3593
3578
  "isSigner": false
3594
3579
  },
3595
3580
  {
3596
- "name": "authority",
3581
+ "name": "spotMarket",
3597
3582
  "isMut": true,
3598
- "isSigner": true
3583
+ "isSigner": false
3599
3584
  },
3600
3585
  {
3601
- "name": "insuranceFundVault",
3586
+ "name": "insuranceFundStake",
3587
+ "isMut": true,
3588
+ "isSigner": false
3589
+ },
3590
+ {
3591
+ "name": "userStats",
3602
3592
  "isMut": true,
3603
3593
  "isSigner": false
3604
3594
  },
@@ -3608,7 +3598,12 @@
3608
3598
  "isSigner": false
3609
3599
  },
3610
3600
  {
3611
- "name": "ifRebalanceConfig",
3601
+ "name": "insuranceFundVault",
3602
+ "isMut": true,
3603
+ "isSigner": false
3604
+ },
3605
+ {
3606
+ "name": "userTokenAccount",
3612
3607
  "isMut": true,
3613
3608
  "isSigner": false
3614
3609
  },
@@ -4272,27 +4267,6 @@
4272
4267
  }
4273
4268
  ]
4274
4269
  },
4275
- {
4276
- "name": "updateSerumVault",
4277
- "accounts": [
4278
- {
4279
- "name": "state",
4280
- "isMut": true,
4281
- "isSigner": false
4282
- },
4283
- {
4284
- "name": "admin",
4285
- "isMut": true,
4286
- "isSigner": true
4287
- },
4288
- {
4289
- "name": "srmVault",
4290
- "isMut": false,
4291
- "isSigner": false
4292
- }
4293
- ],
4294
- "args": []
4295
- },
4296
4270
  {
4297
4271
  "name": "initializePerpMarket",
4298
4272
  "accounts": [
@@ -6886,76 +6860,6 @@
6886
6860
  }
6887
6861
  ]
6888
6862
  },
6889
- {
6890
- "name": "initializeProtocolIfSharesTransferConfig",
6891
- "accounts": [
6892
- {
6893
- "name": "admin",
6894
- "isMut": true,
6895
- "isSigner": true
6896
- },
6897
- {
6898
- "name": "protocolIfSharesTransferConfig",
6899
- "isMut": true,
6900
- "isSigner": false
6901
- },
6902
- {
6903
- "name": "state",
6904
- "isMut": false,
6905
- "isSigner": false
6906
- },
6907
- {
6908
- "name": "rent",
6909
- "isMut": false,
6910
- "isSigner": false
6911
- },
6912
- {
6913
- "name": "systemProgram",
6914
- "isMut": false,
6915
- "isSigner": false
6916
- }
6917
- ],
6918
- "args": []
6919
- },
6920
- {
6921
- "name": "updateProtocolIfSharesTransferConfig",
6922
- "accounts": [
6923
- {
6924
- "name": "admin",
6925
- "isMut": true,
6926
- "isSigner": true
6927
- },
6928
- {
6929
- "name": "protocolIfSharesTransferConfig",
6930
- "isMut": true,
6931
- "isSigner": false
6932
- },
6933
- {
6934
- "name": "state",
6935
- "isMut": false,
6936
- "isSigner": false
6937
- }
6938
- ],
6939
- "args": [
6940
- {
6941
- "name": "whitelistedSigners",
6942
- "type": {
6943
- "option": {
6944
- "array": [
6945
- "publicKey",
6946
- 4
6947
- ]
6948
- }
6949
- }
6950
- },
6951
- {
6952
- "name": "maxTransferPerEpoch",
6953
- "type": {
6954
- "option": "u128"
6955
- }
6956
- }
6957
- ]
6958
- },
6959
6863
  {
6960
6864
  "name": "initializePrelaunchOracle",
6961
6865
  "accounts": [
@@ -12206,6 +12110,9 @@
12206
12110
  },
12207
12111
  {
12208
12112
  "name": "StakeTransfer"
12113
+ },
12114
+ {
12115
+ "name": "AdminDeposit"
12209
12116
  }
12210
12117
  ]
12211
12118
  }
@@ -16218,5 +16125,8 @@
16218
16125
  "name": "InvalidIfRebalanceSwap",
16219
16126
  "msg": "Invalid If Rebalance Swap"
16220
16127
  }
16221
- ]
16128
+ ],
16129
+ "metadata": {
16130
+ "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
16131
+ }
16222
16132
  }
@@ -37,6 +37,10 @@ export interface SwiftOrderMessage {
37
37
  /** Base64 string of a prerequisite deposit tx. The swift order_message should be bundled
38
38
  * after the deposit when present */
39
39
  depositTx?: string;
40
+ /** order market index */
41
+ market_index: number;
42
+ /** order timestamp in unix ms */
43
+ ts: number;
40
44
  }
41
45
  export declare class SwiftOrderSubscriber {
42
46
  private config;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
3
- import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus, IfRebalanceConfigParams } from './types';
3
+ import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus, IfRebalanceConfigParams, TxParams } from './types';
4
4
  import { BN } from '@coral-xyz/anchor';
5
5
  import { DriftClient } from './driftClient';
6
6
  export declare class AdminClient extends DriftClient {
@@ -236,7 +236,11 @@ export declare class AdminClient extends DriftClient {
236
236
  getZeroMMOracleFieldsIx(marketIndex: number): Promise<TransactionInstruction>;
237
237
  updateFeatureBitFlagsMMOracle(enable: boolean): Promise<TransactionSignature>;
238
238
  getUpdateFeatureBitFlagsMMOracleIx(enable: boolean): Promise<TransactionInstruction>;
239
+ updateFeatureBitFlagsMedianTriggerPrice(enable: boolean): Promise<TransactionSignature>;
240
+ getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable: boolean): Promise<TransactionInstruction>;
239
241
  updateDelegateUserGovTokenInsuranceStake(authority: PublicKey, delegate: PublicKey): Promise<TransactionSignature>;
240
242
  getUpdateDelegateUserGovTokenInsuranceStakeIx(authority: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>;
243
+ depositIntoInsuranceFundStake(marketIndex: number, amount: BN, userStatsPublicKey: PublicKey, insuranceFundStakePublicKey: PublicKey, userTokenAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
244
+ getDepositIntoInsuranceFundStakeIx(marketIndex: number, amount: BN, userStatsPublicKey: PublicKey, insuranceFundStakePublicKey: PublicKey, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
241
245
  }
242
246
  //# sourceMappingURL=adminClient.d.ts.map