@drift-labs/sdk 2.13.0-beta.2 → 2.14.0-beta.0
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.d.ts +1 -0
- package/lib/accounts/bulkAccountLoader.js +3 -3
- package/lib/accounts/fetch.js +2 -2
- package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
- package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
- package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
- package/lib/accounts/types.d.ts +1 -0
- package/lib/accounts/webSocketAccountSubscriber.js +1 -1
- package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.js +5 -1
- package/lib/adminClient.js +61 -57
- package/lib/dlob/DLOB.js +67 -67
- package/lib/dlob/DLOBNode.js +7 -7
- package/lib/dlob/NodeList.js +2 -2
- package/lib/driftClient.d.ts +33 -33
- package/lib/driftClient.js +120 -116
- package/lib/events/eventSubscriber.js +2 -2
- package/lib/events/pollingLogProvider.js +1 -1
- package/lib/events/types.d.ts +1 -0
- package/lib/examples/loadDlob.js +2 -2
- package/lib/examples/makeTradeExample.js +9 -9
- package/lib/factory/bigNum.js +9 -9
- package/lib/factory/oracleClient.js +2 -2
- package/lib/idl/drift.json +1 -1
- package/lib/index.js +5 -1
- package/lib/math/amm.js +23 -23
- package/lib/math/auction.js +6 -6
- package/lib/math/exchangeStatus.js +2 -2
- package/lib/math/funding.d.ts +1 -1
- package/lib/math/funding.js +8 -8
- package/lib/math/margin.js +5 -5
- package/lib/math/market.js +13 -13
- package/lib/math/oracles.js +1 -1
- package/lib/math/orders.js +23 -23
- package/lib/math/position.js +5 -5
- package/lib/math/repeg.js +1 -1
- package/lib/math/spotBalance.js +9 -9
- package/lib/math/spotPosition.js +3 -3
- package/lib/math/trade.js +42 -42
- package/lib/oracles/oracleClientCache.js +1 -1
- package/lib/oracles/pythClient.js +1 -1
- package/lib/token/index.js +1 -1
- package/lib/tokenFaucet.js +5 -1
- package/lib/tx/retryTxSender.js +1 -1
- package/lib/user.d.ts +8 -9
- package/lib/user.js +153 -158
- package/lib/userMap/userMap.js +1 -1
- package/lib/userMap/userStatsMap.js +3 -3
- package/lib/userStats.js +2 -2
- package/package.json +3 -3
- package/src/driftClient.ts +209 -68
- package/src/events/types.ts +15 -0
- package/src/idl/drift.json +1 -1
- package/src/math/funding.ts +7 -8
- package/src/math/spotBalance.ts +14 -7
- package/src/token/index.ts +1 -1
- package/src/user.ts +187 -184
- package/src/assert/assert.js +0 -9
- package/src/token/index.js +0 -38
- package/src/tx/types.js +0 -2
- package/src/tx/utils.js +0 -17
- package/src/util/computeUnits.js +0 -27
- package/src/util/getTokenAddress.js +0 -9
- package/src/util/promiseTimeout.js +0 -14
- package/src/util/tps.js +0 -27
package/lib/driftClient.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -76,7 +80,7 @@ class DriftClient {
|
|
|
76
80
|
if (config.userStats) {
|
|
77
81
|
this.userStats = new userStats_1.UserStats({
|
|
78
82
|
driftClient: this,
|
|
79
|
-
userStatsAccountPublicKey: pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority),
|
|
83
|
+
userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority),
|
|
80
84
|
accountSubscription: this.userAccountSubscriptionConfig,
|
|
81
85
|
});
|
|
82
86
|
}
|
|
@@ -84,7 +88,7 @@ class DriftClient {
|
|
|
84
88
|
let spotMarketIndexes = config.spotMarketIndexes;
|
|
85
89
|
let oracleInfos = config.oracleInfos;
|
|
86
90
|
if (config.env) {
|
|
87
|
-
const { perpMarketIndexes: envPerpMarketIndexes, spotMarketIndexes: envSpotMarketIndexes, oracleInfos: envOracleInfos, } = config_1.getMarketsAndOraclesForSubscription(config.env);
|
|
91
|
+
const { perpMarketIndexes: envPerpMarketIndexes, spotMarketIndexes: envSpotMarketIndexes, oracleInfos: envOracleInfos, } = (0, config_1.getMarketsAndOraclesForSubscription)(config.env);
|
|
88
92
|
perpMarketIndexes = perpMarketIndexes
|
|
89
93
|
? perpMarketIndexes
|
|
90
94
|
: envPerpMarketIndexes;
|
|
@@ -115,7 +119,7 @@ class DriftClient {
|
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
createUser(subAccountId, accountSubscriptionConfig) {
|
|
118
|
-
const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.authority, subAccountId);
|
|
122
|
+
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.authority, subAccountId);
|
|
119
123
|
return new user_1.User({
|
|
120
124
|
driftClient: this,
|
|
121
125
|
userAccountPublicKey,
|
|
@@ -160,14 +164,14 @@ class DriftClient {
|
|
|
160
164
|
if (this.statePublicKey) {
|
|
161
165
|
return this.statePublicKey;
|
|
162
166
|
}
|
|
163
|
-
this.statePublicKey = await pda_1.getDriftStateAccountPublicKey(this.program.programId);
|
|
167
|
+
this.statePublicKey = await (0, pda_1.getDriftStateAccountPublicKey)(this.program.programId);
|
|
164
168
|
return this.statePublicKey;
|
|
165
169
|
}
|
|
166
170
|
getSignerPublicKey() {
|
|
167
171
|
if (this.signerPublicKey) {
|
|
168
172
|
return this.signerPublicKey;
|
|
169
173
|
}
|
|
170
|
-
this.signerPublicKey = pda_1.getDriftSignerPublicKey(this.program.programId);
|
|
174
|
+
this.signerPublicKey = (0, pda_1.getDriftSignerPublicKey)(this.program.programId);
|
|
171
175
|
return this.signerPublicKey;
|
|
172
176
|
}
|
|
173
177
|
getStateAccount() {
|
|
@@ -228,7 +232,7 @@ class DriftClient {
|
|
|
228
232
|
return this.accountSubscriber.getOraclePriceDataAndSlot(oraclePublicKey);
|
|
229
233
|
}
|
|
230
234
|
async getSerumV3FulfillmentConfig(serumMarket) {
|
|
231
|
-
const address = await pda_1.getSerumFulfillmentConfigPublicKey(this.program.programId, serumMarket);
|
|
235
|
+
const address = await (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
|
|
232
236
|
return (await this.program.account.serumV3FulfillmentConfig.fetch(address));
|
|
233
237
|
}
|
|
234
238
|
/**
|
|
@@ -252,7 +256,7 @@ class DriftClient {
|
|
|
252
256
|
await this.userStats.unsubscribe();
|
|
253
257
|
this.userStats = new userStats_1.UserStats({
|
|
254
258
|
driftClient: this,
|
|
255
|
-
userStatsAccountPublicKey: pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority),
|
|
259
|
+
userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority),
|
|
256
260
|
accountSubscription: this.userAccountSubscriptionConfig,
|
|
257
261
|
});
|
|
258
262
|
}
|
|
@@ -292,7 +296,7 @@ class DriftClient {
|
|
|
292
296
|
return [txSig, userAccountPublicKey];
|
|
293
297
|
}
|
|
294
298
|
async getInitializeUserInstructions(subAccountId = 0, name = userName_1.DEFAULT_USER_NAME, referrerInfo) {
|
|
295
|
-
const userAccountPublicKey = await pda_1.getUserAccountPublicKey(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
299
|
+
const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
296
300
|
const remainingAccounts = new Array();
|
|
297
301
|
if (referrerInfo !== undefined) {
|
|
298
302
|
remainingAccounts.push({
|
|
@@ -315,7 +319,7 @@ class DriftClient {
|
|
|
315
319
|
isSigner: false,
|
|
316
320
|
});
|
|
317
321
|
}
|
|
318
|
-
const nameBuffer = userName_1.encodeName(name);
|
|
322
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
319
323
|
const initializeUserAccountIx = await this.program.instruction.initializeUser(subAccountId, nameBuffer, {
|
|
320
324
|
accounts: {
|
|
321
325
|
user: userAccountPublicKey,
|
|
@@ -343,8 +347,8 @@ class DriftClient {
|
|
|
343
347
|
});
|
|
344
348
|
}
|
|
345
349
|
async updateUserName(name, subAccountId = 0) {
|
|
346
|
-
const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
347
|
-
const nameBuffer = userName_1.encodeName(name);
|
|
350
|
+
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
351
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
348
352
|
const tx = await this.program.transaction.updateUserName(subAccountId, nameBuffer, {
|
|
349
353
|
accounts: {
|
|
350
354
|
user: userAccountPublicKey,
|
|
@@ -365,7 +369,7 @@ class DriftClient {
|
|
|
365
369
|
return txSig;
|
|
366
370
|
}
|
|
367
371
|
async updateUserMarginTradingEnabled(marginTradingEnabled, subAccountId = 0) {
|
|
368
|
-
const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
372
|
+
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
369
373
|
const tx = await this.program.transaction.updateUserMarginTradingEnabled(subAccountId, marginTradingEnabled, {
|
|
370
374
|
accounts: {
|
|
371
375
|
user: userAccountPublicKey,
|
|
@@ -409,9 +413,9 @@ class DriftClient {
|
|
|
409
413
|
]);
|
|
410
414
|
return programAccounts.map((programAccount) => programAccount.account);
|
|
411
415
|
}
|
|
412
|
-
async deleteUser(subAccountId = 0) {
|
|
416
|
+
async deleteUser(subAccountId = 0, txParams) {
|
|
413
417
|
var _a;
|
|
414
|
-
const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
418
|
+
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
415
419
|
const ix = await this.program.instruction.deleteUser({
|
|
416
420
|
accounts: {
|
|
417
421
|
user: userAccountPublicKey,
|
|
@@ -420,7 +424,7 @@ class DriftClient {
|
|
|
420
424
|
state: await this.getStatePublicKey(),
|
|
421
425
|
},
|
|
422
426
|
});
|
|
423
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(ix), [], this.opts);
|
|
427
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(ix, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
424
428
|
await ((_a = this.users.get(subAccountId)) === null || _a === void 0 ? void 0 : _a.unsubscribe());
|
|
425
429
|
this.users.delete(subAccountId);
|
|
426
430
|
return txSig;
|
|
@@ -442,7 +446,7 @@ class DriftClient {
|
|
|
442
446
|
if (this.userStatsAccountPublicKey) {
|
|
443
447
|
return this.userStatsAccountPublicKey;
|
|
444
448
|
}
|
|
445
|
-
this.userStatsAccountPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, this.authority);
|
|
449
|
+
this.userStatsAccountPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, this.authority);
|
|
446
450
|
return this.userStatsAccountPublicKey;
|
|
447
451
|
}
|
|
448
452
|
async getUserAccountPublicKey() {
|
|
@@ -468,7 +472,7 @@ class DriftClient {
|
|
|
468
472
|
getQuoteAssetTokenAmount() {
|
|
469
473
|
const spotMarket = this.getSpotMarketAccount(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
|
|
470
474
|
const spotPosition = this.getSpotPosition(numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
|
|
471
|
-
return spotBalance_1.getTokenAmount(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
|
|
475
|
+
return (0, spotBalance_1.getTokenAmount)(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
|
|
472
476
|
}
|
|
473
477
|
getTokenAmount(marketIndex) {
|
|
474
478
|
const spotPosition = this.getSpotPosition(marketIndex);
|
|
@@ -476,7 +480,7 @@ class DriftClient {
|
|
|
476
480
|
return numericConstants_1.ZERO;
|
|
477
481
|
}
|
|
478
482
|
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
479
|
-
return spotBalance_1.getTokenAmount(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
|
|
483
|
+
return (0, spotBalance_1.getTokenAmount)(spotPosition.scaledBalance, spotMarket, spotPosition.balanceType);
|
|
480
484
|
}
|
|
481
485
|
getRemainingAccounts(params) {
|
|
482
486
|
var _a;
|
|
@@ -600,7 +604,7 @@ class DriftClient {
|
|
|
600
604
|
const perpMarketAccountMap = new Map();
|
|
601
605
|
for (const userAccount of userAccounts) {
|
|
602
606
|
for (const spotPosition of userAccount.spotPositions) {
|
|
603
|
-
if (!spotPosition_1.isSpotPositionAvailable(spotPosition)) {
|
|
607
|
+
if (!(0, spotPosition_1.isSpotPositionAvailable)(spotPosition)) {
|
|
604
608
|
const spotMarket = this.getSpotMarketAccount(spotPosition.marketIndex);
|
|
605
609
|
spotMarketAccountMap.set(spotPosition.marketIndex, {
|
|
606
610
|
pubkey: spotMarket.pubkey,
|
|
@@ -625,7 +629,7 @@ class DriftClient {
|
|
|
625
629
|
}
|
|
626
630
|
}
|
|
627
631
|
for (const position of userAccount.perpPositions) {
|
|
628
|
-
if (!position_1.positionIsAvailable(position)) {
|
|
632
|
+
if (!(0, position_1.positionIsAvailable)(position)) {
|
|
629
633
|
const market = this.getPerpMarketAccount(position.marketIndex);
|
|
630
634
|
perpMarketAccountMap.set(position.marketIndex, {
|
|
631
635
|
pubkey: market.pubkey,
|
|
@@ -685,7 +689,7 @@ class DriftClient {
|
|
|
685
689
|
}
|
|
686
690
|
async getDepositInstruction(amount, marketIndex, userTokenAccount, subAccountId, reduceOnly = false, userInitialized = true) {
|
|
687
691
|
const userAccountPublicKey = subAccountId
|
|
688
|
-
? await pda_1.getUserAccountPublicKey(this.program.programId, this.authority, subAccountId)
|
|
692
|
+
? await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, subAccountId)
|
|
689
693
|
: await this.getUserAccountPublicKey();
|
|
690
694
|
let remainingAccounts = [];
|
|
691
695
|
if (userInitialized) {
|
|
@@ -870,8 +874,8 @@ class DriftClient {
|
|
|
870
874
|
remainingAccounts,
|
|
871
875
|
});
|
|
872
876
|
}
|
|
873
|
-
async transferDeposit(amount, marketIndex, fromSubAccountId, toSubAccountId) {
|
|
874
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getTransferDepositIx(amount, marketIndex, fromSubAccountId, toSubAccountId)), [], this.opts);
|
|
877
|
+
async transferDeposit(amount, marketIndex, fromSubAccountId, toSubAccountId, txParams) {
|
|
878
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getTransferDepositIx(amount, marketIndex, fromSubAccountId, toSubAccountId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
875
879
|
if (fromSubAccountId === this.activeSubAccountId ||
|
|
876
880
|
toSubAccountId === this.activeSubAccountId) {
|
|
877
881
|
this.spotMarketLastSlotCache.set(marketIndex, slot);
|
|
@@ -879,8 +883,8 @@ class DriftClient {
|
|
|
879
883
|
return txSig;
|
|
880
884
|
}
|
|
881
885
|
async getTransferDepositIx(amount, marketIndex, fromSubAccountId, toSubAccountId) {
|
|
882
|
-
const fromUser = await pda_1.getUserAccountPublicKey(this.program.programId, this.wallet.publicKey, fromSubAccountId);
|
|
883
|
-
const toUser = await pda_1.getUserAccountPublicKey(this.program.programId, this.wallet.publicKey, toSubAccountId);
|
|
886
|
+
const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
|
|
887
|
+
const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
|
|
884
888
|
let remainingAccounts;
|
|
885
889
|
if (this.users.has(fromSubAccountId)) {
|
|
886
890
|
remainingAccounts = this.getRemainingAccounts({
|
|
@@ -890,7 +894,7 @@ class DriftClient {
|
|
|
890
894
|
});
|
|
891
895
|
}
|
|
892
896
|
else {
|
|
893
|
-
const userAccountPublicKey = pda_1.getUserAccountPublicKeySync(this.program.programId, this.authority, fromSubAccountId);
|
|
897
|
+
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.authority, fromSubAccountId);
|
|
894
898
|
const fromUserAccount = (await this.program.account.user.fetch(userAccountPublicKey));
|
|
895
899
|
remainingAccounts = this.getRemainingAccounts({
|
|
896
900
|
userAccounts: [fromUserAccount],
|
|
@@ -910,8 +914,8 @@ class DriftClient {
|
|
|
910
914
|
remainingAccounts,
|
|
911
915
|
});
|
|
912
916
|
}
|
|
913
|
-
async updateSpotMarketCumulativeInterest(marketIndex) {
|
|
914
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.updateSpotMarketCumulativeInterestIx(marketIndex)), [], this.opts);
|
|
917
|
+
async updateSpotMarketCumulativeInterest(marketIndex, txParams) {
|
|
918
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.updateSpotMarketCumulativeInterestIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
915
919
|
return txSig;
|
|
916
920
|
}
|
|
917
921
|
async updateSpotMarketCumulativeInterestIx(marketIndex) {
|
|
@@ -924,8 +928,8 @@ class DriftClient {
|
|
|
924
928
|
},
|
|
925
929
|
});
|
|
926
930
|
}
|
|
927
|
-
async settleLP(settleeUserAccountPublicKey, marketIndex) {
|
|
928
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.settleLPIx(settleeUserAccountPublicKey, marketIndex)), [], this.opts);
|
|
931
|
+
async settleLP(settleeUserAccountPublicKey, marketIndex, txParams) {
|
|
932
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.settleLPIx(settleeUserAccountPublicKey, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
929
933
|
return txSig;
|
|
930
934
|
}
|
|
931
935
|
async settleLPIx(settleeUserAccountPublicKey, marketIndex) {
|
|
@@ -942,12 +946,12 @@ class DriftClient {
|
|
|
942
946
|
remainingAccounts: remainingAccounts,
|
|
943
947
|
});
|
|
944
948
|
}
|
|
945
|
-
async removePerpLpShares(marketIndex, sharesToBurn) {
|
|
946
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getRemovePerpLpSharesIx(marketIndex, sharesToBurn)), [], this.opts);
|
|
949
|
+
async removePerpLpShares(marketIndex, sharesToBurn, txParams) {
|
|
950
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getRemovePerpLpSharesIx(marketIndex, sharesToBurn), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
947
951
|
return txSig;
|
|
948
952
|
}
|
|
949
|
-
async removePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn) {
|
|
950
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn)), [], this.opts);
|
|
953
|
+
async removePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn, txParams) {
|
|
954
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
951
955
|
return txSig;
|
|
952
956
|
}
|
|
953
957
|
async getRemovePerpLpSharesInExpiringMarket(marketIndex, userAccountPublicKey, sharesToBurn) {
|
|
@@ -992,8 +996,8 @@ class DriftClient {
|
|
|
992
996
|
remainingAccounts: remainingAccounts,
|
|
993
997
|
});
|
|
994
998
|
}
|
|
995
|
-
async addPerpLpShares(amount, marketIndex) {
|
|
996
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getAddPerpLpSharesIx(amount, marketIndex)), [], this.opts);
|
|
999
|
+
async addPerpLpShares(amount, marketIndex, txParams) {
|
|
1000
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getAddPerpLpSharesIx(amount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
997
1001
|
this.perpMarketLastSlotCache.set(marketIndex, slot);
|
|
998
1002
|
return txSig;
|
|
999
1003
|
}
|
|
@@ -1034,14 +1038,14 @@ class DriftClient {
|
|
|
1034
1038
|
* @param makerInfo
|
|
1035
1039
|
* @returns
|
|
1036
1040
|
*/
|
|
1037
|
-
async sendMarketOrderAndGetSignedFillTx(orderParams, userAccountPublicKey, userAccount, makerInfo) {
|
|
1041
|
+
async sendMarketOrderAndGetSignedFillTx(orderParams, userAccountPublicKey, userAccount, makerInfo, txParams) {
|
|
1038
1042
|
const marketIndex = orderParams.marketIndex;
|
|
1039
1043
|
const orderId = userAccount.nextOrderId;
|
|
1040
|
-
const marketOrderTx = utils_1.wrapInTx(await this.getPlacePerpOrderIx(orderParams));
|
|
1041
|
-
const fillTx = utils_1.wrapInTx(await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
|
|
1044
|
+
const marketOrderTx = (0, utils_1.wrapInTx)(await this.getPlacePerpOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
|
|
1045
|
+
const fillTx = (0, utils_1.wrapInTx)(await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
|
|
1042
1046
|
orderId,
|
|
1043
1047
|
marketIndex,
|
|
1044
|
-
}, makerInfo));
|
|
1048
|
+
}, makerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
|
|
1045
1049
|
// Apply the latest blockhash to the txs so that we can sign before sending them
|
|
1046
1050
|
const currentBlockHash = (await this.connection.getLatestBlockhash('finalized')).blockhash;
|
|
1047
1051
|
marketOrderTx.recentBlockhash = currentBlockHash;
|
|
@@ -1053,8 +1057,8 @@ class DriftClient {
|
|
|
1053
1057
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1054
1058
|
return { txSig, signedFillTx };
|
|
1055
1059
|
}
|
|
1056
|
-
async placePerpOrder(orderParams) {
|
|
1057
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlacePerpOrderIx(orderParams)), [], this.opts);
|
|
1060
|
+
async placePerpOrder(orderParams, txParams) {
|
|
1061
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlacePerpOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1058
1062
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1059
1063
|
return txSig;
|
|
1060
1064
|
}
|
|
@@ -1081,8 +1085,8 @@ class DriftClient {
|
|
|
1081
1085
|
remainingAccounts,
|
|
1082
1086
|
});
|
|
1083
1087
|
}
|
|
1084
|
-
async updateAMMs(marketIndexes) {
|
|
1085
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getUpdateAMMsIx(marketIndexes)), [], this.opts);
|
|
1088
|
+
async updateAMMs(marketIndexes, txParams) {
|
|
1089
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getUpdateAMMsIx(marketIndexes), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1086
1090
|
return txSig;
|
|
1087
1091
|
}
|
|
1088
1092
|
async getUpdateAMMsIx(marketIndexes) {
|
|
@@ -1115,8 +1119,8 @@ class DriftClient {
|
|
|
1115
1119
|
remainingAccounts,
|
|
1116
1120
|
});
|
|
1117
1121
|
}
|
|
1118
|
-
async settleExpiredMarket(marketIndex) {
|
|
1119
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getSettleExpiredMarketIx(marketIndex)), [], this.opts);
|
|
1122
|
+
async settleExpiredMarket(marketIndex, txParams) {
|
|
1123
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getSettleExpiredMarketIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1120
1124
|
return txSig;
|
|
1121
1125
|
}
|
|
1122
1126
|
async getSettleExpiredMarketIx(marketIndex) {
|
|
@@ -1150,9 +1154,9 @@ class DriftClient {
|
|
|
1150
1154
|
remainingAccounts,
|
|
1151
1155
|
});
|
|
1152
1156
|
}
|
|
1153
|
-
async settleExpiredMarketPoolsToRevenuePool(perpMarketIndex) {
|
|
1154
|
-
const perpMarketPublicKey = await pda_1.getPerpMarketPublicKey(this.program.programId, perpMarketIndex);
|
|
1155
|
-
const spotMarketPublicKey = await pda_1.getSpotMarketPublicKey(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
|
|
1157
|
+
async settleExpiredMarketPoolsToRevenuePool(perpMarketIndex, txParams) {
|
|
1158
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1159
|
+
const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX);
|
|
1156
1160
|
const ix = await this.program.instruction.settleExpiredMarketPoolsToRevenuePool({
|
|
1157
1161
|
accounts: {
|
|
1158
1162
|
state: await this.getStatePublicKey(),
|
|
@@ -1161,11 +1165,11 @@ class DriftClient {
|
|
|
1161
1165
|
perpMarket: perpMarketPublicKey,
|
|
1162
1166
|
},
|
|
1163
1167
|
});
|
|
1164
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(ix), [], this.opts);
|
|
1168
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(ix, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1165
1169
|
return txSig;
|
|
1166
1170
|
}
|
|
1167
|
-
async cancelOrder(orderId) {
|
|
1168
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getCancelOrderIx(orderId)), [], this.opts);
|
|
1171
|
+
async cancelOrder(orderId, txParams) {
|
|
1172
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getCancelOrderIx(orderId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1169
1173
|
return txSig;
|
|
1170
1174
|
}
|
|
1171
1175
|
async getCancelOrderIx(orderId) {
|
|
@@ -1183,8 +1187,8 @@ class DriftClient {
|
|
|
1183
1187
|
remainingAccounts,
|
|
1184
1188
|
});
|
|
1185
1189
|
}
|
|
1186
|
-
async cancelOrderByUserId(userOrderId) {
|
|
1187
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getCancelOrderByUserIdIx(userOrderId)), [], this.opts);
|
|
1190
|
+
async cancelOrderByUserId(userOrderId, txParams) {
|
|
1191
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getCancelOrderByUserIdIx(userOrderId), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1188
1192
|
return txSig;
|
|
1189
1193
|
}
|
|
1190
1194
|
async getCancelOrderByUserIdIx(userOrderId) {
|
|
@@ -1205,8 +1209,8 @@ class DriftClient {
|
|
|
1205
1209
|
remainingAccounts,
|
|
1206
1210
|
});
|
|
1207
1211
|
}
|
|
1208
|
-
async cancelOrders(marketType, marketIndex, direction) {
|
|
1209
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getCancelOrdersIx(marketType, marketIndex, direction)), [], this.opts);
|
|
1212
|
+
async cancelOrders(marketType, marketIndex, direction, txParams) {
|
|
1213
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getCancelOrdersIx(marketType, marketIndex, direction), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1210
1214
|
return txSig;
|
|
1211
1215
|
}
|
|
1212
1216
|
async getCancelOrdersIx(marketType, marketIndex, direction) {
|
|
@@ -1214,10 +1218,10 @@ class DriftClient {
|
|
|
1214
1218
|
let readablePerpMarketIndex = undefined;
|
|
1215
1219
|
let readableSpotMarketIndexes = undefined;
|
|
1216
1220
|
if (marketIndex) {
|
|
1217
|
-
if (marketType && types_1.isVariant(marketType, 'perp')) {
|
|
1221
|
+
if (marketType && (0, types_1.isVariant)(marketType, 'perp')) {
|
|
1218
1222
|
readablePerpMarketIndex = marketIndex;
|
|
1219
1223
|
}
|
|
1220
|
-
else if (marketType && types_1.isVariant(marketType, 'spot')) {
|
|
1224
|
+
else if (marketType && (0, types_1.isVariant)(marketType, 'spot')) {
|
|
1221
1225
|
readableSpotMarketIndexes = [marketIndex];
|
|
1222
1226
|
}
|
|
1223
1227
|
}
|
|
@@ -1236,12 +1240,12 @@ class DriftClient {
|
|
|
1236
1240
|
remainingAccounts,
|
|
1237
1241
|
});
|
|
1238
1242
|
}
|
|
1239
|
-
async fillPerpOrder(userAccountPublicKey, user, order, makerInfo, referrerInfo) {
|
|
1240
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getFillPerpOrderIx(userAccountPublicKey, user, order, makerInfo, referrerInfo)), [], this.opts);
|
|
1243
|
+
async fillPerpOrder(userAccountPublicKey, user, order, makerInfo, referrerInfo, txParams) {
|
|
1244
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getFillPerpOrderIx(userAccountPublicKey, user, order, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1241
1245
|
return txSig;
|
|
1242
1246
|
}
|
|
1243
1247
|
async getFillPerpOrderIx(userAccountPublicKey, userAccount, order, makerInfo, referrerInfo) {
|
|
1244
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1248
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1245
1249
|
const fillerPublicKey = await this.getUserAccountPublicKey();
|
|
1246
1250
|
const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
1247
1251
|
const marketIndex = order
|
|
@@ -1293,8 +1297,8 @@ class DriftClient {
|
|
|
1293
1297
|
remainingAccounts,
|
|
1294
1298
|
});
|
|
1295
1299
|
}
|
|
1296
|
-
async placeSpotOrder(orderParams) {
|
|
1297
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceSpotOrderIx(orderParams)), [], this.opts);
|
|
1300
|
+
async placeSpotOrder(orderParams, txParams) {
|
|
1301
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceSpotOrderIx(orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1298
1302
|
this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1299
1303
|
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
1300
1304
|
return txSig;
|
|
@@ -1321,11 +1325,11 @@ class DriftClient {
|
|
|
1321
1325
|
});
|
|
1322
1326
|
}
|
|
1323
1327
|
async fillSpotOrder(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo, txParams) {
|
|
1324
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getFillSpotOrderIx(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1328
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getFillSpotOrderIx(userAccountPublicKey, user, order, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1325
1329
|
return txSig;
|
|
1326
1330
|
}
|
|
1327
1331
|
async getFillSpotOrderIx(userAccountPublicKey, userAccount, order, fulfillmentConfig, makerInfo, referrerInfo) {
|
|
1328
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1332
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1329
1333
|
const fillerPublicKey = await this.getUserAccountPublicKey();
|
|
1330
1334
|
const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
1331
1335
|
const marketIndex = order
|
|
@@ -1447,7 +1451,7 @@ class DriftClient {
|
|
|
1447
1451
|
isSigner: false,
|
|
1448
1452
|
});
|
|
1449
1453
|
remainingAccounts.push({
|
|
1450
|
-
pubkey: pda_1.getSerumSignerPublicKey(fulfillmentConfig.serumProgramId, fulfillmentConfig.serumMarket, fulfillmentConfig.serumSignerNonce),
|
|
1454
|
+
pubkey: (0, pda_1.getSerumSignerPublicKey)(fulfillmentConfig.serumProgramId, fulfillmentConfig.serumMarket, fulfillmentConfig.serumSignerNonce),
|
|
1451
1455
|
isWritable: false,
|
|
1452
1456
|
isSigner: false,
|
|
1453
1457
|
});
|
|
@@ -1477,14 +1481,14 @@ class DriftClient {
|
|
|
1477
1481
|
isSigner: false,
|
|
1478
1482
|
});
|
|
1479
1483
|
}
|
|
1480
|
-
async triggerOrder(userAccountPublicKey, user, order) {
|
|
1481
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getTriggerOrderIx(userAccountPublicKey, user, order)), [], this.opts);
|
|
1484
|
+
async triggerOrder(userAccountPublicKey, user, order, txParams) {
|
|
1485
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getTriggerOrderIx(userAccountPublicKey, user, order), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1482
1486
|
return txSig;
|
|
1483
1487
|
}
|
|
1484
1488
|
async getTriggerOrderIx(userAccountPublicKey, userAccount, order) {
|
|
1485
1489
|
const fillerPublicKey = await this.getUserAccountPublicKey();
|
|
1486
1490
|
let remainingAccountsParams;
|
|
1487
|
-
if (types_1.isVariant(order.marketType, 'perp')) {
|
|
1491
|
+
if ((0, types_1.isVariant)(order.marketType, 'perp')) {
|
|
1488
1492
|
remainingAccountsParams = {
|
|
1489
1493
|
userAccounts: [userAccount],
|
|
1490
1494
|
writablePerpMarketIndexes: [order.marketIndex],
|
|
@@ -1508,8 +1512,8 @@ class DriftClient {
|
|
|
1508
1512
|
remainingAccounts,
|
|
1509
1513
|
});
|
|
1510
1514
|
}
|
|
1511
|
-
async forceCancelOrders(userAccountPublicKey, user) {
|
|
1512
|
-
const { txSig } = await this.txSender.send(utils_1.wrapInTx(await this.getForceCancelOrdersIx(userAccountPublicKey, user)), [], this.opts);
|
|
1515
|
+
async forceCancelOrders(userAccountPublicKey, user, txParams) {
|
|
1516
|
+
const { txSig } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getForceCancelOrdersIx(userAccountPublicKey, user), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1513
1517
|
return txSig;
|
|
1514
1518
|
}
|
|
1515
1519
|
async getForceCancelOrdersIx(userAccountPublicKey, userAccount) {
|
|
@@ -1528,8 +1532,8 @@ class DriftClient {
|
|
|
1528
1532
|
remainingAccounts,
|
|
1529
1533
|
});
|
|
1530
1534
|
}
|
|
1531
|
-
async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo) {
|
|
1532
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo)), [], this.opts);
|
|
1535
|
+
async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, txParams) {
|
|
1536
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1533
1537
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1534
1538
|
return txSig;
|
|
1535
1539
|
}
|
|
@@ -1582,8 +1586,8 @@ class DriftClient {
|
|
|
1582
1586
|
remainingAccounts,
|
|
1583
1587
|
});
|
|
1584
1588
|
}
|
|
1585
|
-
async placeAndMakePerpOrder(orderParams, takerInfo, referrerInfo) {
|
|
1586
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndMakePerpOrderIx(orderParams, takerInfo, referrerInfo)), [], this.opts);
|
|
1589
|
+
async placeAndMakePerpOrder(orderParams, takerInfo, referrerInfo, txParams) {
|
|
1590
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndMakePerpOrderIx(orderParams, takerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1587
1591
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1588
1592
|
return txSig;
|
|
1589
1593
|
}
|
|
@@ -1622,7 +1626,7 @@ class DriftClient {
|
|
|
1622
1626
|
});
|
|
1623
1627
|
}
|
|
1624
1628
|
async placeAndTakeSpotOrder(orderParams, fulfillmentConfig, makerInfo, referrerInfo, txParams) {
|
|
1625
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1629
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndTakeSpotOrderIx(orderParams, fulfillmentConfig, makerInfo, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1626
1630
|
this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1627
1631
|
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
1628
1632
|
return txSig;
|
|
@@ -1680,8 +1684,8 @@ class DriftClient {
|
|
|
1680
1684
|
remainingAccounts,
|
|
1681
1685
|
});
|
|
1682
1686
|
}
|
|
1683
|
-
async placeAndMakeSpotOrder(orderParams, takerInfo, fulfillmentConfig, referrerInfo) {
|
|
1684
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getPlaceAndMakeSpotOrderIx(orderParams, takerInfo, fulfillmentConfig, referrerInfo)), [], this.opts);
|
|
1687
|
+
async placeAndMakeSpotOrder(orderParams, takerInfo, fulfillmentConfig, referrerInfo, txParams) {
|
|
1688
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getPlaceAndMakeSpotOrderIx(orderParams, takerInfo, fulfillmentConfig, referrerInfo), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1685
1689
|
this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1686
1690
|
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
1687
1691
|
return txSig;
|
|
@@ -1737,7 +1741,7 @@ class DriftClient {
|
|
|
1737
1741
|
return await this.placeAndTakePerpOrder({
|
|
1738
1742
|
orderType: types_1.OrderType.MARKET,
|
|
1739
1743
|
marketIndex,
|
|
1740
|
-
direction: position_1.findDirectionToClose(userPosition),
|
|
1744
|
+
direction: (0, position_1.findDirectionToClose)(userPosition),
|
|
1741
1745
|
baseAssetAmount: userPosition.baseAssetAmount.abs(),
|
|
1742
1746
|
reduceOnly: true,
|
|
1743
1747
|
price: limitPrice,
|
|
@@ -1807,7 +1811,7 @@ class DriftClient {
|
|
|
1807
1811
|
if (!openOrder) {
|
|
1808
1812
|
throw new Error(`No open order with user order id ${userOrderId.toString()}`);
|
|
1809
1813
|
}
|
|
1810
|
-
const cancelOrderIx = await this.
|
|
1814
|
+
const cancelOrderIx = await this.getCancelOrderByUserIdIx(userOrderId);
|
|
1811
1815
|
const newOrderParams = {
|
|
1812
1816
|
orderType: openOrder.orderType,
|
|
1813
1817
|
marketType: openOrder.marketType,
|
|
@@ -1853,8 +1857,8 @@ class DriftClient {
|
|
|
1853
1857
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1854
1858
|
return txSig;
|
|
1855
1859
|
}
|
|
1856
|
-
async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex) {
|
|
1857
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex)), [], this.opts);
|
|
1860
|
+
async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex, txParams) {
|
|
1861
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1858
1862
|
return txSig;
|
|
1859
1863
|
}
|
|
1860
1864
|
async settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex) {
|
|
@@ -1873,13 +1877,13 @@ class DriftClient {
|
|
|
1873
1877
|
remainingAccounts: remainingAccounts,
|
|
1874
1878
|
});
|
|
1875
1879
|
}
|
|
1876
|
-
async liquidatePerp(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice) {
|
|
1877
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice)), [], this.opts);
|
|
1880
|
+
async liquidatePerp(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice, txParams) {
|
|
1881
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1878
1882
|
this.perpMarketLastSlotCache.set(marketIndex, slot);
|
|
1879
1883
|
return txSig;
|
|
1880
1884
|
}
|
|
1881
1885
|
async getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice) {
|
|
1882
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1886
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1883
1887
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1884
1888
|
const liquidatorStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
1885
1889
|
const remainingAccounts = this.getRemainingAccounts({
|
|
@@ -1899,14 +1903,14 @@ class DriftClient {
|
|
|
1899
1903
|
remainingAccounts: remainingAccounts,
|
|
1900
1904
|
});
|
|
1901
1905
|
}
|
|
1902
|
-
async liquidateSpot(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1903
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice)), [], this.opts);
|
|
1906
|
+
async liquidateSpot(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams) {
|
|
1907
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1904
1908
|
this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
|
|
1905
1909
|
this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
|
|
1906
1910
|
return txSig;
|
|
1907
1911
|
}
|
|
1908
1912
|
async getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1909
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1913
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1910
1914
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1911
1915
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
1912
1916
|
const remainingAccounts = this.getRemainingAccounts({
|
|
@@ -1926,14 +1930,14 @@ class DriftClient {
|
|
|
1926
1930
|
remainingAccounts: remainingAccounts,
|
|
1927
1931
|
});
|
|
1928
1932
|
}
|
|
1929
|
-
async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1930
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice)), [], this.opts);
|
|
1933
|
+
async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice, txParams) {
|
|
1934
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1931
1935
|
this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
|
|
1932
1936
|
this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
|
|
1933
1937
|
return txSig;
|
|
1934
1938
|
}
|
|
1935
1939
|
async getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1936
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1940
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1937
1941
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1938
1942
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
1939
1943
|
const remainingAccounts = this.getRemainingAccounts({
|
|
@@ -1953,14 +1957,14 @@ class DriftClient {
|
|
|
1953
1957
|
remainingAccounts: remainingAccounts,
|
|
1954
1958
|
});
|
|
1955
1959
|
}
|
|
1956
|
-
async liquidatePerpPnlForDeposit(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice) {
|
|
1957
|
-
const { txSig, slot } = await this.sendTransaction(utils_1.wrapInTx(await this.getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice)), [], this.opts);
|
|
1960
|
+
async liquidatePerpPnlForDeposit(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice, txParams) {
|
|
1961
|
+
const { txSig, slot } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1958
1962
|
this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
|
|
1959
1963
|
this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
|
|
1960
1964
|
return txSig;
|
|
1961
1965
|
}
|
|
1962
1966
|
async getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice) {
|
|
1963
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1967
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1964
1968
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1965
1969
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
1966
1970
|
const remainingAccounts = this.getRemainingAccounts({
|
|
@@ -1980,12 +1984,12 @@ class DriftClient {
|
|
|
1980
1984
|
remainingAccounts: remainingAccounts,
|
|
1981
1985
|
});
|
|
1982
1986
|
}
|
|
1983
|
-
async resolvePerpBankruptcy(userAccountPublicKey, userAccount, marketIndex) {
|
|
1984
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex)), [], this.opts);
|
|
1987
|
+
async resolvePerpBankruptcy(userAccountPublicKey, userAccount, marketIndex, txParams) {
|
|
1988
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
1985
1989
|
return txSig;
|
|
1986
1990
|
}
|
|
1987
1991
|
async getResolvePerpBankruptcyIx(userAccountPublicKey, userAccount, marketIndex) {
|
|
1988
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
1992
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1989
1993
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1990
1994
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
1991
1995
|
const remainingAccounts = this.getRemainingAccounts({
|
|
@@ -2010,12 +2014,12 @@ class DriftClient {
|
|
|
2010
2014
|
remainingAccounts: remainingAccounts,
|
|
2011
2015
|
});
|
|
2012
2016
|
}
|
|
2013
|
-
async resolveSpotBankruptcy(userAccountPublicKey, userAccount, marketIndex) {
|
|
2014
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex)), [], this.opts);
|
|
2017
|
+
async resolveSpotBankruptcy(userAccountPublicKey, userAccount, marketIndex, txParams) {
|
|
2018
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2015
2019
|
return txSig;
|
|
2016
2020
|
}
|
|
2017
2021
|
async getResolveSpotBankruptcyIx(userAccountPublicKey, userAccount, marketIndex) {
|
|
2018
|
-
const userStatsPublicKey = pda_1.getUserStatsAccountPublicKey(this.program.programId, userAccount.authority);
|
|
2022
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
2019
2023
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
2020
2024
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
2021
2025
|
const remainingAccounts = this.getRemainingAccounts({
|
|
@@ -2039,12 +2043,12 @@ class DriftClient {
|
|
|
2039
2043
|
remainingAccounts: remainingAccounts,
|
|
2040
2044
|
});
|
|
2041
2045
|
}
|
|
2042
|
-
async updateFundingRate(perpMarketIndex, oracle) {
|
|
2043
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getUpdateFundingRateIx(perpMarketIndex, oracle)), [], this.opts);
|
|
2046
|
+
async updateFundingRate(perpMarketIndex, oracle, txParams) {
|
|
2047
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getUpdateFundingRateIx(perpMarketIndex, oracle), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2044
2048
|
return txSig;
|
|
2045
2049
|
}
|
|
2046
2050
|
async getUpdateFundingRateIx(perpMarketIndex, oracle) {
|
|
2047
|
-
const perpMarketPublicKey = await pda_1.getPerpMarketPublicKey(this.program.programId, perpMarketIndex);
|
|
2051
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
2048
2052
|
return await this.program.instruction.updateFundingRate(perpMarketIndex, {
|
|
2049
2053
|
accounts: {
|
|
2050
2054
|
state: await this.getStatePublicKey(),
|
|
@@ -2053,15 +2057,15 @@ class DriftClient {
|
|
|
2053
2057
|
},
|
|
2054
2058
|
});
|
|
2055
2059
|
}
|
|
2056
|
-
async settleFundingPayment(userAccountPublicKey) {
|
|
2057
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getSettleFundingPaymentIx(userAccountPublicKey)), [], this.opts);
|
|
2060
|
+
async settleFundingPayment(userAccountPublicKey, txParams) {
|
|
2061
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getSettleFundingPaymentIx(userAccountPublicKey), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2058
2062
|
return txSig;
|
|
2059
2063
|
}
|
|
2060
2064
|
async getSettleFundingPaymentIx(userAccountPublicKey) {
|
|
2061
2065
|
const userAccount = (await this.program.account.user.fetch(userAccountPublicKey));
|
|
2062
2066
|
const writablePerpMarketIndexes = [];
|
|
2063
2067
|
for (const position of userAccount.perpPositions) {
|
|
2064
|
-
if (!position_1.positionIsAvailable(position)) {
|
|
2068
|
+
if (!(0, position_1.positionIsAvailable)(position)) {
|
|
2065
2069
|
writablePerpMarketIndexes.push(position.marketIndex);
|
|
2066
2070
|
}
|
|
2067
2071
|
}
|
|
@@ -2090,12 +2094,12 @@ class DriftClient {
|
|
|
2090
2094
|
const oracleData = this.getOraclePriceDataAndSlot(oracleKey).data;
|
|
2091
2095
|
return oracleData;
|
|
2092
2096
|
}
|
|
2093
|
-
async initializeInsuranceFundStake(marketIndex) {
|
|
2094
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getInitializeInsuranceFundStakeIx(marketIndex)), [], this.opts);
|
|
2097
|
+
async initializeInsuranceFundStake(marketIndex, txParams) {
|
|
2098
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getInitializeInsuranceFundStakeIx(marketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2095
2099
|
return txSig;
|
|
2096
2100
|
}
|
|
2097
2101
|
async getInitializeInsuranceFundStakeIx(marketIndex) {
|
|
2098
|
-
const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2102
|
+
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2099
2103
|
return await this.program.instruction.initializeInsuranceFundStake(marketIndex, {
|
|
2100
2104
|
accounts: {
|
|
2101
2105
|
insuranceFundStake: ifStakeAccountPublicKey,
|
|
@@ -2111,7 +2115,7 @@ class DriftClient {
|
|
|
2111
2115
|
}
|
|
2112
2116
|
async addInsuranceFundStake(marketIndex, amount, collateralAccountPublicKey) {
|
|
2113
2117
|
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
2114
|
-
const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2118
|
+
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2115
2119
|
const remainingAccounts = this.getRemainingAccounts({
|
|
2116
2120
|
userAccounts: [this.getUserAccount()],
|
|
2117
2121
|
useMarketLastSlotCache: true,
|
|
@@ -2137,7 +2141,7 @@ class DriftClient {
|
|
|
2137
2141
|
}
|
|
2138
2142
|
async requestRemoveInsuranceFundStake(marketIndex, amount) {
|
|
2139
2143
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
2140
|
-
const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2144
|
+
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2141
2145
|
const remainingAccounts = this.getRemainingAccounts({
|
|
2142
2146
|
userAccounts: [this.getUserAccount()],
|
|
2143
2147
|
useMarketLastSlotCache: true,
|
|
@@ -2159,7 +2163,7 @@ class DriftClient {
|
|
|
2159
2163
|
}
|
|
2160
2164
|
async cancelRequestRemoveInsuranceFundStake(marketIndex) {
|
|
2161
2165
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
2162
|
-
const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2166
|
+
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2163
2167
|
const remainingAccounts = this.getRemainingAccounts({
|
|
2164
2168
|
userAccounts: [this.getUserAccount()],
|
|
2165
2169
|
useMarketLastSlotCache: true,
|
|
@@ -2181,7 +2185,7 @@ class DriftClient {
|
|
|
2181
2185
|
}
|
|
2182
2186
|
async removeInsuranceFundStake(marketIndex, collateralAccountPublicKey) {
|
|
2183
2187
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
2184
|
-
const ifStakeAccountPublicKey = pda_1.getInsuranceFundStakeAccountPublicKey(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2188
|
+
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, this.wallet.publicKey, marketIndex);
|
|
2185
2189
|
const remainingAccounts = this.getRemainingAccounts({
|
|
2186
2190
|
userAccounts: [this.getUserAccount()],
|
|
2187
2191
|
useMarketLastSlotCache: true,
|
|
@@ -2225,8 +2229,8 @@ class DriftClient {
|
|
|
2225
2229
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2226
2230
|
return txSig;
|
|
2227
2231
|
}
|
|
2228
|
-
async resolvePerpPnlDeficit(spotMarketIndex, perpMarketIndex) {
|
|
2229
|
-
const { txSig } = await this.sendTransaction(utils_1.wrapInTx(await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex)), [], this.opts);
|
|
2232
|
+
async resolvePerpPnlDeficit(spotMarketIndex, perpMarketIndex, txParams) {
|
|
2233
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2230
2234
|
return txSig;
|
|
2231
2235
|
}
|
|
2232
2236
|
async getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex) {
|