@strobelabs/perpcity-sdk 0.5.0 → 0.5.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/dist/index.d.mts CHANGED
@@ -1825,8 +1825,13 @@ type OpenMakerPositionParams = {
1825
1825
  priceLower: number;
1826
1826
  priceUpper: number;
1827
1827
  liquidity: bigint;
1828
- maxAmt0In: number | bigint;
1829
- maxAmt1In: number | bigint;
1828
+ slippageTolerance?: number;
1829
+ maxAmt0In?: number | bigint;
1830
+ maxAmt1In?: number | bigint;
1831
+ };
1832
+ type QuoteOpenMakerPositionResult = {
1833
+ perpDelta: bigint;
1834
+ usdDelta: bigint;
1830
1835
  };
1831
1836
  type CreatePerpParams = {
1832
1837
  beacon: Address;
@@ -6374,6 +6379,11 @@ declare function getPerpTickSpacing(perpData: PerpData): number;
6374
6379
 
6375
6380
  declare function createPerp(context: PerpCityContext, params: CreatePerpParams): Promise<Hex>;
6376
6381
  declare function openTakerPosition(context: PerpCityContext, perpId: Hex, params: OpenTakerPositionParams): Promise<OpenPosition>;
6382
+ declare function calculateAlignedTicks(priceLower: number, priceUpper: number, tickSpacing: number): {
6383
+ alignedTickLower: number;
6384
+ alignedTickUpper: number;
6385
+ };
6386
+ declare function quoteOpenMakerPosition(context: PerpCityContext, perpId: Hex, params: OpenMakerPositionParams): Promise<QuoteOpenMakerPositionResult>;
6377
6387
  declare function openMakerPosition(context: PerpCityContext, perpId: Hex, params: OpenMakerPositionParams): Promise<OpenPosition>;
6378
6388
 
6379
6389
  declare function getPositionPerpId(positionData: OpenPositionData): Hex;
@@ -6437,6 +6447,10 @@ declare function approveUsdc(context: PerpCityContext, amount: bigint, confirmat
6437
6447
  declare const NUMBER_1E6: number;
6438
6448
  declare const BIGINT_1E6: bigint;
6439
6449
  declare const Q96: bigint;
6450
+ declare const MIN_TICK = -887272;
6451
+ declare const MAX_TICK = 887272;
6452
+ declare const MIN_PRICE = 0.000001;
6453
+ declare const MAX_PRICE = 1000000;
6440
6454
 
6441
6455
  declare function priceToSqrtPriceX96(price: number): bigint;
6442
6456
  /**
@@ -6591,4 +6605,4 @@ interface RpcConfig {
6591
6605
  */
6592
6606
  declare function getRpcUrl(config?: RpcConfig): string;
6593
6607
 
6594
- export { BEACON_ABI, BIGINT_1E6, type Bounds, type CacheConfig, type ClosePositionParams, type ClosePositionResult, ContractError, type CreatePerpParams, ErrorCategory, type ErrorDebugInfo, ErrorSource, type Fees, InsufficientFundsError, type LiveDetails, type MarginRatios, NUMBER_1E6, type OpenMakerPositionParams, OpenPosition, type OpenPositionData, type OpenTakerPositionParams, PERP_MANAGER_ABI, PerpCityContext, type PerpCityContextConfig, type PerpCityDeployments, PerpCityError, type PerpConfig, type PerpData, type PositionRawData, Q96, RPCError, type RpcConfig, TransactionRejectedError, type UserData, ValidationError, approveUsdc, calculateEntryPrice, calculateLeverage, calculateLiquidationPrice, calculateLiquidityForTargetRatio, calculatePositionSize, calculatePositionValue, closePosition, createPerp, estimateLiquidity, getPerpBeacon, getPerpBounds, getPerpFees, getPerpMark, getPerpTickSpacing, getPositionEffectiveMargin, getPositionFundingPayment, getPositionId, getPositionIsLiquidatable, getPositionIsLong, getPositionIsMaker, getPositionLiveDetails, getPositionLiveDetailsFromContract, getPositionPerpId, getPositionPnl, getRpcUrl, getUserOpenPositions, getUserUsdcBalance, getUserWalletAddress, marginRatioToLeverage, openMakerPosition, openTakerPosition, parseContractError, priceToSqrtPriceX96, priceToTick, scale6Decimals, scaleFrom6Decimals, scaleFromX96, scaleToX96, sqrtPriceX96ToPrice, tickToPrice, withErrorHandling };
6608
+ export { BEACON_ABI, BIGINT_1E6, type Bounds, type CacheConfig, type ClosePositionParams, type ClosePositionResult, ContractError, type CreatePerpParams, ErrorCategory, type ErrorDebugInfo, ErrorSource, type Fees, InsufficientFundsError, type LiveDetails, MAX_PRICE, MAX_TICK, MIN_PRICE, MIN_TICK, type MarginRatios, NUMBER_1E6, type OpenMakerPositionParams, OpenPosition, type OpenPositionData, type OpenTakerPositionParams, PERP_MANAGER_ABI, PerpCityContext, type PerpCityContextConfig, type PerpCityDeployments, PerpCityError, type PerpConfig, type PerpData, type PositionRawData, Q96, type QuoteOpenMakerPositionResult, RPCError, type RpcConfig, TransactionRejectedError, type UserData, ValidationError, approveUsdc, calculateAlignedTicks, calculateEntryPrice, calculateLeverage, calculateLiquidationPrice, calculateLiquidityForTargetRatio, calculatePositionSize, calculatePositionValue, closePosition, createPerp, estimateLiquidity, getPerpBeacon, getPerpBounds, getPerpFees, getPerpMark, getPerpTickSpacing, getPositionEffectiveMargin, getPositionFundingPayment, getPositionId, getPositionIsLiquidatable, getPositionIsLong, getPositionIsMaker, getPositionLiveDetails, getPositionLiveDetailsFromContract, getPositionPerpId, getPositionPnl, getRpcUrl, getUserOpenPositions, getUserUsdcBalance, getUserWalletAddress, marginRatioToLeverage, openMakerPosition, openTakerPosition, parseContractError, priceToSqrtPriceX96, priceToTick, quoteOpenMakerPosition, scale6Decimals, scaleFrom6Decimals, scaleFromX96, scaleToX96, sqrtPriceX96ToPrice, tickToPrice, withErrorHandling };
package/dist/index.d.ts CHANGED
@@ -1825,8 +1825,13 @@ type OpenMakerPositionParams = {
1825
1825
  priceLower: number;
1826
1826
  priceUpper: number;
1827
1827
  liquidity: bigint;
1828
- maxAmt0In: number | bigint;
1829
- maxAmt1In: number | bigint;
1828
+ slippageTolerance?: number;
1829
+ maxAmt0In?: number | bigint;
1830
+ maxAmt1In?: number | bigint;
1831
+ };
1832
+ type QuoteOpenMakerPositionResult = {
1833
+ perpDelta: bigint;
1834
+ usdDelta: bigint;
1830
1835
  };
1831
1836
  type CreatePerpParams = {
1832
1837
  beacon: Address;
@@ -6374,6 +6379,11 @@ declare function getPerpTickSpacing(perpData: PerpData): number;
6374
6379
 
6375
6380
  declare function createPerp(context: PerpCityContext, params: CreatePerpParams): Promise<Hex>;
6376
6381
  declare function openTakerPosition(context: PerpCityContext, perpId: Hex, params: OpenTakerPositionParams): Promise<OpenPosition>;
6382
+ declare function calculateAlignedTicks(priceLower: number, priceUpper: number, tickSpacing: number): {
6383
+ alignedTickLower: number;
6384
+ alignedTickUpper: number;
6385
+ };
6386
+ declare function quoteOpenMakerPosition(context: PerpCityContext, perpId: Hex, params: OpenMakerPositionParams): Promise<QuoteOpenMakerPositionResult>;
6377
6387
  declare function openMakerPosition(context: PerpCityContext, perpId: Hex, params: OpenMakerPositionParams): Promise<OpenPosition>;
6378
6388
 
6379
6389
  declare function getPositionPerpId(positionData: OpenPositionData): Hex;
@@ -6437,6 +6447,10 @@ declare function approveUsdc(context: PerpCityContext, amount: bigint, confirmat
6437
6447
  declare const NUMBER_1E6: number;
6438
6448
  declare const BIGINT_1E6: bigint;
6439
6449
  declare const Q96: bigint;
6450
+ declare const MIN_TICK = -887272;
6451
+ declare const MAX_TICK = 887272;
6452
+ declare const MIN_PRICE = 0.000001;
6453
+ declare const MAX_PRICE = 1000000;
6440
6454
 
6441
6455
  declare function priceToSqrtPriceX96(price: number): bigint;
6442
6456
  /**
@@ -6591,4 +6605,4 @@ interface RpcConfig {
6591
6605
  */
6592
6606
  declare function getRpcUrl(config?: RpcConfig): string;
6593
6607
 
6594
- export { BEACON_ABI, BIGINT_1E6, type Bounds, type CacheConfig, type ClosePositionParams, type ClosePositionResult, ContractError, type CreatePerpParams, ErrorCategory, type ErrorDebugInfo, ErrorSource, type Fees, InsufficientFundsError, type LiveDetails, type MarginRatios, NUMBER_1E6, type OpenMakerPositionParams, OpenPosition, type OpenPositionData, type OpenTakerPositionParams, PERP_MANAGER_ABI, PerpCityContext, type PerpCityContextConfig, type PerpCityDeployments, PerpCityError, type PerpConfig, type PerpData, type PositionRawData, Q96, RPCError, type RpcConfig, TransactionRejectedError, type UserData, ValidationError, approveUsdc, calculateEntryPrice, calculateLeverage, calculateLiquidationPrice, calculateLiquidityForTargetRatio, calculatePositionSize, calculatePositionValue, closePosition, createPerp, estimateLiquidity, getPerpBeacon, getPerpBounds, getPerpFees, getPerpMark, getPerpTickSpacing, getPositionEffectiveMargin, getPositionFundingPayment, getPositionId, getPositionIsLiquidatable, getPositionIsLong, getPositionIsMaker, getPositionLiveDetails, getPositionLiveDetailsFromContract, getPositionPerpId, getPositionPnl, getRpcUrl, getUserOpenPositions, getUserUsdcBalance, getUserWalletAddress, marginRatioToLeverage, openMakerPosition, openTakerPosition, parseContractError, priceToSqrtPriceX96, priceToTick, scale6Decimals, scaleFrom6Decimals, scaleFromX96, scaleToX96, sqrtPriceX96ToPrice, tickToPrice, withErrorHandling };
6608
+ export { BEACON_ABI, BIGINT_1E6, type Bounds, type CacheConfig, type ClosePositionParams, type ClosePositionResult, ContractError, type CreatePerpParams, ErrorCategory, type ErrorDebugInfo, ErrorSource, type Fees, InsufficientFundsError, type LiveDetails, MAX_PRICE, MAX_TICK, MIN_PRICE, MIN_TICK, type MarginRatios, NUMBER_1E6, type OpenMakerPositionParams, OpenPosition, type OpenPositionData, type OpenTakerPositionParams, PERP_MANAGER_ABI, PerpCityContext, type PerpCityContextConfig, type PerpCityDeployments, PerpCityError, type PerpConfig, type PerpData, type PositionRawData, Q96, type QuoteOpenMakerPositionResult, RPCError, type RpcConfig, TransactionRejectedError, type UserData, ValidationError, approveUsdc, calculateAlignedTicks, calculateEntryPrice, calculateLeverage, calculateLiquidationPrice, calculateLiquidityForTargetRatio, calculatePositionSize, calculatePositionValue, closePosition, createPerp, estimateLiquidity, getPerpBeacon, getPerpBounds, getPerpFees, getPerpMark, getPerpTickSpacing, getPositionEffectiveMargin, getPositionFundingPayment, getPositionId, getPositionIsLiquidatable, getPositionIsLong, getPositionIsMaker, getPositionLiveDetails, getPositionLiveDetailsFromContract, getPositionPerpId, getPositionPnl, getRpcUrl, getUserOpenPositions, getUserUsdcBalance, getUserWalletAddress, marginRatioToLeverage, openMakerPosition, openTakerPosition, parseContractError, priceToSqrtPriceX96, priceToTick, quoteOpenMakerPosition, scale6Decimals, scaleFrom6Decimals, scaleFromX96, scaleToX96, sqrtPriceX96ToPrice, tickToPrice, withErrorHandling };
package/dist/index.js CHANGED
@@ -36,6 +36,10 @@ __export(index_exports, {
36
36
  ErrorCategory: () => ErrorCategory,
37
37
  ErrorSource: () => ErrorSource,
38
38
  InsufficientFundsError: () => InsufficientFundsError,
39
+ MAX_PRICE: () => MAX_PRICE,
40
+ MAX_TICK: () => MAX_TICK,
41
+ MIN_PRICE: () => MIN_PRICE,
42
+ MIN_TICK: () => MIN_TICK,
39
43
  NUMBER_1E6: () => NUMBER_1E6,
40
44
  OpenPosition: () => OpenPosition,
41
45
  PERP_MANAGER_ABI: () => PERP_MANAGER_ABI,
@@ -46,6 +50,7 @@ __export(index_exports, {
46
50
  TransactionRejectedError: () => TransactionRejectedError,
47
51
  ValidationError: () => ValidationError,
48
52
  approveUsdc: () => approveUsdc,
53
+ calculateAlignedTicks: () => calculateAlignedTicks,
49
54
  calculateEntryPrice: () => calculateEntryPrice,
50
55
  calculateLeverage: () => calculateLeverage,
51
56
  calculateLiquidationPrice: () => calculateLiquidationPrice,
@@ -80,6 +85,7 @@ __export(index_exports, {
80
85
  parseContractError: () => parseContractError,
81
86
  priceToSqrtPriceX96: () => priceToSqrtPriceX96,
82
87
  priceToTick: () => priceToTick,
88
+ quoteOpenMakerPosition: () => quoteOpenMakerPosition,
83
89
  scale6Decimals: () => scale6Decimals,
84
90
  scaleFrom6Decimals: () => scaleFrom6Decimals,
85
91
  scaleFromX96: () => scaleFromX96,
@@ -2462,6 +2468,10 @@ async function approveUsdc(context, amount, confirmations = DEFAULT_CONFIRMATION
2462
2468
  var NUMBER_1E6 = 1e6;
2463
2469
  var BIGINT_1E6 = 1000000n;
2464
2470
  var Q96 = 79228162514264337593543950336n;
2471
+ var MIN_TICK = -887272;
2472
+ var MAX_TICK = 887272;
2473
+ var MIN_PRICE = 1e-6;
2474
+ var MAX_PRICE = 1e6;
2465
2475
 
2466
2476
  // src/utils/conversions.ts
2467
2477
  function priceToSqrtPriceX96(price) {
@@ -2494,6 +2504,11 @@ function priceToTick(price, roundDown) {
2494
2504
  if (price <= 0) {
2495
2505
  throw new Error("Price must be positive");
2496
2506
  }
2507
+ if (price < MIN_PRICE || price > MAX_PRICE) {
2508
+ throw new Error(
2509
+ `Price ${price} is outside the representable range [${MIN_PRICE}, ${MAX_PRICE}]`
2510
+ );
2511
+ }
2497
2512
  const logPrice = Math.log(price) / Math.log(1.0001);
2498
2513
  return roundDown ? Math.floor(logPrice) : Math.ceil(logPrice);
2499
2514
  }
@@ -3555,7 +3570,9 @@ async function createPerp(context, params) {
3555
3570
  account: context.walletClient.account
3556
3571
  });
3557
3572
  const txHash = await context.walletClient.writeContract(request);
3558
- const receipt = await context.publicClient.waitForTransactionReceipt({ hash: txHash });
3573
+ const receipt = await context.publicClient.waitForTransactionReceipt({
3574
+ hash: txHash
3575
+ });
3559
3576
  if (receipt.status === "reverted") {
3560
3577
  throw new Error(`Transaction reverted. Hash: ${txHash}`);
3561
3578
  }
@@ -3622,7 +3639,9 @@ async function openTakerPosition(context, perpId, params) {
3622
3639
  account: context.walletClient.account
3623
3640
  });
3624
3641
  const txHash = await context.walletClient.writeContract(request);
3625
- const receipt = await context.publicClient.waitForTransactionReceipt({ hash: txHash });
3642
+ const receipt = await context.publicClient.waitForTransactionReceipt({
3643
+ hash: txHash
3644
+ });
3626
3645
  if (receipt.status === "reverted") {
3627
3646
  throw new Error(`Transaction reverted. Hash: ${txHash}`);
3628
3647
  }
@@ -3647,6 +3666,82 @@ async function openTakerPosition(context, perpId, params) {
3647
3666
  return new OpenPosition(context, perpId, takerPosId, params.isLong, false, txHash);
3648
3667
  }, "openTakerPosition");
3649
3668
  }
3669
+ function buildMakerContractParams(context, marginScaled, params, alignedTickLower, alignedTickUpper, maxAmt0In, maxAmt1In) {
3670
+ return {
3671
+ holder: context.walletClient.account.address,
3672
+ margin: marginScaled,
3673
+ liquidity: params.liquidity,
3674
+ tickLower: alignedTickLower,
3675
+ tickUpper: alignedTickUpper,
3676
+ maxAmt0In,
3677
+ maxAmt1In
3678
+ };
3679
+ }
3680
+ function calculateAlignedTicks(priceLower, priceUpper, tickSpacing) {
3681
+ const tickLower = priceToTick(priceLower, true);
3682
+ const tickUpper = priceToTick(priceUpper, false);
3683
+ const alignedTickLower = Math.floor(tickLower / tickSpacing) * tickSpacing;
3684
+ const alignedTickUpper = Math.ceil(tickUpper / tickSpacing) * tickSpacing;
3685
+ if (alignedTickLower < MIN_TICK) {
3686
+ throw new Error(
3687
+ `Lower tick ${alignedTickLower} is below MIN_TICK (${MIN_TICK}). Increase priceLower.`
3688
+ );
3689
+ }
3690
+ if (alignedTickUpper > MAX_TICK) {
3691
+ throw new Error(
3692
+ `Upper tick ${alignedTickUpper} exceeds MAX_TICK (${MAX_TICK}). Decrease priceUpper.`
3693
+ );
3694
+ }
3695
+ if (alignedTickLower === alignedTickUpper) {
3696
+ throw new Error(
3697
+ "Price range too narrow: lower and upper ticks are equal after alignment. Widen the range."
3698
+ );
3699
+ }
3700
+ return { alignedTickLower, alignedTickUpper };
3701
+ }
3702
+ function alignMakerTicks(params, tickSpacing) {
3703
+ return calculateAlignedTicks(params.priceLower, params.priceUpper, tickSpacing);
3704
+ }
3705
+ var DEFAULT_MAKER_SLIPPAGE_TOLERANCE = 0.01;
3706
+ var MAX_UINT128 = 2n ** 128n - 1n;
3707
+ async function quoteOpenMakerPosition(context, perpId, params) {
3708
+ return withErrorHandling(async () => {
3709
+ if (params.margin <= 0) {
3710
+ throw new Error("Margin must be greater than 0");
3711
+ }
3712
+ if (params.priceLower >= params.priceUpper) {
3713
+ throw new Error("priceLower must be less than priceUpper");
3714
+ }
3715
+ const marginScaled = scale6Decimals(params.margin);
3716
+ const perpData = await context.getPerpData(perpId);
3717
+ const { alignedTickLower, alignedTickUpper } = alignMakerTicks(params, perpData.tickSpacing);
3718
+ const contractParams = buildMakerContractParams(
3719
+ context,
3720
+ marginScaled,
3721
+ params,
3722
+ alignedTickLower,
3723
+ alignedTickUpper,
3724
+ MAX_UINT128,
3725
+ MAX_UINT128
3726
+ );
3727
+ const [unexpectedReason, perpDelta, usdDelta] = await context.publicClient.readContract({
3728
+ address: context.deployments().perpManager,
3729
+ abi: PERP_MANAGER_ABI,
3730
+ functionName: "quoteOpenMakerPosition",
3731
+ args: [perpId, contractParams]
3732
+ });
3733
+ if (unexpectedReason !== "0x") {
3734
+ throw new Error(`Quote failed: ${unexpectedReason}`);
3735
+ }
3736
+ return { perpDelta, usdDelta };
3737
+ }, "quoteOpenMakerPosition");
3738
+ }
3739
+ function applySlippage(delta, slippageTolerance) {
3740
+ if (delta >= 0n) return 0n;
3741
+ const absDelta = -delta;
3742
+ const slippageBps = BigInt(Math.ceil(slippageTolerance * 1e4));
3743
+ return absDelta + absDelta * slippageBps / 10000n;
3744
+ }
3650
3745
  async function openMakerPosition(context, perpId, params) {
3651
3746
  return withErrorHandling(async () => {
3652
3747
  if (params.margin <= 0) {
@@ -3656,8 +3751,24 @@ async function openMakerPosition(context, perpId, params) {
3656
3751
  throw new Error("priceLower must be less than priceUpper");
3657
3752
  }
3658
3753
  const marginScaled = scale6Decimals(params.margin);
3659
- const maxAmt0InScaled = typeof params.maxAmt0In === "bigint" ? params.maxAmt0In : scale6Decimals(params.maxAmt0In);
3660
- const maxAmt1InScaled = typeof params.maxAmt1In === "bigint" ? params.maxAmt1In : scale6Decimals(params.maxAmt1In);
3754
+ const perpData = await context.getPerpData(perpId);
3755
+ const { alignedTickLower, alignedTickUpper } = alignMakerTicks(params, perpData.tickSpacing);
3756
+ let maxAmt0In;
3757
+ let maxAmt1In;
3758
+ if (params.maxAmt0In === void 0 !== (params.maxAmt1In === void 0)) {
3759
+ throw new Error(
3760
+ "Both maxAmt0In and maxAmt1In must be provided together or neither. Omit both to use automatic quote-based slippage calculation."
3761
+ );
3762
+ }
3763
+ if (params.maxAmt0In !== void 0 && params.maxAmt1In !== void 0) {
3764
+ maxAmt0In = typeof params.maxAmt0In === "bigint" ? params.maxAmt0In : scale6Decimals(params.maxAmt0In);
3765
+ maxAmt1In = typeof params.maxAmt1In === "bigint" ? params.maxAmt1In : scale6Decimals(params.maxAmt1In);
3766
+ } else {
3767
+ const quote = await quoteOpenMakerPosition(context, perpId, params);
3768
+ const slippage = params.slippageTolerance ?? DEFAULT_MAKER_SLIPPAGE_TOLERANCE;
3769
+ maxAmt0In = applySlippage(quote.perpDelta, slippage);
3770
+ maxAmt1In = applySlippage(quote.usdDelta, slippage);
3771
+ }
3661
3772
  const currentAllowance = await context.publicClient.readContract({
3662
3773
  address: context.deployments().usdc,
3663
3774
  abi: import_viem5.erc20Abi,
@@ -3668,21 +3779,15 @@ async function openMakerPosition(context, perpId, params) {
3668
3779
  if (currentAllowance < marginScaled) {
3669
3780
  await approveUsdc(context, marginScaled);
3670
3781
  }
3671
- const perpData = await context.getPerpData(perpId);
3672
- const tickLower = priceToTick(params.priceLower, true);
3673
- const tickUpper = priceToTick(params.priceUpper, false);
3674
- const tickSpacing = perpData.tickSpacing;
3675
- const alignedTickLower = Math.floor(tickLower / tickSpacing) * tickSpacing;
3676
- const alignedTickUpper = Math.ceil(tickUpper / tickSpacing) * tickSpacing;
3677
- const contractParams = {
3678
- holder: context.walletClient.account.address,
3679
- margin: marginScaled,
3680
- liquidity: params.liquidity,
3681
- tickLower: alignedTickLower,
3682
- tickUpper: alignedTickUpper,
3683
- maxAmt0In: maxAmt0InScaled,
3684
- maxAmt1In: maxAmt1InScaled
3685
- };
3782
+ const contractParams = buildMakerContractParams(
3783
+ context,
3784
+ marginScaled,
3785
+ params,
3786
+ alignedTickLower,
3787
+ alignedTickUpper,
3788
+ maxAmt0In,
3789
+ maxAmt1In
3790
+ );
3686
3791
  const { request } = await context.publicClient.simulateContract({
3687
3792
  address: context.deployments().perpManager,
3688
3793
  abi: PERP_MANAGER_ABI,
@@ -3691,7 +3796,9 @@ async function openMakerPosition(context, perpId, params) {
3691
3796
  account: context.walletClient.account
3692
3797
  });
3693
3798
  const txHash = await context.walletClient.writeContract(request);
3694
- const receipt = await context.publicClient.waitForTransactionReceipt({ hash: txHash });
3799
+ const receipt = await context.publicClient.waitForTransactionReceipt({
3800
+ hash: txHash
3801
+ });
3695
3802
  if (receipt.status === "reverted") {
3696
3803
  throw new Error(`Transaction reverted. Hash: ${txHash}`);
3697
3804
  }
@@ -3879,6 +3986,10 @@ function getUserWalletAddress(userData) {
3879
3986
  ErrorCategory,
3880
3987
  ErrorSource,
3881
3988
  InsufficientFundsError,
3989
+ MAX_PRICE,
3990
+ MAX_TICK,
3991
+ MIN_PRICE,
3992
+ MIN_TICK,
3882
3993
  NUMBER_1E6,
3883
3994
  OpenPosition,
3884
3995
  PERP_MANAGER_ABI,
@@ -3889,6 +4000,7 @@ function getUserWalletAddress(userData) {
3889
4000
  TransactionRejectedError,
3890
4001
  ValidationError,
3891
4002
  approveUsdc,
4003
+ calculateAlignedTicks,
3892
4004
  calculateEntryPrice,
3893
4005
  calculateLeverage,
3894
4006
  calculateLiquidationPrice,
@@ -3923,6 +4035,7 @@ function getUserWalletAddress(userData) {
3923
4035
  parseContractError,
3924
4036
  priceToSqrtPriceX96,
3925
4037
  priceToTick,
4038
+ quoteOpenMakerPosition,
3926
4039
  scale6Decimals,
3927
4040
  scaleFrom6Decimals,
3928
4041
  scaleFromX96,