@drift-labs/sdk 2.86.0-beta.20 → 2.86.0-beta.22

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.86.0-beta.20
1
+ 2.86.0-beta.22
@@ -183,6 +183,8 @@ export declare class AdminClient extends DriftClient {
183
183
  getUpdateSpotMarketFuelIx(spotMarketIndex: number, fuelBoostDeposits?: number, fuelBoostBorrows?: number, fuelBoostTaker?: number, fuelBoostMaker?: number, fuelBoostInsurance?: number): Promise<TransactionInstruction>;
184
184
  updatePerpMarketFuel(perpMarketIndex: number, fuelBoostTaker?: number, fuelBoostMaker?: number, fuelBoostPosition?: number): Promise<TransactionSignature>;
185
185
  getUpdatePerpMarketFuelIx(perpMarketIndex: number, fuelBoostTaker?: number, fuelBoostMaker?: number, fuelBoostPosition?: number): Promise<TransactionInstruction>;
186
+ initUserFuel(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionSignature>;
187
+ getInitUserFuelIx(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionInstruction>;
186
188
  initializePythPullOracle(feedId: string): Promise<TransactionSignature>;
187
189
  getInitializePythPullOracleIx(feedId: string): Promise<TransactionInstruction>;
188
190
  }
@@ -1667,6 +1667,23 @@ class AdminClient extends driftClient_1.DriftClient {
1667
1667
  },
1668
1668
  });
1669
1669
  }
1670
+ async initUserFuel(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance) {
1671
+ const updatePerpMarketFuelIx = await this.getInitUserFuelIx(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance);
1672
+ const tx = await this.buildTransaction(updatePerpMarketFuelIx);
1673
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1674
+ return txSig;
1675
+ }
1676
+ async getInitUserFuelIx(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance) {
1677
+ const userStats = await (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
1678
+ return await this.program.instruction.initUserFuel(fuelBonusDeposits || null, fuelBonusBorrows || null, fuelBonusTaker || null, fuelBonusMaker || null, fuelBonusInsurance || null, {
1679
+ accounts: {
1680
+ admin: this.wallet.publicKey,
1681
+ state: await this.getStatePublicKey(),
1682
+ user,
1683
+ userStats,
1684
+ },
1685
+ });
1686
+ }
1670
1687
  async initializePythPullOracle(feedId) {
1671
1688
  const initializePythPullOracleIx = await this.getInitializePythPullOracleIx(feedId);
1672
1689
  const tx = await this.buildTransaction(initializePythPullOracleIx);
@@ -342,9 +342,9 @@ exports.MainnetPerpMarkets = [
342
342
  symbol: '1MBONK-PERP',
343
343
  baseAssetSymbol: '1MBONK',
344
344
  marketIndex: 4,
345
- oracle: new web3_js_1.PublicKey('8ihFLu5FimgTQ1Unh4dVyEHUGodJ5gJQCrQf4KUVB9bN'),
345
+ oracle: new web3_js_1.PublicKey('GojbSnJuPdKDT1ZuHuAM5t9oz6bxTo1xhUKpTua2F72p'),
346
346
  launchTs: 1677690149000,
347
- oracleSource: __1.OracleSource.PYTH_1M,
347
+ oracleSource: __1.OracleSource.PYTH_1M_PULL,
348
348
  pythFeedId: '0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419',
349
349
  },
350
350
  {
@@ -375,9 +375,9 @@ exports.MainnetPerpMarkets = [
375
375
  symbol: 'DOGE-PERP',
376
376
  baseAssetSymbol: 'DOGE',
377
377
  marketIndex: 7,
378
- oracle: new web3_js_1.PublicKey('FsSM3s38PX9K7Dn6eGzuE29S2Dsk1Sss1baytTQdCaQj'),
378
+ oracle: new web3_js_1.PublicKey('23y63pHVwKfYSCDFdiGRaGbTYWoyr8UzhUE7zukyf6gK'),
379
379
  launchTs: 1680808053000,
380
- oracleSource: __1.OracleSource.PYTH,
380
+ oracleSource: __1.OracleSource.PYTH_PULL,
381
381
  pythFeedId: '0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c',
382
382
  },
383
383
  {
@@ -397,9 +397,9 @@ exports.MainnetPerpMarkets = [
397
397
  symbol: 'SUI-PERP',
398
398
  baseAssetSymbol: 'SUI',
399
399
  marketIndex: 9,
400
- oracle: new web3_js_1.PublicKey('3Qub3HaAJaa2xNY7SUqPKd3vVwTqDfDDkEUMPjXD2c1q'),
400
+ oracle: new web3_js_1.PublicKey('HBordkz5YxjzNURmKUY4vfEYFG9fZyZNeNF1VDLMoemT'),
401
401
  launchTs: 1683125906000,
402
- oracleSource: __1.OracleSource.PYTH,
402
+ oracleSource: __1.OracleSource.PYTH_PULL,
403
403
  pythFeedId: '0x23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
404
404
  },
405
405
  {
@@ -408,9 +408,9 @@ exports.MainnetPerpMarkets = [
408
408
  symbol: '1MPEPE-PERP',
409
409
  baseAssetSymbol: '1MPEPE',
410
410
  marketIndex: 10,
411
- oracle: new web3_js_1.PublicKey('FSfxunDmjjbDV2QxpyxFCAPKmYJHSLnLuvQXDLkMzLBm'),
411
+ oracle: new web3_js_1.PublicKey('CLxofhtzvLiErpn25wvUzpZXEqBhuZ6WMEckEraxyuGt'),
412
412
  launchTs: 1683781239000,
413
- oracleSource: __1.OracleSource.PYTH_1M,
413
+ oracleSource: __1.OracleSource.PYTH_1M_PULL,
414
414
  pythFeedId: '0xd69731a2e74ac1ce884fc3890f7ee324b6deb66147055249568869ed700882e4',
415
415
  },
416
416
  {
@@ -430,9 +430,9 @@ exports.MainnetPerpMarkets = [
430
430
  symbol: 'RNDR-PERP',
431
431
  baseAssetSymbol: 'RNDR',
432
432
  marketIndex: 12,
433
- oracle: new web3_js_1.PublicKey('CYGfrBJB9HgLf9iZyN4aH5HvUAi2htQ4MjPxeXMf4Egn'),
433
+ oracle: new web3_js_1.PublicKey('F3mPHRtJqqq57JPDBmUwUVhpyPLmjE5dAzDfpVgpFkug'),
434
434
  launchTs: 1687201081000,
435
- oracleSource: __1.OracleSource.PYTH,
435
+ oracleSource: __1.OracleSource.PYTH_PULL,
436
436
  pythFeedId: '0xab7347771135fc733f8f38db462ba085ed3309955f42554a14fa13e855ac0e2f',
437
437
  },
438
438
  {
@@ -463,9 +463,9 @@ exports.MainnetPerpMarkets = [
463
463
  symbol: 'INJ-PERP',
464
464
  baseAssetSymbol: 'INJ',
465
465
  marketIndex: 15,
466
- oracle: new web3_js_1.PublicKey('9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj'),
466
+ oracle: new web3_js_1.PublicKey('BfXcyDWJmYADa5eZD7gySSDd6giqgjvm7xsAhQ239SUD'),
467
467
  launchTs: 1698074659000,
468
- oracleSource: __1.OracleSource.PYTH,
468
+ oracleSource: __1.OracleSource.PYTH_PULL,
469
469
  pythFeedId: '0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592',
470
470
  },
471
471
  {
@@ -182,8 +182,8 @@ exports.MainnetSpotMarkets = [
182
182
  {
183
183
  symbol: 'RNDR',
184
184
  marketIndex: 12,
185
- oracle: new web3_js_1.PublicKey('CYGfrBJB9HgLf9iZyN4aH5HvUAi2htQ4MjPxeXMf4Egn'),
186
- oracleSource: __1.OracleSource.PYTH,
185
+ oracle: new web3_js_1.PublicKey('F3mPHRtJqqq57JPDBmUwUVhpyPLmjE5dAzDfpVgpFkug'),
186
+ oracleSource: __1.OracleSource.PYTH_PULL,
187
187
  mint: new web3_js_1.PublicKey('rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof'),
188
188
  precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
189
189
  precisionExp: numericConstants_1.EIGHT,
@@ -5207,6 +5207,63 @@
5207
5207
  }
5208
5208
  ]
5209
5209
  },
5210
+ {
5211
+ "name": "initUserFuel",
5212
+ "accounts": [
5213
+ {
5214
+ "name": "admin",
5215
+ "isMut": false,
5216
+ "isSigner": true
5217
+ },
5218
+ {
5219
+ "name": "state",
5220
+ "isMut": false,
5221
+ "isSigner": false
5222
+ },
5223
+ {
5224
+ "name": "user",
5225
+ "isMut": true,
5226
+ "isSigner": false
5227
+ },
5228
+ {
5229
+ "name": "userStats",
5230
+ "isMut": true,
5231
+ "isSigner": false
5232
+ }
5233
+ ],
5234
+ "args": [
5235
+ {
5236
+ "name": "fuelBoostDeposits",
5237
+ "type": {
5238
+ "option": "u32"
5239
+ }
5240
+ },
5241
+ {
5242
+ "name": "fuelBoostBorrows",
5243
+ "type": {
5244
+ "option": "u32"
5245
+ }
5246
+ },
5247
+ {
5248
+ "name": "fuelBoostTaker",
5249
+ "type": {
5250
+ "option": "u32"
5251
+ }
5252
+ },
5253
+ {
5254
+ "name": "fuelBoostMaker",
5255
+ "type": {
5256
+ "option": "u32"
5257
+ }
5258
+ },
5259
+ {
5260
+ "name": "fuelBoostInsurance",
5261
+ "type": {
5262
+ "option": "u32"
5263
+ }
5264
+ }
5265
+ ]
5266
+ },
5210
5267
  {
5211
5268
  "name": "updateAdmin",
5212
5269
  "accounts": [
package/lib/user.d.ts CHANGED
@@ -137,11 +137,12 @@ export declare class User {
137
137
  */
138
138
  getUnrealizedFundingPNL(marketIndex?: number): BN;
139
139
  getFuelBonus(now: BN, includeSettled?: boolean, includeUnsettled?: boolean): {
140
- depositFuel: any;
141
- borrowFuel: any;
142
- positionFuel: any;
143
- takerFuel: any;
144
- makerFuel: any;
140
+ depositFuel: BN;
141
+ borrowFuel: BN;
142
+ positionFuel: BN;
143
+ takerFuel: BN;
144
+ makerFuel: BN;
145
+ insuranceFuel: BN;
145
146
  };
146
147
  getSpotMarketAssetAndLiabilityValue(marketIndex?: number, marginCategory?: MarginCategory, liquidationBuffer?: BN, includeOpenOrders?: boolean, strict?: boolean, now?: BN): {
147
148
  totalAssetValue: BN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.86.0-beta.20",
3
+ "version": "2.86.0-beta.22",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -30,6 +30,7 @@ import {
30
30
  getProtocolIfSharesTransferConfigPublicKey,
31
31
  getPrelaunchOraclePublicKey,
32
32
  getPythPullOraclePublicKey,
33
+ getUserStatsAccountPublicKey,
33
34
  } from './addresses/pda';
34
35
  import { squareRootBN } from './math/utils';
35
36
  import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
@@ -3633,6 +3634,62 @@ export class AdminClient extends DriftClient {
3633
3634
  );
3634
3635
  }
3635
3636
 
3637
+ public async initUserFuel(
3638
+ user: PublicKey,
3639
+ authority: PublicKey,
3640
+ fuelBonusDeposits?: number,
3641
+ fuelBonusBorrows?: number,
3642
+ fuelBonusTaker?: number,
3643
+ fuelBonusMaker?: number,
3644
+ fuelBonusInsurance?: number
3645
+ ): Promise<TransactionSignature> {
3646
+ const updatePerpMarketFuelIx = await this.getInitUserFuelIx(
3647
+ user,
3648
+ authority,
3649
+ fuelBonusDeposits,
3650
+ fuelBonusBorrows,
3651
+ fuelBonusTaker,
3652
+ fuelBonusMaker,
3653
+ fuelBonusInsurance
3654
+ );
3655
+
3656
+ const tx = await this.buildTransaction(updatePerpMarketFuelIx);
3657
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
3658
+
3659
+ return txSig;
3660
+ }
3661
+
3662
+ public async getInitUserFuelIx(
3663
+ user: PublicKey,
3664
+ authority: PublicKey,
3665
+ fuelBonusDeposits?: number,
3666
+ fuelBonusBorrows?: number,
3667
+ fuelBonusTaker?: number,
3668
+ fuelBonusMaker?: number,
3669
+ fuelBonusInsurance?: number
3670
+ ): Promise<TransactionInstruction> {
3671
+ const userStats = await getUserStatsAccountPublicKey(
3672
+ this.program.programId,
3673
+ authority
3674
+ );
3675
+
3676
+ return await this.program.instruction.initUserFuel(
3677
+ fuelBonusDeposits || null,
3678
+ fuelBonusBorrows || null,
3679
+ fuelBonusTaker || null,
3680
+ fuelBonusMaker || null,
3681
+ fuelBonusInsurance || null,
3682
+ {
3683
+ accounts: {
3684
+ admin: this.wallet.publicKey,
3685
+ state: await this.getStatePublicKey(),
3686
+ user,
3687
+ userStats,
3688
+ },
3689
+ }
3690
+ );
3691
+ }
3692
+
3636
3693
  public async initializePythPullOracle(
3637
3694
  feedId: string
3638
3695
  ): Promise<TransactionSignature> {
@@ -384,9 +384,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
384
384
  symbol: '1MBONK-PERP',
385
385
  baseAssetSymbol: '1MBONK',
386
386
  marketIndex: 4,
387
- oracle: new PublicKey('8ihFLu5FimgTQ1Unh4dVyEHUGodJ5gJQCrQf4KUVB9bN'),
387
+ oracle: new PublicKey('GojbSnJuPdKDT1ZuHuAM5t9oz6bxTo1xhUKpTua2F72p'),
388
388
  launchTs: 1677690149000,
389
- oracleSource: OracleSource.PYTH_1M,
389
+ oracleSource: OracleSource.PYTH_1M_PULL,
390
390
  pythFeedId:
391
391
  '0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419',
392
392
  },
@@ -420,9 +420,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
420
420
  symbol: 'DOGE-PERP',
421
421
  baseAssetSymbol: 'DOGE',
422
422
  marketIndex: 7,
423
- oracle: new PublicKey('FsSM3s38PX9K7Dn6eGzuE29S2Dsk1Sss1baytTQdCaQj'),
423
+ oracle: new PublicKey('23y63pHVwKfYSCDFdiGRaGbTYWoyr8UzhUE7zukyf6gK'),
424
424
  launchTs: 1680808053000,
425
- oracleSource: OracleSource.PYTH,
425
+ oracleSource: OracleSource.PYTH_PULL,
426
426
  pythFeedId:
427
427
  '0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c',
428
428
  },
@@ -444,9 +444,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
444
444
  symbol: 'SUI-PERP',
445
445
  baseAssetSymbol: 'SUI',
446
446
  marketIndex: 9,
447
- oracle: new PublicKey('3Qub3HaAJaa2xNY7SUqPKd3vVwTqDfDDkEUMPjXD2c1q'),
447
+ oracle: new PublicKey('HBordkz5YxjzNURmKUY4vfEYFG9fZyZNeNF1VDLMoemT'),
448
448
  launchTs: 1683125906000,
449
- oracleSource: OracleSource.PYTH,
449
+ oracleSource: OracleSource.PYTH_PULL,
450
450
  pythFeedId:
451
451
  '0x23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
452
452
  },
@@ -456,9 +456,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
456
456
  symbol: '1MPEPE-PERP',
457
457
  baseAssetSymbol: '1MPEPE',
458
458
  marketIndex: 10,
459
- oracle: new PublicKey('FSfxunDmjjbDV2QxpyxFCAPKmYJHSLnLuvQXDLkMzLBm'),
459
+ oracle: new PublicKey('CLxofhtzvLiErpn25wvUzpZXEqBhuZ6WMEckEraxyuGt'),
460
460
  launchTs: 1683781239000,
461
- oracleSource: OracleSource.PYTH_1M,
461
+ oracleSource: OracleSource.PYTH_1M_PULL,
462
462
  pythFeedId:
463
463
  '0xd69731a2e74ac1ce884fc3890f7ee324b6deb66147055249568869ed700882e4',
464
464
  },
@@ -480,9 +480,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
480
480
  symbol: 'RNDR-PERP',
481
481
  baseAssetSymbol: 'RNDR',
482
482
  marketIndex: 12,
483
- oracle: new PublicKey('CYGfrBJB9HgLf9iZyN4aH5HvUAi2htQ4MjPxeXMf4Egn'),
483
+ oracle: new PublicKey('F3mPHRtJqqq57JPDBmUwUVhpyPLmjE5dAzDfpVgpFkug'),
484
484
  launchTs: 1687201081000,
485
- oracleSource: OracleSource.PYTH,
485
+ oracleSource: OracleSource.PYTH_PULL,
486
486
  pythFeedId:
487
487
  '0xab7347771135fc733f8f38db462ba085ed3309955f42554a14fa13e855ac0e2f',
488
488
  },
@@ -516,9 +516,9 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
516
516
  symbol: 'INJ-PERP',
517
517
  baseAssetSymbol: 'INJ',
518
518
  marketIndex: 15,
519
- oracle: new PublicKey('9EdtbaivHQYA4Nh3XzGR6DwRaoorqXYnmpfsnFhvwuVj'),
519
+ oracle: new PublicKey('BfXcyDWJmYADa5eZD7gySSDd6giqgjvm7xsAhQ239SUD'),
520
520
  launchTs: 1698074659000,
521
- oracleSource: OracleSource.PYTH,
521
+ oracleSource: OracleSource.PYTH_PULL,
522
522
  pythFeedId:
523
523
  '0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592',
524
524
  },
@@ -237,8 +237,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
237
237
  {
238
238
  symbol: 'RNDR',
239
239
  marketIndex: 12,
240
- oracle: new PublicKey('CYGfrBJB9HgLf9iZyN4aH5HvUAi2htQ4MjPxeXMf4Egn'),
241
- oracleSource: OracleSource.PYTH,
240
+ oracle: new PublicKey('F3mPHRtJqqq57JPDBmUwUVhpyPLmjE5dAzDfpVgpFkug'),
241
+ oracleSource: OracleSource.PYTH_PULL,
242
242
  mint: new PublicKey('rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof'),
243
243
  precision: new BN(10).pow(EIGHT),
244
244
  precisionExp: EIGHT,
@@ -5207,6 +5207,63 @@
5207
5207
  }
5208
5208
  ]
5209
5209
  },
5210
+ {
5211
+ "name": "initUserFuel",
5212
+ "accounts": [
5213
+ {
5214
+ "name": "admin",
5215
+ "isMut": false,
5216
+ "isSigner": true
5217
+ },
5218
+ {
5219
+ "name": "state",
5220
+ "isMut": false,
5221
+ "isSigner": false
5222
+ },
5223
+ {
5224
+ "name": "user",
5225
+ "isMut": true,
5226
+ "isSigner": false
5227
+ },
5228
+ {
5229
+ "name": "userStats",
5230
+ "isMut": true,
5231
+ "isSigner": false
5232
+ }
5233
+ ],
5234
+ "args": [
5235
+ {
5236
+ "name": "fuelBoostDeposits",
5237
+ "type": {
5238
+ "option": "u32"
5239
+ }
5240
+ },
5241
+ {
5242
+ "name": "fuelBoostBorrows",
5243
+ "type": {
5244
+ "option": "u32"
5245
+ }
5246
+ },
5247
+ {
5248
+ "name": "fuelBoostTaker",
5249
+ "type": {
5250
+ "option": "u32"
5251
+ }
5252
+ },
5253
+ {
5254
+ "name": "fuelBoostMaker",
5255
+ "type": {
5256
+ "option": "u32"
5257
+ }
5258
+ },
5259
+ {
5260
+ "name": "fuelBoostInsurance",
5261
+ "type": {
5262
+ "option": "u32"
5263
+ }
5264
+ }
5265
+ ]
5266
+ },
5210
5267
  {
5211
5268
  "name": "updateAdmin",
5212
5269
  "accounts": [
package/src/user.ts CHANGED
@@ -886,11 +886,12 @@ export class User {
886
886
  includeSettled = true,
887
887
  includeUnsettled = true
888
888
  ): {
889
- depositFuel;
890
- borrowFuel;
891
- positionFuel;
892
- takerFuel;
893
- makerFuel;
889
+ depositFuel: BN;
890
+ borrowFuel: BN;
891
+ positionFuel: BN;
892
+ takerFuel: BN;
893
+ makerFuel: BN;
894
+ insuranceFuel: BN;
894
895
  } {
895
896
  const userAccount: UserAccount = this.getUserAccount();
896
897