@drift-labs/sdk 0.1.29-master.1 → 0.1.30-master.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.
Files changed (73) hide show
  1. package/lib/accounts/bulkAccountLoader.d.ts +2 -1
  2. package/lib/accounts/bulkAccountLoader.js +44 -32
  3. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +15 -0
  4. package/lib/accounts/pollingClearingHouseAccountSubscriber.js +50 -23
  5. package/lib/clearingHouse.d.ts +4 -2
  6. package/lib/clearingHouse.js +49 -14
  7. package/lib/constants/accounts.d.ts +15 -0
  8. package/lib/constants/accounts.js +18 -0
  9. package/lib/constants/markets.js +11 -0
  10. package/lib/factory/clearingHouse.d.ts +14 -4
  11. package/lib/factory/clearingHouse.js +23 -6
  12. package/lib/idl/clearing_house.json +53 -33
  13. package/lib/math/amm.d.ts +18 -0
  14. package/lib/math/amm.js +88 -1
  15. package/lib/oracles/pythClient.js +1 -1
  16. package/lib/orderParams.d.ts +1 -1
  17. package/lib/orderParams.js +2 -2
  18. package/lib/tx/retryTxSender.d.ts +5 -2
  19. package/lib/tx/retryTxSender.js +14 -1
  20. package/lib/util/promiseTimeout.d.ts +1 -0
  21. package/lib/util/promiseTimeout.js +14 -0
  22. package/package.json +1 -1
  23. package/src/accounts/bulkAccountLoader.ts +51 -40
  24. package/src/accounts/pollingClearingHouseAccountSubscriber.ts +73 -30
  25. package/src/clearingHouse.ts +71 -13
  26. package/src/constants/accounts.ts +26 -0
  27. package/src/constants/markets.ts +11 -0
  28. package/src/factory/clearingHouse.ts +47 -7
  29. package/src/idl/clearing_house.json +53 -33
  30. package/src/math/amm.ts +127 -2
  31. package/src/oracles/pythClient.ts +1 -1
  32. package/src/orderParams.ts +3 -2
  33. package/src/tx/retryTxSender.ts +19 -1
  34. package/src/util/promiseTimeout.ts +14 -0
  35. package/lib/math/repeg.d.ts +0 -32
  36. package/lib/math/repeg.js +0 -178
  37. package/src/accounts/bulkUserSubscription.js +0 -56
  38. package/src/accounts/bulkUserSubscription.js.map +0 -1
  39. package/src/accounts/pollingClearingHouseAccountSubscriber.js +0 -210
  40. package/src/accounts/pollingClearingHouseAccountSubscriber.js.map +0 -1
  41. package/src/accounts/pollingOracleSubscriber.js +0 -65
  42. package/src/accounts/pollingOracleSubscriber.js.map +0 -1
  43. package/src/accounts/pollingTokenAccountSubscriber.js +0 -65
  44. package/src/accounts/pollingTokenAccountSubscriber.js.map +0 -1
  45. package/src/accounts/pollingUserAccountSubscriber.js +0 -139
  46. package/src/accounts/pollingUserAccountSubscriber.js.map +0 -1
  47. package/src/accounts/types.js +0 -11
  48. package/src/accounts/types.js.map +0 -1
  49. package/src/accounts/utils.js +0 -8
  50. package/src/accounts/utils.js.map +0 -1
  51. package/src/accounts/webSocketAccountSubscriber.js +0 -64
  52. package/src/accounts/webSocketAccountSubscriber.js.map +0 -1
  53. package/src/accounts/webSocketClearingHouseAccountSubscriber.js +0 -212
  54. package/src/accounts/webSocketClearingHouseAccountSubscriber.js.map +0 -1
  55. package/src/accounts/webSocketUserAccountSubscriber.js +0 -78
  56. package/src/accounts/webSocketUserAccountSubscriber.js.map +0 -1
  57. package/src/constants/markets.js +0 -167
  58. package/src/constants/markets.js.map +0 -1
  59. package/src/constants/numericConstants.js +0 -22
  60. package/src/constants/numericConstants.js.map +0 -1
  61. package/src/factory/clearingHouse.js +0 -65
  62. package/src/factory/clearingHouse.js.map +0 -1
  63. package/src/factory/clearingHouseUser.js +0 -35
  64. package/src/factory/clearingHouseUser.js.map +0 -1
  65. package/src/factory/oracleClient.js +0 -17
  66. package/src/factory/oracleClient.js.map +0 -1
  67. package/src/math/amm.js +0 -285
  68. package/src/math/amm.js.map +0 -1
  69. package/src/math/repeg.ts +0 -253
  70. package/src/oracles/pythClient.js +0 -39
  71. package/src/oracles/pythClient.js.map +0 -1
  72. package/src/tx/retryTxSender.js +0 -137
  73. package/src/tx/retryTxSender.js.map +0 -1
@@ -24,6 +24,8 @@ import { getClearingHouseStateAccountPublicKey } from '../addresses';
24
24
  import { BulkAccountLoader } from './bulkAccountLoader';
25
25
  import { capitalize } from './utils';
26
26
  import { ClearingHouseConfigType } from '../factory/clearingHouse';
27
+ import { PublicKey } from '@solana/web3.js';
28
+ import { CLEARING_HOUSE_STATE_ACCOUNTS } from '../constants/accounts';
27
29
 
28
30
  export class PollingClearingHouseAccountSubscriber
29
31
  implements ClearingHouseAccountSubscriber
@@ -98,44 +100,38 @@ export class PollingClearingHouseAccountSubscriber
98
100
  return;
99
101
  }
100
102
 
101
- const statePublicKey = await getClearingHouseStateAccountPublicKey(
102
- this.program.programId
103
- );
104
-
105
- const state = (await this.program.account.state.fetch(
106
- statePublicKey
107
- )) as StateAccount;
103
+ const accounts = await this.getClearingHouseAccounts();
108
104
 
109
- this.accountsToPoll.set(statePublicKey.toString(), {
105
+ this.accountsToPoll.set(accounts.state.toString(), {
110
106
  key: 'state',
111
- publicKey: statePublicKey,
107
+ publicKey: accounts.state,
112
108
  eventType: 'stateAccountUpdate',
113
109
  });
114
110
 
115
- this.accountsToPoll.set(state.markets.toString(), {
111
+ this.accountsToPoll.set(accounts.markets.toString(), {
116
112
  key: 'markets',
117
- publicKey: state.markets,
113
+ publicKey: accounts.markets,
118
114
  eventType: 'marketsAccountUpdate',
119
115
  });
120
116
 
121
- this.accountsToPoll.set(state.orderState.toString(), {
117
+ this.accountsToPoll.set(accounts.orderState.toString(), {
122
118
  key: 'orderState',
123
- publicKey: state.orderState,
119
+ publicKey: accounts.orderState,
124
120
  eventType: 'orderStateAccountUpdate',
125
121
  });
126
122
 
127
123
  if (this.optionalExtraSubscriptions?.includes('tradeHistoryAccount')) {
128
- this.accountsToPoll.set(state.tradeHistory.toString(), {
124
+ this.accountsToPoll.set(accounts.tradeHistory.toString(), {
129
125
  key: 'tradeHistory',
130
- publicKey: state.tradeHistory,
126
+ publicKey: accounts.tradeHistory,
131
127
  eventType: 'tradeHistoryAccountUpdate',
132
128
  });
133
129
  }
134
130
 
135
131
  if (this.optionalExtraSubscriptions?.includes('depositHistoryAccount')) {
136
- this.accountsToPoll.set(state.depositHistory.toString(), {
132
+ this.accountsToPoll.set(accounts.depositHistory.toString(), {
137
133
  key: 'depositHistory',
138
- publicKey: state.depositHistory,
134
+ publicKey: accounts.depositHistory,
139
135
  eventType: 'depositHistoryAccountUpdate',
140
136
  });
141
137
  }
@@ -143,9 +139,9 @@ export class PollingClearingHouseAccountSubscriber
143
139
  if (
144
140
  this.optionalExtraSubscriptions?.includes('fundingPaymentHistoryAccount')
145
141
  ) {
146
- this.accountsToPoll.set(state.fundingPaymentHistory.toString(), {
142
+ this.accountsToPoll.set(accounts.fundingPaymentHistory.toString(), {
147
143
  key: 'fundingPaymentHistory',
148
- publicKey: state.fundingPaymentHistory,
144
+ publicKey: accounts.fundingPaymentHistory,
149
145
  eventType: 'fundingPaymentHistoryAccountUpdate',
150
146
  });
151
147
  }
@@ -153,17 +149,17 @@ export class PollingClearingHouseAccountSubscriber
153
149
  if (
154
150
  this.optionalExtraSubscriptions?.includes('fundingRateHistoryAccount')
155
151
  ) {
156
- this.accountsToPoll.set(state.fundingRateHistory.toString(), {
152
+ this.accountsToPoll.set(accounts.fundingRateHistory.toString(), {
157
153
  key: 'fundingRateHistory',
158
- publicKey: state.fundingRateHistory,
154
+ publicKey: accounts.fundingRateHistory,
159
155
  eventType: 'fundingRateHistoryAccountUpdate',
160
156
  });
161
157
  }
162
158
 
163
159
  if (this.optionalExtraSubscriptions?.includes('curveHistoryAccount')) {
164
- this.accountsToPoll.set(state.extendedCurveHistory.toString(), {
160
+ this.accountsToPoll.set(accounts.extendedCurveHistory.toString(), {
165
161
  key: 'extendedCurveHistory',
166
- publicKey: state.extendedCurveHistory,
162
+ publicKey: accounts.extendedCurveHistory,
167
163
  eventType: 'curveHistoryAccountUpdate',
168
164
  });
169
165
  }
@@ -171,24 +167,58 @@ export class PollingClearingHouseAccountSubscriber
171
167
  if (
172
168
  this.optionalExtraSubscriptions?.includes('liquidationHistoryAccount')
173
169
  ) {
174
- this.accountsToPoll.set(state.liquidationHistory.toString(), {
170
+ this.accountsToPoll.set(accounts.liquidationHistory.toString(), {
175
171
  key: 'liquidationHistory',
176
- publicKey: state.liquidationHistory,
172
+ publicKey: accounts.liquidationHistory,
177
173
  eventType: 'liquidationHistoryAccountUpdate',
178
174
  });
179
175
  }
180
176
 
177
+ if (this.optionalExtraSubscriptions?.includes('orderHistoryAccount')) {
178
+ this.accountsToPoll.set(accounts.orderHistory.toString(), {
179
+ key: 'orderHistory',
180
+ publicKey: accounts.orderHistory,
181
+ eventType: 'orderHistoryAccountUpdate',
182
+ });
183
+ }
184
+ }
185
+
186
+ async getClearingHouseAccounts(): Promise<ClearingHouseAccounts> {
187
+ // Skip extra calls to rpc if we already know all the accounts
188
+ if (CLEARING_HOUSE_STATE_ACCOUNTS[this.program.programId.toString()]) {
189
+ return CLEARING_HOUSE_STATE_ACCOUNTS[this.program.programId.toString()];
190
+ }
191
+
192
+ const statePublicKey = await getClearingHouseStateAccountPublicKey(
193
+ this.program.programId
194
+ );
195
+
196
+ const state = (await this.program.account.state.fetch(
197
+ statePublicKey
198
+ )) as StateAccount;
199
+
200
+ const accounts = {
201
+ state: statePublicKey,
202
+ markets: state.markets,
203
+ orderState: state.orderState,
204
+ tradeHistory: state.tradeHistory,
205
+ depositHistory: state.depositHistory,
206
+ fundingPaymentHistory: state.fundingPaymentHistory,
207
+ fundingRateHistory: state.fundingRateHistory,
208
+ extendedCurveHistory: state.extendedCurveHistory,
209
+ liquidationHistory: state.liquidationHistory,
210
+ orderHistory: undefined,
211
+ };
212
+
181
213
  if (this.optionalExtraSubscriptions?.includes('orderHistoryAccount')) {
182
214
  const orderState = (await this.program.account.orderState.fetch(
183
215
  state.orderState
184
216
  )) as OrderStateAccount;
185
217
 
186
- this.accountsToPoll.set(orderState.orderHistory.toString(), {
187
- key: 'orderHistory',
188
- publicKey: orderState.orderHistory,
189
- eventType: 'orderHistoryAccountUpdate',
190
- });
218
+ accounts.orderHistory = orderState.orderHistory;
191
219
  }
220
+
221
+ return accounts;
192
222
  }
193
223
 
194
224
  async addToAccountLoader(): Promise<void> {
@@ -324,3 +354,16 @@ export class PollingClearingHouseAccountSubscriber
324
354
  return this.orderHistory;
325
355
  }
326
356
  }
357
+
358
+ type ClearingHouseAccounts = {
359
+ state: PublicKey;
360
+ markets: PublicKey;
361
+ orderState: PublicKey;
362
+ tradeHistory?: PublicKey;
363
+ depositHistory?: PublicKey;
364
+ fundingPaymentHistory?: PublicKey;
365
+ fundingRateHistory?: PublicKey;
366
+ extendedCurveHistory?: PublicKey;
367
+ liquidationHistory?: PublicKey;
368
+ orderHistory?: PublicKey;
369
+ };
@@ -21,6 +21,7 @@ import {
21
21
  OrderParams,
22
22
  Order,
23
23
  ExtendedCurveHistoryAccount,
24
+ UserPositionsAccount,
24
25
  } from './types';
25
26
  import * as anchor from '@project-serum/anchor';
26
27
  import clearingHouseIDL from './idl/clearing_house.json';
@@ -542,19 +543,6 @@ export class ClearingHouse {
542
543
  return [txSig, userAccountPublicKey];
543
544
  }
544
545
 
545
- public async deleteUser(): Promise<TransactionSignature> {
546
- const userAccountPublicKey = await this.getUserAccountPublicKey();
547
- const user = await this.program.account.user.fetch(userAccountPublicKey);
548
- const deleteUserTx = await this.program.transaction.deleteUser({
549
- accounts: {
550
- user: userAccountPublicKey,
551
- userPositions: user.positions,
552
- authority: this.wallet.publicKey,
553
- },
554
- });
555
- return this.txSender.send(deleteUserTx, [], this.opts);
556
- }
557
-
558
546
  public async withdrawCollateral(
559
547
  amount: BN,
560
548
  collateralAccountPublicKey: PublicKey
@@ -922,6 +910,51 @@ export class ClearingHouse {
922
910
  });
923
911
  }
924
912
 
913
+ public async cancelAllOrders(
914
+ oracles?: PublicKey[]
915
+ ): Promise<TransactionSignature> {
916
+ return await this.txSender.send(
917
+ wrapInTx(await this.getCancelAllOrdersIx(oracles)),
918
+ [],
919
+ this.opts
920
+ );
921
+ }
922
+
923
+ public async getCancelAllOrdersIx(
924
+ oracles: PublicKey[]
925
+ ): Promise<TransactionInstruction> {
926
+ const userAccountPublicKey = await this.getUserAccountPublicKey();
927
+ const userAccount = await this.getUserAccount();
928
+
929
+ const state = this.getStateAccount();
930
+ const orderState = this.getOrderStateAccount();
931
+
932
+ const remainingAccounts = [];
933
+ for (const oracle of oracles) {
934
+ remainingAccounts.push({
935
+ pubkey: oracle,
936
+ isWritable: false,
937
+ isSigner: false,
938
+ });
939
+ }
940
+
941
+ return await this.program.instruction.cancelAllOrders({
942
+ accounts: {
943
+ state: await this.getStatePublicKey(),
944
+ user: userAccountPublicKey,
945
+ authority: this.wallet.publicKey,
946
+ markets: state.markets,
947
+ userOrders: await this.getUserOrdersAccountPublicKey(),
948
+ userPositions: userAccount.positions,
949
+ fundingPaymentHistory: state.fundingPaymentHistory,
950
+ fundingRateHistory: state.fundingRateHistory,
951
+ orderState: await this.getOrderStatePublicKey(),
952
+ orderHistory: orderState.orderHistory,
953
+ },
954
+ remainingAccounts,
955
+ });
956
+ }
957
+
925
958
  public async fillOrder(
926
959
  userAccountPublicKey: PublicKey,
927
960
  userOrdersAccountPublicKey: PublicKey,
@@ -1160,6 +1193,31 @@ export class ClearingHouse {
1160
1193
  );
1161
1194
  }
1162
1195
 
1196
+ public async closeAllPositions(
1197
+ userPositionsAccount: UserPositionsAccount,
1198
+ discountToken?: PublicKey,
1199
+ referrer?: PublicKey
1200
+ ): Promise<TransactionSignature> {
1201
+ const ixs: TransactionInstruction[] = [];
1202
+ for (const userPosition of userPositionsAccount.positions) {
1203
+ if (userPosition.baseAssetAmount.eq(ZERO)) {
1204
+ continue;
1205
+ }
1206
+
1207
+ ixs.push(
1208
+ await this.getClosePositionIx(
1209
+ userPosition.marketIndex,
1210
+ discountToken,
1211
+ referrer
1212
+ )
1213
+ );
1214
+ }
1215
+
1216
+ const tx = new Transaction().add(...ixs);
1217
+
1218
+ return this.txSender.send(tx, [], this.opts);
1219
+ }
1220
+
1163
1221
  public async liquidate(
1164
1222
  liquidateeUserAccountPublicKey: PublicKey
1165
1223
  ): Promise<TransactionSignature> {
@@ -0,0 +1,26 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+
3
+ export const CLEARING_HOUSE_STATE_ACCOUNTS = {
4
+ dammHkt7jmytvbS3nHTxQNEcP59aE57nxwV21YdqEDN: {
5
+ state: new PublicKey('FExhvPycCCwYnZGeDsVtLhpEQ3yEkVY2k1HuPyfLj91L'),
6
+ markets: new PublicKey('773hq3SbGPKVj93TXi5qV5CREuhxobywfALjS3XVHhLH'),
7
+ orderState: new PublicKey('4cC34bWwTPGncBaX2S6v5mH3Lj4Nb3byPMrxQSDcY985'),
8
+ tradeHistory: new PublicKey('FCuCXEoQppoaCYdttA7rK3HNQfYkTNEGpwuBESzYcENp'),
9
+ depositHistory: new PublicKey(
10
+ 'C7rF2Qy2rnDGQLRijBRRArJyaeuQcFi81BXDrUCQ45ya'
11
+ ),
12
+ fundingPaymentHistory: new PublicKey(
13
+ '895iPhzwT2tBufLnRpYtBG3gif1HDDUfpH2AqbS5joo4'
14
+ ),
15
+ fundingRateHistory: new PublicKey(
16
+ 'BWiJLMbmrwfqHVpcPJa8715XamNyNYamDDKQVQMnduEC'
17
+ ),
18
+ extendedCurveHistory: new PublicKey(
19
+ '7vBbqvMdtZLQdTVdzt5y63pZdAFE5W42kP3avngSJKCk'
20
+ ),
21
+ liquidationHistory: new PublicKey(
22
+ 'CSFaaf8yVoTx6NcXUKtNPYAewv76CH2jATqSVRBvUWKM'
23
+ ),
24
+ orderHistory: new PublicKey('DZ7XfUqyHoRKnJLRApxmJ943xHJ7NDBUTqpbooviEtbU'),
25
+ },
26
+ };
@@ -187,6 +187,17 @@ export const Markets: MarketConfig[] = [
187
187
  launchTs: 1648607439000,
188
188
  oracleSource: OracleSource.PYTH,
189
189
  },
190
+ {
191
+ fullName: 'Near',
192
+ category: ['L1', 'Infra'],
193
+ symbol: 'NEAR-PERP',
194
+ baseAssetSymbol: 'NEAR',
195
+ marketIndex: new BN(16),
196
+ devnetPublicKey: '3gnSbT7bhoTdGkFVZc1dW1PvjreWzpUNUD5ppXwv1N59',
197
+ mainnetPublicKey: 'ECSFWQ1bnnpqPVvoy9237t2wddZAaHisW88mYxuEHKWf',
198
+ launchTs: 1649105516000,
199
+ oracleSource: OracleSource.PYTH,
200
+ },
190
201
  // {
191
202
  // symbol: 'mSOL-PERP',
192
203
  // baseAssetSymbol: 'mSOL',
@@ -10,6 +10,7 @@ import { DefaultTxSender } from '../tx/defaultTxSender';
10
10
  import { ClearingHouseAccountSubscriber } from '../accounts/types';
11
11
  import { PollingClearingHouseAccountSubscriber } from '../accounts/pollingClearingHouseAccountSubscriber';
12
12
  import { Admin } from '../admin';
13
+ import { RetryTxSender } from '../tx/retryTxSender';
13
14
 
14
15
  export type ClearingHouseConfigType = 'websocket' | 'polling' | 'custom';
15
16
 
@@ -19,7 +20,7 @@ type BaseClearingHouseConfig = {
19
20
  wallet: IWallet;
20
21
  programID: PublicKey;
21
22
  opts?: ConfirmOptions;
22
- txSender?: TxSender;
23
+ txSenderConfig?: TxSenderConfig;
23
24
  };
24
25
 
25
26
  type WebSocketClearingHouseConfiguration = BaseClearingHouseConfig;
@@ -32,12 +33,28 @@ type ClearingHouseConfig =
32
33
  | PollingClearingHouseConfiguration
33
34
  | WebSocketClearingHouseConfiguration;
34
35
 
36
+ export type TxSenderType = 'default' | 'retry';
37
+
38
+ type BaseTxSenderConfig = {
39
+ type: TxSenderType;
40
+ };
41
+
42
+ type DefaultTxSenderConfig = BaseTxSenderConfig;
43
+
44
+ type RetryTxSenderConfig = BaseTxSenderConfig & {
45
+ timeout?: number;
46
+ retrySleep?: number;
47
+ additionalConnections?: Connection[];
48
+ };
49
+
50
+ type TxSenderConfig = DefaultTxSenderConfig | RetryTxSenderConfig;
51
+
35
52
  export function getWebSocketClearingHouseConfig(
36
53
  connection: Connection,
37
54
  wallet: IWallet,
38
55
  programID: PublicKey,
39
56
  opts: ConfirmOptions = Provider.defaultOptions(),
40
- txSender?: TxSender
57
+ txSenderConfig?: TxSenderConfig
41
58
  ): WebSocketClearingHouseConfiguration {
42
59
  return {
43
60
  type: 'websocket',
@@ -45,7 +62,7 @@ export function getWebSocketClearingHouseConfig(
45
62
  wallet,
46
63
  programID,
47
64
  opts,
48
- txSender,
65
+ txSenderConfig,
49
66
  };
50
67
  }
51
68
 
@@ -55,7 +72,7 @@ export function getPollingClearingHouseConfig(
55
72
  programID: PublicKey,
56
73
  accountLoader: BulkAccountLoader,
57
74
  opts: ConfirmOptions = Provider.defaultOptions(),
58
- txSender?: TxSender
75
+ txSenderConfig?: TxSenderConfig
59
76
  ): PollingClearingHouseConfiguration {
60
77
  return {
61
78
  type: 'polling',
@@ -64,7 +81,7 @@ export function getPollingClearingHouseConfig(
64
81
  programID,
65
82
  accountLoader,
66
83
  opts,
67
- txSender,
84
+ txSenderConfig,
68
85
  };
69
86
  }
70
87
 
@@ -85,7 +102,19 @@ export function getClearingHouse(config: ClearingHouseConfig): ClearingHouse {
85
102
  );
86
103
  }
87
104
 
88
- const txSender = config.txSender || new DefaultTxSender(provider);
105
+ let txSender: TxSender;
106
+ if (config.txSenderConfig?.type === 'retry') {
107
+ const txSenderConfig = config.txSenderConfig as RetryTxSenderConfig;
108
+ txSender = new RetryTxSender(
109
+ provider,
110
+ txSenderConfig.timeout,
111
+ txSenderConfig.retrySleep,
112
+ txSenderConfig.additionalConnections
113
+ );
114
+ } else {
115
+ txSender = new DefaultTxSender(provider);
116
+ }
117
+
89
118
  return new ClearingHouse(
90
119
  config.connection,
91
120
  config.wallet,
@@ -113,7 +142,18 @@ export function getAdmin(config: ClearingHouseConfig): Admin {
113
142
  );
114
143
  }
115
144
 
116
- const txSender = config.txSender || new DefaultTxSender(provider);
145
+ let txSender: TxSender;
146
+ if (config.txSenderConfig?.type === 'retry') {
147
+ const txSenderConfig = config.txSenderConfig as RetryTxSenderConfig;
148
+ txSender = new RetryTxSender(
149
+ provider,
150
+ txSenderConfig.timeout,
151
+ txSenderConfig.retrySleep,
152
+ txSenderConfig.additionalConnections
153
+ );
154
+ } else {
155
+ txSender = new DefaultTxSender(provider);
156
+ }
117
157
  return new Admin(
118
158
  config.connection,
119
159
  config.wallet,
@@ -677,6 +677,57 @@
677
677
  }
678
678
  ]
679
679
  },
680
+ {
681
+ "name": "cancelAllOrders",
682
+ "accounts": [
683
+ {
684
+ "name": "state",
685
+ "isMut": false,
686
+ "isSigner": false
687
+ },
688
+ {
689
+ "name": "orderState",
690
+ "isMut": false,
691
+ "isSigner": false
692
+ },
693
+ {
694
+ "name": "user",
695
+ "isMut": false,
696
+ "isSigner": false
697
+ },
698
+ {
699
+ "name": "authority",
700
+ "isMut": false,
701
+ "isSigner": true
702
+ },
703
+ {
704
+ "name": "markets",
705
+ "isMut": false,
706
+ "isSigner": false
707
+ },
708
+ {
709
+ "name": "userPositions",
710
+ "isMut": true,
711
+ "isSigner": false
712
+ },
713
+ {
714
+ "name": "userOrders",
715
+ "isMut": true,
716
+ "isSigner": false
717
+ },
718
+ {
719
+ "name": "fundingPaymentHistory",
720
+ "isMut": true,
721
+ "isSigner": false
722
+ },
723
+ {
724
+ "name": "orderHistory",
725
+ "isMut": true,
726
+ "isSigner": false
727
+ }
728
+ ],
729
+ "args": []
730
+ },
680
731
  {
681
732
  "name": "expireOrders",
682
733
  "accounts": [
@@ -1431,32 +1482,6 @@
1431
1482
  }
1432
1483
  ]
1433
1484
  },
1434
- {
1435
- "name": "deleteUser",
1436
- "accounts": [
1437
- {
1438
- "name": "user",
1439
- "isMut": true,
1440
- "isSigner": false
1441
- },
1442
- {
1443
- "name": "userPositions",
1444
- "isMut": true,
1445
- "isSigner": false
1446
- },
1447
- {
1448
- "name": "userOrders",
1449
- "isMut": true,
1450
- "isSigner": false
1451
- },
1452
- {
1453
- "name": "authority",
1454
- "isMut": false,
1455
- "isSigner": true
1456
- }
1457
- ],
1458
- "args": []
1459
- },
1460
1485
  {
1461
1486
  "name": "settleFundingPayment",
1462
1487
  "accounts": [
@@ -3241,8 +3266,8 @@
3241
3266
  "type": "u128"
3242
3267
  },
3243
3268
  {
3244
- "name": "netRevenueSinceLastFunding",
3245
- "type": "i64"
3269
+ "name": "padding1",
3270
+ "type": "u64"
3246
3271
  },
3247
3272
  {
3248
3273
  "name": "padding2",
@@ -4249,11 +4274,6 @@
4249
4274
  "code": 6060,
4250
4275
  "name": "CantExpireOrders",
4251
4276
  "msg": "CantExpireOrders"
4252
- },
4253
- {
4254
- "code": 6061,
4255
- "name": "InvalidRepegPriceImpact",
4256
- "msg": "AMM repeg mark price impact vs oracle too large"
4257
4277
  }
4258
4278
  ]
4259
4279
  }