@drift-labs/sdk 2.101.0-beta.1 → 2.101.0-beta.3
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/browser/driftClient.d.ts +3 -1
- package/lib/browser/driftClient.js +16 -3
- package/lib/browser/idl/drift.json +21 -0
- package/lib/node/driftClient.d.ts +3 -1
- package/lib/node/driftClient.js +16 -3
- package/lib/node/idl/drift.json +21 -0
- package/package.json +1 -1
- package/src/driftClient.ts +31 -6
- package/src/idl/drift.json +21 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.101.0-beta.
|
|
1
|
+
2.101.0-beta.3
|
|
@@ -16,6 +16,7 @@ import { OraclePriceData } from './oracles/types';
|
|
|
16
16
|
import { DriftClientConfig } from './driftClientConfig';
|
|
17
17
|
import { User } from './user';
|
|
18
18
|
import { UserSubscriptionConfig } from './userConfig';
|
|
19
|
+
import { DriftEnv } from './config';
|
|
19
20
|
import { UserStats } from './userStats';
|
|
20
21
|
import { JupiterClient, QuoteResponse, Route, SwapMode } from './jupiter/jupiterClient';
|
|
21
22
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
@@ -759,8 +760,9 @@ export declare class DriftClient {
|
|
|
759
760
|
removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
760
761
|
updateUserQuoteAssetInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
761
762
|
getUpdateUserQuoteAssetInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
762
|
-
updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
763
|
+
updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams, env?: DriftEnv): Promise<TransactionSignature>;
|
|
763
764
|
getUpdateUserGovTokenInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
765
|
+
getUpdateUserGovTokenInsuranceStakeDevnetIx(authority: PublicKey, amount?: BN): Promise<TransactionInstruction>;
|
|
764
766
|
settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
765
767
|
getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
766
768
|
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
@@ -3012,7 +3012,7 @@ class DriftClient {
|
|
|
3012
3012
|
let optionalParams = null;
|
|
3013
3013
|
if (auctionDurationPercentage || successCondition) {
|
|
3014
3014
|
optionalParams =
|
|
3015
|
-
((
|
|
3015
|
+
((auctionDurationPercentage !== null && auctionDurationPercentage !== void 0 ? auctionDurationPercentage : 100) << 8) | (successCondition !== null && successCondition !== void 0 ? successCondition : 0);
|
|
3016
3016
|
}
|
|
3017
3017
|
return await this.program.instruction.placeAndTakePerpOrder(orderParams, optionalParams, {
|
|
3018
3018
|
accounts: {
|
|
@@ -4095,8 +4095,11 @@ class DriftClient {
|
|
|
4095
4095
|
});
|
|
4096
4096
|
return ix;
|
|
4097
4097
|
}
|
|
4098
|
-
async updateUserGovTokenInsuranceStake(authority, txParams) {
|
|
4099
|
-
const
|
|
4098
|
+
async updateUserGovTokenInsuranceStake(authority, txParams, env = 'mainnet-beta') {
|
|
4099
|
+
const ix = env == 'mainnet-beta'
|
|
4100
|
+
? await this.getUpdateUserGovTokenInsuranceStakeIx(authority)
|
|
4101
|
+
: await this.getUpdateUserGovTokenInsuranceStakeDevnetIx(authority);
|
|
4102
|
+
const tx = await this.buildTransaction(ix, txParams);
|
|
4100
4103
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4101
4104
|
return txSig;
|
|
4102
4105
|
}
|
|
@@ -4117,6 +4120,16 @@ class DriftClient {
|
|
|
4117
4120
|
});
|
|
4118
4121
|
return ix;
|
|
4119
4122
|
}
|
|
4123
|
+
async getUpdateUserGovTokenInsuranceStakeDevnetIx(authority, amount = new anchor_1.BN(1)) {
|
|
4124
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
|
|
4125
|
+
const ix = this.program.instruction.updateUserGovTokenInsuranceStakeDevnet(amount, {
|
|
4126
|
+
accounts: {
|
|
4127
|
+
userStats: userStatsPublicKey,
|
|
4128
|
+
signer: this.wallet.publicKey,
|
|
4129
|
+
},
|
|
4130
|
+
});
|
|
4131
|
+
return ix;
|
|
4132
|
+
}
|
|
4120
4133
|
async settleRevenueToInsuranceFund(spotMarketIndex, txParams) {
|
|
4121
4134
|
const tx = await this.buildTransaction(await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex), txParams);
|
|
4122
4135
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
@@ -2737,6 +2737,27 @@
|
|
|
2737
2737
|
],
|
|
2738
2738
|
"args": []
|
|
2739
2739
|
},
|
|
2740
|
+
{
|
|
2741
|
+
"name": "updateUserGovTokenInsuranceStakeDevnet",
|
|
2742
|
+
"accounts": [
|
|
2743
|
+
{
|
|
2744
|
+
"name": "userStats",
|
|
2745
|
+
"isMut": true,
|
|
2746
|
+
"isSigner": false
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
"name": "signer",
|
|
2750
|
+
"isMut": false,
|
|
2751
|
+
"isSigner": true
|
|
2752
|
+
}
|
|
2753
|
+
],
|
|
2754
|
+
"args": [
|
|
2755
|
+
{
|
|
2756
|
+
"name": "govStakeAmount",
|
|
2757
|
+
"type": "u64"
|
|
2758
|
+
}
|
|
2759
|
+
]
|
|
2760
|
+
},
|
|
2740
2761
|
{
|
|
2741
2762
|
"name": "initializeInsuranceFundStake",
|
|
2742
2763
|
"accounts": [
|
|
@@ -16,6 +16,7 @@ import { OraclePriceData } from './oracles/types';
|
|
|
16
16
|
import { DriftClientConfig } from './driftClientConfig';
|
|
17
17
|
import { User } from './user';
|
|
18
18
|
import { UserSubscriptionConfig } from './userConfig';
|
|
19
|
+
import { DriftEnv } from './config';
|
|
19
20
|
import { UserStats } from './userStats';
|
|
20
21
|
import { JupiterClient, QuoteResponse, Route, SwapMode } from './jupiter/jupiterClient';
|
|
21
22
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
@@ -759,8 +760,9 @@ export declare class DriftClient {
|
|
|
759
760
|
removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
760
761
|
updateUserQuoteAssetInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
761
762
|
getUpdateUserQuoteAssetInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
762
|
-
updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
763
|
+
updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams, env?: DriftEnv): Promise<TransactionSignature>;
|
|
763
764
|
getUpdateUserGovTokenInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
765
|
+
getUpdateUserGovTokenInsuranceStakeDevnetIx(authority: PublicKey, amount?: BN): Promise<TransactionInstruction>;
|
|
764
766
|
settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
765
767
|
getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
766
768
|
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
package/lib/node/driftClient.js
CHANGED
|
@@ -3012,7 +3012,7 @@ class DriftClient {
|
|
|
3012
3012
|
let optionalParams = null;
|
|
3013
3013
|
if (auctionDurationPercentage || successCondition) {
|
|
3014
3014
|
optionalParams =
|
|
3015
|
-
((
|
|
3015
|
+
((auctionDurationPercentage !== null && auctionDurationPercentage !== void 0 ? auctionDurationPercentage : 100) << 8) | (successCondition !== null && successCondition !== void 0 ? successCondition : 0);
|
|
3016
3016
|
}
|
|
3017
3017
|
return await this.program.instruction.placeAndTakePerpOrder(orderParams, optionalParams, {
|
|
3018
3018
|
accounts: {
|
|
@@ -4095,8 +4095,11 @@ class DriftClient {
|
|
|
4095
4095
|
});
|
|
4096
4096
|
return ix;
|
|
4097
4097
|
}
|
|
4098
|
-
async updateUserGovTokenInsuranceStake(authority, txParams) {
|
|
4099
|
-
const
|
|
4098
|
+
async updateUserGovTokenInsuranceStake(authority, txParams, env = 'mainnet-beta') {
|
|
4099
|
+
const ix = env == 'mainnet-beta'
|
|
4100
|
+
? await this.getUpdateUserGovTokenInsuranceStakeIx(authority)
|
|
4101
|
+
: await this.getUpdateUserGovTokenInsuranceStakeDevnetIx(authority);
|
|
4102
|
+
const tx = await this.buildTransaction(ix, txParams);
|
|
4100
4103
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4101
4104
|
return txSig;
|
|
4102
4105
|
}
|
|
@@ -4117,6 +4120,16 @@ class DriftClient {
|
|
|
4117
4120
|
});
|
|
4118
4121
|
return ix;
|
|
4119
4122
|
}
|
|
4123
|
+
async getUpdateUserGovTokenInsuranceStakeDevnetIx(authority, amount = new anchor_1.BN(1)) {
|
|
4124
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
|
|
4125
|
+
const ix = this.program.instruction.updateUserGovTokenInsuranceStakeDevnet(amount, {
|
|
4126
|
+
accounts: {
|
|
4127
|
+
userStats: userStatsPublicKey,
|
|
4128
|
+
signer: this.wallet.publicKey,
|
|
4129
|
+
},
|
|
4130
|
+
});
|
|
4131
|
+
return ix;
|
|
4132
|
+
}
|
|
4120
4133
|
async settleRevenueToInsuranceFund(spotMarketIndex, txParams) {
|
|
4121
4134
|
const tx = await this.buildTransaction(await this.getSettleRevenueToInsuranceFundIx(spotMarketIndex), txParams);
|
|
4122
4135
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
package/lib/node/idl/drift.json
CHANGED
|
@@ -2737,6 +2737,27 @@
|
|
|
2737
2737
|
],
|
|
2738
2738
|
"args": []
|
|
2739
2739
|
},
|
|
2740
|
+
{
|
|
2741
|
+
"name": "updateUserGovTokenInsuranceStakeDevnet",
|
|
2742
|
+
"accounts": [
|
|
2743
|
+
{
|
|
2744
|
+
"name": "userStats",
|
|
2745
|
+
"isMut": true,
|
|
2746
|
+
"isSigner": false
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
"name": "signer",
|
|
2750
|
+
"isMut": false,
|
|
2751
|
+
"isSigner": true
|
|
2752
|
+
}
|
|
2753
|
+
],
|
|
2754
|
+
"args": [
|
|
2755
|
+
{
|
|
2756
|
+
"name": "govStakeAmount",
|
|
2757
|
+
"type": "u64"
|
|
2758
|
+
}
|
|
2759
|
+
]
|
|
2760
|
+
},
|
|
2740
2761
|
{
|
|
2741
2762
|
"name": "initializeInsuranceFundStake",
|
|
2742
2763
|
"accounts": [
|
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -134,6 +134,7 @@ import {
|
|
|
134
134
|
DEFAULT_CONFIRMATION_OPTS,
|
|
135
135
|
DRIFT_PROGRAM_ID,
|
|
136
136
|
SWIFT_ID,
|
|
137
|
+
DriftEnv,
|
|
137
138
|
} from './config';
|
|
138
139
|
import { WRAPPED_SOL_MINT } from './constants/spotMarkets';
|
|
139
140
|
import { UserStats } from './userStats';
|
|
@@ -5582,7 +5583,7 @@ export class DriftClient {
|
|
|
5582
5583
|
let optionalParams = null;
|
|
5583
5584
|
if (auctionDurationPercentage || successCondition) {
|
|
5584
5585
|
optionalParams =
|
|
5585
|
-
((
|
|
5586
|
+
((auctionDurationPercentage ?? 100) << 8) | (successCondition ?? 0);
|
|
5586
5587
|
}
|
|
5587
5588
|
|
|
5588
5589
|
return await this.program.instruction.placeAndTakePerpOrder(
|
|
@@ -7849,12 +7850,14 @@ export class DriftClient {
|
|
|
7849
7850
|
|
|
7850
7851
|
public async updateUserGovTokenInsuranceStake(
|
|
7851
7852
|
authority: PublicKey,
|
|
7852
|
-
txParams?: TxParams
|
|
7853
|
+
txParams?: TxParams,
|
|
7854
|
+
env: DriftEnv = 'mainnet-beta'
|
|
7853
7855
|
): Promise<TransactionSignature> {
|
|
7854
|
-
const
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7856
|
+
const ix =
|
|
7857
|
+
env == 'mainnet-beta'
|
|
7858
|
+
? await this.getUpdateUserGovTokenInsuranceStakeIx(authority)
|
|
7859
|
+
: await this.getUpdateUserGovTokenInsuranceStakeDevnetIx(authority);
|
|
7860
|
+
const tx = await this.buildTransaction(ix, txParams);
|
|
7858
7861
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
7859
7862
|
return txSig;
|
|
7860
7863
|
}
|
|
@@ -7888,6 +7891,28 @@ export class DriftClient {
|
|
|
7888
7891
|
return ix;
|
|
7889
7892
|
}
|
|
7890
7893
|
|
|
7894
|
+
public async getUpdateUserGovTokenInsuranceStakeDevnetIx(
|
|
7895
|
+
authority: PublicKey,
|
|
7896
|
+
amount: BN = new BN(1)
|
|
7897
|
+
): Promise<TransactionInstruction> {
|
|
7898
|
+
const userStatsPublicKey = getUserStatsAccountPublicKey(
|
|
7899
|
+
this.program.programId,
|
|
7900
|
+
authority
|
|
7901
|
+
);
|
|
7902
|
+
|
|
7903
|
+
const ix = this.program.instruction.updateUserGovTokenInsuranceStakeDevnet(
|
|
7904
|
+
amount,
|
|
7905
|
+
{
|
|
7906
|
+
accounts: {
|
|
7907
|
+
userStats: userStatsPublicKey,
|
|
7908
|
+
signer: this.wallet.publicKey,
|
|
7909
|
+
},
|
|
7910
|
+
}
|
|
7911
|
+
);
|
|
7912
|
+
|
|
7913
|
+
return ix;
|
|
7914
|
+
}
|
|
7915
|
+
|
|
7891
7916
|
public async settleRevenueToInsuranceFund(
|
|
7892
7917
|
spotMarketIndex: number,
|
|
7893
7918
|
txParams?: TxParams
|
package/src/idl/drift.json
CHANGED
|
@@ -2737,6 +2737,27 @@
|
|
|
2737
2737
|
],
|
|
2738
2738
|
"args": []
|
|
2739
2739
|
},
|
|
2740
|
+
{
|
|
2741
|
+
"name": "updateUserGovTokenInsuranceStakeDevnet",
|
|
2742
|
+
"accounts": [
|
|
2743
|
+
{
|
|
2744
|
+
"name": "userStats",
|
|
2745
|
+
"isMut": true,
|
|
2746
|
+
"isSigner": false
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
"name": "signer",
|
|
2750
|
+
"isMut": false,
|
|
2751
|
+
"isSigner": true
|
|
2752
|
+
}
|
|
2753
|
+
],
|
|
2754
|
+
"args": [
|
|
2755
|
+
{
|
|
2756
|
+
"name": "govStakeAmount",
|
|
2757
|
+
"type": "u64"
|
|
2758
|
+
}
|
|
2759
|
+
]
|
|
2760
|
+
},
|
|
2740
2761
|
{
|
|
2741
2762
|
"name": "initializeInsuranceFundStake",
|
|
2742
2763
|
"accounts": [
|