@drift-labs/sdk 0.2.0-master.3 → 0.2.0-master.30

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 (208) hide show
  1. package/README.md +13 -13
  2. package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
  3. package/lib/accounts/bulkUserStatsSubscription.js +21 -0
  4. package/lib/accounts/bulkUserSubscription.js +0 -1
  5. package/lib/accounts/fetch.d.ts +2 -1
  6. package/lib/accounts/fetch.js +9 -1
  7. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +16 -16
  8. package/lib/accounts/pollingClearingHouseAccountSubscriber.js +31 -28
  9. package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
  10. package/lib/accounts/pollingUserStatsAccountSubscriber.js +113 -0
  11. package/lib/accounts/types.d.ts +22 -11
  12. package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +17 -17
  13. package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +37 -35
  14. package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
  15. package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
  16. package/lib/addresses/marketAddresses.d.ts +1 -3
  17. package/lib/addresses/pda.d.ts +10 -4
  18. package/lib/addresses/pda.js +51 -14
  19. package/lib/admin.d.ts +34 -22
  20. package/lib/admin.js +182 -73
  21. package/lib/clearingHouse.d.ts +120 -42
  22. package/lib/clearingHouse.js +1505 -254
  23. package/lib/clearingHouseConfig.d.ts +4 -4
  24. package/lib/clearingHouseUser.d.ts +50 -38
  25. package/lib/clearingHouseUser.js +410 -190
  26. package/lib/clearingHouseUserStats.d.ts +18 -0
  27. package/lib/clearingHouseUserStats.js +49 -0
  28. package/lib/clearingHouseUserStatsConfig.d.ts +14 -0
  29. package/lib/clearingHouseUserStatsConfig.js +2 -0
  30. package/lib/config.d.ts +7 -9
  31. package/lib/config.js +21 -21
  32. package/lib/constants/numericConstants.d.ts +18 -12
  33. package/lib/constants/numericConstants.js +28 -21
  34. package/lib/constants/perpMarkets.d.ts +18 -0
  35. package/lib/constants/{markets.js → perpMarkets.js} +7 -7
  36. package/lib/constants/spotMarkets.d.ts +19 -0
  37. package/lib/constants/spotMarkets.js +53 -0
  38. package/lib/dlob/DLOB.d.ts +73 -0
  39. package/lib/dlob/DLOB.js +553 -0
  40. package/lib/dlob/DLOBNode.d.ts +52 -0
  41. package/lib/dlob/DLOBNode.js +82 -0
  42. package/lib/dlob/NodeList.d.ts +26 -0
  43. package/lib/dlob/NodeList.js +138 -0
  44. package/lib/events/eventList.js +3 -0
  45. package/lib/events/eventSubscriber.d.ts +4 -2
  46. package/lib/events/eventSubscriber.js +16 -9
  47. package/lib/events/fetchLogs.d.ts +10 -1
  48. package/lib/events/fetchLogs.js +27 -7
  49. package/lib/events/pollingLogProvider.d.ts +2 -1
  50. package/lib/events/pollingLogProvider.js +6 -2
  51. package/lib/events/sort.js +8 -11
  52. package/lib/events/types.d.ts +7 -2
  53. package/lib/events/types.js +5 -0
  54. package/lib/examples/makeTradeExample.js +20 -8
  55. package/lib/factory/bigNum.d.ts +1 -0
  56. package/lib/factory/bigNum.js +34 -10
  57. package/lib/idl/clearing_house.json +4313 -1433
  58. package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
  59. package/lib/index.d.ts +21 -6
  60. package/lib/index.js +25 -6
  61. package/lib/math/amm.d.ts +8 -5
  62. package/lib/math/amm.js +68 -46
  63. package/lib/math/auction.js +4 -1
  64. package/lib/math/conversion.js +1 -1
  65. package/lib/math/funding.d.ts +6 -6
  66. package/lib/math/funding.js +11 -10
  67. package/lib/math/insurance.d.ts +4 -0
  68. package/lib/math/insurance.js +27 -0
  69. package/lib/math/margin.d.ts +11 -0
  70. package/lib/math/margin.js +77 -0
  71. package/lib/math/market.d.ts +14 -9
  72. package/lib/math/market.js +69 -7
  73. package/lib/math/oracles.d.ts +4 -0
  74. package/lib/math/oracles.js +36 -8
  75. package/lib/math/orders.d.ts +6 -2
  76. package/lib/math/orders.js +78 -3
  77. package/lib/math/position.d.ts +21 -13
  78. package/lib/math/position.js +76 -36
  79. package/lib/math/repeg.js +14 -5
  80. package/lib/math/spotBalance.d.ts +22 -0
  81. package/lib/math/spotBalance.js +193 -0
  82. package/lib/math/spotMarket.d.ts +4 -0
  83. package/lib/math/spotMarket.js +8 -0
  84. package/lib/math/spotPosition.d.ts +6 -0
  85. package/lib/math/spotPosition.js +23 -0
  86. package/lib/math/trade.d.ts +10 -10
  87. package/lib/math/trade.js +22 -29
  88. package/lib/oracles/pythClient.js +1 -1
  89. package/lib/oracles/quoteAssetOracleClient.js +1 -1
  90. package/lib/oracles/switchboardClient.js +1 -1
  91. package/lib/orderParams.d.ts +14 -5
  92. package/lib/orderParams.js +12 -92
  93. package/lib/serum/serumSubscriber.d.ts +23 -0
  94. package/lib/serum/serumSubscriber.js +41 -0
  95. package/lib/serum/types.d.ts +11 -0
  96. package/lib/serum/types.js +2 -0
  97. package/lib/slot/SlotSubscriber.d.ts +7 -0
  98. package/lib/slot/SlotSubscriber.js +3 -0
  99. package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
  100. package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
  101. package/lib/tx/retryTxSender.d.ts +1 -1
  102. package/lib/tx/retryTxSender.js +13 -4
  103. package/lib/tx/types.d.ts +1 -1
  104. package/lib/tx/utils.js +1 -1
  105. package/lib/types.d.ts +474 -123
  106. package/lib/types.js +99 -5
  107. package/lib/userMap/userMap.d.ts +25 -0
  108. package/lib/userMap/userMap.js +73 -0
  109. package/lib/userMap/userStatsMap.d.ts +19 -0
  110. package/lib/userMap/userStatsMap.js +68 -0
  111. package/lib/util/computeUnits.js +1 -1
  112. package/lib/util/getTokenAddress.d.ts +2 -0
  113. package/lib/util/getTokenAddress.js +9 -0
  114. package/package.json +9 -5
  115. package/src/accounts/bulkUserStatsSubscription.ts +33 -0
  116. package/src/accounts/bulkUserSubscription.ts +0 -1
  117. package/src/accounts/fetch.ts +27 -2
  118. package/src/accounts/pollingClearingHouseAccountSubscriber.ts +46 -42
  119. package/src/accounts/pollingUserStatsAccountSubscriber.ts +172 -0
  120. package/src/accounts/types.ts +31 -11
  121. package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +64 -59
  122. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
  123. package/src/addresses/marketAddresses.ts +1 -2
  124. package/src/addresses/pda.ts +88 -14
  125. package/src/admin.ts +333 -128
  126. package/src/assert/assert.js +9 -0
  127. package/src/clearingHouse.ts +2464 -458
  128. package/src/clearingHouseConfig.ts +4 -3
  129. package/src/clearingHouseUser.ts +747 -291
  130. package/src/clearingHouseUserStats.ts +75 -0
  131. package/src/clearingHouseUserStatsConfig.ts +18 -0
  132. package/src/config.ts +30 -31
  133. package/src/constants/numericConstants.ts +41 -25
  134. package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
  135. package/src/constants/spotMarkets.ts +72 -0
  136. package/src/dlob/DLOB.ts +868 -0
  137. package/src/dlob/DLOBNode.ts +162 -0
  138. package/src/dlob/NodeList.ts +185 -0
  139. package/src/events/eventList.js +77 -0
  140. package/src/events/eventList.ts +3 -0
  141. package/src/events/eventSubscriber.ts +20 -12
  142. package/src/events/fetchLogs.ts +35 -8
  143. package/src/events/pollingLogProvider.ts +10 -2
  144. package/src/events/sort.ts +11 -15
  145. package/src/events/types.ts +16 -1
  146. package/src/examples/makeTradeExample.js +157 -0
  147. package/src/examples/makeTradeExample.ts +32 -14
  148. package/src/factory/bigNum.ts +42 -13
  149. package/src/idl/clearing_house.json +4313 -1433
  150. package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
  151. package/src/index.ts +21 -6
  152. package/src/math/amm.ts +136 -66
  153. package/src/math/auction.ts +5 -1
  154. package/src/math/conversion.ts +2 -2
  155. package/src/math/funding.ts +20 -18
  156. package/src/math/insurance.ts +35 -0
  157. package/src/math/margin.ts +127 -0
  158. package/src/math/market.ts +138 -12
  159. package/src/math/oracles.ts +63 -9
  160. package/src/math/orders.ts +138 -4
  161. package/src/math/position.ts +119 -58
  162. package/src/math/repeg.ts +16 -6
  163. package/src/math/spotBalance.ts +316 -0
  164. package/src/math/spotMarket.ts +9 -0
  165. package/src/math/spotPosition.ts +47 -0
  166. package/src/math/trade.ts +43 -49
  167. package/src/oracles/pythClient.ts +2 -2
  168. package/src/oracles/quoteAssetOracleClient.ts +2 -2
  169. package/src/oracles/switchboardClient.ts +2 -2
  170. package/src/orderParams.ts +24 -137
  171. package/src/serum/serumSubscriber.ts +80 -0
  172. package/src/serum/types.ts +13 -0
  173. package/src/slot/SlotSubscriber.ts +11 -1
  174. package/src/token/index.js +38 -0
  175. package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
  176. package/src/tx/retryTxSender.ts +16 -5
  177. package/src/tx/types.js +2 -0
  178. package/src/tx/types.ts +2 -1
  179. package/src/tx/utils.js +17 -0
  180. package/src/tx/utils.ts +1 -1
  181. package/src/types.ts +477 -125
  182. package/src/userMap/userMap.ts +100 -0
  183. package/src/userMap/userStatsMap.ts +110 -0
  184. package/src/util/computeUnits.js +21 -11
  185. package/src/util/computeUnits.ts +1 -1
  186. package/src/util/getTokenAddress.js +9 -0
  187. package/src/util/getTokenAddress.ts +18 -0
  188. package/src/util/promiseTimeout.js +14 -0
  189. package/src/util/tps.js +27 -0
  190. package/tests/bn/test.ts +12 -3
  191. package/tests/dlob/helpers.ts +374 -0
  192. package/tests/dlob/test.ts +2865 -0
  193. package/lib/constants/banks.d.ts +0 -16
  194. package/lib/constants/banks.js +0 -34
  195. package/lib/constants/markets.d.ts +0 -19
  196. package/lib/math/bankBalance.d.ts +0 -9
  197. package/lib/math/bankBalance.js +0 -75
  198. package/lib/math/state.d.ts +0 -8
  199. package/lib/math/state.js +0 -15
  200. package/lib/orders.d.ts +0 -8
  201. package/lib/orders.js +0 -134
  202. package/src/constants/banks.ts +0 -43
  203. package/src/math/bankBalance.ts +0 -112
  204. package/src/math/state.ts +0 -14
  205. package/src/math/utils.js +0 -27
  206. package/src/math/utils.js.map +0 -1
  207. package/src/orders.ts +0 -244
  208. package/src/util/computeUnits.js.map +0 -1
@@ -0,0 +1,374 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import {
3
+ BN,
4
+ PerpMarketAccount,
5
+ SpotMarketAccount,
6
+ MarketStatus,
7
+ ContractType,
8
+ DevnetPerpMarkets,
9
+ OracleSource,
10
+ DevnetSpotMarkets,
11
+ } from '../../src';
12
+
13
+ export const mockPerpPosition = {
14
+ baseAssetAmount: new BN(0),
15
+ remainderBaseAssetAmount: new BN(0),
16
+ lastCumulativeFundingRate: new BN(0),
17
+ marketIndex: new BN(0),
18
+ quoteAssetAmount: new BN(0),
19
+ quoteEntryAmount: new BN(0),
20
+ openOrders: new BN(0),
21
+ openBids: new BN(0),
22
+ openAsks: new BN(0),
23
+ settledPnl: new BN(0),
24
+ lpShares: new BN(0),
25
+ lastFeePerLp: new BN(0),
26
+ lastNetBaseAssetAmountPerLp: new BN(0),
27
+ lastNetQuoteAssetAmountPerLp: new BN(0),
28
+ };
29
+
30
+ export const mockAMM = {
31
+ /* these values create a bid/ask price of 12 */
32
+ baseAssetReserve: new BN(2800000),
33
+ quoteAssetReserve: new BN(3),
34
+ sqrtK: new BN(1),
35
+ pegMultiplier: new BN(1),
36
+ maxSlippageRatio: 1_000_000,
37
+
38
+ cumulativeFundingRate: new BN(0),
39
+ lastFundingRate: new BN(0),
40
+ lastFundingRateTs: new BN(0),
41
+ lastMarkPriceTwap: new BN(0),
42
+ lastMarkPriceTwap5min: new BN(0),
43
+ lastMarkPriceTwapTs: new BN(0),
44
+ historicalOracleData: {
45
+ lastOraclePrice: new BN(0),
46
+ lastOracleConf: new BN(0),
47
+ lastOracleDelay: new BN(0),
48
+ lastOraclePriceTwap: new BN(0),
49
+ lastOraclePriceTwap5min: new BN(0),
50
+ lastOraclePriceTwapTs: new BN(0),
51
+ },
52
+ lastOracleMarkSpreadPct: new BN(0),
53
+ lastOracleConfPct: new BN(0),
54
+ oracle: PublicKey.default,
55
+ oracleSource: OracleSource.PYTH,
56
+ fundingPeriod: new BN(0),
57
+ cumulativeFundingRateLong: new BN(0),
58
+ cumulativeFundingRateShort: new BN(0),
59
+ cumulativeFundingRateLp: new BN(0),
60
+ cumulativeRepegRebateLong: new BN(0),
61
+ cumulativeRepegRebateShort: new BN(0),
62
+ totalFeeMinusDistributions: new BN(0),
63
+ totalFeeWithdrawn: new BN(0),
64
+ totalFee: new BN(0),
65
+ cumulativeFundingPaymentPerLp: new BN(0),
66
+ cumulativeFeePerLp: new BN(0),
67
+ cumulativeNetBaseAssetAmountPerLp: new BN(0),
68
+ userLpShares: new BN(0),
69
+ netUnsettledLpBaseAssetAmount: new BN(0),
70
+ minimumQuoteAssetTradeSize: new BN(0),
71
+ baseAssetAmountStepSize: new BN(0),
72
+ maxBaseAssetAmountRatio: 0,
73
+ baseSpread: 0,
74
+ curveUpdateIntensity: 0,
75
+ netBaseAssetAmount: new BN(0),
76
+ quoteAssetAmountLong: new BN(0),
77
+ quoteAssetAmountShort: new BN(0),
78
+ terminalQuoteAssetReserve: new BN(0),
79
+ feePool: {
80
+ balance: new BN(0),
81
+ },
82
+ totalExchangeFee: new BN(0),
83
+ totalMmFee: new BN(0),
84
+ netRevenueSinceLastFunding: new BN(0),
85
+ lastUpdateSlot: new BN(0),
86
+ lastOracleValid: true,
87
+ lastBidPriceTwap: new BN(0),
88
+ lastAskPriceTwap: new BN(0),
89
+ longSpread: new BN(0),
90
+ shortSpread: new BN(0),
91
+ maxSpread: 0,
92
+ marketPosition: mockPerpPosition,
93
+ marketPositionPerLp: mockPerpPosition,
94
+ ammJitIntensity: 0,
95
+ maxBaseAssetReserve: new BN(0),
96
+ minBaseAssetReserve: new BN(0),
97
+ cumulativeSocialLoss: new BN(0),
98
+ };
99
+
100
+ export const mockPerpMarkets: Array<PerpMarketAccount> = [
101
+ {
102
+ status: MarketStatus.INITIALIZED,
103
+ contractType: ContractType.PERPETUAL,
104
+ expiryTs: new BN(0),
105
+ settlementPrice: new BN(0),
106
+ marketIndex: DevnetPerpMarkets[0].marketIndex,
107
+ pubkey: PublicKey.default,
108
+ amm: mockAMM,
109
+ baseAssetAmount: new BN(0),
110
+ baseAssetAmountLong: new BN(0),
111
+ baseAssetAmountShort: new BN(0),
112
+ openInterest: new BN(0),
113
+ marginRatioInitial: 0,
114
+ marginRatioMaintenance: 0,
115
+ nextFillRecordId: new BN(0),
116
+ pnlPool: {
117
+ balance: new BN(0),
118
+ },
119
+ ifLiquidationFee: new BN(0),
120
+ liquidatorFee: new BN(0),
121
+ imfFactor: new BN(0),
122
+ unrealizedImfFactor: new BN(0),
123
+ unrealizedMaxImbalance: new BN(0),
124
+ unrealizedInitialAssetWeight: 0,
125
+ unrealizedMaintenanceAssetWeight: 0,
126
+ revenueWithdrawSinceLastSettle: new BN(0),
127
+ maxRevenueWithdrawPerPeriod: new BN(0),
128
+ lastRevenueWithdrawTs: new BN(0),
129
+ quoteSettledInsurance: new BN(0),
130
+ quoteMaxInsurance: new BN(0),
131
+ },
132
+ {
133
+ status: MarketStatus.INITIALIZED,
134
+ contractType: ContractType.PERPETUAL,
135
+ expiryTs: new BN(0),
136
+ settlementPrice: new BN(0),
137
+ marketIndex: DevnetPerpMarkets[1].marketIndex,
138
+ pubkey: PublicKey.default,
139
+ amm: mockAMM,
140
+ baseAssetAmount: new BN(0),
141
+ baseAssetAmountLong: new BN(0),
142
+ baseAssetAmountShort: new BN(0),
143
+ openInterest: new BN(0),
144
+ marginRatioInitial: 0,
145
+ marginRatioMaintenance: 0,
146
+ nextFillRecordId: new BN(0),
147
+ pnlPool: {
148
+ balance: new BN(0),
149
+ },
150
+ ifLiquidationFee: new BN(0),
151
+ liquidatorFee: new BN(0),
152
+ imfFactor: new BN(0),
153
+ unrealizedImfFactor: new BN(0),
154
+ unrealizedMaxImbalance: new BN(0),
155
+ unrealizedInitialAssetWeight: 0,
156
+ unrealizedMaintenanceAssetWeight: 0,
157
+ revenueWithdrawSinceLastSettle: new BN(0),
158
+ maxRevenueWithdrawPerPeriod: new BN(0),
159
+ lastRevenueWithdrawTs: new BN(0),
160
+ quoteSettledInsurance: new BN(0),
161
+ quoteMaxInsurance: new BN(0),
162
+ },
163
+ {
164
+ status: MarketStatus.INITIALIZED,
165
+ contractType: ContractType.PERPETUAL,
166
+ expiryTs: new BN(0),
167
+ settlementPrice: new BN(0),
168
+ marketIndex: DevnetPerpMarkets[2].marketIndex,
169
+ pubkey: PublicKey.default,
170
+ amm: mockAMM,
171
+ baseAssetAmount: new BN(0),
172
+ baseAssetAmountLong: new BN(0),
173
+ baseAssetAmountShort: new BN(0),
174
+ openInterest: new BN(0),
175
+ marginRatioInitial: 0,
176
+ marginRatioMaintenance: 0,
177
+ nextFillRecordId: new BN(0),
178
+ pnlPool: {
179
+ balance: new BN(0),
180
+ },
181
+ ifLiquidationFee: new BN(0),
182
+ liquidatorFee: new BN(0),
183
+ imfFactor: new BN(0),
184
+ unrealizedImfFactor: new BN(0),
185
+ unrealizedMaxImbalance: new BN(0),
186
+ unrealizedInitialAssetWeight: 0,
187
+ unrealizedMaintenanceAssetWeight: 0,
188
+ revenueWithdrawSinceLastSettle: new BN(0),
189
+ maxRevenueWithdrawPerPeriod: new BN(0),
190
+ lastRevenueWithdrawTs: new BN(0),
191
+ quoteSettledInsurance: new BN(0),
192
+ quoteMaxInsurance: new BN(0),
193
+ },
194
+ ];
195
+
196
+ export const mockSpotMarkets: Array<SpotMarketAccount> = [
197
+ {
198
+ marketIndex: new BN(0),
199
+ pubkey: PublicKey.default,
200
+ mint: DevnetSpotMarkets[0].mint,
201
+ vault: PublicKey.default,
202
+ insuranceFundVault: PublicKey.default,
203
+ insuranceWithdrawEscrowPeriod: new BN(0),
204
+ revenuePool: {
205
+ balance: new BN(0),
206
+ },
207
+ totalIfShares: new BN(0),
208
+ userIfShares: new BN(0),
209
+ userIfFactor: new BN(0),
210
+ totalIfFactor: new BN(0),
211
+ ifLiquidationFee: new BN(0),
212
+ liquidatorFee: new BN(0),
213
+ decimals: 6,
214
+ optimalUtilization: new BN(0),
215
+ optimalBorrowRate: new BN(0),
216
+ maxBorrowRate: new BN(0),
217
+ cumulativeDepositInterest: new BN(0),
218
+ cumulativeBorrowInterest: new BN(0),
219
+ depositBalance: new BN(0),
220
+ borrowBalance: new BN(0),
221
+ lastInterestTs: new BN(0),
222
+ lastTwapTs: new BN(0),
223
+ oracle: PublicKey.default,
224
+ initialAssetWeight: new BN(0),
225
+ maintenanceAssetWeight: new BN(0),
226
+ initialLiabilityWeight: new BN(0),
227
+ maintenanceLiabilityWeight: new BN(0),
228
+ imfFactor: new BN(0),
229
+ withdrawGuardThreshold: new BN(0),
230
+ depositTokenTwap: new BN(0),
231
+ borrowTokenTwap: new BN(0),
232
+ utilizationTwap: new BN(0),
233
+ orderStepSize: new BN(0),
234
+ nextFillRecordId: new BN(0),
235
+ spotFeePool: {
236
+ balance: new BN(0),
237
+ },
238
+ totalSpotFee: new BN(0),
239
+ oracleSource: OracleSource.PYTH,
240
+ historicalOracleData: {
241
+ lastOraclePrice: new BN(0),
242
+ lastOracleConf: new BN(0),
243
+ lastOracleDelay: new BN(0),
244
+ lastOraclePriceTwap: new BN(0),
245
+ lastOraclePriceTwap5min: new BN(0),
246
+ lastOraclePriceTwapTs: new BN(0),
247
+ },
248
+ historicalIndexData: {
249
+ lastIndexBidPrice: new BN(0),
250
+ lastIndexAskPrice: new BN(0),
251
+ lastIndexPriceTwap: new BN(0),
252
+ lastIndexPriceTwap5Min: new BN(0),
253
+ lastIndexPriceTwapTs: new BN(0),
254
+ },
255
+ },
256
+ {
257
+ marketIndex: new BN(1),
258
+ pubkey: PublicKey.default,
259
+ mint: DevnetSpotMarkets[1].mint,
260
+ vault: PublicKey.default,
261
+ insuranceFundVault: PublicKey.default,
262
+ insuranceWithdrawEscrowPeriod: new BN(0),
263
+ revenuePool: {
264
+ balance: new BN(0),
265
+ },
266
+ totalIfShares: new BN(0),
267
+ userIfShares: new BN(0),
268
+ userIfFactor: new BN(0),
269
+ totalIfFactor: new BN(0),
270
+ ifLiquidationFee: new BN(0),
271
+ liquidatorFee: new BN(0),
272
+ decimals: 9,
273
+ optimalUtilization: new BN(0),
274
+ optimalBorrowRate: new BN(0),
275
+ maxBorrowRate: new BN(0),
276
+ cumulativeDepositInterest: new BN(0),
277
+ cumulativeBorrowInterest: new BN(0),
278
+ depositBalance: new BN(0),
279
+ borrowBalance: new BN(0),
280
+ lastInterestTs: new BN(0),
281
+ lastTwapTs: new BN(0),
282
+ oracle: PublicKey.default,
283
+ initialAssetWeight: new BN(0),
284
+ maintenanceAssetWeight: new BN(0),
285
+ initialLiabilityWeight: new BN(0),
286
+ maintenanceLiabilityWeight: new BN(0),
287
+ imfFactor: new BN(0),
288
+ withdrawGuardThreshold: new BN(0),
289
+ depositTokenTwap: new BN(0),
290
+ borrowTokenTwap: new BN(0),
291
+ utilizationTwap: new BN(0),
292
+ orderStepSize: new BN(0),
293
+ nextFillRecordId: new BN(0),
294
+ spotFeePool: {
295
+ balance: new BN(0),
296
+ },
297
+ totalSpotFee: new BN(0),
298
+ oracleSource: OracleSource.PYTH,
299
+ historicalOracleData: {
300
+ lastOraclePrice: new BN(0),
301
+ lastOracleConf: new BN(0),
302
+ lastOracleDelay: new BN(0),
303
+ lastOraclePriceTwap: new BN(0),
304
+ lastOraclePriceTwap5min: new BN(0),
305
+ lastOraclePriceTwapTs: new BN(0),
306
+ },
307
+ historicalIndexData: {
308
+ lastIndexBidPrice: new BN(0),
309
+ lastIndexAskPrice: new BN(0),
310
+ lastIndexPriceTwap: new BN(0),
311
+ lastIndexPriceTwap5Min: new BN(0),
312
+ lastIndexPriceTwapTs: new BN(0),
313
+ },
314
+ },
315
+ {
316
+ marketIndex: new BN(2),
317
+ pubkey: PublicKey.default,
318
+ mint: DevnetSpotMarkets[2].mint,
319
+ vault: PublicKey.default,
320
+ insuranceFundVault: PublicKey.default,
321
+ insuranceWithdrawEscrowPeriod: new BN(0),
322
+ revenuePool: {
323
+ balance: new BN(0),
324
+ },
325
+ totalIfShares: new BN(0),
326
+ userIfShares: new BN(0),
327
+ userIfFactor: new BN(0),
328
+ totalIfFactor: new BN(0),
329
+ ifLiquidationFee: new BN(0),
330
+ liquidatorFee: new BN(0),
331
+ decimals: 6,
332
+ optimalUtilization: new BN(0),
333
+ optimalBorrowRate: new BN(0),
334
+ maxBorrowRate: new BN(0),
335
+ cumulativeDepositInterest: new BN(0),
336
+ cumulativeBorrowInterest: new BN(0),
337
+ depositBalance: new BN(0),
338
+ borrowBalance: new BN(0),
339
+ lastInterestTs: new BN(0),
340
+ lastTwapTs: new BN(0),
341
+ oracle: PublicKey.default,
342
+ initialAssetWeight: new BN(0),
343
+ maintenanceAssetWeight: new BN(0),
344
+ initialLiabilityWeight: new BN(0),
345
+ maintenanceLiabilityWeight: new BN(0),
346
+ imfFactor: new BN(0),
347
+ withdrawGuardThreshold: new BN(0),
348
+ depositTokenTwap: new BN(0),
349
+ borrowTokenTwap: new BN(0),
350
+ utilizationTwap: new BN(0),
351
+ orderStepSize: new BN(0),
352
+ nextFillRecordId: new BN(0),
353
+ spotFeePool: {
354
+ balance: new BN(0),
355
+ },
356
+ totalSpotFee: new BN(0),
357
+ oracleSource: OracleSource.PYTH,
358
+ historicalOracleData: {
359
+ lastOraclePrice: new BN(0),
360
+ lastOracleConf: new BN(0),
361
+ lastOracleDelay: new BN(0),
362
+ lastOraclePriceTwap: new BN(0),
363
+ lastOraclePriceTwap5min: new BN(0),
364
+ lastOraclePriceTwapTs: new BN(0),
365
+ },
366
+ historicalIndexData: {
367
+ lastIndexBidPrice: new BN(0),
368
+ lastIndexAskPrice: new BN(0),
369
+ lastIndexPriceTwap: new BN(0),
370
+ lastIndexPriceTwap5Min: new BN(0),
371
+ lastIndexPriceTwapTs: new BN(0),
372
+ },
373
+ },
374
+ ];