@drift-labs/sdk 2.82.0-beta.1 → 2.82.0-beta.2
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 +2 -1
- package/lib/driftClient.js +11 -8
- package/package.json +1 -1
- package/src/blockhashSubscriber/types.ts +4 -0
- package/src/driftClient.ts +22 -11
- package/tests/dlob/helpers.ts +4 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.82.0-beta.
|
|
1
|
+
2.82.0-beta.2
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -650,7 +650,8 @@ export declare class DriftClient {
|
|
|
650
650
|
requestRemoveInsuranceFundStake(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
651
651
|
cancelRequestRemoveInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
652
652
|
removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
653
|
-
settleRevenueToInsuranceFund(
|
|
653
|
+
settleRevenueToInsuranceFund(spotMarketIndex: number, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
654
|
+
getSettleRevenueToInsuranceFundIx(spotMarketIndex: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
654
655
|
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
655
656
|
getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
656
657
|
getDepositIntoSpotMarketRevenuePoolIx(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
package/lib/driftClient.js
CHANGED
|
@@ -3465,14 +3465,19 @@ class DriftClient {
|
|
|
3465
3465
|
const { txSig } = await this.sendTransaction(tx, additionalSigners, this.opts);
|
|
3466
3466
|
return txSig;
|
|
3467
3467
|
}
|
|
3468
|
-
async settleRevenueToInsuranceFund(
|
|
3469
|
-
const
|
|
3468
|
+
async settleRevenueToInsuranceFund(spotMarketIndex, subAccountId, txParams) {
|
|
3469
|
+
const tx = await this.buildTransaction(await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex, subAccountId), txParams);
|
|
3470
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3471
|
+
return txSig;
|
|
3472
|
+
}
|
|
3473
|
+
async getSettleRevenueToInsuranceFundIx(spotMarketIndex, subAccountId) {
|
|
3474
|
+
const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
|
|
3470
3475
|
const remainingAccounts = this.getRemainingAccounts({
|
|
3471
|
-
userAccounts: [this.getUserAccount()],
|
|
3476
|
+
userAccounts: [this.getUserAccount(subAccountId)],
|
|
3472
3477
|
useMarketLastSlotCache: true,
|
|
3473
|
-
writableSpotMarketIndexes: [
|
|
3478
|
+
writableSpotMarketIndexes: [spotMarketIndex],
|
|
3474
3479
|
});
|
|
3475
|
-
const ix = await this.program.instruction.settleRevenueToInsuranceFund(
|
|
3480
|
+
const ix = await this.program.instruction.settleRevenueToInsuranceFund(spotMarketIndex, {
|
|
3476
3481
|
accounts: {
|
|
3477
3482
|
state: await this.getStatePublicKey(),
|
|
3478
3483
|
spotMarket: spotMarketAccount.pubkey,
|
|
@@ -3483,9 +3488,7 @@ class DriftClient {
|
|
|
3483
3488
|
},
|
|
3484
3489
|
remainingAccounts,
|
|
3485
3490
|
});
|
|
3486
|
-
|
|
3487
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3488
|
-
return txSig;
|
|
3491
|
+
return ix;
|
|
3489
3492
|
}
|
|
3490
3493
|
async resolvePerpPnlDeficit(spotMarketIndex, perpMarketIndex, txParams) {
|
|
3491
3494
|
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex), txParams), [], this.opts);
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Commitment, Connection } from '@solana/web3.js';
|
|
2
2
|
|
|
3
3
|
export type BlockhashSubscriberConfig = {
|
|
4
|
+
/// rpcUrl to poll block hashes from, one of rpcUrl or Connection must provided
|
|
4
5
|
rpcUrl?: string;
|
|
6
|
+
/// connection to poll block hashes from, one of rpcUrl or Connection must provided
|
|
5
7
|
connection?: Connection;
|
|
8
|
+
/// commitment to poll block hashes with, default is 'confirmed'
|
|
6
9
|
commitment?: Commitment;
|
|
10
|
+
/// interval to poll block hashes, default is 1000 ms
|
|
7
11
|
updateIntervalMs?: number;
|
|
8
12
|
};
|
package/src/driftClient.ts
CHANGED
|
@@ -6488,18 +6488,33 @@ export class DriftClient {
|
|
|
6488
6488
|
}
|
|
6489
6489
|
|
|
6490
6490
|
public async settleRevenueToInsuranceFund(
|
|
6491
|
-
|
|
6491
|
+
spotMarketIndex: number,
|
|
6492
|
+
subAccountId?: number,
|
|
6493
|
+
txParams?: TxParams
|
|
6492
6494
|
): Promise<TransactionSignature> {
|
|
6493
|
-
const
|
|
6495
|
+
const tx = await this.buildTransaction(
|
|
6496
|
+
await this.getSettleRevenueToInsuranceFundIx(
|
|
6497
|
+
spotMarketIndex,
|
|
6498
|
+
subAccountId
|
|
6499
|
+
),
|
|
6500
|
+
txParams
|
|
6501
|
+
);
|
|
6502
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
6503
|
+
return txSig;
|
|
6504
|
+
}
|
|
6494
6505
|
|
|
6506
|
+
public async getSettleRevenueToInsuranceFundIx(
|
|
6507
|
+
spotMarketIndex: number,
|
|
6508
|
+
subAccountId?: number
|
|
6509
|
+
): Promise<TransactionInstruction> {
|
|
6510
|
+
const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
|
|
6495
6511
|
const remainingAccounts = this.getRemainingAccounts({
|
|
6496
|
-
userAccounts: [this.getUserAccount()],
|
|
6512
|
+
userAccounts: [this.getUserAccount(subAccountId)],
|
|
6497
6513
|
useMarketLastSlotCache: true,
|
|
6498
|
-
writableSpotMarketIndexes: [
|
|
6514
|
+
writableSpotMarketIndexes: [spotMarketIndex],
|
|
6499
6515
|
});
|
|
6500
|
-
|
|
6501
6516
|
const ix = await this.program.instruction.settleRevenueToInsuranceFund(
|
|
6502
|
-
|
|
6517
|
+
spotMarketIndex,
|
|
6503
6518
|
{
|
|
6504
6519
|
accounts: {
|
|
6505
6520
|
state: await this.getStatePublicKey(),
|
|
@@ -6512,11 +6527,7 @@ export class DriftClient {
|
|
|
6512
6527
|
remainingAccounts,
|
|
6513
6528
|
}
|
|
6514
6529
|
);
|
|
6515
|
-
|
|
6516
|
-
const tx = await this.buildTransaction(ix);
|
|
6517
|
-
|
|
6518
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
6519
|
-
return txSig;
|
|
6530
|
+
return ix;
|
|
6520
6531
|
}
|
|
6521
6532
|
|
|
6522
6533
|
public async resolvePerpPnlDeficit(
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -142,6 +142,10 @@ export const mockAMM: AMM = {
|
|
|
142
142
|
bidQuoteAssetReserve: new BN(0),
|
|
143
143
|
askBaseAssetReserve: new BN(0),
|
|
144
144
|
askQuoteAssetReserve: new BN(0),
|
|
145
|
+
|
|
146
|
+
netUnsettledFundingPnl: new BN(0),
|
|
147
|
+
quoteAssetAmountWithUnsettledLp: new BN(0),
|
|
148
|
+
referencePriceOffset: 0,
|
|
145
149
|
};
|
|
146
150
|
|
|
147
151
|
export const mockPerpMarkets: Array<PerpMarketAccount> = [
|