@drift-labs/sdk 0.2.0-master.40 → 0.2.0-master.42
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/pollingUserAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingUserAccountSubscriber.js +5 -11
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +5 -11
- package/lib/config.js +1 -1
- package/lib/dlob/DLOB.js +6 -8
- package/lib/driftClient.d.ts +7 -6
- package/lib/driftClient.js +24 -12
- package/lib/events/types.d.ts +3 -1
- package/lib/events/types.js +2 -0
- package/lib/idl/drift.json +164 -28
- package/lib/math/oracles.js +1 -1
- package/lib/math/orders.d.ts +2 -0
- package/lib/math/orders.js +10 -3
- package/lib/types.d.ts +125 -46
- package/lib/types.js +61 -23
- package/lib/user.d.ts +2 -0
- package/lib/user.js +11 -1
- package/package.json +2 -2
- package/src/accounts/pollingUserAccountSubscriber.ts +5 -12
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +5 -11
- package/src/config.ts +1 -1
- package/src/dlob/DLOB.ts +10 -13
- package/src/driftClient.ts +39 -9
- package/src/events/types.ts +6 -0
- package/src/idl/drift.json +164 -28
- package/src/math/oracles.ts +1 -1
- package/src/math/orders.ts +9 -4
- package/src/types.ts +104 -37
- package/src/user.ts +18 -1
- package/tests/dlob/helpers.ts +19 -10
- package/tests/dlob/test.ts +0 -2
|
@@ -20,7 +20,7 @@ export declare class PollingUserAccountSubscriber implements UserAccountSubscrib
|
|
|
20
20
|
addToAccountLoader(): Promise<void>;
|
|
21
21
|
fetchIfUnloaded(): Promise<void>;
|
|
22
22
|
fetch(): Promise<void>;
|
|
23
|
-
|
|
23
|
+
doAccountsExist(): boolean;
|
|
24
24
|
unsubscribe(): Promise<void>;
|
|
25
25
|
assertIsSubscribed(): void;
|
|
26
26
|
getUserAccountAndSlot(): DataAndSlot<UserAccount>;
|
|
@@ -18,18 +18,12 @@ class PollingUserAccountSubscriber {
|
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
await this.addToAccountLoader();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
while (!subscriptionSucceeded && retries < 5) {
|
|
24
|
-
await this.fetchIfUnloaded();
|
|
25
|
-
subscriptionSucceeded = this.didSubscriptionSucceed();
|
|
26
|
-
retries++;
|
|
27
|
-
}
|
|
28
|
-
if (subscriptionSucceeded) {
|
|
21
|
+
await this.fetchIfUnloaded();
|
|
22
|
+
if (this.doAccountsExist()) {
|
|
29
23
|
this.eventEmitter.emit('update');
|
|
30
24
|
}
|
|
31
|
-
this.isSubscribed =
|
|
32
|
-
return
|
|
25
|
+
this.isSubscribed = true;
|
|
26
|
+
return true;
|
|
33
27
|
}
|
|
34
28
|
async addToAccountLoader() {
|
|
35
29
|
if (this.accountsToPoll.size > 0) {
|
|
@@ -78,7 +72,7 @@ class PollingUserAccountSubscriber {
|
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
|
-
|
|
75
|
+
doAccountsExist() {
|
|
82
76
|
let success = true;
|
|
83
77
|
for (const [_, accountToPoll] of this.accountsToPoll) {
|
|
84
78
|
if (!this[accountToPoll.key]) {
|
|
@@ -20,7 +20,7 @@ export declare class PollingUserStatsAccountSubscriber implements UserStatsAccou
|
|
|
20
20
|
addToAccountLoader(): Promise<void>;
|
|
21
21
|
fetchIfUnloaded(): Promise<void>;
|
|
22
22
|
fetch(): Promise<void>;
|
|
23
|
-
|
|
23
|
+
doAccountsExist(): boolean;
|
|
24
24
|
unsubscribe(): Promise<void>;
|
|
25
25
|
assertIsSubscribed(): void;
|
|
26
26
|
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount>;
|
|
@@ -18,18 +18,12 @@ class PollingUserStatsAccountSubscriber {
|
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
await this.addToAccountLoader();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
while (!subscriptionSucceeded && retries < 5) {
|
|
24
|
-
await this.fetchIfUnloaded();
|
|
25
|
-
subscriptionSucceeded = this.didSubscriptionSucceed();
|
|
26
|
-
retries++;
|
|
27
|
-
}
|
|
28
|
-
if (subscriptionSucceeded) {
|
|
21
|
+
await this.fetchIfUnloaded();
|
|
22
|
+
if (this.doAccountsExist()) {
|
|
29
23
|
this.eventEmitter.emit('update');
|
|
30
24
|
}
|
|
31
|
-
this.isSubscribed =
|
|
32
|
-
return
|
|
25
|
+
this.isSubscribed = true;
|
|
26
|
+
return true;
|
|
33
27
|
}
|
|
34
28
|
async addToAccountLoader() {
|
|
35
29
|
if (this.accountsToPoll.size > 0) {
|
|
@@ -78,7 +72,7 @@ class PollingUserStatsAccountSubscriber {
|
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
|
-
|
|
75
|
+
doAccountsExist() {
|
|
82
76
|
let success = true;
|
|
83
77
|
for (const [_, accountToPoll] of this.accountsToPoll) {
|
|
84
78
|
if (!this[accountToPoll.key]) {
|
package/lib/config.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.configs = {
|
|
|
7
7
|
devnet: {
|
|
8
8
|
ENV: 'devnet',
|
|
9
9
|
PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
|
|
10
|
-
CLEARING_HOUSE_PROGRAM_ID: '
|
|
10
|
+
CLEARING_HOUSE_PROGRAM_ID: '4PzAUP84r19y2whicgTysCiqxw5aHabLHyDh3oJiAtqe',
|
|
11
11
|
USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
|
|
12
12
|
SERUM_V3: 'DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY',
|
|
13
13
|
V2_ALPHA_TICKET_MINT_ADDRESS: 'DeEiGWfCMP9psnLGkxGrBBMEAW5Jv8bBGMN8DCtFRCyB',
|
package/lib/dlob/DLOB.js
CHANGED
|
@@ -146,8 +146,7 @@ class DLOB {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
getListForOrder(order) {
|
|
149
|
-
const isInactiveTriggerOrder = (0, __1.
|
|
150
|
-
!order.triggered;
|
|
149
|
+
const isInactiveTriggerOrder = (0, __1.mustBeTriggered)(order) && !(0, __1.isTriggered)(order);
|
|
151
150
|
let type;
|
|
152
151
|
if (isInactiveTriggerOrder) {
|
|
153
152
|
type = 'trigger';
|
|
@@ -391,8 +390,7 @@ class DLOB {
|
|
|
391
390
|
// skip order if user is being liquidated/bankrupt
|
|
392
391
|
if (bestGenerator.next.value.userAccount !== undefined) {
|
|
393
392
|
const user = this.userMap.get(bestGenerator.next.value.userAccount.toString());
|
|
394
|
-
if (
|
|
395
|
-
(user === null || user === void 0 ? void 0 : user.getUserAccount().isBankrupt)) {
|
|
393
|
+
if (user === null || user === void 0 ? void 0 : user.isBeingLiquidated()) {
|
|
396
394
|
bestGenerator.next = bestGenerator.generator.next();
|
|
397
395
|
continue;
|
|
398
396
|
}
|
|
@@ -452,8 +450,7 @@ class DLOB {
|
|
|
452
450
|
// skip order if user is being liquidated/bankrupt
|
|
453
451
|
if (bestGenerator.next.value.userAccount !== undefined) {
|
|
454
452
|
const user = this.userMap.get(bestGenerator.next.value.userAccount.toString());
|
|
455
|
-
if (
|
|
456
|
-
(user === null || user === void 0 ? void 0 : user.getUserAccount().isBankrupt)) {
|
|
453
|
+
if (user === null || user === void 0 ? void 0 : user.isBeingLiquidated()) {
|
|
457
454
|
bestGenerator.next = bestGenerator.generator.next();
|
|
458
455
|
continue;
|
|
459
456
|
}
|
|
@@ -492,8 +489,9 @@ class DLOB {
|
|
|
492
489
|
};
|
|
493
490
|
}
|
|
494
491
|
const { takerNode, makerNode, makerSide } = this.determineMakerAndTaker(askNode, bidNode);
|
|
495
|
-
// If order
|
|
496
|
-
if (
|
|
492
|
+
// If maker is market order and auction is complete, cant be maker
|
|
493
|
+
if ((0, __1.isMarketOrder)(makerNode.order) &&
|
|
494
|
+
(0, __1.isAuctionComplete)(makerNode.order, slot)) {
|
|
497
495
|
return {
|
|
498
496
|
crossingNodes: [],
|
|
499
497
|
exhaustedSide: makerSide,
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ export declare class DriftClient {
|
|
|
84
84
|
updateUserCustomMarginRatio(marginRatio: number, subAccountId?: number): Promise<TransactionSignature>;
|
|
85
85
|
updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
|
|
86
86
|
getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
|
|
87
|
+
getUserAccountsForAuthority(authority: PublicKey): Promise<UserAccount[]>;
|
|
87
88
|
deleteUser(subAccountId?: number): Promise<TransactionSignature>;
|
|
88
89
|
getUser(subAccountId?: number): User;
|
|
89
90
|
getUsers(): User[];
|
|
@@ -203,12 +204,12 @@ export declare class DriftClient {
|
|
|
203
204
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
204
205
|
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN): Promise<TransactionSignature>;
|
|
205
206
|
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
206
|
-
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
|
|
207
|
-
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
|
|
208
|
-
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
|
|
209
|
-
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
|
|
210
|
-
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN): Promise<TransactionSignature>;
|
|
211
|
-
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN): Promise<TransactionInstruction>;
|
|
207
|
+
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN): Promise<TransactionSignature>;
|
|
208
|
+
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
209
|
+
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN): Promise<TransactionSignature>;
|
|
210
|
+
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
211
|
+
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN): Promise<TransactionSignature>;
|
|
212
|
+
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
212
213
|
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionSignature>;
|
|
213
214
|
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
214
215
|
resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionSignature>;
|
package/lib/driftClient.js
CHANGED
|
@@ -353,6 +353,18 @@ class DriftClient {
|
|
|
353
353
|
]);
|
|
354
354
|
return programAccounts.map((programAccount) => programAccount.account);
|
|
355
355
|
}
|
|
356
|
+
async getUserAccountsForAuthority(authority) {
|
|
357
|
+
const programAccounts = await this.program.account.user.all([
|
|
358
|
+
{
|
|
359
|
+
memcmp: {
|
|
360
|
+
offset: 8,
|
|
361
|
+
/** data to match, as base-58 encoded string and limited to less than 129 bytes */
|
|
362
|
+
bytes: bs58_1.default.encode(authority.toBuffer()),
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
]);
|
|
366
|
+
return programAccounts.map((programAccount) => programAccount.account);
|
|
367
|
+
}
|
|
356
368
|
async deleteUser(subAccountId = 0) {
|
|
357
369
|
var _a;
|
|
358
370
|
const userAccountPublicKey = (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
@@ -1752,13 +1764,13 @@ class DriftClient {
|
|
|
1752
1764
|
remainingAccounts: remainingAccounts,
|
|
1753
1765
|
});
|
|
1754
1766
|
}
|
|
1755
|
-
async liquidateSpot(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer) {
|
|
1756
|
-
const { txSig, slot } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer)), [], this.opts);
|
|
1767
|
+
async liquidateSpot(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1768
|
+
const { txSig, slot } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice)), [], this.opts);
|
|
1757
1769
|
this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
|
|
1758
1770
|
this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
|
|
1759
1771
|
return txSig;
|
|
1760
1772
|
}
|
|
1761
|
-
async getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer) {
|
|
1773
|
+
async getLiquidateSpotIx(userAccountPublicKey, userAccount, assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1762
1774
|
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1763
1775
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1764
1776
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
@@ -1767,7 +1779,7 @@ class DriftClient {
|
|
|
1767
1779
|
useMarketLastSlotCache: true,
|
|
1768
1780
|
writableSpotMarketIndexes: [liabilityMarketIndex, assetMarketIndex],
|
|
1769
1781
|
});
|
|
1770
|
-
return await this.program.instruction.liquidateSpot(assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, {
|
|
1782
|
+
return await this.program.instruction.liquidateSpot(assetMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice || null, {
|
|
1771
1783
|
accounts: {
|
|
1772
1784
|
state: await this.getStatePublicKey(),
|
|
1773
1785
|
authority: this.wallet.publicKey,
|
|
@@ -1779,13 +1791,13 @@ class DriftClient {
|
|
|
1779
1791
|
remainingAccounts: remainingAccounts,
|
|
1780
1792
|
});
|
|
1781
1793
|
}
|
|
1782
|
-
async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer) {
|
|
1783
|
-
const { txSig, slot } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer)), [], this.opts);
|
|
1794
|
+
async liquidateBorrowForPerpPnl(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1795
|
+
const { txSig, slot } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice)), [], this.opts);
|
|
1784
1796
|
this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
|
|
1785
1797
|
this.spotMarketLastSlotCache.set(liabilityMarketIndex, slot);
|
|
1786
1798
|
return txSig;
|
|
1787
1799
|
}
|
|
1788
|
-
async getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer) {
|
|
1800
|
+
async getLiquidateBorrowForPerpPnlIx(userAccountPublicKey, userAccount, perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice) {
|
|
1789
1801
|
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1790
1802
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1791
1803
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
@@ -1794,7 +1806,7 @@ class DriftClient {
|
|
|
1794
1806
|
writablePerpMarketIndexes: [perpMarketIndex],
|
|
1795
1807
|
writableSpotMarketIndexes: [liabilityMarketIndex],
|
|
1796
1808
|
});
|
|
1797
|
-
return await this.program.instruction.liquidateBorrowForPerpPnl(perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, {
|
|
1809
|
+
return await this.program.instruction.liquidateBorrowForPerpPnl(perpMarketIndex, liabilityMarketIndex, maxLiabilityTransfer, limitPrice || null, {
|
|
1798
1810
|
accounts: {
|
|
1799
1811
|
state: await this.getStatePublicKey(),
|
|
1800
1812
|
authority: this.wallet.publicKey,
|
|
@@ -1806,13 +1818,13 @@ class DriftClient {
|
|
|
1806
1818
|
remainingAccounts: remainingAccounts,
|
|
1807
1819
|
});
|
|
1808
1820
|
}
|
|
1809
|
-
async liquidatePerpPnlForDeposit(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer) {
|
|
1810
|
-
const { txSig, slot } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer)), [], this.opts);
|
|
1821
|
+
async liquidatePerpPnlForDeposit(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice) {
|
|
1822
|
+
const { txSig, slot } = await this.txSender.send((0, utils_1.wrapInTx)(await this.getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice)), [], this.opts);
|
|
1811
1823
|
this.perpMarketLastSlotCache.set(perpMarketIndex, slot);
|
|
1812
1824
|
this.spotMarketLastSlotCache.set(assetMarketIndex, slot);
|
|
1813
1825
|
return txSig;
|
|
1814
1826
|
}
|
|
1815
|
-
async getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer) {
|
|
1827
|
+
async getLiquidatePerpPnlForDepositIx(userAccountPublicKey, userAccount, perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice) {
|
|
1816
1828
|
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, userAccount.authority);
|
|
1817
1829
|
const liquidatorPublicKey = await this.getUserAccountPublicKey();
|
|
1818
1830
|
const liquidatorStatsPublicKey = await this.getUserStatsAccountPublicKey();
|
|
@@ -1821,7 +1833,7 @@ class DriftClient {
|
|
|
1821
1833
|
writablePerpMarketIndexes: [perpMarketIndex],
|
|
1822
1834
|
writableSpotMarketIndexes: [assetMarketIndex],
|
|
1823
1835
|
});
|
|
1824
|
-
return await this.program.instruction.liquidatePerpPnlForDeposit(perpMarketIndex, assetMarketIndex, maxPnlTransfer, {
|
|
1836
|
+
return await this.program.instruction.liquidatePerpPnlForDeposit(perpMarketIndex, assetMarketIndex, maxPnlTransfer, limitPrice || null, {
|
|
1825
1837
|
accounts: {
|
|
1826
1838
|
state: await this.getStatePublicKey(),
|
|
1827
1839
|
authority: this.wallet.publicKey,
|
package/lib/events/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Commitment, TransactionSignature } from '@solana/web3.js';
|
|
2
|
-
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord } from '../index';
|
|
2
|
+
import { DepositRecord, FundingPaymentRecord, FundingRateRecord, LiquidationRecord, NewUserRecord, OrderActionRecord, OrderRecord, SettlePnlRecord, LPRecord, InsuranceFundRecord, SpotInterestRecord, InsuranceFundStakeRecord, CurveRecord } from '../index';
|
|
3
3
|
export declare type EventSubscriptionOptions = {
|
|
4
4
|
eventTypes?: EventType[];
|
|
5
5
|
maxEventsPerType?: number;
|
|
@@ -33,6 +33,8 @@ export declare type EventMap = {
|
|
|
33
33
|
LPRecord: Event<LPRecord>;
|
|
34
34
|
InsuranceFundRecord: Event<InsuranceFundRecord>;
|
|
35
35
|
SpotInterestRecord: Event<SpotInterestRecord>;
|
|
36
|
+
InsuranceFundStakeRecord: Event<InsuranceFundStakeRecord>;
|
|
37
|
+
CurveRecord: Event<CurveRecord>;
|
|
36
38
|
};
|
|
37
39
|
export declare type EventType = keyof EventMap;
|
|
38
40
|
export interface EventSubscriberEvents {
|