@drift-labs/sdk 0.2.0-master.32 → 0.2.0-master.34

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 (108) hide show
  1. package/lib/accounts/bulkAccountLoader.js +2 -1
  2. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +2 -2
  3. package/lib/accounts/pollingClearingHouseAccountSubscriber.js +8 -8
  4. package/lib/accounts/types.d.ts +1 -0
  5. package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +2 -2
  6. package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +7 -7
  7. package/lib/addresses/marketAddresses.js +1 -1
  8. package/lib/addresses/pda.d.ts +4 -4
  9. package/lib/addresses/pda.js +23 -22
  10. package/lib/admin.d.ts +30 -32
  11. package/lib/admin.js +111 -119
  12. package/lib/clearingHouse.d.ts +43 -34
  13. package/lib/clearingHouse.js +353 -193
  14. package/lib/clearingHouseConfig.d.ts +2 -2
  15. package/lib/clearingHouseUser.d.ts +26 -5
  16. package/lib/clearingHouseUser.js +151 -51
  17. package/lib/config.d.ts +2 -0
  18. package/lib/config.js +5 -1
  19. package/lib/constants/numericConstants.d.ts +1 -0
  20. package/lib/constants/numericConstants.js +3 -2
  21. package/lib/dlob/DLOB.d.ts +18 -11
  22. package/lib/dlob/DLOB.js +179 -107
  23. package/lib/dlob/DLOBNode.js +2 -10
  24. package/lib/dlob/NodeList.js +1 -1
  25. package/lib/events/eventSubscriber.d.ts +1 -0
  26. package/lib/events/eventSubscriber.js +11 -4
  27. package/lib/events/fetchLogs.d.ts +3 -1
  28. package/lib/events/fetchLogs.js +13 -5
  29. package/lib/events/pollingLogProvider.js +1 -1
  30. package/lib/events/types.d.ts +1 -1
  31. package/lib/events/webSocketLogProvider.js +1 -1
  32. package/lib/factory/bigNum.d.ts +5 -4
  33. package/lib/factory/bigNum.js +36 -6
  34. package/lib/idl/clearing_house.json +1540 -1246
  35. package/lib/index.d.ts +3 -0
  36. package/lib/index.js +3 -0
  37. package/lib/math/amm.js +9 -9
  38. package/lib/math/exchangeStatus.d.ts +4 -0
  39. package/lib/math/exchangeStatus.js +18 -0
  40. package/lib/math/funding.js +10 -10
  41. package/lib/math/margin.js +6 -1
  42. package/lib/math/market.js +9 -9
  43. package/lib/math/orders.d.ts +7 -3
  44. package/lib/math/orders.js +39 -31
  45. package/lib/math/repeg.js +3 -3
  46. package/lib/math/spotBalance.js +3 -3
  47. package/lib/math/spotPosition.js +2 -2
  48. package/lib/serum/serumFulfillmentConfigMap.d.ts +10 -0
  49. package/lib/serum/serumFulfillmentConfigMap.js +17 -0
  50. package/lib/serum/serumSubscriber.d.ts +4 -0
  51. package/lib/serum/serumSubscriber.js +16 -1
  52. package/lib/types.d.ts +60 -75
  53. package/lib/types.js +2 -1
  54. package/lib/userMap/userMap.d.ts +17 -1
  55. package/lib/userMap/userMap.js +12 -0
  56. package/lib/userName.d.ts +1 -0
  57. package/lib/userName.js +3 -2
  58. package/package.json +1 -1
  59. package/src/accounts/bulkAccountLoader.ts +5 -1
  60. package/src/accounts/pollingClearingHouseAccountSubscriber.ts +9 -9
  61. package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +8 -8
  62. package/src/addresses/marketAddresses.ts +2 -2
  63. package/src/addresses/pda.ts +20 -20
  64. package/src/admin.ts +246 -221
  65. package/src/assert/assert.js +9 -0
  66. package/src/clearingHouse.ts +556 -236
  67. package/src/clearingHouseConfig.ts +2 -2
  68. package/src/clearingHouseUser.ts +237 -87
  69. package/src/config.ts +8 -1
  70. package/src/constants/numericConstants.ts +5 -1
  71. package/src/dlob/DLOB.ts +257 -120
  72. package/src/dlob/DLOBNode.ts +2 -14
  73. package/src/dlob/NodeList.ts +1 -1
  74. package/src/events/eventList.js +77 -0
  75. package/src/events/eventSubscriber.ts +18 -4
  76. package/src/events/fetchLogs.ts +20 -5
  77. package/src/events/pollingLogProvider.ts +1 -1
  78. package/src/events/types.ts +2 -1
  79. package/src/events/webSocketLogProvider.ts +1 -1
  80. package/src/examples/makeTradeExample.js +157 -0
  81. package/src/factory/bigNum.ts +59 -6
  82. package/src/idl/clearing_house.json +1540 -1246
  83. package/src/idl/pyth.json +98 -2
  84. package/src/index.ts +3 -0
  85. package/src/math/amm.ts +9 -9
  86. package/src/math/exchangeStatus.ts +31 -0
  87. package/src/math/funding.ts +20 -10
  88. package/src/math/margin.ts +7 -1
  89. package/src/math/market.ts +9 -9
  90. package/src/math/orders.ts +44 -29
  91. package/src/math/repeg.ts +3 -3
  92. package/src/math/spotBalance.ts +4 -4
  93. package/src/math/spotPosition.ts +2 -2
  94. package/src/serum/serumFulfillmentConfigMap.ts +26 -0
  95. package/src/serum/serumSubscriber.ts +20 -1
  96. package/src/token/index.js +38 -0
  97. package/src/tx/types.js +2 -0
  98. package/src/tx/utils.js +17 -0
  99. package/src/types.ts +65 -51
  100. package/src/userMap/userMap.ts +25 -1
  101. package/src/userName.ts +2 -1
  102. package/src/util/computeUnits.js +27 -0
  103. package/src/util/getTokenAddress.js +9 -0
  104. package/src/util/promiseTimeout.js +14 -0
  105. package/src/util/tps.js +27 -0
  106. package/tests/bn/test.ts +22 -1
  107. package/tests/dlob/helpers.ts +252 -81
  108. package/tests/dlob/test.ts +1040 -219
package/lib/admin.js CHANGED
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Admin = void 0;
27
27
  const web3_js_1 = require("@solana/web3.js");
28
28
  const types_1 = require("./types");
29
+ const userName_1 = require("./userName");
29
30
  const anchor_1 = require("@project-serum/anchor");
30
31
  const anchor = __importStar(require("@project-serum/anchor"));
31
32
  const pda_1 = require("./addresses/pda");
@@ -103,14 +104,15 @@ class Admin extends clearingHouse_1.ClearingHouse {
103
104
  },
104
105
  });
105
106
  }
106
- async initializeMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidationFee = numericConstants_1.ZERO, activeStatus = true) {
107
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, this.getStateAccount().numberOfMarkets);
108
- const initializeMarketTx = await this.program.transaction.initializeMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidationFee, activeStatus, {
107
+ async initializePerpMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidationFee = numericConstants_1.ZERO, activeStatus = true, name = userName_1.DEFAULT_MARKET_NAME) {
108
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, this.getStateAccount().numberOfMarkets);
109
+ const nameBuffer = (0, userName_1.encodeName)(name);
110
+ const initializeMarketTx = await this.program.transaction.initializePerpMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidationFee, activeStatus, nameBuffer, {
109
111
  accounts: {
110
112
  state: await this.getStatePublicKey(),
111
113
  admin: this.wallet.publicKey,
112
114
  oracle: priceOracle,
113
- market: marketPublicKey,
115
+ perpMarket: perpMarketPublicKey,
114
116
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
115
117
  systemProgram: anchor.web3.SystemProgram.programId,
116
118
  },
@@ -123,8 +125,8 @@ class Admin extends clearingHouse_1.ClearingHouse {
123
125
  });
124
126
  return txSig;
125
127
  }
126
- async moveAmmPrice(marketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
127
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
128
+ async moveAmmPrice(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
129
+ const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
128
130
  if (sqrtK == undefined) {
129
131
  sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
130
132
  }
@@ -136,82 +138,82 @@ class Admin extends clearingHouse_1.ClearingHouse {
136
138
  },
137
139
  });
138
140
  }
139
- async updateK(sqrtK, marketIndex) {
141
+ async updateK(perpMarketIndex, sqrtK) {
140
142
  return await this.program.rpc.updateK(sqrtK, {
141
143
  accounts: {
142
144
  state: await this.getStatePublicKey(),
143
145
  admin: this.wallet.publicKey,
144
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
145
- oracle: this.getPerpMarketAccount(marketIndex).amm.oracle,
146
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
147
+ oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
146
148
  },
147
149
  });
148
150
  }
149
- async updateConcentrationScale(marketIndex, concentrationScale) {
150
- return await this.program.rpc.updateConcentrationCoef(concentrationScale, {
151
+ async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
152
+ return await this.program.rpc.updatePerpMarketConcentrationCoef(concentrationScale, {
151
153
  accounts: {
152
154
  state: await this.getStatePublicKey(),
153
155
  admin: this.wallet.publicKey,
154
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
156
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
155
157
  },
156
158
  });
157
159
  }
158
160
  async moveAmmToPrice(perpMarketIndex, targetPrice) {
159
- const market = this.getPerpMarketAccount(perpMarketIndex);
160
- const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(market, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
161
+ const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
162
+ const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
161
163
  );
162
- const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(market.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
163
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex);
164
- return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, market.amm.sqrtK, {
164
+ const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
165
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
166
+ return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, perpMarket.amm.sqrtK, {
165
167
  accounts: {
166
168
  state: await this.getStatePublicKey(),
167
169
  admin: this.wallet.publicKey,
168
- perpMarket: marketPublicKey,
170
+ perpMarket: perpMarketPublicKey,
169
171
  },
170
172
  });
171
173
  }
172
- async repegAmmCurve(newPeg, marketIndex) {
173
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
174
- const ammData = this.getPerpMarketAccount(marketIndex).amm;
174
+ async repegAmmCurve(newPeg, perpMarketIndex) {
175
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
176
+ const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
175
177
  return await this.program.rpc.repegAmmCurve(newPeg, {
176
178
  accounts: {
177
179
  state: await this.getStatePublicKey(),
178
180
  admin: this.wallet.publicKey,
179
181
  oracle: ammData.oracle,
180
- market: marketPublicKey,
182
+ perpMarket: perpMarketPublicKey,
181
183
  },
182
184
  });
183
185
  }
184
- async updateAmmOracleTwap(marketIndex) {
185
- const ammData = this.getPerpMarketAccount(marketIndex).amm;
186
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
187
- return await this.program.rpc.updateAmmOracleTwap({
186
+ async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
187
+ const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
188
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
189
+ return await this.program.rpc.updatePerpMarketAmmOracleTwap({
188
190
  accounts: {
189
191
  state: await this.getStatePublicKey(),
190
192
  admin: this.wallet.publicKey,
191
193
  oracle: ammData.oracle,
192
- market: marketPublicKey,
194
+ perpMarket: perpMarketPublicKey,
193
195
  },
194
196
  });
195
197
  }
196
- async resetAmmOracleTwap(marketIndex) {
197
- const ammData = this.getPerpMarketAccount(marketIndex).amm;
198
- const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
199
- return await this.program.rpc.resetAmmOracleTwap({
198
+ async resetPerpMarketAmmOracleTwap(perpMarketIndex) {
199
+ const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
200
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
201
+ return await this.program.rpc.resetPerpMarketAmmOracleTwap({
200
202
  accounts: {
201
203
  state: await this.getStatePublicKey(),
202
204
  admin: this.wallet.publicKey,
203
205
  oracle: ammData.oracle,
204
- market: marketPublicKey,
206
+ perpMarket: perpMarketPublicKey,
205
207
  },
206
208
  });
207
209
  }
208
- async depositIntoMarketFeePool(marketIndex, amount, sourceVault) {
210
+ async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
209
211
  const spotMarket = this.getQuoteSpotMarketAccount();
210
- return await this.program.rpc.depositIntoMarketFeePool(amount, {
212
+ return await this.program.rpc.depositIntoPerpMarketFeePool(amount, {
211
213
  accounts: {
212
214
  admin: this.wallet.publicKey,
213
215
  state: await this.getStatePublicKey(),
214
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
216
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
215
217
  sourceVault,
216
218
  clearingHouseSigner: this.getSignerPublicKey(),
217
219
  quoteSpotMarket: spotMarket.pubkey,
@@ -228,204 +230,202 @@ class Admin extends clearingHouse_1.ClearingHouse {
228
230
  },
229
231
  });
230
232
  }
231
- async updateCurveUpdateIntensity(marketIndex, curveUpdateIntensity) {
233
+ async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
232
234
  // assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
233
235
  // assert(Number.isInteger(curveUpdateIntensity));
234
- return await this.program.rpc.updateCurveUpdateIntensity(curveUpdateIntensity, {
236
+ return await this.program.rpc.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
235
237
  accounts: {
236
238
  admin: this.wallet.publicKey,
237
239
  state: await this.getStatePublicKey(),
238
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
240
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
239
241
  },
240
242
  });
241
243
  }
242
- async updateMarginRatio(marketIndex, marginRatioInitial, marginRatioMaintenance) {
243
- return await this.program.rpc.updateMarginRatio(marginRatioInitial, marginRatioMaintenance, {
244
+ async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
245
+ return await this.program.rpc.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
244
246
  accounts: {
245
247
  admin: this.wallet.publicKey,
246
248
  state: await this.getStatePublicKey(),
247
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
249
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
248
250
  },
249
251
  });
250
252
  }
251
- async updateMarketBaseSpread(marketIndex, baseSpread) {
252
- return await this.program.rpc.updateMarketBaseSpread(baseSpread, {
253
+ async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
254
+ return await this.program.rpc.updatePerpMarketBaseSpread(baseSpread, {
253
255
  accounts: {
254
256
  admin: this.wallet.publicKey,
255
257
  state: await this.getStatePublicKey(),
256
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
258
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
257
259
  },
258
260
  });
259
261
  }
260
- async updateAmmJitIntensity(marketIndex, ammJitIntensity) {
262
+ async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
261
263
  return await this.program.rpc.updateAmmJitIntensity(ammJitIntensity, {
262
264
  accounts: {
263
265
  admin: this.wallet.publicKey,
264
266
  state: await this.getStatePublicKey(),
265
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
266
- },
267
- });
268
- }
269
- async updateMarketMaxSpread(marketIndex, maxSpread) {
270
- return await this.program.rpc.updateMarketMaxSpread(maxSpread, {
271
- accounts: {
272
- admin: this.wallet.publicKey,
273
- state: await this.getStatePublicKey(),
274
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
267
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
275
268
  },
276
269
  });
277
270
  }
278
- async updatePartialLiquidationClosePercentage(numerator, denominator) {
279
- return await this.program.rpc.updatePartialLiquidationClosePercentage(numerator, denominator, {
271
+ async updatePerpMarketName(perpMarketIndex, name) {
272
+ const nameBuffer = (0, userName_1.encodeName)(name);
273
+ return await this.program.rpc.updatePerpMarketName(nameBuffer, {
280
274
  accounts: {
281
275
  admin: this.wallet.publicKey,
282
276
  state: await this.getStatePublicKey(),
277
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
283
278
  },
284
279
  });
285
280
  }
286
- async updatePartialLiquidationPenaltyPercentage(numerator, denominator) {
287
- return await this.program.rpc.updatePartialLiquidationPenaltyPercentage(numerator, denominator, {
281
+ async updatePerpMarketMaxSpread(perpMarketIndex, maxSpread) {
282
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
283
+ return await this.program.rpc.updatePerpMarketMaxSpread(maxSpread, {
288
284
  accounts: {
289
285
  admin: this.wallet.publicKey,
290
286
  state: await this.getStatePublicKey(),
287
+ perpMarket: perpMarketPublicKey,
291
288
  },
292
289
  });
293
290
  }
294
- async updateFullLiquidationPenaltyPercentage(numerator, denominator) {
295
- return await this.program.rpc.updateFullLiquidationPenaltyPercentage(numerator, denominator, {
291
+ async updatePerpFeeStructure(feeStructure) {
292
+ return await this.program.rpc.updatePerpFeeStructure(feeStructure, {
296
293
  accounts: {
297
294
  admin: this.wallet.publicKey,
298
295
  state: await this.getStatePublicKey(),
299
296
  },
300
297
  });
301
298
  }
302
- async updatePartialLiquidationShareDenominator(denominator) {
303
- return await this.program.rpc.updatePartialLiquidationLiquidatorShareDenominator(denominator, {
299
+ async updateSpotFeeStructure(feeStructure) {
300
+ return await this.program.rpc.updateSpotFeeStructure(feeStructure, {
304
301
  accounts: {
305
302
  admin: this.wallet.publicKey,
306
303
  state: await this.getStatePublicKey(),
307
304
  },
308
305
  });
309
306
  }
310
- async updateFullLiquidationShareDenominator(denominator) {
311
- return await this.program.rpc.updateFullLiquidationLiquidatorShareDenominator(denominator, {
307
+ async updateOracleGuardRails(oracleGuardRails) {
308
+ return await this.program.rpc.updateOracleGuardRails(oracleGuardRails, {
312
309
  accounts: {
313
310
  admin: this.wallet.publicKey,
314
311
  state: await this.getStatePublicKey(),
315
312
  },
316
313
  });
317
314
  }
318
- async updatePerpFeeStructure(feeStructure) {
319
- return await this.program.rpc.updatePerpFeeStructure(feeStructure, {
315
+ async updateStateSettlementDuration(settlementDuration) {
316
+ return await this.program.rpc.updateStateSettlementDuration(settlementDuration, {
320
317
  accounts: {
321
318
  admin: this.wallet.publicKey,
322
319
  state: await this.getStatePublicKey(),
323
320
  },
324
321
  });
325
322
  }
326
- async updateSpotFeeStructure(feeStructure) {
327
- return await this.program.rpc.updateSpotFeeStructure(feeStructure, {
323
+ async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
324
+ return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
328
325
  accounts: {
329
326
  admin: this.wallet.publicKey,
330
327
  state: await this.getStatePublicKey(),
328
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
331
329
  },
332
330
  });
333
331
  }
334
- async updateOracleGuardRails(oracleGuardRails) {
335
- return await this.program.rpc.updateOracleGuardRails(oracleGuardRails, {
332
+ async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
333
+ return await this.program.rpc.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
336
334
  accounts: {
337
335
  admin: this.wallet.publicKey,
338
336
  state: await this.getStatePublicKey(),
337
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
339
338
  },
340
339
  });
341
340
  }
342
- async updateWithdrawGuardThreshold(marketIndex, withdrawGuardThreshold) {
343
- return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
341
+ async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
342
+ return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
344
343
  accounts: {
345
344
  admin: this.wallet.publicKey,
346
345
  state: await this.getStatePublicKey(),
347
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
346
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
348
347
  },
349
348
  });
350
349
  }
351
- async updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor) {
352
- return await this.program.rpc.updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor, {
350
+ async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
351
+ return await this.program.rpc.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
353
352
  accounts: {
354
353
  admin: this.wallet.publicKey,
355
354
  state: await this.getStatePublicKey(),
356
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
355
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
357
356
  },
358
357
  });
359
358
  }
360
- async updateSpotMarketRevenueSettlePeriod(marketIndex, revenueSettlePeriod) {
361
- return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
359
+ async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
360
+ return await this.program.rpc.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
362
361
  accounts: {
363
362
  admin: this.wallet.publicKey,
364
363
  state: await this.getStatePublicKey(),
365
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
364
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
366
365
  },
367
366
  });
368
367
  }
369
- async updateSpotMarketMaxTokenDeposits(marketIndex, maxTokenDeposits) {
370
- return await this.program.rpc.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
368
+ async updateLpCooldownTime(cooldownTime) {
369
+ return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
371
370
  accounts: {
372
371
  admin: this.wallet.publicKey,
373
372
  state: await this.getStatePublicKey(),
374
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
375
373
  },
376
374
  });
377
375
  }
378
- async updateInsuranceWithdrawEscrowPeriod(marketIndex, insuranceWithdrawEscrowPeriod) {
379
- return await this.program.rpc.updateInsuranceWithdrawEscrowPeriod(insuranceWithdrawEscrowPeriod, {
376
+ async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource) {
377
+ return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
380
378
  accounts: {
381
379
  admin: this.wallet.publicKey,
382
380
  state: await this.getStatePublicKey(),
383
- spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
381
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
382
+ oracle: oracle,
384
383
  },
385
384
  });
386
385
  }
387
- async updateLpCooldownTime(marketIndex, cooldownTime) {
388
- return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
386
+ async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
387
+ return await this.program.rpc.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
389
388
  accounts: {
390
389
  admin: this.wallet.publicKey,
391
390
  state: await this.getStatePublicKey(),
392
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
391
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
393
392
  },
394
393
  });
395
394
  }
396
- async updateMarketOracle(marketIndex, oracle, oracleSource) {
397
- return await this.program.rpc.updateMarketOracle(oracle, oracleSource, {
395
+ async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
396
+ return await this.program.rpc.updatePerpMarketMinOrderSize(orderSize, {
398
397
  accounts: {
399
398
  admin: this.wallet.publicKey,
400
399
  state: await this.getStatePublicKey(),
401
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
400
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
402
401
  },
403
402
  });
404
403
  }
405
- async updateMarketMinimumQuoteAssetTradeSize(marketIndex, minimumTradeSize) {
406
- return await this.program.rpc.updateMarketMinimumQuoteAssetTradeSize(minimumTradeSize, {
404
+ async updatePerpMarketExpiry(perpMarketIndex, expiryTs) {
405
+ return await this.program.rpc.updatePerpMarketExpiry(expiryTs, {
407
406
  accounts: {
408
407
  admin: this.wallet.publicKey,
409
408
  state: await this.getStatePublicKey(),
410
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
409
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
411
410
  },
412
411
  });
413
412
  }
414
- async updateMarketBaseAssetAmountStepSize(marketIndex, stepSize) {
415
- return await this.program.rpc.updateMarketBaseAssetAmountStepSize(stepSize, {
413
+ async updateSpotMarketOracle(spotMarketIndex, oracle, oracleSource) {
414
+ return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
416
415
  accounts: {
417
416
  admin: this.wallet.publicKey,
418
417
  state: await this.getStatePublicKey(),
419
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
418
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
419
+ oracle: oracle,
420
420
  },
421
421
  });
422
422
  }
423
- async updateMarketExpiry(perpMarketIndex, expiryTs) {
424
- return await this.program.rpc.updateMarketExpiry(expiryTs, {
423
+ async updateSpotMarketExpiry(spotMarketIndex, expiryTs) {
424
+ return await this.program.rpc.updateSpotMarketExpiry(expiryTs, {
425
425
  accounts: {
426
426
  admin: this.wallet.publicKey,
427
427
  state: await this.getStatePublicKey(),
428
- perpMarket: await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex),
428
+ spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
429
429
  },
430
430
  });
431
431
  }
@@ -445,14 +445,6 @@ class Admin extends clearingHouse_1.ClearingHouse {
445
445
  },
446
446
  });
447
447
  }
448
- async updateMaxDeposit(maxDeposit) {
449
- return await this.program.rpc.updateMaxDeposit(maxDeposit, {
450
- accounts: {
451
- admin: this.wallet.publicKey,
452
- state: await this.getStatePublicKey(),
453
- },
454
- });
455
- }
456
448
  async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = new anchor_1.BN(0)) {
457
449
  return await this.program.rpc.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
458
450
  accounts: {
@@ -485,7 +477,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
485
477
  accounts: {
486
478
  admin: this.wallet.publicKey,
487
479
  state: await this.getStatePublicKey(),
488
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex),
480
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
489
481
  },
490
482
  });
491
483
  }
@@ -494,7 +486,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
494
486
  accounts: {
495
487
  admin: this.wallet.publicKey,
496
488
  state: await this.getStatePublicKey(),
497
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex),
489
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
498
490
  },
499
491
  });
500
492
  }
@@ -522,30 +514,30 @@ class Admin extends clearingHouse_1.ClearingHouse {
522
514
  },
523
515
  });
524
516
  }
525
- async updateMaxBaseAssetAmountRatio(marketIndex, maxBaseAssetAmountRatio) {
526
- return await this.program.rpc.updateMaxBaseAssetAmountRatio(maxBaseAssetAmountRatio, {
517
+ async updatePerpMarketMaxFillReserveFraction(perpMarketIndex, maxBaseAssetAmountRatio) {
518
+ return await this.program.rpc.updatePerpMarketMaxFillReserveFraction(maxBaseAssetAmountRatio, {
527
519
  accounts: {
528
520
  admin: this.wallet.publicKey,
529
521
  state: await this.getStatePublicKey(),
530
- market: this.getPerpMarketAccount(marketIndex).pubkey,
522
+ perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
531
523
  },
532
524
  });
533
525
  }
534
- async updateMaxSlippageRatio(marketIndex, maxSlippageRatio) {
526
+ async updateMaxSlippageRatio(perpMarketIndex, maxSlippageRatio) {
535
527
  return await this.program.rpc.updateMaxSlippageRatio(maxSlippageRatio, {
536
528
  accounts: {
537
529
  admin: this.wallet.publicKey,
538
530
  state: await this.getStatePublicKey(),
539
- market: this.getPerpMarketAccount(marketIndex).pubkey,
531
+ perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
540
532
  },
541
533
  });
542
534
  }
543
- async updateMarketMaxImbalances(marketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
544
- return await this.program.rpc.updateMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
535
+ async updatePerpMarketMaxImbalances(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
536
+ return await this.program.rpc.updatePerpMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
545
537
  accounts: {
546
538
  admin: this.wallet.publicKey,
547
539
  state: await this.getStatePublicKey(),
548
- market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
540
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
549
541
  },
550
542
  });
551
543
  }