@drift-labs/sdk 2.145.0-beta.2 → 2.145.0

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 (73) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/accounts/types.d.ts +13 -1
  3. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +53 -0
  4. package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +453 -0
  5. package/lib/browser/addresses/pda.d.ts +9 -0
  6. package/lib/browser/addresses/pda.js +60 -1
  7. package/lib/browser/adminClient.d.ts +160 -8
  8. package/lib/browser/adminClient.js +754 -18
  9. package/lib/browser/constituentMap/constituentMap.d.ts +64 -0
  10. package/lib/browser/constituentMap/constituentMap.js +170 -0
  11. package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +24 -0
  12. package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
  13. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +24 -0
  14. package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
  15. package/lib/browser/driftClient.d.ts +89 -2
  16. package/lib/browser/driftClient.js +486 -27
  17. package/lib/browser/driftClientConfig.d.ts +2 -7
  18. package/lib/browser/idl/drift.json +4304 -1380
  19. package/lib/browser/index.d.ts +1 -4
  20. package/lib/browser/index.js +2 -9
  21. package/lib/browser/memcmp.d.ts +3 -1
  22. package/lib/browser/memcmp.js +19 -1
  23. package/lib/browser/types.d.ts +147 -0
  24. package/lib/browser/types.js +13 -1
  25. package/lib/node/accounts/types.d.ts +13 -1
  26. package/lib/node/accounts/types.d.ts.map +1 -1
  27. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +54 -0
  28. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -0
  29. package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +453 -0
  30. package/lib/node/addresses/pda.d.ts +9 -0
  31. package/lib/node/addresses/pda.d.ts.map +1 -1
  32. package/lib/node/addresses/pda.js +60 -1
  33. package/lib/node/adminClient.d.ts +160 -8
  34. package/lib/node/adminClient.d.ts.map +1 -1
  35. package/lib/node/adminClient.js +754 -18
  36. package/lib/node/constituentMap/constituentMap.d.ts +65 -0
  37. package/lib/node/constituentMap/constituentMap.d.ts.map +1 -0
  38. package/lib/node/constituentMap/constituentMap.js +170 -0
  39. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +25 -0
  40. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -0
  41. package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
  42. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +25 -0
  43. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -0
  44. package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
  45. package/lib/node/driftClient.d.ts +89 -2
  46. package/lib/node/driftClient.d.ts.map +1 -1
  47. package/lib/node/driftClient.js +486 -27
  48. package/lib/node/driftClientConfig.d.ts +2 -7
  49. package/lib/node/driftClientConfig.d.ts.map +1 -1
  50. package/lib/node/idl/drift.json +4304 -1380
  51. package/lib/node/index.d.ts +1 -4
  52. package/lib/node/index.d.ts.map +1 -1
  53. package/lib/node/index.js +2 -9
  54. package/lib/node/memcmp.d.ts +3 -1
  55. package/lib/node/memcmp.d.ts.map +1 -1
  56. package/lib/node/memcmp.js +19 -1
  57. package/lib/node/types.d.ts +147 -0
  58. package/lib/node/types.d.ts.map +1 -1
  59. package/lib/node/types.js +13 -1
  60. package/package.json +1 -1
  61. package/src/accounts/types.ts +20 -0
  62. package/src/accounts/webSocketProgramAccountSubscriberV2.ts +596 -0
  63. package/src/addresses/pda.ts +115 -1
  64. package/src/adminClient.ts +1612 -41
  65. package/src/constituentMap/constituentMap.ts +285 -0
  66. package/src/constituentMap/pollingConstituentAccountSubscriber.ts +97 -0
  67. package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +112 -0
  68. package/src/driftClient.ts +1097 -17
  69. package/src/driftClientConfig.ts +8 -15
  70. package/src/idl/drift.json +4304 -1380
  71. package/src/index.ts +1 -4
  72. package/src/memcmp.ts +23 -1
  73. package/src/types.ts +160 -0
@@ -0,0 +1,64 @@
1
+ import { Commitment, Connection, MemcmpFilter } from '@solana/web3.js';
2
+ import { DataAndSlot } from '../accounts/types';
3
+ import { ConstituentAccount } from '../types';
4
+ import { DriftClient } from '../driftClient';
5
+ export type ConstituentMapConfig = {
6
+ driftClient: DriftClient;
7
+ connection?: Connection;
8
+ subscriptionConfig: {
9
+ type: 'polling';
10
+ frequency: number;
11
+ commitment?: Commitment;
12
+ } | {
13
+ type: 'websocket';
14
+ resubTimeoutMs?: number;
15
+ logResubMessages?: boolean;
16
+ commitment?: Commitment;
17
+ };
18
+ lpPoolId?: number;
19
+ additionalFilters?: MemcmpFilter[];
20
+ };
21
+ export interface ConstituentMapInterface {
22
+ subscribe(): Promise<void>;
23
+ unsubscribe(): Promise<void>;
24
+ has(key: string): boolean;
25
+ get(key: string): ConstituentAccount | undefined;
26
+ getFromSpotMarketIndex(spotMarketIndex: number): ConstituentAccount | undefined;
27
+ getFromConstituentIndex(constituentIndex: number): ConstituentAccount | undefined;
28
+ getWithSlot(key: string): DataAndSlot<ConstituentAccount> | undefined;
29
+ mustGet(key: string): Promise<ConstituentAccount>;
30
+ mustGetWithSlot(key: string): Promise<DataAndSlot<ConstituentAccount>>;
31
+ }
32
+ export declare class ConstituentMap implements ConstituentMapInterface {
33
+ private driftClient;
34
+ private constituentMap;
35
+ private constituentAccountSubscriber;
36
+ private additionalFilters?;
37
+ private commitment?;
38
+ private connection?;
39
+ private constituentIndexToKeyMap;
40
+ private spotMarketIndexToKeyMap;
41
+ private lpPoolId;
42
+ constructor(config: ConstituentMapConfig);
43
+ private getFilters;
44
+ private decode;
45
+ sync(): Promise<void>;
46
+ subscribe(): Promise<void>;
47
+ unsubscribe(): Promise<void>;
48
+ has(key: string): boolean;
49
+ get(key: string): ConstituentAccount | undefined;
50
+ getFromConstituentIndex(constituentIndex: number): ConstituentAccount | undefined;
51
+ getFromSpotMarketIndex(spotMarketIndex: number): ConstituentAccount | undefined;
52
+ getWithSlot(key: string): DataAndSlot<ConstituentAccount> | undefined;
53
+ mustGet(key: string): Promise<ConstituentAccount>;
54
+ mustGetWithSlot(key: string): Promise<DataAndSlot<ConstituentAccount>>;
55
+ size(): number;
56
+ values(): IterableIterator<ConstituentAccount>;
57
+ valuesWithSlot(): IterableIterator<DataAndSlot<ConstituentAccount>>;
58
+ entries(): IterableIterator<[string, ConstituentAccount]>;
59
+ entriesWithSlot(): IterableIterator<[
60
+ string,
61
+ DataAndSlot<ConstituentAccount>
62
+ ]>;
63
+ updateConstituentAccount(key: string, constituentAccount: ConstituentAccount, slot: number): void;
64
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConstituentMap = void 0;
4
+ const pollingConstituentAccountSubscriber_1 = require("./pollingConstituentAccountSubscriber");
5
+ const webSocketConstituentAccountSubscriber_1 = require("./webSocketConstituentAccountSubscriber");
6
+ const memcmp_1 = require("../memcmp");
7
+ const zstddec_1 = require("zstddec");
8
+ const pda_1 = require("../addresses/pda");
9
+ const MAX_CONSTITUENT_SIZE_BYTES = 480; // TODO: update this when account is finalized
10
+ class ConstituentMap {
11
+ constructor(config) {
12
+ var _a;
13
+ this.constituentMap = new Map();
14
+ this.constituentIndexToKeyMap = new Map();
15
+ this.spotMarketIndexToKeyMap = new Map();
16
+ this.driftClient = config.driftClient;
17
+ this.additionalFilters = config.additionalFilters;
18
+ 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
+ if (config.subscriptionConfig.type === 'polling') {
22
+ this.constituentAccountSubscriber =
23
+ new pollingConstituentAccountSubscriber_1.PollingConstituentAccountSubscriber(this, this.driftClient.program, config.subscriptionConfig.frequency, config.subscriptionConfig.commitment, this.getFilters());
24
+ }
25
+ else if (config.subscriptionConfig.type === 'websocket') {
26
+ this.constituentAccountSubscriber =
27
+ new webSocketConstituentAccountSubscriber_1.WebSocketConstituentAccountSubscriber(this, this.driftClient.program, config.subscriptionConfig.resubTimeoutMs, config.subscriptionConfig.commitment, this.getFilters());
28
+ }
29
+ // Listen for account updates from the subscriber
30
+ this.constituentAccountSubscriber.eventEmitter.on('onAccountUpdate', (account, pubkey, slot) => {
31
+ this.updateConstituentAccount(pubkey.toString(), account, slot);
32
+ });
33
+ }
34
+ getFilters() {
35
+ const filters = [
36
+ (0, memcmp_1.getConstituentFilter)(),
37
+ (0, memcmp_1.getConstituentLpPoolFilter)((0, pda_1.getLpPoolPublicKey)(this.driftClient.program.programId, this.lpPoolId)),
38
+ ];
39
+ if (this.additionalFilters) {
40
+ filters.push(...this.additionalFilters);
41
+ }
42
+ return filters;
43
+ }
44
+ decode(name, buffer) {
45
+ return this.driftClient.program.account.constituent.coder.accounts.decodeUnchecked(name, buffer);
46
+ }
47
+ async sync() {
48
+ try {
49
+ const rpcRequestArgs = [
50
+ this.driftClient.program.programId.toBase58(),
51
+ {
52
+ commitment: this.commitment,
53
+ filters: this.getFilters(),
54
+ encoding: 'base64+zstd',
55
+ withContext: true,
56
+ },
57
+ ];
58
+ // @ts-ignore
59
+ const rpcJSONResponse = await this.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
60
+ const rpcResponseAndContext = rpcJSONResponse.result;
61
+ const slot = rpcResponseAndContext.context.slot;
62
+ const promises = rpcResponseAndContext.value.map(async (programAccount) => {
63
+ const compressedUserData = Buffer.from(programAccount.account.data[0], 'base64');
64
+ const decoder = new zstddec_1.ZSTDDecoder();
65
+ await decoder.init();
66
+ const buffer = Buffer.from(decoder.decode(compressedUserData, MAX_CONSTITUENT_SIZE_BYTES));
67
+ const key = programAccount.pubkey.toString();
68
+ const currAccountWithSlot = this.getWithSlot(key);
69
+ if (currAccountWithSlot) {
70
+ if (slot >= currAccountWithSlot.slot) {
71
+ const constituentAcc = this.decode('Constituent', buffer);
72
+ this.updateConstituentAccount(key, constituentAcc, slot);
73
+ }
74
+ }
75
+ else {
76
+ const constituentAcc = this.decode('Constituent', buffer);
77
+ this.updateConstituentAccount(key, constituentAcc, slot);
78
+ }
79
+ });
80
+ await Promise.all(promises);
81
+ }
82
+ catch (error) {
83
+ console.log(`ConstituentMap.sync() error: ${error.message}`);
84
+ }
85
+ }
86
+ async subscribe() {
87
+ await this.constituentAccountSubscriber.subscribe();
88
+ }
89
+ async unsubscribe() {
90
+ await this.constituentAccountSubscriber.unsubscribe();
91
+ this.constituentMap.clear();
92
+ }
93
+ has(key) {
94
+ return this.constituentMap.has(key);
95
+ }
96
+ get(key) {
97
+ var _a;
98
+ return (_a = this.constituentMap.get(key)) === null || _a === void 0 ? void 0 : _a.data;
99
+ }
100
+ getFromConstituentIndex(constituentIndex) {
101
+ const key = this.constituentIndexToKeyMap.get(constituentIndex);
102
+ return key ? this.get(key) : undefined;
103
+ }
104
+ getFromSpotMarketIndex(spotMarketIndex) {
105
+ const key = this.spotMarketIndexToKeyMap.get(spotMarketIndex);
106
+ return key ? this.get(key) : undefined;
107
+ }
108
+ getWithSlot(key) {
109
+ return this.constituentMap.get(key);
110
+ }
111
+ async mustGet(key) {
112
+ if (!this.has(key)) {
113
+ await this.sync();
114
+ }
115
+ const result = this.constituentMap.get(key);
116
+ if (!result) {
117
+ throw new Error(`ConstituentAccount not found for key: ${key}`);
118
+ }
119
+ return result.data;
120
+ }
121
+ async mustGetWithSlot(key) {
122
+ if (!this.has(key)) {
123
+ await this.sync();
124
+ }
125
+ const result = this.constituentMap.get(key);
126
+ if (!result) {
127
+ throw new Error(`ConstituentAccount not found for key: ${key}`);
128
+ }
129
+ return result;
130
+ }
131
+ size() {
132
+ return this.constituentMap.size;
133
+ }
134
+ *values() {
135
+ for (const dataAndSlot of this.constituentMap.values()) {
136
+ yield dataAndSlot.data;
137
+ }
138
+ }
139
+ valuesWithSlot() {
140
+ return this.constituentMap.values();
141
+ }
142
+ *entries() {
143
+ for (const [key, dataAndSlot] of this.constituentMap.entries()) {
144
+ yield [key, dataAndSlot.data];
145
+ }
146
+ }
147
+ entriesWithSlot() {
148
+ return this.constituentMap.entries();
149
+ }
150
+ updateConstituentAccount(key, constituentAccount, slot) {
151
+ const existingData = this.getWithSlot(key);
152
+ if (existingData) {
153
+ if (slot >= existingData.slot) {
154
+ this.constituentMap.set(key, {
155
+ data: constituentAccount,
156
+ slot,
157
+ });
158
+ }
159
+ }
160
+ else {
161
+ this.constituentMap.set(key, {
162
+ data: constituentAccount,
163
+ slot,
164
+ });
165
+ }
166
+ this.constituentIndexToKeyMap.set(constituentAccount.constituentIndex, key);
167
+ this.spotMarketIndexToKeyMap.set(constituentAccount.spotMarketIndex, key);
168
+ }
169
+ }
170
+ exports.ConstituentMap = ConstituentMap;
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { ConstituentAccountEvents, ConstituentAccountSubscriber } from '../accounts/types';
4
+ import { Program } from '@coral-xyz/anchor';
5
+ import StrictEventEmitter from 'strict-event-emitter-types';
6
+ import { EventEmitter } from 'events';
7
+ import { Commitment, MemcmpFilter } from '@solana/web3.js';
8
+ import { ConstituentMap } from './constituentMap';
9
+ export declare class PollingConstituentAccountSubscriber implements ConstituentAccountSubscriber {
10
+ isSubscribed: boolean;
11
+ program: Program;
12
+ frequency: number;
13
+ commitment?: Commitment;
14
+ additionalFilters?: MemcmpFilter[];
15
+ eventEmitter: StrictEventEmitter<EventEmitter, ConstituentAccountEvents>;
16
+ intervalId?: NodeJS.Timeout;
17
+ constituentMap: ConstituentMap;
18
+ constructor(constituentMap: ConstituentMap, program: Program, frequency: number, commitment?: Commitment, additionalFilters?: MemcmpFilter[]);
19
+ subscribe(): Promise<boolean>;
20
+ sync(): Promise<void>;
21
+ unsubscribe(): Promise<void>;
22
+ assertIsSubscribed(): void;
23
+ didSubscriptionSucceed(): boolean;
24
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PollingConstituentAccountSubscriber = void 0;
4
+ const types_1 = require("../accounts/types");
5
+ const events_1 = require("events");
6
+ class PollingConstituentAccountSubscriber {
7
+ constructor(constituentMap, program, frequency, commitment, additionalFilters) {
8
+ this.constituentMap = constituentMap;
9
+ this.isSubscribed = false;
10
+ this.program = program;
11
+ this.frequency = frequency;
12
+ this.commitment = commitment;
13
+ this.additionalFilters = additionalFilters;
14
+ this.eventEmitter = new events_1.EventEmitter();
15
+ }
16
+ async subscribe() {
17
+ if (this.isSubscribed || this.frequency <= 0) {
18
+ return true;
19
+ }
20
+ const executeSync = async () => {
21
+ await this.sync();
22
+ this.intervalId = setTimeout(executeSync, this.frequency);
23
+ };
24
+ // Initial sync
25
+ await this.sync();
26
+ // Start polling
27
+ this.intervalId = setTimeout(executeSync, this.frequency);
28
+ this.isSubscribed = true;
29
+ return true;
30
+ }
31
+ async sync() {
32
+ try {
33
+ await this.constituentMap.sync();
34
+ this.eventEmitter.emit('update');
35
+ }
36
+ catch (error) {
37
+ console.log(`PollingConstituentAccountSubscriber.sync() error: ${error.message}`);
38
+ this.eventEmitter.emit('error', error);
39
+ }
40
+ }
41
+ async unsubscribe() {
42
+ if (!this.isSubscribed) {
43
+ return;
44
+ }
45
+ if (this.intervalId) {
46
+ clearTimeout(this.intervalId);
47
+ this.intervalId = undefined;
48
+ }
49
+ this.isSubscribed = false;
50
+ }
51
+ assertIsSubscribed() {
52
+ if (!this.isSubscribed) {
53
+ throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
54
+ }
55
+ }
56
+ didSubscriptionSucceed() {
57
+ return this.isSubscribed;
58
+ }
59
+ }
60
+ exports.PollingConstituentAccountSubscriber = PollingConstituentAccountSubscriber;
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import { ConstituentAccountEvents, ConstituentAccountSubscriber } from '../accounts/types';
3
+ import { Program } from '@coral-xyz/anchor';
4
+ import StrictEventEmitter from 'strict-event-emitter-types';
5
+ import { EventEmitter } from 'events';
6
+ import { Commitment, MemcmpFilter } from '@solana/web3.js';
7
+ import { ConstituentAccount } from '../types';
8
+ import { WebSocketProgramAccountSubscriber } from '../accounts/webSocketProgramAccountSubscriber';
9
+ import { ConstituentMap } from './constituentMap';
10
+ export declare class WebSocketConstituentAccountSubscriber implements ConstituentAccountSubscriber {
11
+ isSubscribed: boolean;
12
+ resubTimeoutMs?: number;
13
+ commitment?: Commitment;
14
+ program: Program;
15
+ eventEmitter: StrictEventEmitter<EventEmitter, ConstituentAccountEvents>;
16
+ constituentDataAccountSubscriber: WebSocketProgramAccountSubscriber<ConstituentAccount>;
17
+ constituentMap: ConstituentMap;
18
+ private additionalFilters?;
19
+ constructor(constituentMap: ConstituentMap, program: Program, resubTimeoutMs?: number, commitment?: Commitment, additionalFilters?: MemcmpFilter[]);
20
+ subscribe(): Promise<boolean>;
21
+ sync(): Promise<void>;
22
+ unsubscribe(): Promise<void>;
23
+ assertIsSubscribed(): void;
24
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebSocketConstituentAccountSubscriber = void 0;
4
+ const types_1 = require("../accounts/types");
5
+ const events_1 = require("events");
6
+ const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
7
+ const memcmp_1 = require("../memcmp");
8
+ class WebSocketConstituentAccountSubscriber {
9
+ constructor(constituentMap, program, resubTimeoutMs, commitment, additionalFilters) {
10
+ this.constituentMap = constituentMap;
11
+ this.isSubscribed = false;
12
+ this.program = program;
13
+ this.eventEmitter = new events_1.EventEmitter();
14
+ this.resubTimeoutMs = resubTimeoutMs;
15
+ this.commitment = commitment;
16
+ this.additionalFilters = additionalFilters;
17
+ }
18
+ async subscribe() {
19
+ if (this.isSubscribed) {
20
+ return true;
21
+ }
22
+ this.constituentDataAccountSubscriber =
23
+ new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('LpPoolConstituent', 'Constituent', this.program, this.program.account.constituent.coder.accounts.decode.bind(this.program.account.constituent.coder.accounts), {
24
+ filters: [(0, memcmp_1.getConstituentFilter)(), ...(this.additionalFilters || [])],
25
+ commitment: this.commitment,
26
+ });
27
+ await this.constituentDataAccountSubscriber.subscribe((accountId, account, context) => {
28
+ this.constituentMap.updateConstituentAccount(accountId.toBase58(), account, context.slot);
29
+ this.eventEmitter.emit('onAccountUpdate', account, accountId, context.slot);
30
+ });
31
+ this.eventEmitter.emit('update');
32
+ this.isSubscribed = true;
33
+ return true;
34
+ }
35
+ async sync() {
36
+ try {
37
+ await this.constituentMap.sync();
38
+ this.eventEmitter.emit('update');
39
+ }
40
+ catch (error) {
41
+ console.log(`WebSocketConstituentAccountSubscriber.sync() error: ${error.message}`);
42
+ this.eventEmitter.emit('error', error);
43
+ }
44
+ }
45
+ async unsubscribe() {
46
+ if (!this.isSubscribed) {
47
+ return;
48
+ }
49
+ await Promise.all([this.constituentDataAccountSubscriber.unsubscribe()]);
50
+ this.isSubscribed = false;
51
+ }
52
+ assertIsSubscribed() {
53
+ if (!this.isSubscribed) {
54
+ throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
55
+ }
56
+ }
57
+ }
58
+ exports.WebSocketConstituentAccountSubscriber = WebSocketConstituentAccountSubscriber;
@@ -5,7 +5,7 @@
5
5
  import * as anchor from '@coral-xyz/anchor';
6
6
  import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
7
7
  import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
8
- import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, PostOnlyParams } from './types';
8
+ import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, PostOnlyParams, LPPoolAccount, ConstituentAccount, ConstituentTargetBaseAccount, AmmCache } from './types';
9
9
  import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
10
10
  import { TokenFaucet } from './tokenFaucet';
11
11
  import { EventEmitter } from 'events';
@@ -26,6 +26,7 @@ import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/
26
26
  import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/pyth_solana_receiver';
27
27
  import { Slothash } from './slot/SlothashSubscriber';
28
28
  import { SignedMsgOrderParams } from './types';
29
+ import { ConstituentMap } from './constituentMap/constituentMap';
29
30
  import { RevenueShareEscrowMap } from './userMap/revenueShareEscrowMap';
30
31
  import { TitanClient } from './titan/titanClient';
31
32
  import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
@@ -351,7 +352,7 @@ export declare class DriftClient {
351
352
  * @param useNative
352
353
  * @param tokenProgram
353
354
  */
354
- getAssociatedTokenAccount(marketIndex: number, useNative?: boolean, tokenProgram?: anchor.web3.PublicKey): Promise<PublicKey>;
355
+ getAssociatedTokenAccount(marketIndex: number, useNative?: boolean, tokenProgram?: anchor.web3.PublicKey, authority?: anchor.web3.PublicKey, allowOwnerOffCurve?: boolean): Promise<PublicKey>;
355
356
  createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: anchor.web3.PublicKey): TransactionInstruction;
356
357
  getDepositTxnIx(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionInstruction[]>;
357
358
  buildSwiftDepositTx(signedOrderParams: SignedMsgOrderParams, takerInfo: {
@@ -1098,6 +1099,92 @@ export declare class DriftClient {
1098
1099
  getUpdateMmOracleNativeIx(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionInstruction>;
1099
1100
  updateAmmSpreadAdjustmentNative(marketIndex: number, ammSpreadAdjustment: number): Promise<TransactionSignature>;
1100
1101
  getUpdateAmmSpreadAdjustmentNativeIx(marketIndex: number, ammSpreadAdjustment: number): TransactionInstruction;
1102
+ getLpPoolAccount(lpPoolId: number): Promise<LPPoolAccount>;
1103
+ getConstituentTargetBaseAccount(lpPoolId: number): Promise<ConstituentTargetBaseAccount>;
1104
+ getAmmCache(): Promise<AmmCache>;
1105
+ updateLpConstituentTargetBase(lpPoolId: number, constituents: PublicKey[], txParams?: TxParams): Promise<TransactionSignature>;
1106
+ getUpdateLpConstituentTargetBaseIx(lpPoolId: number, constituents: PublicKey[]): Promise<TransactionInstruction>;
1107
+ updateLpPoolAum(lpPool: LPPoolAccount, spotMarketIndexOfConstituents: number[], txParams?: TxParams): Promise<TransactionSignature>;
1108
+ getUpdateLpPoolAumIxs(lpPool: LPPoolAccount, spotMarketIndexOfConstituents: number[]): Promise<TransactionInstruction>;
1109
+ updateAmmCache(perpMarketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
1110
+ getUpdateAmmCacheIx(perpMarketIndexes: number[]): Promise<TransactionInstruction>;
1111
+ updateConstituentOracleInfo(constituent: ConstituentAccount): Promise<TransactionSignature>;
1112
+ getUpdateConstituentOracleInfoIx(constituent: ConstituentAccount): Promise<TransactionInstruction>;
1113
+ lpPoolSwap(inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, lpPool: PublicKey, userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
1114
+ getLpPoolSwapIx(inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, lpPool: PublicKey, userAuthority: PublicKey): Promise<TransactionInstruction>;
1115
+ viewLpPoolSwapFees(inMarketIndex: number, outMarketIndex: number, inAmount: BN, inTargetWeight: BN, outTargetWeight: BN, lpPool: PublicKey, constituentTargetBase: PublicKey, constituentInTokenAccount: PublicKey, constituentOutTokenAccount: PublicKey, inConstituent: PublicKey, outConstituent: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
1116
+ getViewLpPoolSwapFeesIx(inMarketIndex: number, outMarketIndex: number, inAmount: BN, inTargetWeight: BN, outTargetWeight: BN, lpPool: PublicKey, constituentTargetBase: PublicKey, constituentInTokenAccount: PublicKey, constituentOutTokenAccount: PublicKey, inConstituent: PublicKey, outConstituent: PublicKey): Promise<TransactionInstruction>;
1117
+ getCreateLpPoolTokenAccountIx(lpPool: LPPoolAccount): Promise<TransactionInstruction>;
1118
+ createLpPoolTokenAccount(lpPool: LPPoolAccount, txParams?: TxParams): Promise<TransactionSignature>;
1119
+ lpPoolAddLiquidity({ inMarketIndex, inAmount, minMintAmount, lpPool, txParams, }: {
1120
+ inMarketIndex: number;
1121
+ inAmount: BN;
1122
+ minMintAmount: BN;
1123
+ lpPool: LPPoolAccount;
1124
+ txParams?: TxParams;
1125
+ }): Promise<TransactionSignature>;
1126
+ getLpPoolAddLiquidityIx({ inMarketIndex, inAmount, minMintAmount, lpPool, }: {
1127
+ inMarketIndex: number;
1128
+ inAmount: BN;
1129
+ minMintAmount: BN;
1130
+ lpPool: LPPoolAccount;
1131
+ }): Promise<TransactionInstruction[]>;
1132
+ viewLpPoolAddLiquidityFees({ inMarketIndex, inAmount, lpPool, txParams, }: {
1133
+ inMarketIndex: number;
1134
+ inAmount: BN;
1135
+ lpPool: LPPoolAccount;
1136
+ txParams?: TxParams;
1137
+ }): Promise<TransactionSignature>;
1138
+ getViewLpPoolAddLiquidityFeesIx({ inMarketIndex, inAmount, lpPool, }: {
1139
+ inMarketIndex: number;
1140
+ inAmount: BN;
1141
+ lpPool: LPPoolAccount;
1142
+ }): Promise<TransactionInstruction>;
1143
+ lpPoolRemoveLiquidity({ outMarketIndex, lpToBurn, minAmountOut, lpPool, txParams, }: {
1144
+ outMarketIndex: number;
1145
+ lpToBurn: BN;
1146
+ minAmountOut: BN;
1147
+ lpPool: LPPoolAccount;
1148
+ txParams?: TxParams;
1149
+ }): Promise<TransactionSignature>;
1150
+ getLpPoolRemoveLiquidityIx({ outMarketIndex, lpToBurn, minAmountOut, lpPool, }: {
1151
+ outMarketIndex: number;
1152
+ lpToBurn: BN;
1153
+ minAmountOut: BN;
1154
+ lpPool: LPPoolAccount;
1155
+ }): Promise<TransactionInstruction[]>;
1156
+ viewLpPoolRemoveLiquidityFees({ outMarketIndex, lpToBurn, lpPool, txParams, }: {
1157
+ outMarketIndex: number;
1158
+ lpToBurn: BN;
1159
+ lpPool: LPPoolAccount;
1160
+ txParams?: TxParams;
1161
+ }): Promise<TransactionSignature>;
1162
+ getViewLpPoolRemoveLiquidityFeesIx({ outMarketIndex, lpToBurn, lpPool, }: {
1163
+ outMarketIndex: number;
1164
+ lpToBurn: BN;
1165
+ lpPool: LPPoolAccount;
1166
+ }): Promise<TransactionInstruction>;
1167
+ getAllLpPoolAddLiquidityIxs({ inMarketIndex, inAmount, minMintAmount, lpPool, }: {
1168
+ inMarketIndex: number;
1169
+ inAmount: BN;
1170
+ minMintAmount: BN;
1171
+ lpPool: LPPoolAccount;
1172
+ }, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean, view?: boolean): Promise<TransactionInstruction[]>;
1173
+ getAllLpPoolRemoveLiquidityIxs({ outMarketIndex, lpToBurn, minAmountOut, lpPool, }: {
1174
+ outMarketIndex: number;
1175
+ lpToBurn: BN;
1176
+ minAmountOut: BN;
1177
+ lpPool: LPPoolAccount;
1178
+ }, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean, view?: boolean): Promise<TransactionInstruction[]>;
1179
+ getAllUpdateLpPoolAumIxs(lpPool: LPPoolAccount, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean): Promise<TransactionInstruction[]>;
1180
+ getAllUpdateConstituentTargetBaseIxs(perpMarketIndexes: number[], lpPool: LPPoolAccount, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean): Promise<TransactionInstruction[]>;
1181
+ getAllLpPoolSwapIxs(lpPool: LPPoolAccount, constituentMap: ConstituentMap, inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, userAuthority: PublicKey): Promise<TransactionInstruction[]>;
1182
+ settlePerpToLpPool(lpPoolId: number, perpMarketIndexes: number[]): Promise<TransactionSignature>;
1183
+ getSettlePerpToLpPoolIx(lpPoolId: number, perpMarketIndexes: number[]): Promise<TransactionInstruction>;
1184
+ getAllSettlePerpToLpPoolIxs(lpPoolId: number, marketIndexes: number[]): Promise<TransactionInstruction[]>;
1185
+ /**
1186
+ * Below here are the transaction sending functions
1187
+ */
1101
1188
  private handleSignedTransaction;
1102
1189
  private handlePreSignedTransaction;
1103
1190
  private isVersionedTransaction;