@drift-labs/sdk 2.31.1-beta.0 → 2.31.1-beta.1
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/VERSION +1 -1
- package/lib/driftClient.d.ts +4 -0
- package/lib/driftClient.js +10 -6
- package/lib/idl/drift.json +1 -1
- package/package.json +1 -1
- package/src/driftClient.ts +21 -10
- package/src/idl/drift.json +1 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.31.1-beta.
|
|
1
|
+
2.31.1-beta.1
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -472,6 +472,10 @@ export declare class DriftClient {
|
|
|
472
472
|
settleeUserAccountPublicKey: PublicKey;
|
|
473
473
|
settleeUserAccount: UserAccount;
|
|
474
474
|
}[], marketIndexes: number[]): Promise<TransactionSignature>;
|
|
475
|
+
getSettlePNLsIxs(users: {
|
|
476
|
+
settleeUserAccountPublicKey: PublicKey;
|
|
477
|
+
settleeUserAccount: UserAccount;
|
|
478
|
+
}[], marketIndexes: number[]): Promise<Array<TransactionInstruction>>;
|
|
475
479
|
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
476
480
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
477
481
|
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
package/lib/driftClient.js
CHANGED
|
@@ -2527,12 +2527,7 @@ class DriftClient {
|
|
|
2527
2527
|
});
|
|
2528
2528
|
}
|
|
2529
2529
|
async settlePNLs(users, marketIndexes) {
|
|
2530
|
-
const ixs =
|
|
2531
|
-
for (const { settleeUserAccountPublicKey, settleeUserAccount } of users) {
|
|
2532
|
-
for (const marketIndex of marketIndexes) {
|
|
2533
|
-
ixs.push(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex));
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2530
|
+
const ixs = await this.getSettlePNLsIxs(users, marketIndexes);
|
|
2536
2531
|
const tx = new web3_js_1.Transaction()
|
|
2537
2532
|
.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
2538
2533
|
units: 1000000,
|
|
@@ -2541,6 +2536,15 @@ class DriftClient {
|
|
|
2541
2536
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2542
2537
|
return txSig;
|
|
2543
2538
|
}
|
|
2539
|
+
async getSettlePNLsIxs(users, marketIndexes) {
|
|
2540
|
+
const ixs = [];
|
|
2541
|
+
for (const { settleeUserAccountPublicKey, settleeUserAccount } of users) {
|
|
2542
|
+
for (const marketIndex of marketIndexes) {
|
|
2543
|
+
ixs.push(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex));
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
return ixs;
|
|
2547
|
+
}
|
|
2544
2548
|
async settlePNL(settleeUserAccountPublicKey, settleeUserAccount, marketIndex, txParams) {
|
|
2545
2549
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex), txParams), [], this.opts);
|
|
2546
2550
|
return txSig;
|
package/lib/idl/drift.json
CHANGED
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -4309,6 +4309,26 @@ export class DriftClient {
|
|
|
4309
4309
|
}[],
|
|
4310
4310
|
marketIndexes: number[]
|
|
4311
4311
|
): Promise<TransactionSignature> {
|
|
4312
|
+
const ixs = await this.getSettlePNLsIxs(users, marketIndexes);
|
|
4313
|
+
const tx = new Transaction()
|
|
4314
|
+
.add(
|
|
4315
|
+
ComputeBudgetProgram.setComputeUnitLimit({
|
|
4316
|
+
units: 1_000_000,
|
|
4317
|
+
})
|
|
4318
|
+
)
|
|
4319
|
+
.add(...ixs);
|
|
4320
|
+
|
|
4321
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4322
|
+
return txSig;
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4325
|
+
public async getSettlePNLsIxs(
|
|
4326
|
+
users: {
|
|
4327
|
+
settleeUserAccountPublicKey: PublicKey;
|
|
4328
|
+
settleeUserAccount: UserAccount;
|
|
4329
|
+
}[],
|
|
4330
|
+
marketIndexes: number[]
|
|
4331
|
+
): Promise<Array<TransactionInstruction>> {
|
|
4312
4332
|
const ixs = [];
|
|
4313
4333
|
for (const { settleeUserAccountPublicKey, settleeUserAccount } of users) {
|
|
4314
4334
|
for (const marketIndex of marketIndexes) {
|
|
@@ -4322,16 +4342,7 @@ export class DriftClient {
|
|
|
4322
4342
|
}
|
|
4323
4343
|
}
|
|
4324
4344
|
|
|
4325
|
-
|
|
4326
|
-
.add(
|
|
4327
|
-
ComputeBudgetProgram.setComputeUnitLimit({
|
|
4328
|
-
units: 1_000_000,
|
|
4329
|
-
})
|
|
4330
|
-
)
|
|
4331
|
-
.add(...ixs);
|
|
4332
|
-
|
|
4333
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4334
|
-
return txSig;
|
|
4345
|
+
return ixs;
|
|
4335
4346
|
}
|
|
4336
4347
|
|
|
4337
4348
|
public async settlePNL(
|
package/src/idl/drift.json
CHANGED