@velocity-exchange/sdk 0.0.2 → 0.0.3

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 (161) hide show
  1. package/README.md +5 -6
  2. package/bunfig.toml +3 -0
  3. package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +4 -2
  4. package/lib/browser/auctionSubscriber/auctionSubscriber.js +9 -4
  5. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
  6. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  7. package/lib/browser/auctionSubscriber/types.d.ts +4 -2
  8. package/lib/browser/config.d.ts +3 -8
  9. package/lib/browser/config.js +14 -22
  10. package/lib/browser/constituentMap/constituentMap.d.ts +4 -2
  11. package/lib/browser/constituentMap/constituentMap.js +14 -10
  12. package/lib/browser/core/VelocityCore.d.ts +4 -0
  13. package/lib/browser/core/VelocityCore.js +3 -1
  14. package/lib/browser/dlob/DLOBSubscriber.d.ts +3 -1
  15. package/lib/browser/dlob/DLOBSubscriber.js +19 -10
  16. package/lib/browser/dlob/types.d.ts +3 -1
  17. package/lib/browser/idl/drift.d.ts +54 -1
  18. package/lib/browser/idl/drift.json +6046 -803
  19. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -1
  20. package/lib/browser/orderSubscriber/OrderSubscriber.js +19 -11
  21. package/lib/browser/orderSubscriber/types.d.ts +3 -1
  22. package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +4 -2
  23. package/lib/browser/priorityFee/priorityFeeSubscriber.js +15 -11
  24. package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
  25. package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +18 -18
  26. package/lib/browser/priorityFee/types.d.ts +9 -5
  27. package/lib/browser/priorityFee/types.js +1 -1
  28. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
  29. package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
  30. package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
  31. package/lib/browser/swift/signedMsgUserAccountSubscriber.js +10 -5
  32. package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -4
  33. package/lib/browser/swift/swiftOrderSubscriber.js +19 -11
  34. package/lib/browser/user.d.ts +3 -1
  35. package/lib/browser/user.js +93 -86
  36. package/lib/browser/userConfig.d.ts +4 -2
  37. package/lib/browser/userMap/referrerMap.d.ts +5 -3
  38. package/lib/browser/userMap/referrerMap.js +18 -14
  39. package/lib/browser/userMap/revenueShareEscrowMap.d.ts +5 -3
  40. package/lib/browser/userMap/revenueShareEscrowMap.js +18 -14
  41. package/lib/browser/userMap/userMap.d.ts +3 -1
  42. package/lib/browser/userMap/userMap.js +24 -19
  43. package/lib/browser/userMap/userMapConfig.d.ts +4 -2
  44. package/lib/browser/userMap/userStatsMap.d.ts +5 -3
  45. package/lib/browser/userMap/userStatsMap.js +15 -11
  46. package/lib/browser/userStats.d.ts +3 -1
  47. package/lib/browser/userStats.js +21 -15
  48. package/lib/browser/userStatsConfig.d.ts +4 -2
  49. package/lib/browser/util/deprecatedAlias.d.ts +26 -0
  50. package/lib/browser/util/deprecatedAlias.js +10 -0
  51. package/lib/browser/velocityClient.js +5 -5
  52. package/lib/browser/velocityClientConfig.d.ts +7 -4
  53. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +4 -2
  54. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
  55. package/lib/node/auctionSubscriber/auctionSubscriber.js +9 -4
  56. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
  57. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
  58. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
  59. package/lib/node/auctionSubscriber/types.d.ts +4 -2
  60. package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
  61. package/lib/node/config.d.ts +3 -8
  62. package/lib/node/config.d.ts.map +1 -1
  63. package/lib/node/config.js +14 -22
  64. package/lib/node/constituentMap/constituentMap.d.ts +4 -2
  65. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
  66. package/lib/node/constituentMap/constituentMap.js +14 -10
  67. package/lib/node/core/VelocityCore.d.ts +4 -0
  68. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  69. package/lib/node/core/VelocityCore.js +3 -1
  70. package/lib/node/dlob/DLOBSubscriber.d.ts +3 -1
  71. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  72. package/lib/node/dlob/DLOBSubscriber.js +19 -10
  73. package/lib/node/dlob/types.d.ts +3 -1
  74. package/lib/node/dlob/types.d.ts.map +1 -1
  75. package/lib/node/idl/drift.d.ts +54 -1
  76. package/lib/node/idl/drift.d.ts.map +1 -1
  77. package/lib/node/idl/drift.json +6046 -803
  78. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +3 -1
  79. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
  80. package/lib/node/orderSubscriber/OrderSubscriber.js +19 -11
  81. package/lib/node/orderSubscriber/types.d.ts +3 -1
  82. package/lib/node/orderSubscriber/types.d.ts.map +1 -1
  83. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +4 -2
  84. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
  85. package/lib/node/priorityFee/priorityFeeSubscriber.js +15 -11
  86. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
  87. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
  88. package/lib/node/priorityFee/priorityFeeSubscriberMap.js +18 -18
  89. package/lib/node/priorityFee/types.d.ts +9 -5
  90. package/lib/node/priorityFee/types.d.ts.map +1 -1
  91. package/lib/node/priorityFee/types.js +1 -1
  92. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
  93. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
  94. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
  95. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
  96. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
  97. package/lib/node/swift/signedMsgUserAccountSubscriber.js +10 -5
  98. package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -4
  99. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
  100. package/lib/node/swift/swiftOrderSubscriber.js +19 -11
  101. package/lib/node/user.d.ts +3 -1
  102. package/lib/node/user.d.ts.map +1 -1
  103. package/lib/node/user.js +93 -86
  104. package/lib/node/userConfig.d.ts +4 -2
  105. package/lib/node/userConfig.d.ts.map +1 -1
  106. package/lib/node/userMap/referrerMap.d.ts +5 -3
  107. package/lib/node/userMap/referrerMap.d.ts.map +1 -1
  108. package/lib/node/userMap/referrerMap.js +18 -14
  109. package/lib/node/userMap/revenueShareEscrowMap.d.ts +5 -3
  110. package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
  111. package/lib/node/userMap/revenueShareEscrowMap.js +18 -14
  112. package/lib/node/userMap/userMap.d.ts +3 -1
  113. package/lib/node/userMap/userMap.d.ts.map +1 -1
  114. package/lib/node/userMap/userMap.js +24 -19
  115. package/lib/node/userMap/userMapConfig.d.ts +4 -2
  116. package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
  117. package/lib/node/userMap/userStatsMap.d.ts +5 -3
  118. package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
  119. package/lib/node/userMap/userStatsMap.js +15 -11
  120. package/lib/node/userStats.d.ts +3 -1
  121. package/lib/node/userStats.d.ts.map +1 -1
  122. package/lib/node/userStats.js +21 -15
  123. package/lib/node/userStatsConfig.d.ts +4 -2
  124. package/lib/node/userStatsConfig.d.ts.map +1 -1
  125. package/lib/node/util/deprecatedAlias.d.ts +27 -0
  126. package/lib/node/util/deprecatedAlias.d.ts.map +1 -0
  127. package/lib/node/util/deprecatedAlias.js +10 -0
  128. package/lib/node/velocityClient.js +5 -5
  129. package/lib/node/velocityClientConfig.d.ts +7 -4
  130. package/lib/node/velocityClientConfig.d.ts.map +1 -1
  131. package/package.json +1 -1
  132. package/src/auctionSubscriber/auctionSubscriber.ts +12 -6
  133. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -6
  134. package/src/auctionSubscriber/types.ts +5 -2
  135. package/src/config.ts +35 -27
  136. package/src/constituentMap/constituentMap.ts +17 -9
  137. package/src/core/VelocityCore.ts +6 -0
  138. package/src/dlob/DLOBSubscriber.ts +21 -11
  139. package/src/dlob/types.ts +3 -1
  140. package/src/idl/drift.json +23940 -18697
  141. package/src/idl/drift.ts +54 -1
  142. package/src/orderSubscriber/OrderSubscriber.ts +17 -7
  143. package/src/orderSubscriber/types.ts +3 -1
  144. package/src/priorityFee/priorityFeeSubscriber.ts +13 -9
  145. package/src/priorityFee/priorityFeeSubscriberMap.ts +23 -25
  146. package/src/priorityFee/types.ts +14 -9
  147. package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +10 -23
  148. package/src/swift/signedMsgUserAccountSubscriber.ts +22 -14
  149. package/src/swift/swiftOrderSubscriber.ts +24 -16
  150. package/src/user.ts +93 -82
  151. package/src/userConfig.ts +5 -2
  152. package/src/userMap/referrerMap.ts +19 -15
  153. package/src/userMap/revenueShareEscrowMap.ts +20 -16
  154. package/src/userMap/userMap.ts +20 -15
  155. package/src/userMap/userMapConfig.ts +6 -3
  156. package/src/userMap/userStatsMap.ts +19 -15
  157. package/src/userStats.ts +13 -7
  158. package/src/userStatsConfig.ts +5 -2
  159. package/src/util/deprecatedAlias.ts +25 -0
  160. package/src/velocityClient.ts +6 -6
  161. package/src/velocityClientConfig.ts +25 -42
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <div align="center">
2
- <img height="120x" src="https://uploads-ssl.webflow.com/611580035ad59b20437eb024/616f97a42f5637c4517d0193_Logo%20(1)%20(1).png" />
2
+ <img height="120" src="https://raw.githubusercontent.com/drift-labs/protocol-v2-shadow/master/assets/velocity-logo.svg" />
3
3
 
4
- <h1 style="margin-top:20px;">Drift Protocol v2</h1>
4
+ <h1 style="margin-top:20px;">Velocity Exchange</h1>
5
5
 
6
6
  <p>
7
- <a href="https://www.npmjs.com/package/@drift-labs/sdk"><img alt="SDK npm package" src="https://img.shields.io/npm/v/@drift-labs/sdk" /></a>
7
+ <a href="https://www.npmjs.com/package/@velocity-exchange/sdk"><img alt="SDK npm package" src="https://img.shields.io/npm/v/@velocity-exchange/sdk" /></a>
8
8
  <a href="https://drift-labs.github.io/protocol-v2/sdk/"><img alt="Docs" src="https://img.shields.io/badge/docs-tutorials-blueviolet" /></a>
9
9
  <a href="https://discord.com/channels/849494028176588802/878700556904980500"><img alt="Discord Chat" src="https://img.shields.io/discord/889577356681945098?color=blueviolet" /></a>
10
10
  <a href="https://opensource.org/licenses/Apache-2.0"><img alt="License" src="https://img.shields.io/github/license/project-serum/anchor?color=blueviolet" /></a>
@@ -14,7 +14,7 @@
14
14
  ## Installation
15
15
 
16
16
  ```
17
- npm i @drift-labs/sdk
17
+ npm i @velocity-exchange/sdk
18
18
  ```
19
19
 
20
20
  ## Getting Started
@@ -75,7 +75,7 @@ The Drift SDK uses some common precisions, which are available as constants to i
75
75
  Because BN only supports integers, you need to be conscious of the numbers you are using when dividing. BN will return the floor when using the regular division function; if you want to get the exact division, you need to add the modulus of the two numbers as well. There is a helper function `convertToNumber` in the SDK which will do this for you.
76
76
 
77
77
  ```typescript
78
- import {convertToNumber} from @drift-labs/sdk
78
+ import { convertToNumber } from '@velocity-exchange/sdk';
79
79
 
80
80
  // Gets the floor value
81
81
  new BN(10500).div(new BN(1000)).toNumber(); // = 10
@@ -272,4 +272,3 @@ Drift Protocol v2 is licensed under [Apache 2.0](./LICENSE).
272
272
  Unless you explicitly state otherwise, any contribution intentionally submitted
273
273
  for inclusion in Drift SDK by you, as defined in the Apache-2.0 license, shall be
274
274
  licensed as above, without any additional terms or conditions.
275
-
package/bunfig.toml ADDED
@@ -0,0 +1,3 @@
1
+ [install]
2
+ exact = true
3
+ minimumReleaseAge = 604800 # 7 days
@@ -3,12 +3,14 @@ import { AuctionSubscriberConfig, AuctionSubscriberEvents } from './types';
3
3
  import StrictEventEmitter from 'strict-event-emitter-types';
4
4
  import { EventEmitter } from 'events';
5
5
  export declare class AuctionSubscriber {
6
- private driftClient;
6
+ private velocityClient;
7
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
+ private get driftClient();
7
9
  private opts;
8
10
  private resubOpts?;
9
11
  eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
10
12
  private subscriber;
11
- constructor({ driftClient, opts, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
13
+ constructor({ velocityClient, driftClient, opts, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
12
14
  subscribe(): Promise<void>;
13
15
  unsubscribe(): Promise<void>;
14
16
  }
@@ -5,15 +5,20 @@ const memcmp_1 = require("../memcmp");
5
5
  const events_1 = require("events");
6
6
  const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
7
7
  class AuctionSubscriber {
8
- constructor({ driftClient, opts, resubTimeoutMs, logResubMessages, }) {
9
- this.driftClient = driftClient;
10
- this.opts = opts || this.driftClient.opts;
8
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
9
+ get driftClient() {
10
+ return this.velocityClient;
11
+ }
12
+ constructor({ velocityClient, driftClient, opts, resubTimeoutMs, logResubMessages, }) {
13
+ // Type-system guarantees at least one of the two is supplied.
14
+ this.velocityClient = (velocityClient !== null && velocityClient !== void 0 ? velocityClient : driftClient);
15
+ this.opts = opts || this.velocityClient.opts;
11
16
  this.eventEmitter = new events_1.EventEmitter();
12
17
  this.resubOpts = { resubTimeoutMs, logResubMessages };
13
18
  }
14
19
  async subscribe() {
15
20
  if (!this.subscriber) {
16
- this.subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('AuctionSubscriber', 'user', this.driftClient.program, this.driftClient.program.account.user.coder.accounts.decode.bind(this.driftClient.program.account.user.coder.accounts), {
21
+ this.subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('AuctionSubscriber', 'user', this.velocityClient.program, this.velocityClient.program.account.user.coder.accounts.decode.bind(this.velocityClient.program.account.user.coder.accounts), {
17
22
  filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithAuctionFilter)()],
18
23
  commitment: this.opts.commitment,
19
24
  }, this.resubOpts);
@@ -3,13 +3,15 @@ import { AuctionSubscriberConfig, AuctionSubscriberEvents } from './types';
3
3
  import StrictEventEmitter from 'strict-event-emitter-types';
4
4
  import { EventEmitter } from 'events';
5
5
  export declare class AuctionSubscriberGrpc {
6
- private driftClient;
6
+ private velocityClient;
7
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
+ private get driftClient();
7
9
  private opts;
8
10
  private resubOpts?;
9
11
  private grpcConfigs?;
10
12
  eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
11
13
  private subscriber;
12
- constructor({ driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
14
+ constructor({ velocityClient, driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
13
15
  subscribe(): Promise<void>;
14
16
  unsubscribe(): Promise<void>;
15
17
  }
@@ -5,16 +5,21 @@ const memcmp_1 = require("../memcmp");
5
5
  const events_1 = require("events");
6
6
  const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSubscriber");
7
7
  class AuctionSubscriberGrpc {
8
- constructor({ driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }) {
9
- this.driftClient = driftClient;
10
- this.opts = opts || this.driftClient.opts;
8
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
9
+ get driftClient() {
10
+ return this.velocityClient;
11
+ }
12
+ constructor({ velocityClient, driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }) {
13
+ // Type-system guarantees at least one of the two is supplied.
14
+ this.velocityClient = (velocityClient !== null && velocityClient !== void 0 ? velocityClient : driftClient);
15
+ this.opts = opts || this.velocityClient.opts;
11
16
  this.eventEmitter = new events_1.EventEmitter();
12
17
  this.resubOpts = { resubTimeoutMs, logResubMessages };
13
18
  this.grpcConfigs = grpcConfigs;
14
19
  }
15
20
  async subscribe() {
16
21
  if (!this.subscriber) {
17
- this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'AuctionSubscriber', 'user', this.driftClient.program, this.driftClient.program.account.user.coder.accounts.decode.bind(this.driftClient.program.account.user.coder.accounts), {
22
+ this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'AuctionSubscriber', 'user', this.velocityClient.program, this.velocityClient.program.account.user.coder.accounts.decode.bind(this.velocityClient.program.account.user.coder.accounts), {
18
23
  filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithAuctionFilter)()],
19
24
  }, this.resubOpts);
20
25
  }
@@ -2,13 +2,15 @@ import { GrpcConfigs } from '../accounts/types';
2
2
  import { VelocityClient } from '../velocityClient';
3
3
  import { UserAccount } from '../types';
4
4
  import { ConfirmOptions, PublicKey } from '@solana/web3.js';
5
- export type AuctionSubscriberConfig = {
6
- driftClient: VelocityClient;
5
+ import { AtLeastOne } from '../util/deprecatedAlias';
6
+ type AuctionSubscriberConfigBase = {
7
7
  opts?: ConfirmOptions;
8
8
  resubTimeoutMs?: number;
9
9
  logResubMessages?: boolean;
10
10
  grpcConfigs?: GrpcConfigs;
11
11
  };
12
+ export type AuctionSubscriberConfig = AuctionSubscriberConfigBase & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
12
13
  export interface AuctionSubscriberEvents {
13
14
  onAccountUpdate: (account: UserAccount, pubkey: PublicKey, slot: number) => void;
14
15
  }
16
+ export {};
@@ -11,6 +11,8 @@ export type DriftProgram = VelocityProgram;
11
11
  export type VelocityEnv = 'devnet' | 'mainnet-beta';
12
12
  /** @deprecated Use `VelocityEnv` instead. `DriftEnv` will be removed in a future major. */
13
13
  export type DriftEnv = VelocityEnv;
14
+ /** Widened env type accepted by `initialize()`; `'master'` is a legacy alias for `'devnet'`. */
15
+ export type LegacyVelocityEnv = VelocityEnv | 'master';
14
16
  export interface VelocityConfig {
15
17
  ENV: VelocityEnv;
16
18
  PYTH_ORACLE_MAPPING_ADDRESS: string;
@@ -50,15 +52,8 @@ export declare const configs: {
50
52
  [key in VelocityEnv]: VelocityConfig;
51
53
  };
52
54
  export declare const getConfig: () => VelocityConfig;
53
- /**
54
- * Allows customization of the SDK's environment and endpoints. You can pass individual settings to override the settings with your own presets.
55
- *
56
- * Defaults to master environment if you don't use this function.
57
- * @param props
58
- * @returns
59
- */
60
55
  export declare const initialize: (props: {
61
- env: VelocityEnv;
56
+ env: LegacyVelocityEnv;
62
57
  overrideEnv?: Partial<VelocityConfig>;
63
58
  }) => VelocityConfig;
64
59
  export declare function getMarketsAndOraclesForSubscription(env: VelocityEnv, perpMarkets?: PerpMarketConfig[], spotMarkets?: SpotMarketConfig[]): {
@@ -75,31 +75,23 @@ exports.getConfig = getConfig;
75
75
  * @param props
76
76
  * @returns
77
77
  */
78
+ /**
79
+ * Mirror a canonical/deprecated alias pair so the resolved config carries the
80
+ * same value under both keys regardless of which one the caller overrode.
81
+ */
82
+ const mirrorAlias = (merged, override, canon, deprecated) => {
83
+ var _a, _b;
84
+ const value = (_b = (_a = override[canon]) !== null && _a !== void 0 ? _a : override[deprecated]) !== null && _b !== void 0 ? _b : merged[canon];
85
+ merged[canon] = value;
86
+ merged[deprecated] = value;
87
+ };
78
88
  const initialize = (props) => {
79
89
  var _a;
80
90
  const override = (_a = props.overrideEnv) !== null && _a !== void 0 ? _a : {};
81
- //@ts-ignore
82
- const base = props.env === 'master' ? exports.configs['devnet'] : exports.configs[props.env];
83
- const merged = { ...base, ...override };
84
- const overrodeVelocity = 'VELOCITY_PROGRAM_ID' in override;
85
- const overrodeDrift = 'DRIFT_PROGRAM_ID' in override;
86
- if (overrodeVelocity && !overrodeDrift) {
87
- merged.DRIFT_PROGRAM_ID = merged.VELOCITY_PROGRAM_ID;
88
- }
89
- else if (overrodeDrift && !overrodeVelocity) {
90
- merged.VELOCITY_PROGRAM_ID = merged.DRIFT_PROGRAM_ID;
91
- }
92
- const overrodeVelocityOracleReceiver = 'VELOCITY_ORACLE_RECEIVER_ID' in override;
93
- const overrodeDriftOracleReceiver = 'DRIFT_ORACLE_RECEIVER_ID' in override;
94
- if (overrodeVelocityOracleReceiver && !overrodeDriftOracleReceiver) {
95
- merged.DRIFT_ORACLE_RECEIVER_ID = merged.VELOCITY_ORACLE_RECEIVER_ID;
96
- }
97
- else if (overrodeDriftOracleReceiver && !overrodeVelocityOracleReceiver) {
98
- merged.VELOCITY_ORACLE_RECEIVER_ID = merged.DRIFT_ORACLE_RECEIVER_ID;
99
- }
100
- //@ts-ignore
101
- if (props.env === 'master')
102
- return merged;
91
+ const normalizedEnv = props.env === 'master' ? 'devnet' : props.env;
92
+ const merged = { ...exports.configs[normalizedEnv], ...override };
93
+ mirrorAlias(merged, override, 'VELOCITY_PROGRAM_ID', 'DRIFT_PROGRAM_ID');
94
+ mirrorAlias(merged, override, 'VELOCITY_ORACLE_RECEIVER_ID', 'DRIFT_ORACLE_RECEIVER_ID');
103
95
  currentConfig = merged;
104
96
  return currentConfig;
105
97
  };
@@ -3,7 +3,9 @@ import { DataAndSlot } from '../accounts/types';
3
3
  import { ConstituentAccount } from '../types';
4
4
  import { VelocityClient } from '../velocityClient';
5
5
  export type ConstituentMapConfig = {
6
- driftClient: VelocityClient;
6
+ velocityClient?: VelocityClient;
7
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
8
+ driftClient?: VelocityClient;
7
9
  connection?: Connection;
8
10
  subscriptionConfig: {
9
11
  type: 'polling';
@@ -31,7 +33,7 @@ export interface ConstituentMapInterface {
31
33
  mustGetWithSlot(key: string): Promise<DataAndSlot<ConstituentAccount>>;
32
34
  }
33
35
  export declare class ConstituentMap implements ConstituentMapInterface {
34
- private driftClient;
36
+ private velocityClient;
35
37
  private constituentMap;
36
38
  private constituentAccountSubscriber;
37
39
  private additionalFilters?;
@@ -9,23 +9,27 @@ const pda_1 = require("../addresses/pda");
9
9
  const MAX_CONSTITUENT_SIZE_BYTES = 480; // TODO: update this when account is finalized
10
10
  class ConstituentMap {
11
11
  constructor(config) {
12
- var _a, _b;
12
+ var _a, _b, _c;
13
13
  this.constituentMap = new Map();
14
14
  this.constituentIndexToKeyMap = new Map();
15
15
  this.spotMarketIndexToKeyMap = new Map();
16
- this.driftClient = config.driftClient;
16
+ const velocityClient = (_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient;
17
+ if (!velocityClient) {
18
+ throw new Error('ConstituentMap: velocityClient (or deprecated driftClient) must be provided');
19
+ }
20
+ this.velocityClient = velocityClient;
17
21
  this.additionalFilters = config.additionalFilters;
18
22
  this.commitment = config.subscriptionConfig.commitment;
19
- this.connection = config.connection || this.driftClient.connection;
20
- this.lpPoolId = (_a = config.lpPoolId) !== null && _a !== void 0 ? _a : 0;
21
- this.decoder = (_b = config.decoder) !== null && _b !== void 0 ? _b : 'base64+zstd';
23
+ this.connection = config.connection || this.velocityClient.connection;
24
+ this.lpPoolId = (_b = config.lpPoolId) !== null && _b !== void 0 ? _b : 0;
25
+ this.decoder = (_c = config.decoder) !== null && _c !== void 0 ? _c : 'base64+zstd';
22
26
  if (config.subscriptionConfig.type === 'polling') {
23
27
  this.constituentAccountSubscriber =
24
- new pollingConstituentAccountSubscriber_1.PollingConstituentAccountSubscriber(this, this.driftClient.program, config.subscriptionConfig.frequency, config.subscriptionConfig.commitment, this.getFilters());
28
+ new pollingConstituentAccountSubscriber_1.PollingConstituentAccountSubscriber(this, this.velocityClient.program, config.subscriptionConfig.frequency, config.subscriptionConfig.commitment, this.getFilters());
25
29
  }
26
30
  else if (config.subscriptionConfig.type === 'websocket') {
27
31
  this.constituentAccountSubscriber =
28
- new webSocketConstituentAccountSubscriber_1.WebSocketConstituentAccountSubscriber(this, this.driftClient.program, config.subscriptionConfig.resubTimeoutMs, config.subscriptionConfig.commitment, this.getFilters());
32
+ new webSocketConstituentAccountSubscriber_1.WebSocketConstituentAccountSubscriber(this, this.velocityClient.program, config.subscriptionConfig.resubTimeoutMs, config.subscriptionConfig.commitment, this.getFilters());
29
33
  }
30
34
  // Listen for account updates from the subscriber
31
35
  this.constituentAccountSubscriber.eventEmitter.on('onAccountUpdate', (account, pubkey, slot) => {
@@ -35,7 +39,7 @@ class ConstituentMap {
35
39
  getFilters() {
36
40
  const filters = [
37
41
  (0, memcmp_1.getConstituentFilter)(),
38
- (0, memcmp_1.getConstituentLpPoolFilter)((0, pda_1.getLpPoolPublicKey)(this.driftClient.program.programId, this.lpPoolId)),
42
+ (0, memcmp_1.getConstituentLpPoolFilter)((0, pda_1.getLpPoolPublicKey)(this.velocityClient.program.programId, this.lpPoolId)),
39
43
  ];
40
44
  if (this.additionalFilters) {
41
45
  filters.push(...this.additionalFilters);
@@ -43,12 +47,12 @@ class ConstituentMap {
43
47
  return filters;
44
48
  }
45
49
  decode(name, buffer) {
46
- return this.driftClient.program.account.constituent.coder.accounts.decodeUnchecked(name, buffer);
50
+ return this.velocityClient.program.account.constituent.coder.accounts.decodeUnchecked(name, buffer);
47
51
  }
48
52
  async sync() {
49
53
  try {
50
54
  const rpcRequestArgs = [
51
- this.driftClient.program.programId.toBase58(),
55
+ this.velocityClient.program.programId.toBase58(),
52
56
  {
53
57
  commitment: this.commitment,
54
58
  filters: this.getFilters(),
@@ -224,3 +224,7 @@ export declare class VelocityCore {
224
224
  */
225
225
  static buildInstructions(_ctx: VelocityCoreContext): TransactionInstruction[];
226
226
  }
227
+ /** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
228
+ export declare const DriftCore: typeof VelocityCore;
229
+ /** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
230
+ export type DriftCore = VelocityCore;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.VelocityCore = void 0;
29
+ exports.DriftCore = exports.VelocityCore = void 0;
30
30
  const pdas = __importStar(require("../addresses/pda"));
31
31
  const constants = __importStar(require("../constants"));
32
32
  const user_1 = require("../decode/user");
@@ -136,3 +136,5 @@ VelocityCore.constants = constants;
136
136
  /** Re-export remaining-accounts logic (pure). */
137
137
  VelocityCore.remainingAccounts = remainingAccounts;
138
138
  VelocityCore.signedMsg = signedMsg;
139
+ /** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
140
+ exports.DriftCore = VelocityCore;
@@ -9,7 +9,9 @@ import { MarketType } from '../types';
9
9
  import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
10
10
  import { BN } from '../isomorphic/anchor';
11
11
  export declare class DLOBSubscriber {
12
- driftClient: VelocityClient;
12
+ velocityClient: VelocityClient;
13
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
14
+ get driftClient(): VelocityClient;
13
15
  dlobSource: DLOBSource;
14
16
  slotSource: SlotSource;
15
17
  updateFrequency: number;
@@ -6,8 +6,17 @@ const events_1 = require("events");
6
6
  const types_1 = require("../types");
7
7
  const orderBookLevels_1 = require("./orderBookLevels");
8
8
  class DLOBSubscriber {
9
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
10
+ get driftClient() {
11
+ return this.velocityClient;
12
+ }
9
13
  constructor(config) {
10
- this.driftClient = config.driftClient;
14
+ var _a;
15
+ const velocityClient = (_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient;
16
+ if (!velocityClient) {
17
+ throw new Error('DLOBSubscriber: velocityClient (or deprecated driftClient) must be provided');
18
+ }
19
+ this.velocityClient = velocityClient;
11
20
  this.dlobSource = config.dlobSource;
12
21
  this.slotSource = config.slotSource;
13
22
  this.updateFrequency = config.updateFrequency;
@@ -48,7 +57,7 @@ class DLOBSubscriber {
48
57
  */
49
58
  getL2({ marketName, marketIndex, marketType, depth = 10, includeVamm = false, numVammOrders, fallbackL2Generators = [], latestSlot, }) {
50
59
  if (marketName) {
51
- const derivedMarketInfo = this.driftClient.getMarketIndexAndType(marketName);
60
+ const derivedMarketInfo = this.velocityClient.getMarketIndexAndType(marketName);
52
61
  if (!derivedMarketInfo) {
53
62
  throw new Error(`Market ${marketName} not found`);
54
63
  }
@@ -63,12 +72,12 @@ class DLOBSubscriber {
63
72
  let oraclePriceData;
64
73
  const isPerp = (0, types_1.isVariant)(marketType, 'perp');
65
74
  if (isPerp) {
66
- const perpMarketAccount = this.driftClient.getPerpMarketAccount(marketIndex);
67
- oraclePriceData = this.driftClient.getOracleDataForPerpMarket(perpMarketAccount.marketIndex);
75
+ const perpMarketAccount = this.velocityClient.getPerpMarketAccount(marketIndex);
76
+ oraclePriceData = this.velocityClient.getOracleDataForPerpMarket(perpMarketAccount.marketIndex);
68
77
  }
69
78
  else {
70
79
  oraclePriceData =
71
- this.driftClient.getOracleDataForSpotMarket(marketIndex);
80
+ this.velocityClient.getOracleDataForSpotMarket(marketIndex);
72
81
  }
73
82
  if (isPerp && includeVamm) {
74
83
  if (fallbackL2Generators.length > 0) {
@@ -76,8 +85,8 @@ class DLOBSubscriber {
76
85
  }
77
86
  fallbackL2Generators = [
78
87
  (0, orderBookLevels_1.getVammL2Generator)({
79
- marketAccount: this.driftClient.getPerpMarketAccount(marketIndex),
80
- mmOraclePriceData: this.driftClient.getMMOracleDataForPerpMarket(marketIndex),
88
+ marketAccount: this.velocityClient.getPerpMarketAccount(marketIndex),
89
+ mmOraclePriceData: this.velocityClient.getMMOracleDataForPerpMarket(marketIndex),
81
90
  numOrders: numVammOrders !== null && numVammOrders !== void 0 ? numVammOrders : depth,
82
91
  topOfBookQuoteAmounts: marketIndex < 3
83
92
  ? orderBookLevels_1.MAJORS_TOP_OF_BOOK_QUOTE_AMOUNTS
@@ -104,7 +113,7 @@ class DLOBSubscriber {
104
113
  */
105
114
  getL3({ marketName, marketIndex, marketType, }) {
106
115
  if (marketName) {
107
- const derivedMarketInfo = this.driftClient.getMarketIndexAndType(marketName);
116
+ const derivedMarketInfo = this.velocityClient.getMarketIndexAndType(marketName);
108
117
  if (!derivedMarketInfo) {
109
118
  throw new Error(`Market ${marketName} not found`);
110
119
  }
@@ -120,11 +129,11 @@ class DLOBSubscriber {
120
129
  const isPerp = (0, types_1.isVariant)(marketType, 'perp');
121
130
  if (isPerp) {
122
131
  oraclePriceData =
123
- this.driftClient.getOracleDataForPerpMarket(marketIndex);
132
+ this.velocityClient.getOracleDataForPerpMarket(marketIndex);
124
133
  }
125
134
  else {
126
135
  oraclePriceData =
127
- this.driftClient.getOracleDataForSpotMarket(marketIndex);
136
+ this.velocityClient.getOracleDataForSpotMarket(marketIndex);
128
137
  }
129
138
  return this.dlob.getL3({
130
139
  marketIndex,
@@ -1,7 +1,9 @@
1
1
  import { DLOB } from './DLOB';
2
2
  import { VelocityClient } from '../velocityClient';
3
3
  export type DLOBSubscriptionConfig = {
4
- driftClient: VelocityClient;
4
+ velocityClient?: VelocityClient;
5
+ /** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
6
+ driftClient?: VelocityClient;
5
7
  dlobSource: DLOBSource;
6
8
  slotSource: SlotSource;
7
9
  updateFrequency: number;
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/drift.json`.
6
6
  */
7
7
  export type Drift = {
8
- "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
8
+ "address": "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
9
9
  "metadata": {
10
10
  "name": "drift";
11
11
  "version": "2.162.0";
@@ -2884,6 +2884,59 @@ export type Drift = {
2884
2884
  ];
2885
2885
  "args": [];
2886
2886
  },
2887
+ {
2888
+ "name": "forceWipeAccountsDevnet";
2889
+ "docs": [
2890
+ "Devnet-only escape hatch: cleans up accounts stranded by a layout-breaking",
2891
+ "program upgrade (or by a partial re-init). For each account passed via",
2892
+ "`remaining_accounts`:",
2893
+ "- drift-owned PDA → drain lamports (runtime GCs at end of tx)",
2894
+ "- token-program owned vault (drift_signer close-authority) → CPI",
2895
+ "`close_account`, rent refunded to admin",
2896
+ "Admin gate reads State's first pubkey field at raw offset 8..40 so it",
2897
+ "works regardless of the State layout currently on chain. `drift_signer_nonce`",
2898
+ "must match `State.signer_nonce`; mismatch fails the token CPI signature.",
2899
+ "Stripped from mainnet builds via `mainnet-beta`."
2900
+ ];
2901
+ "discriminator": [
2902
+ 105,
2903
+ 74,
2904
+ 87,
2905
+ 6,
2906
+ 166,
2907
+ 227,
2908
+ 138,
2909
+ 215
2910
+ ];
2911
+ "accounts": [
2912
+ {
2913
+ "name": "admin";
2914
+ "writable": true;
2915
+ "signer": true;
2916
+ },
2917
+ {
2918
+ "name": "state";
2919
+ "docs": [
2920
+ "(cold-)admin pubkey at offset 8..40."
2921
+ ];
2922
+ },
2923
+ {
2924
+ "name": "driftSigner";
2925
+ "docs": [
2926
+ "at CPI time when closing token vaults; ignored otherwise."
2927
+ ];
2928
+ },
2929
+ {
2930
+ "name": "tokenProgram";
2931
+ }
2932
+ ];
2933
+ "args": [
2934
+ {
2935
+ "name": "driftSignerNonce";
2936
+ "type": "u8";
2937
+ }
2938
+ ];
2939
+ },
2887
2940
  {
2888
2941
  "name": "initialize";
2889
2942
  "discriminator": [