@drift-labs/sdk-browser 2.160.0-beta.3 → 2.161.0-beta.0
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/bun.lock +1 -0
- package/lib/browser/adminClient.d.ts +2 -0
- package/lib/browser/adminClient.js +17 -0
- package/lib/browser/idl/drift.json +164 -118
- package/lib/browser/math/exchangeStatus.d.ts +3 -1
- package/lib/browser/math/exchangeStatus.js +9 -1
- package/lib/browser/types.d.ts +4 -0
- package/lib/browser/types.js +6 -2
- package/lib/node/adminClient.d.ts +2 -0
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +17 -0
- package/lib/node/idl/drift.json +164 -118
- package/lib/node/math/exchangeStatus.d.ts +3 -1
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +9 -1
- package/lib/node/types.d.ts +4 -0
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +6 -2
- package/package.json +1 -1
- package/src/adminClient.ts +28 -0
- package/src/idl/drift.json +164 -118
- package/src/math/exchangeStatus.ts +15 -0
- package/src/types.ts +5 -0
- package/tests/dlob/helpers.ts +3 -0
package/src/adminClient.ts
CHANGED
|
@@ -6605,4 +6605,32 @@ export class AdminClient extends DriftClient {
|
|
|
6605
6605
|
ixs.push(mintToInstruction);
|
|
6606
6606
|
return ixs;
|
|
6607
6607
|
}
|
|
6608
|
+
|
|
6609
|
+
public async updatePerpMarketConfig(
|
|
6610
|
+
marketIndex: number,
|
|
6611
|
+
marketConfig: number
|
|
6612
|
+
) {
|
|
6613
|
+
const ix = await this.getUpdatePerpMarketConfigIx(
|
|
6614
|
+
marketIndex,
|
|
6615
|
+
marketConfig
|
|
6616
|
+
);
|
|
6617
|
+
const tx = await this.buildTransaction(ix);
|
|
6618
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
6619
|
+
return txSig;
|
|
6620
|
+
}
|
|
6621
|
+
|
|
6622
|
+
public async getUpdatePerpMarketConfigIx(
|
|
6623
|
+
marketIndex: number,
|
|
6624
|
+
marketConfig: number
|
|
6625
|
+
): Promise<TransactionInstruction> {
|
|
6626
|
+
return this.program.instruction.updatePerpMarketConfig(marketConfig, {
|
|
6627
|
+
accounts: {
|
|
6628
|
+
admin: this.useHotWalletAdmin
|
|
6629
|
+
? this.wallet.publicKey
|
|
6630
|
+
: this.getStateAccount().admin,
|
|
6631
|
+
state: await this.getStatePublicKey(),
|
|
6632
|
+
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
6633
|
+
},
|
|
6634
|
+
});
|
|
6635
|
+
}
|
|
6608
6636
|
}
|
package/src/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.160.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -9378,6 +9378,32 @@
|
|
|
9378
9378
|
}
|
|
9379
9379
|
],
|
|
9380
9380
|
"args": []
|
|
9381
|
+
},
|
|
9382
|
+
{
|
|
9383
|
+
"name": "updatePerpMarketConfig",
|
|
9384
|
+
"accounts": [
|
|
9385
|
+
{
|
|
9386
|
+
"name": "admin",
|
|
9387
|
+
"isMut": false,
|
|
9388
|
+
"isSigner": true
|
|
9389
|
+
},
|
|
9390
|
+
{
|
|
9391
|
+
"name": "state",
|
|
9392
|
+
"isMut": false,
|
|
9393
|
+
"isSigner": false
|
|
9394
|
+
},
|
|
9395
|
+
{
|
|
9396
|
+
"name": "perpMarket",
|
|
9397
|
+
"isMut": true,
|
|
9398
|
+
"isSigner": false
|
|
9399
|
+
}
|
|
9400
|
+
],
|
|
9401
|
+
"args": [
|
|
9402
|
+
{
|
|
9403
|
+
"name": "marketConfig",
|
|
9404
|
+
"type": "u8"
|
|
9405
|
+
}
|
|
9406
|
+
]
|
|
9381
9407
|
}
|
|
9382
9408
|
],
|
|
9383
9409
|
"accounts": [
|
|
@@ -10635,12 +10661,16 @@
|
|
|
10635
10661
|
"name": "lpPoolId",
|
|
10636
10662
|
"type": "u8"
|
|
10637
10663
|
},
|
|
10664
|
+
{
|
|
10665
|
+
"name": "marketConfig",
|
|
10666
|
+
"type": "u8"
|
|
10667
|
+
},
|
|
10638
10668
|
{
|
|
10639
10669
|
"name": "padding",
|
|
10640
10670
|
"type": {
|
|
10641
10671
|
"array": [
|
|
10642
10672
|
"u8",
|
|
10643
|
-
|
|
10673
|
+
22
|
|
10644
10674
|
]
|
|
10645
10675
|
}
|
|
10646
10676
|
}
|
|
@@ -13338,102 +13368,6 @@
|
|
|
13338
13368
|
]
|
|
13339
13369
|
}
|
|
13340
13370
|
},
|
|
13341
|
-
{
|
|
13342
|
-
"name": "ScaleOrderParams",
|
|
13343
|
-
"docs": [
|
|
13344
|
-
"Parameters for placing scale orders - multiple limit orders distributed across a price range"
|
|
13345
|
-
],
|
|
13346
|
-
"type": {
|
|
13347
|
-
"kind": "struct",
|
|
13348
|
-
"fields": [
|
|
13349
|
-
{
|
|
13350
|
-
"name": "marketType",
|
|
13351
|
-
"type": {
|
|
13352
|
-
"defined": "MarketType"
|
|
13353
|
-
}
|
|
13354
|
-
},
|
|
13355
|
-
{
|
|
13356
|
-
"name": "direction",
|
|
13357
|
-
"type": {
|
|
13358
|
-
"defined": "PositionDirection"
|
|
13359
|
-
}
|
|
13360
|
-
},
|
|
13361
|
-
{
|
|
13362
|
-
"name": "marketIndex",
|
|
13363
|
-
"type": "u16"
|
|
13364
|
-
},
|
|
13365
|
-
{
|
|
13366
|
-
"name": "totalBaseAssetAmount",
|
|
13367
|
-
"docs": [
|
|
13368
|
-
"Total base asset amount to distribute across all orders"
|
|
13369
|
-
],
|
|
13370
|
-
"type": "u64"
|
|
13371
|
-
},
|
|
13372
|
-
{
|
|
13373
|
-
"name": "startPrice",
|
|
13374
|
-
"docs": [
|
|
13375
|
-
"Starting price for the scale (in PRICE_PRECISION)"
|
|
13376
|
-
],
|
|
13377
|
-
"type": "u64"
|
|
13378
|
-
},
|
|
13379
|
-
{
|
|
13380
|
-
"name": "endPrice",
|
|
13381
|
-
"docs": [
|
|
13382
|
-
"Ending price for the scale (in PRICE_PRECISION)"
|
|
13383
|
-
],
|
|
13384
|
-
"type": "u64"
|
|
13385
|
-
},
|
|
13386
|
-
{
|
|
13387
|
-
"name": "orderCount",
|
|
13388
|
-
"docs": [
|
|
13389
|
-
"Number of orders to place (min 2, max 32)"
|
|
13390
|
-
],
|
|
13391
|
-
"type": "u8"
|
|
13392
|
-
},
|
|
13393
|
-
{
|
|
13394
|
-
"name": "sizeDistribution",
|
|
13395
|
-
"docs": [
|
|
13396
|
-
"How to distribute sizes across orders"
|
|
13397
|
-
],
|
|
13398
|
-
"type": {
|
|
13399
|
-
"defined": "SizeDistribution"
|
|
13400
|
-
}
|
|
13401
|
-
},
|
|
13402
|
-
{
|
|
13403
|
-
"name": "reduceOnly",
|
|
13404
|
-
"docs": [
|
|
13405
|
-
"Whether orders should be reduce-only"
|
|
13406
|
-
],
|
|
13407
|
-
"type": "bool"
|
|
13408
|
-
},
|
|
13409
|
-
{
|
|
13410
|
-
"name": "postOnly",
|
|
13411
|
-
"docs": [
|
|
13412
|
-
"Post-only setting for all orders"
|
|
13413
|
-
],
|
|
13414
|
-
"type": {
|
|
13415
|
-
"defined": "PostOnlyParam"
|
|
13416
|
-
}
|
|
13417
|
-
},
|
|
13418
|
-
{
|
|
13419
|
-
"name": "bitFlags",
|
|
13420
|
-
"docs": [
|
|
13421
|
-
"Bit flags (e.g., for high leverage mode)"
|
|
13422
|
-
],
|
|
13423
|
-
"type": "u8"
|
|
13424
|
-
},
|
|
13425
|
-
{
|
|
13426
|
-
"name": "maxTs",
|
|
13427
|
-
"docs": [
|
|
13428
|
-
"Maximum timestamp for orders to be valid"
|
|
13429
|
-
],
|
|
13430
|
-
"type": {
|
|
13431
|
-
"option": "i64"
|
|
13432
|
-
}
|
|
13433
|
-
}
|
|
13434
|
-
]
|
|
13435
|
-
}
|
|
13436
|
-
},
|
|
13437
13371
|
{
|
|
13438
13372
|
"name": "InsuranceClaim",
|
|
13439
13373
|
"type": {
|
|
@@ -14323,6 +14257,102 @@
|
|
|
14323
14257
|
]
|
|
14324
14258
|
}
|
|
14325
14259
|
},
|
|
14260
|
+
{
|
|
14261
|
+
"name": "ScaleOrderParams",
|
|
14262
|
+
"docs": [
|
|
14263
|
+
"Parameters for placing scale orders - multiple limit orders distributed across a price range"
|
|
14264
|
+
],
|
|
14265
|
+
"type": {
|
|
14266
|
+
"kind": "struct",
|
|
14267
|
+
"fields": [
|
|
14268
|
+
{
|
|
14269
|
+
"name": "marketType",
|
|
14270
|
+
"type": {
|
|
14271
|
+
"defined": "MarketType"
|
|
14272
|
+
}
|
|
14273
|
+
},
|
|
14274
|
+
{
|
|
14275
|
+
"name": "direction",
|
|
14276
|
+
"type": {
|
|
14277
|
+
"defined": "PositionDirection"
|
|
14278
|
+
}
|
|
14279
|
+
},
|
|
14280
|
+
{
|
|
14281
|
+
"name": "marketIndex",
|
|
14282
|
+
"type": "u16"
|
|
14283
|
+
},
|
|
14284
|
+
{
|
|
14285
|
+
"name": "totalBaseAssetAmount",
|
|
14286
|
+
"docs": [
|
|
14287
|
+
"Total base asset amount to distribute across all orders"
|
|
14288
|
+
],
|
|
14289
|
+
"type": "u64"
|
|
14290
|
+
},
|
|
14291
|
+
{
|
|
14292
|
+
"name": "startPrice",
|
|
14293
|
+
"docs": [
|
|
14294
|
+
"Starting price for the scale (in PRICE_PRECISION)"
|
|
14295
|
+
],
|
|
14296
|
+
"type": "u64"
|
|
14297
|
+
},
|
|
14298
|
+
{
|
|
14299
|
+
"name": "endPrice",
|
|
14300
|
+
"docs": [
|
|
14301
|
+
"Ending price for the scale (in PRICE_PRECISION)"
|
|
14302
|
+
],
|
|
14303
|
+
"type": "u64"
|
|
14304
|
+
},
|
|
14305
|
+
{
|
|
14306
|
+
"name": "orderCount",
|
|
14307
|
+
"docs": [
|
|
14308
|
+
"Number of orders to place (min 2, max 32)"
|
|
14309
|
+
],
|
|
14310
|
+
"type": "u8"
|
|
14311
|
+
},
|
|
14312
|
+
{
|
|
14313
|
+
"name": "sizeDistribution",
|
|
14314
|
+
"docs": [
|
|
14315
|
+
"How to distribute sizes across orders"
|
|
14316
|
+
],
|
|
14317
|
+
"type": {
|
|
14318
|
+
"defined": "SizeDistribution"
|
|
14319
|
+
}
|
|
14320
|
+
},
|
|
14321
|
+
{
|
|
14322
|
+
"name": "reduceOnly",
|
|
14323
|
+
"docs": [
|
|
14324
|
+
"Whether orders should be reduce-only"
|
|
14325
|
+
],
|
|
14326
|
+
"type": "bool"
|
|
14327
|
+
},
|
|
14328
|
+
{
|
|
14329
|
+
"name": "postOnly",
|
|
14330
|
+
"docs": [
|
|
14331
|
+
"Post-only setting for all orders"
|
|
14332
|
+
],
|
|
14333
|
+
"type": {
|
|
14334
|
+
"defined": "PostOnlyParam"
|
|
14335
|
+
}
|
|
14336
|
+
},
|
|
14337
|
+
{
|
|
14338
|
+
"name": "bitFlags",
|
|
14339
|
+
"docs": [
|
|
14340
|
+
"Bit flags (e.g., for high leverage mode)"
|
|
14341
|
+
],
|
|
14342
|
+
"type": "u8"
|
|
14343
|
+
},
|
|
14344
|
+
{
|
|
14345
|
+
"name": "maxTs",
|
|
14346
|
+
"docs": [
|
|
14347
|
+
"Maximum timestamp for orders to be valid"
|
|
14348
|
+
],
|
|
14349
|
+
"type": {
|
|
14350
|
+
"option": "i64"
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14353
|
+
]
|
|
14354
|
+
}
|
|
14355
|
+
},
|
|
14326
14356
|
{
|
|
14327
14357
|
"name": "SignedMsgOrderId",
|
|
14328
14358
|
"type": {
|
|
@@ -15781,26 +15811,6 @@
|
|
|
15781
15811
|
]
|
|
15782
15812
|
}
|
|
15783
15813
|
},
|
|
15784
|
-
{
|
|
15785
|
-
"name": "SizeDistribution",
|
|
15786
|
-
"docs": [
|
|
15787
|
-
"How to distribute order sizes across scale orders"
|
|
15788
|
-
],
|
|
15789
|
-
"type": {
|
|
15790
|
-
"kind": "enum",
|
|
15791
|
-
"variants": [
|
|
15792
|
-
{
|
|
15793
|
-
"name": "Flat"
|
|
15794
|
-
},
|
|
15795
|
-
{
|
|
15796
|
-
"name": "Ascending"
|
|
15797
|
-
},
|
|
15798
|
-
{
|
|
15799
|
-
"name": "Descending"
|
|
15800
|
-
}
|
|
15801
|
-
]
|
|
15802
|
-
}
|
|
15803
|
-
},
|
|
15804
15814
|
{
|
|
15805
15815
|
"name": "PerpOperation",
|
|
15806
15816
|
"type": {
|
|
@@ -16002,6 +16012,17 @@
|
|
|
16002
16012
|
]
|
|
16003
16013
|
}
|
|
16004
16014
|
},
|
|
16015
|
+
{
|
|
16016
|
+
"name": "MarketConfigFlag",
|
|
16017
|
+
"type": {
|
|
16018
|
+
"kind": "enum",
|
|
16019
|
+
"variants": [
|
|
16020
|
+
{
|
|
16021
|
+
"name": "DisableFormulaicKUpdate"
|
|
16022
|
+
}
|
|
16023
|
+
]
|
|
16024
|
+
}
|
|
16025
|
+
},
|
|
16005
16026
|
{
|
|
16006
16027
|
"name": "RevenueShareOrderBitFlag",
|
|
16007
16028
|
"type": {
|
|
@@ -16022,6 +16043,26 @@
|
|
|
16022
16043
|
]
|
|
16023
16044
|
}
|
|
16024
16045
|
},
|
|
16046
|
+
{
|
|
16047
|
+
"name": "SizeDistribution",
|
|
16048
|
+
"docs": [
|
|
16049
|
+
"How to distribute order sizes across scale orders"
|
|
16050
|
+
],
|
|
16051
|
+
"type": {
|
|
16052
|
+
"kind": "enum",
|
|
16053
|
+
"variants": [
|
|
16054
|
+
{
|
|
16055
|
+
"name": "Flat"
|
|
16056
|
+
},
|
|
16057
|
+
{
|
|
16058
|
+
"name": "Ascending"
|
|
16059
|
+
},
|
|
16060
|
+
{
|
|
16061
|
+
"name": "Descending"
|
|
16062
|
+
}
|
|
16063
|
+
]
|
|
16064
|
+
}
|
|
16065
|
+
},
|
|
16025
16066
|
{
|
|
16026
16067
|
"name": "SettlePnlMode",
|
|
16027
16068
|
"type": {
|
|
@@ -20028,6 +20069,11 @@
|
|
|
20028
20069
|
"code": 6347,
|
|
20029
20070
|
"name": "InvalidOrderScalePriceRange",
|
|
20030
20071
|
"msg": "Invalid scale order price range"
|
|
20072
|
+
},
|
|
20073
|
+
{
|
|
20074
|
+
"code": 6348,
|
|
20075
|
+
"name": "InvalidPerpMarketConfig",
|
|
20076
|
+
"msg": "Invalid perp market config"
|
|
20031
20077
|
}
|
|
20032
20078
|
]
|
|
20033
20079
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
StateAccount,
|
|
13
13
|
isVariant,
|
|
14
14
|
InsuranceFundOperation,
|
|
15
|
+
MarketConfigFlag,
|
|
15
16
|
} from '../types';
|
|
16
17
|
import { BN } from '@coral-xyz/anchor';
|
|
17
18
|
|
|
@@ -119,3 +120,17 @@ export function isAmmDrawdownPause(market: PerpMarketAccount): boolean {
|
|
|
119
120
|
|
|
120
121
|
return false;
|
|
121
122
|
}
|
|
123
|
+
|
|
124
|
+
export function isMarketConfigFlagSet(
|
|
125
|
+
marketConfig: number,
|
|
126
|
+
flag: MarketConfigFlag
|
|
127
|
+
): boolean {
|
|
128
|
+
return (marketConfig & flag) > 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function isFormulaicKUpdateDisabled(market: PerpMarketAccount): boolean {
|
|
132
|
+
return isMarketConfigFlagSet(
|
|
133
|
+
market.marketConfig,
|
|
134
|
+
MarketConfigFlag.DISABLE_FORMULAIC_K_UPDATE
|
|
135
|
+
);
|
|
136
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -86,6 +86,10 @@ export enum UserStatsPausedOperation {
|
|
|
86
86
|
AMM_ATOMIC_RISK_INCREASING_FILL = 4,
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
export enum MarketConfigFlag {
|
|
90
|
+
DISABLE_FORMULAIC_K_UPDATE = 1,
|
|
91
|
+
}
|
|
92
|
+
|
|
89
93
|
export class MarginMode {
|
|
90
94
|
static readonly DEFAULT = { default: {} };
|
|
91
95
|
static readonly HIGH_LEVERAGE = { highLeverage: {} };
|
|
@@ -911,6 +915,7 @@ export type PerpMarketAccount = {
|
|
|
911
915
|
lpExchangeFeeExcluscionScalar: number;
|
|
912
916
|
lpStatus: number;
|
|
913
917
|
lpPausedOperations: number;
|
|
918
|
+
marketConfig: number;
|
|
914
919
|
};
|
|
915
920
|
|
|
916
921
|
export type HistoricalOracleData = {
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -209,6 +209,7 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
209
209
|
lpExchangeFeeExcluscionScalar: 0,
|
|
210
210
|
lpStatus: 0,
|
|
211
211
|
lpPausedOperations: 0,
|
|
212
|
+
marketConfig: 0,
|
|
212
213
|
},
|
|
213
214
|
{
|
|
214
215
|
status: MarketStatus.INITIALIZED,
|
|
@@ -261,6 +262,7 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
261
262
|
lpExchangeFeeExcluscionScalar: 0,
|
|
262
263
|
lpStatus: 0,
|
|
263
264
|
lpPausedOperations: 0,
|
|
265
|
+
marketConfig: 0,
|
|
264
266
|
},
|
|
265
267
|
{
|
|
266
268
|
status: MarketStatus.INITIALIZED,
|
|
@@ -313,6 +315,7 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
313
315
|
lpExchangeFeeExcluscionScalar: 0,
|
|
314
316
|
lpStatus: 0,
|
|
315
317
|
lpPausedOperations: 0,
|
|
318
|
+
marketConfig: 0,
|
|
316
319
|
},
|
|
317
320
|
];
|
|
318
321
|
|