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

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 (184) hide show
  1. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +13 -13
  2. package/lib/accounts/pollingClearingHouseAccountSubscriber.js +27 -27
  3. package/lib/accounts/types.d.ts +8 -9
  4. package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +14 -14
  5. package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +35 -34
  6. package/lib/addresses/pda.d.ts +7 -6
  7. package/lib/addresses/pda.js +31 -27
  8. package/lib/admin.d.ts +9 -6
  9. package/lib/admin.js +83 -42
  10. package/lib/clearingHouse.d.ts +69 -42
  11. package/lib/clearingHouse.js +753 -277
  12. package/lib/clearingHouseConfig.d.ts +2 -2
  13. package/lib/clearingHouseUser.d.ts +16 -16
  14. package/lib/clearingHouseUser.js +139 -119
  15. package/lib/config.d.ts +7 -7
  16. package/lib/config.js +20 -20
  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/{src/constants/markets.js → lib/constants/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/events/types.d.ts +2 -1
  24. package/lib/events/types.js +1 -0
  25. package/lib/examples/makeTradeExample.js +7 -7
  26. package/lib/idl/clearing_house.json +1008 -279
  27. package/lib/index.d.ts +5 -3
  28. package/lib/index.js +5 -3
  29. package/lib/math/amm.d.ts +2 -2
  30. package/lib/math/amm.js +1 -1
  31. package/lib/math/funding.d.ts +6 -6
  32. package/lib/math/funding.js +2 -1
  33. package/lib/math/margin.d.ts +4 -4
  34. package/lib/math/margin.js +18 -11
  35. package/lib/math/market.d.ts +10 -9
  36. package/lib/math/market.js +29 -6
  37. package/lib/math/oracles.d.ts +2 -1
  38. package/lib/math/oracles.js +11 -1
  39. package/lib/math/orders.d.ts +5 -5
  40. package/lib/math/position.d.ts +13 -13
  41. package/lib/math/position.js +19 -19
  42. package/lib/math/spotBalance.d.ts +19 -0
  43. package/lib/math/spotBalance.js +176 -0
  44. package/lib/math/spotMarket.d.ts +4 -0
  45. package/lib/math/spotMarket.js +8 -0
  46. package/lib/math/spotPosition.d.ts +2 -0
  47. package/lib/math/spotPosition.js +8 -0
  48. package/lib/math/state.js +2 -2
  49. package/lib/math/trade.d.ts +4 -4
  50. package/lib/orderParams.d.ts +4 -4
  51. package/lib/orderParams.js +12 -4
  52. package/lib/serum/serumSubscriber.d.ts +23 -0
  53. package/lib/serum/serumSubscriber.js +41 -0
  54. package/lib/serum/types.d.ts +11 -0
  55. package/lib/serum/types.js +2 -0
  56. package/lib/tx/retryTxSender.d.ts +1 -1
  57. package/lib/tx/retryTxSender.js +4 -2
  58. package/lib/tx/types.d.ts +1 -1
  59. package/lib/types.d.ts +123 -33
  60. package/lib/types.js +31 -9
  61. package/my-script/.env +7 -0
  62. package/my-script/getUserStats.ts +106 -0
  63. package/my-script/multiConnections.ts +119 -0
  64. package/my-script/test-regex.ts +11 -0
  65. package/my-script/utils.ts +52 -0
  66. package/package.json +1 -1
  67. package/src/accounts/bulkAccountLoader.js +249 -0
  68. package/src/accounts/bulkUserStatsSubscription.js +75 -0
  69. package/src/accounts/bulkUserSubscription.js +75 -0
  70. package/src/accounts/fetch.js +92 -0
  71. package/src/accounts/pollingClearingHouseAccountSubscriber.js +465 -0
  72. package/src/accounts/pollingClearingHouseAccountSubscriber.ts +38 -38
  73. package/src/accounts/pollingOracleSubscriber.js +156 -0
  74. package/src/accounts/pollingTokenAccountSubscriber.js +141 -0
  75. package/src/accounts/pollingUserAccountSubscriber.js +208 -0
  76. package/src/accounts/pollingUserStatsAccountSubscriber.js +208 -0
  77. package/src/accounts/types.js +28 -0
  78. package/src/accounts/types.ts +11 -9
  79. package/src/accounts/utils.js +7 -0
  80. package/src/accounts/webSocketAccountSubscriber.js +138 -0
  81. package/src/accounts/webSocketClearingHouseAccountSubscriber.js +433 -0
  82. package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +59 -52
  83. package/src/accounts/webSocketUserAccountSubscriber.js +113 -0
  84. package/src/accounts/webSocketUserStatsAccountSubsriber.js +113 -0
  85. package/src/addresses/pda.js +186 -0
  86. package/src/addresses/pda.ts +49 -44
  87. package/src/admin.js +1284 -0
  88. package/src/admin.ts +140 -47
  89. package/src/assert/assert.js +1 -1
  90. package/src/clearingHouse.js +3433 -0
  91. package/src/clearingHouse.ts +1083 -378
  92. package/src/clearingHouseConfig.js +2 -0
  93. package/src/clearingHouseConfig.ts +2 -2
  94. package/src/clearingHouseUser.js +874 -0
  95. package/src/clearingHouseUser.ts +232 -168
  96. package/src/clearingHouseUserConfig.js +2 -0
  97. package/src/clearingHouseUserStats.js +115 -0
  98. package/src/clearingHouseUserStatsConfig.js +2 -0
  99. package/src/config.js +80 -0
  100. package/src/config.ts +29 -29
  101. package/src/constants/numericConstants.js +18 -11
  102. package/src/constants/numericConstants.ts +17 -15
  103. package/{lib/constants/markets.js → src/constants/perpMarkets.js} +11 -11
  104. package/src/constants/{markets.ts → perpMarkets.ts} +5 -5
  105. package/src/constants/spotMarkets.js +51 -0
  106. package/src/constants/{banks.ts → spotMarkets.ts} +19 -19
  107. package/src/events/eventList.js +66 -23
  108. package/src/events/eventSubscriber.js +202 -0
  109. package/src/events/fetchLogs.js +117 -0
  110. package/src/events/pollingLogProvider.js +113 -0
  111. package/src/events/sort.js +41 -0
  112. package/src/events/txEventCache.js +22 -19
  113. package/src/events/types.js +25 -0
  114. package/src/events/types.ts +3 -0
  115. package/src/events/webSocketLogProvider.js +76 -0
  116. package/src/examples/makeTradeExample.ts +10 -8
  117. package/src/factory/bigNum.js +183 -180
  118. package/src/factory/oracleClient.js +9 -9
  119. package/src/idl/clearing_house.json +1008 -279
  120. package/src/index.js +75 -0
  121. package/src/index.ts +5 -3
  122. package/src/math/amm.js +422 -0
  123. package/src/math/amm.ts +6 -3
  124. package/src/math/auction.js +10 -10
  125. package/src/math/conversion.js +4 -3
  126. package/src/math/funding.js +223 -175
  127. package/src/math/funding.ts +7 -7
  128. package/src/math/insurance.js +27 -0
  129. package/src/math/margin.js +77 -0
  130. package/src/math/margin.ts +34 -23
  131. package/src/math/market.js +105 -0
  132. package/src/math/market.ts +71 -19
  133. package/src/math/oracles.js +40 -10
  134. package/src/math/oracles.ts +18 -1
  135. package/src/math/orders.js +153 -0
  136. package/src/math/orders.ts +5 -5
  137. package/src/math/position.js +172 -0
  138. package/src/math/position.ts +31 -31
  139. package/src/math/repeg.js +40 -40
  140. package/src/math/spotBalance.js +176 -0
  141. package/src/math/spotBalance.ts +290 -0
  142. package/src/math/spotMarket.js +8 -0
  143. package/src/math/spotMarket.ts +9 -0
  144. package/src/math/spotPosition.js +8 -0
  145. package/src/math/spotPosition.ts +6 -0
  146. package/src/math/state.ts +2 -2
  147. package/src/math/trade.js +81 -74
  148. package/src/math/trade.ts +4 -4
  149. package/src/math/utils.js +8 -7
  150. package/src/oracles/oracleClientCache.js +10 -9
  151. package/src/oracles/pythClient.js +52 -17
  152. package/src/oracles/quoteAssetOracleClient.js +44 -13
  153. package/src/oracles/switchboardClient.js +69 -37
  154. package/src/oracles/types.js +1 -1
  155. package/src/orderParams.js +14 -6
  156. package/src/orderParams.ts +16 -8
  157. package/src/serum/serumSubscriber.js +102 -0
  158. package/src/serum/serumSubscriber.ts +80 -0
  159. package/src/serum/types.js +2 -0
  160. package/src/serum/types.ts +13 -0
  161. package/src/slot/SlotSubscriber.js +67 -20
  162. package/src/token/index.js +4 -4
  163. package/src/tokenFaucet.js +288 -154
  164. package/src/tx/retryTxSender.js +280 -0
  165. package/src/tx/retryTxSender.ts +5 -2
  166. package/src/tx/types.js +1 -1
  167. package/src/tx/types.ts +2 -1
  168. package/src/tx/utils.js +7 -6
  169. package/src/types.js +216 -0
  170. package/src/types.ts +110 -33
  171. package/src/userName.js +5 -5
  172. package/src/util/computeUnits.js +46 -11
  173. package/src/util/promiseTimeout.js +5 -5
  174. package/src/util/tps.js +46 -12
  175. package/src/wallet.js +55 -18
  176. package/lib/math/bankBalance.d.ts +0 -15
  177. package/lib/math/bankBalance.js +0 -150
  178. package/src/addresses/marketAddresses.js +0 -26
  179. package/src/constants/banks.js +0 -42
  180. package/src/examples/makeTradeExample.js +0 -80
  181. package/src/math/bankBalance.ts +0 -258
  182. package/src/math/state.js +0 -15
  183. package/src/math/utils.js.map +0 -1
  184. package/src/util/getTokenAddress.js +0 -9
package/lib/admin.js CHANGED
@@ -29,6 +29,7 @@ const types_1 = require("./types");
29
29
  const anchor_1 = require("@project-serum/anchor");
30
30
  const anchor = __importStar(require("@project-serum/anchor"));
31
31
  const pda_1 = require("./addresses/pda");
32
+ const utils_1 = require("./math/utils");
32
33
  const spl_token_1 = require("@solana/spl-token");
33
34
  const clearingHouse_1 = require("./clearingHouse");
34
35
  const numericConstants_1 = require("./constants/numericConstants");
@@ -57,20 +58,20 @@ class Admin extends clearingHouse_1.ClearingHouse {
57
58
  const { txSig: initializeTxSig } = await this.txSender.send(initializeTx, [], this.opts);
58
59
  return [initializeTxSig];
59
60
  }
60
- async initializeBank(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = new anchor_1.BN(0), liquidationFee = numericConstants_1.ZERO) {
61
- const bankIndex = this.getStateAccount().numberOfBanks;
62
- const bank = await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex);
63
- const bankVault = await (0, pda_1.getBankVaultPublicKey)(this.program.programId, bankIndex);
64
- const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, bankIndex);
65
- const initializeTx = await this.program.transaction.initializeBank(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidationFee, {
61
+ async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = new anchor_1.BN(0), liquidationFee = numericConstants_1.ZERO) {
62
+ const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
63
+ const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
64
+ const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
65
+ const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
66
+ const initializeTx = await this.program.transaction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidationFee, {
66
67
  accounts: {
67
68
  admin: this.wallet.publicKey,
68
69
  state: await this.getStatePublicKey(),
69
- bank,
70
- bankVault,
70
+ spotMarket,
71
+ spotMarketVault,
71
72
  insuranceFundVault,
72
73
  clearingHouseSigner: this.getSignerPublicKey(),
73
- bankMint: mint,
74
+ spotMarketMint: mint,
74
75
  oracle,
75
76
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
76
77
  systemProgram: anchor.web3.SystemProgram.programId,
@@ -78,13 +79,32 @@ class Admin extends clearingHouse_1.ClearingHouse {
78
79
  },
79
80
  });
80
81
  const { txSig } = await this.txSender.send(initializeTx, [], this.opts);
81
- await this.accountSubscriber.addBank(bankIndex);
82
+ await this.accountSubscriber.addSpotMarket(spotMarketIndex);
82
83
  await this.accountSubscriber.addOracle({
83
84
  source: oracleSource,
84
85
  publicKey: oracle,
85
86
  });
86
87
  return txSig;
87
88
  }
89
+ async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
90
+ const serumOpenOrders = (0, pda_1.getSerumOpenOrdersPublicKey)(this.program.programId, serumMarket);
91
+ const serumFulfillmentConfig = (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
92
+ return await this.program.rpc.initializeSerumFulfillmentConfig(marketIndex, {
93
+ accounts: {
94
+ admin: this.wallet.publicKey,
95
+ state: await this.getStatePublicKey(),
96
+ baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
97
+ quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
98
+ clearingHouseSigner: this.getSignerPublicKey(),
99
+ serumProgram,
100
+ serumMarket,
101
+ serumOpenOrders,
102
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
103
+ systemProgram: anchor.web3.SystemProgram.programId,
104
+ serumFulfillmentConfig,
105
+ },
106
+ });
107
+ }
88
108
  async initializeMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidationFee = numericConstants_1.ZERO) {
89
109
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, this.getStateAccount().numberOfMarkets);
90
110
  const initializeMarketTx = await this.program.transaction.initializeMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidationFee, {
@@ -98,20 +118,23 @@ class Admin extends clearingHouse_1.ClearingHouse {
98
118
  },
99
119
  });
100
120
  const { txSig } = await this.txSender.send(initializeMarketTx, [], this.opts);
101
- await this.accountSubscriber.addMarket(this.getStateAccount().numberOfMarkets);
121
+ await this.accountSubscriber.addPerpMarket(this.getStateAccount().numberOfMarkets);
102
122
  await this.accountSubscriber.addOracle({
103
123
  source: oracleSource,
104
124
  publicKey: priceOracle,
105
125
  });
106
126
  return txSig;
107
127
  }
108
- async moveAmmPrice(baseAssetReserve, quoteAssetReserve, marketIndex) {
128
+ async moveAmmPrice(marketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
109
129
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
110
- return await this.program.rpc.moveAmmPrice(baseAssetReserve, quoteAssetReserve, {
130
+ if (sqrtK == undefined) {
131
+ sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
132
+ }
133
+ return await this.program.rpc.moveAmmPrice(baseAssetReserve, quoteAssetReserve, sqrtK, {
111
134
  accounts: {
112
135
  state: await this.getStatePublicKey(),
113
136
  admin: this.wallet.publicKey,
114
- market: marketPublicKey,
137
+ perpMarket: marketPublicKey,
115
138
  },
116
139
  });
117
140
  }
@@ -121,27 +144,27 @@ class Admin extends clearingHouse_1.ClearingHouse {
121
144
  state: await this.getStatePublicKey(),
122
145
  admin: this.wallet.publicKey,
123
146
  market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
124
- oracle: this.getMarketAccount(marketIndex).amm.oracle,
147
+ oracle: this.getPerpMarketAccount(marketIndex).amm.oracle,
125
148
  },
126
149
  });
127
150
  }
128
- async moveAmmToPrice(marketIndex, targetPrice) {
129
- const market = this.getMarketAccount(marketIndex);
151
+ async moveAmmToPrice(perpMarketIndex, targetPrice) {
152
+ const market = this.getPerpMarketAccount(perpMarketIndex);
130
153
  const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(market, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
131
154
  );
132
155
  const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(market.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
133
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
134
- return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, {
156
+ const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex);
157
+ return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, market.amm.sqrtK, {
135
158
  accounts: {
136
159
  state: await this.getStatePublicKey(),
137
160
  admin: this.wallet.publicKey,
138
- market: marketPublicKey,
161
+ perpMarket: marketPublicKey,
139
162
  },
140
163
  });
141
164
  }
142
165
  async repegAmmCurve(newPeg, marketIndex) {
143
166
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
144
- const ammData = this.getMarketAccount(marketIndex).amm;
167
+ const ammData = this.getPerpMarketAccount(marketIndex).amm;
145
168
  return await this.program.rpc.repegAmmCurve(newPeg, {
146
169
  accounts: {
147
170
  state: await this.getStatePublicKey(),
@@ -152,7 +175,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
152
175
  });
153
176
  }
154
177
  async updateAmmOracleTwap(marketIndex) {
155
- const ammData = this.getMarketAccount(marketIndex).amm;
178
+ const ammData = this.getPerpMarketAccount(marketIndex).amm;
156
179
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
157
180
  return await this.program.rpc.updateAmmOracleTwap({
158
181
  accounts: {
@@ -164,7 +187,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
164
187
  });
165
188
  }
166
189
  async resetAmmOracleTwap(marketIndex) {
167
- const ammData = this.getMarketAccount(marketIndex).amm;
190
+ const ammData = this.getPerpMarketAccount(marketIndex).amm;
168
191
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
169
192
  return await this.program.rpc.resetAmmOracleTwap({
170
193
  accounts: {
@@ -177,12 +200,12 @@ class Admin extends clearingHouse_1.ClearingHouse {
177
200
  }
178
201
  async withdrawFromInsuranceVault(amount, recipient) {
179
202
  const state = await this.getStateAccount();
180
- const bank = this.getQuoteAssetBankAccount();
203
+ const spotMarket = this.getQuoteSpotMarketAccount();
181
204
  return await this.program.rpc.withdrawFromInsuranceVault(amount, {
182
205
  accounts: {
183
206
  admin: this.wallet.publicKey,
184
207
  state: await this.getStatePublicKey(),
185
- bank: bank.pubkey,
208
+ spotMarket: spotMarket.pubkey,
186
209
  insuranceVault: state.insuranceVault,
187
210
  clearingHouseSigner: this.getSignerPublicKey(),
188
211
  recipient: recipient,
@@ -192,14 +215,14 @@ class Admin extends clearingHouse_1.ClearingHouse {
192
215
  }
193
216
  async withdrawFromMarketToInsuranceVault(marketIndex, amount, recipient) {
194
217
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
195
- const bank = this.getQuoteAssetBankAccount();
218
+ const spotMarket = this.getQuoteSpotMarketAccount();
196
219
  return await this.program.rpc.withdrawFromMarketToInsuranceVault(amount, {
197
220
  accounts: {
198
221
  admin: this.wallet.publicKey,
199
222
  state: await this.getStatePublicKey(),
200
223
  market: marketPublicKey,
201
- bank: bank.pubkey,
202
- bankVault: bank.vault,
224
+ spotMarket: spotMarket.pubkey,
225
+ spotMarketVault: spotMarket.vault,
203
226
  clearingHouseSigner: this.getSignerPublicKey(),
204
227
  recipient: recipient,
205
228
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -208,7 +231,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
208
231
  }
209
232
  async withdrawFromInsuranceVaultToMarket(marketIndex, amount) {
210
233
  const state = await this.getStateAccount();
211
- const bank = this.getQuoteAssetBankAccount();
234
+ const spotMarket = this.getQuoteSpotMarketAccount();
212
235
  return await this.program.rpc.withdrawFromInsuranceVaultToMarket(amount, {
213
236
  accounts: {
214
237
  admin: this.wallet.publicKey,
@@ -216,8 +239,8 @@ class Admin extends clearingHouse_1.ClearingHouse {
216
239
  market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
217
240
  insuranceVault: state.insuranceVault,
218
241
  clearingHouseSigner: this.getSignerPublicKey(),
219
- bank: bank.pubkey,
220
- bankVault: bank.vault,
242
+ quoteSpotMarket: spotMarket.pubkey,
243
+ spotMarketVault: spotMarket.vault,
221
244
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
222
245
  },
223
246
  });
@@ -341,30 +364,30 @@ class Admin extends clearingHouse_1.ClearingHouse {
341
364
  },
342
365
  });
343
366
  }
344
- async updateBankWithdrawGuardThreshold(bankIndex, withdrawGuardThreshold) {
345
- return await this.program.rpc.updateBankWithdrawGuardThreshold(withdrawGuardThreshold, {
367
+ async updateWithdrawGuardThreshold(marketIndex, withdrawGuardThreshold) {
368
+ return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
346
369
  accounts: {
347
370
  admin: this.wallet.publicKey,
348
371
  state: await this.getStatePublicKey(),
349
- bank: await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex),
372
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
350
373
  },
351
374
  });
352
375
  }
353
- async updateBankIfFactor(bankIndex, userIfFactor, totalIfFactor, liquidationIfFactor) {
354
- return await this.program.rpc.updateBankIfFactor(bankIndex, userIfFactor, totalIfFactor, liquidationIfFactor, {
376
+ async updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor, liquidationIfFactor) {
377
+ return await this.program.rpc.updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor, liquidationIfFactor, {
355
378
  accounts: {
356
379
  admin: this.wallet.publicKey,
357
380
  state: await this.getStatePublicKey(),
358
- bank: await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex),
381
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
359
382
  },
360
383
  });
361
384
  }
362
- async updateBankInsuranceWithdrawEscrowPeriod(bankIndex, insuranceWithdrawEscrowPeriod) {
363
- return await this.program.rpc.updateBankInsuranceWithdrawEscrowPeriod(insuranceWithdrawEscrowPeriod, {
385
+ async updateInsuranceWithdrawEscrowPeriod(marketIndex, insuranceWithdrawEscrowPeriod) {
386
+ return await this.program.rpc.updateInsuranceWithdrawEscrowPeriod(insuranceWithdrawEscrowPeriod, {
364
387
  accounts: {
365
388
  admin: this.wallet.publicKey,
366
389
  state: await this.getStatePublicKey(),
367
- bank: await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex),
390
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
368
391
  },
369
392
  });
370
393
  }
@@ -404,6 +427,15 @@ class Admin extends clearingHouse_1.ClearingHouse {
404
427
  },
405
428
  });
406
429
  }
430
+ async updateMarketExpiry(perpMarketIndex, expiryTs) {
431
+ return await this.program.rpc.updateMarketExpiry(expiryTs, {
432
+ accounts: {
433
+ admin: this.wallet.publicKey,
434
+ state: await this.getStatePublicKey(),
435
+ perpMarket: await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex),
436
+ },
437
+ });
438
+ }
407
439
  async updateWhitelistMint(whitelistMint) {
408
440
  return await this.program.rpc.updateWhitelistMint(whitelistMint, {
409
441
  accounts: {
@@ -465,7 +497,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
465
497
  accounts: {
466
498
  admin: this.wallet.publicKey,
467
499
  state: await this.getStatePublicKey(),
468
- market: this.getMarketAccount(marketIndex).pubkey,
500
+ market: this.getPerpMarketAccount(marketIndex).pubkey,
469
501
  },
470
502
  });
471
503
  }
@@ -474,7 +506,16 @@ class Admin extends clearingHouse_1.ClearingHouse {
474
506
  accounts: {
475
507
  admin: this.wallet.publicKey,
476
508
  state: await this.getStatePublicKey(),
477
- market: this.getMarketAccount(marketIndex).pubkey,
509
+ market: this.getPerpMarketAccount(marketIndex).pubkey,
510
+ },
511
+ });
512
+ }
513
+ async updateMarketMaxImbalances(marketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
514
+ return await this.program.rpc.updateMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
515
+ accounts: {
516
+ admin: this.wallet.publicKey,
517
+ state: await this.getStatePublicKey(),
518
+ market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
478
519
  },
479
520
  });
480
521
  }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="bn.js" />
3
3
  import { AnchorProvider, BN, Program } from '@project-serum/anchor';
4
- import { StateAccount, IWallet, PositionDirection, UserAccount, MarketAccount, OrderParams, Order, BankAccount, UserBankBalance, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo } from './types';
5
- import { Connection, PublicKey, TransactionSignature, ConfirmOptions, TransactionInstruction, AccountMeta } from '@solana/web3.js';
4
+ import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, SerumV3FulfillmentConfigAccount } from './types';
5
+ import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta } from '@solana/web3.js';
6
6
  import { TokenFaucet } from './tokenFaucet';
7
7
  import { EventEmitter } from 'events';
8
8
  import StrictEventEmitter from 'strict-event-emitter-types';
@@ -50,11 +50,12 @@ export declare class ClearingHouse {
50
50
  signerPublicKey?: PublicKey;
51
51
  getSignerPublicKey(): PublicKey;
52
52
  getStateAccount(): StateAccount;
53
- getMarketAccount(marketIndex: BN | number): MarketAccount | undefined;
54
- getMarketAccounts(): MarketAccount[];
55
- getBankAccount(bankIndex: BN | number): BankAccount | undefined;
56
- getQuoteAssetBankAccount(): BankAccount;
53
+ getPerpMarketAccount(marketIndex: BN | number): PerpMarketAccount | undefined;
54
+ getPerpMarketAccounts(): PerpMarketAccount[];
55
+ getSpotMarketAccount(marketIndex: BN | number): SpotMarketAccount | undefined;
56
+ getQuoteSpotMarketAccount(): SpotMarketAccount;
57
57
  getOraclePriceDataAndSlot(oraclePublicKey: PublicKey): DataAndSlot<OraclePriceData> | undefined;
58
+ getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>;
58
59
  /**
59
60
  * Update the wallet to use for clearing house transactions and linked user account
60
61
  * @param newWallet
@@ -67,6 +68,7 @@ export declare class ClearingHouse {
67
68
  initializeUserAccount(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
68
69
  getInitializeUserInstructions(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
69
70
  getInitializeUserStatsIx(): Promise<TransactionInstruction>;
71
+ updateUserName(name: string, userId?: number): Promise<TransactionSignature>;
70
72
  getUser(userId?: number): ClearingHouseUser;
71
73
  getUsers(): ClearingHouseUser[];
72
74
  getUserStats(): ClearingHouseUserStats;
@@ -75,17 +77,18 @@ export declare class ClearingHouse {
75
77
  getUserAccountPublicKey(): Promise<PublicKey>;
76
78
  getUserAccount(userId?: number): UserAccount | undefined;
77
79
  getUserAccountAndSlot(userId?: number): DataAndSlot<UserAccount> | undefined;
78
- getUserBankBalance(bankIndex: number | BN): UserBankBalance | undefined;
80
+ getSpotPosition(marketIndex: number | BN): SpotPosition | undefined;
79
81
  getQuoteAssetTokenAmount(): BN;
80
82
  getRemainingAccounts(params: {
81
- writableMarketIndex?: BN;
82
- writableBankIndex?: BN;
83
- readableMarketIndex?: BN;
83
+ writablePerpMarketIndex?: BN;
84
+ writableSpotMarketIndex?: BN;
85
+ readablePerpMarketIndex?: BN;
86
+ readableSpotMarketIndex?: BN;
84
87
  }): AccountMeta[];
85
88
  getOrder(orderId: BN | number): Order | undefined;
86
89
  getOrderByUserId(userOrderId: number): Order | undefined;
87
- deposit(amount: BN, bankIndex: BN, collateralAccountPublicKey: PublicKey, userId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
88
- getDepositInstruction(amount: BN, bankIndex: BN, userTokenAccount: PublicKey, userId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
90
+ deposit(amount: BN, marketIndex: BN, collateralAccountPublicKey: PublicKey, userId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
91
+ getDepositInstruction(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, userId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
89
92
  private checkIfAccountExists;
90
93
  private getSolWithdrawalIxs;
91
94
  private getWrappedSolAccountCreationIxs;
@@ -93,20 +96,20 @@ export declare class ClearingHouse {
93
96
  * Creates the Clearing House User account for a user, and deposits some initial collateral
94
97
  * @param amount
95
98
  * @param userTokenAccount
96
- * @param bankIndex
99
+ * @param marketIndex
97
100
  * @param userId
98
101
  * @param name
99
102
  * @param fromUserId
100
103
  * @returns
101
104
  */
102
- initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, bankIndex?: BN, userId?: number, name?: string, fromUserId?: number, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
103
- initializeUserAccountForDevnet(userId: number, name: string, bankIndex: BN, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
104
- withdraw(amount: BN, bankIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
105
- getWithdrawIx(amount: BN, bankIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
106
- transferDeposit(amount: BN, bankIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionSignature>;
107
- getTransferDepositIx(amount: BN, bankIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionInstruction>;
108
- updateBankCumulativeInterest(bankIndex: BN): Promise<TransactionSignature>;
109
- updateBankCumulativeInterestIx(bankIndex: BN): Promise<TransactionInstruction>;
105
+ initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: BN, userId?: number, name?: string, fromUserId?: number, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
106
+ initializeUserAccountForDevnet(userId: number, name: string, marketIndex: BN, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
107
+ withdraw(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
108
+ getWithdrawIx(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
109
+ transferDeposit(amount: BN, marketIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionSignature>;
110
+ getTransferDepositIx(amount: BN, marketIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionInstruction>;
111
+ updateSpotMarketCumulativeInterest(marketIndex: BN): Promise<TransactionSignature>;
112
+ updateSpotMarketCumulativeInterestIx(marketIndex: BN): Promise<TransactionInstruction>;
110
113
  settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
111
114
  settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
112
115
  removeLiquidity(marketIndex: BN, sharesToBurn?: BN): Promise<TransactionSignature>;
@@ -114,19 +117,39 @@ export declare class ClearingHouse {
114
117
  addLiquidity(amount: BN, marketIndex: BN): Promise<TransactionSignature>;
115
118
  getAddLiquidityIx(amount: BN, marketIndex: BN): Promise<TransactionInstruction>;
116
119
  openPosition(direction: PositionDirection, amount: BN, marketIndex: BN, limitPrice?: BN): Promise<TransactionSignature>;
120
+ sendSignedTx(tx: Transaction): Promise<TransactionSignature>;
121
+ /**
122
+ * Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
123
+ * @param orderParams
124
+ * @param userAccountPublicKey
125
+ * @param userAccount
126
+ * @returns
127
+ */
128
+ sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<{
129
+ txSig: TransactionSignature;
130
+ signedFillTx: Transaction;
131
+ }>;
117
132
  placeOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
118
- getOrderParams(optionalOrderParams: OptionalOrderParams): OrderParams;
133
+ getOrderParams(optionalOrderParams: OptionalOrderParams, marketType: MarketType): OrderParams;
119
134
  getPlaceOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
120
135
  updateAMMs(marketIndexes: BN[]): Promise<TransactionSignature>;
121
136
  getUpdateAMMsIx(marketIndexes: BN[]): Promise<TransactionInstruction>;
137
+ settleExpiredMarket(marketIndex: BN): Promise<TransactionSignature>;
138
+ getSettleExpiredMarketIx(marketIndex: BN): Promise<TransactionInstruction>;
122
139
  cancelOrder(orderId?: BN): Promise<TransactionSignature>;
123
140
  getCancelOrderIx(orderId?: BN): Promise<TransactionInstruction>;
124
141
  cancelOrderByUserId(userOrderId: number): Promise<TransactionSignature>;
125
142
  getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
126
143
  fillOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
127
- getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
144
+ getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
145
+ placeSpotOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
146
+ getPlaceSpotOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
147
+ fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
148
+ getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
128
149
  triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
129
150
  getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
151
+ triggerSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
152
+ getTriggerSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
130
153
  placeAndTake(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
131
154
  getPlaceAndTakeIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
132
155
  placeAndMake(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
@@ -143,22 +166,24 @@ export declare class ClearingHouse {
143
166
  }[], marketIndex: BN): Promise<TransactionSignature>;
144
167
  settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
145
168
  settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
169
+ settleExpiredPosition(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
170
+ getSettleExpiredPositionIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
146
171
  liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN, maxBaseAssetAmount: BN): Promise<TransactionSignature>;
147
172
  getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN, maxBaseAssetAmount: BN): Promise<TransactionInstruction>;
148
- liquidateBorrow(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetBankIndex: BN, liabilityBankIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
149
- getLiquidateBorrowIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetBankIndex: BN, liabilityBankIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
150
- liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilityBankIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
151
- getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilityBankIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
152
- liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetBankIndex: BN, maxPnlTransfer: BN): Promise<TransactionSignature>;
153
- getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetBankIndex: BN, maxPnlTransfer: BN): Promise<TransactionInstruction>;
154
- resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, bankIndex: BN, marketIndex: BN): Promise<TransactionSignature>;
155
- getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, bankIndex: BN, marketIndex: BN): Promise<TransactionInstruction>;
156
- resolveBorrowBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, bankIndex: BN): Promise<TransactionSignature>;
157
- getResolveBorrowBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, bankIndex: BN): Promise<TransactionInstruction>;
173
+ liquidateBorrow(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetmarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
174
+ getLiquidateBorrowIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetmarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
175
+ liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
176
+ getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
177
+ liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetMarketIndex: BN, maxPnlTransfer: BN): Promise<TransactionSignature>;
178
+ getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetMarketIndex: BN, maxPnlTransfer: BN): Promise<TransactionInstruction>;
179
+ resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
180
+ getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
181
+ resolveBorrowBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
182
+ getResolveBorrowBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
158
183
  getRemainingAccountsWithCounterparty(params: {
159
184
  counterPartyUserAccount: UserAccount;
160
- writableMarketIndex?: BN;
161
- writableBankIndexes?: BN[];
185
+ writablePerpMarketIndex?: BN;
186
+ writableSpotMarketIndexes?: BN[];
162
187
  }): AccountMeta[];
163
188
  updateFundingRate(oracle: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
164
189
  getUpdateFundingRateIx(oracle: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
@@ -166,11 +191,13 @@ export declare class ClearingHouse {
166
191
  getSettleFundingPaymentIx(userAccount: PublicKey): Promise<TransactionInstruction>;
167
192
  triggerEvent(eventName: keyof ClearingHouseAccountEvents, data?: any): void;
168
193
  getOracleDataForMarket(marketIndex: BN): OraclePriceData;
169
- initializeInsuranceFundStake(bankIndex: BN): Promise<TransactionSignature>;
170
- getInitializeInsuranceFundStakeIx(bankIndex: BN): Promise<TransactionInstruction>;
171
- addInsuranceFundStake(bankIndex: BN, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
172
- requestRemoveInsuranceFundStake(bankIndex: BN, amount: BN): Promise<TransactionSignature>;
173
- cancelRequestRemoveInsuranceFundStake(bankIndex: BN): Promise<TransactionSignature>;
174
- removeInsuranceFundStake(bankIndex: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
175
- settleRevenueToInsuranceFund(bankIndex: BN): Promise<TransactionSignature>;
194
+ initializeInsuranceFundStake(marketIndex: BN): Promise<TransactionSignature>;
195
+ getInitializeInsuranceFundStakeIx(marketIndex: BN): Promise<TransactionInstruction>;
196
+ addInsuranceFundStake(marketIndex: BN, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
197
+ requestRemoveInsuranceFundStake(marketIndex: BN, amount: BN): Promise<TransactionSignature>;
198
+ cancelRequestRemoveInsuranceFundStake(marketIndex: BN): Promise<TransactionSignature>;
199
+ removeInsuranceFundStake(marketIndex: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
200
+ settleRevenueToInsuranceFund(marketIndex: BN): Promise<TransactionSignature>;
201
+ resolvePerpPnlDeficit(spotMarketIndex: BN, perpMarketIndex: BN): Promise<TransactionSignature>;
202
+ getResolvePerpPnlDeficitIx(spotMarketIndex: BN, perpMarketIndex: BN): Promise<TransactionInstruction>;
176
203
  }