@drift-labs/sdk 2.79.0-beta.2 → 2.80.0-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/adminClient.d.ts +2 -0
- package/lib/adminClient.js +23 -0
- package/lib/idl/drift.json +65 -1
- package/package.json +1 -1
- package/src/adminClient.ts +55 -0
- package/src/idl/drift.json +65 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.80.0-beta.1
|
package/lib/adminClient.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
44
44
|
updatePerpMarketCurveUpdateIntensity(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionSignature>;
|
|
45
45
|
getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionInstruction>;
|
|
46
46
|
updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionSignature>;
|
|
47
|
+
updatePerpMarketAmmSummaryStats(perpMarketIndex: number, updateAmmSummaryStats?: boolean, quoteAssetAmountWithUnsettledLp?: BN, netUnsettledFundingPnl?: BN): Promise<TransactionSignature>;
|
|
48
|
+
getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex: number, updateAmmSummaryStats?: boolean, quoteAssetAmountWithUnsettledLp?: BN, netUnsettledFundingPnl?: BN): Promise<TransactionInstruction>;
|
|
47
49
|
getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionInstruction>;
|
|
48
50
|
updatePerpMarketMarginRatio(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionSignature>;
|
|
49
51
|
getUpdatePerpMarketMarginRatioIx(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionInstruction>;
|
package/lib/adminClient.js
CHANGED
|
@@ -445,6 +445,29 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
445
445
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
446
446
|
return txSig;
|
|
447
447
|
}
|
|
448
|
+
async updatePerpMarketAmmSummaryStats(perpMarketIndex, updateAmmSummaryStats, quoteAssetAmountWithUnsettledLp, netUnsettledFundingPnl) {
|
|
449
|
+
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, quoteAssetAmountWithUnsettledLp, netUnsettledFundingPnl);
|
|
450
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
451
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
452
|
+
return txSig;
|
|
453
|
+
}
|
|
454
|
+
async getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, quoteAssetAmountWithUnsettledLp, netUnsettledFundingPnl) {
|
|
455
|
+
return await this.program.instruction.updatePerpMarketAmmSummaryStats({
|
|
456
|
+
updateAmmSummaryStats: updateAmmSummaryStats !== null && updateAmmSummaryStats !== void 0 ? updateAmmSummaryStats : null,
|
|
457
|
+
quoteAssetAmountWithUnsettledLp: quoteAssetAmountWithUnsettledLp !== null && quoteAssetAmountWithUnsettledLp !== void 0 ? quoteAssetAmountWithUnsettledLp : null,
|
|
458
|
+
netUnsettledFundingPnl: netUnsettledFundingPnl !== null && netUnsettledFundingPnl !== void 0 ? netUnsettledFundingPnl : null,
|
|
459
|
+
}, {
|
|
460
|
+
accounts: {
|
|
461
|
+
admin: this.isSubscribed
|
|
462
|
+
? this.getStateAccount().admin
|
|
463
|
+
: this.wallet.publicKey,
|
|
464
|
+
state: await this.getStatePublicKey(),
|
|
465
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
466
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
|
|
467
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
}
|
|
448
471
|
async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
449
472
|
return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp(targetBaseAssetAmountPerLP, {
|
|
450
473
|
accounts: {
|
package/lib/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.79.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -3182,6 +3182,44 @@
|
|
|
3182
3182
|
}
|
|
3183
3183
|
]
|
|
3184
3184
|
},
|
|
3185
|
+
{
|
|
3186
|
+
"name": "updatePerpMarketAmmSummaryStats",
|
|
3187
|
+
"accounts": [
|
|
3188
|
+
{
|
|
3189
|
+
"name": "admin",
|
|
3190
|
+
"isMut": false,
|
|
3191
|
+
"isSigner": true
|
|
3192
|
+
},
|
|
3193
|
+
{
|
|
3194
|
+
"name": "state",
|
|
3195
|
+
"isMut": false,
|
|
3196
|
+
"isSigner": false
|
|
3197
|
+
},
|
|
3198
|
+
{
|
|
3199
|
+
"name": "perpMarket",
|
|
3200
|
+
"isMut": true,
|
|
3201
|
+
"isSigner": false
|
|
3202
|
+
},
|
|
3203
|
+
{
|
|
3204
|
+
"name": "spotMarket",
|
|
3205
|
+
"isMut": false,
|
|
3206
|
+
"isSigner": false
|
|
3207
|
+
},
|
|
3208
|
+
{
|
|
3209
|
+
"name": "oracle",
|
|
3210
|
+
"isMut": false,
|
|
3211
|
+
"isSigner": false
|
|
3212
|
+
}
|
|
3213
|
+
],
|
|
3214
|
+
"args": [
|
|
3215
|
+
{
|
|
3216
|
+
"name": "params",
|
|
3217
|
+
"type": {
|
|
3218
|
+
"defined": "UpdatePerpMarketSummaryStatsParams"
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
]
|
|
3222
|
+
},
|
|
3185
3223
|
{
|
|
3186
3224
|
"name": "updatePerpMarketExpiry",
|
|
3187
3225
|
"accounts": [
|
|
@@ -6659,6 +6697,32 @@
|
|
|
6659
6697
|
}
|
|
6660
6698
|
],
|
|
6661
6699
|
"types": [
|
|
6700
|
+
{
|
|
6701
|
+
"name": "UpdatePerpMarketSummaryStatsParams",
|
|
6702
|
+
"type": {
|
|
6703
|
+
"kind": "struct",
|
|
6704
|
+
"fields": [
|
|
6705
|
+
{
|
|
6706
|
+
"name": "quoteAssetAmountWithUnsettledLp",
|
|
6707
|
+
"type": {
|
|
6708
|
+
"option": "i64"
|
|
6709
|
+
}
|
|
6710
|
+
},
|
|
6711
|
+
{
|
|
6712
|
+
"name": "netUnsettledFundingPnl",
|
|
6713
|
+
"type": {
|
|
6714
|
+
"option": "i64"
|
|
6715
|
+
}
|
|
6716
|
+
},
|
|
6717
|
+
{
|
|
6718
|
+
"name": "updateAmmSummaryStats",
|
|
6719
|
+
"type": {
|
|
6720
|
+
"option": "bool"
|
|
6721
|
+
}
|
|
6722
|
+
}
|
|
6723
|
+
]
|
|
6724
|
+
}
|
|
6725
|
+
},
|
|
6662
6726
|
{
|
|
6663
6727
|
"name": "LiquidatePerpRecord",
|
|
6664
6728
|
"type": {
|
package/package.json
CHANGED
package/src/adminClient.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
|
34
34
|
import { DriftClient } from './driftClient';
|
|
35
35
|
import {
|
|
36
36
|
PEG_PRECISION,
|
|
37
|
+
QUOTE_SPOT_MARKET_INDEX,
|
|
37
38
|
ZERO,
|
|
38
39
|
ONE,
|
|
39
40
|
BASE_PRECISION,
|
|
@@ -1020,6 +1021,60 @@ export class AdminClient extends DriftClient {
|
|
|
1020
1021
|
return txSig;
|
|
1021
1022
|
}
|
|
1022
1023
|
|
|
1024
|
+
public async updatePerpMarketAmmSummaryStats(
|
|
1025
|
+
perpMarketIndex: number,
|
|
1026
|
+
updateAmmSummaryStats?: boolean,
|
|
1027
|
+
quoteAssetAmountWithUnsettledLp?: BN,
|
|
1028
|
+
netUnsettledFundingPnl?: BN
|
|
1029
|
+
): Promise<TransactionSignature> {
|
|
1030
|
+
const updatePerpMarketMarginRatioIx =
|
|
1031
|
+
await this.getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1032
|
+
perpMarketIndex,
|
|
1033
|
+
updateAmmSummaryStats,
|
|
1034
|
+
quoteAssetAmountWithUnsettledLp,
|
|
1035
|
+
netUnsettledFundingPnl
|
|
1036
|
+
);
|
|
1037
|
+
|
|
1038
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
1039
|
+
|
|
1040
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1041
|
+
|
|
1042
|
+
return txSig;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
public async getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1046
|
+
perpMarketIndex: number,
|
|
1047
|
+
updateAmmSummaryStats?: boolean,
|
|
1048
|
+
quoteAssetAmountWithUnsettledLp?: BN,
|
|
1049
|
+
netUnsettledFundingPnl?: BN
|
|
1050
|
+
): Promise<TransactionInstruction> {
|
|
1051
|
+
return await this.program.instruction.updatePerpMarketAmmSummaryStats(
|
|
1052
|
+
{
|
|
1053
|
+
updateAmmSummaryStats: updateAmmSummaryStats ?? null,
|
|
1054
|
+
quoteAssetAmountWithUnsettledLp:
|
|
1055
|
+
quoteAssetAmountWithUnsettledLp ?? null,
|
|
1056
|
+
netUnsettledFundingPnl: netUnsettledFundingPnl ?? null,
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
accounts: {
|
|
1060
|
+
admin: this.isSubscribed
|
|
1061
|
+
? this.getStateAccount().admin
|
|
1062
|
+
: this.wallet.publicKey,
|
|
1063
|
+
state: await this.getStatePublicKey(),
|
|
1064
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1065
|
+
this.program.programId,
|
|
1066
|
+
perpMarketIndex
|
|
1067
|
+
),
|
|
1068
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1069
|
+
this.program.programId,
|
|
1070
|
+
QUOTE_SPOT_MARKET_INDEX
|
|
1071
|
+
),
|
|
1072
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
1073
|
+
},
|
|
1074
|
+
}
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1023
1078
|
public async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
1024
1079
|
perpMarketIndex: number,
|
|
1025
1080
|
targetBaseAssetAmountPerLP: number
|
package/src/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.79.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -3182,6 +3182,44 @@
|
|
|
3182
3182
|
}
|
|
3183
3183
|
]
|
|
3184
3184
|
},
|
|
3185
|
+
{
|
|
3186
|
+
"name": "updatePerpMarketAmmSummaryStats",
|
|
3187
|
+
"accounts": [
|
|
3188
|
+
{
|
|
3189
|
+
"name": "admin",
|
|
3190
|
+
"isMut": false,
|
|
3191
|
+
"isSigner": true
|
|
3192
|
+
},
|
|
3193
|
+
{
|
|
3194
|
+
"name": "state",
|
|
3195
|
+
"isMut": false,
|
|
3196
|
+
"isSigner": false
|
|
3197
|
+
},
|
|
3198
|
+
{
|
|
3199
|
+
"name": "perpMarket",
|
|
3200
|
+
"isMut": true,
|
|
3201
|
+
"isSigner": false
|
|
3202
|
+
},
|
|
3203
|
+
{
|
|
3204
|
+
"name": "spotMarket",
|
|
3205
|
+
"isMut": false,
|
|
3206
|
+
"isSigner": false
|
|
3207
|
+
},
|
|
3208
|
+
{
|
|
3209
|
+
"name": "oracle",
|
|
3210
|
+
"isMut": false,
|
|
3211
|
+
"isSigner": false
|
|
3212
|
+
}
|
|
3213
|
+
],
|
|
3214
|
+
"args": [
|
|
3215
|
+
{
|
|
3216
|
+
"name": "params",
|
|
3217
|
+
"type": {
|
|
3218
|
+
"defined": "UpdatePerpMarketSummaryStatsParams"
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
]
|
|
3222
|
+
},
|
|
3185
3223
|
{
|
|
3186
3224
|
"name": "updatePerpMarketExpiry",
|
|
3187
3225
|
"accounts": [
|
|
@@ -6659,6 +6697,32 @@
|
|
|
6659
6697
|
}
|
|
6660
6698
|
],
|
|
6661
6699
|
"types": [
|
|
6700
|
+
{
|
|
6701
|
+
"name": "UpdatePerpMarketSummaryStatsParams",
|
|
6702
|
+
"type": {
|
|
6703
|
+
"kind": "struct",
|
|
6704
|
+
"fields": [
|
|
6705
|
+
{
|
|
6706
|
+
"name": "quoteAssetAmountWithUnsettledLp",
|
|
6707
|
+
"type": {
|
|
6708
|
+
"option": "i64"
|
|
6709
|
+
}
|
|
6710
|
+
},
|
|
6711
|
+
{
|
|
6712
|
+
"name": "netUnsettledFundingPnl",
|
|
6713
|
+
"type": {
|
|
6714
|
+
"option": "i64"
|
|
6715
|
+
}
|
|
6716
|
+
},
|
|
6717
|
+
{
|
|
6718
|
+
"name": "updateAmmSummaryStats",
|
|
6719
|
+
"type": {
|
|
6720
|
+
"option": "bool"
|
|
6721
|
+
}
|
|
6722
|
+
}
|
|
6723
|
+
]
|
|
6724
|
+
}
|
|
6725
|
+
},
|
|
6662
6726
|
{
|
|
6663
6727
|
"name": "LiquidatePerpRecord",
|
|
6664
6728
|
"type": {
|