@drift-labs/sdk 2.91.0-beta.8 → 2.92.0-beta.1

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.91.0-beta.8
1
+ 2.92.0-beta.1
@@ -273,8 +273,8 @@ exports.MainnetSpotMarkets = [
273
273
  {
274
274
  symbol: 'JLP',
275
275
  marketIndex: 19,
276
- oracle: new web3_js_1.PublicKey('pmHEXBam7kbmCCg5ED5V7RNMN8e34sKu338KeuFAGof'),
277
- oracleSource: __1.OracleSource.SWITCHBOARD,
276
+ oracle: new web3_js_1.PublicKey('5Mb11e5rt1Sp6A286B145E4TmgMzsM2UX9nCF2vas5bs'),
277
+ oracleSource: __1.OracleSource.PYTH_PULL,
278
278
  mint: new web3_js_1.PublicKey('27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4'),
279
279
  precision: new __1.BN(10).pow(numericConstants_1.SIX),
280
280
  precisionExp: numericConstants_1.SIX,
@@ -694,6 +694,10 @@ export declare class DriftClient {
694
694
  requestRemoveInsuranceFundStake(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
695
695
  cancelRequestRemoveInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
696
696
  removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
697
+ updateUserQuoteAssetInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
698
+ getUpdateUserQuoteAssetInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
699
+ updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
700
+ getUpdateUserGovTokenInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
697
701
  settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
698
702
  getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
699
703
  resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
@@ -3674,6 +3674,50 @@ class DriftClient {
3674
3674
  const { txSig } = await this.sendTransaction(tx, additionalSigners, this.opts);
3675
3675
  return txSig;
3676
3676
  }
3677
+ async updateUserQuoteAssetInsuranceStake(authority, txParams) {
3678
+ const tx = await this.buildTransaction(await this.getUpdateUserQuoteAssetInsuranceStakeIx(authority), txParams);
3679
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
3680
+ return txSig;
3681
+ }
3682
+ async getUpdateUserQuoteAssetInsuranceStakeIx(authority) {
3683
+ const marketIndex = numericConstants_1.QUOTE_SPOT_MARKET_INDEX;
3684
+ const spotMarket = this.getSpotMarketAccount(marketIndex);
3685
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, authority, marketIndex);
3686
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
3687
+ const ix = this.program.instruction.updateUserQuoteAssetInsuranceStake({
3688
+ accounts: {
3689
+ state: await this.getStatePublicKey(),
3690
+ spotMarket: spotMarket.pubkey,
3691
+ insuranceFundStake: ifStakeAccountPublicKey,
3692
+ userStats: userStatsPublicKey,
3693
+ signer: this.wallet.publicKey,
3694
+ insuranceFundVault: spotMarket.insuranceFund.vault,
3695
+ },
3696
+ });
3697
+ return ix;
3698
+ }
3699
+ async updateUserGovTokenInsuranceStake(authority, txParams) {
3700
+ const tx = await this.buildTransaction(await this.getUpdateUserGovTokenInsuranceStakeIx(authority), txParams);
3701
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
3702
+ return txSig;
3703
+ }
3704
+ async getUpdateUserGovTokenInsuranceStakeIx(authority) {
3705
+ const marketIndex = numericConstants_1.GOV_SPOT_MARKET_INDEX;
3706
+ const spotMarket = this.getSpotMarketAccount(marketIndex);
3707
+ const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, authority, marketIndex);
3708
+ const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
3709
+ const ix = this.program.instruction.updateUserGovTokenInsuranceStake({
3710
+ accounts: {
3711
+ state: await this.getStatePublicKey(),
3712
+ spotMarket: spotMarket.pubkey,
3713
+ insuranceFundStake: ifStakeAccountPublicKey,
3714
+ userStats: userStatsPublicKey,
3715
+ signer: this.wallet.publicKey,
3716
+ insuranceFundVault: spotMarket.insuranceFund.vault,
3717
+ },
3718
+ });
3719
+ return ix;
3720
+ }
3677
3721
  async settleRevenueToInsuranceFund(spotMarketIndex, txParams) {
3678
3722
  const tx = await this.buildTransaction(await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex), txParams);
3679
3723
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.90.0",
2
+ "version": "2.91.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.91.0-beta.8",
3
+ "version": "2.92.0-beta.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -344,8 +344,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
344
344
  {
345
345
  symbol: 'JLP',
346
346
  marketIndex: 19,
347
- oracle: new PublicKey('pmHEXBam7kbmCCg5ED5V7RNMN8e34sKu338KeuFAGof'),
348
- oracleSource: OracleSource.SWITCHBOARD,
347
+ oracle: new PublicKey('5Mb11e5rt1Sp6A286B145E4TmgMzsM2UX9nCF2vas5bs'),
348
+ oracleSource: OracleSource.PYTH_PULL,
349
349
  mint: new PublicKey('27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4'),
350
350
  precision: new BN(10).pow(SIX),
351
351
  precisionExp: SIX,
@@ -102,6 +102,7 @@ import {
102
102
  QUOTE_SPOT_MARKET_INDEX,
103
103
  ZERO,
104
104
  QUOTE_PRECISION,
105
+ GOV_SPOT_MARKET_INDEX,
105
106
  } from './constants/numericConstants';
106
107
  import { findDirectionToClose, positionIsAvailable } from './math/position';
107
108
  import { getSignedTokenAmount, getTokenAmount } from './math/spotBalance';
@@ -6957,6 +6958,88 @@ export class DriftClient {
6957
6958
  return txSig;
6958
6959
  }
6959
6960
 
6961
+ public async updateUserQuoteAssetInsuranceStake(
6962
+ authority: PublicKey,
6963
+ txParams?: TxParams
6964
+ ): Promise<TransactionSignature> {
6965
+ const tx = await this.buildTransaction(
6966
+ await this.getUpdateUserQuoteAssetInsuranceStakeIx(authority),
6967
+ txParams
6968
+ );
6969
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
6970
+ return txSig;
6971
+ }
6972
+
6973
+ public async getUpdateUserQuoteAssetInsuranceStakeIx(
6974
+ authority: PublicKey
6975
+ ): Promise<TransactionInstruction> {
6976
+ const marketIndex = QUOTE_SPOT_MARKET_INDEX;
6977
+ const spotMarket = this.getSpotMarketAccount(marketIndex);
6978
+ const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
6979
+ this.program.programId,
6980
+ authority,
6981
+ marketIndex
6982
+ );
6983
+ const userStatsPublicKey = getUserStatsAccountPublicKey(
6984
+ this.program.programId,
6985
+ authority
6986
+ );
6987
+
6988
+ const ix = this.program.instruction.updateUserQuoteAssetInsuranceStake({
6989
+ accounts: {
6990
+ state: await this.getStatePublicKey(),
6991
+ spotMarket: spotMarket.pubkey,
6992
+ insuranceFundStake: ifStakeAccountPublicKey,
6993
+ userStats: userStatsPublicKey,
6994
+ signer: this.wallet.publicKey,
6995
+ insuranceFundVault: spotMarket.insuranceFund.vault,
6996
+ },
6997
+ });
6998
+
6999
+ return ix;
7000
+ }
7001
+
7002
+ public async updateUserGovTokenInsuranceStake(
7003
+ authority: PublicKey,
7004
+ txParams?: TxParams
7005
+ ): Promise<TransactionSignature> {
7006
+ const tx = await this.buildTransaction(
7007
+ await this.getUpdateUserGovTokenInsuranceStakeIx(authority),
7008
+ txParams
7009
+ );
7010
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
7011
+ return txSig;
7012
+ }
7013
+
7014
+ public async getUpdateUserGovTokenInsuranceStakeIx(
7015
+ authority: PublicKey
7016
+ ): Promise<TransactionInstruction> {
7017
+ const marketIndex = GOV_SPOT_MARKET_INDEX;
7018
+ const spotMarket = this.getSpotMarketAccount(marketIndex);
7019
+ const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
7020
+ this.program.programId,
7021
+ authority,
7022
+ marketIndex
7023
+ );
7024
+ const userStatsPublicKey = getUserStatsAccountPublicKey(
7025
+ this.program.programId,
7026
+ authority
7027
+ );
7028
+
7029
+ const ix = this.program.instruction.updateUserGovTokenInsuranceStake({
7030
+ accounts: {
7031
+ state: await this.getStatePublicKey(),
7032
+ spotMarket: spotMarket.pubkey,
7033
+ insuranceFundStake: ifStakeAccountPublicKey,
7034
+ userStats: userStatsPublicKey,
7035
+ signer: this.wallet.publicKey,
7036
+ insuranceFundVault: spotMarket.insuranceFund.vault,
7037
+ },
7038
+ });
7039
+
7040
+ return ix;
7041
+ }
7042
+
6960
7043
  public async settleRevenueToInsuranceFund(
6961
7044
  spotMarketIndex: number,
6962
7045
  txParams?: TxParams
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.90.0",
2
+ "version": "2.91.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {