@drift-labs/sdk 2.95.0-beta.0 → 2.95.0-beta.10

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.95.0-beta.0
1
+ 2.95.0-beta.10
@@ -65,10 +65,10 @@ exports.DevnetPerpMarkets = [
65
65
  symbol: 'MATIC-PERP',
66
66
  baseAssetSymbol: 'MATIC',
67
67
  marketIndex: 5,
68
- oracle: new web3_js_1.PublicKey('5Wf1WrXLeNJghU8WRo5odvwAjpjSSF4THbjdxbKmwVsi'),
68
+ oracle: new web3_js_1.PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
69
69
  launchTs: 1677690149000,
70
70
  oracleSource: __1.OracleSource.PYTH_PULL,
71
- pythFeedId: '0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52',
71
+ pythFeedId: '0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472',
72
72
  },
73
73
  {
74
74
  fullName: 'Arbitrum',
@@ -373,10 +373,10 @@ exports.MainnetPerpMarkets = [
373
373
  symbol: 'MATIC-PERP',
374
374
  baseAssetSymbol: 'MATIC',
375
375
  marketIndex: 5,
376
- oracle: new web3_js_1.PublicKey('5Wf1WrXLeNJghU8WRo5odvwAjpjSSF4THbjdxbKmwVsi'),
376
+ oracle: new web3_js_1.PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
377
377
  launchTs: 1677690149000,
378
378
  oracleSource: __1.OracleSource.PYTH_PULL,
379
- pythFeedId: '0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52',
379
+ pythFeedId: '0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472',
380
380
  },
381
381
  {
382
382
  fullName: 'Arbitrum',
@@ -757,6 +757,27 @@ exports.MainnetPerpMarkets = [
757
757
  launchTs: 1724250126000,
758
758
  oracleSource: __1.OracleSource.Prelaunch,
759
759
  },
760
+ {
761
+ fullName: 'DEMOCRATS-WIN-MICHIGAN-BET',
762
+ category: ['Prediction', 'Election'],
763
+ symbol: 'DEMOCRATS-WIN-MICHIGAN-BET',
764
+ baseAssetSymbol: 'DEMOCRATS-WIN-MICHIGAN',
765
+ marketIndex: 41,
766
+ oracle: new web3_js_1.PublicKey('8HTDLjhb2esGU5mu11v3pq3eWeFqmvKPkQNCnTTwKAyB'),
767
+ launchTs: 1725551484000,
768
+ oracleSource: __1.OracleSource.Prelaunch,
769
+ },
770
+ {
771
+ fullName: 'TON',
772
+ category: ['L1'],
773
+ symbol: 'TON-PERP',
774
+ baseAssetSymbol: 'TON',
775
+ marketIndex: 42,
776
+ oracle: new web3_js_1.PublicKey('BNjCXrpEqjdBnuRy2SAUgm5Pq8B73wGFwsf6RYFJiLPY'),
777
+ launchTs: 1725551484000,
778
+ oracleSource: __1.OracleSource.PYTH_PULL,
779
+ pythFeedId: '0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026',
780
+ },
760
781
  ];
761
782
  exports.PerpMarkets = {
762
783
  devnet: exports.DevnetPerpMarkets,
@@ -1,2 +1,6 @@
1
1
  import { Program, Event } from '@coral-xyz/anchor';
2
2
  export declare function parseLogs(program: Program, logs: string[], programId?: string): Event[];
3
+ export declare function parseLogsWithRaw(program: Program, logs: string[], programId?: string): {
4
+ events: Event[];
5
+ rawLogs: string[];
6
+ };
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseLogs = void 0;
3
+ exports.parseLogsWithRaw = exports.parseLogs = void 0;
4
4
  const driftProgramId = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH';
5
5
  const PROGRAM_LOG = 'Program log: ';
6
6
  const PROGRAM_DATA = 'Program data: ';
7
7
  const PROGRAM_LOG_START_INDEX = PROGRAM_LOG.length;
8
8
  const PROGRAM_DATA_START_INDEX = PROGRAM_DATA.length;
9
9
  function parseLogs(program, logs, programId = driftProgramId) {
10
+ const { events } = parseLogsWithRaw(program, logs, programId);
11
+ return events;
12
+ }
13
+ exports.parseLogs = parseLogs;
14
+ function parseLogsWithRaw(program, logs, programId = driftProgramId) {
10
15
  const events = [];
16
+ const rawLogs = [];
11
17
  const execution = new ExecutionContext();
12
18
  for (const log of logs) {
13
19
  if (log.startsWith('Log truncated')) {
@@ -16,6 +22,7 @@ function parseLogs(program, logs, programId = driftProgramId) {
16
22
  const [event, newProgram, didPop] = handleLog(execution, log, program, programId);
17
23
  if (event) {
18
24
  events.push(event);
25
+ rawLogs.push(log);
19
26
  }
20
27
  if (newProgram) {
21
28
  execution.push(newProgram);
@@ -24,9 +31,9 @@ function parseLogs(program, logs, programId = driftProgramId) {
24
31
  execution.pop();
25
32
  }
26
33
  }
27
- return events;
34
+ return { events, rawLogs };
28
35
  }
29
- exports.parseLogs = parseLogs;
36
+ exports.parseLogsWithRaw = parseLogsWithRaw;
30
37
  function handleLog(execution, log, program, programId = driftProgramId) {
31
38
  // Executing program is drift program.
32
39
  if (execution.stack.length > 0 && execution.program() === programId) {
@@ -6,12 +6,16 @@ export declare function isFallbackAvailableLiquiditySource(order: Order, minAuct
6
6
  export declare function getAuctionPrice(order: Order, slot: number, oraclePrice: BN): BN;
7
7
  export declare function getAuctionPriceForFixedAuction(order: Order, slot: number): BN;
8
8
  export declare function getAuctionPriceForOracleOffsetAuction(order: Order, slot: number, oraclePrice: BN): BN;
9
- export declare function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, }: {
9
+ export declare function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, auctionPriceCaps, }: {
10
10
  direction: PositionDirection;
11
11
  oraclePrice: BN;
12
12
  auctionStartPrice: BN;
13
13
  auctionEndPrice: BN;
14
14
  limitPrice: BN;
15
+ auctionPriceCaps?: {
16
+ min: BN;
17
+ max: BN;
18
+ };
15
19
  }): {
16
20
  auctionStartPrice: BN;
17
21
  auctionEndPrice: BN;
@@ -94,7 +94,7 @@ function getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice) {
94
94
  return _1.BN.max(oraclePrice.add(priceOffset), _1.ONE);
95
95
  }
96
96
  exports.getAuctionPriceForOracleOffsetAuction = getAuctionPriceForOracleOffsetAuction;
97
- function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, }) {
97
+ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice, auctionEndPrice, limitPrice, auctionPriceCaps, }) {
98
98
  let oraclePriceOffset;
99
99
  if (limitPrice.eq(_1.ZERO) || oraclePrice.eq(_1.ZERO)) {
100
100
  oraclePriceOffset = _1.ZERO;
@@ -114,6 +114,10 @@ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice,
114
114
  catch (e) {
115
115
  oraclePriceOffsetNum = 0;
116
116
  }
117
+ if (auctionPriceCaps) {
118
+ auctionStartPrice = _1.BN.min(_1.BN.max(auctionStartPrice, auctionPriceCaps.min), auctionPriceCaps.max);
119
+ auctionEndPrice = _1.BN.min(_1.BN.max(auctionEndPrice, auctionPriceCaps.min), auctionPriceCaps.max);
120
+ }
117
121
  return {
118
122
  auctionStartPrice: auctionStartPrice.sub(oraclePrice),
119
123
  auctionEndPrice: auctionEndPrice.sub(oraclePrice),
@@ -16,8 +16,7 @@ const DEFAULT_TIMEOUT = 35000;
16
16
  const DEFAULT_TX_LAND_RATE_LOOKBACK_WINDOW_MINUTES = 10;
17
17
  const NOT_CONFIRMED_ERROR_CODE = -1001;
18
18
  class BaseTxSender {
19
- constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, additionalConnections = new Array(), confirmationStrategy = types_1.ConfirmationStrategy.Combo, additionalTxSenderCallbacks, trackTxLandRate, txHandler, txLandRateLookbackWindowMinutes = DEFAULT_TX_LAND_RATE_LOOKBACK_WINDOW_MINUTES *
20
- 60, landRateToFeeFunc, }) {
19
+ constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, additionalConnections = new Array(), confirmationStrategy = types_1.ConfirmationStrategy.Combo, additionalTxSenderCallbacks, trackTxLandRate, txHandler, txLandRateLookbackWindowMinutes = DEFAULT_TX_LAND_RATE_LOOKBACK_WINDOW_MINUTES, landRateToFeeFunc, }) {
21
20
  this.timeoutCount = 0;
22
21
  this.txLandRate = 0;
23
22
  this.lastPriorityFeeSuggestion = 1;
package/lib/types.d.ts CHANGED
@@ -286,6 +286,9 @@ export declare class OrderActionExplanation {
286
286
  static readonly ORDER_FILLED_WITH_SERUM: {
287
287
  orderFillWithSerum: {};
288
288
  };
289
+ static readonly ORDER_FILLED_WITH_OPENBOOK_V2: {
290
+ orderFilledWithOpenbookV2: {};
291
+ };
289
292
  static readonly ORDER_FILLED_WITH_PHOENIX: {
290
293
  orderFillWithPhoenix: {};
291
294
  };
package/lib/types.js CHANGED
@@ -188,6 +188,9 @@ OrderActionExplanation.RISK_INCREASING_ORDER = {
188
188
  OrderActionExplanation.ORDER_FILLED_WITH_SERUM = {
189
189
  orderFillWithSerum: {},
190
190
  };
191
+ OrderActionExplanation.ORDER_FILLED_WITH_OPENBOOK_V2 = {
192
+ orderFilledWithOpenbookV2: {},
193
+ };
191
194
  OrderActionExplanation.ORDER_FILLED_WITH_PHOENIX = {
192
195
  orderFillWithPhoenix: {},
193
196
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.95.0-beta.0",
3
+ "version": "2.95.0-beta.10",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -81,11 +81,11 @@ export const DevnetPerpMarkets: PerpMarketConfig[] = [
81
81
  symbol: 'MATIC-PERP',
82
82
  baseAssetSymbol: 'MATIC',
83
83
  marketIndex: 5,
84
- oracle: new PublicKey('5Wf1WrXLeNJghU8WRo5odvwAjpjSSF4THbjdxbKmwVsi'),
84
+ oracle: new PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
85
85
  launchTs: 1677690149000, //todo
86
86
  oracleSource: OracleSource.PYTH_PULL,
87
87
  pythFeedId:
88
- '0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52',
88
+ '0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472',
89
89
  },
90
90
  {
91
91
  fullName: 'Arbitrum',
@@ -416,11 +416,11 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
416
416
  symbol: 'MATIC-PERP',
417
417
  baseAssetSymbol: 'MATIC',
418
418
  marketIndex: 5,
419
- oracle: new PublicKey('5Wf1WrXLeNJghU8WRo5odvwAjpjSSF4THbjdxbKmwVsi'),
419
+ oracle: new PublicKey('BrzyDgwELy4jjjsqLQpBeUxzrsueYyMhuWpYBaUYcXvi'),
420
420
  launchTs: 1677690149000, //todo
421
421
  oracleSource: OracleSource.PYTH_PULL,
422
422
  pythFeedId:
423
- '0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52',
423
+ '0xffd11c5a1cfd42f80afb2df4d9f264c15f956d68153335374ec10722edd70472',
424
424
  },
425
425
  {
426
426
  fullName: 'Arbitrum',
@@ -830,6 +830,28 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
830
830
  launchTs: 1724250126000,
831
831
  oracleSource: OracleSource.Prelaunch,
832
832
  },
833
+ {
834
+ fullName: 'DEMOCRATS-WIN-MICHIGAN-BET',
835
+ category: ['Prediction', 'Election'],
836
+ symbol: 'DEMOCRATS-WIN-MICHIGAN-BET',
837
+ baseAssetSymbol: 'DEMOCRATS-WIN-MICHIGAN',
838
+ marketIndex: 41,
839
+ oracle: new PublicKey('8HTDLjhb2esGU5mu11v3pq3eWeFqmvKPkQNCnTTwKAyB'),
840
+ launchTs: 1725551484000,
841
+ oracleSource: OracleSource.Prelaunch,
842
+ },
843
+ {
844
+ fullName: 'TON',
845
+ category: ['L1'],
846
+ symbol: 'TON-PERP',
847
+ baseAssetSymbol: 'TON',
848
+ marketIndex: 42,
849
+ oracle: new PublicKey('BNjCXrpEqjdBnuRy2SAUgm5Pq8B73wGFwsf6RYFJiLPY'),
850
+ launchTs: 1725551484000,
851
+ oracleSource: OracleSource.PYTH_PULL,
852
+ pythFeedId:
853
+ '0x8963217838ab4cf5cadc172203c1f0b763fbaa45f346d8ee50ba994bbcac3026',
854
+ },
833
855
  ];
834
856
 
835
857
  export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
@@ -11,7 +11,17 @@ export function parseLogs(
11
11
  logs: string[],
12
12
  programId = driftProgramId
13
13
  ): Event[] {
14
+ const { events } = parseLogsWithRaw(program, logs, programId);
15
+ return events;
16
+ }
17
+
18
+ export function parseLogsWithRaw(
19
+ program: Program,
20
+ logs: string[],
21
+ programId = driftProgramId
22
+ ): { events: Event[]; rawLogs: string[] } {
14
23
  const events = [];
24
+ const rawLogs = [];
15
25
  const execution = new ExecutionContext();
16
26
  for (const log of logs) {
17
27
  if (log.startsWith('Log truncated')) {
@@ -26,6 +36,7 @@ export function parseLogs(
26
36
  );
27
37
  if (event) {
28
38
  events.push(event);
39
+ rawLogs.push(log);
29
40
  }
30
41
  if (newProgram) {
31
42
  execution.push(newProgram);
@@ -34,7 +45,7 @@ export function parseLogs(
34
45
  execution.pop();
35
46
  }
36
47
  }
37
- return events;
48
+ return { events, rawLogs };
38
49
  }
39
50
 
40
51
  function handleLog(
@@ -120,12 +120,17 @@ export function deriveOracleAuctionParams({
120
120
  auctionStartPrice,
121
121
  auctionEndPrice,
122
122
  limitPrice,
123
+ auctionPriceCaps,
123
124
  }: {
124
125
  direction: PositionDirection;
125
126
  oraclePrice: BN;
126
127
  auctionStartPrice: BN;
127
128
  auctionEndPrice: BN;
128
129
  limitPrice: BN;
130
+ auctionPriceCaps?: {
131
+ min: BN;
132
+ max: BN;
133
+ };
129
134
  }): { auctionStartPrice: BN; auctionEndPrice: BN; oraclePriceOffset: number } {
130
135
  let oraclePriceOffset;
131
136
 
@@ -148,6 +153,17 @@ export function deriveOracleAuctionParams({
148
153
  oraclePriceOffsetNum = 0;
149
154
  }
150
155
 
156
+ if (auctionPriceCaps) {
157
+ auctionStartPrice = BN.min(
158
+ BN.max(auctionStartPrice, auctionPriceCaps.min),
159
+ auctionPriceCaps.max
160
+ );
161
+ auctionEndPrice = BN.min(
162
+ BN.max(auctionEndPrice, auctionPriceCaps.min),
163
+ auctionPriceCaps.max
164
+ );
165
+ }
166
+
151
167
  return {
152
168
  auctionStartPrice: auctionStartPrice.sub(oraclePrice),
153
169
  auctionEndPrice: auctionEndPrice.sub(oraclePrice),
@@ -61,8 +61,7 @@ export abstract class BaseTxSender implements TxSender {
61
61
  additionalTxSenderCallbacks,
62
62
  trackTxLandRate,
63
63
  txHandler,
64
- txLandRateLookbackWindowMinutes = DEFAULT_TX_LAND_RATE_LOOKBACK_WINDOW_MINUTES *
65
- 60,
64
+ txLandRateLookbackWindowMinutes = DEFAULT_TX_LAND_RATE_LOOKBACK_WINDOW_MINUTES,
66
65
  landRateToFeeFunc,
67
66
  }: {
68
67
  connection: Connection;
package/src/types.ts CHANGED
@@ -192,6 +192,9 @@ export class OrderActionExplanation {
192
192
  static readonly ORDER_FILLED_WITH_SERUM = {
193
193
  orderFillWithSerum: {},
194
194
  };
195
+ static readonly ORDER_FILLED_WITH_OPENBOOK_V2 = {
196
+ orderFilledWithOpenbookV2: {},
197
+ };
195
198
  static readonly ORDER_FILLED_WITH_PHOENIX = {
196
199
  orderFillWithPhoenix: {},
197
200
  };