@drift-labs/sdk 2.38.1-beta.1 → 2.38.1-beta.11

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.
Files changed (54) hide show
  1. package/VERSION +1 -1
  2. package/lib/accounts/fetch.js +2 -2
  3. package/lib/accounts/pollingDriftClientAccountSubscriber.js +2 -14
  4. package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
  5. package/lib/adminClient.d.ts +1 -0
  6. package/lib/adminClient.js +11 -0
  7. package/lib/config.d.ts +1 -0
  8. package/lib/config.js +2 -0
  9. package/lib/driftClient.d.ts +22 -2
  10. package/lib/driftClient.js +101 -15
  11. package/lib/examples/loadDlob.js +3 -1
  12. package/lib/examples/makeTradeExample.js +3 -1
  13. package/lib/idl/drift.json +36 -1
  14. package/lib/index.d.ts +3 -0
  15. package/lib/index.js +3 -0
  16. package/lib/jupiter/jupiterClient.d.ts +197 -0
  17. package/lib/jupiter/jupiterClient.js +48 -3
  18. package/lib/math/spotBalance.d.ts +6 -5
  19. package/lib/math/spotBalance.js +29 -12
  20. package/lib/math/spotMarket.d.ts +1 -1
  21. package/lib/math/spotMarket.js +2 -2
  22. package/lib/math/spotPosition.d.ts +16 -3
  23. package/lib/math/spotPosition.js +53 -9
  24. package/lib/oracles/strictOraclePrice.d.ts +8 -0
  25. package/lib/oracles/strictOraclePrice.js +17 -0
  26. package/lib/priorityFee/priorityFeeSubscriber.d.ts +22 -0
  27. package/lib/priorityFee/priorityFeeSubscriber.js +46 -0
  28. package/lib/tokenFaucet.js +1 -0
  29. package/lib/types.d.ts +4 -0
  30. package/lib/types.js +3 -0
  31. package/lib/user.d.ts +5 -4
  32. package/lib/user.js +71 -105
  33. package/package.json +2 -2
  34. package/src/accounts/fetch.ts +2 -2
  35. package/src/accounts/pollingDriftClientAccountSubscriber.ts +5 -23
  36. package/src/accounts/pollingUserStatsAccountSubscriber.ts +10 -8
  37. package/src/adminClient.ts +23 -0
  38. package/src/config.ts +3 -0
  39. package/src/driftClient.ts +173 -13
  40. package/src/examples/loadDlob.ts +1 -0
  41. package/src/examples/makeTradeExample.ts +1 -0
  42. package/src/idl/drift.json +36 -1
  43. package/src/index.ts +3 -0
  44. package/src/jupiter/jupiterClient.ts +246 -3
  45. package/src/math/spotBalance.ts +38 -12
  46. package/src/math/spotMarket.ts +7 -1
  47. package/src/math/spotPosition.ts +133 -18
  48. package/src/oracles/strictOraclePrice.ts +19 -0
  49. package/src/priorityFee/priorityFeeSubscriber.ts +75 -0
  50. package/src/tokenFaucet.ts +1 -0
  51. package/src/types.ts +4 -0
  52. package/src/user.ts +171 -228
  53. package/tests/dlob/helpers.ts +10 -7
  54. package/tests/user/test.ts +77 -4
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.38.1-beta.1
1
+ 2.38.1-beta.11
@@ -16,7 +16,7 @@ async function fetchUserAccountsUsingKeys(connection, program, userAccountPublic
16
16
  if (!accountInfo) {
17
17
  return undefined;
18
18
  }
19
- return program.account.user.coder.accounts.decode('User', accountInfo.data);
19
+ return program.account.user.coder.accounts.decodeUnchecked('User', accountInfo.data);
20
20
  });
21
21
  }
22
22
  exports.fetchUserAccountsUsingKeys = fetchUserAccountsUsingKeys;
@@ -24,7 +24,7 @@ async function fetchUserStatsAccount(connection, program, authority) {
24
24
  const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(program.programId, authority);
25
25
  const accountInfo = await connection.getAccountInfo(userStatsPublicKey, 'confirmed');
26
26
  return accountInfo
27
- ? program.account.user.coder.accounts.decode('UserStats', accountInfo.data)
27
+ ? program.account.user.coder.accounts.decodeUnchecked('UserStats', accountInfo.data)
28
28
  : undefined;
29
29
  }
30
30
  exports.fetchUserStatsAccount = fetchUserStatsAccount;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PollingDriftClientAccountSubscriber = void 0;
4
4
  const types_1 = require("./types");
5
- const anchor_1 = require("@coral-xyz/anchor");
6
5
  const events_1 = require("events");
7
6
  const pda_1 = require("../addresses/pda");
8
7
  const utils_1 = require("./utils");
@@ -138,18 +137,7 @@ class PollingDriftClientAccountSubscriber {
138
137
  accountToPoll.callbackId = await this.accountLoader.addAccount(accountToPoll.publicKey, (buffer, slot) => {
139
138
  if (!buffer)
140
139
  return;
141
- let account;
142
- try {
143
- account = this.program.account[accountToPoll.key].coder.accounts.decode((0, utils_1.capitalize)(accountToPoll.key), buffer);
144
- }
145
- catch (e) {
146
- console.error(e);
147
- console.log('account key', accountToPoll.key);
148
- console.log('accountToPoll.publicKey', accountToPoll.publicKey.toString());
149
- console.log('buffer', buffer.toString('base64'));
150
- console.log('discriminator', anchor_1.BorshAccountsCoder.accountDiscriminator((0, utils_1.capitalize)(accountToPoll.key)).toString('base64'));
151
- return;
152
- }
140
+ const account = this.program.account[accountToPoll.key].coder.accounts.decodeUnchecked((0, utils_1.capitalize)(accountToPoll.key), buffer);
153
141
  const dataAndSlot = {
154
142
  data: account,
155
143
  slot,
@@ -188,7 +176,7 @@ class PollingDriftClientAccountSubscriber {
188
176
  for (const [_, accountToPoll] of this.accountsToPoll) {
189
177
  const { buffer, slot } = this.accountLoader.getBufferAndSlot(accountToPoll.publicKey);
190
178
  if (buffer) {
191
- const account = this.program.account[accountToPoll.key].coder.accounts.decode((0, utils_1.capitalize)(accountToPoll.key), buffer);
179
+ const account = this.program.account[accountToPoll.key].coder.accounts.decodeUnchecked((0, utils_1.capitalize)(accountToPoll.key), buffer);
192
180
  if (accountToPoll.mapKey != undefined) {
193
181
  this[accountToPoll.key].set(accountToPoll.mapKey, {
194
182
  data: account,
@@ -37,7 +37,7 @@ class PollingUserStatsAccountSubscriber {
37
37
  if (this.userStats && this.userStats.slot > slot) {
38
38
  return;
39
39
  }
40
- const account = this.program.account.userStats.coder.accounts.decode('UserStats', buffer);
40
+ const account = this.program.account.userStats.coder.accounts.decodeUnchecked('UserStats', buffer);
41
41
  this.userStats = { data: account, slot };
42
42
  this.eventEmitter.emit('userStatsAccountUpdate', account);
43
43
  this.eventEmitter.emit('update');
@@ -57,7 +57,7 @@ class PollingUserStatsAccountSubscriber {
57
57
  const { buffer, slot } = this.accountLoader.getBufferAndSlot(this.userStatsAccountPublicKey);
58
58
  const currentSlot = (_b = (_a = this.userStats) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0;
59
59
  if (buffer && slot > currentSlot) {
60
- const account = this.program.account.userStats.coder.accounts.decode('UserStats', buffer);
60
+ const account = this.program.account.userStats.coder.accounts.decodeUnchecked('UserStats', buffer);
61
61
  this.userStats = { data: account, slot };
62
62
  }
63
63
  }
@@ -38,6 +38,7 @@ export declare class AdminClient extends DriftClient {
38
38
  updateSpotMarketIfFactor(spotMarketIndex: number, userIfFactor: BN, totalIfFactor: BN): Promise<TransactionSignature>;
39
39
  updateSpotMarketRevenueSettlePeriod(spotMarketIndex: number, revenueSettlePeriod: BN): Promise<TransactionSignature>;
40
40
  updateSpotMarketMaxTokenDeposits(spotMarketIndex: number, maxTokenDeposits: BN): Promise<TransactionSignature>;
41
+ updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex: number, scaleInitialAssetWeightStart: BN): Promise<TransactionSignature>;
41
42
  updateInsuranceFundUnstakingPeriod(spotMarketIndex: number, insuranceWithdrawEscrowPeriod: BN): Promise<TransactionSignature>;
42
43
  updateLpCooldownTime(cooldownTime: BN): Promise<TransactionSignature>;
43
44
  updatePerpMarketOracle(perpMarketIndex: number, oracle: PublicKey, oracleSource: OracleSource): Promise<TransactionSignature>;
@@ -483,6 +483,17 @@ class AdminClient extends driftClient_1.DriftClient {
483
483
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
484
484
  return txSig;
485
485
  }
486
+ async updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex, scaleInitialAssetWeightStart) {
487
+ const tx = this.program.transaction.updateSpotMarketScaleInitialAssetWeightStart(scaleInitialAssetWeightStart, {
488
+ accounts: {
489
+ admin: this.wallet.publicKey,
490
+ state: await this.getStatePublicKey(),
491
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
492
+ },
493
+ });
494
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
495
+ return txSig;
496
+ }
486
497
  async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
487
498
  const tx = await this.program.transaction.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
488
499
  accounts: {
package/lib/config.d.ts CHANGED
@@ -6,6 +6,7 @@ type DriftConfig = {
6
6
  ENV: DriftEnv;
7
7
  PYTH_ORACLE_MAPPING_ADDRESS: string;
8
8
  DRIFT_PROGRAM_ID: string;
9
+ JIT_PROXY_PROGRAM_ID?: string;
9
10
  USDC_MINT_ADDRESS: string;
10
11
  SERUM_V3: string;
11
12
  PHOENIX: string;
package/lib/config.js CHANGED
@@ -9,6 +9,7 @@ exports.configs = {
9
9
  ENV: 'devnet',
10
10
  PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
11
11
  DRIFT_PROGRAM_ID: exports.DRIFT_PROGRAM_ID,
12
+ JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
12
13
  USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
13
14
  SERUM_V3: 'DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY',
14
15
  PHOENIX: 'PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY',
@@ -21,6 +22,7 @@ exports.configs = {
21
22
  ENV: 'mainnet-beta',
22
23
  PYTH_ORACLE_MAPPING_ADDRESS: 'AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J',
23
24
  DRIFT_PROGRAM_ID: exports.DRIFT_PROGRAM_ID,
25
+ JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
24
26
  USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
25
27
  SERUM_V3: 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX',
26
28
  PHOENIX: 'PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY',
@@ -13,7 +13,7 @@ import { DriftClientConfig } from './driftClientConfig';
13
13
  import { User } from './user';
14
14
  import { UserSubscriptionConfig } from './userConfig';
15
15
  import { UserStats } from './userStats';
16
- import { JupiterClient, Route, SwapMode } from './jupiter/jupiterClient';
16
+ import { JupiterClient, QuoteResponse, Route, SwapMode } from './jupiter/jupiterClient';
17
17
  import { UserStatsSubscriptionConfig } from './userStatsConfig';
18
18
  type RemainingAccountParams = {
19
19
  userAccounts: UserAccount[];
@@ -319,7 +319,7 @@ export declare class DriftClient {
319
319
  * @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
320
320
  * @param txParams
321
321
  */
322
- swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, }: {
322
+ swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, }: {
323
323
  jupiterClient: JupiterClient;
324
324
  outMarketIndex: number;
325
325
  inMarketIndex: number;
@@ -331,6 +331,9 @@ export declare class DriftClient {
331
331
  route?: Route;
332
332
  reduceOnly?: SwapReduceOnly;
333
333
  txParams?: TxParams;
334
+ v6?: {
335
+ quote?: QuoteResponse;
336
+ };
334
337
  }): Promise<TransactionSignature>;
335
338
  getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, route, reduceOnly, userAccountPublicKey, }: {
336
339
  jupiterClient: JupiterClient;
@@ -349,6 +352,23 @@ export declare class DriftClient {
349
352
  ixs: TransactionInstruction[];
350
353
  lookupTables: AddressLookupTableAccount[];
351
354
  }>;
355
+ getJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, quote, reduceOnly, userAccountPublicKey, }: {
356
+ jupiterClient: JupiterClient;
357
+ outMarketIndex: number;
358
+ inMarketIndex: number;
359
+ outAssociatedTokenAccount?: PublicKey;
360
+ inAssociatedTokenAccount?: PublicKey;
361
+ amount: BN;
362
+ slippageBps?: number;
363
+ swapMode?: SwapMode;
364
+ onlyDirectRoutes?: boolean;
365
+ quote?: QuoteResponse;
366
+ reduceOnly?: SwapReduceOnly;
367
+ userAccountPublicKey?: PublicKey;
368
+ }): Promise<{
369
+ ixs: TransactionInstruction[];
370
+ lookupTables: AddressLookupTableAccount[];
371
+ }>;
352
372
  /**
353
373
  * Get the drift begin_swap and end_swap instructions
354
374
  *
@@ -76,7 +76,9 @@ class DriftClient {
76
76
  this.connection = config.connection;
77
77
  this.wallet = config.wallet;
78
78
  this.opts = config.opts || anchor_1.AnchorProvider.defaultOptions();
79
- this.provider = new anchor_1.AnchorProvider(config.connection, config.wallet, this.opts);
79
+ this.provider = new anchor_1.AnchorProvider(config.connection,
80
+ // @ts-ignore
81
+ config.wallet, this.opts);
80
82
  this.program = new anchor_1.Program(drift_json_1.default, (_a = config.programID) !== null && _a !== void 0 ? _a : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
81
83
  this.authority = (_b = config.authority) !== null && _b !== void 0 ? _b : this.wallet.publicKey;
82
84
  this.activeSubAccountId = (_c = config.activeSubAccountId) !== null && _c !== void 0 ? _c : 0;
@@ -292,7 +294,9 @@ class DriftClient {
292
294
  * @param includeDelegates
293
295
  */
294
296
  async updateWallet(newWallet, subAccountIds, activeSubAccountId, includeDelegates, authoritySubaccountMap) {
295
- const newProvider = new anchor_1.AnchorProvider(this.connection, newWallet, this.opts);
297
+ const newProvider = new anchor_1.AnchorProvider(this.connection,
298
+ // @ts-ignore
299
+ newWallet, this.opts);
296
300
  const newProgram = new anchor_1.Program(drift_json_1.default, this.program.programId, newProvider);
297
301
  this.skipLoadUsers = false;
298
302
  // Update provider for txSender with new wallet details
@@ -1374,6 +1378,7 @@ class DriftClient {
1374
1378
  ]);
1375
1379
  const { txSig, slot } = await this.txSender.sendRawTransaction(signedVersionedMarketOrderTx.serialize(), this.opts);
1376
1380
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1381
+ // @ts-ignore
1377
1382
  return { txSig, signedFillTx: signedVersionedFillTx };
1378
1383
  }
1379
1384
  else {
@@ -1970,19 +1975,41 @@ class DriftClient {
1970
1975
  * @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
1971
1976
  * @param txParams
1972
1977
  */
1973
- async swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, }) {
1974
- const { ixs, lookupTables } = await this.getJupiterSwapIx({
1975
- jupiterClient,
1976
- outMarketIndex,
1977
- inMarketIndex,
1978
- outAssociatedTokenAccount,
1979
- inAssociatedTokenAccount,
1980
- amount,
1981
- slippageBps,
1982
- swapMode,
1983
- route,
1984
- reduceOnly,
1985
- });
1978
+ async swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, }) {
1979
+ let ixs;
1980
+ let lookupTables;
1981
+ if (v6) {
1982
+ const res = await this.getJupiterSwapIxV6({
1983
+ jupiterClient,
1984
+ outMarketIndex,
1985
+ inMarketIndex,
1986
+ outAssociatedTokenAccount,
1987
+ inAssociatedTokenAccount,
1988
+ amount,
1989
+ slippageBps,
1990
+ swapMode,
1991
+ quote: v6.quote,
1992
+ reduceOnly,
1993
+ });
1994
+ ixs = res.ixs;
1995
+ lookupTables = res.lookupTables;
1996
+ }
1997
+ else {
1998
+ const res = await this.getJupiterSwapIx({
1999
+ jupiterClient,
2000
+ outMarketIndex,
2001
+ inMarketIndex,
2002
+ outAssociatedTokenAccount,
2003
+ inAssociatedTokenAccount,
2004
+ amount,
2005
+ slippageBps,
2006
+ swapMode,
2007
+ route,
2008
+ reduceOnly,
2009
+ });
2010
+ ixs = res.ixs;
2011
+ lookupTables = res.lookupTables;
2012
+ }
1986
2013
  const tx = (await this.buildTransaction(ixs, txParams, 0, lookupTables));
1987
2014
  const { txSig, slot } = await this.sendTransaction(tx);
1988
2015
  this.spotMarketLastSlotCache.set(outMarketIndex, slot);
@@ -2051,6 +2078,65 @@ class DriftClient {
2051
2078
  ];
2052
2079
  return { ixs, lookupTables };
2053
2080
  }
2081
+ async getJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, quote, reduceOnly, userAccountPublicKey, }) {
2082
+ const outMarket = this.getSpotMarketAccount(outMarketIndex);
2083
+ const inMarket = this.getSpotMarketAccount(inMarketIndex);
2084
+ if (!quote) {
2085
+ const fetchedQuote = await jupiterClient.getQuote({
2086
+ inputMint: inMarket.mint,
2087
+ outputMint: outMarket.mint,
2088
+ amount,
2089
+ slippageBps,
2090
+ swapMode,
2091
+ onlyDirectRoutes,
2092
+ });
2093
+ quote = fetchedQuote;
2094
+ }
2095
+ const transaction = await jupiterClient.getSwap({
2096
+ quote,
2097
+ userPublicKey: this.provider.wallet.publicKey,
2098
+ slippageBps,
2099
+ });
2100
+ const { transactionMessage, lookupTables } = await jupiterClient.getTransactionMessageAndLookupTables({
2101
+ transaction,
2102
+ });
2103
+ const jupiterInstructions = jupiterClient.getJupiterInstructions({
2104
+ transactionMessage,
2105
+ inputMint: inMarket.mint,
2106
+ outputMint: outMarket.mint,
2107
+ });
2108
+ const preInstructions = [];
2109
+ if (!outAssociatedTokenAccount) {
2110
+ outAssociatedTokenAccount = await this.getAssociatedTokenAccount(outMarket.marketIndex, false);
2111
+ const accountInfo = await this.connection.getAccountInfo(outAssociatedTokenAccount);
2112
+ if (!accountInfo) {
2113
+ preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(outAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, outMarket.mint));
2114
+ }
2115
+ }
2116
+ if (!inAssociatedTokenAccount) {
2117
+ inAssociatedTokenAccount = await this.getAssociatedTokenAccount(inMarket.marketIndex, false);
2118
+ const accountInfo = await this.connection.getAccountInfo(inAssociatedTokenAccount);
2119
+ if (!accountInfo) {
2120
+ preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(inAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, inMarket.mint));
2121
+ }
2122
+ }
2123
+ const { beginSwapIx, endSwapIx } = await this.getSwapIx({
2124
+ outMarketIndex,
2125
+ inMarketIndex,
2126
+ amountIn: amount,
2127
+ inTokenAccount: inAssociatedTokenAccount,
2128
+ outTokenAccount: outAssociatedTokenAccount,
2129
+ reduceOnly,
2130
+ userAccountPublicKey,
2131
+ });
2132
+ const ixs = [
2133
+ ...preInstructions,
2134
+ beginSwapIx,
2135
+ ...jupiterInstructions,
2136
+ endSwapIx,
2137
+ ];
2138
+ return { ixs, lookupTables };
2139
+ }
2054
2140
  /**
2055
2141
  * Get the drift begin_swap and end_swap instructions
2056
2142
  *
@@ -16,7 +16,9 @@ const main = async () => {
16
16
  const rpcAddress = process.env.RPC_ADDRESS; // can use: https://api.devnet.solana.com for devnet; https://api.mainnet-beta.solana.com for mainnet;
17
17
  const connection = new web3_js_1.Connection(rpcAddress);
18
18
  // Set up the Provider
19
- const provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
19
+ const provider = new anchor_1.AnchorProvider(connection,
20
+ // @ts-ignore
21
+ wallet, anchor_1.AnchorProvider.defaultOptions());
20
22
  // Set up the Drift Clearing House
21
23
  const driftPublicKey = new web3_js_1.PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
22
24
  const bulkAccountLoader = new __2.BulkAccountLoader(connection, 'confirmed', 1000);
@@ -23,7 +23,9 @@ const main = async () => {
23
23
  const rpcAddress = process.env.RPC_ADDRESS; // can use: https://api.devnet.solana.com for devnet; https://api.mainnet-beta.solana.com for mainnet;
24
24
  const connection = new web3_js_1.Connection(rpcAddress);
25
25
  // Set up the Provider
26
- const provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
26
+ const provider = new anchor_1.AnchorProvider(connection,
27
+ // @ts-ignore
28
+ wallet, anchor_1.AnchorProvider.defaultOptions());
27
29
  // Check SOL Balance
28
30
  const lamportsBalance = await connection.getBalance(wallet.publicKey);
29
31
  console.log('SOL balance:', lamportsBalance / 10 ** 9);
@@ -3538,6 +3538,32 @@
3538
3538
  }
3539
3539
  ]
3540
3540
  },
3541
+ {
3542
+ "name": "updateSpotMarketScaleInitialAssetWeightStart",
3543
+ "accounts": [
3544
+ {
3545
+ "name": "admin",
3546
+ "isMut": false,
3547
+ "isSigner": true
3548
+ },
3549
+ {
3550
+ "name": "state",
3551
+ "isMut": false,
3552
+ "isSigner": false
3553
+ },
3554
+ {
3555
+ "name": "spotMarket",
3556
+ "isMut": true,
3557
+ "isSigner": false
3558
+ }
3559
+ ],
3560
+ "args": [
3561
+ {
3562
+ "name": "scaleInitialAssetWeightStart",
3563
+ "type": "u64"
3564
+ }
3565
+ ]
3566
+ },
3541
3567
  {
3542
3568
  "name": "updateSpotMarketOracle",
3543
3569
  "accounts": [
@@ -5357,12 +5383,21 @@
5357
5383
  ],
5358
5384
  "type": "u64"
5359
5385
  },
5386
+ {
5387
+ "name": "scaleInitialAssetWeightStart",
5388
+ "docs": [
5389
+ "When to begin scaling down the initial asset weight",
5390
+ "disabled when 0",
5391
+ "precision: QUOTE_PRECISION"
5392
+ ],
5393
+ "type": "u64"
5394
+ },
5360
5395
  {
5361
5396
  "name": "padding",
5362
5397
  "type": {
5363
5398
  "array": [
5364
5399
  "u8",
5365
- 56
5400
+ 48
5366
5401
  ]
5367
5402
  }
5368
5403
  }
package/lib/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import pyth from '@pythnetwork/client';
4
4
  export * from './tokenFaucet';
5
5
  export * from './oracles/types';
6
6
  export * from './oracles/pythClient';
7
+ export * from './oracles/strictOraclePrice';
7
8
  export * from './types';
8
9
  export * from './constants/perpMarkets';
9
10
  export * from './accounts/fetch';
@@ -48,6 +49,7 @@ export * from './math/repeg';
48
49
  export * from './math/margin';
49
50
  export * from './math/insurance';
50
51
  export * from './math/superStake';
52
+ export * from './math/spotPosition';
51
53
  export * from './marinade';
52
54
  export * from './orderParams';
53
55
  export * from './slot/SlotSubscriber';
@@ -59,6 +61,7 @@ export * from './constants/numericConstants';
59
61
  export * from './serum/serumSubscriber';
60
62
  export * from './serum/serumFulfillmentConfigMap';
61
63
  export * from './phoenix/phoenixSubscriber';
64
+ export * from './priorityFee/priorityFeeSubscriber';
62
65
  export * from './phoenix/phoenixFulfillmentConfigMap';
63
66
  export * from './tx/fastSingleTxSender';
64
67
  export * from './tx/retryTxSender';
package/lib/index.js CHANGED
@@ -27,6 +27,7 @@ exports.pyth = client_1.default;
27
27
  __exportStar(require("./tokenFaucet"), exports);
28
28
  __exportStar(require("./oracles/types"), exports);
29
29
  __exportStar(require("./oracles/pythClient"), exports);
30
+ __exportStar(require("./oracles/strictOraclePrice"), exports);
30
31
  __exportStar(require("./types"), exports);
31
32
  __exportStar(require("./constants/perpMarkets"), exports);
32
33
  __exportStar(require("./accounts/fetch"), exports);
@@ -71,6 +72,7 @@ __exportStar(require("./math/repeg"), exports);
71
72
  __exportStar(require("./math/margin"), exports);
72
73
  __exportStar(require("./math/insurance"), exports);
73
74
  __exportStar(require("./math/superStake"), exports);
75
+ __exportStar(require("./math/spotPosition"), exports);
74
76
  __exportStar(require("./marinade"), exports);
75
77
  __exportStar(require("./orderParams"), exports);
76
78
  __exportStar(require("./slot/SlotSubscriber"), exports);
@@ -82,6 +84,7 @@ __exportStar(require("./constants/numericConstants"), exports);
82
84
  __exportStar(require("./serum/serumSubscriber"), exports);
83
85
  __exportStar(require("./serum/serumFulfillmentConfigMap"), exports);
84
86
  __exportStar(require("./phoenix/phoenixSubscriber"), exports);
87
+ __exportStar(require("./priorityFee/priorityFeeSubscriber"), exports);
85
88
  __exportStar(require("./phoenix/phoenixFulfillmentConfigMap"), exports);
86
89
  __exportStar(require("./tx/fastSingleTxSender"), exports);
87
90
  __exportStar(require("./tx/retryTxSender"), exports);