@drift-labs/sdk 2.30.0 → 2.31.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.
@@ -19,6 +19,7 @@ export declare class AdminClient extends DriftClient {
19
19
  depositIntoPerpMarketFeePool(perpMarketIndex: number, amount: BN, sourceVault: PublicKey): Promise<TransactionSignature>;
20
20
  updateAdmin(admin: PublicKey): Promise<TransactionSignature>;
21
21
  updatePerpMarketCurveUpdateIntensity(perpMarketIndex: number, curveUpdateIntensity: number): Promise<TransactionSignature>;
22
+ updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex: number, targetBaseAssetAmountPerLP: number): Promise<TransactionSignature>;
22
23
  updatePerpMarketMarginRatio(perpMarketIndex: number, marginRatioInitial: number, marginRatioMaintenance: number): Promise<TransactionSignature>;
23
24
  updatePerpMarketImfFactor(perpMarketIndex: number, imfFactor: number, unrealizedPnlImfFactor: number): Promise<TransactionSignature>;
24
25
  updatePerpMarketBaseSpread(perpMarketIndex: number, baseSpread: number): Promise<TransactionSignature>;
@@ -292,6 +292,15 @@ class AdminClient extends driftClient_1.DriftClient {
292
292
  },
293
293
  });
294
294
  }
295
+ async updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex, targetBaseAssetAmountPerLP) {
296
+ return await this.program.rpc.updatePerpMarketTargetBaseAssetAmountPerLp(targetBaseAssetAmountPerLP, {
297
+ accounts: {
298
+ admin: this.wallet.publicKey,
299
+ state: await this.getStatePublicKey(),
300
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
301
+ },
302
+ });
303
+ }
295
304
  async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
296
305
  const tx = await this.program.transaction.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
297
306
  accounts: {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.30.0",
2
+ "version": "2.31.0-beta.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -3644,6 +3644,32 @@
3644
3644
  }
3645
3645
  ]
3646
3646
  },
3647
+ {
3648
+ "name": "updatePerpMarketTargetBaseAssetAmountPerLp",
3649
+ "accounts": [
3650
+ {
3651
+ "name": "admin",
3652
+ "isMut": false,
3653
+ "isSigner": true
3654
+ },
3655
+ {
3656
+ "name": "state",
3657
+ "isMut": false,
3658
+ "isSigner": false
3659
+ },
3660
+ {
3661
+ "name": "perpMarket",
3662
+ "isMut": true,
3663
+ "isSigner": false
3664
+ }
3665
+ ],
3666
+ "args": [
3667
+ {
3668
+ "name": "targetBaseAssetAmountPerLp",
3669
+ "type": "i32"
3670
+ }
3671
+ ]
3672
+ },
3647
3673
  {
3648
3674
  "name": "updateLpCooldownTime",
3649
3675
  "accounts": [
@@ -6449,7 +6475,8 @@
6449
6475
  {
6450
6476
  "name": "lastOracleNormalisedPrice",
6451
6477
  "docs": [
6452
- "the last seen oracle price partially shrunk toward the amm reserve price"
6478
+ "the last seen oracle price partially shrunk toward the amm reserve price",
6479
+ "precision: PRICE_PRECISION"
6453
6480
  ],
6454
6481
  "type": "i64"
6455
6482
  },
@@ -6463,21 +6490,24 @@
6463
6490
  {
6464
6491
  "name": "lastBidPriceTwap",
6465
6492
  "docs": [
6466
- "average estimate of bid price over funding_period"
6493
+ "average estimate of bid price over funding_period",
6494
+ "precision: PRICE_PRECISION"
6467
6495
  ],
6468
6496
  "type": "u64"
6469
6497
  },
6470
6498
  {
6471
6499
  "name": "lastAskPriceTwap",
6472
6500
  "docs": [
6473
- "average estimate of ask price over funding_period"
6501
+ "average estimate of ask price over funding_period",
6502
+ "precision: PRICE_PRECISION"
6474
6503
  ],
6475
6504
  "type": "u64"
6476
6505
  },
6477
6506
  {
6478
6507
  "name": "lastMarkPriceTwap",
6479
6508
  "docs": [
6480
- "average estimate of (bid+ask)/2 price over funding_period"
6509
+ "average estimate of (bid+ask)/2 price over funding_period",
6510
+ "precision: PRICE_PRECISION"
6481
6511
  ],
6482
6512
  "type": "u64"
6483
6513
  },
@@ -6499,14 +6529,15 @@
6499
6529
  "name": "lastOracleConfPct",
6500
6530
  "docs": [
6501
6531
  "the pct size of the oracle confidence interval",
6502
- "PERCENTAGE_PRECISION"
6532
+ "precision: PERCENTAGE_PRECISION"
6503
6533
  ],
6504
6534
  "type": "u64"
6505
6535
  },
6506
6536
  {
6507
6537
  "name": "netRevenueSinceLastFunding",
6508
6538
  "docs": [
6509
- "the total_fee_minus_distribution change since the last funding update"
6539
+ "the total_fee_minus_distribution change since the last funding update",
6540
+ "precision: QUOTE_PRECISION"
6510
6541
  ],
6511
6542
  "type": "i64"
6512
6543
  },
@@ -6527,28 +6558,32 @@
6527
6558
  {
6528
6559
  "name": "orderStepSize",
6529
6560
  "docs": [
6530
- "the base step size (increment) of orders"
6561
+ "the base step size (increment) of orders",
6562
+ "precision: BASE_PRECISION"
6531
6563
  ],
6532
6564
  "type": "u64"
6533
6565
  },
6534
6566
  {
6535
6567
  "name": "orderTickSize",
6536
6568
  "docs": [
6537
- "the price tick size of orders"
6569
+ "the price tick size of orders",
6570
+ "precision: PRICE_PRECISION"
6538
6571
  ],
6539
6572
  "type": "u64"
6540
6573
  },
6541
6574
  {
6542
6575
  "name": "minOrderSize",
6543
6576
  "docs": [
6544
- "the minimum base size of an order"
6577
+ "the minimum base size of an order",
6578
+ "precision: BASE_PRECISION"
6545
6579
  ],
6546
6580
  "type": "u64"
6547
6581
  },
6548
6582
  {
6549
6583
  "name": "maxPositionSize",
6550
6584
  "docs": [
6551
- "the max base size a single user can have"
6585
+ "the max base size a single user can have",
6586
+ "precision: BASE_PRECISION"
6552
6587
  ],
6553
6588
  "type": "u64"
6554
6589
  },
@@ -6584,14 +6619,16 @@
6584
6619
  {
6585
6620
  "name": "markStd",
6586
6621
  "docs": [
6587
- "estimate of standard deviation of the fill (mark) prices"
6622
+ "estimate of standard deviation of the fill (mark) prices",
6623
+ "precision: PRICE_PRECISION"
6588
6624
  ],
6589
6625
  "type": "u64"
6590
6626
  },
6591
6627
  {
6592
6628
  "name": "oracleStd",
6593
6629
  "docs": [
6594
- "estimate of standard deviation of the oracle price at each update"
6630
+ "estimate of standard deviation of the oracle price at each update",
6631
+ "precision: PRICE_PRECISION"
6595
6632
  ],
6596
6633
  "type": "u64"
6597
6634
  },
@@ -6668,7 +6705,8 @@
6668
6705
  {
6669
6706
  "name": "ammJitIntensity",
6670
6707
  "docs": [
6671
- "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation."
6708
+ "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.",
6709
+ "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM."
6672
6710
  ],
6673
6711
  "type": "u8"
6674
6712
  },
@@ -6688,12 +6726,20 @@
6688
6726
  ],
6689
6727
  "type": "bool"
6690
6728
  },
6729
+ {
6730
+ "name": "targetBaseAssetAmountPerLp",
6731
+ "docs": [
6732
+ "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split",
6733
+ "precision: BASE_PRECISION"
6734
+ ],
6735
+ "type": "i32"
6736
+ },
6691
6737
  {
6692
6738
  "name": "padding",
6693
6739
  "type": {
6694
6740
  "array": [
6695
6741
  "u8",
6696
- 48
6742
+ 44
6697
6743
  ]
6698
6744
  }
6699
6745
  }
@@ -7703,6 +7749,12 @@
7703
7749
  },
7704
7750
  {
7705
7751
  "name": "OrderFillWithPhoenix"
7752
+ },
7753
+ {
7754
+ "name": "OrderFilledWithAMMJitLPSplit"
7755
+ },
7756
+ {
7757
+ "name": "OrderFilledWithLPJit"
7706
7758
  }
7707
7759
  ]
7708
7760
  }
@@ -7919,6 +7971,23 @@
7919
7971
  ]
7920
7972
  }
7921
7973
  },
7974
+ {
7975
+ "name": "AMMLiquiditySplit",
7976
+ "type": {
7977
+ "kind": "enum",
7978
+ "variants": [
7979
+ {
7980
+ "name": "ProtocolOwned"
7981
+ },
7982
+ {
7983
+ "name": "LPOwned"
7984
+ },
7985
+ {
7986
+ "name": "Shared"
7987
+ }
7988
+ ]
7989
+ }
7990
+ },
7922
7991
  {
7923
7992
  "name": "SpotBalanceType",
7924
7993
  "type": {
package/lib/types.d.ts CHANGED
@@ -218,6 +218,12 @@ export declare class OrderActionExplanation {
218
218
  static readonly ORDER_FILLED_WITH_AMM_JIT: {
219
219
  orderFilledWithAmmJit: {};
220
220
  };
221
+ static readonly ORDER_FILLED_WITH_AMM_JIT_LP_SPLIT: {
222
+ orderFilledWithAmmJitLpSplit: {};
223
+ };
224
+ static readonly ORDER_FILLED_WITH_LP_JIT: {
225
+ orderFilledWithAmmJitLpSplit: {};
226
+ };
221
227
  static readonly ORDER_FILLED_WITH_MATCH: {
222
228
  orderFilledWithMatch: {};
223
229
  };
@@ -786,6 +792,7 @@ export type AMM = {
786
792
  maxSpread: number;
787
793
  baseAssetAmountPerLp: BN;
788
794
  quoteAssetAmountPerLp: BN;
795
+ targetBaseAssetAmountPerLp: number;
789
796
  ammJitIntensity: number;
790
797
  maxOpenInterest: BN;
791
798
  maxBaseAssetReserve: BN;
package/lib/types.js CHANGED
@@ -134,6 +134,12 @@ OrderActionExplanation.ORDER_FILLED_WITH_AMM = {
134
134
  OrderActionExplanation.ORDER_FILLED_WITH_AMM_JIT = {
135
135
  orderFilledWithAmmJit: {},
136
136
  };
137
+ OrderActionExplanation.ORDER_FILLED_WITH_AMM_JIT_LP_SPLIT = {
138
+ orderFilledWithAmmJitLpSplit: {},
139
+ };
140
+ OrderActionExplanation.ORDER_FILLED_WITH_LP_JIT = {
141
+ orderFilledWithAmmJitLpSplit: {},
142
+ };
137
143
  OrderActionExplanation.ORDER_FILLED_WITH_MATCH = {
138
144
  orderFilledWithMatch: {},
139
145
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.30.0",
3
+ "version": "2.31.0-beta.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -544,6 +544,25 @@ export class AdminClient extends DriftClient {
544
544
  );
545
545
  }
546
546
 
547
+ public async updatePerpMarketTargetBaseAssetAmountPerLp(
548
+ perpMarketIndex: number,
549
+ targetBaseAssetAmountPerLP: number
550
+ ): Promise<TransactionSignature> {
551
+ return await this.program.rpc.updatePerpMarketTargetBaseAssetAmountPerLp(
552
+ targetBaseAssetAmountPerLP,
553
+ {
554
+ accounts: {
555
+ admin: this.wallet.publicKey,
556
+ state: await this.getStatePublicKey(),
557
+ perpMarket: await getPerpMarketPublicKey(
558
+ this.program.programId,
559
+ perpMarketIndex
560
+ ),
561
+ },
562
+ }
563
+ );
564
+ }
565
+
547
566
  public async updatePerpMarketMarginRatio(
548
567
  perpMarketIndex: number,
549
568
  marginRatioInitial: number,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.30.0",
2
+ "version": "2.31.0-beta.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -3644,6 +3644,32 @@
3644
3644
  }
3645
3645
  ]
3646
3646
  },
3647
+ {
3648
+ "name": "updatePerpMarketTargetBaseAssetAmountPerLp",
3649
+ "accounts": [
3650
+ {
3651
+ "name": "admin",
3652
+ "isMut": false,
3653
+ "isSigner": true
3654
+ },
3655
+ {
3656
+ "name": "state",
3657
+ "isMut": false,
3658
+ "isSigner": false
3659
+ },
3660
+ {
3661
+ "name": "perpMarket",
3662
+ "isMut": true,
3663
+ "isSigner": false
3664
+ }
3665
+ ],
3666
+ "args": [
3667
+ {
3668
+ "name": "targetBaseAssetAmountPerLp",
3669
+ "type": "i32"
3670
+ }
3671
+ ]
3672
+ },
3647
3673
  {
3648
3674
  "name": "updateLpCooldownTime",
3649
3675
  "accounts": [
@@ -6449,7 +6475,8 @@
6449
6475
  {
6450
6476
  "name": "lastOracleNormalisedPrice",
6451
6477
  "docs": [
6452
- "the last seen oracle price partially shrunk toward the amm reserve price"
6478
+ "the last seen oracle price partially shrunk toward the amm reserve price",
6479
+ "precision: PRICE_PRECISION"
6453
6480
  ],
6454
6481
  "type": "i64"
6455
6482
  },
@@ -6463,21 +6490,24 @@
6463
6490
  {
6464
6491
  "name": "lastBidPriceTwap",
6465
6492
  "docs": [
6466
- "average estimate of bid price over funding_period"
6493
+ "average estimate of bid price over funding_period",
6494
+ "precision: PRICE_PRECISION"
6467
6495
  ],
6468
6496
  "type": "u64"
6469
6497
  },
6470
6498
  {
6471
6499
  "name": "lastAskPriceTwap",
6472
6500
  "docs": [
6473
- "average estimate of ask price over funding_period"
6501
+ "average estimate of ask price over funding_period",
6502
+ "precision: PRICE_PRECISION"
6474
6503
  ],
6475
6504
  "type": "u64"
6476
6505
  },
6477
6506
  {
6478
6507
  "name": "lastMarkPriceTwap",
6479
6508
  "docs": [
6480
- "average estimate of (bid+ask)/2 price over funding_period"
6509
+ "average estimate of (bid+ask)/2 price over funding_period",
6510
+ "precision: PRICE_PRECISION"
6481
6511
  ],
6482
6512
  "type": "u64"
6483
6513
  },
@@ -6499,14 +6529,15 @@
6499
6529
  "name": "lastOracleConfPct",
6500
6530
  "docs": [
6501
6531
  "the pct size of the oracle confidence interval",
6502
- "PERCENTAGE_PRECISION"
6532
+ "precision: PERCENTAGE_PRECISION"
6503
6533
  ],
6504
6534
  "type": "u64"
6505
6535
  },
6506
6536
  {
6507
6537
  "name": "netRevenueSinceLastFunding",
6508
6538
  "docs": [
6509
- "the total_fee_minus_distribution change since the last funding update"
6539
+ "the total_fee_minus_distribution change since the last funding update",
6540
+ "precision: QUOTE_PRECISION"
6510
6541
  ],
6511
6542
  "type": "i64"
6512
6543
  },
@@ -6527,28 +6558,32 @@
6527
6558
  {
6528
6559
  "name": "orderStepSize",
6529
6560
  "docs": [
6530
- "the base step size (increment) of orders"
6561
+ "the base step size (increment) of orders",
6562
+ "precision: BASE_PRECISION"
6531
6563
  ],
6532
6564
  "type": "u64"
6533
6565
  },
6534
6566
  {
6535
6567
  "name": "orderTickSize",
6536
6568
  "docs": [
6537
- "the price tick size of orders"
6569
+ "the price tick size of orders",
6570
+ "precision: PRICE_PRECISION"
6538
6571
  ],
6539
6572
  "type": "u64"
6540
6573
  },
6541
6574
  {
6542
6575
  "name": "minOrderSize",
6543
6576
  "docs": [
6544
- "the minimum base size of an order"
6577
+ "the minimum base size of an order",
6578
+ "precision: BASE_PRECISION"
6545
6579
  ],
6546
6580
  "type": "u64"
6547
6581
  },
6548
6582
  {
6549
6583
  "name": "maxPositionSize",
6550
6584
  "docs": [
6551
- "the max base size a single user can have"
6585
+ "the max base size a single user can have",
6586
+ "precision: BASE_PRECISION"
6552
6587
  ],
6553
6588
  "type": "u64"
6554
6589
  },
@@ -6584,14 +6619,16 @@
6584
6619
  {
6585
6620
  "name": "markStd",
6586
6621
  "docs": [
6587
- "estimate of standard deviation of the fill (mark) prices"
6622
+ "estimate of standard deviation of the fill (mark) prices",
6623
+ "precision: PRICE_PRECISION"
6588
6624
  ],
6589
6625
  "type": "u64"
6590
6626
  },
6591
6627
  {
6592
6628
  "name": "oracleStd",
6593
6629
  "docs": [
6594
- "estimate of standard deviation of the oracle price at each update"
6630
+ "estimate of standard deviation of the oracle price at each update",
6631
+ "precision: PRICE_PRECISION"
6595
6632
  ],
6596
6633
  "type": "u64"
6597
6634
  },
@@ -6668,7 +6705,8 @@
6668
6705
  {
6669
6706
  "name": "ammJitIntensity",
6670
6707
  "docs": [
6671
- "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation."
6708
+ "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.",
6709
+ "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM."
6672
6710
  ],
6673
6711
  "type": "u8"
6674
6712
  },
@@ -6688,12 +6726,20 @@
6688
6726
  ],
6689
6727
  "type": "bool"
6690
6728
  },
6729
+ {
6730
+ "name": "targetBaseAssetAmountPerLp",
6731
+ "docs": [
6732
+ "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split",
6733
+ "precision: BASE_PRECISION"
6734
+ ],
6735
+ "type": "i32"
6736
+ },
6691
6737
  {
6692
6738
  "name": "padding",
6693
6739
  "type": {
6694
6740
  "array": [
6695
6741
  "u8",
6696
- 48
6742
+ 44
6697
6743
  ]
6698
6744
  }
6699
6745
  }
@@ -7703,6 +7749,12 @@
7703
7749
  },
7704
7750
  {
7705
7751
  "name": "OrderFillWithPhoenix"
7752
+ },
7753
+ {
7754
+ "name": "OrderFilledWithAMMJitLPSplit"
7755
+ },
7756
+ {
7757
+ "name": "OrderFilledWithLPJit"
7706
7758
  }
7707
7759
  ]
7708
7760
  }
@@ -7919,6 +7971,23 @@
7919
7971
  ]
7920
7972
  }
7921
7973
  },
7974
+ {
7975
+ "name": "AMMLiquiditySplit",
7976
+ "type": {
7977
+ "kind": "enum",
7978
+ "variants": [
7979
+ {
7980
+ "name": "ProtocolOwned"
7981
+ },
7982
+ {
7983
+ "name": "LPOwned"
7984
+ },
7985
+ {
7986
+ "name": "Shared"
7987
+ }
7988
+ ]
7989
+ }
7990
+ },
7922
7991
  {
7923
7992
  "name": "SpotBalanceType",
7924
7993
  "type": {
package/src/types.ts CHANGED
@@ -133,6 +133,12 @@ export class OrderActionExplanation {
133
133
  static readonly ORDER_FILLED_WITH_AMM_JIT = {
134
134
  orderFilledWithAmmJit: {},
135
135
  };
136
+ static readonly ORDER_FILLED_WITH_AMM_JIT_LP_SPLIT = {
137
+ orderFilledWithAmmJitLpSplit: {},
138
+ };
139
+ static readonly ORDER_FILLED_WITH_LP_JIT = {
140
+ orderFilledWithAmmJitLpSplit: {},
141
+ };
136
142
  static readonly ORDER_FILLED_WITH_MATCH = {
137
143
  orderFilledWithMatch: {},
138
144
  };
@@ -730,6 +736,7 @@ export type AMM = {
730
736
 
731
737
  baseAssetAmountPerLp: BN;
732
738
  quoteAssetAmountPerLp: BN;
739
+ targetBaseAssetAmountPerLp: number;
733
740
 
734
741
  ammJitIntensity: number;
735
742
  maxOpenInterest: BN;
@@ -114,6 +114,7 @@ export const mockAMM: AMM = {
114
114
  totalSocialLoss: new BN(0),
115
115
  baseAssetAmountPerLp: new BN(0),
116
116
  quoteAssetAmountPerLp: new BN(0),
117
+ targetBaseAssetAmountPerLp: 0,
117
118
 
118
119
  quoteBreakEvenAmountLong: new BN(0),
119
120
  quoteBreakEvenAmountShort: new BN(0),