@drift-labs/sdk 2.23.0-beta.0 → 2.23.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.
@@ -9,8 +9,8 @@ exports.DevnetSpotMarkets = [
9
9
  {
10
10
  symbol: 'USDC',
11
11
  marketIndex: 0,
12
- oracle: web3_js_1.PublicKey.default,
13
- oracleSource: __1.OracleSource.QUOTE_ASSET,
12
+ oracle: new web3_js_1.PublicKey('5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7'),
13
+ oracleSource: __1.OracleSource.PYTH_STABLE_COIN,
14
14
  mint: new web3_js_1.PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
15
15
  precision: new __1.BN(10).pow(numericConstants_1.SIX),
16
16
  precisionExp: numericConstants_1.SIX,
@@ -40,8 +40,8 @@ exports.MainnetSpotMarkets = [
40
40
  {
41
41
  symbol: 'USDC',
42
42
  marketIndex: 0,
43
- oracle: web3_js_1.PublicKey.default,
44
- oracleSource: __1.OracleSource.QUOTE_ASSET,
43
+ oracle: new web3_js_1.PublicKey('Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD'),
44
+ oracleSource: __1.OracleSource.PYTH_STABLE_COIN,
45
45
  mint: new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
46
46
  precision: numericConstants_1.QUOTE_PRECISION,
47
47
  precisionExp: numericConstants_1.QUOTE_PRECISION_EXP,
@@ -246,6 +246,7 @@ class DriftClient {
246
246
  if (!this.marketLookupTable) {
247
247
  throw Error('Market lookup table address not set');
248
248
  }
249
+ // @ts-ignore
249
250
  return (await this.connection.getAddressLookupTable(this.marketLookupTable))
250
251
  .value;
251
252
  }
@@ -800,7 +801,9 @@ class DriftClient {
800
801
  }
801
802
  async deposit(amount, marketIndex, collateralAccountPublicKey, subAccountId, reduceOnly = false) {
802
803
  const tx = new web3_js_1.Transaction();
803
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
804
+ tx.add(
805
+ // @ts-ignore
806
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
804
807
  units: 600000,
805
808
  }));
806
809
  const additionalSigners = [];
@@ -913,11 +916,15 @@ class DriftClient {
913
916
  const spotMarket = this.getSpotMarketAccount(marketIndex);
914
917
  const isSolMarket = spotMarket.mint.equals(spotMarkets_1.WRAPPED_SOL_MINT);
915
918
  const tx = new web3_js_1.Transaction();
916
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
919
+ tx.add(
920
+ // @ts-ignore
921
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
917
922
  units: (_a = txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits) !== null && _a !== void 0 ? _a : 600000,
918
923
  }));
919
924
  if (txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice) {
920
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
925
+ tx.add(
926
+ // @ts-ignore
927
+ web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
921
928
  microLamports: txParams.computeUnitsPrice,
922
929
  }));
923
930
  }
@@ -964,7 +971,9 @@ class DriftClient {
964
971
  }
965
972
  async withdraw(amount, marketIndex, userTokenAccount, reduceOnly = false) {
966
973
  const tx = new web3_js_1.Transaction();
967
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
974
+ tx.add(
975
+ // @ts-ignore
976
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
968
977
  units: 600000,
969
978
  }));
970
979
  const additionalSigners = [];
@@ -2039,7 +2048,9 @@ class DriftClient {
2039
2048
  ? await this.getPlaceSpotOrderIx(newOrderParams)
2040
2049
  : await this.getPlacePerpOrderIx(newOrderParams);
2041
2050
  const tx = new web3_js_1.Transaction();
2042
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2051
+ tx.add(
2052
+ // @ts-ignore
2053
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2043
2054
  units: 1000000,
2044
2055
  }));
2045
2056
  tx.add(cancelOrderIx);
@@ -2114,7 +2125,9 @@ class DriftClient {
2114
2125
  ? await this.getPlaceSpotOrderIx(newOrderParams)
2115
2126
  : await this.getPlacePerpOrderIx(newOrderParams);
2116
2127
  const tx = new web3_js_1.Transaction();
2117
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2128
+ tx.add(
2129
+ // @ts-ignore
2130
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2118
2131
  units: 1000000,
2119
2132
  }));
2120
2133
  tx.add(cancelOrderIx);
@@ -2137,7 +2150,9 @@ class DriftClient {
2137
2150
  }
2138
2151
  }
2139
2152
  const tx = new web3_js_1.Transaction()
2140
- .add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2153
+ .add(
2154
+ // @ts-ignore
2155
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2141
2156
  units: 1000000,
2142
2157
  }))
2143
2158
  .add(...ixs);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.23.0-beta.0",
2
+ "version": "2.23.0-beta.1",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/lib/tx/utils.js CHANGED
@@ -6,12 +6,16 @@ const COMPUTE_UNITS_DEFAULT = 200000;
6
6
  function wrapInTx(instruction, computeUnits = 600000, computeUnitsPrice = 0) {
7
7
  const tx = new web3_js_1.Transaction();
8
8
  if (computeUnits != COMPUTE_UNITS_DEFAULT) {
9
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
9
+ tx.add(
10
+ // @ts-ignore
11
+ web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
10
12
  units: computeUnits,
11
13
  }));
12
14
  }
13
15
  if (computeUnitsPrice != 0) {
14
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
16
+ tx.add(
17
+ // @ts-ignore
18
+ web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
15
19
  microLamports: computeUnitsPrice,
16
20
  }));
17
21
  }
package/lib/user.js CHANGED
@@ -1236,7 +1236,8 @@ class User {
1236
1236
  return false;
1237
1237
  }
1238
1238
  const userLastActiveSlot = userAccount.lastActiveSlot;
1239
- if (userLastActiveSlot.lt(slotsBeforeIdle)) {
1239
+ const slotsSinceLastActive = slot.sub(userLastActiveSlot);
1240
+ if (slotsSinceLastActive.lt(slotsBeforeIdle)) {
1240
1241
  return false;
1241
1242
  }
1242
1243
  if (this.isBeingLiquidated()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.23.0-beta.0",
3
+ "version": "2.23.0-beta.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -27,8 +27,8 @@ export const DevnetSpotMarkets: SpotMarketConfig[] = [
27
27
  {
28
28
  symbol: 'USDC',
29
29
  marketIndex: 0,
30
- oracle: PublicKey.default,
31
- oracleSource: OracleSource.QUOTE_ASSET,
30
+ oracle: new PublicKey('5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7'),
31
+ oracleSource: OracleSource.PYTH_STABLE_COIN,
32
32
  mint: new PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
33
33
  precision: new BN(10).pow(SIX),
34
34
  precisionExp: SIX,
@@ -59,8 +59,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
59
59
  {
60
60
  symbol: 'USDC',
61
61
  marketIndex: 0,
62
- oracle: PublicKey.default,
63
- oracleSource: OracleSource.QUOTE_ASSET,
62
+ oracle: new PublicKey('Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD'),
63
+ oracleSource: OracleSource.PYTH_STABLE_COIN,
64
64
  mint: new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
65
65
  precision: QUOTE_PRECISION,
66
66
  precisionExp: QUOTE_PRECISION_EXP,
@@ -418,6 +418,7 @@ export class DriftClient {
418
418
  throw Error('Market lookup table address not set');
419
419
  }
420
420
 
421
+ // @ts-ignore
421
422
  return (await this.connection.getAddressLookupTable(this.marketLookupTable))
422
423
  .value;
423
424
  }
@@ -1232,6 +1233,7 @@ export class DriftClient {
1232
1233
  ): Promise<TransactionSignature> {
1233
1234
  const tx = new Transaction();
1234
1235
  tx.add(
1236
+ // @ts-ignore
1235
1237
  ComputeBudgetProgram.setComputeUnitLimit({
1236
1238
  units: 600_000,
1237
1239
  })
@@ -1457,6 +1459,7 @@ export class DriftClient {
1457
1459
  const tx = new Transaction();
1458
1460
 
1459
1461
  tx.add(
1462
+ // @ts-ignore
1460
1463
  ComputeBudgetProgram.setComputeUnitLimit({
1461
1464
  units: txParams?.computeUnits ?? 600_000,
1462
1465
  })
@@ -1464,6 +1467,7 @@ export class DriftClient {
1464
1467
 
1465
1468
  if (txParams?.computeUnitsPrice) {
1466
1469
  tx.add(
1470
+ // @ts-ignore
1467
1471
  ComputeBudgetProgram.setComputeUnitPrice({
1468
1472
  microLamports: txParams.computeUnitsPrice,
1469
1473
  })
@@ -1594,6 +1598,7 @@ export class DriftClient {
1594
1598
  ): Promise<TransactionSignature> {
1595
1599
  const tx = new Transaction();
1596
1600
  tx.add(
1601
+ // @ts-ignore
1597
1602
  ComputeBudgetProgram.setComputeUnitLimit({
1598
1603
  units: 600_000,
1599
1604
  })
@@ -3453,6 +3458,7 @@ export class DriftClient {
3453
3458
 
3454
3459
  const tx = new Transaction();
3455
3460
  tx.add(
3461
+ // @ts-ignore
3456
3462
  ComputeBudgetProgram.setComputeUnitLimit({
3457
3463
  units: 1_000_000,
3458
3464
  })
@@ -3564,6 +3570,7 @@ export class DriftClient {
3564
3570
 
3565
3571
  const tx = new Transaction();
3566
3572
  tx.add(
3573
+ // @ts-ignore
3567
3574
  ComputeBudgetProgram.setComputeUnitLimit({
3568
3575
  units: 1_000_000,
3569
3576
  })
@@ -3604,6 +3611,7 @@ export class DriftClient {
3604
3611
 
3605
3612
  const tx = new Transaction()
3606
3613
  .add(
3614
+ // @ts-ignore
3607
3615
  ComputeBudgetProgram.setComputeUnitLimit({
3608
3616
  units: 1_000_000,
3609
3617
  })
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.23.0-beta.0",
2
+ "version": "2.23.0-beta.1",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/src/tx/utils.ts CHANGED
@@ -14,6 +14,7 @@ export function wrapInTx(
14
14
  const tx = new Transaction();
15
15
  if (computeUnits != COMPUTE_UNITS_DEFAULT) {
16
16
  tx.add(
17
+ // @ts-ignore
17
18
  ComputeBudgetProgram.setComputeUnitLimit({
18
19
  units: computeUnits,
19
20
  })
@@ -22,6 +23,7 @@ export function wrapInTx(
22
23
 
23
24
  if (computeUnitsPrice != 0) {
24
25
  tx.add(
26
+ // @ts-ignore
25
27
  ComputeBudgetProgram.setComputeUnitPrice({
26
28
  microLamports: computeUnitsPrice,
27
29
  })
package/src/user.ts CHANGED
@@ -2237,7 +2237,8 @@ export class User {
2237
2237
  }
2238
2238
 
2239
2239
  const userLastActiveSlot = userAccount.lastActiveSlot;
2240
- if (userLastActiveSlot.lt(slotsBeforeIdle)) {
2240
+ const slotsSinceLastActive = slot.sub(userLastActiveSlot);
2241
+ if (slotsSinceLastActive.lt(slotsBeforeIdle)) {
2241
2242
  return false;
2242
2243
  }
2243
2244