@drift-labs/sdk 0.2.0-master.4 → 0.2.0-master.41

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 (247) hide show
  1. package/README.md +27 -27
  2. package/lib/accounts/bulkAccountLoader.d.ts +2 -0
  3. package/lib/accounts/bulkAccountLoader.js +36 -29
  4. package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
  5. package/lib/accounts/bulkUserStatsSubscription.js +21 -0
  6. package/lib/accounts/bulkUserSubscription.d.ts +2 -2
  7. package/lib/accounts/bulkUserSubscription.js +0 -1
  8. package/lib/accounts/fetch.d.ts +2 -1
  9. package/lib/accounts/fetch.js +9 -1
  10. package/lib/accounts/{pollingClearingHouseAccountSubscriber.d.ts → pollingDriftClientAccountSubscriber.d.ts} +20 -25
  11. package/lib/accounts/{pollingClearingHouseAccountSubscriber.js → pollingDriftClientAccountSubscriber.js} +45 -49
  12. package/lib/accounts/{pollingOracleSubscriber.d.ts → pollingOracleAccountSubscriber.d.ts} +2 -2
  13. package/lib/accounts/{pollingOracleSubscriber.js → pollingOracleAccountSubscriber.js} +3 -3
  14. package/lib/accounts/pollingUserAccountSubscriber.d.ts +1 -1
  15. package/lib/accounts/pollingUserAccountSubscriber.js +5 -11
  16. package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
  17. package/lib/accounts/pollingUserStatsAccountSubscriber.js +107 -0
  18. package/lib/accounts/types.d.ts +26 -15
  19. package/lib/accounts/webSocketDriftClientAccountSubscriber.d.ts +49 -0
  20. package/lib/accounts/{webSocketClearingHouseAccountSubscriber.js → webSocketDriftClientAccountSubscriber.js} +47 -45
  21. package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
  22. package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
  23. package/lib/addresses/marketAddresses.d.ts +1 -3
  24. package/lib/addresses/marketAddresses.js +1 -1
  25. package/lib/addresses/pda.d.ts +15 -9
  26. package/lib/addresses/pda.js +73 -35
  27. package/lib/adminClient.d.ts +65 -0
  28. package/lib/adminClient.js +637 -0
  29. package/lib/config.d.ts +9 -9
  30. package/lib/config.js +25 -21
  31. package/lib/constants/numericConstants.d.ts +30 -12
  32. package/lib/constants/numericConstants.js +41 -21
  33. package/lib/constants/perpMarkets.d.ts +18 -0
  34. package/lib/constants/{markets.js → perpMarkets.js} +7 -7
  35. package/lib/constants/spotMarkets.d.ts +19 -0
  36. package/lib/constants/spotMarkets.js +53 -0
  37. package/lib/dlob/DLOB.d.ts +82 -0
  38. package/lib/dlob/DLOB.js +694 -0
  39. package/lib/dlob/DLOBNode.d.ts +54 -0
  40. package/lib/dlob/DLOBNode.js +77 -0
  41. package/lib/dlob/NodeList.d.ts +27 -0
  42. package/lib/dlob/NodeList.js +144 -0
  43. package/lib/driftClient.d.ts +234 -0
  44. package/lib/driftClient.js +2108 -0
  45. package/lib/{clearingHouseConfig.d.ts → driftClientConfig.d.ts} +9 -9
  46. package/lib/{clearingHouseConfig.js → driftClientConfig.js} +0 -0
  47. package/lib/events/eventList.js +3 -0
  48. package/lib/events/eventSubscriber.d.ts +5 -2
  49. package/lib/events/eventSubscriber.js +25 -11
  50. package/lib/events/fetchLogs.d.ts +13 -2
  51. package/lib/events/fetchLogs.js +40 -12
  52. package/lib/events/pollingLogProvider.d.ts +2 -1
  53. package/lib/events/pollingLogProvider.js +7 -3
  54. package/lib/events/sort.js +8 -11
  55. package/lib/events/types.d.ts +11 -3
  56. package/lib/events/types.js +8 -0
  57. package/lib/events/webSocketLogProvider.js +1 -1
  58. package/lib/examples/makeTradeExample.js +30 -18
  59. package/lib/factory/bigNum.d.ts +8 -4
  60. package/lib/factory/bigNum.js +109 -19
  61. package/lib/idl/drift.json +8386 -0
  62. package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
  63. package/lib/index.d.ts +30 -13
  64. package/lib/index.js +30 -13
  65. package/lib/math/amm.d.ts +9 -6
  66. package/lib/math/amm.js +91 -38
  67. package/lib/math/conversion.js +1 -1
  68. package/lib/math/exchangeStatus.d.ts +4 -0
  69. package/lib/math/exchangeStatus.js +18 -0
  70. package/lib/math/funding.d.ts +6 -6
  71. package/lib/math/funding.js +23 -21
  72. package/lib/math/insurance.d.ts +4 -0
  73. package/lib/math/insurance.js +27 -0
  74. package/lib/math/margin.d.ts +11 -0
  75. package/lib/math/margin.js +82 -0
  76. package/lib/math/market.d.ts +14 -9
  77. package/lib/math/market.js +70 -10
  78. package/lib/math/oracles.d.ts +4 -0
  79. package/lib/math/oracles.js +36 -8
  80. package/lib/math/orders.d.ts +16 -6
  81. package/lib/math/orders.js +97 -17
  82. package/lib/math/position.d.ts +27 -13
  83. package/lib/math/position.js +92 -36
  84. package/lib/math/repeg.js +17 -8
  85. package/lib/math/spotBalance.d.ts +22 -0
  86. package/lib/math/spotBalance.js +192 -0
  87. package/lib/math/spotMarket.d.ts +4 -0
  88. package/lib/math/spotMarket.js +8 -0
  89. package/lib/math/spotPosition.d.ts +6 -0
  90. package/lib/math/spotPosition.js +23 -0
  91. package/lib/math/trade.d.ts +10 -10
  92. package/lib/math/trade.js +27 -31
  93. package/lib/oracles/pythClient.js +1 -1
  94. package/lib/oracles/quoteAssetOracleClient.js +1 -1
  95. package/lib/oracles/switchboardClient.js +1 -1
  96. package/lib/orderParams.d.ts +4 -4
  97. package/lib/orderParams.js +12 -4
  98. package/lib/serum/serumFulfillmentConfigMap.d.ts +10 -0
  99. package/lib/serum/serumFulfillmentConfigMap.js +17 -0
  100. package/lib/serum/serumSubscriber.d.ts +27 -0
  101. package/lib/serum/serumSubscriber.js +56 -0
  102. package/lib/serum/types.d.ts +11 -0
  103. package/lib/{clearingHouseUserConfig.js → serum/types.js} +0 -0
  104. package/lib/slot/SlotSubscriber.d.ts +7 -0
  105. package/lib/slot/SlotSubscriber.js +3 -0
  106. package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
  107. package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
  108. package/lib/tx/retryTxSender.d.ts +1 -1
  109. package/lib/tx/retryTxSender.js +13 -4
  110. package/lib/tx/types.d.ts +1 -1
  111. package/lib/tx/utils.js +1 -1
  112. package/lib/types.d.ts +688 -216
  113. package/lib/types.js +153 -24
  114. package/lib/user.d.ts +228 -0
  115. package/lib/user.js +959 -0
  116. package/lib/userConfig.d.ts +14 -0
  117. package/lib/userConfig.js +2 -0
  118. package/lib/userMap/userMap.d.ts +41 -0
  119. package/lib/userMap/userMap.js +85 -0
  120. package/lib/userMap/userStatsMap.d.ts +19 -0
  121. package/lib/userMap/userStatsMap.js +68 -0
  122. package/lib/userName.d.ts +1 -0
  123. package/lib/userName.js +3 -2
  124. package/lib/userStats.d.ts +18 -0
  125. package/lib/userStats.js +49 -0
  126. package/lib/userStatsConfig.d.ts +14 -0
  127. package/lib/userStatsConfig.js +2 -0
  128. package/lib/util/computeUnits.js +1 -1
  129. package/lib/util/getTokenAddress.d.ts +2 -0
  130. package/lib/util/getTokenAddress.js +9 -0
  131. package/package.json +11 -4
  132. package/src/accounts/bulkAccountLoader.ts +44 -34
  133. package/src/accounts/bulkUserStatsSubscription.ts +33 -0
  134. package/src/accounts/bulkUserSubscription.ts +2 -3
  135. package/src/accounts/fetch.ts +27 -2
  136. package/src/accounts/{pollingClearingHouseAccountSubscriber.ts → pollingDriftClientAccountSubscriber.ts} +65 -75
  137. package/src/accounts/{pollingOracleSubscriber.ts → pollingOracleAccountSubscriber.ts} +2 -2
  138. package/src/accounts/pollingUserAccountSubscriber.ts +5 -12
  139. package/src/accounts/pollingUserStatsAccountSubscriber.ts +166 -0
  140. package/src/accounts/types.ts +35 -15
  141. package/src/accounts/{webSocketClearingHouseAccountSubscriber.ts → webSocketDriftClientAccountSubscriber.ts} +78 -73
  142. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
  143. package/src/addresses/marketAddresses.ts +3 -4
  144. package/src/addresses/pda.ts +105 -33
  145. package/src/adminClient.ts +1207 -0
  146. package/src/assert/assert.js +9 -0
  147. package/src/config.ts +37 -31
  148. package/src/constants/numericConstants.ts +58 -24
  149. package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
  150. package/src/constants/spotMarkets.ts +73 -0
  151. package/src/dlob/DLOB.ts +1120 -0
  152. package/src/dlob/DLOBNode.ts +155 -0
  153. package/src/dlob/NodeList.ts +195 -0
  154. package/src/driftClient.ts +3594 -0
  155. package/src/{clearingHouseConfig.ts → driftClientConfig.ts} +9 -8
  156. package/src/events/eventList.js +77 -0
  157. package/src/events/eventList.ts +3 -0
  158. package/src/events/eventSubscriber.ts +36 -14
  159. package/src/events/fetchLogs.ts +55 -13
  160. package/src/events/pollingLogProvider.ts +11 -3
  161. package/src/events/sort.ts +11 -15
  162. package/src/events/types.ts +27 -2
  163. package/src/events/webSocketLogProvider.ts +1 -1
  164. package/src/examples/makeTradeExample.js +157 -0
  165. package/src/examples/makeTradeExample.ts +44 -28
  166. package/src/factory/bigNum.ts +150 -22
  167. package/src/idl/drift.json +8386 -0
  168. package/src/idl/pyth.json +98 -2
  169. package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
  170. package/src/index.ts +30 -13
  171. package/src/math/amm.ts +161 -48
  172. package/src/math/conversion.ts +2 -2
  173. package/src/math/exchangeStatus.ts +31 -0
  174. package/src/math/funding.ts +41 -31
  175. package/src/math/insurance.ts +35 -0
  176. package/src/math/margin.ts +133 -0
  177. package/src/math/market.ts +143 -14
  178. package/src/math/oracles.ts +63 -9
  179. package/src/math/orders.ts +168 -26
  180. package/src/math/position.ts +136 -58
  181. package/src/math/repeg.ts +19 -9
  182. package/src/math/spotBalance.ts +319 -0
  183. package/src/math/spotMarket.ts +9 -0
  184. package/src/math/spotPosition.ts +47 -0
  185. package/src/math/trade.ts +33 -37
  186. package/src/oracles/pythClient.ts +2 -2
  187. package/src/oracles/quoteAssetOracleClient.ts +2 -2
  188. package/src/oracles/switchboardClient.ts +2 -2
  189. package/src/orderParams.ts +16 -8
  190. package/src/serum/serumFulfillmentConfigMap.ts +26 -0
  191. package/src/serum/serumSubscriber.ts +99 -0
  192. package/src/serum/types.ts +13 -0
  193. package/src/slot/SlotSubscriber.ts +11 -1
  194. package/src/token/index.js +38 -0
  195. package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
  196. package/src/tx/retryTxSender.ts +16 -5
  197. package/src/tx/types.js +2 -0
  198. package/src/tx/types.ts +2 -1
  199. package/src/tx/utils.js +17 -0
  200. package/src/tx/utils.ts +1 -1
  201. package/src/types.ts +650 -189
  202. package/src/user.ts +1599 -0
  203. package/src/{clearingHouseUserConfig.ts → userConfig.ts} +5 -5
  204. package/src/userMap/userMap.ts +124 -0
  205. package/src/userMap/userStatsMap.ts +108 -0
  206. package/src/userName.ts +2 -1
  207. package/src/userStats.ts +75 -0
  208. package/src/userStatsConfig.ts +18 -0
  209. package/src/util/computeUnits.js +21 -11
  210. package/src/util/computeUnits.ts +1 -1
  211. package/src/util/getTokenAddress.js +9 -0
  212. package/src/util/getTokenAddress.ts +18 -0
  213. package/src/util/promiseTimeout.js +14 -0
  214. package/src/util/tps.js +27 -0
  215. package/tests/bn/test.ts +46 -11
  216. package/tests/dlob/helpers.ts +620 -0
  217. package/tests/dlob/test.ts +4586 -0
  218. package/yarn-error.log +3160 -0
  219. package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +0 -49
  220. package/lib/admin.d.ts +0 -44
  221. package/lib/admin.js +0 -433
  222. package/lib/clearingHouse.d.ts +0 -133
  223. package/lib/clearingHouse.js +0 -931
  224. package/lib/clearingHouseUser.d.ts +0 -187
  225. package/lib/clearingHouseUser.js +0 -643
  226. package/lib/clearingHouseUserConfig.d.ts +0 -14
  227. package/lib/constants/banks.d.ts +0 -16
  228. package/lib/constants/banks.js +0 -34
  229. package/lib/constants/markets.d.ts +0 -19
  230. package/lib/idl/clearing_house.json +0 -3998
  231. package/lib/math/bankBalance.d.ts +0 -9
  232. package/lib/math/bankBalance.js +0 -75
  233. package/lib/math/state.d.ts +0 -8
  234. package/lib/math/state.js +0 -15
  235. package/lib/orders.d.ts +0 -8
  236. package/lib/orders.js +0 -134
  237. package/src/admin.ts +0 -722
  238. package/src/clearingHouse.ts +0 -1451
  239. package/src/clearingHouseUser.ts +0 -989
  240. package/src/constants/banks.ts +0 -43
  241. package/src/idl/clearing_house.json +0 -3998
  242. package/src/math/bankBalance.ts +0 -112
  243. package/src/math/state.ts +0 -14
  244. package/src/math/utils.js +0 -27
  245. package/src/math/utils.js.map +0 -1
  246. package/src/orders.ts +0 -244
  247. package/src/util/computeUnits.js.map +0 -1
package/lib/types.d.ts CHANGED
@@ -1,6 +1,111 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { PublicKey, Transaction } from '@solana/web3.js';
3
3
  import { BN } from '.';
4
+ export declare class ExchangeStatus {
5
+ static readonly ACTIVE: {
6
+ active: {};
7
+ };
8
+ static readonly FUNDING_PAUSED: {
9
+ fundingPaused: {};
10
+ };
11
+ static readonly AMM_PAUSED: {
12
+ ammPaused: {};
13
+ };
14
+ static readonly FILL_PAUSED: {
15
+ fillPaused: {};
16
+ };
17
+ static readonly LIQ_PAUSED: {
18
+ liqPaused: {};
19
+ };
20
+ static readonly WITHDRAW_PAUSED: {
21
+ withdrawPaused: {};
22
+ };
23
+ static readonly PAUSED: {
24
+ paused: {};
25
+ };
26
+ }
27
+ export declare class MarketStatus {
28
+ static readonly INITIALIZED: {
29
+ initialized: {};
30
+ };
31
+ static readonly ACTIVE: {
32
+ active: {};
33
+ };
34
+ static readonly FUNDING_PAUSED: {
35
+ fundingPaused: {};
36
+ };
37
+ static readonly AMM_PAUSED: {
38
+ ammPaused: {};
39
+ };
40
+ static readonly FILL_PAUSED: {
41
+ fillPaused: {};
42
+ };
43
+ static readonly WITHDRAW_PAUSED: {
44
+ withdrawPaused: {};
45
+ };
46
+ static readonly REDUCE_ONLY: {
47
+ reduceOnly: {};
48
+ };
49
+ static readonly SETTLEMENT: {
50
+ settlement: {};
51
+ };
52
+ static readonly DELISTED: {
53
+ delisted: {};
54
+ };
55
+ }
56
+ export declare class UserStatus {
57
+ static readonly ACTIVE: {
58
+ active: {};
59
+ };
60
+ static readonly BEING_LIQUIDATED: {
61
+ beingLiquidated: {};
62
+ };
63
+ static readonly BANKRUPT: {
64
+ bankrupt: {};
65
+ };
66
+ }
67
+ export declare class ContractType {
68
+ static readonly PERPETUAL: {
69
+ perpetual: {};
70
+ };
71
+ static readonly FUTURE: {
72
+ future: {};
73
+ };
74
+ }
75
+ export declare class ContractTier {
76
+ static readonly A: {
77
+ a: {};
78
+ };
79
+ static readonly B: {
80
+ b: {};
81
+ };
82
+ static readonly C: {
83
+ c: {};
84
+ };
85
+ static readonly SPECULATIVE: {
86
+ speculative: {};
87
+ };
88
+ static readonly ISOLATED: {
89
+ isolated: {};
90
+ };
91
+ }
92
+ export declare class AssetTier {
93
+ static readonly COLLATERAL: {
94
+ collateral: {};
95
+ };
96
+ static readonly PROTECTED: {
97
+ protected: {};
98
+ };
99
+ static readonly CROSS: {
100
+ cross: {};
101
+ };
102
+ static readonly ISOLATED: {
103
+ isolated: {};
104
+ };
105
+ static readonly UNLISTED: {
106
+ unlisted: {};
107
+ };
108
+ }
4
109
  export declare class SwapDirection {
5
110
  static readonly ADD: {
6
111
  add: {};
@@ -9,7 +114,7 @@ export declare class SwapDirection {
9
114
  remove: {};
10
115
  };
11
116
  }
12
- export declare class BankBalanceType {
117
+ export declare class SpotBalanceType {
13
118
  static readonly DEPOSIT: {
14
119
  deposit: {};
15
120
  };
@@ -25,6 +130,14 @@ export declare class PositionDirection {
25
130
  short: {};
26
131
  };
27
132
  }
133
+ export declare class DepositDirection {
134
+ static readonly DEPOSIT: {
135
+ deposit: {};
136
+ };
137
+ static readonly WITHDRAW: {
138
+ withdraw: {};
139
+ };
140
+ }
28
141
  export declare class OracleSource {
29
142
  static readonly PYTH: {
30
143
  pyth: {};
@@ -50,6 +163,15 @@ export declare class OrderType {
50
163
  market: {};
51
164
  };
52
165
  }
166
+ export declare type MarketTypeStr = 'perp' | 'spot';
167
+ export declare class MarketType {
168
+ static readonly SPOT: {
169
+ spot: {};
170
+ };
171
+ static readonly PERP: {
172
+ perp: {};
173
+ };
174
+ }
53
175
  export declare class OrderStatus {
54
176
  static readonly INIT: {
55
177
  init: {};
@@ -58,23 +180,6 @@ export declare class OrderStatus {
58
180
  open: {};
59
181
  };
60
182
  }
61
- export declare class OrderDiscountTier {
62
- static readonly NONE: {
63
- none: {};
64
- };
65
- static readonly FIRST: {
66
- first: {};
67
- };
68
- static readonly SECOND: {
69
- second: {};
70
- };
71
- static readonly THIRD: {
72
- third: {};
73
- };
74
- static readonly FOURTH: {
75
- fourth: {};
76
- };
77
- }
78
183
  export declare class OrderAction {
79
184
  static readonly PLACE: {
80
185
  place: {};
@@ -96,8 +201,8 @@ export declare class OrderActionExplanation {
96
201
  static readonly NONE: {
97
202
  none: {};
98
203
  };
99
- static readonly BREACHED_MARGIN_REQUIREMENT: {
100
- breachedMarginRequirement: {};
204
+ static readonly INSUFFICIENT_FREE_COLLATERAL: {
205
+ insufficientFreeCollateral: {};
101
206
  };
102
207
  static readonly ORACLE_PRICE_BREACHED_LIMIT_PRICE: {
103
208
  oraclePriceBreachedLimitPrice: {};
@@ -105,6 +210,30 @@ export declare class OrderActionExplanation {
105
210
  static readonly MARKET_ORDER_FILLED_TO_LIMIT_PRICE: {
106
211
  marketOrderFilledToLimitPrice: {};
107
212
  };
213
+ static readonly ORDER_EXPIRED: {
214
+ orderExpired: {};
215
+ };
216
+ static readonly LIQUIDATION: {
217
+ liquidation: {};
218
+ };
219
+ static readonly ORDER_FILLED_WITH_AMM: {
220
+ orderFilledWithAMM: {};
221
+ };
222
+ static readonly ORDER_FILLED_WITH_AMM_JIT: {
223
+ orderFilledWithAMMJit: {};
224
+ };
225
+ static readonly ORDER_FILLED_WITH_MATCH: {
226
+ orderFilledWithMatch: {};
227
+ };
228
+ static readonly MARKET_EXPIRED: {
229
+ marketExpired: {};
230
+ };
231
+ static readonly RISK_INCREASING_ORDER: {
232
+ riskingIncreasingOrder: {};
233
+ };
234
+ static readonly ORDER_FILLED_WITH_SERUM: {
235
+ orderFillWithSerum: {};
236
+ };
108
237
  }
109
238
  export declare class OrderTriggerCondition {
110
239
  static readonly ABOVE: {
@@ -113,15 +242,73 @@ export declare class OrderTriggerCondition {
113
242
  static readonly BELOW: {
114
243
  below: {};
115
244
  };
245
+ static readonly TRIGGERED_ABOVE: {
246
+ triggeredAbove: {};
247
+ };
248
+ static readonly TRIGGERED_BELOW: {
249
+ triggeredBelow: {};
250
+ };
251
+ }
252
+ export declare class SpotFulfillmentType {
253
+ static readonly SERUM_v3: {
254
+ serumV3: {};
255
+ };
256
+ }
257
+ export declare class SpotFulfillmentStatus {
258
+ static readonly ENABLED: {
259
+ enabled: {};
260
+ };
261
+ static readonly DISABLED: {
262
+ disabled: {};
263
+ };
264
+ }
265
+ export declare class DepositExplanation {
266
+ static readonly NONE: {
267
+ none: {};
268
+ };
269
+ static readonly TRANSFER: {
270
+ transfer: {};
271
+ };
272
+ }
273
+ export declare class SettlePnlExplanation {
274
+ static readonly NONE: {
275
+ none: {};
276
+ };
277
+ static readonly EXPIRED_POSITION: {
278
+ expiredPosition: {};
279
+ };
280
+ }
281
+ export declare class StakeAction {
282
+ static readonly STAKE: {
283
+ stake: {};
284
+ };
285
+ static readonly UNSTAKE_REQUEST: {
286
+ unstakeRequest: {};
287
+ };
288
+ static readonly UNSTAKE_CANCEL_REQUEST: {
289
+ unstakeCancelRequest: {};
290
+ };
291
+ static readonly UNSTAKE: {
292
+ unstake: {};
293
+ };
116
294
  }
117
295
  export declare function isVariant(object: unknown, type: string): boolean;
118
296
  export declare function isOneOfVariant(object: unknown, types: string[]): boolean;
297
+ export declare function getVariant(object: unknown): string;
119
298
  export declare enum TradeSide {
120
299
  None = 0,
121
300
  Buy = 1,
122
301
  Sell = 2
123
302
  }
124
303
  export declare type CandleResolution = '1' | '5' | '15' | '60' | '240' | 'D' | 'W' | 'M';
304
+ export declare type NewUserRecord = {
305
+ ts: BN;
306
+ userAuthority: PublicKey;
307
+ user: PublicKey;
308
+ subAccount: number;
309
+ name: number[];
310
+ referrer: PublicKey;
311
+ };
125
312
  export declare type DepositRecord = {
126
313
  ts: BN;
127
314
  userAuthority: PublicKey;
@@ -130,15 +317,34 @@ export declare type DepositRecord = {
130
317
  deposit?: any;
131
318
  withdraw?: any;
132
319
  };
133
- bankIndex: BN;
320
+ marketIndex: number;
134
321
  amount: BN;
135
- from?: PublicKey;
136
- to?: PublicKey;
322
+ oraclePrice: BN;
323
+ marketDepositBalance: BN;
324
+ marketWithdrawBalance: BN;
325
+ marketCumulativeDepositInterest: BN;
326
+ marketCumulativeBorrowInterest: BN;
327
+ totalDepositsAfter: BN;
328
+ totalWithdrawsAfter: BN;
329
+ depositRecordId: BN;
330
+ explanation: DepositExplanation;
331
+ transferUser?: PublicKey;
332
+ };
333
+ export declare type SpotInterestRecord = {
334
+ ts: BN;
335
+ marketIndex: number;
336
+ depositBalance: BN;
337
+ cumulativeDepositInterest: BN;
338
+ borrowBalance: BN;
339
+ cumulativeBorrowInterest: BN;
340
+ optimalUtilization: number;
341
+ optimalBorrowRate: number;
342
+ maxBorrowRate: number;
137
343
  };
138
344
  export declare type CurveRecord = {
139
345
  ts: BN;
140
346
  recordId: BN;
141
- marketIndex: BN;
347
+ marketIndex: number;
142
348
  pegMultiplierBefore: BN;
143
349
  baseAssetReserveBefore: BN;
144
350
  quoteAssetReserveBefore: BN;
@@ -149,140 +355,350 @@ export declare type CurveRecord = {
149
355
  sqrtKAfter: BN;
150
356
  baseAssetAmountLong: BN;
151
357
  baseAssetAmountShort: BN;
152
- baseAssetAmount: BN;
153
- openInterest: BN;
358
+ baseAssetAmountWithAmm: BN;
359
+ totalFee: BN;
360
+ totalFeeMinusDistributions: BN;
361
+ adjustmentCost: BN;
362
+ numberOfUsers: BN;
154
363
  oraclePrice: BN;
155
- tradeId: BN;
364
+ fillRecord: BN;
365
+ };
366
+ export declare type InsuranceFundRecord = {
367
+ ts: BN;
368
+ spotMarketIndex: BN;
369
+ perpMarketIndex: number;
370
+ userIfFactor: number;
371
+ totalIfFactor: number;
372
+ vaultAmountBefore: BN;
373
+ insuranceVaultAmountBefore: BN;
374
+ totalIfSharesBefore: BN;
375
+ totalIfSharesAfter: BN;
376
+ amount: BN;
377
+ };
378
+ export declare type InsuranceFundStakeRecord = {
379
+ ts: BN;
380
+ userAuthority: PublicKey;
381
+ action: StakeAction;
382
+ amount: BN;
383
+ marketIndex: number;
384
+ insuranceVaultAmountBefore: BN;
385
+ ifSharesBefore: BN;
386
+ userIfSharesBefore: BN;
387
+ totalIfSharesBefore: BN;
388
+ ifSharesAfter: BN;
389
+ userIfSharesAfter: BN;
390
+ totalIfSharesAfter: BN;
391
+ };
392
+ export declare type LPRecord = {
393
+ ts: BN;
394
+ user: PublicKey;
395
+ action: LPAction;
396
+ nShares: BN;
397
+ marketIndex: number;
398
+ deltaBaseAssetAmount: BN;
399
+ deltaQuoteAssetAmount: BN;
400
+ pnl: BN;
156
401
  };
402
+ export declare class LPAction {
403
+ static readonly ADD_LIQUIDITY: {
404
+ addLiquidity: {};
405
+ };
406
+ static readonly REMOVE_LIQUIDITY: {
407
+ removeLiquidity: {};
408
+ };
409
+ static readonly SETTLE_LIQUIDITY: {
410
+ settleLiquidity: {};
411
+ };
412
+ }
157
413
  export declare type FundingRateRecord = {
158
414
  ts: BN;
159
415
  recordId: BN;
160
- marketIndex: BN;
416
+ marketIndex: number;
161
417
  fundingRate: BN;
418
+ fundingRateLong: BN;
419
+ fundingRateShort: BN;
162
420
  cumulativeFundingRateLong: BN;
163
421
  cumulativeFundingRateShort: BN;
164
422
  oraclePriceTwap: BN;
165
423
  markPriceTwap: BN;
424
+ periodRevenue: BN;
425
+ baseAssetAmountWithAmm: BN;
426
+ baseAssetAmountWithUnsettledLp: BN;
166
427
  };
167
428
  export declare type FundingPaymentRecord = {
168
429
  ts: BN;
169
430
  userAuthority: PublicKey;
170
431
  user: PublicKey;
171
- marketIndex: BN;
432
+ marketIndex: number;
172
433
  fundingPayment: BN;
173
434
  baseAssetAmount: BN;
174
435
  userLastCumulativeFunding: BN;
175
- userLastFundingRateTs: BN;
176
436
  ammCumulativeFundingLong: BN;
177
437
  ammCumulativeFundingShort: BN;
178
438
  };
179
439
  export declare type LiquidationRecord = {
180
440
  ts: BN;
181
- recordId: BN;
182
- userAuthority: PublicKey;
183
441
  user: PublicKey;
184
- partial: boolean;
185
- baseAssetValue: BN;
186
- baseAssetValueClosed: BN;
187
- liquidationFee: BN;
188
- feeToLiquidator: BN;
189
- feeToInsuranceFund: BN;
190
442
  liquidator: PublicKey;
443
+ liquidationType: LiquidationType;
444
+ marginRequirement: BN;
191
445
  totalCollateral: BN;
192
- collateral: BN;
193
- unrealizedPnl: BN;
194
- marginRatio: BN;
446
+ marginFreed: BN;
447
+ liquidationId: number;
448
+ bankrupt: boolean;
449
+ canceledOrderIds: BN[];
450
+ liquidatePerp: LiquidatePerpRecord;
451
+ liquidateSpot: LiquidateSpotRecord;
452
+ liquidateBorrowForPerpPnl: LiquidateBorrowForPerpPnlRecord;
453
+ liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
454
+ perpBankruptcy: PerpBankruptcyRecord;
455
+ spotBankruptcy: SpotBankruptcyRecord;
456
+ };
457
+ export declare class LiquidationType {
458
+ static readonly LIQUIDATE_PERP: {
459
+ liquidatePerp: {};
460
+ };
461
+ static readonly LIQUIDATE_BORROW: {
462
+ liquidateBorrow: {};
463
+ };
464
+ static readonly LIQUIDATE_BORROW_FOR_PERP_PNL: {
465
+ liquidateBorrowForPerpPnl: {};
466
+ };
467
+ static readonly LIQUIDATE_PERP_PNL_FOR_DEPOSIT: {
468
+ liquidatePerpPnlForDeposit: {};
469
+ };
470
+ static readonly PERP_BANKRUPTCY: {
471
+ perpBankruptcy: {};
472
+ };
473
+ static readonly BORROW_BANKRUPTCY: {
474
+ borrowBankruptcy: {};
475
+ };
476
+ }
477
+ export declare type LiquidatePerpRecord = {
478
+ marketIndex: number;
479
+ oraclePrice: BN;
480
+ baseAssetAmount: BN;
481
+ quoteAssetAmount: BN;
482
+ lpShares: BN;
483
+ userOrderId: BN;
484
+ liquidatorOrderId: BN;
485
+ fillRecordId: BN;
486
+ liquidatorFee: BN;
487
+ ifFee: BN;
488
+ };
489
+ export declare type LiquidateSpotRecord = {
490
+ assetMarketIndex: number;
491
+ assetPrice: BN;
492
+ assetTransfer: BN;
493
+ liabilityMarketIndex: number;
494
+ liabilityPrice: BN;
495
+ liabilityTransfer: BN;
496
+ ifFee: BN;
497
+ };
498
+ export declare type LiquidateBorrowForPerpPnlRecord = {
499
+ perpMarketIndex: number;
500
+ marketOraclePrice: BN;
501
+ pnlTransfer: BN;
502
+ liabilityMarketIndex: number;
503
+ liabilityPrice: BN;
504
+ liabilityTransfer: BN;
505
+ };
506
+ export declare type LiquidatePerpPnlForDepositRecord = {
507
+ perpMarketIndex: number;
508
+ marketOraclePrice: BN;
509
+ pnlTransfer: BN;
510
+ assetMarketIndex: number;
511
+ assetPrice: BN;
512
+ assetTransfer: BN;
513
+ };
514
+ export declare type PerpBankruptcyRecord = {
515
+ marketIndex: number;
516
+ pnl: BN;
517
+ ifPayment: BN;
518
+ clawbackUser: PublicKey | null;
519
+ clawbackUserPayment: BN | null;
520
+ cumulativeFundingRateDelta: BN;
521
+ };
522
+ export declare type SpotBankruptcyRecord = {
523
+ marketIndex: number;
524
+ borrowAmount: BN;
525
+ cumulativeDepositInterestDelta: BN;
526
+ ifPayment: BN;
527
+ };
528
+ export declare type SettlePnlRecord = {
529
+ ts: BN;
530
+ user: PublicKey;
531
+ marketIndex: number;
532
+ pnl: BN;
533
+ baseAssetAmount: BN;
534
+ quoteAssetAmountAfter: BN;
535
+ quoteEntryAmount: BN;
536
+ settlePrice: BN;
537
+ explanation: SettlePnlExplanation;
195
538
  };
196
539
  export declare type OrderRecord = {
197
540
  ts: BN;
198
- taker: PublicKey;
199
- maker: PublicKey;
200
- takerOrder: Order;
201
- makerOrder: Order;
202
- takerUnsettledPnl: BN;
203
- makerUnsettledPnl: BN;
541
+ user: PublicKey;
542
+ order: Order;
543
+ };
544
+ export declare type OrderActionRecord = {
545
+ ts: BN;
204
546
  action: OrderAction;
205
547
  actionExplanation: OrderActionExplanation;
206
- filler: PublicKey;
207
- fillRecordId: BN;
208
- marketIndex: BN;
209
- baseAssetAmountFilled: BN;
210
- quoteAssetAmountFilled: BN;
211
- makerRebate: BN;
212
- takerFee: BN;
213
- fillerReward: BN;
214
- quoteAssetAmountSurplus: BN;
548
+ marketIndex: number;
549
+ marketType: MarketType;
550
+ filler: PublicKey | null;
551
+ fillerReward: BN | null;
552
+ fillRecordId: BN | null;
553
+ baseAssetAmountFilled: BN | null;
554
+ quoteAssetAmountFilled: BN | null;
555
+ takerFee: BN | null;
556
+ makerFee: BN | null;
557
+ referrerReward: number | null;
558
+ quoteAssetAmountSurplus: BN | null;
559
+ spot_fulfillment_method_fee: BN | null;
560
+ taker: PublicKey | null;
561
+ takerOrderId: number | null;
562
+ takerOrderDirection: PositionDirection | null;
563
+ takerOrderBaseAssetAmount: BN | null;
564
+ takerOrderCumulativeBaseAssetAmountFilled: BN | null;
565
+ takerOrderCumulativeQuoteAssetAmountFilled: BN | null;
566
+ maker: PublicKey | null;
567
+ makerOrderId: number | null;
568
+ makerOrderDirection: PositionDirection | null;
569
+ makerOrderBaseAssetAmount: BN | null;
570
+ makerOrderCumulativeBaseAssetAmountFilled: BN | null;
571
+ makerOrderCumulativeQuoteAssetAmountFilled: BN | null;
215
572
  oraclePrice: BN;
216
573
  };
217
574
  export declare type StateAccount = {
218
575
  admin: PublicKey;
219
- fundingPaused: boolean;
220
- exchangePaused: boolean;
221
- adminControlsPrices: boolean;
222
- insuranceVault: PublicKey;
223
- insuranceVaultAuthority: PublicKey;
224
- insuranceVaultNonce: number;
225
- marginRatioInitial: BN;
226
- marginRatioMaintenance: BN;
227
- marginRatioPartial: BN;
228
- partialLiquidationClosePercentageNumerator: BN;
229
- partialLiquidationClosePercentageDenominator: BN;
230
- partialLiquidationPenaltyPercentageNumerator: BN;
231
- partialLiquidationPenaltyPercentageDenominator: BN;
232
- fullLiquidationPenaltyPercentageNumerator: BN;
233
- fullLiquidationPenaltyPercentageDenominator: BN;
234
- partialLiquidationLiquidatorShareDenominator: BN;
235
- fullLiquidationLiquidatorShareDenominator: BN;
236
- feeStructure: FeeStructure;
237
- totalFee: BN;
238
- totalFeeWithdrawn: BN;
576
+ exchangeStatus: ExchangeStatus;
239
577
  whitelistMint: PublicKey;
240
578
  discountMint: PublicKey;
241
579
  oracleGuardRails: OracleGuardRails;
242
- maxDeposit: BN;
243
- numberOfMarkets: BN;
244
- numberOfBanks: BN;
245
- minOrderQuoteAssetAmount: BN;
246
- };
247
- export declare type MarketAccount = {
248
- initialized: boolean;
249
- marketIndex: BN;
580
+ numberOfAuthorities: BN;
581
+ numberOfSubAccounts: BN;
582
+ numberOfMarkets: number;
583
+ numberOfSpotMarkets: number;
584
+ minPerpAuctionDuration: number;
585
+ defaultMarketOrderTimeInForce: number;
586
+ defaultSpotAuctionDuration: number;
587
+ liquidationMarginBufferRatio: number;
588
+ settlementDuration: number;
589
+ signer: PublicKey;
590
+ signerNonce: number;
591
+ srmVault: PublicKey;
592
+ perpFeeStructure: FeeStructure;
593
+ spotFeeStructure: FeeStructure;
594
+ lpCooldownTime: BN;
595
+ };
596
+ export declare type PerpMarketAccount = {
597
+ status: MarketStatus;
598
+ contractType: ContractType;
599
+ contractTier: ContractTier;
600
+ expiryTs: BN;
601
+ expiryPrice: BN;
602
+ marketIndex: number;
250
603
  pubkey: PublicKey;
604
+ name: number[];
251
605
  amm: AMM;
252
- baseAssetAmount: BN;
253
- baseAssetAmountLong: BN;
254
- baseAssetAmountShort: BN;
255
- openInterest: BN;
606
+ numberOfUsersWithBase: number;
607
+ numberOfUsers: number;
256
608
  marginRatioInitial: number;
257
609
  marginRatioMaintenance: number;
258
- marginRatioPartial: number;
259
610
  nextFillRecordId: BN;
611
+ nextFundingRateRecordId: BN;
612
+ nextCurveRecordId: BN;
260
613
  pnlPool: PoolBalance;
614
+ liquidatorFee: number;
615
+ ifLiquidationFee: number;
616
+ imfFactor: number;
617
+ unrealizedPnlImfFactor: number;
618
+ unrealizedPnlMaxImbalance: BN;
619
+ unrealizedPnlInitialAssetWeight: number;
620
+ unrealizedPnlMaintenanceAssetWeight: number;
621
+ insuranceClaim: {
622
+ revenueWithdrawSinceLastSettle: BN;
623
+ maxRevenueWithdrawPerPeriod: BN;
624
+ lastRevenueWithdrawTs: BN;
625
+ quoteSettledInsurance: BN;
626
+ quoteMaxInsurance: BN;
627
+ };
261
628
  };
262
- export declare type BankAccount = {
263
- bankIndex: BN;
629
+ export declare type HistoricalOracleData = {
630
+ lastOraclePrice: BN;
631
+ lastOracleDelay: BN;
632
+ lastOracleConf: BN;
633
+ lastOraclePriceTwap: BN;
634
+ lastOraclePriceTwap5Min: BN;
635
+ lastOraclePriceTwapTs: BN;
636
+ };
637
+ export declare type HistoricalIndexData = {
638
+ lastIndexBidPrice: BN;
639
+ lastIndexAskPrice: BN;
640
+ lastIndexPriceTwap: BN;
641
+ lastIndexPriceTwap5Min: BN;
642
+ lastIndexPriceTwapTs: BN;
643
+ };
644
+ export declare type SpotMarketAccount = {
645
+ status: MarketStatus;
646
+ assetTier: AssetTier;
647
+ marketIndex: number;
264
648
  pubkey: PublicKey;
265
649
  mint: PublicKey;
266
650
  vault: PublicKey;
267
- vaultAuthority: PublicKey;
268
- vaultAuthorityNonce: number;
651
+ oracle: PublicKey;
652
+ oracleSource: OracleSource;
653
+ historicalOracleData: HistoricalOracleData;
654
+ historicalIndexData: HistoricalIndexData;
655
+ insuranceFund: {
656
+ vault: PublicKey;
657
+ totalShares: BN;
658
+ userShares: BN;
659
+ sharesBase: BN;
660
+ unstakingPeriod: BN;
661
+ lastRevenueSettleTs: BN;
662
+ revenueSettlePeriod: BN;
663
+ totalFactor: number;
664
+ userFactor: number;
665
+ };
666
+ revenuePool: PoolBalance;
667
+ ifLiquidationFee: number;
269
668
  decimals: number;
270
- optimalUtilization: BN;
271
- optimalBorrowRate: BN;
272
- maxBorrowRate: BN;
669
+ optimalUtilization: number;
670
+ optimalBorrowRate: number;
671
+ maxBorrowRate: number;
273
672
  cumulativeDepositInterest: BN;
274
673
  cumulativeBorrowInterest: BN;
674
+ totalSocialLoss: BN;
675
+ totalQuoteSocialLoss: BN;
275
676
  depositBalance: BN;
276
677
  borrowBalance: BN;
277
- lastUpdated: BN;
278
- oracle: PublicKey;
279
- initialAssetWeight: BN;
280
- maintenanceAssetWeight: BN;
281
- initialLiabilityWeight: BN;
282
- maintenanceLiabilityWeight: BN;
678
+ maxTokenDeposits: BN;
679
+ lastInterestTs: BN;
680
+ lastTwapTs: BN;
681
+ initialAssetWeight: number;
682
+ maintenanceAssetWeight: number;
683
+ initialLiabilityWeight: number;
684
+ maintenanceLiabilityWeight: number;
685
+ liquidatorFee: number;
686
+ imfFactor: number;
687
+ withdrawGuardThreshold: BN;
688
+ depositTokenTwap: BN;
689
+ borrowTokenTwap: BN;
690
+ utilizationTwap: BN;
691
+ nextDepositRecordId: BN;
692
+ orderStepSize: BN;
693
+ orderTickSize: BN;
694
+ nextFillRecordId: BN;
695
+ spotFeePool: PoolBalance;
696
+ totalSpotFee: BN;
697
+ ordersEnabled: boolean;
283
698
  };
284
699
  export declare type PoolBalance = {
285
- balance: BN;
700
+ scaledBalance: BN;
701
+ marketIndex: number;
286
702
  };
287
703
  export declare type AMM = {
288
704
  baseAssetReserve: BN;
@@ -291,207 +707,242 @@ export declare type AMM = {
291
707
  lastFundingRate: BN;
292
708
  lastFundingRateTs: BN;
293
709
  lastMarkPriceTwap: BN;
710
+ lastMarkPriceTwap5Min: BN;
294
711
  lastMarkPriceTwapTs: BN;
295
- lastOraclePriceTwap: BN;
296
- lastOraclePriceTwapTs: BN;
297
- lastOracleMarkSpreadPct: BN;
298
- lastOracleConfPct: BN;
712
+ lastTradeTs: BN;
299
713
  oracle: PublicKey;
300
714
  oracleSource: OracleSource;
715
+ historicalOracleData: HistoricalOracleData;
716
+ lastOracleReservePriceSpreadPct: BN;
717
+ lastOracleConfPct: BN;
301
718
  fundingPeriod: BN;
302
719
  quoteAssetReserve: BN;
303
720
  pegMultiplier: BN;
304
721
  cumulativeFundingRateLong: BN;
305
722
  cumulativeFundingRateShort: BN;
306
- cumulativeRepegRebateLong: BN;
307
- cumulativeRepegRebateShort: BN;
723
+ last24hAvgFundingRate: BN;
724
+ lastFundingRateShort: BN;
725
+ lastFundingRateLong: BN;
726
+ totalLiquidationFee: BN;
308
727
  totalFeeMinusDistributions: BN;
309
728
  totalFeeWithdrawn: BN;
310
729
  totalFee: BN;
311
- minimumQuoteAssetTradeSize: BN;
312
- baseAssetAmountStepSize: BN;
313
- maxBaseAssetAmountRatio: number;
730
+ userLpShares: BN;
731
+ baseAssetAmountWithUnsettledLp: BN;
732
+ orderStepSize: BN;
733
+ orderTickSize: BN;
734
+ maxFillReserveFraction: number;
314
735
  maxSlippageRatio: number;
315
- lastOraclePrice: BN;
316
736
  baseSpread: number;
317
737
  curveUpdateIntensity: number;
318
- netBaseAssetAmount: BN;
319
- quoteAssetAmountLong: BN;
320
- quoteAssetAmountShort: BN;
738
+ baseAssetAmountWithAmm: BN;
739
+ baseAssetAmountLong: BN;
740
+ baseAssetAmountShort: BN;
741
+ quoteAssetAmount: BN;
321
742
  terminalQuoteAssetReserve: BN;
743
+ concentrationCoef: BN;
322
744
  feePool: PoolBalance;
323
745
  totalExchangeFee: BN;
324
746
  totalMmFee: BN;
325
747
  netRevenueSinceLastFunding: BN;
326
748
  lastUpdateSlot: BN;
749
+ lastOracleNormalisedPrice: BN;
750
+ lastOracleValid: boolean;
327
751
  lastBidPriceTwap: BN;
328
752
  lastAskPriceTwap: BN;
329
- longSpread: BN;
330
- shortSpread: BN;
753
+ longSpread: number;
754
+ shortSpread: number;
331
755
  maxSpread: number;
756
+ baseAssetAmountPerLp: BN;
757
+ quoteAssetAmountPerLp: BN;
758
+ ammJitIntensity: number;
759
+ maxOpenInterest: BN;
760
+ maxBaseAssetReserve: BN;
761
+ minBaseAssetReserve: BN;
762
+ totalSocialLoss: BN;
763
+ quoteBreakEvenAmountLong: BN;
764
+ quoteBreakEvenAmountShort: BN;
765
+ quoteEntryAmountLong: BN;
766
+ quoteEntryAmountShort: BN;
767
+ markStd: BN;
768
+ oracleStd: BN;
769
+ longIntensityCount: number;
770
+ longIntensityVolume: BN;
771
+ shortIntensityCount: number;
772
+ shortIntensityVolume: BN;
773
+ volume24H: BN;
774
+ minOrderSize: BN;
775
+ maxPositionSize: BN;
776
+ bidBaseAssetReserve: BN;
777
+ bidQuoteAssetReserve: BN;
778
+ askBaseAssetReserve: BN;
779
+ askQuoteAssetReserve: BN;
332
780
  };
333
- export declare type UserPosition = {
781
+ export declare type PerpPosition = {
334
782
  baseAssetAmount: BN;
335
783
  lastCumulativeFundingRate: BN;
336
- marketIndex: BN;
784
+ marketIndex: number;
337
785
  quoteAssetAmount: BN;
338
786
  quoteEntryAmount: BN;
339
- openOrders: BN;
340
- unsettledPnl: BN;
787
+ quoteBreakEvenAmount: BN;
788
+ openOrders: number;
341
789
  openBids: BN;
342
790
  openAsks: BN;
791
+ settledPnl: BN;
792
+ lpShares: BN;
793
+ remainderBaseAssetAmount: number;
794
+ lastNetBaseAssetAmountPerLp: BN;
795
+ lastNetQuoteAssetAmountPerLp: BN;
343
796
  };
344
- export declare type UserAccount = {
345
- authority: PublicKey;
346
- name: number[];
347
- userId: number;
348
- bankBalances: UserBankBalance[];
349
- collateral: BN;
350
- cumulativeDeposits: BN;
797
+ export declare type UserStatsAccount = {
798
+ numberOfSubAccounts: number;
799
+ numberOfSubAccountsCreated: number;
800
+ makerVolume30D: BN;
801
+ takerVolume30D: BN;
802
+ fillerVolume30D: BN;
803
+ lastMakerVolume30DTs: BN;
804
+ lastTakerVolume30DTs: BN;
805
+ lastFillerVolume30DTs: BN;
351
806
  fees: {
352
807
  totalFeePaid: BN;
353
808
  totalFeeRebate: BN;
354
809
  totalTokenDiscount: BN;
355
- totalReferralReward: BN;
356
810
  totalRefereeDiscount: BN;
811
+ totalReferrerReward: BN;
812
+ current_epoch_referrer_reward: BN;
357
813
  };
358
- positions: UserPosition[];
814
+ referrer: PublicKey;
815
+ isReferrer: boolean;
816
+ authority: PublicKey;
817
+ ifStakedQuoteAssetAmount: BN;
818
+ };
819
+ export declare type UserAccount = {
820
+ authority: PublicKey;
821
+ delegate: PublicKey;
822
+ name: number[];
823
+ subAccountId: number;
824
+ spotPositions: SpotPosition[];
825
+ perpPositions: PerpPosition[];
359
826
  orders: Order[];
827
+ status: UserStatus;
828
+ nextLiquidationId: number;
829
+ nextOrderId: number;
830
+ maxMarginRatio: number;
831
+ lastAddPerpLpSharesTs: BN;
832
+ settledPerpPnl: BN;
833
+ totalDeposits: BN;
834
+ totalWithdraws: BN;
835
+ totalSocialLoss: BN;
836
+ cumulativePerpFunding: BN;
360
837
  };
361
- export declare type UserBankBalance = {
362
- bankIndex: BN;
363
- balanceType: BankBalanceType;
364
- balance: BN;
838
+ export declare type SpotPosition = {
839
+ marketIndex: number;
840
+ balanceType: SpotBalanceType;
841
+ scaledBalance: BN;
842
+ openOrders: number;
843
+ openBids: BN;
844
+ openAsks: BN;
845
+ cumulativeDeposits: BN;
365
846
  };
366
847
  export declare type Order = {
367
848
  status: OrderStatus;
368
849
  orderType: OrderType;
369
- ts: BN;
850
+ marketType: MarketType;
370
851
  slot: BN;
371
- orderId: BN;
852
+ orderId: number;
372
853
  userOrderId: number;
373
- marketIndex: BN;
854
+ marketIndex: number;
374
855
  price: BN;
375
856
  baseAssetAmount: BN;
376
857
  baseAssetAmountFilled: BN;
377
858
  quoteAssetAmount: BN;
378
859
  quoteAssetAmountFilled: BN;
379
- fee: BN;
380
860
  direction: PositionDirection;
381
861
  reduceOnly: boolean;
382
862
  triggerPrice: BN;
383
863
  triggerCondition: OrderTriggerCondition;
384
- triggered: boolean;
385
- discountTier: OrderDiscountTier;
386
864
  existingPositionDirection: PositionDirection;
387
- referrer: PublicKey;
388
865
  postOnly: boolean;
389
866
  immediateOrCancel: boolean;
390
- oraclePriceOffset: BN;
867
+ oraclePriceOffset: number;
391
868
  auctionDuration: number;
392
869
  auctionStartPrice: BN;
393
870
  auctionEndPrice: BN;
871
+ maxTs: BN;
394
872
  };
395
873
  export declare type OrderParams = {
396
874
  orderType: OrderType;
875
+ marketType: MarketType;
397
876
  userOrderId: number;
398
877
  direction: PositionDirection;
399
878
  baseAssetAmount: BN;
400
879
  price: BN;
401
- marketIndex: BN;
880
+ marketIndex: number;
402
881
  reduceOnly: boolean;
403
882
  postOnly: boolean;
404
883
  immediateOrCancel: boolean;
405
- triggerPrice: BN;
884
+ triggerPrice: BN | null;
406
885
  triggerCondition: OrderTriggerCondition;
407
886
  positionLimit: BN;
408
- oraclePriceOffset: BN;
409
- padding0: boolean;
410
- padding1: BN;
411
- optionalAccounts: {
412
- discountToken: boolean;
413
- referrer: boolean;
414
- };
887
+ oraclePriceOffset: number | null;
888
+ auctionDuration: number | null;
889
+ maxTs: BN | null;
890
+ auctionStartPrice: BN | null;
891
+ auctionEndPrice: BN | null;
415
892
  };
416
893
  export declare type NecessaryOrderParams = {
417
894
  orderType: OrderType;
418
- marketIndex: BN;
895
+ marketIndex: number;
419
896
  baseAssetAmount: BN;
420
897
  direction: PositionDirection;
421
898
  };
422
899
  export declare type OptionalOrderParams = {
423
900
  [Property in keyof OrderParams]?: OrderParams[Property];
424
901
  } & NecessaryOrderParams;
425
- export declare const DefaultOrderParams: {
426
- orderType: {
427
- market: {};
428
- };
429
- userOrderId: number;
430
- direction: {
431
- long: {};
432
- };
433
- baseAssetAmount: BN;
434
- price: BN;
435
- marketIndex: BN;
436
- reduceOnly: boolean;
437
- postOnly: boolean;
438
- immediateOrCancel: boolean;
439
- triggerPrice: BN;
440
- triggerCondition: {
441
- above: {};
442
- };
443
- positionLimit: BN;
444
- oraclePriceOffset: BN;
445
- padding0: BN;
446
- padding1: BN;
447
- optionalAccounts: {
448
- discountToken: boolean;
449
- referrer: boolean;
450
- };
451
- };
902
+ export declare const DefaultOrderParams: OrderParams;
452
903
  export declare type MakerInfo = {
453
904
  maker: PublicKey;
905
+ makerStats: PublicKey;
906
+ makerUserAccount: UserAccount;
454
907
  order: Order;
455
908
  };
909
+ export declare type TakerInfo = {
910
+ taker: PublicKey;
911
+ takerStats: PublicKey;
912
+ takerUserAccount: UserAccount;
913
+ order: Order;
914
+ };
915
+ export declare type ReferrerInfo = {
916
+ referrer: PublicKey;
917
+ referrerStats: PublicKey;
918
+ };
456
919
  export interface IWallet {
457
920
  signTransaction(tx: Transaction): Promise<Transaction>;
458
921
  signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
459
922
  publicKey: PublicKey;
460
923
  }
461
924
  export declare type FeeStructure = {
462
- feeNumerator: BN;
463
- feeDenominator: BN;
464
- discountTokenTiers: {
465
- firstTier: {
466
- minimumBalance: BN;
467
- discountNumerator: BN;
468
- discountDenominator: BN;
469
- };
470
- secondTier: {
471
- minimumBalance: BN;
472
- discountNumerator: BN;
473
- discountDenominator: BN;
474
- };
475
- thirdTier: {
476
- minimumBalance: BN;
477
- discountNumerator: BN;
478
- discountDenominator: BN;
479
- };
480
- fourthTier: {
481
- minimumBalance: BN;
482
- discountNumerator: BN;
483
- discountDenominator: BN;
484
- };
485
- };
486
- referralDiscount: {
487
- referrerRewardNumerator: BN;
488
- referrerRewardDenominator: BN;
489
- refereeDiscountNumerator: BN;
490
- refereeDiscountDenominator: BN;
491
- };
925
+ feeTiers: FeeTier[];
492
926
  makerRebateNumerator: BN;
493
927
  makerRebateDenominator: BN;
494
928
  fillerRewardStructure: OrderFillerRewardStructure;
929
+ flatFillerFee: BN;
930
+ referrerRewardEpochUpperBound: BN;
931
+ };
932
+ export declare type FeeTier = {
933
+ feeNumerator: number;
934
+ feeDenominator: number;
935
+ makerRebateNumerator: number;
936
+ makerRebateDenominator: number;
937
+ referrerRewardNumerator: number;
938
+ referrerRewardDenominator: number;
939
+ refereeFeeNumerator: number;
940
+ refereeFeeDenominator: number;
941
+ };
942
+ export declare type OrderFillerRewardStructure = {
943
+ rewardNumerator: BN;
944
+ rewardDenominator: BN;
945
+ timeBasedRewardLowerBound: BN;
495
946
  };
496
947
  export declare type OracleGuardRails = {
497
948
  priceDivergence: {
@@ -499,15 +950,36 @@ export declare type OracleGuardRails = {
499
950
  markOracleDivergenceDenominator: BN;
500
951
  };
501
952
  validity: {
502
- slotsBeforeStale: BN;
953
+ slotsBeforeStaleForAmm: BN;
954
+ slotsBeforeStaleForMargin: BN;
503
955
  confidenceIntervalMaxSize: BN;
504
956
  tooVolatileRatio: BN;
505
957
  };
506
958
  useForLiquidations: boolean;
507
959
  };
508
- export declare type OrderFillerRewardStructure = {
509
- rewardNumerator: BN;
510
- rewardDenominator: BN;
511
- timeBasedRewardLowerBound: BN;
960
+ export declare type MarginCategory = 'Initial' | 'Maintenance';
961
+ export declare type InsuranceFundStake = {
962
+ marketIndex: number;
963
+ authority: PublicKey;
964
+ ifShares: BN;
965
+ ifBase: BN;
966
+ lastWithdrawRequestShares: BN;
967
+ lastWithdrawRequestValue: BN;
968
+ lastWithdrawRequestTs: BN;
969
+ };
970
+ export declare type SerumV3FulfillmentConfigAccount = {
971
+ fulfillmentType: SpotFulfillmentType;
972
+ status: SpotFulfillmentStatus;
973
+ pubkey: PublicKey;
974
+ marketIndex: number;
975
+ serumProgramId: PublicKey;
976
+ serumMarket: PublicKey;
977
+ serumRequestQueue: PublicKey;
978
+ serumEventQueue: PublicKey;
979
+ serumBids: PublicKey;
980
+ serumAsks: PublicKey;
981
+ serumBaseVault: PublicKey;
982
+ serumQuoteVault: PublicKey;
983
+ serumOpenOrders: PublicKey;
984
+ serumSignerNonce: BN;
512
985
  };
513
- export declare type MarginCategory = 'Initial' | 'Partial' | 'Maintenance';