@continuumdao/ctm-mpc-defi 0.2.4 → 0.2.6

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.
@@ -554,6 +554,68 @@ declare function uniswapV4RegisterPositionNftPlaceholder(): never;
554
554
  declare function uniswapV4RegisterPositionFromMintTxPlaceholder(): never;
555
555
  declare function isNativeUniswapLpTokenAddress(token: string): boolean;
556
556
 
557
+ type UniswapV4PoolKeyInput = {
558
+ token0Address: string;
559
+ token1Address: string;
560
+ fee: number;
561
+ tickSpacing: number;
562
+ hooks?: string;
563
+ };
564
+ /** Sort currencies numerically (lower address = currency0). Native ETH stays `0x0`. */
565
+ declare function sortUniswapV4PoolCurrencies(token0Address: string, token1Address: string): {
566
+ currency0: Address;
567
+ currency1: Address;
568
+ };
569
+ /** V4 pool id = keccak256(abi.encode(PoolKey)). */
570
+ declare function computeUniswapV4PoolReference(args: UniswapV4PoolKeyInput): `0x${string}`;
571
+
572
+ declare const UNISWAP_V4_LP_POOL_LOOKUP_HINT = "Pool may not be initialized on this chain. Call ctm_uniswap_v4_list_lp_pools for other presets, pass a custom existingPool.poolReference, or use newPool to initialize a pool.";
573
+ type UniswapV4StandardLpPoolRow = {
574
+ presetId: string;
575
+ pairSlug: string;
576
+ pairLabel: string;
577
+ fee: number;
578
+ feeLabel: string;
579
+ tickSpacing: number;
580
+ token0Symbol: string;
581
+ token1Symbol: string;
582
+ token0Address: Address;
583
+ token1Address: Address;
584
+ poolReference: `0x${string}`;
585
+ hooks: Address;
586
+ nativeWrapped?: Address;
587
+ usesNativeEth: boolean;
588
+ };
589
+ declare function listUniswapV4StandardLpPools(args: {
590
+ chainId: number | string;
591
+ pair?: string;
592
+ }): {
593
+ chainId: number;
594
+ chainLabel: string;
595
+ pools: UniswapV4StandardLpPoolRow[];
596
+ notes: string;
597
+ };
598
+ declare function resolveUniswapV4LpPoolPreset(args: {
599
+ chainId: number | string;
600
+ presetId: string;
601
+ }): UniswapV4StandardLpPoolRow;
602
+ declare function resolveUniswapV4LpExistingPoolFromKey(args: {
603
+ token0Address: string;
604
+ token1Address: string;
605
+ fee: number;
606
+ tickSpacing: number;
607
+ hooks?: string;
608
+ poolReference?: string;
609
+ }): {
610
+ token0Address: Address;
611
+ token1Address: Address;
612
+ poolReference: `0x${string}`;
613
+ };
614
+ declare function uniswapV4ListStandardLpPools(args: {
615
+ chainId: number | string;
616
+ pair?: string;
617
+ }): ReturnType<typeof listUniswapV4StandardLpPools>;
618
+
557
619
  type UniswapV4SessionPayload = {
558
620
  chainId: number;
559
621
  rpcUrl: string;
@@ -620,4 +682,4 @@ declare const uniswapV4: {
620
682
  isChainSupported: typeof isUniswapV4ChainSupported;
621
683
  };
622
684
 
623
- export { MAX_UINT160, MAX_UINT48, PERMIT2_ADDRESS, type SwapExactInputArgs, UNISWAP_LP_API_BASE_DEFAULT, UNISWAP_LP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_LP_DEFAULT_EXPIRY_MINUTES, UNISWAP_LP_DEFAULT_SLIPPAGE_PERCENT, UNISWAP_SWAP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_SWAP_DEFAULT_EXPIRY_MINUTES, UNISWAP_TRADE_BASE_DEFAULT, UNISWAP_UNIVERSAL_ROUTER_DEFAULT_GAS_UNITS, UNISWAP_UNIVERSAL_ROUTER_VERSION_DEFAULT, UNISWAP_V4_LP_COLLECT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_DECREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK, UNISWAP_V4_LP_INCREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_LOG_CHUNK_SIZE_DEFAULT, UNISWAP_V4_LP_LOG_CHUNK_SIZE_MIN, UNISWAP_V4_LP_MINT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_POSITION_REGISTRY_HINT, UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK, UNISWAP_V4_PROTOCOL_ID, type UniswapLpAction, type UniswapLpExistingPool, type UniswapLpIndependentToken, type UniswapLpNewPool, type UniswapLpPriceBounds, type UniswapLpProtocol, type UniswapLpTickBounds, type UniswapLpTokenAmount, type UniswapLpTransactionRequest, type UniswapQuoteTradeType, type UniswapTradeQuoteParams, type UniswapV4PositionRow, type UniswapV4PositionScanProgress, type UniswapV4RegistryErc721Row, type UniswapV4SessionPayload, applySlippagePercentToApproveWei, buildEvmMultisignBodyUniswapV4CollectFeesBatch, buildEvmMultisignBodyUniswapV4DecreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4IncreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4MintLiquidityBatch, buildEvmMultisignBodyUniswapV4SkipPermit2Batch, buildUniswapQuoteRequestBody, buildUniswapV4PurposePrefill, computeUniswapV4Session, createSwap, errorMessageFromUniswapJsonBody, extractUniswapLpTokenAmounts, extractUniswapLpTransaction, fetchEthereumAddressForKeyGen, formatUniswapAmountFieldFromWei, formatUniswapLpAmountHuman, formatUniswapPercentForUi, formatUniswapQuoteForDisplay, formatUniswapV4PositionNotFoundError, getClassicQuoteFromStoredUniswapResponse, getUniswapUniversalRouterSpenderOrThrow, getUniswapV4PositionManagerDeployBlock, getUniswapV4PositionManagerOrThrow, isEthGetLogsBlockRangeTooLargeError, isNativeUniswapLpTokenAddress, isUniswapFullQuoteResponseNativeIn, isUniswapTokenInAddressNative, isUniswapV4ChainSupported, isUniswapV4LiquidityEvmSignRequest, isUniswapV4SwapEvmSignRequest, listUniswapV4PositionsForWallet, messageFromUniswapHttpResponseBody, parseUniswapChainId, parseUniswapLpApiSnapshot, parseUniswapQuoteClassicInOut, parseUniswapQuoteSlippageInfo, parseUniswapV4ScanFromDateYmd, quoteSwap, readUniswapV4PositionInfoRaw, resolveBlockAtOrAfterUnixTime, resolveRouterSwapGasUnitsFromSignRequest, resolveUniswapV4PositionScanFromDate, swapExactInput, swapFromQuote, swapTransactionDeadlineUnixFromExpiryMinutes, tryGetUniswapV4PositionManager, uniswapCreateSwap, uniswapLpClaimFees, uniswapLpCreatePosition, uniswapLpDecreasePosition, uniswapLpIncreasePosition, uniswapLpTxFieldForAction, uniswapQuoteToJsonQuoteOneLine, uniswapTradeQuote, uniswapV4, uniswapV4ListPositionsForMcp, uniswapV4ListPositionsFromRegistryForMcp, uniswapV4ListPositionsRegistryMcpPlaceholder, uniswapV4PositionMintedTokenIdsFromReceipt, uniswapV4ProtocolModule, uniswapV4RegisterPositionFromMintTxPlaceholder, uniswapV4RegisterPositionNftPlaceholder };
685
+ export { MAX_UINT160, MAX_UINT48, PERMIT2_ADDRESS, type SwapExactInputArgs, UNISWAP_LP_API_BASE_DEFAULT, UNISWAP_LP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_LP_DEFAULT_EXPIRY_MINUTES, UNISWAP_LP_DEFAULT_SLIPPAGE_PERCENT, UNISWAP_SWAP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_SWAP_DEFAULT_EXPIRY_MINUTES, UNISWAP_TRADE_BASE_DEFAULT, UNISWAP_UNIVERSAL_ROUTER_DEFAULT_GAS_UNITS, UNISWAP_UNIVERSAL_ROUTER_VERSION_DEFAULT, UNISWAP_V4_LP_COLLECT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_DECREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK, UNISWAP_V4_LP_INCREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_LOG_CHUNK_SIZE_DEFAULT, UNISWAP_V4_LP_LOG_CHUNK_SIZE_MIN, UNISWAP_V4_LP_MINT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_POOL_LOOKUP_HINT, UNISWAP_V4_LP_POSITION_REGISTRY_HINT, UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK, UNISWAP_V4_PROTOCOL_ID, type UniswapLpAction, type UniswapLpExistingPool, type UniswapLpIndependentToken, type UniswapLpNewPool, type UniswapLpPriceBounds, type UniswapLpProtocol, type UniswapLpTickBounds, type UniswapLpTokenAmount, type UniswapLpTransactionRequest, type UniswapQuoteTradeType, type UniswapTradeQuoteParams, type UniswapV4PoolKeyInput, type UniswapV4PositionRow, type UniswapV4PositionScanProgress, type UniswapV4RegistryErc721Row, type UniswapV4SessionPayload, type UniswapV4StandardLpPoolRow, applySlippagePercentToApproveWei, buildEvmMultisignBodyUniswapV4CollectFeesBatch, buildEvmMultisignBodyUniswapV4DecreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4IncreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4MintLiquidityBatch, buildEvmMultisignBodyUniswapV4SkipPermit2Batch, buildUniswapQuoteRequestBody, buildUniswapV4PurposePrefill, computeUniswapV4PoolReference, computeUniswapV4Session, createSwap, errorMessageFromUniswapJsonBody, extractUniswapLpTokenAmounts, extractUniswapLpTransaction, fetchEthereumAddressForKeyGen, formatUniswapAmountFieldFromWei, formatUniswapLpAmountHuman, formatUniswapPercentForUi, formatUniswapQuoteForDisplay, formatUniswapV4PositionNotFoundError, getClassicQuoteFromStoredUniswapResponse, getUniswapUniversalRouterSpenderOrThrow, getUniswapV4PositionManagerDeployBlock, getUniswapV4PositionManagerOrThrow, isEthGetLogsBlockRangeTooLargeError, isNativeUniswapLpTokenAddress, isUniswapFullQuoteResponseNativeIn, isUniswapTokenInAddressNative, isUniswapV4ChainSupported, isUniswapV4LiquidityEvmSignRequest, isUniswapV4SwapEvmSignRequest, listUniswapV4PositionsForWallet, listUniswapV4StandardLpPools, messageFromUniswapHttpResponseBody, parseUniswapChainId, parseUniswapLpApiSnapshot, parseUniswapQuoteClassicInOut, parseUniswapQuoteSlippageInfo, parseUniswapV4ScanFromDateYmd, quoteSwap, readUniswapV4PositionInfoRaw, resolveBlockAtOrAfterUnixTime, resolveRouterSwapGasUnitsFromSignRequest, resolveUniswapV4LpExistingPoolFromKey, resolveUniswapV4LpPoolPreset, resolveUniswapV4PositionScanFromDate, sortUniswapV4PoolCurrencies, swapExactInput, swapFromQuote, swapTransactionDeadlineUnixFromExpiryMinutes, tryGetUniswapV4PositionManager, uniswapCreateSwap, uniswapLpClaimFees, uniswapLpCreatePosition, uniswapLpDecreasePosition, uniswapLpIncreasePosition, uniswapLpTxFieldForAction, uniswapQuoteToJsonQuoteOneLine, uniswapTradeQuote, uniswapV4, uniswapV4ListPositionsForMcp, uniswapV4ListPositionsFromRegistryForMcp, uniswapV4ListPositionsRegistryMcpPlaceholder, uniswapV4ListStandardLpPools, uniswapV4PositionMintedTokenIdsFromReceipt, uniswapV4ProtocolModule, uniswapV4RegisterPositionFromMintTxPlaceholder, uniswapV4RegisterPositionNftPlaceholder };
@@ -1,4 +1,4 @@
1
- import { parseAbi, parseAbiItem, getAddress, zeroAddress, formatUnits, parseUnits, encodeFunctionData, erc20Abi, decodeEventLog, defineChain, createPublicClient, http, decodeFunctionData, parseGwei, serializeTransaction, keccak256 } from 'viem';
1
+ import { parseAbiParameters, parseAbi, parseAbiItem, getAddress, zeroAddress, formatUnits, parseUnits, encodeFunctionData, erc20Abi, keccak256, encodeAbiParameters, decodeEventLog, defineChain, createPublicClient, http, decodeFunctionData, parseGwei, serializeTransaction } from 'viem';
2
2
  import { nodeFetchWithReadAuth, fetchChainFeeParams, gasLimitFromEstimateAndChainConfig, gweiToDecimalString, proposalTxParamsToFeeSnapshot, alignEip1559FeesWithLatestBase, getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk';
3
3
 
4
4
  // src/core/registry.ts
@@ -1376,6 +1376,223 @@ async function buildEvmMultisignBodyUniswapV4SkipPermit2Batch(args) {
1376
1376
  }
1377
1377
  });
1378
1378
  }
1379
+ var POOL_KEY_ABI = parseAbiParameters(
1380
+ "address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"
1381
+ );
1382
+ var ZERO_HOOKS = "0x0000000000000000000000000000000000000000";
1383
+ function sortUniswapV4PoolCurrencies(token0Address, token1Address) {
1384
+ const a = normalizePoolCurrency(token0Address);
1385
+ const b = normalizePoolCurrency(token1Address);
1386
+ if (a.toLowerCase() === b.toLowerCase()) {
1387
+ throw new Error("Pool tokens must be distinct.");
1388
+ }
1389
+ return a.toLowerCase() < b.toLowerCase() ? { currency0: a, currency1: b } : { currency0: b, currency1: a };
1390
+ }
1391
+ function normalizePoolCurrency(raw) {
1392
+ const trimmed = raw.trim();
1393
+ if (!trimmed) {
1394
+ throw new Error("Pool token address is required.");
1395
+ }
1396
+ const lower = trimmed.toLowerCase();
1397
+ if (lower === "eth" || lower === "native" || lower === "native_eth" || lower === zeroAddress.toLowerCase()) {
1398
+ return zeroAddress;
1399
+ }
1400
+ return getAddress(trimmed);
1401
+ }
1402
+ function computeUniswapV4PoolReference(args) {
1403
+ const { currency0, currency1 } = sortUniswapV4PoolCurrencies(
1404
+ args.token0Address,
1405
+ args.token1Address
1406
+ );
1407
+ const hooks = args.hooks?.trim() && args.hooks.trim() !== "0x" ? getAddress(args.hooks.trim()) : ZERO_HOOKS;
1408
+ return keccak256(
1409
+ encodeAbiParameters(POOL_KEY_ABI, [
1410
+ currency0,
1411
+ currency1,
1412
+ args.fee,
1413
+ args.tickSpacing,
1414
+ hooks
1415
+ ])
1416
+ );
1417
+ }
1418
+
1419
+ // src/protocols/evm/uniswap-v4/knownLpPools.ts
1420
+ var ZERO_HOOKS2 = "0x0000000000000000000000000000000000000000";
1421
+ var UNISWAP_V4_LP_POOL_LOOKUP_HINT = "Pool may not be initialized on this chain. Call ctm_uniswap_v4_list_lp_pools for other presets, pass a custom existingPool.poolReference, or use newPool to initialize a pool.";
1422
+ var FEE_TIERS = [
1423
+ { fee: 500, feeLabel: "0.05%", tickSpacing: 10 },
1424
+ { fee: 3e3, feeLabel: "0.3%", tickSpacing: 60 },
1425
+ { fee: 1e4, feeLabel: "1%", tickSpacing: 200 }
1426
+ ];
1427
+ var CHAIN_LP_CONFIGS = [
1428
+ {
1429
+ chainId: 1,
1430
+ chainLabel: "Ethereum",
1431
+ nativeWrapped: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
1432
+ tokens: {
1433
+ eth: { symbol: "ETH", address: "0x0000000000000000000000000000000000000000", native: true },
1434
+ usdc: { symbol: "USDC", address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" },
1435
+ usdt: { symbol: "USDT", address: "0xdAC17F958D2ee523a2206206994597C13D831ec7" },
1436
+ wbtc: { symbol: "WBTC", address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" }
1437
+ },
1438
+ pairs: [
1439
+ { slug: "eth-usdc", label: "ETH/USDC", token0Key: "eth", token1Key: "usdc", tiers: [...FEE_TIERS] },
1440
+ { slug: "eth-usdt", label: "ETH/USDT", token0Key: "eth", token1Key: "usdt", tiers: [...FEE_TIERS] },
1441
+ { slug: "eth-wbtc", label: "ETH/WBTC", token0Key: "eth", token1Key: "wbtc", tiers: [...FEE_TIERS] }
1442
+ ]
1443
+ },
1444
+ {
1445
+ chainId: 8453,
1446
+ chainLabel: "Base",
1447
+ nativeWrapped: "0x4200000000000000000000000000000000000006",
1448
+ tokens: {
1449
+ eth: { symbol: "ETH", address: "0x0000000000000000000000000000000000000000", native: true },
1450
+ usdc: { symbol: "USDC", address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }
1451
+ },
1452
+ pairs: [
1453
+ { slug: "eth-usdc", label: "ETH/USDC", token0Key: "eth", token1Key: "usdc", tiers: [...FEE_TIERS] }
1454
+ ]
1455
+ },
1456
+ {
1457
+ chainId: 42161,
1458
+ chainLabel: "Arbitrum",
1459
+ nativeWrapped: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
1460
+ tokens: {
1461
+ eth: { symbol: "ETH", address: "0x0000000000000000000000000000000000000000", native: true },
1462
+ usdc: { symbol: "USDC", address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" }
1463
+ },
1464
+ pairs: [
1465
+ { slug: "eth-usdc", label: "ETH/USDC", token0Key: "eth", token1Key: "usdc", tiers: [...FEE_TIERS] }
1466
+ ]
1467
+ },
1468
+ {
1469
+ chainId: 10,
1470
+ chainLabel: "Optimism",
1471
+ nativeWrapped: "0x4200000000000000000000000000000000000006",
1472
+ tokens: {
1473
+ eth: { symbol: "ETH", address: "0x0000000000000000000000000000000000000000", native: true },
1474
+ usdc: { symbol: "USDC", address: "0x0b2C639c533813f4Aa9D7837CAa646c993D1B7926" }
1475
+ },
1476
+ pairs: [
1477
+ { slug: "eth-usdc", label: "ETH/USDC", token0Key: "eth", token1Key: "usdc", tiers: [...FEE_TIERS] }
1478
+ ]
1479
+ },
1480
+ {
1481
+ chainId: 137,
1482
+ chainLabel: "Polygon",
1483
+ nativeWrapped: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
1484
+ tokens: {
1485
+ eth: { symbol: "ETH", address: "0x0000000000000000000000000000000000000000", native: true },
1486
+ usdc: { symbol: "USDC", address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359" }
1487
+ },
1488
+ pairs: [
1489
+ { slug: "eth-usdc", label: "ETH/USDC", token0Key: "eth", token1Key: "usdc", tiers: [...FEE_TIERS] }
1490
+ ]
1491
+ }
1492
+ ];
1493
+ function buildPresetId(pairSlug, feeLabel) {
1494
+ const feeSlug = feeLabel.replace("%", "").replace(".", "-");
1495
+ return `${pairSlug}-${feeSlug}`;
1496
+ }
1497
+ function buildPoolRows(config) {
1498
+ const rows = [];
1499
+ for (const pair of config.pairs) {
1500
+ const token0 = config.tokens[pair.token0Key];
1501
+ const token1 = config.tokens[pair.token1Key];
1502
+ if (!token0 || !token1) continue;
1503
+ for (const tier of pair.tiers) {
1504
+ const poolReference = computeUniswapV4PoolReference({
1505
+ token0Address: token0.address,
1506
+ token1Address: token1.address,
1507
+ fee: tier.fee,
1508
+ tickSpacing: tier.tickSpacing,
1509
+ hooks: ZERO_HOOKS2
1510
+ });
1511
+ const usesNativeEth = Boolean(token0.native || token1.native);
1512
+ rows.push({
1513
+ presetId: buildPresetId(pair.slug, tier.feeLabel),
1514
+ pairSlug: pair.slug,
1515
+ pairLabel: pair.label,
1516
+ fee: tier.fee,
1517
+ feeLabel: tier.feeLabel,
1518
+ tickSpacing: tier.tickSpacing,
1519
+ token0Symbol: token0.symbol,
1520
+ token1Symbol: token1.symbol,
1521
+ token0Address: getAddress(token0.address),
1522
+ token1Address: getAddress(token1.address),
1523
+ poolReference,
1524
+ hooks: ZERO_HOOKS2,
1525
+ nativeWrapped: usesNativeEth ? getAddress(config.nativeWrapped) : void 0,
1526
+ usesNativeEth
1527
+ });
1528
+ }
1529
+ }
1530
+ return rows;
1531
+ }
1532
+ function chainConfigOrThrow(chainId) {
1533
+ const config = CHAIN_LP_CONFIGS.find((row) => row.chainId === chainId);
1534
+ if (!config) {
1535
+ throw new Error(
1536
+ `No standard Uniswap V4 LP pool catalog for chainId ${chainId}. Supported catalog chains: ${CHAIN_LP_CONFIGS.map((c) => c.chainId).join(", ")}.`
1537
+ );
1538
+ }
1539
+ if (!isUniswapV4ChainSupported(chainId)) {
1540
+ throw new Error(`chainId ${chainId} is not supported for Uniswap V4 MCP tools.`);
1541
+ }
1542
+ return config;
1543
+ }
1544
+ function listUniswapV4StandardLpPools(args) {
1545
+ const chainId = parseUniswapChainId(args.chainId);
1546
+ const config = chainConfigOrThrow(chainId);
1547
+ let pools = buildPoolRows(config);
1548
+ const pairFilter = args.pair?.trim().toLowerCase();
1549
+ if (pairFilter) {
1550
+ pools = pools.filter(
1551
+ (row) => row.pairSlug.includes(pairFilter) || row.pairLabel.toLowerCase().includes(pairFilter) || row.presetId.includes(pairFilter)
1552
+ );
1553
+ }
1554
+ return {
1555
+ chainId,
1556
+ chainLabel: config.chainLabel,
1557
+ pools,
1558
+ notes: "poolReference is derived from token addresses, fee, tickSpacing, and hooks (no-hook pools). Pass presetId to ctm_uniswap_v4_lp_create_position as poolPreset, or copy existingPool fields. If LP create fails, the pool may not exist on-chain \u2014 try another preset, pass poolReference manually, or use newPool."
1559
+ };
1560
+ }
1561
+ function resolveUniswapV4LpPoolPreset(args) {
1562
+ const chainId = parseUniswapChainId(args.chainId);
1563
+ const preset = args.presetId.trim().toLowerCase();
1564
+ const row = buildPoolRows(chainConfigOrThrow(chainId)).find(
1565
+ (pool) => pool.presetId.toLowerCase() === preset
1566
+ );
1567
+ if (!row) {
1568
+ throw new Error(
1569
+ `Unknown LP pool preset "${args.presetId}" on chainId ${chainId}. Call ctm_uniswap_v4_list_lp_pools to list standard presets.`
1570
+ );
1571
+ }
1572
+ return row;
1573
+ }
1574
+ function resolveUniswapV4LpExistingPoolFromKey(args) {
1575
+ const poolReference = args.poolReference?.trim() || computeUniswapV4PoolReference({
1576
+ token0Address: args.token0Address,
1577
+ token1Address: args.token1Address,
1578
+ fee: args.fee,
1579
+ tickSpacing: args.tickSpacing,
1580
+ hooks: args.hooks
1581
+ });
1582
+ const sorted = sortTokensForExistingPool(args.token0Address, args.token1Address);
1583
+ return {
1584
+ token0Address: sorted.token0Address,
1585
+ token1Address: sorted.token1Address,
1586
+ poolReference
1587
+ };
1588
+ }
1589
+ function sortTokensForExistingPool(token0Address, token1Address) {
1590
+ const sorted = sortUniswapV4PoolCurrencies(token0Address, token1Address);
1591
+ return { token0Address: sorted.currency0, token1Address: sorted.currency1 };
1592
+ }
1593
+ function uniswapV4ListStandardLpPools(args) {
1594
+ return listUniswapV4StandardLpPools(args);
1595
+ }
1379
1596
 
1380
1597
  // src/protocols/evm/uniswap-v4/liquidityApi.ts
1381
1598
  var LP_HEADERS_BASE = {
@@ -1440,9 +1657,9 @@ async function postUniswapLpApi(args) {
1440
1657
  });
1441
1658
  const text = await res.text();
1442
1659
  if (!res.ok) {
1443
- throw new Error(
1444
- `Uniswap LP POST /${args.path} failed: ${messageFromUniswapHttpResponseBody(text, res.status, res.statusText)}`
1445
- );
1660
+ const base2 = messageFromUniswapHttpResponseBody(text, res.status, res.statusText);
1661
+ const hint = args.path === "create" && args.body.existingPool ? ` ${UNISWAP_V4_LP_POOL_LOOKUP_HINT}` : "";
1662
+ throw new Error(`Uniswap LP POST /${args.path} failed: ${base2}${hint}`);
1446
1663
  }
1447
1664
  return JSON.parse(text);
1448
1665
  }
@@ -2401,6 +2618,6 @@ var uniswapV4 = {
2401
2618
  isChainSupported: isUniswapV4ChainSupported
2402
2619
  };
2403
2620
 
2404
- export { MAX_UINT160, MAX_UINT48, PERMIT2_ADDRESS, UNISWAP_LP_API_BASE_DEFAULT, UNISWAP_LP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_LP_DEFAULT_EXPIRY_MINUTES, UNISWAP_LP_DEFAULT_SLIPPAGE_PERCENT, UNISWAP_SWAP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_SWAP_DEFAULT_EXPIRY_MINUTES, UNISWAP_TRADE_BASE_DEFAULT, UNISWAP_UNIVERSAL_ROUTER_DEFAULT_GAS_UNITS, UNISWAP_UNIVERSAL_ROUTER_VERSION_DEFAULT, UNISWAP_V4_LP_COLLECT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_DECREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK, UNISWAP_V4_LP_INCREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_LOG_CHUNK_SIZE_DEFAULT, UNISWAP_V4_LP_LOG_CHUNK_SIZE_MIN, UNISWAP_V4_LP_MINT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_POSITION_REGISTRY_HINT, UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK, UNISWAP_V4_PROTOCOL_ID, applySlippagePercentToApproveWei, buildEvmMultisignBodyUniswapV4CollectFeesBatch, buildEvmMultisignBodyUniswapV4DecreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4IncreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4MintLiquidityBatch, buildEvmMultisignBodyUniswapV4SkipPermit2Batch, buildUniswapQuoteRequestBody, buildUniswapV4PurposePrefill, computeUniswapV4Session, createSwap, errorMessageFromUniswapJsonBody, extractUniswapLpTokenAmounts, extractUniswapLpTransaction, fetchEthereumAddressForKeyGen, formatUniswapAmountFieldFromWei, formatUniswapLpAmountHuman, formatUniswapPercentForUi, formatUniswapQuoteForDisplay, formatUniswapV4PositionNotFoundError, getClassicQuoteFromStoredUniswapResponse, getUniswapUniversalRouterSpenderOrThrow, getUniswapV4PositionManagerDeployBlock, getUniswapV4PositionManagerOrThrow, isEthGetLogsBlockRangeTooLargeError, isNativeUniswapLpTokenAddress, isUniswapFullQuoteResponseNativeIn, isUniswapTokenInAddressNative, isUniswapV4ChainSupported, isUniswapV4LiquidityEvmSignRequest, isUniswapV4SwapEvmSignRequest, listUniswapV4PositionsForWallet, messageFromUniswapHttpResponseBody, parseUniswapChainId, parseUniswapLpApiSnapshot, parseUniswapQuoteClassicInOut, parseUniswapQuoteSlippageInfo, parseUniswapV4ScanFromDateYmd, quoteSwap, readUniswapV4PositionInfoRaw, resolveBlockAtOrAfterUnixTime, resolveRouterSwapGasUnitsFromSignRequest, resolveUniswapV4PositionScanFromDate, swapExactInput, swapFromQuote, swapTransactionDeadlineUnixFromExpiryMinutes, tryGetUniswapV4PositionManager, uniswapCreateSwap, uniswapLpClaimFees, uniswapLpCreatePosition, uniswapLpDecreasePosition, uniswapLpIncreasePosition, uniswapLpTxFieldForAction, uniswapQuoteToJsonQuoteOneLine, uniswapTradeQuote, uniswapV4, uniswapV4ListPositionsForMcp, uniswapV4ListPositionsFromRegistryForMcp, uniswapV4ListPositionsRegistryMcpPlaceholder, uniswapV4PositionMintedTokenIdsFromReceipt, uniswapV4ProtocolModule, uniswapV4RegisterPositionFromMintTxPlaceholder, uniswapV4RegisterPositionNftPlaceholder };
2621
+ export { MAX_UINT160, MAX_UINT48, PERMIT2_ADDRESS, UNISWAP_LP_API_BASE_DEFAULT, UNISWAP_LP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_LP_DEFAULT_EXPIRY_MINUTES, UNISWAP_LP_DEFAULT_SLIPPAGE_PERCENT, UNISWAP_SWAP_DEFAULT_DEADLINE_SEC_OFFSET, UNISWAP_SWAP_DEFAULT_EXPIRY_MINUTES, UNISWAP_TRADE_BASE_DEFAULT, UNISWAP_UNIVERSAL_ROUTER_DEFAULT_GAS_UNITS, UNISWAP_UNIVERSAL_ROUTER_VERSION_DEFAULT, UNISWAP_V4_LP_COLLECT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_DECREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_ERC20_APPROVE_FALLBACK, UNISWAP_V4_LP_INCREASE_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_LOG_CHUNK_SIZE_DEFAULT, UNISWAP_V4_LP_LOG_CHUNK_SIZE_MIN, UNISWAP_V4_LP_MINT_DEFAULT_GAS_UNITS, UNISWAP_V4_LP_POOL_LOOKUP_HINT, UNISWAP_V4_LP_POSITION_REGISTRY_HINT, UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK, UNISWAP_V4_PROTOCOL_ID, applySlippagePercentToApproveWei, buildEvmMultisignBodyUniswapV4CollectFeesBatch, buildEvmMultisignBodyUniswapV4DecreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4IncreaseLiquidityBatch, buildEvmMultisignBodyUniswapV4MintLiquidityBatch, buildEvmMultisignBodyUniswapV4SkipPermit2Batch, buildUniswapQuoteRequestBody, buildUniswapV4PurposePrefill, computeUniswapV4PoolReference, computeUniswapV4Session, createSwap, errorMessageFromUniswapJsonBody, extractUniswapLpTokenAmounts, extractUniswapLpTransaction, fetchEthereumAddressForKeyGen, formatUniswapAmountFieldFromWei, formatUniswapLpAmountHuman, formatUniswapPercentForUi, formatUniswapQuoteForDisplay, formatUniswapV4PositionNotFoundError, getClassicQuoteFromStoredUniswapResponse, getUniswapUniversalRouterSpenderOrThrow, getUniswapV4PositionManagerDeployBlock, getUniswapV4PositionManagerOrThrow, isEthGetLogsBlockRangeTooLargeError, isNativeUniswapLpTokenAddress, isUniswapFullQuoteResponseNativeIn, isUniswapTokenInAddressNative, isUniswapV4ChainSupported, isUniswapV4LiquidityEvmSignRequest, isUniswapV4SwapEvmSignRequest, listUniswapV4PositionsForWallet, listUniswapV4StandardLpPools, messageFromUniswapHttpResponseBody, parseUniswapChainId, parseUniswapLpApiSnapshot, parseUniswapQuoteClassicInOut, parseUniswapQuoteSlippageInfo, parseUniswapV4ScanFromDateYmd, quoteSwap, readUniswapV4PositionInfoRaw, resolveBlockAtOrAfterUnixTime, resolveRouterSwapGasUnitsFromSignRequest, resolveUniswapV4LpExistingPoolFromKey, resolveUniswapV4LpPoolPreset, resolveUniswapV4PositionScanFromDate, sortUniswapV4PoolCurrencies, swapExactInput, swapFromQuote, swapTransactionDeadlineUnixFromExpiryMinutes, tryGetUniswapV4PositionManager, uniswapCreateSwap, uniswapLpClaimFees, uniswapLpCreatePosition, uniswapLpDecreasePosition, uniswapLpIncreasePosition, uniswapLpTxFieldForAction, uniswapQuoteToJsonQuoteOneLine, uniswapTradeQuote, uniswapV4, uniswapV4ListPositionsForMcp, uniswapV4ListPositionsFromRegistryForMcp, uniswapV4ListPositionsRegistryMcpPlaceholder, uniswapV4ListStandardLpPools, uniswapV4PositionMintedTokenIdsFromReceipt, uniswapV4ProtocolModule, uniswapV4RegisterPositionFromMintTxPlaceholder, uniswapV4RegisterPositionNftPlaceholder };
2405
2622
  //# sourceMappingURL=index.js.map
2406
2623
  //# sourceMappingURL=index.js.map