@drift-labs/sdk 2.42.0-beta.5 → 2.42.0-beta.7

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.
@@ -1,5 +1,6 @@
1
1
  import { MarginCategory, SpotMarketAccount, SpotPosition } from '../types';
2
2
  import {
3
+ QUOTE_SPOT_MARKET_INDEX,
3
4
  SPOT_MARKET_WEIGHT_PRECISION,
4
5
  ZERO,
5
6
  } from '../constants/numericConstants';
@@ -31,7 +32,8 @@ export function getWorstCaseTokenAmounts(
31
32
  spotPosition: SpotPosition,
32
33
  spotMarketAccount: SpotMarketAccount,
33
34
  strictOraclePrice: StrictOraclePrice,
34
- marginCategory: MarginCategory
35
+ marginCategory: MarginCategory,
36
+ customMarginRatio?: number
35
37
  ): OrderFillSimulation {
36
38
  const tokenAmount = getSignedTokenAmount(
37
39
  getTokenAmount(
@@ -54,7 +56,8 @@ export function getWorstCaseTokenAmounts(
54
56
  tokenValue,
55
57
  strictOraclePrice.current,
56
58
  spotMarketAccount,
57
- marginCategory
59
+ marginCategory,
60
+ customMarginRatio
58
61
  );
59
62
  return {
60
63
  tokenAmount,
@@ -72,7 +75,8 @@ export function getWorstCaseTokenAmounts(
72
75
  spotPosition.openBids,
73
76
  strictOraclePrice,
74
77
  spotMarketAccount,
75
- marginCategory
78
+ marginCategory,
79
+ customMarginRatio
76
80
  );
77
81
  const asksSimulation = simulateOrderFill(
78
82
  tokenAmount,
@@ -80,7 +84,8 @@ export function getWorstCaseTokenAmounts(
80
84
  spotPosition.openAsks,
81
85
  strictOraclePrice,
82
86
  spotMarketAccount,
83
- marginCategory
87
+ marginCategory,
88
+ customMarginRatio
84
89
  );
85
90
 
86
91
  if (
@@ -99,7 +104,8 @@ export function calculateWeightedTokenValue(
99
104
  tokenValue: BN,
100
105
  oraclePrice: BN,
101
106
  spotMarket: SpotMarketAccount,
102
- marginCategory: MarginCategory
107
+ marginCategory: MarginCategory,
108
+ customMarginRatio?: number
103
109
  ): { weight: BN; weightedTokenValue: BN } {
104
110
  let weight: BN;
105
111
  if (tokenValue.gte(ZERO)) {
@@ -117,6 +123,20 @@ export function calculateWeightedTokenValue(
117
123
  );
118
124
  }
119
125
 
126
+ if (
127
+ marginCategory === 'Initial' &&
128
+ customMarginRatio &&
129
+ spotMarket.marketIndex !== QUOTE_SPOT_MARKET_INDEX
130
+ ) {
131
+ const userCustomAssetWeight = tokenValue.gte(ZERO)
132
+ ? BN.max(ZERO, SPOT_MARKET_WEIGHT_PRECISION.subn(customMarginRatio))
133
+ : SPOT_MARKET_WEIGHT_PRECISION.addn(customMarginRatio);
134
+
135
+ weight = tokenValue.gte(ZERO)
136
+ ? BN.min(weight, userCustomAssetWeight)
137
+ : BN.max(weight, userCustomAssetWeight);
138
+ }
139
+
120
140
  return {
121
141
  weight: weight,
122
142
  weightedTokenValue: tokenValue
@@ -131,7 +151,8 @@ export function simulateOrderFill(
131
151
  openOrders: BN,
132
152
  strictOraclePrice: StrictOraclePrice,
133
153
  spotMarket: SpotMarketAccount,
134
- marginCategory: MarginCategory
154
+ marginCategory: MarginCategory,
155
+ customMarginRatio?: number
135
156
  ): OrderFillSimulation {
136
157
  const ordersValue = getTokenValue(openOrders.neg(), spotMarket.decimals, {
137
158
  price: strictOraclePrice.max(),
@@ -145,7 +166,8 @@ export function simulateOrderFill(
145
166
  tokenValueAfterFill,
146
167
  strictOraclePrice.current,
147
168
  spotMarket,
148
- marginCategory
169
+ marginCategory,
170
+ customMarginRatio
149
171
  );
150
172
 
151
173
  const freeCollateralContribution =
package/src/user.ts CHANGED
@@ -78,7 +78,6 @@ import {
78
78
  getWorstCaseTokenAmounts,
79
79
  isSpotPositionAvailable,
80
80
  } from './math/spotPosition';
81
-
82
81
  import { calculateLiveOracleTwap } from './math/oracles';
83
82
  import { getPerpMarketTierNumber, getSpotMarketTierNumber } from './math/tiers';
84
83
  import { StrictOraclePrice } from './oracles/strictOraclePrice';
@@ -632,7 +631,8 @@ export class User {
632
631
  const marginRatio = calculateMarketMarginRatio(
633
632
  this.driftClient.getPerpMarketAccount(marketIndex),
634
633
  baseAssetAmount,
635
- 'Initial'
634
+ 'Initial',
635
+ this.getUserAccount().maxMarginRatio
636
636
  );
637
637
 
638
638
  return freeCollateral.mul(MARGIN_PRECISION).div(new BN(marginRatio));
@@ -968,7 +968,8 @@ export class User {
968
968
  spotPosition,
969
969
  spotMarketAccount,
970
970
  strictOraclePrice,
971
- marginCategory ?? 'Initial'
971
+ marginCategory,
972
+ this.getUserAccount().maxMarginRatio
972
973
  );
973
974
 
974
975
  if (worstCaseTokenAmount.gt(ZERO) && countForBase) {
@@ -1067,8 +1068,16 @@ export class User {
1067
1068
  marginCategory
1068
1069
  );
1069
1070
 
1070
- if (marginCategory === 'Initial') {
1071
- weight = BN.max(weight, new BN(this.getUserAccount().maxMarginRatio));
1071
+ if (
1072
+ marginCategory === 'Initial' &&
1073
+ spotMarketAccount.marketIndex !== QUOTE_SPOT_MARKET_INDEX
1074
+ ) {
1075
+ weight = BN.max(
1076
+ weight,
1077
+ SPOT_MARKET_WEIGHT_PRECISION.addn(
1078
+ this.getUserAccount().maxMarginRatio
1079
+ )
1080
+ );
1072
1081
  }
1073
1082
 
1074
1083
  if (liquidationBuffer !== undefined) {
@@ -1114,13 +1123,26 @@ export class User {
1114
1123
  );
1115
1124
 
1116
1125
  if (marginCategory !== undefined) {
1117
- const weight = calculateAssetWeight(
1126
+ let weight = calculateAssetWeight(
1118
1127
  tokenAmount,
1119
1128
  strictOraclePrice.current,
1120
1129
  spotMarketAccount,
1121
1130
  marginCategory
1122
1131
  );
1123
1132
 
1133
+ if (
1134
+ marginCategory === 'Initial' &&
1135
+ spotMarketAccount.marketIndex !== QUOTE_SPOT_MARKET_INDEX
1136
+ ) {
1137
+ const userCustomAssetWeight = BN.max(
1138
+ ZERO,
1139
+ SPOT_MARKET_WEIGHT_PRECISION.subn(
1140
+ this.getUserAccount().maxMarginRatio
1141
+ )
1142
+ );
1143
+ weight = BN.min(weight, userCustomAssetWeight);
1144
+ }
1145
+
1124
1146
  assetValue = assetValue.mul(weight).div(SPOT_MARKET_WEIGHT_PRECISION);
1125
1147
  }
1126
1148
 
@@ -1254,17 +1276,11 @@ export class User {
1254
1276
  calculateMarketMarginRatio(
1255
1277
  market,
1256
1278
  baseAssetAmount.abs(),
1257
- marginCategory
1279
+ marginCategory,
1280
+ this.getUserAccount().maxMarginRatio
1258
1281
  )
1259
1282
  );
1260
1283
 
1261
- if (marginCategory === 'Initial') {
1262
- marginRatio = BN.max(
1263
- marginRatio,
1264
- new BN(this.getUserAccount().maxMarginRatio)
1265
- );
1266
- }
1267
-
1268
1284
  if (liquidationBuffer !== undefined) {
1269
1285
  marginRatio = marginRatio.add(liquidationBuffer);
1270
1286
  }
@@ -1494,25 +1510,28 @@ export class User {
1494
1510
  return totalLiabilityValue.mul(TEN_THOUSAND).div(netAssetValue);
1495
1511
  }
1496
1512
 
1497
- getLeverageComponents(includeOpenOrders = true): {
1513
+ getLeverageComponents(
1514
+ includeOpenOrders = true,
1515
+ marginCategory: MarginCategory = undefined
1516
+ ): {
1498
1517
  perpLiabilityValue: BN;
1499
1518
  perpPnl: BN;
1500
1519
  spotAssetValue: BN;
1501
1520
  spotLiabilityValue: BN;
1502
1521
  } {
1503
1522
  const perpLiability = this.getTotalPerpPositionValue(
1504
- undefined,
1523
+ marginCategory,
1505
1524
  undefined,
1506
1525
  includeOpenOrders
1507
1526
  );
1508
- const perpPnl = this.getUnrealizedPNL(true);
1527
+ const perpPnl = this.getUnrealizedPNL(true, undefined, marginCategory);
1509
1528
 
1510
1529
  const {
1511
1530
  totalAssetValue: spotAssetValue,
1512
1531
  totalLiabilityValue: spotLiabilityValue,
1513
1532
  } = this.getSpotMarketAssetAndLiabilityValue(
1514
1533
  undefined,
1515
- undefined,
1534
+ marginCategory,
1516
1535
  undefined,
1517
1536
  includeOpenOrders
1518
1537
  );
@@ -1599,7 +1618,10 @@ export class User {
1599
1618
 
1600
1619
  switch (marginCategory) {
1601
1620
  case 'Initial':
1602
- rawMarginRatio = market.marginRatioInitial;
1621
+ rawMarginRatio = Math.max(
1622
+ market.marginRatioInitial,
1623
+ this.getUserAccount().maxMarginRatio
1624
+ );
1603
1625
  break;
1604
1626
  case 'Maintenance':
1605
1627
  rawMarginRatio = market.marginRatioMaintenance;
@@ -1623,7 +1645,8 @@ export class User {
1623
1645
  let marginRatio = calculateMarketMarginRatio(
1624
1646
  market,
1625
1647
  maxSize,
1626
- marginCategory
1648
+ marginCategory,
1649
+ this.getUserAccount().maxMarginRatio
1627
1650
  );
1628
1651
 
1629
1652
  // use more fesible size since imf factor activated
@@ -1643,7 +1666,8 @@ export class User {
1643
1666
  marginRatio = calculateMarketMarginRatio(
1644
1667
  market,
1645
1668
  targetSize,
1646
- marginCategory
1669
+ marginCategory,
1670
+ this.getUserAccount().maxMarginRatio
1647
1671
  );
1648
1672
  attempts += 1;
1649
1673
  }
@@ -2177,6 +2201,7 @@ export class User {
2177
2201
  : this.getPerpPositionValue(targetMarketIndex, oracleData);
2178
2202
 
2179
2203
  let maxPositionSize = this.getPerpBuyingPower(targetMarketIndex, lpBuffer);
2204
+
2180
2205
  if (maxPositionSize.gte(ZERO)) {
2181
2206
  if (oppositeSizeValueUSDC.eq(ZERO)) {
2182
2207
  // case 1 : Regular trade where current total position less than max, and no opposite position to account for
@@ -2262,7 +2287,8 @@ export class User {
2262
2287
  ZERO,
2263
2288
  isVariant(direction, 'long')
2264
2289
  ? SpotBalanceType.DEPOSIT
2265
- : SpotBalanceType.BORROW
2290
+ : SpotBalanceType.BORROW,
2291
+ this.getUserAccount().maxMarginRatio
2266
2292
  );
2267
2293
 
2268
2294
  let tradeAmount = ZERO;
@@ -2275,7 +2301,8 @@ export class User {
2275
2301
  oraclePrice,
2276
2302
  'Initial',
2277
2303
  this.getTokenAmount(targetMarketIndex).abs(),
2278
- SpotBalanceType.BORROW
2304
+ SpotBalanceType.BORROW,
2305
+ this.getUserAccount().maxMarginRatio
2279
2306
  );
2280
2307
  freeCollateral = freeCollateral.add(
2281
2308
  tradeAmount.mul(new BN(marginRatio)).div(MARGIN_PRECISION)
@@ -2290,7 +2317,8 @@ export class User {
2290
2317
  oraclePrice,
2291
2318
  'Initial',
2292
2319
  this.getTokenAmount(targetMarketIndex),
2293
- SpotBalanceType.DEPOSIT
2320
+ SpotBalanceType.DEPOSIT,
2321
+ this.getUserAccount().maxMarginRatio
2294
2322
  );
2295
2323
  freeCollateral = freeCollateral.add(
2296
2324
  tradeAmount.mul(new BN(marginRatio)).div(MARGIN_PRECISION)
@@ -2384,7 +2412,7 @@ export class User {
2384
2412
  );
2385
2413
 
2386
2414
  const { perpLiabilityValue, perpPnl, spotAssetValue, spotLiabilityValue } =
2387
- this.getLeverageComponents();
2415
+ this.getLeverageComponents(undefined, 'Initial');
2388
2416
 
2389
2417
  if (!calculateSwap) {
2390
2418
  calculateSwap = (inSwap: BN) => {
@@ -2583,7 +2611,8 @@ export class User {
2583
2611
  spotPosition,
2584
2612
  spotMarketAccount,
2585
2613
  strictOraclePrice,
2586
- marginCategory
2614
+ marginCategory,
2615
+ this.getUserAccount().maxMarginRatio
2587
2616
  );
2588
2617
 
2589
2618
  return freeCollateralContribution;
@@ -2606,7 +2635,8 @@ export class User {
2606
2635
  spotPosition,
2607
2636
  spotMarketAccount,
2608
2637
  strictOraclePrice,
2609
- 'Initial'
2638
+ 'Initial',
2639
+ this.getUserAccount().maxMarginRatio
2610
2640
  );
2611
2641
 
2612
2642
  if (tokenValue.gte(ZERO)) {
@@ -2678,7 +2708,7 @@ export class User {
2678
2708
  );
2679
2709
 
2680
2710
  const { perpLiabilityValue, perpPnl, spotAssetValue, spotLiabilityValue } =
2681
- this.getLeverageComponents();
2711
+ this.getLeverageComponents(undefined, 'Initial');
2682
2712
 
2683
2713
  const inPositionAfter = this.cloneAndUpdateSpotPosition(
2684
2714
  inSpotPosition,
@@ -3225,7 +3255,8 @@ export class User {
3225
3255
  calculateMarketMarginRatio(
3226
3256
  perpMarket,
3227
3257
  worstCaseBaseAmount.abs(),
3228
- marginCategory
3258
+ marginCategory,
3259
+ this.getUserAccount().maxMarginRatio
3229
3260
  )
3230
3261
  );
3231
3262
 
@@ -3349,7 +3380,8 @@ export class User {
3349
3380
  spotPosition,
3350
3381
  spotMarketAccount,
3351
3382
  strictOraclePrice,
3352
- marginCategory
3383
+ marginCategory,
3384
+ this.getUserAccount().maxMarginRatio
3353
3385
  );
3354
3386
 
3355
3387
  netQuoteValue = netQuoteValue.add(ordersValue);
@@ -3393,7 +3425,8 @@ export class User {
3393
3425
  baseAssetValue,
3394
3426
  oraclePriceData.price,
3395
3427
  spotMarketAccount,
3396
- marginCategory
3428
+ marginCategory,
3429
+ this.getUserAccount().maxMarginRatio
3397
3430
  );
3398
3431
 
3399
3432
  if (netQuoteValue.lt(ZERO)) {
package/tests/amm/test.ts CHANGED
@@ -568,7 +568,8 @@ describe('AMM Tests', () => {
568
568
  mockMarket1.amm.maxBaseAssetReserve = mockMarket1.amm.baseAssetReserve.add(
569
569
  new BN(1234835)
570
570
  );
571
- mockMarket1.amm.minBaseAssetReserve = mockMarket1.amm.baseAssetReserve.sub(BASE_PRECISION);
571
+ mockMarket1.amm.minBaseAssetReserve =
572
+ mockMarket1.amm.baseAssetReserve.sub(BASE_PRECISION);
572
573
  mockMarket1.amm.quoteAssetReserve = new BN(cc).mul(BASE_PRECISION);
573
574
  mockMarket1.amm.pegMultiplier = new BN(18.32 * PEG_PRECISION.toNumber());
574
575
  mockMarket1.amm.sqrtK = new BN(cc).mul(BASE_PRECISION);
@@ -790,14 +791,14 @@ describe('AMM Tests', () => {
790
791
  assert(totalAskSize.sub(openAsks.abs()).lte(new BN(5))); // only tiny rounding errors
791
792
  });
792
793
 
793
-
794
794
  it('orderbook L2 gen (4 topOfBookQuoteAmounts, 10 numOrders, low bid liquidity)', async () => {
795
795
  const myMockPerpMarkets = _.cloneDeep(mockPerpMarkets);
796
796
 
797
797
  const mockMarket1: PerpMarketAccount = myMockPerpMarkets[0];
798
798
  const cc = 38104569;
799
799
  mockMarket1.amm.baseAssetReserve = new BN(cc).mul(BASE_PRECISION);
800
- mockMarket1.amm.maxBaseAssetReserve = mockMarket1.amm.baseAssetReserve.add(BASE_PRECISION); // only 1 base
800
+ mockMarket1.amm.maxBaseAssetReserve =
801
+ mockMarket1.amm.baseAssetReserve.add(BASE_PRECISION); // only 1 base
801
802
  mockMarket1.amm.minBaseAssetReserve = mockMarket1.amm.baseAssetReserve.div(
802
803
  new BN(2)
803
804
  );
@@ -873,14 +874,15 @@ describe('AMM Tests', () => {
873
874
  assert(totalAskSize.sub(openAsks.abs()).lte(new BN(5))); // only tiny rounding errors
874
875
  });
875
876
 
876
-
877
877
  it('orderbook L2 gen (4 topOfBookQuoteAmounts, 10 numOrders, low ask liquidity)', async () => {
878
878
  const myMockPerpMarkets = _.cloneDeep(mockPerpMarkets);
879
879
 
880
880
  const mockMarket1: PerpMarketAccount = myMockPerpMarkets[0];
881
881
  const cc = 38104569;
882
882
  mockMarket1.amm.baseAssetReserve = new BN(cc).mul(BASE_PRECISION);
883
- mockMarket1.amm.maxBaseAssetReserve = mockMarket1.amm.baseAssetReserve.add(BASE_PRECISION.mul(new BN(1000))); // 1000 base
883
+ mockMarket1.amm.maxBaseAssetReserve = mockMarket1.amm.baseAssetReserve.add(
884
+ BASE_PRECISION.mul(new BN(1000))
885
+ ); // 1000 base
884
886
  mockMarket1.amm.minBaseAssetReserve = mockMarket1.amm.baseAssetReserve.sub(
885
887
  BASE_PRECISION.div(new BN(2))
886
888
  ); // only .5 base
@@ -1,9 +1,8 @@
1
- import {PRICE_PRECISION, BN, deriveOracleAuctionParams} from "../../src";
2
- import {assert} from "chai";
3
- import {PositionDirection} from "../../lib";
1
+ import { PRICE_PRECISION, BN, deriveOracleAuctionParams } from '../../src';
2
+ import { assert } from 'chai';
3
+ import { PositionDirection } from '../../lib';
4
4
 
5
5
  describe('Auction Tests', () => {
6
-
7
6
  it('deriveOracleAuctionParams', async () => {
8
7
  let oraclePrice = new BN(100).mul(PRICE_PRECISION);
9
8
  let auctionStartPrice = new BN(90).mul(PRICE_PRECISION);
@@ -18,9 +17,15 @@ describe('Auction Tests', () => {
18
17
  limitPrice,
19
18
  });
20
19
 
21
- assert(oracleOrderParams.auctionStartPrice.eq(new BN(-10).mul(PRICE_PRECISION)));
22
- assert(oracleOrderParams.auctionEndPrice.eq(new BN(10).mul(PRICE_PRECISION)));
23
- assert(oracleOrderParams.oraclePriceOffset === 20 * PRICE_PRECISION.toNumber());
20
+ assert(
21
+ oracleOrderParams.auctionStartPrice.eq(new BN(-10).mul(PRICE_PRECISION))
22
+ );
23
+ assert(
24
+ oracleOrderParams.auctionEndPrice.eq(new BN(10).mul(PRICE_PRECISION))
25
+ );
26
+ assert(
27
+ oracleOrderParams.oraclePriceOffset === 20 * PRICE_PRECISION.toNumber()
28
+ );
24
29
 
25
30
  oracleOrderParams = deriveOracleAuctionParams({
26
31
  direction: PositionDirection.LONG,
@@ -47,9 +52,15 @@ describe('Auction Tests', () => {
47
52
  limitPrice,
48
53
  });
49
54
 
50
- assert(oracleOrderParams.auctionStartPrice.eq(new BN(10).mul(PRICE_PRECISION)));
51
- assert(oracleOrderParams.auctionEndPrice.eq(new BN(-10).mul(PRICE_PRECISION)));
52
- assert(oracleOrderParams.oraclePriceOffset === -20 * PRICE_PRECISION.toNumber());
55
+ assert(
56
+ oracleOrderParams.auctionStartPrice.eq(new BN(10).mul(PRICE_PRECISION))
57
+ );
58
+ assert(
59
+ oracleOrderParams.auctionEndPrice.eq(new BN(-10).mul(PRICE_PRECISION))
60
+ );
61
+ assert(
62
+ oracleOrderParams.oraclePriceOffset === -20 * PRICE_PRECISION.toNumber()
63
+ );
53
64
 
54
65
  oracleOrderParams = deriveOracleAuctionParams({
55
66
  direction: PositionDirection.SHORT,
@@ -63,4 +74,4 @@ describe('Auction Tests', () => {
63
74
  assert(oracleOrderParams.auctionEndPrice.eq(new BN(0)));
64
75
  assert(oracleOrderParams.oraclePriceOffset === -1);
65
76
  });
66
- });
77
+ });
@@ -21,7 +21,9 @@ import {
21
21
  OrderRecord,
22
22
  ZERO,
23
23
  ContractTier,
24
- SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION
24
+ SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION,
25
+ SPOT_MARKET_WEIGHT_PRECISION,
26
+ PRICE_PRECISION,
25
27
  } from '../../src';
26
28
 
27
29
  export const mockPerpPosition: PerpPosition = {
@@ -263,7 +265,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
263
265
  status: MarketStatus.ACTIVE,
264
266
  assetTier: AssetTier.COLLATERAL,
265
267
  name: [],
266
- maxTokenDeposits: new BN(1000000),
268
+ maxTokenDeposits: new BN(1000000 * QUOTE_PRECISION.toNumber()),
267
269
  marketIndex: 0,
268
270
  pubkey: PublicKey.default,
269
271
  mint: DevnetSpotMarkets[0].mint,
@@ -300,10 +302,10 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
300
302
  lastInterestTs: new BN(0),
301
303
  lastTwapTs: new BN(0),
302
304
  oracle: PublicKey.default,
303
- initialAssetWeight: 0,
304
- maintenanceAssetWeight: 0,
305
- initialLiabilityWeight: 0,
306
- maintenanceLiabilityWeight: 0,
305
+ initialAssetWeight: SPOT_MARKET_WEIGHT_PRECISION.toNumber(),
306
+ maintenanceAssetWeight: SPOT_MARKET_WEIGHT_PRECISION.toNumber(),
307
+ initialLiabilityWeight: SPOT_MARKET_WEIGHT_PRECISION.toNumber(),
308
+ maintenanceLiabilityWeight: SPOT_MARKET_WEIGHT_PRECISION.toNumber(),
307
309
  scaleInitialAssetWeightStart: new BN(0),
308
310
  imfFactor: 0,
309
311
  withdrawGuardThreshold: new BN(0),
@@ -325,18 +327,18 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
325
327
  flashLoanInitialTokenAmount: new BN(0),
326
328
  oracleSource: OracleSource.PYTH,
327
329
  historicalOracleData: {
328
- lastOraclePrice: new BN(0),
330
+ lastOraclePrice: PRICE_PRECISION,
329
331
  lastOracleConf: new BN(0),
330
332
  lastOracleDelay: new BN(0),
331
- lastOraclePriceTwap: new BN(0),
332
- lastOraclePriceTwap5Min: new BN(0),
333
+ lastOraclePriceTwap: PRICE_PRECISION,
334
+ lastOraclePriceTwap5Min: PRICE_PRECISION,
333
335
  lastOraclePriceTwapTs: new BN(0),
334
336
  },
335
337
  historicalIndexData: {
336
- lastIndexBidPrice: new BN(0),
337
- lastIndexAskPrice: new BN(0),
338
- lastIndexPriceTwap: new BN(0),
339
- lastIndexPriceTwap5Min: new BN(0),
338
+ lastIndexBidPrice: PRICE_PRECISION,
339
+ lastIndexAskPrice: PRICE_PRECISION,
340
+ lastIndexPriceTwap: PRICE_PRECISION,
341
+ lastIndexPriceTwap5Min: PRICE_PRECISION,
340
342
  lastIndexPriceTwapTs: new BN(0),
341
343
  },
342
344
  },
@@ -74,4 +74,4 @@ describe('PriorityFeeCalculator', () => {
74
74
  additionalFeeMicroLamports
75
75
  );
76
76
  });
77
- });
77
+ });