@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
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,36 @@ 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 updateConcentrationScale(marketIndex, concentrationScale) {
152
+ return await this.program.rpc.updateConcentrationScale(concentrationScale, {
153
+ accounts: {
154
+ state: await this.getStatePublicKey(),
155
+ admin: this.wallet.publicKey,
156
+ market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
157
+ },
158
+ });
159
+ }
160
+ async moveAmmToPrice(perpMarketIndex, targetPrice) {
161
+ const market = this.getPerpMarketAccount(perpMarketIndex);
130
162
  const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(market, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
131
163
  );
132
164
  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, {
165
+ const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex);
166
+ return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, market.amm.sqrtK, {
135
167
  accounts: {
136
168
  state: await this.getStatePublicKey(),
137
169
  admin: this.wallet.publicKey,
138
- market: marketPublicKey,
170
+ perpMarket: marketPublicKey,
139
171
  },
140
172
  });
141
173
  }
142
174
  async repegAmmCurve(newPeg, marketIndex) {
143
175
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
144
- const ammData = this.getMarketAccount(marketIndex).amm;
176
+ const ammData = this.getPerpMarketAccount(marketIndex).amm;
145
177
  return await this.program.rpc.repegAmmCurve(newPeg, {
146
178
  accounts: {
147
179
  state: await this.getStatePublicKey(),
@@ -152,7 +184,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
152
184
  });
153
185
  }
154
186
  async updateAmmOracleTwap(marketIndex) {
155
- const ammData = this.getMarketAccount(marketIndex).amm;
187
+ const ammData = this.getPerpMarketAccount(marketIndex).amm;
156
188
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
157
189
  return await this.program.rpc.updateAmmOracleTwap({
158
190
  accounts: {
@@ -164,7 +196,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
164
196
  });
165
197
  }
166
198
  async resetAmmOracleTwap(marketIndex) {
167
- const ammData = this.getMarketAccount(marketIndex).amm;
199
+ const ammData = this.getPerpMarketAccount(marketIndex).amm;
168
200
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
169
201
  return await this.program.rpc.resetAmmOracleTwap({
170
202
  accounts: {
@@ -177,12 +209,12 @@ class Admin extends clearingHouse_1.ClearingHouse {
177
209
  }
178
210
  async withdrawFromInsuranceVault(amount, recipient) {
179
211
  const state = await this.getStateAccount();
180
- const bank = this.getQuoteAssetBankAccount();
212
+ const spotMarket = this.getQuoteSpotMarketAccount();
181
213
  return await this.program.rpc.withdrawFromInsuranceVault(amount, {
182
214
  accounts: {
183
215
  admin: this.wallet.publicKey,
184
216
  state: await this.getStatePublicKey(),
185
- bank: bank.pubkey,
217
+ spotMarket: spotMarket.pubkey,
186
218
  insuranceVault: state.insuranceVault,
187
219
  clearingHouseSigner: this.getSignerPublicKey(),
188
220
  recipient: recipient,
@@ -192,14 +224,14 @@ class Admin extends clearingHouse_1.ClearingHouse {
192
224
  }
193
225
  async withdrawFromMarketToInsuranceVault(marketIndex, amount, recipient) {
194
226
  const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
195
- const bank = this.getQuoteAssetBankAccount();
227
+ const spotMarket = this.getQuoteSpotMarketAccount();
196
228
  return await this.program.rpc.withdrawFromMarketToInsuranceVault(amount, {
197
229
  accounts: {
198
230
  admin: this.wallet.publicKey,
199
231
  state: await this.getStatePublicKey(),
200
232
  market: marketPublicKey,
201
- bank: bank.pubkey,
202
- bankVault: bank.vault,
233
+ spotMarket: spotMarket.pubkey,
234
+ spotMarketVault: spotMarket.vault,
203
235
  clearingHouseSigner: this.getSignerPublicKey(),
204
236
  recipient: recipient,
205
237
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -208,7 +240,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
208
240
  }
209
241
  async withdrawFromInsuranceVaultToMarket(marketIndex, amount) {
210
242
  const state = await this.getStateAccount();
211
- const bank = this.getQuoteAssetBankAccount();
243
+ const spotMarket = this.getQuoteSpotMarketAccount();
212
244
  return await this.program.rpc.withdrawFromInsuranceVaultToMarket(amount, {
213
245
  accounts: {
214
246
  admin: this.wallet.publicKey,
@@ -216,8 +248,8 @@ class Admin extends clearingHouse_1.ClearingHouse {
216
248
  market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
217
249
  insuranceVault: state.insuranceVault,
218
250
  clearingHouseSigner: this.getSignerPublicKey(),
219
- bank: bank.pubkey,
220
- bankVault: bank.vault,
251
+ quoteSpotMarket: spotMarket.pubkey,
252
+ spotMarketVault: spotMarket.vault,
221
253
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
222
254
  },
223
255
  });
@@ -341,30 +373,39 @@ class Admin extends clearingHouse_1.ClearingHouse {
341
373
  },
342
374
  });
343
375
  }
344
- async updateBankWithdrawGuardThreshold(bankIndex, withdrawGuardThreshold) {
345
- return await this.program.rpc.updateBankWithdrawGuardThreshold(withdrawGuardThreshold, {
376
+ async updateWithdrawGuardThreshold(marketIndex, withdrawGuardThreshold) {
377
+ return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
346
378
  accounts: {
347
379
  admin: this.wallet.publicKey,
348
380
  state: await this.getStatePublicKey(),
349
- bank: await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex),
381
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
350
382
  },
351
383
  });
352
384
  }
353
- async updateBankIfFactor(bankIndex, userIfFactor, totalIfFactor, liquidationIfFactor) {
354
- return await this.program.rpc.updateBankIfFactor(bankIndex, userIfFactor, totalIfFactor, liquidationIfFactor, {
385
+ async updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor) {
386
+ return await this.program.rpc.updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor, {
355
387
  accounts: {
356
388
  admin: this.wallet.publicKey,
357
389
  state: await this.getStatePublicKey(),
358
- bank: await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex),
390
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
359
391
  },
360
392
  });
361
393
  }
362
- async updateBankInsuranceWithdrawEscrowPeriod(bankIndex, insuranceWithdrawEscrowPeriod) {
363
- return await this.program.rpc.updateBankInsuranceWithdrawEscrowPeriod(insuranceWithdrawEscrowPeriod, {
394
+ async updateSpotMarketRevenueSettlePeriod(marketIndex, revenueSettlePeriod) {
395
+ return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
364
396
  accounts: {
365
397
  admin: this.wallet.publicKey,
366
398
  state: await this.getStatePublicKey(),
367
- bank: await (0, pda_1.getBankPublicKey)(this.program.programId, bankIndex),
399
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
400
+ },
401
+ });
402
+ }
403
+ async updateInsuranceWithdrawEscrowPeriod(marketIndex, insuranceWithdrawEscrowPeriod) {
404
+ return await this.program.rpc.updateInsuranceWithdrawEscrowPeriod(insuranceWithdrawEscrowPeriod, {
405
+ accounts: {
406
+ admin: this.wallet.publicKey,
407
+ state: await this.getStatePublicKey(),
408
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
368
409
  },
369
410
  });
370
411
  }
@@ -404,6 +445,15 @@ class Admin extends clearingHouse_1.ClearingHouse {
404
445
  },
405
446
  });
406
447
  }
448
+ async updateMarketExpiry(perpMarketIndex, expiryTs) {
449
+ return await this.program.rpc.updateMarketExpiry(expiryTs, {
450
+ accounts: {
451
+ admin: this.wallet.publicKey,
452
+ state: await this.getStatePublicKey(),
453
+ perpMarket: await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex),
454
+ },
455
+ });
456
+ }
407
457
  async updateWhitelistMint(whitelistMint) {
408
458
  return await this.program.rpc.updateWhitelistMint(whitelistMint, {
409
459
  accounts: {
@@ -452,8 +502,16 @@ class Admin extends clearingHouse_1.ClearingHouse {
452
502
  },
453
503
  });
454
504
  }
455
- async updateAuctionDuration(minDuration, maxDuration) {
456
- return await this.program.rpc.updateAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), typeof maxDuration === 'number' ? maxDuration : maxDuration.toNumber(), {
505
+ async updatePerpAuctionDuration(minDuration) {
506
+ return await this.program.rpc.updatePerpAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), {
507
+ accounts: {
508
+ admin: this.wallet.publicKey,
509
+ state: await this.getStatePublicKey(),
510
+ },
511
+ });
512
+ }
513
+ async updateSpotAuctionDuration(defaultAuctionDuration) {
514
+ return await this.program.rpc.updateSpotAuctionDuration(defaultAuctionDuration, {
457
515
  accounts: {
458
516
  admin: this.wallet.publicKey,
459
517
  state: await this.getStatePublicKey(),
@@ -465,7 +523,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
465
523
  accounts: {
466
524
  admin: this.wallet.publicKey,
467
525
  state: await this.getStatePublicKey(),
468
- market: this.getMarketAccount(marketIndex).pubkey,
526
+ market: this.getPerpMarketAccount(marketIndex).pubkey,
469
527
  },
470
528
  });
471
529
  }
@@ -474,7 +532,16 @@ class Admin extends clearingHouse_1.ClearingHouse {
474
532
  accounts: {
475
533
  admin: this.wallet.publicKey,
476
534
  state: await this.getStatePublicKey(),
477
- market: this.getMarketAccount(marketIndex).pubkey,
535
+ market: this.getPerpMarketAccount(marketIndex).pubkey,
536
+ },
537
+ });
538
+ }
539
+ async updateMarketMaxImbalances(marketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
540
+ return await this.program.rpc.updateMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
541
+ accounts: {
542
+ admin: this.wallet.publicKey,
543
+ state: await this.getStatePublicKey(),
544
+ market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
478
545
  },
479
546
  });
480
547
  }
@@ -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,13 @@ 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
+ getSpotMarketAccounts(): SpotMarketAccount[];
57
+ getQuoteSpotMarketAccount(): SpotMarketAccount;
57
58
  getOraclePriceDataAndSlot(oraclePublicKey: PublicKey): DataAndSlot<OraclePriceData> | undefined;
59
+ getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>;
58
60
  /**
59
61
  * Update the wallet to use for clearing house transactions and linked user account
60
62
  * @param newWallet
@@ -67,6 +69,8 @@ export declare class ClearingHouse {
67
69
  initializeUserAccount(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
68
70
  getInitializeUserInstructions(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
69
71
  getInitializeUserStatsIx(): Promise<TransactionInstruction>;
72
+ updateUserName(name: string, userId?: number): Promise<TransactionSignature>;
73
+ updateUserCustomMarginRatio(marginRatio: number, userId?: number): Promise<TransactionSignature>;
70
74
  getUser(userId?: number): ClearingHouseUser;
71
75
  getUsers(): ClearingHouseUser[];
72
76
  getUserStats(): ClearingHouseUserStats;
@@ -75,17 +79,18 @@ export declare class ClearingHouse {
75
79
  getUserAccountPublicKey(): Promise<PublicKey>;
76
80
  getUserAccount(userId?: number): UserAccount | undefined;
77
81
  getUserAccountAndSlot(userId?: number): DataAndSlot<UserAccount> | undefined;
78
- getUserBankBalance(bankIndex: number | BN): UserBankBalance | undefined;
82
+ getSpotPosition(marketIndex: number | BN): SpotPosition | undefined;
79
83
  getQuoteAssetTokenAmount(): BN;
80
84
  getRemainingAccounts(params: {
81
- writableMarketIndex?: BN;
82
- writableBankIndex?: BN;
83
- readableMarketIndex?: BN;
85
+ writablePerpMarketIndex?: BN;
86
+ writableSpotMarketIndex?: BN;
87
+ readablePerpMarketIndex?: BN;
88
+ readableSpotMarketIndex?: BN;
84
89
  }): AccountMeta[];
85
90
  getOrder(orderId: BN | number): Order | undefined;
86
91
  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>;
92
+ deposit(amount: BN, marketIndex: BN, collateralAccountPublicKey: PublicKey, userId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
93
+ getDepositInstruction(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, userId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
89
94
  private checkIfAccountExists;
90
95
  private getSolWithdrawalIxs;
91
96
  private getWrappedSolAccountCreationIxs;
@@ -93,20 +98,20 @@ export declare class ClearingHouse {
93
98
  * Creates the Clearing House User account for a user, and deposits some initial collateral
94
99
  * @param amount
95
100
  * @param userTokenAccount
96
- * @param bankIndex
101
+ * @param marketIndex
97
102
  * @param userId
98
103
  * @param name
99
104
  * @param fromUserId
100
105
  * @returns
101
106
  */
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>;
107
+ initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: BN, userId?: number, name?: string, fromUserId?: number, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
108
+ initializeUserAccountForDevnet(userId: number, name: string, marketIndex: BN, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
109
+ withdraw(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
110
+ getWithdrawIx(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
111
+ transferDeposit(amount: BN, marketIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionSignature>;
112
+ getTransferDepositIx(amount: BN, marketIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionInstruction>;
113
+ updateSpotMarketCumulativeInterest(marketIndex: BN): Promise<TransactionSignature>;
114
+ updateSpotMarketCumulativeInterestIx(marketIndex: BN): Promise<TransactionInstruction>;
110
115
  settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
111
116
  settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
112
117
  removeLiquidity(marketIndex: BN, sharesToBurn?: BN): Promise<TransactionSignature>;
@@ -114,19 +119,39 @@ export declare class ClearingHouse {
114
119
  addLiquidity(amount: BN, marketIndex: BN): Promise<TransactionSignature>;
115
120
  getAddLiquidityIx(amount: BN, marketIndex: BN): Promise<TransactionInstruction>;
116
121
  openPosition(direction: PositionDirection, amount: BN, marketIndex: BN, limitPrice?: BN): Promise<TransactionSignature>;
122
+ sendSignedTx(tx: Transaction): Promise<TransactionSignature>;
123
+ /**
124
+ * 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.
125
+ * @param orderParams
126
+ * @param userAccountPublicKey
127
+ * @param userAccount
128
+ * @returns
129
+ */
130
+ sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<{
131
+ txSig: TransactionSignature;
132
+ signedFillTx: Transaction;
133
+ }>;
117
134
  placeOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
118
- getOrderParams(optionalOrderParams: OptionalOrderParams): OrderParams;
135
+ getOrderParams(optionalOrderParams: OptionalOrderParams, marketType: MarketType): OrderParams;
119
136
  getPlaceOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
120
137
  updateAMMs(marketIndexes: BN[]): Promise<TransactionSignature>;
121
138
  getUpdateAMMsIx(marketIndexes: BN[]): Promise<TransactionInstruction>;
139
+ settleExpiredMarket(marketIndex: BN): Promise<TransactionSignature>;
140
+ getSettleExpiredMarketIx(marketIndex: BN): Promise<TransactionInstruction>;
122
141
  cancelOrder(orderId?: BN): Promise<TransactionSignature>;
123
142
  getCancelOrderIx(orderId?: BN): Promise<TransactionInstruction>;
124
143
  cancelOrderByUserId(userOrderId: number): Promise<TransactionSignature>;
125
144
  getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
126
145
  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>;
146
+ getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
147
+ placeSpotOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
148
+ getPlaceSpotOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
149
+ fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
150
+ getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
128
151
  triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
129
152
  getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
153
+ triggerSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
154
+ getTriggerSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
130
155
  placeAndTake(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
131
156
  getPlaceAndTakeIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
132
157
  placeAndMake(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
@@ -143,22 +168,24 @@ export declare class ClearingHouse {
143
168
  }[], marketIndex: BN): Promise<TransactionSignature>;
144
169
  settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
145
170
  settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
171
+ settleExpiredPosition(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
172
+ getSettleExpiredPositionIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
146
173
  liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN, maxBaseAssetAmount: BN): Promise<TransactionSignature>;
147
174
  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>;
175
+ liquidateBorrow(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetmarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
176
+ getLiquidateBorrowIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetmarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
177
+ liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
178
+ getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
179
+ liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetMarketIndex: BN, maxPnlTransfer: BN): Promise<TransactionSignature>;
180
+ getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetMarketIndex: BN, maxPnlTransfer: BN): Promise<TransactionInstruction>;
181
+ resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
182
+ getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
183
+ resolveBorrowBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
184
+ getResolveBorrowBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
158
185
  getRemainingAccountsWithCounterparty(params: {
159
186
  counterPartyUserAccount: UserAccount;
160
- writableMarketIndex?: BN;
161
- writableBankIndexes?: BN[];
187
+ writablePerpMarketIndex?: BN;
188
+ writableSpotMarketIndexes?: BN[];
162
189
  }): AccountMeta[];
163
190
  updateFundingRate(oracle: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
164
191
  getUpdateFundingRateIx(oracle: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
@@ -166,11 +193,13 @@ export declare class ClearingHouse {
166
193
  getSettleFundingPaymentIx(userAccount: PublicKey): Promise<TransactionInstruction>;
167
194
  triggerEvent(eventName: keyof ClearingHouseAccountEvents, data?: any): void;
168
195
  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>;
196
+ initializeInsuranceFundStake(marketIndex: BN): Promise<TransactionSignature>;
197
+ getInitializeInsuranceFundStakeIx(marketIndex: BN): Promise<TransactionInstruction>;
198
+ addInsuranceFundStake(marketIndex: BN, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
199
+ requestRemoveInsuranceFundStake(marketIndex: BN, amount: BN): Promise<TransactionSignature>;
200
+ cancelRequestRemoveInsuranceFundStake(marketIndex: BN): Promise<TransactionSignature>;
201
+ removeInsuranceFundStake(marketIndex: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
202
+ settleRevenueToInsuranceFund(marketIndex: BN): Promise<TransactionSignature>;
203
+ resolvePerpPnlDeficit(spotMarketIndex: BN, perpMarketIndex: BN): Promise<TransactionSignature>;
204
+ getResolvePerpPnlDeficitIx(spotMarketIndex: BN, perpMarketIndex: BN): Promise<TransactionInstruction>;
176
205
  }