@drift-labs/sdk 0.2.0-master.31 → 0.2.0-master.33
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.
- package/lib/accounts/bulkAccountLoader.js +2 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +2 -2
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +8 -8
- package/lib/accounts/types.d.ts +1 -0
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +2 -2
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +7 -7
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.d.ts +4 -4
- package/lib/addresses/pda.js +23 -22
- package/lib/admin.d.ts +30 -32
- package/lib/admin.js +111 -119
- package/lib/clearingHouse.d.ts +43 -34
- package/lib/clearingHouse.js +353 -193
- package/lib/clearingHouseConfig.d.ts +2 -2
- package/lib/clearingHouseUser.d.ts +26 -5
- package/lib/clearingHouseUser.js +151 -51
- package/lib/config.d.ts +2 -0
- package/lib/config.js +5 -1
- package/lib/constants/numericConstants.d.ts +1 -0
- package/lib/constants/numericConstants.js +3 -2
- package/lib/dlob/DLOB.d.ts +19 -11
- package/lib/dlob/DLOB.js +208 -107
- package/lib/dlob/DLOBNode.js +2 -10
- package/lib/dlob/NodeList.d.ts +1 -0
- package/lib/dlob/NodeList.js +6 -1
- package/lib/events/eventSubscriber.d.ts +1 -0
- package/lib/events/eventSubscriber.js +11 -4
- package/lib/events/fetchLogs.d.ts +3 -1
- package/lib/events/fetchLogs.js +13 -5
- package/lib/events/pollingLogProvider.js +1 -1
- package/lib/events/types.d.ts +1 -1
- package/lib/events/webSocketLogProvider.js +1 -1
- package/lib/factory/bigNum.d.ts +5 -4
- package/lib/factory/bigNum.js +36 -6
- package/lib/idl/clearing_house.json +1527 -1242
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/math/amm.js +9 -9
- package/lib/math/exchangeStatus.d.ts +4 -0
- package/lib/math/exchangeStatus.js +18 -0
- package/lib/math/funding.js +10 -10
- package/lib/math/margin.js +6 -1
- package/lib/math/market.js +9 -9
- package/lib/math/orders.d.ts +7 -3
- package/lib/math/orders.js +39 -31
- package/lib/math/repeg.js +3 -3
- package/lib/math/spotBalance.js +3 -3
- package/lib/math/spotPosition.js +2 -2
- package/lib/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/serum/serumSubscriber.d.ts +4 -0
- package/lib/serum/serumSubscriber.js +16 -1
- package/lib/types.d.ts +70 -85
- package/lib/types.js +12 -11
- package/lib/userMap/userMap.d.ts +17 -1
- package/lib/userMap/userMap.js +12 -0
- package/lib/userName.d.ts +1 -0
- package/lib/userName.js +3 -2
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.ts +5 -1
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +9 -9
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +8 -8
- package/src/addresses/marketAddresses.ts +2 -2
- package/src/addresses/pda.ts +20 -20
- package/src/admin.ts +246 -221
- package/src/clearingHouse.ts +556 -236
- package/src/clearingHouseConfig.ts +2 -2
- package/src/clearingHouseUser.ts +237 -87
- package/src/config.ts +8 -1
- package/src/constants/numericConstants.ts +5 -1
- package/src/dlob/DLOB.ts +290 -120
- package/src/dlob/DLOBNode.ts +2 -14
- package/src/dlob/NodeList.ts +7 -1
- package/src/events/eventSubscriber.ts +18 -4
- package/src/events/fetchLogs.ts +20 -5
- package/src/events/pollingLogProvider.ts +1 -1
- package/src/events/types.ts +2 -1
- package/src/events/webSocketLogProvider.ts +1 -1
- package/src/factory/bigNum.ts +59 -6
- package/src/idl/clearing_house.json +1527 -1242
- package/src/idl/pyth.json +98 -2
- package/src/index.ts +3 -0
- package/src/math/amm.ts +9 -9
- package/src/math/exchangeStatus.ts +31 -0
- package/src/math/funding.ts +20 -10
- package/src/math/margin.ts +7 -1
- package/src/math/market.ts +9 -9
- package/src/math/orders.ts +44 -29
- package/src/math/repeg.ts +3 -3
- package/src/math/spotBalance.ts +4 -4
- package/src/math/spotPosition.ts +2 -2
- package/src/serum/serumFulfillmentConfigMap.ts +26 -0
- package/src/serum/serumSubscriber.ts +20 -1
- package/src/types.ts +75 -61
- package/src/userMap/userMap.ts +25 -1
- package/src/userName.ts +2 -1
- package/tests/bn/test.ts +22 -1
- package/tests/dlob/helpers.ts +252 -81
- package/tests/dlob/test.ts +1115 -215
package/src/admin.ts
CHANGED
|
@@ -12,13 +12,14 @@ import {
|
|
|
12
12
|
ContractTier,
|
|
13
13
|
AssetTier,
|
|
14
14
|
} from './types';
|
|
15
|
+
import { DEFAULT_MARKET_NAME, encodeName } from './userName';
|
|
15
16
|
import { BN } from '@project-serum/anchor';
|
|
16
17
|
import * as anchor from '@project-serum/anchor';
|
|
17
18
|
import {
|
|
18
19
|
getClearingHouseStateAccountPublicKeyAndNonce,
|
|
19
20
|
getSpotMarketPublicKey,
|
|
20
21
|
getSpotMarketVaultPublicKey,
|
|
21
|
-
|
|
22
|
+
getPerpMarketPublicKey,
|
|
22
23
|
getInsuranceFundVaultPublicKey,
|
|
23
24
|
getSerumOpenOrdersPublicKey,
|
|
24
25
|
getSerumFulfillmentConfigPublicKey,
|
|
@@ -174,7 +175,7 @@ export class Admin extends ClearingHouse {
|
|
|
174
175
|
);
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
public async
|
|
178
|
+
public async initializePerpMarket(
|
|
178
179
|
priceOracle: PublicKey,
|
|
179
180
|
baseAssetReserve: BN,
|
|
180
181
|
quoteAssetReserve: BN,
|
|
@@ -184,34 +185,38 @@ export class Admin extends ClearingHouse {
|
|
|
184
185
|
marginRatioInitial = 2000,
|
|
185
186
|
marginRatioMaintenance = 500,
|
|
186
187
|
liquidationFee = ZERO,
|
|
187
|
-
activeStatus = true
|
|
188
|
+
activeStatus = true,
|
|
189
|
+
name = DEFAULT_MARKET_NAME
|
|
188
190
|
): Promise<TransactionSignature> {
|
|
189
|
-
const
|
|
191
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
190
192
|
this.program.programId,
|
|
191
193
|
this.getStateAccount().numberOfMarkets
|
|
192
194
|
);
|
|
193
195
|
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
196
|
+
const nameBuffer = encodeName(name);
|
|
197
|
+
const initializeMarketTx =
|
|
198
|
+
await this.program.transaction.initializePerpMarket(
|
|
199
|
+
baseAssetReserve,
|
|
200
|
+
quoteAssetReserve,
|
|
201
|
+
periodicity,
|
|
202
|
+
pegMultiplier,
|
|
203
|
+
oracleSource,
|
|
204
|
+
marginRatioInitial,
|
|
205
|
+
marginRatioMaintenance,
|
|
206
|
+
liquidationFee,
|
|
207
|
+
activeStatus,
|
|
208
|
+
nameBuffer,
|
|
209
|
+
{
|
|
210
|
+
accounts: {
|
|
211
|
+
state: await this.getStatePublicKey(),
|
|
212
|
+
admin: this.wallet.publicKey,
|
|
213
|
+
oracle: priceOracle,
|
|
214
|
+
perpMarket: perpMarketPublicKey,
|
|
215
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
216
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
217
|
+
},
|
|
218
|
+
}
|
|
219
|
+
);
|
|
215
220
|
const { txSig } = await this.txSender.send(
|
|
216
221
|
initializeMarketTx,
|
|
217
222
|
[],
|
|
@@ -230,14 +235,14 @@ export class Admin extends ClearingHouse {
|
|
|
230
235
|
}
|
|
231
236
|
|
|
232
237
|
public async moveAmmPrice(
|
|
233
|
-
|
|
238
|
+
perpMarketIndex: number,
|
|
234
239
|
baseAssetReserve: BN,
|
|
235
240
|
quoteAssetReserve: BN,
|
|
236
241
|
sqrtK?: BN
|
|
237
242
|
): Promise<TransactionSignature> {
|
|
238
|
-
const marketPublicKey = await
|
|
243
|
+
const marketPublicKey = await getPerpMarketPublicKey(
|
|
239
244
|
this.program.programId,
|
|
240
|
-
|
|
245
|
+
perpMarketIndex
|
|
241
246
|
);
|
|
242
247
|
|
|
243
248
|
if (sqrtK == undefined) {
|
|
@@ -259,40 +264,49 @@ export class Admin extends ClearingHouse {
|
|
|
259
264
|
}
|
|
260
265
|
|
|
261
266
|
public async updateK(
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
perpMarketIndex: number,
|
|
268
|
+
sqrtK: BN
|
|
264
269
|
): Promise<TransactionSignature> {
|
|
265
270
|
return await this.program.rpc.updateK(sqrtK, {
|
|
266
271
|
accounts: {
|
|
267
272
|
state: await this.getStatePublicKey(),
|
|
268
273
|
admin: this.wallet.publicKey,
|
|
269
|
-
|
|
270
|
-
|
|
274
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
275
|
+
this.program.programId,
|
|
276
|
+
perpMarketIndex
|
|
277
|
+
),
|
|
278
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
271
279
|
},
|
|
272
280
|
});
|
|
273
281
|
}
|
|
274
282
|
|
|
275
|
-
public async
|
|
276
|
-
|
|
283
|
+
public async updatePerpMarketConcentrationScale(
|
|
284
|
+
perpMarketIndex: number,
|
|
277
285
|
concentrationScale: BN
|
|
278
286
|
): Promise<TransactionSignature> {
|
|
279
|
-
return await this.program.rpc.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
287
|
+
return await this.program.rpc.updatePerpMarketConcentrationCoef(
|
|
288
|
+
concentrationScale,
|
|
289
|
+
{
|
|
290
|
+
accounts: {
|
|
291
|
+
state: await this.getStatePublicKey(),
|
|
292
|
+
admin: this.wallet.publicKey,
|
|
293
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
294
|
+
this.program.programId,
|
|
295
|
+
perpMarketIndex
|
|
296
|
+
),
|
|
297
|
+
},
|
|
298
|
+
}
|
|
299
|
+
);
|
|
286
300
|
}
|
|
287
301
|
|
|
288
302
|
public async moveAmmToPrice(
|
|
289
303
|
perpMarketIndex: number,
|
|
290
304
|
targetPrice: BN
|
|
291
305
|
): Promise<TransactionSignature> {
|
|
292
|
-
const
|
|
306
|
+
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
293
307
|
|
|
294
308
|
const [direction, tradeSize, _] = calculateTargetPriceTrade(
|
|
295
|
-
|
|
309
|
+
perpMarket,
|
|
296
310
|
targetPrice,
|
|
297
311
|
new BN(1000),
|
|
298
312
|
'quote',
|
|
@@ -301,13 +315,13 @@ export class Admin extends ClearingHouse {
|
|
|
301
315
|
|
|
302
316
|
const [newQuoteAssetAmount, newBaseAssetAmount] =
|
|
303
317
|
calculateAmmReservesAfterSwap(
|
|
304
|
-
|
|
318
|
+
perpMarket.amm,
|
|
305
319
|
'quote',
|
|
306
320
|
tradeSize,
|
|
307
321
|
getSwapDirection('quote', direction)
|
|
308
322
|
);
|
|
309
323
|
|
|
310
|
-
const
|
|
324
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
311
325
|
this.program.programId,
|
|
312
326
|
perpMarketIndex
|
|
313
327
|
);
|
|
@@ -315,12 +329,12 @@ export class Admin extends ClearingHouse {
|
|
|
315
329
|
return await this.program.rpc.moveAmmPrice(
|
|
316
330
|
newBaseAssetAmount,
|
|
317
331
|
newQuoteAssetAmount,
|
|
318
|
-
|
|
332
|
+
perpMarket.amm.sqrtK,
|
|
319
333
|
{
|
|
320
334
|
accounts: {
|
|
321
335
|
state: await this.getStatePublicKey(),
|
|
322
336
|
admin: this.wallet.publicKey,
|
|
323
|
-
perpMarket:
|
|
337
|
+
perpMarket: perpMarketPublicKey,
|
|
324
338
|
},
|
|
325
339
|
}
|
|
326
340
|
);
|
|
@@ -328,74 +342,77 @@ export class Admin extends ClearingHouse {
|
|
|
328
342
|
|
|
329
343
|
public async repegAmmCurve(
|
|
330
344
|
newPeg: BN,
|
|
331
|
-
|
|
345
|
+
perpMarketIndex: number
|
|
332
346
|
): Promise<TransactionSignature> {
|
|
333
|
-
const
|
|
347
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
334
348
|
this.program.programId,
|
|
335
|
-
|
|
349
|
+
perpMarketIndex
|
|
336
350
|
);
|
|
337
|
-
const ammData = this.getPerpMarketAccount(
|
|
351
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
338
352
|
|
|
339
353
|
return await this.program.rpc.repegAmmCurve(newPeg, {
|
|
340
354
|
accounts: {
|
|
341
355
|
state: await this.getStatePublicKey(),
|
|
342
356
|
admin: this.wallet.publicKey,
|
|
343
357
|
oracle: ammData.oracle,
|
|
344
|
-
|
|
358
|
+
perpMarket: perpMarketPublicKey,
|
|
345
359
|
},
|
|
346
360
|
});
|
|
347
361
|
}
|
|
348
362
|
|
|
349
|
-
public async
|
|
350
|
-
|
|
363
|
+
public async updatePerpMarketAmmOracleTwap(
|
|
364
|
+
perpMarketIndex: number
|
|
351
365
|
): Promise<TransactionSignature> {
|
|
352
|
-
const ammData = this.getPerpMarketAccount(
|
|
353
|
-
const
|
|
366
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
367
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
354
368
|
this.program.programId,
|
|
355
|
-
|
|
369
|
+
perpMarketIndex
|
|
356
370
|
);
|
|
357
371
|
|
|
358
|
-
return await this.program.rpc.
|
|
372
|
+
return await this.program.rpc.updatePerpMarketAmmOracleTwap({
|
|
359
373
|
accounts: {
|
|
360
374
|
state: await this.getStatePublicKey(),
|
|
361
375
|
admin: this.wallet.publicKey,
|
|
362
376
|
oracle: ammData.oracle,
|
|
363
|
-
|
|
377
|
+
perpMarket: perpMarketPublicKey,
|
|
364
378
|
},
|
|
365
379
|
});
|
|
366
380
|
}
|
|
367
381
|
|
|
368
|
-
public async
|
|
369
|
-
|
|
382
|
+
public async resetPerpMarketAmmOracleTwap(
|
|
383
|
+
perpMarketIndex: number
|
|
370
384
|
): Promise<TransactionSignature> {
|
|
371
|
-
const ammData = this.getPerpMarketAccount(
|
|
372
|
-
const
|
|
385
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
386
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
373
387
|
this.program.programId,
|
|
374
|
-
|
|
388
|
+
perpMarketIndex
|
|
375
389
|
);
|
|
376
390
|
|
|
377
|
-
return await this.program.rpc.
|
|
391
|
+
return await this.program.rpc.resetPerpMarketAmmOracleTwap({
|
|
378
392
|
accounts: {
|
|
379
393
|
state: await this.getStatePublicKey(),
|
|
380
394
|
admin: this.wallet.publicKey,
|
|
381
395
|
oracle: ammData.oracle,
|
|
382
|
-
|
|
396
|
+
perpMarket: perpMarketPublicKey,
|
|
383
397
|
},
|
|
384
398
|
});
|
|
385
399
|
}
|
|
386
400
|
|
|
387
|
-
public async
|
|
388
|
-
|
|
401
|
+
public async depositIntoPerpMarketFeePool(
|
|
402
|
+
perpMarketIndex: number,
|
|
389
403
|
amount: BN,
|
|
390
404
|
sourceVault: PublicKey
|
|
391
405
|
): Promise<TransactionSignature> {
|
|
392
406
|
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
393
407
|
|
|
394
|
-
return await this.program.rpc.
|
|
408
|
+
return await this.program.rpc.depositIntoPerpMarketFeePool(amount, {
|
|
395
409
|
accounts: {
|
|
396
410
|
admin: this.wallet.publicKey,
|
|
397
411
|
state: await this.getStatePublicKey(),
|
|
398
|
-
|
|
412
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
413
|
+
this.program.programId,
|
|
414
|
+
perpMarketIndex
|
|
415
|
+
),
|
|
399
416
|
sourceVault,
|
|
400
417
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
401
418
|
quoteSpotMarket: spotMarket.pubkey,
|
|
@@ -414,156 +431,115 @@ export class Admin extends ClearingHouse {
|
|
|
414
431
|
});
|
|
415
432
|
}
|
|
416
433
|
|
|
417
|
-
public async
|
|
418
|
-
|
|
434
|
+
public async updatePerpMarketCurveUpdateIntensity(
|
|
435
|
+
perpMarketIndex: number,
|
|
419
436
|
curveUpdateIntensity: number
|
|
420
437
|
): Promise<TransactionSignature> {
|
|
421
438
|
// assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
|
|
422
439
|
// assert(Number.isInteger(curveUpdateIntensity));
|
|
423
440
|
|
|
424
|
-
return await this.program.rpc.
|
|
441
|
+
return await this.program.rpc.updatePerpMarketCurveUpdateIntensity(
|
|
425
442
|
curveUpdateIntensity,
|
|
426
443
|
{
|
|
427
444
|
accounts: {
|
|
428
445
|
admin: this.wallet.publicKey,
|
|
429
446
|
state: await this.getStatePublicKey(),
|
|
430
|
-
|
|
447
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
448
|
+
this.program.programId,
|
|
449
|
+
perpMarketIndex
|
|
450
|
+
),
|
|
431
451
|
},
|
|
432
452
|
}
|
|
433
453
|
);
|
|
434
454
|
}
|
|
435
455
|
|
|
436
|
-
public async
|
|
437
|
-
|
|
456
|
+
public async updatePerpMarketMarginRatio(
|
|
457
|
+
perpMarketIndex: number,
|
|
438
458
|
marginRatioInitial: number,
|
|
439
459
|
marginRatioMaintenance: number
|
|
440
460
|
): Promise<TransactionSignature> {
|
|
441
|
-
return await this.program.rpc.
|
|
461
|
+
return await this.program.rpc.updatePerpMarketMarginRatio(
|
|
442
462
|
marginRatioInitial,
|
|
443
463
|
marginRatioMaintenance,
|
|
444
464
|
{
|
|
445
465
|
accounts: {
|
|
446
466
|
admin: this.wallet.publicKey,
|
|
447
467
|
state: await this.getStatePublicKey(),
|
|
448
|
-
|
|
468
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
469
|
+
this.program.programId,
|
|
470
|
+
perpMarketIndex
|
|
471
|
+
),
|
|
449
472
|
},
|
|
450
473
|
}
|
|
451
474
|
);
|
|
452
475
|
}
|
|
453
476
|
|
|
454
|
-
public async
|
|
455
|
-
|
|
477
|
+
public async updatePerpMarketBaseSpread(
|
|
478
|
+
perpMarketIndex: number,
|
|
456
479
|
baseSpread: number
|
|
457
480
|
): Promise<TransactionSignature> {
|
|
458
|
-
return await this.program.rpc.
|
|
481
|
+
return await this.program.rpc.updatePerpMarketBaseSpread(baseSpread, {
|
|
459
482
|
accounts: {
|
|
460
483
|
admin: this.wallet.publicKey,
|
|
461
484
|
state: await this.getStatePublicKey(),
|
|
462
|
-
|
|
485
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
486
|
+
this.program.programId,
|
|
487
|
+
perpMarketIndex
|
|
488
|
+
),
|
|
463
489
|
},
|
|
464
490
|
});
|
|
465
491
|
}
|
|
466
492
|
|
|
467
493
|
public async updateAmmJitIntensity(
|
|
468
|
-
|
|
494
|
+
perpMarketIndex: number,
|
|
469
495
|
ammJitIntensity: number
|
|
470
496
|
): Promise<TransactionSignature> {
|
|
471
497
|
return await this.program.rpc.updateAmmJitIntensity(ammJitIntensity, {
|
|
472
498
|
accounts: {
|
|
473
499
|
admin: this.wallet.publicKey,
|
|
474
500
|
state: await this.getStatePublicKey(),
|
|
475
|
-
|
|
501
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
502
|
+
this.program.programId,
|
|
503
|
+
perpMarketIndex
|
|
504
|
+
),
|
|
476
505
|
},
|
|
477
506
|
});
|
|
478
507
|
}
|
|
479
508
|
|
|
480
|
-
public async
|
|
481
|
-
|
|
482
|
-
|
|
509
|
+
public async updatePerpMarketName(
|
|
510
|
+
perpMarketIndex: number,
|
|
511
|
+
name: string
|
|
483
512
|
): Promise<TransactionSignature> {
|
|
484
|
-
|
|
513
|
+
const nameBuffer = encodeName(name);
|
|
514
|
+
|
|
515
|
+
return await this.program.rpc.updatePerpMarketName(nameBuffer, {
|
|
485
516
|
accounts: {
|
|
486
517
|
admin: this.wallet.publicKey,
|
|
487
518
|
state: await this.getStatePublicKey(),
|
|
488
|
-
|
|
519
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
520
|
+
this.program.programId,
|
|
521
|
+
perpMarketIndex
|
|
522
|
+
),
|
|
489
523
|
},
|
|
490
524
|
});
|
|
491
525
|
}
|
|
492
526
|
|
|
493
|
-
public async
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
): Promise<TransactionSignature> {
|
|
497
|
-
return await this.program.rpc.updatePartialLiquidationClosePercentage(
|
|
498
|
-
numerator,
|
|
499
|
-
denominator,
|
|
500
|
-
{
|
|
501
|
-
accounts: {
|
|
502
|
-
admin: this.wallet.publicKey,
|
|
503
|
-
state: await this.getStatePublicKey(),
|
|
504
|
-
},
|
|
505
|
-
}
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
public async updatePartialLiquidationPenaltyPercentage(
|
|
510
|
-
numerator: BN,
|
|
511
|
-
denominator: BN
|
|
512
|
-
): Promise<TransactionSignature> {
|
|
513
|
-
return await this.program.rpc.updatePartialLiquidationPenaltyPercentage(
|
|
514
|
-
numerator,
|
|
515
|
-
denominator,
|
|
516
|
-
{
|
|
517
|
-
accounts: {
|
|
518
|
-
admin: this.wallet.publicKey,
|
|
519
|
-
state: await this.getStatePublicKey(),
|
|
520
|
-
},
|
|
521
|
-
}
|
|
522
|
-
);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
public async updateFullLiquidationPenaltyPercentage(
|
|
526
|
-
numerator: BN,
|
|
527
|
-
denominator: BN
|
|
528
|
-
): Promise<TransactionSignature> {
|
|
529
|
-
return await this.program.rpc.updateFullLiquidationPenaltyPercentage(
|
|
530
|
-
numerator,
|
|
531
|
-
denominator,
|
|
532
|
-
{
|
|
533
|
-
accounts: {
|
|
534
|
-
admin: this.wallet.publicKey,
|
|
535
|
-
state: await this.getStatePublicKey(),
|
|
536
|
-
},
|
|
537
|
-
}
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
public async updatePartialLiquidationShareDenominator(
|
|
542
|
-
denominator: BN
|
|
527
|
+
public async updatePerpMarketMaxSpread(
|
|
528
|
+
perpMarketIndex: number,
|
|
529
|
+
maxSpread: number
|
|
543
530
|
): Promise<TransactionSignature> {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
accounts: {
|
|
548
|
-
admin: this.wallet.publicKey,
|
|
549
|
-
state: await this.getStatePublicKey(),
|
|
550
|
-
},
|
|
551
|
-
}
|
|
531
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
532
|
+
this.program.programId,
|
|
533
|
+
perpMarketIndex
|
|
552
534
|
);
|
|
553
|
-
}
|
|
554
535
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
admin: this.wallet.publicKey,
|
|
563
|
-
state: await this.getStatePublicKey(),
|
|
564
|
-
},
|
|
565
|
-
}
|
|
566
|
-
);
|
|
536
|
+
return await this.program.rpc.updatePerpMarketMaxSpread(maxSpread, {
|
|
537
|
+
accounts: {
|
|
538
|
+
admin: this.wallet.publicKey,
|
|
539
|
+
state: await this.getStatePublicKey(),
|
|
540
|
+
perpMarket: perpMarketPublicKey,
|
|
541
|
+
},
|
|
542
|
+
});
|
|
567
543
|
}
|
|
568
544
|
|
|
569
545
|
public async updatePerpFeeStructure(
|
|
@@ -599,8 +575,22 @@ export class Admin extends ClearingHouse {
|
|
|
599
575
|
});
|
|
600
576
|
}
|
|
601
577
|
|
|
578
|
+
public async updateStateSettlementDuration(
|
|
579
|
+
settlementDuration: number
|
|
580
|
+
): Promise<TransactionSignature> {
|
|
581
|
+
return await this.program.rpc.updateStateSettlementDuration(
|
|
582
|
+
settlementDuration,
|
|
583
|
+
{
|
|
584
|
+
accounts: {
|
|
585
|
+
admin: this.wallet.publicKey,
|
|
586
|
+
state: await this.getStatePublicKey(),
|
|
587
|
+
},
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
|
|
602
592
|
public async updateWithdrawGuardThreshold(
|
|
603
|
-
|
|
593
|
+
spotMarketIndex: number,
|
|
604
594
|
withdrawGuardThreshold: BN
|
|
605
595
|
): Promise<TransactionSignature> {
|
|
606
596
|
return await this.program.rpc.updateWithdrawGuardThreshold(
|
|
@@ -611,7 +601,7 @@ export class Admin extends ClearingHouse {
|
|
|
611
601
|
state: await this.getStatePublicKey(),
|
|
612
602
|
spotMarket: await getSpotMarketPublicKey(
|
|
613
603
|
this.program.programId,
|
|
614
|
-
|
|
604
|
+
spotMarketIndex
|
|
615
605
|
),
|
|
616
606
|
},
|
|
617
607
|
}
|
|
@@ -619,12 +609,12 @@ export class Admin extends ClearingHouse {
|
|
|
619
609
|
}
|
|
620
610
|
|
|
621
611
|
public async updateSpotMarketIfFactor(
|
|
622
|
-
|
|
612
|
+
spotMarketIndex: number,
|
|
623
613
|
userIfFactor: BN,
|
|
624
614
|
totalIfFactor: BN
|
|
625
615
|
): Promise<TransactionSignature> {
|
|
626
616
|
return await this.program.rpc.updateSpotMarketIfFactor(
|
|
627
|
-
|
|
617
|
+
spotMarketIndex,
|
|
628
618
|
userIfFactor,
|
|
629
619
|
totalIfFactor,
|
|
630
620
|
{
|
|
@@ -633,7 +623,7 @@ export class Admin extends ClearingHouse {
|
|
|
633
623
|
state: await this.getStatePublicKey(),
|
|
634
624
|
spotMarket: await getSpotMarketPublicKey(
|
|
635
625
|
this.program.programId,
|
|
636
|
-
|
|
626
|
+
spotMarketIndex
|
|
637
627
|
),
|
|
638
628
|
},
|
|
639
629
|
}
|
|
@@ -641,7 +631,7 @@ export class Admin extends ClearingHouse {
|
|
|
641
631
|
}
|
|
642
632
|
|
|
643
633
|
public async updateSpotMarketRevenueSettlePeriod(
|
|
644
|
-
|
|
634
|
+
spotMarketIndex: number,
|
|
645
635
|
revenueSettlePeriod: BN
|
|
646
636
|
): Promise<TransactionSignature> {
|
|
647
637
|
return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(
|
|
@@ -652,7 +642,7 @@ export class Admin extends ClearingHouse {
|
|
|
652
642
|
state: await this.getStatePublicKey(),
|
|
653
643
|
spotMarket: await getSpotMarketPublicKey(
|
|
654
644
|
this.program.programId,
|
|
655
|
-
|
|
645
|
+
spotMarketIndex
|
|
656
646
|
),
|
|
657
647
|
},
|
|
658
648
|
}
|
|
@@ -660,7 +650,7 @@ export class Admin extends ClearingHouse {
|
|
|
660
650
|
}
|
|
661
651
|
|
|
662
652
|
public async updateSpotMarketMaxTokenDeposits(
|
|
663
|
-
|
|
653
|
+
spotMarketIndex: number,
|
|
664
654
|
maxTokenDeposits: BN
|
|
665
655
|
): Promise<TransactionSignature> {
|
|
666
656
|
return await this.program.rpc.updateSpotMarketMaxTokenDeposits(
|
|
@@ -671,18 +661,18 @@ export class Admin extends ClearingHouse {
|
|
|
671
661
|
state: await this.getStatePublicKey(),
|
|
672
662
|
spotMarket: await getSpotMarketPublicKey(
|
|
673
663
|
this.program.programId,
|
|
674
|
-
|
|
664
|
+
spotMarketIndex
|
|
675
665
|
),
|
|
676
666
|
},
|
|
677
667
|
}
|
|
678
668
|
);
|
|
679
669
|
}
|
|
680
670
|
|
|
681
|
-
public async
|
|
682
|
-
|
|
671
|
+
public async updateInsuranceFundUnstakingPeriod(
|
|
672
|
+
spotMarketIndex: number,
|
|
683
673
|
insuranceWithdrawEscrowPeriod: BN
|
|
684
674
|
): Promise<TransactionSignature> {
|
|
685
|
-
return await this.program.rpc.
|
|
675
|
+
return await this.program.rpc.updateInsuranceFundUnstakingPeriod(
|
|
686
676
|
insuranceWithdrawEscrowPeriod,
|
|
687
677
|
{
|
|
688
678
|
accounts: {
|
|
@@ -690,7 +680,7 @@ export class Admin extends ClearingHouse {
|
|
|
690
680
|
state: await this.getStatePublicKey(),
|
|
691
681
|
spotMarket: await getSpotMarketPublicKey(
|
|
692
682
|
this.program.programId,
|
|
693
|
-
|
|
683
|
+
spotMarketIndex
|
|
694
684
|
),
|
|
695
685
|
},
|
|
696
686
|
}
|
|
@@ -698,73 +688,80 @@ export class Admin extends ClearingHouse {
|
|
|
698
688
|
}
|
|
699
689
|
|
|
700
690
|
public async updateLpCooldownTime(
|
|
701
|
-
marketIndex: number,
|
|
702
691
|
cooldownTime: BN
|
|
703
692
|
): Promise<TransactionSignature> {
|
|
704
693
|
return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
|
|
705
694
|
accounts: {
|
|
706
695
|
admin: this.wallet.publicKey,
|
|
707
696
|
state: await this.getStatePublicKey(),
|
|
708
|
-
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
709
697
|
},
|
|
710
698
|
});
|
|
711
699
|
}
|
|
712
700
|
|
|
713
|
-
public async
|
|
714
|
-
|
|
701
|
+
public async updatePerpMarketOracle(
|
|
702
|
+
perpMarketIndex: number,
|
|
715
703
|
oracle: PublicKey,
|
|
716
704
|
oracleSource: OracleSource
|
|
717
705
|
): Promise<TransactionSignature> {
|
|
718
|
-
return await this.program.rpc.
|
|
706
|
+
return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
|
|
719
707
|
accounts: {
|
|
720
708
|
admin: this.wallet.publicKey,
|
|
721
709
|
state: await this.getStatePublicKey(),
|
|
722
|
-
|
|
710
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
711
|
+
this.program.programId,
|
|
712
|
+
perpMarketIndex
|
|
713
|
+
),
|
|
714
|
+
oracle: oracle,
|
|
723
715
|
},
|
|
724
716
|
});
|
|
725
717
|
}
|
|
726
718
|
|
|
727
|
-
public async
|
|
728
|
-
|
|
729
|
-
|
|
719
|
+
public async updatePerpMarketStepSizeAndTickSize(
|
|
720
|
+
perpMarketIndex: number,
|
|
721
|
+
stepSize: BN,
|
|
722
|
+
tickSize: BN
|
|
730
723
|
): Promise<TransactionSignature> {
|
|
731
|
-
return await this.program.rpc.
|
|
732
|
-
|
|
724
|
+
return await this.program.rpc.updatePerpMarketStepSizeAndTickSize(
|
|
725
|
+
stepSize,
|
|
726
|
+
tickSize,
|
|
733
727
|
{
|
|
734
728
|
accounts: {
|
|
735
729
|
admin: this.wallet.publicKey,
|
|
736
730
|
state: await this.getStatePublicKey(),
|
|
737
|
-
|
|
731
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
732
|
+
this.program.programId,
|
|
733
|
+
perpMarketIndex
|
|
734
|
+
),
|
|
738
735
|
},
|
|
739
736
|
}
|
|
740
737
|
);
|
|
741
738
|
}
|
|
742
739
|
|
|
743
|
-
public async
|
|
744
|
-
|
|
745
|
-
|
|
740
|
+
public async updatePerpMarketMinOrderSize(
|
|
741
|
+
perpMarketIndex: number,
|
|
742
|
+
orderSize: BN
|
|
746
743
|
): Promise<TransactionSignature> {
|
|
747
|
-
return await this.program.rpc.
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
);
|
|
744
|
+
return await this.program.rpc.updatePerpMarketMinOrderSize(orderSize, {
|
|
745
|
+
accounts: {
|
|
746
|
+
admin: this.wallet.publicKey,
|
|
747
|
+
state: await this.getStatePublicKey(),
|
|
748
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
749
|
+
this.program.programId,
|
|
750
|
+
perpMarketIndex
|
|
751
|
+
),
|
|
752
|
+
},
|
|
753
|
+
});
|
|
757
754
|
}
|
|
758
755
|
|
|
759
|
-
public async
|
|
756
|
+
public async updatePerpMarketExpiry(
|
|
760
757
|
perpMarketIndex: number,
|
|
761
758
|
expiryTs: BN
|
|
762
759
|
): Promise<TransactionSignature> {
|
|
763
|
-
return await this.program.rpc.
|
|
760
|
+
return await this.program.rpc.updatePerpMarketExpiry(expiryTs, {
|
|
764
761
|
accounts: {
|
|
765
762
|
admin: this.wallet.publicKey,
|
|
766
763
|
state: await this.getStatePublicKey(),
|
|
767
|
-
perpMarket: await
|
|
764
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
768
765
|
this.program.programId,
|
|
769
766
|
perpMarketIndex
|
|
770
767
|
),
|
|
@@ -772,21 +769,44 @@ export class Admin extends ClearingHouse {
|
|
|
772
769
|
});
|
|
773
770
|
}
|
|
774
771
|
|
|
775
|
-
public async
|
|
776
|
-
|
|
772
|
+
public async updateSpotMarketOracle(
|
|
773
|
+
spotMarketIndex: number,
|
|
774
|
+
oracle: PublicKey,
|
|
775
|
+
oracleSource: OracleSource
|
|
777
776
|
): Promise<TransactionSignature> {
|
|
778
|
-
return await this.program.rpc.
|
|
777
|
+
return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
|
|
779
778
|
accounts: {
|
|
780
779
|
admin: this.wallet.publicKey,
|
|
781
780
|
state: await this.getStatePublicKey(),
|
|
781
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
782
|
+
this.program.programId,
|
|
783
|
+
spotMarketIndex
|
|
784
|
+
),
|
|
785
|
+
oracle: oracle,
|
|
782
786
|
},
|
|
783
787
|
});
|
|
784
788
|
}
|
|
785
789
|
|
|
786
|
-
public async
|
|
787
|
-
|
|
790
|
+
public async updateSpotMarketExpiry(
|
|
791
|
+
spotMarketIndex: number,
|
|
792
|
+
expiryTs: BN
|
|
788
793
|
): Promise<TransactionSignature> {
|
|
789
|
-
return await this.program.rpc.
|
|
794
|
+
return await this.program.rpc.updateSpotMarketExpiry(expiryTs, {
|
|
795
|
+
accounts: {
|
|
796
|
+
admin: this.wallet.publicKey,
|
|
797
|
+
state: await this.getStatePublicKey(),
|
|
798
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
799
|
+
this.program.programId,
|
|
800
|
+
spotMarketIndex
|
|
801
|
+
),
|
|
802
|
+
},
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
public async updateWhitelistMint(
|
|
807
|
+
whitelistMint?: PublicKey
|
|
808
|
+
): Promise<TransactionSignature> {
|
|
809
|
+
return await this.program.rpc.updateWhitelistMint(whitelistMint, {
|
|
790
810
|
accounts: {
|
|
791
811
|
admin: this.wallet.publicKey,
|
|
792
812
|
state: await this.getStatePublicKey(),
|
|
@@ -794,8 +814,10 @@ export class Admin extends ClearingHouse {
|
|
|
794
814
|
});
|
|
795
815
|
}
|
|
796
816
|
|
|
797
|
-
public async
|
|
798
|
-
|
|
817
|
+
public async updateDiscountMint(
|
|
818
|
+
discountMint: PublicKey
|
|
819
|
+
): Promise<TransactionSignature> {
|
|
820
|
+
return await this.program.rpc.updateDiscountMint(discountMint, {
|
|
799
821
|
accounts: {
|
|
800
822
|
admin: this.wallet.publicKey,
|
|
801
823
|
state: await this.getStatePublicKey(),
|
|
@@ -870,7 +892,7 @@ export class Admin extends ClearingHouse {
|
|
|
870
892
|
accounts: {
|
|
871
893
|
admin: this.wallet.publicKey,
|
|
872
894
|
state: await this.getStatePublicKey(),
|
|
873
|
-
|
|
895
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
874
896
|
this.program.programId,
|
|
875
897
|
perpMarketIndex
|
|
876
898
|
),
|
|
@@ -886,7 +908,7 @@ export class Admin extends ClearingHouse {
|
|
|
886
908
|
accounts: {
|
|
887
909
|
admin: this.wallet.publicKey,
|
|
888
910
|
state: await this.getStatePublicKey(),
|
|
889
|
-
|
|
911
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
890
912
|
this.program.programId,
|
|
891
913
|
perpMarketIndex
|
|
892
914
|
),
|
|
@@ -933,42 +955,42 @@ export class Admin extends ClearingHouse {
|
|
|
933
955
|
);
|
|
934
956
|
}
|
|
935
957
|
|
|
936
|
-
public async
|
|
937
|
-
|
|
958
|
+
public async updatePerpMarketMaxFillReserveFraction(
|
|
959
|
+
perpMarketIndex: number,
|
|
938
960
|
maxBaseAssetAmountRatio: number
|
|
939
961
|
): Promise<TransactionSignature> {
|
|
940
|
-
return await this.program.rpc.
|
|
962
|
+
return await this.program.rpc.updatePerpMarketMaxFillReserveFraction(
|
|
941
963
|
maxBaseAssetAmountRatio,
|
|
942
964
|
{
|
|
943
965
|
accounts: {
|
|
944
966
|
admin: this.wallet.publicKey,
|
|
945
967
|
state: await this.getStatePublicKey(),
|
|
946
|
-
|
|
968
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
947
969
|
},
|
|
948
970
|
}
|
|
949
971
|
);
|
|
950
972
|
}
|
|
951
973
|
|
|
952
974
|
public async updateMaxSlippageRatio(
|
|
953
|
-
|
|
975
|
+
perpMarketIndex: number,
|
|
954
976
|
maxSlippageRatio: number
|
|
955
977
|
): Promise<TransactionSignature> {
|
|
956
978
|
return await this.program.rpc.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
957
979
|
accounts: {
|
|
958
980
|
admin: this.wallet.publicKey,
|
|
959
981
|
state: await this.getStatePublicKey(),
|
|
960
|
-
|
|
982
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
961
983
|
},
|
|
962
984
|
});
|
|
963
985
|
}
|
|
964
986
|
|
|
965
|
-
public async
|
|
966
|
-
|
|
987
|
+
public async updatePerpMarketMaxImbalances(
|
|
988
|
+
perpMarketIndex: number,
|
|
967
989
|
unrealizedMaxImbalance: BN,
|
|
968
990
|
maxRevenueWithdrawPerPeriod: BN,
|
|
969
991
|
quoteMaxInsurance: BN
|
|
970
992
|
): Promise<TransactionSignature> {
|
|
971
|
-
return await this.program.rpc.
|
|
993
|
+
return await this.program.rpc.updatePerpMarketMaxImbalances(
|
|
972
994
|
unrealizedMaxImbalance,
|
|
973
995
|
maxRevenueWithdrawPerPeriod,
|
|
974
996
|
quoteMaxInsurance,
|
|
@@ -976,7 +998,10 @@ export class Admin extends ClearingHouse {
|
|
|
976
998
|
accounts: {
|
|
977
999
|
admin: this.wallet.publicKey,
|
|
978
1000
|
state: await this.getStatePublicKey(),
|
|
979
|
-
|
|
1001
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1002
|
+
this.program.programId,
|
|
1003
|
+
perpMarketIndex
|
|
1004
|
+
),
|
|
980
1005
|
},
|
|
981
1006
|
}
|
|
982
1007
|
);
|