@strobelabs/perpcity-sdk 0.4.3 → 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
@@ -452,22 +452,17 @@ declare const PERP_MANAGER_ABI: readonly [{
452
452
  }, {
453
453
  readonly anonymous: false;
454
454
  readonly inputs: readonly [{
455
- readonly indexed: false;
456
- readonly internalType: "contract IFees";
457
- readonly name: "feesModule";
458
- readonly type: "address";
459
- }];
460
- readonly name: "FeesModuleRegistered";
461
- readonly type: "event";
462
- }, {
463
- readonly anonymous: false;
464
- readonly inputs: readonly [{
465
- readonly indexed: false;
466
- readonly internalType: "contract ILockupPeriod";
467
- readonly name: "lockupPeriodModule";
455
+ readonly indexed: true;
456
+ readonly internalType: "uint8";
457
+ readonly name: "moduleType";
458
+ readonly type: "uint8";
459
+ }, {
460
+ readonly indexed: true;
461
+ readonly internalType: "address";
462
+ readonly name: "module";
468
463
  readonly type: "address";
469
464
  }];
470
- readonly name: "LockupPeriodModuleRegistered";
465
+ readonly name: "ModuleRegistered";
471
466
  readonly type: "event";
472
467
  }, {
473
468
  readonly anonymous: false;
@@ -489,16 +484,6 @@ declare const PERP_MANAGER_ABI: readonly [{
489
484
  }];
490
485
  readonly name: "MarginAdjusted";
491
486
  readonly type: "event";
492
- }, {
493
- readonly anonymous: false;
494
- readonly inputs: readonly [{
495
- readonly indexed: false;
496
- readonly internalType: "contract IMarginRatios";
497
- readonly name: "marginRatiosModule";
498
- readonly type: "address";
499
- }];
500
- readonly name: "MarginRatiosModuleRegistered";
501
- readonly type: "event";
502
487
  }, {
503
488
  readonly anonymous: false;
504
489
  readonly inputs: readonly [{
@@ -639,12 +624,12 @@ declare const PERP_MANAGER_ABI: readonly [{
639
624
  }, {
640
625
  readonly indexed: false;
641
626
  readonly internalType: "int256";
642
- readonly name: "perpDelta";
627
+ readonly name: "exitPerpDelta";
643
628
  readonly type: "int256";
644
629
  }, {
645
630
  readonly indexed: false;
646
631
  readonly internalType: "int256";
647
- readonly name: "usdDelta";
632
+ readonly name: "exitUsdDelta";
648
633
  readonly type: "int256";
649
634
  }, {
650
635
  readonly indexed: false;
@@ -656,6 +641,36 @@ declare const PERP_MANAGER_ABI: readonly [{
656
641
  readonly internalType: "int24";
657
642
  readonly name: "tickUpper";
658
643
  readonly type: "int24";
644
+ }, {
645
+ readonly indexed: false;
646
+ readonly internalType: "int256";
647
+ readonly name: "netUsdDelta";
648
+ readonly type: "int256";
649
+ }, {
650
+ readonly indexed: false;
651
+ readonly internalType: "int256";
652
+ readonly name: "funding";
653
+ readonly type: "int256";
654
+ }, {
655
+ readonly indexed: false;
656
+ readonly internalType: "uint256";
657
+ readonly name: "utilizationFee";
658
+ readonly type: "uint256";
659
+ }, {
660
+ readonly indexed: false;
661
+ readonly internalType: "uint256";
662
+ readonly name: "adl";
663
+ readonly type: "uint256";
664
+ }, {
665
+ readonly indexed: false;
666
+ readonly internalType: "uint256";
667
+ readonly name: "liquidationFee";
668
+ readonly type: "uint256";
669
+ }, {
670
+ readonly indexed: false;
671
+ readonly internalType: "int256";
672
+ readonly name: "netMargin";
673
+ readonly type: "int256";
659
674
  }];
660
675
  readonly name: "PositionClosed";
661
676
  readonly type: "event";
@@ -714,16 +729,6 @@ declare const PERP_MANAGER_ABI: readonly [{
714
729
  }];
715
730
  readonly name: "PositionOpened";
716
731
  readonly type: "event";
717
- }, {
718
- readonly anonymous: false;
719
- readonly inputs: readonly [{
720
- readonly indexed: false;
721
- readonly internalType: "contract ISqrtPriceImpactLimit";
722
- readonly name: "sqrtPriceImpactLimitModule";
723
- readonly type: "address";
724
- }];
725
- readonly name: "SqrtPriceImpactLimitModuleRegistered";
726
- readonly type: "event";
727
732
  }, {
728
733
  readonly anonymous: false;
729
734
  readonly inputs: readonly [{
@@ -821,11 +826,11 @@ declare const PERP_MANAGER_ABI: readonly [{
821
826
  readonly type: "uint256";
822
827
  }, {
823
828
  readonly internalType: "int256";
824
- readonly name: "perpDelta";
829
+ readonly name: "usdDelta";
825
830
  readonly type: "int256";
826
831
  }, {
827
832
  readonly internalType: "uint128";
828
- readonly name: "usdLimit";
833
+ readonly name: "perpLimit";
829
834
  readonly type: "uint128";
830
835
  }];
831
836
  readonly internalType: "struct IPerpManager.AdjustNotionalParams";
@@ -1016,10 +1021,6 @@ declare const PERP_MANAGER_ABI: readonly [{
1016
1021
  readonly internalType: "contract ISqrtPriceImpactLimit";
1017
1022
  readonly name: "sqrtPriceImpactLimit";
1018
1023
  readonly type: "address";
1019
- }, {
1020
- readonly internalType: "uint160";
1021
- readonly name: "startingSqrtPriceX96";
1022
- readonly type: "uint160";
1023
1024
  }];
1024
1025
  readonly internalType: "struct IPerpManager.CreatePerpParams";
1025
1026
  readonly name: "params";
@@ -1109,53 +1110,15 @@ declare const PERP_MANAGER_ABI: readonly [{
1109
1110
  readonly type: "function";
1110
1111
  }, {
1111
1112
  readonly inputs: readonly [{
1112
- readonly internalType: "contract IFees";
1113
- readonly name: "";
1114
- readonly type: "address";
1115
- }];
1116
- readonly name: "isFeesRegistered";
1117
- readonly outputs: readonly [{
1118
- readonly internalType: "bool";
1119
- readonly name: "";
1120
- readonly type: "bool";
1121
- }];
1122
- readonly stateMutability: "view";
1123
- readonly type: "function";
1124
- }, {
1125
- readonly inputs: readonly [{
1126
- readonly internalType: "contract ILockupPeriod";
1127
- readonly name: "";
1128
- readonly type: "address";
1129
- }];
1130
- readonly name: "isLockupPeriodRegistered";
1131
- readonly outputs: readonly [{
1132
- readonly internalType: "bool";
1133
- readonly name: "";
1134
- readonly type: "bool";
1135
- }];
1136
- readonly stateMutability: "view";
1137
- readonly type: "function";
1138
- }, {
1139
- readonly inputs: readonly [{
1140
- readonly internalType: "contract IMarginRatios";
1141
- readonly name: "";
1142
- readonly type: "address";
1143
- }];
1144
- readonly name: "isMarginRatiosRegistered";
1145
- readonly outputs: readonly [{
1146
- readonly internalType: "bool";
1147
- readonly name: "";
1148
- readonly type: "bool";
1149
- }];
1150
- readonly stateMutability: "view";
1151
- readonly type: "function";
1152
- }, {
1153
- readonly inputs: readonly [{
1154
- readonly internalType: "contract ISqrtPriceImpactLimit";
1155
- readonly name: "";
1113
+ readonly internalType: "uint8";
1114
+ readonly name: "moduleType";
1115
+ readonly type: "uint8";
1116
+ }, {
1117
+ readonly internalType: "address";
1118
+ readonly name: "module";
1156
1119
  readonly type: "address";
1157
1120
  }];
1158
- readonly name: "isSqrtPriceImpactLimitRegistered";
1121
+ readonly name: "isModuleRegistered";
1159
1122
  readonly outputs: readonly [{
1160
1123
  readonly internalType: "bool";
1161
1124
  readonly name: "";
@@ -1425,13 +1388,17 @@ declare const PERP_MANAGER_ABI: readonly [{
1425
1388
  readonly name: "funding";
1426
1389
  readonly type: "int256";
1427
1390
  }, {
1428
- readonly internalType: "uint256";
1391
+ readonly internalType: "int256";
1429
1392
  readonly name: "netMargin";
1430
- readonly type: "uint256";
1393
+ readonly type: "int256";
1431
1394
  }, {
1432
1395
  readonly internalType: "bool";
1433
1396
  readonly name: "wasLiquidated";
1434
1397
  readonly type: "bool";
1398
+ }, {
1399
+ readonly internalType: "uint256";
1400
+ readonly name: "notional";
1401
+ readonly type: "uint256";
1435
1402
  }];
1436
1403
  readonly stateMutability: "nonpayable";
1437
1404
  readonly type: "function";
@@ -1539,41 +1506,53 @@ declare const PERP_MANAGER_ABI: readonly [{
1539
1506
  readonly type: "function";
1540
1507
  }, {
1541
1508
  readonly inputs: readonly [{
1542
- readonly internalType: "contract IFees";
1543
- readonly name: "feesModule";
1544
- readonly type: "address";
1545
- }];
1546
- readonly name: "registerFeesModule";
1547
- readonly outputs: readonly [];
1548
- readonly stateMutability: "nonpayable";
1549
- readonly type: "function";
1550
- }, {
1551
- readonly inputs: readonly [{
1552
- readonly internalType: "contract ILockupPeriod";
1553
- readonly name: "lockupPeriodModule";
1554
- readonly type: "address";
1509
+ readonly internalType: "PoolId";
1510
+ readonly name: "perpId";
1511
+ readonly type: "bytes32";
1512
+ }, {
1513
+ readonly internalType: "bool";
1514
+ readonly name: "zeroForOne";
1515
+ readonly type: "bool";
1516
+ }, {
1517
+ readonly internalType: "bool";
1518
+ readonly name: "isExactIn";
1519
+ readonly type: "bool";
1520
+ }, {
1521
+ readonly internalType: "uint256";
1522
+ readonly name: "amount";
1523
+ readonly type: "uint256";
1524
+ }, {
1525
+ readonly internalType: "uint160";
1526
+ readonly name: "sqrtPriceLimitX96";
1527
+ readonly type: "uint160";
1555
1528
  }];
1556
- readonly name: "registerLockupPeriodModule";
1557
- readonly outputs: readonly [];
1558
- readonly stateMutability: "nonpayable";
1559
- readonly type: "function";
1560
- }, {
1561
- readonly inputs: readonly [{
1562
- readonly internalType: "contract IMarginRatios";
1563
- readonly name: "marginRatiosModule";
1564
- readonly type: "address";
1529
+ readonly name: "quoteSwap";
1530
+ readonly outputs: readonly [{
1531
+ readonly internalType: "bytes";
1532
+ readonly name: "unexpectedReason";
1533
+ readonly type: "bytes";
1534
+ }, {
1535
+ readonly internalType: "int256";
1536
+ readonly name: "perpDelta";
1537
+ readonly type: "int256";
1538
+ }, {
1539
+ readonly internalType: "int256";
1540
+ readonly name: "usdDelta";
1541
+ readonly type: "int256";
1565
1542
  }];
1566
- readonly name: "registerMarginRatiosModule";
1567
- readonly outputs: readonly [];
1568
1543
  readonly stateMutability: "nonpayable";
1569
1544
  readonly type: "function";
1570
1545
  }, {
1571
1546
  readonly inputs: readonly [{
1572
- readonly internalType: "contract ISqrtPriceImpactLimit";
1573
- readonly name: "sqrtPriceImpactLimitModule";
1547
+ readonly internalType: "uint8";
1548
+ readonly name: "moduleType";
1549
+ readonly type: "uint8";
1550
+ }, {
1551
+ readonly internalType: "address";
1552
+ readonly name: "module";
1574
1553
  readonly type: "address";
1575
1554
  }];
1576
- readonly name: "registerSqrtPriceImpactLimitModule";
1555
+ readonly name: "registerModule";
1577
1556
  readonly outputs: readonly [];
1578
1557
  readonly stateMutability: "nonpayable";
1579
1558
  readonly type: "function";
@@ -1846,11 +1825,15 @@ type OpenMakerPositionParams = {
1846
1825
  priceLower: number;
1847
1826
  priceUpper: number;
1848
1827
  liquidity: bigint;
1849
- maxAmt0In: number | bigint;
1850
- maxAmt1In: number | bigint;
1828
+ slippageTolerance?: number;
1829
+ maxAmt0In?: number | bigint;
1830
+ maxAmt1In?: number | bigint;
1831
+ };
1832
+ type QuoteOpenMakerPositionResult = {
1833
+ perpDelta: bigint;
1834
+ usdDelta: bigint;
1851
1835
  };
1852
1836
  type CreatePerpParams = {
1853
- startingPrice: number;
1854
1837
  beacon: Address;
1855
1838
  fees?: Address;
1856
1839
  marginRatios?: Address;
@@ -6112,27 +6095,27 @@ declare class PerpCityContext {
6112
6095
  [x: `int24[${string}]`]: undefined;
6113
6096
  [x: `uint24[${string}]`]: undefined;
6114
6097
  [x: `uint128[${string}]`]: undefined;
6115
- [x: `uint160[${string}]`]: undefined;
6116
6098
  [x: `uint120[${string}]`]: undefined;
6099
+ [x: `uint160[${string}]`]: undefined;
6117
6100
  [x: `bytes4[${string}]`]: undefined;
6118
6101
  [x: `bytes1[${string}]`]: undefined;
6119
6102
  [x: `bytes2[${string}]`]: undefined;
6120
6103
  [x: `bytes3[${string}]`]: undefined;
6121
6104
  [x: `bytes25[${string}]`]: undefined;
6122
6105
  [x: `bytes6[${string}]`]: undefined;
6123
- [x: `bytes12[${string}]`]: undefined;
6106
+ [x: `bytes18[${string}]`]: undefined;
6124
6107
  [x: `bytes10[${string}]`]: undefined;
6125
6108
  [x: `bytes5[${string}]`]: undefined;
6126
6109
  [x: `bytes8[${string}]`]: undefined;
6127
6110
  [x: `bytes7[${string}]`]: undefined;
6128
6111
  [x: `bytes9[${string}]`]: undefined;
6129
6112
  [x: `bytes11[${string}]`]: undefined;
6113
+ [x: `bytes12[${string}]`]: undefined;
6130
6114
  [x: `bytes13[${string}]`]: undefined;
6131
6115
  [x: `bytes14[${string}]`]: undefined;
6132
6116
  [x: `bytes15[${string}]`]: undefined;
6133
6117
  [x: `bytes16[${string}]`]: undefined;
6134
6118
  [x: `bytes17[${string}]`]: undefined;
6135
- [x: `bytes18[${string}]`]: undefined;
6136
6119
  [x: `bytes19[${string}]`]: undefined;
6137
6120
  [x: `bytes20[${string}]`]: undefined;
6138
6121
  [x: `bytes21[${string}]`]: undefined;
@@ -6214,27 +6197,27 @@ declare class PerpCityContext {
6214
6197
  int24?: undefined;
6215
6198
  uint24?: undefined;
6216
6199
  uint128?: undefined;
6217
- uint160?: undefined;
6218
6200
  uint120?: undefined;
6201
+ uint160?: undefined;
6219
6202
  bytes4?: undefined;
6220
6203
  bytes1?: undefined;
6221
6204
  bytes2?: undefined;
6222
6205
  bytes3?: undefined;
6223
6206
  bytes25?: undefined;
6224
6207
  bytes6?: undefined;
6225
- bytes12?: undefined;
6208
+ bytes18?: undefined;
6226
6209
  bytes10?: undefined;
6227
6210
  bytes5?: undefined;
6228
6211
  bytes8?: undefined;
6229
6212
  bytes7?: undefined;
6230
6213
  bytes9?: undefined;
6231
6214
  bytes11?: undefined;
6215
+ bytes12?: undefined;
6232
6216
  bytes13?: undefined;
6233
6217
  bytes14?: undefined;
6234
6218
  bytes15?: undefined;
6235
6219
  bytes16?: undefined;
6236
6220
  bytes17?: undefined;
6237
- bytes18?: undefined;
6238
6221
  bytes19?: undefined;
6239
6222
  bytes20?: undefined;
6240
6223
  bytes21?: undefined;
@@ -6396,6 +6379,11 @@ declare function getPerpTickSpacing(perpData: PerpData): number;
6396
6379
 
6397
6380
  declare function createPerp(context: PerpCityContext, params: CreatePerpParams): Promise<Hex>;
6398
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>;
6399
6387
  declare function openMakerPosition(context: PerpCityContext, perpId: Hex, params: OpenMakerPositionParams): Promise<OpenPosition>;
6400
6388
 
6401
6389
  declare function getPositionPerpId(positionData: OpenPositionData): Hex;
@@ -6459,6 +6447,10 @@ declare function approveUsdc(context: PerpCityContext, amount: bigint, confirmat
6459
6447
  declare const NUMBER_1E6: number;
6460
6448
  declare const BIGINT_1E6: bigint;
6461
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;
6462
6454
 
6463
6455
  declare function priceToSqrtPriceX96(price: number): bigint;
6464
6456
  /**
@@ -6613,4 +6605,4 @@ interface RpcConfig {
6613
6605
  */
6614
6606
  declare function getRpcUrl(config?: RpcConfig): string;
6615
6607
 
6616
- 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 };