@drift-labs/sdk 0.2.0-master.25 → 0.2.0-master.27

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 (124) hide show
  1. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +14 -13
  2. package/lib/accounts/pollingClearingHouseAccountSubscriber.js +30 -27
  3. package/lib/accounts/types.d.ts +9 -9
  4. package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +15 -14
  5. package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +38 -34
  6. package/lib/addresses/pda.d.ts +7 -6
  7. package/lib/addresses/pda.js +31 -27
  8. package/lib/admin.d.ts +13 -7
  9. package/lib/admin.js +111 -44
  10. package/lib/clearingHouse.d.ts +71 -42
  11. package/lib/clearingHouse.js +767 -278
  12. package/lib/clearingHouseConfig.d.ts +2 -2
  13. package/lib/clearingHouseUser.d.ts +24 -22
  14. package/lib/clearingHouseUser.js +273 -177
  15. package/lib/config.d.ts +7 -7
  16. package/lib/config.js +21 -21
  17. package/lib/constants/numericConstants.d.ts +12 -12
  18. package/lib/constants/numericConstants.js +13 -13
  19. package/lib/constants/{markets.d.ts → perpMarkets.d.ts} +5 -5
  20. package/lib/constants/{markets.js → perpMarkets.js} +4 -4
  21. package/lib/constants/{banks.d.ts → spotMarkets.d.ts} +6 -6
  22. package/lib/constants/{banks.js → spotMarkets.js} +16 -16
  23. package/lib/dlob/DLOB.d.ts +73 -0
  24. package/lib/dlob/DLOB.js +557 -0
  25. package/lib/dlob/DLOBNode.d.ts +52 -0
  26. package/lib/dlob/DLOBNode.js +82 -0
  27. package/lib/dlob/NodeList.d.ts +26 -0
  28. package/lib/dlob/NodeList.js +138 -0
  29. package/lib/events/types.d.ts +2 -1
  30. package/lib/events/types.js +1 -0
  31. package/lib/examples/makeTradeExample.js +7 -7
  32. package/lib/idl/clearing_house.json +1152 -503
  33. package/lib/index.d.ts +10 -3
  34. package/lib/index.js +10 -3
  35. package/lib/math/amm.d.ts +2 -2
  36. package/lib/math/amm.js +1 -1
  37. package/lib/math/funding.d.ts +6 -6
  38. package/lib/math/funding.js +2 -1
  39. package/lib/math/margin.d.ts +4 -4
  40. package/lib/math/margin.js +18 -11
  41. package/lib/math/market.d.ts +11 -10
  42. package/lib/math/market.js +30 -7
  43. package/lib/math/oracles.d.ts +2 -1
  44. package/lib/math/oracles.js +11 -1
  45. package/lib/math/orders.d.ts +6 -6
  46. package/lib/math/orders.js +31 -16
  47. package/lib/math/position.d.ts +13 -13
  48. package/lib/math/position.js +19 -19
  49. package/lib/math/spotBalance.d.ts +22 -0
  50. package/lib/math/spotBalance.js +193 -0
  51. package/lib/math/spotMarket.d.ts +4 -0
  52. package/lib/math/spotMarket.js +8 -0
  53. package/lib/math/spotPosition.d.ts +6 -0
  54. package/lib/math/spotPosition.js +23 -0
  55. package/lib/math/state.js +2 -2
  56. package/lib/math/trade.d.ts +4 -4
  57. package/lib/orderParams.d.ts +4 -4
  58. package/lib/orderParams.js +12 -4
  59. package/lib/serum/serumSubscriber.d.ts +23 -0
  60. package/lib/serum/serumSubscriber.js +41 -0
  61. package/lib/serum/types.d.ts +11 -0
  62. package/lib/serum/types.js +2 -0
  63. package/lib/tx/retryTxSender.d.ts +1 -1
  64. package/lib/tx/retryTxSender.js +4 -2
  65. package/lib/tx/types.d.ts +1 -1
  66. package/lib/types.d.ts +148 -57
  67. package/lib/types.js +39 -11
  68. package/lib/userMap/userMap.d.ts +25 -0
  69. package/lib/userMap/userMap.js +73 -0
  70. package/lib/userMap/userStatsMap.d.ts +19 -0
  71. package/lib/userMap/userStatsMap.js +68 -0
  72. package/package.json +6 -3
  73. package/src/accounts/pollingClearingHouseAccountSubscriber.ts +42 -38
  74. package/src/accounts/types.ts +12 -9
  75. package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +65 -52
  76. package/src/addresses/pda.ts +49 -44
  77. package/src/admin.ts +190 -55
  78. package/src/clearingHouse.ts +1092 -365
  79. package/src/clearingHouseConfig.ts +2 -2
  80. package/src/clearingHouseUser.ts +518 -255
  81. package/src/config.ts +30 -30
  82. package/src/constants/numericConstants.ts +17 -15
  83. package/src/constants/{markets.ts → perpMarkets.ts} +5 -5
  84. package/src/constants/{banks.ts → spotMarkets.ts} +19 -19
  85. package/src/dlob/DLOB.ts +884 -0
  86. package/src/dlob/DLOBNode.ts +163 -0
  87. package/src/dlob/NodeList.ts +185 -0
  88. package/src/events/types.ts +3 -0
  89. package/src/examples/makeTradeExample.js +152 -75
  90. package/src/examples/makeTradeExample.ts +10 -8
  91. package/src/idl/clearing_house.json +1152 -503
  92. package/src/index.ts +10 -3
  93. package/src/math/amm.ts +6 -3
  94. package/src/math/funding.ts +7 -7
  95. package/src/math/margin.ts +34 -23
  96. package/src/math/market.ts +72 -20
  97. package/src/math/oracles.ts +18 -1
  98. package/src/math/orders.ts +33 -25
  99. package/src/math/position.ts +31 -31
  100. package/src/math/spotBalance.ts +316 -0
  101. package/src/math/spotMarket.ts +9 -0
  102. package/src/math/spotPosition.ts +47 -0
  103. package/src/math/state.ts +2 -2
  104. package/src/math/trade.ts +4 -4
  105. package/src/orderParams.ts +16 -8
  106. package/src/serum/serumSubscriber.ts +80 -0
  107. package/src/serum/types.ts +13 -0
  108. package/src/tx/retryTxSender.ts +5 -2
  109. package/src/tx/types.ts +2 -1
  110. package/src/types.ts +135 -56
  111. package/src/userMap/userMap.ts +100 -0
  112. package/src/userMap/userStatsMap.ts +110 -0
  113. package/tests/bn/test.ts +2 -3
  114. package/tests/dlob/helpers.ts +322 -0
  115. package/tests/dlob/test.ts +2865 -0
  116. package/lib/math/bankBalance.d.ts +0 -15
  117. package/lib/math/bankBalance.js +0 -150
  118. package/src/constants/numericConstants.js +0 -41
  119. package/src/math/bankBalance.ts +0 -258
  120. package/src/math/oracles.js +0 -26
  121. package/src/math/state.js +0 -15
  122. package/src/orderParams.js +0 -20
  123. package/src/slot/SlotSubscriber.js +0 -39
  124. package/src/tokenFaucet.js +0 -189
@@ -0,0 +1,110 @@
1
+ import {
2
+ ClearingHouse,
3
+ getUserStatsAccountPublicKey,
4
+ OrderRecord,
5
+ UserStatsAccount,
6
+ ClearingHouseUserStats,
7
+ ClearingHouseUserStatsAccountSubscriptionConfig,
8
+ bulkPollingUserStatsSubscribe,
9
+ } from '..';
10
+ import { ProgramAccount } from '@project-serum/anchor';
11
+ import { PublicKey } from '@solana/web3.js';
12
+
13
+ import { UserMap } from './userMap';
14
+
15
+ export class UserStatsMap {
16
+ /**
17
+ * map from authority pubkey to ClearingHouseUserStats
18
+ */
19
+ private userStatsMap = new Map<string, ClearingHouseUserStats>();
20
+ private clearingHouse: ClearingHouse;
21
+ private accountSubscription: ClearingHouseUserStatsAccountSubscriptionConfig;
22
+
23
+ constructor(
24
+ clearingHouse: ClearingHouse,
25
+ accountSubscription: ClearingHouseUserStatsAccountSubscriptionConfig
26
+ ) {
27
+ this.clearingHouse = clearingHouse;
28
+ this.accountSubscription = accountSubscription;
29
+ }
30
+
31
+ public async fetchAllUserStats() {
32
+ const userStatArray: ClearingHouseUserStats[] = [];
33
+
34
+ const programUserAccounts =
35
+ (await this.clearingHouse.program.account.userStats.all()) as ProgramAccount<UserStatsAccount>[];
36
+
37
+ for (const programUserAccount of programUserAccounts) {
38
+ const userStat: UserStatsAccount = programUserAccount.account;
39
+ if (this.userStatsMap.has(userStat.authority.toString())) {
40
+ continue;
41
+ }
42
+
43
+ const chUserStat = new ClearingHouseUserStats({
44
+ clearingHouse: this.clearingHouse,
45
+ userStatsAccountPublicKey: getUserStatsAccountPublicKey(
46
+ this.clearingHouse.program.programId,
47
+ userStat.authority
48
+ ),
49
+ accountSubscription: this.accountSubscription,
50
+ });
51
+ userStatArray.push(chUserStat);
52
+ }
53
+
54
+ if (this.accountSubscription.type === 'polling') {
55
+ await bulkPollingUserStatsSubscribe(
56
+ userStatArray,
57
+ this.accountSubscription.accountLoader
58
+ );
59
+ }
60
+
61
+ for (const userStat of userStatArray) {
62
+ this.userStatsMap.set(
63
+ userStat.getAccount().authority.toString(),
64
+ userStat
65
+ );
66
+ }
67
+ }
68
+
69
+ public async addUserStat(authority: PublicKey) {
70
+ const userStat = new ClearingHouseUserStats({
71
+ clearingHouse: this.clearingHouse,
72
+ userStatsAccountPublicKey: getUserStatsAccountPublicKey(
73
+ this.clearingHouse.program.programId,
74
+ authority
75
+ ),
76
+ accountSubscription: this.accountSubscription,
77
+ });
78
+ await userStat.subscribe();
79
+
80
+ this.userStatsMap.set(authority.toString(), userStat);
81
+ }
82
+
83
+ public async updateWithOrderRecord(record: OrderRecord, userMap: UserMap) {
84
+ if (!this.has(record.user.toString())) {
85
+ const takerUserAccount = await userMap.mustGet(record.user.toString());
86
+ this.addUserStat(takerUserAccount.getUserAccount().authority);
87
+ }
88
+ }
89
+
90
+ public has(authorityPublicKey: string): boolean {
91
+ return this.userStatsMap.has(authorityPublicKey);
92
+ }
93
+
94
+ public get(authorityPublicKey: string): ClearingHouseUserStats {
95
+ return this.userStatsMap.get(authorityPublicKey);
96
+ }
97
+
98
+ public async mustGet(
99
+ authorityPublicKey: string
100
+ ): Promise<ClearingHouseUserStats> {
101
+ if (!this.has(authorityPublicKey)) {
102
+ await this.addUserStat(new PublicKey(authorityPublicKey));
103
+ }
104
+ return this.get(authorityPublicKey);
105
+ }
106
+
107
+ public values(): IterableIterator<ClearingHouseUserStats> {
108
+ return this.userStatsMap.values();
109
+ }
110
+ }
package/tests/bn/test.ts CHANGED
@@ -70,8 +70,7 @@ describe('BigNum Tests', () => {
70
70
 
71
71
  expect(val.print()).to.equal('1234.56789');
72
72
 
73
- expect(val.toFixed(3)).to.equal('1234.567');
74
-
73
+ expect(val.toNum().toFixed(3)).to.equal('1234.568');
75
74
  expect(val.toPrecision(1)).to.equal('1e3');
76
75
  expect(val.toPrecision(3)).to.equal('123e1');
77
76
  expect(val.toPrecision(4)).to.equal('1234');
@@ -102,7 +101,7 @@ describe('BigNum Tests', () => {
102
101
 
103
102
  expect(val4.toString()).to.equal('250000000000');
104
103
  expect(val4.print()).to.equal('0.0250000000000');
105
- expect(val4.toFixed(3)).to.equal('0.025');
104
+ expect(val4.toNum().toFixed(3)).to.equal('0.025');
106
105
  expect(val4.toPrecision(4)).to.equal('0.025');
107
106
 
108
107
  // Case 5
@@ -0,0 +1,322 @@
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
+ realizedPnl: 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
+ lastOraclePriceTwap: new BN(0),
45
+ lastOraclePriceTwap5min: new BN(0),
46
+ lastOraclePriceTwapTs: new BN(0),
47
+ lastOracleMarkSpreadPct: new BN(0),
48
+ lastOracleConfPct: new BN(0),
49
+ oracle: PublicKey.default,
50
+ oracleSource: OracleSource.PYTH,
51
+ fundingPeriod: new BN(0),
52
+ cumulativeFundingRateLong: new BN(0),
53
+ cumulativeFundingRateShort: new BN(0),
54
+ cumulativeFundingRateLp: new BN(0),
55
+ cumulativeRepegRebateLong: new BN(0),
56
+ cumulativeRepegRebateShort: new BN(0),
57
+ totalFeeMinusDistributions: new BN(0),
58
+ totalFeeWithdrawn: new BN(0),
59
+ totalFee: new BN(0),
60
+ cumulativeFundingPaymentPerLp: new BN(0),
61
+ cumulativeFeePerLp: new BN(0),
62
+ cumulativeNetBaseAssetAmountPerLp: new BN(0),
63
+ userLpShares: new BN(0),
64
+ netUnsettledLpBaseAssetAmount: new BN(0),
65
+ minimumQuoteAssetTradeSize: new BN(0),
66
+ baseAssetAmountStepSize: new BN(0),
67
+ maxBaseAssetAmountRatio: 0,
68
+ lastOraclePrice: new BN(0),
69
+ baseSpread: 0,
70
+ curveUpdateIntensity: 0,
71
+ netBaseAssetAmount: new BN(0),
72
+ quoteAssetAmountLong: new BN(0),
73
+ quoteAssetAmountShort: new BN(0),
74
+ terminalQuoteAssetReserve: new BN(0),
75
+ feePool: {
76
+ balance: new BN(0),
77
+ },
78
+ totalExchangeFee: new BN(0),
79
+ totalMmFee: new BN(0),
80
+ netRevenueSinceLastFunding: new BN(0),
81
+ lastUpdateSlot: new BN(0),
82
+ lastOracleValid: true,
83
+ lastBidPriceTwap: new BN(0),
84
+ lastAskPriceTwap: new BN(0),
85
+ longSpread: new BN(0),
86
+ shortSpread: new BN(0),
87
+ maxSpread: 0,
88
+ marketPosition: mockPerpPosition,
89
+ marketPositionPerLp: mockPerpPosition,
90
+ ammJitIntensity: 0,
91
+ maxBaseAssetReserve: new BN(0),
92
+ minBaseAssetReserve: new BN(0),
93
+ cumulativeSocialLoss: new BN(0),
94
+ };
95
+
96
+ export const mockPerpMarkets: Array<PerpMarketAccount> = [
97
+ {
98
+ status: MarketStatus.INITIALIZED,
99
+ contractType: ContractType.PERPETUAL,
100
+ expiryTs: new BN(0),
101
+ settlementPrice: new BN(0),
102
+ marketIndex: DevnetPerpMarkets[0].marketIndex,
103
+ pubkey: PublicKey.default,
104
+ amm: mockAMM,
105
+ baseAssetAmount: new BN(0),
106
+ baseAssetAmountLong: new BN(0),
107
+ baseAssetAmountShort: new BN(0),
108
+ openInterest: new BN(0),
109
+ marginRatioInitial: 0,
110
+ marginRatioMaintenance: 0,
111
+ nextFillRecordId: new BN(0),
112
+ pnlPool: {
113
+ balance: new BN(0),
114
+ },
115
+ ifLiquidationFee: new BN(0),
116
+ liquidatorFee: new BN(0),
117
+ imfFactor: new BN(0),
118
+ unrealizedImfFactor: new BN(0),
119
+ unrealizedMaxImbalance: new BN(0),
120
+ unrealizedInitialAssetWeight: 0,
121
+ unrealizedMaintenanceAssetWeight: 0,
122
+ revenueWithdrawSinceLastSettle: new BN(0),
123
+ maxRevenueWithdrawPerPeriod: new BN(0),
124
+ lastRevenueWithdrawTs: new BN(0),
125
+ quoteSettledInsurance: new BN(0),
126
+ quoteMaxInsurance: new BN(0),
127
+ },
128
+ {
129
+ status: MarketStatus.INITIALIZED,
130
+ contractType: ContractType.PERPETUAL,
131
+ expiryTs: new BN(0),
132
+ settlementPrice: new BN(0),
133
+ marketIndex: DevnetPerpMarkets[1].marketIndex,
134
+ pubkey: PublicKey.default,
135
+ amm: mockAMM,
136
+ baseAssetAmount: new BN(0),
137
+ baseAssetAmountLong: new BN(0),
138
+ baseAssetAmountShort: new BN(0),
139
+ openInterest: new BN(0),
140
+ marginRatioInitial: 0,
141
+ marginRatioMaintenance: 0,
142
+ nextFillRecordId: new BN(0),
143
+ pnlPool: {
144
+ balance: new BN(0),
145
+ },
146
+ ifLiquidationFee: new BN(0),
147
+ liquidatorFee: new BN(0),
148
+ imfFactor: new BN(0),
149
+ unrealizedImfFactor: new BN(0),
150
+ unrealizedMaxImbalance: new BN(0),
151
+ unrealizedInitialAssetWeight: 0,
152
+ unrealizedMaintenanceAssetWeight: 0,
153
+ revenueWithdrawSinceLastSettle: new BN(0),
154
+ maxRevenueWithdrawPerPeriod: new BN(0),
155
+ lastRevenueWithdrawTs: new BN(0),
156
+ quoteSettledInsurance: new BN(0),
157
+ quoteMaxInsurance: new BN(0),
158
+ },
159
+ {
160
+ status: MarketStatus.INITIALIZED,
161
+ contractType: ContractType.PERPETUAL,
162
+ expiryTs: new BN(0),
163
+ settlementPrice: new BN(0),
164
+ marketIndex: DevnetPerpMarkets[2].marketIndex,
165
+ pubkey: PublicKey.default,
166
+ amm: mockAMM,
167
+ baseAssetAmount: new BN(0),
168
+ baseAssetAmountLong: new BN(0),
169
+ baseAssetAmountShort: new BN(0),
170
+ openInterest: new BN(0),
171
+ marginRatioInitial: 0,
172
+ marginRatioMaintenance: 0,
173
+ nextFillRecordId: new BN(0),
174
+ pnlPool: {
175
+ balance: new BN(0),
176
+ },
177
+ ifLiquidationFee: new BN(0),
178
+ liquidatorFee: new BN(0),
179
+ imfFactor: new BN(0),
180
+ unrealizedImfFactor: new BN(0),
181
+ unrealizedMaxImbalance: new BN(0),
182
+ unrealizedInitialAssetWeight: 0,
183
+ unrealizedMaintenanceAssetWeight: 0,
184
+ revenueWithdrawSinceLastSettle: new BN(0),
185
+ maxRevenueWithdrawPerPeriod: new BN(0),
186
+ lastRevenueWithdrawTs: new BN(0),
187
+ quoteSettledInsurance: new BN(0),
188
+ quoteMaxInsurance: new BN(0),
189
+ },
190
+ ];
191
+
192
+ export const mockSpotMarkets: Array<SpotMarketAccount> = [
193
+ {
194
+ marketIndex: new BN(0),
195
+ pubkey: PublicKey.default,
196
+ mint: DevnetSpotMarkets[0].mint,
197
+ vault: PublicKey.default,
198
+ insuranceFundVault: PublicKey.default,
199
+ insuranceWithdrawEscrowPeriod: new BN(0),
200
+ revenuePool: {
201
+ balance: new BN(0),
202
+ },
203
+ totalIfShares: new BN(0),
204
+ userIfShares: new BN(0),
205
+ userIfFactor: new BN(0),
206
+ totalIfFactor: new BN(0),
207
+ ifLiquidationFee: new BN(0),
208
+ liquidatorFee: new BN(0),
209
+ decimals: 6,
210
+ optimalUtilization: new BN(0),
211
+ optimalBorrowRate: new BN(0),
212
+ maxBorrowRate: new BN(0),
213
+ cumulativeDepositInterest: new BN(0),
214
+ cumulativeBorrowInterest: new BN(0),
215
+ depositBalance: new BN(0),
216
+ borrowBalance: new BN(0),
217
+ lastInterestTs: new BN(0),
218
+ lastTwapTs: new BN(0),
219
+ oracle: PublicKey.default,
220
+ initialAssetWeight: new BN(0),
221
+ maintenanceAssetWeight: new BN(0),
222
+ initialLiabilityWeight: new BN(0),
223
+ maintenanceLiabilityWeight: new BN(0),
224
+ imfFactor: new BN(0),
225
+ withdrawGuardThreshold: new BN(0),
226
+ depositTokenTwap: new BN(0),
227
+ borrowTokenTwap: new BN(0),
228
+ utilizationTwap: new BN(0),
229
+ orderStepSize: new BN(0),
230
+ nextFillRecordId: new BN(0),
231
+ spotFeePool: {
232
+ balance: new BN(0),
233
+ },
234
+ totalSpotFee: new BN(0),
235
+ },
236
+ {
237
+ marketIndex: new BN(1),
238
+ pubkey: PublicKey.default,
239
+ mint: DevnetSpotMarkets[1].mint,
240
+ vault: PublicKey.default,
241
+ insuranceFundVault: PublicKey.default,
242
+ insuranceWithdrawEscrowPeriod: new BN(0),
243
+ revenuePool: {
244
+ balance: new BN(0),
245
+ },
246
+ totalIfShares: new BN(0),
247
+ userIfShares: new BN(0),
248
+ userIfFactor: new BN(0),
249
+ totalIfFactor: new BN(0),
250
+ ifLiquidationFee: new BN(0),
251
+ liquidatorFee: new BN(0),
252
+ decimals: 9,
253
+ optimalUtilization: new BN(0),
254
+ optimalBorrowRate: new BN(0),
255
+ maxBorrowRate: new BN(0),
256
+ cumulativeDepositInterest: new BN(0),
257
+ cumulativeBorrowInterest: new BN(0),
258
+ depositBalance: new BN(0),
259
+ borrowBalance: new BN(0),
260
+ lastInterestTs: new BN(0),
261
+ lastTwapTs: new BN(0),
262
+ oracle: PublicKey.default,
263
+ initialAssetWeight: new BN(0),
264
+ maintenanceAssetWeight: new BN(0),
265
+ initialLiabilityWeight: new BN(0),
266
+ maintenanceLiabilityWeight: new BN(0),
267
+ imfFactor: new BN(0),
268
+ withdrawGuardThreshold: new BN(0),
269
+ depositTokenTwap: new BN(0),
270
+ borrowTokenTwap: new BN(0),
271
+ utilizationTwap: new BN(0),
272
+ orderStepSize: new BN(0),
273
+ nextFillRecordId: new BN(0),
274
+ spotFeePool: {
275
+ balance: new BN(0),
276
+ },
277
+ totalSpotFee: new BN(0),
278
+ },
279
+ {
280
+ marketIndex: new BN(2),
281
+ pubkey: PublicKey.default,
282
+ mint: DevnetSpotMarkets[2].mint,
283
+ vault: PublicKey.default,
284
+ insuranceFundVault: PublicKey.default,
285
+ insuranceWithdrawEscrowPeriod: new BN(0),
286
+ revenuePool: {
287
+ balance: new BN(0),
288
+ },
289
+ totalIfShares: new BN(0),
290
+ userIfShares: new BN(0),
291
+ userIfFactor: new BN(0),
292
+ totalIfFactor: new BN(0),
293
+ ifLiquidationFee: new BN(0),
294
+ liquidatorFee: new BN(0),
295
+ decimals: 6,
296
+ optimalUtilization: new BN(0),
297
+ optimalBorrowRate: new BN(0),
298
+ maxBorrowRate: new BN(0),
299
+ cumulativeDepositInterest: new BN(0),
300
+ cumulativeBorrowInterest: new BN(0),
301
+ depositBalance: new BN(0),
302
+ borrowBalance: new BN(0),
303
+ lastInterestTs: new BN(0),
304
+ lastTwapTs: new BN(0),
305
+ oracle: PublicKey.default,
306
+ initialAssetWeight: new BN(0),
307
+ maintenanceAssetWeight: new BN(0),
308
+ initialLiabilityWeight: new BN(0),
309
+ maintenanceLiabilityWeight: new BN(0),
310
+ imfFactor: new BN(0),
311
+ withdrawGuardThreshold: new BN(0),
312
+ depositTokenTwap: new BN(0),
313
+ borrowTokenTwap: new BN(0),
314
+ utilizationTwap: new BN(0),
315
+ orderStepSize: new BN(0),
316
+ nextFillRecordId: new BN(0),
317
+ spotFeePool: {
318
+ balance: new BN(0),
319
+ },
320
+ totalSpotFee: new BN(0),
321
+ },
322
+ ];