@anywalletkit/protocol-swap2-uniswap 0.3.1 → 0.4.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.
- package/dist/activity.cjs +12 -10
- package/dist/activity.cjs.map +1 -1
- package/dist/activity.d.cts +1 -1
- package/dist/activity.d.ts +1 -1
- package/dist/activity.js +1 -1
- package/dist/{addresses-Du1Qks_b.d.cts → addresses-gagFZ2tJ.d.cts} +7 -6
- package/dist/{addresses-Du1Qks_b.d.ts → addresses-gagFZ2tJ.d.ts} +7 -6
- package/dist/{chunk-ND647CPH.js → chunk-7XZQD45M.js} +7 -5
- package/dist/chunk-7XZQD45M.js.map +1 -0
- package/dist/{chunk-OPFCIWX7.js → chunk-QQGCEDT3.js} +3 -3
- package/dist/{chunk-BHGKOL3N.js → chunk-SXUKROTA.js} +13 -11
- package/dist/chunk-SXUKROTA.js.map +1 -0
- package/dist/index.cjs +17 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/protocol.cjs +17 -13
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +1 -1
- package/dist/protocol.d.ts +1 -1
- package/dist/protocol.js +3 -3
- package/dist/provider.cjs +17 -13
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.cts +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-BHGKOL3N.js.map +0 -1
- package/dist/chunk-ND647CPH.js.map +0 -1
- /package/dist/{chunk-OPFCIWX7.js.map → chunk-QQGCEDT3.js.map} +0 -0
package/dist/activity.cjs
CHANGED
|
@@ -38,20 +38,22 @@ var UNISWAP_V3 = Object.freeze({
|
|
|
38
38
|
137: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270" },
|
|
39
39
|
8453: { factory: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD", quoter: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", router: "0x2626664c2603336E57B271c5C0b26F421741e481", weth: "0x4200000000000000000000000000000000000006" },
|
|
40
40
|
42161: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" },
|
|
41
|
-
// zkSync Era and Celo:
|
|
41
|
+
// zkSync Era and Celo: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04. Celo's
|
|
42
|
+
// router and quoter report WETH9 0x0, so `weth` there is the CELO ERC-20, used only as the two-hop token.
|
|
42
43
|
324: { factory: "0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422", quoter: "0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28", router: "0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3", weth: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91" },
|
|
43
44
|
42220: { factory: "0xAfE208a311B21f13EF87E33A90049fC17A7acDEc", quoter: "0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8", router: "0x5615CDAb10dc425a742d643d949a7F474C01abc4", weth: "0x471EcE3750Da237f93B8E339c536989b8978a438", nativeWrap: false },
|
|
44
|
-
// Unichain, Monad, Linea: Uniswap's
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//
|
|
45
|
+
// Unichain, Monad, Linea: factory, QuoterV2 and SwapRouter02 as Uniswap's deployments.json lists them (status
|
|
46
|
+
// active), verified on-chain 2026-11-04: router + quoter report the factory and WETH9, and the quoter's gasEstimate
|
|
47
|
+
// is non-zero. The old `Quoter` on these chains (deprecated) quotes the same amounts but always reports gas 0.
|
|
48
|
+
130: { factory: "0x1F98400000000000000000000000000000000003", quoter: "0x385A5cf5F83e99f7BB2852b6A19C3538b9FA7658", router: "0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C", weth: "0x4200000000000000000000000000000000000006" },
|
|
49
|
+
143: { factory: "0x204FAca1764B154221e35c0d20aBb3c525710498", quoter: "0x661E93cca42AfacB172121EF892830cA3b70F08d", router: "0xfE31F71C1b106EAc32F1A19239c9a9A72ddfb900", weth: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A" },
|
|
50
|
+
59144: { factory: "0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9", quoter: "0x42bE4D6527829FeFA1493e1fb9F3676d2425C3C1", router: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", weth: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f" },
|
|
51
|
+
// World Chain, Ink, X Layer: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04
|
|
52
|
+
// (router + quoter report the factory and WETH9; X Layer's router wraps WOKB).
|
|
51
53
|
480: { factory: "0x7a5028BDa40e7B173C278C5342087826455ea25a", quoter: "0x10158D43e6cc414deE1Bd1eB0EfC6a5cBCfF244c", router: "0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6", weth: "0x4200000000000000000000000000000000000006" },
|
|
52
54
|
57073: { factory: "0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424", quoter: "0x96b572D2d880cf2Fa2563651BD23ADE6f5516652", router: "0x177778F19E89dD1012BdBe603F144088A95C4B53", weth: "0x4200000000000000000000000000000000000006" },
|
|
53
|
-
196: { factory: "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804", quoter: "
|
|
54
|
-
// Robinhood Chain:
|
|
55
|
+
196: { factory: "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804", quoter: "0xD1b797D92d87B688193A2B976eFc8D577D204343", router: "0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA", weth: "0xe538905cf8410324e03A5A23C1c177a474D59b2b" },
|
|
56
|
+
// Robinhood Chain: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04.
|
|
55
57
|
4663: { factory: "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA", quoter: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7", router: "0xCaf681a66D020601342297493863E78C959E5cb2", weth: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73" },
|
|
56
58
|
43114: { factory: "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD", quoter: "0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F", router: "0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE", weth: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" }
|
|
57
59
|
});
|
package/dist/activity.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/activity.ts","../src/addresses.ts"],"sourcesContent":["/**\n * Activity recognition for Uniswap v3: a call into the chain's SwapRouter02\n * (the deployment table, or the caller's override) with one of the router's\n * swap entry points → `swap`, \"Swapped A → B\" from the owner's net transfers.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {UNISWAP_V3, type UniswapDeployment} from \"./addresses.js\";\n\nexport const UNISWAP_MODULE = \"@anywalletkit/protocol-swap2-uniswap\";\n\n/** SwapRouter02 entry points (`viem toFunctionSelector`, 2026-10-14). */\nexport const UNISWAP_ROUTER_SELECTORS: ReadonlySet<string> = new Set([\n \"0x5ae401dc\", // multicall(uint256 deadline, bytes[] data)\n \"0xac9650d8\", // multicall(bytes[] data)\n \"0x1f0464d1\", // multicall(bytes32 previousBlockhash, bytes[] data)\n \"0x04e45aaf\", // exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))\n \"0xb858183f\", // exactInput((bytes,address,uint256,uint256))\n \"0x5023b4df\", // exactOutputSingle((address,address,uint24,address,uint256,uint256,uint160))\n \"0x09b81346\", // exactOutput((bytes,address,uint256,uint256))\n]);\n\nexport function describeUniswapActivity(\n tx: ChainTx,\n ctx: DescribeActivityContext,\n deployments: Readonly<Record<number, UniswapDeployment>> = UNISWAP_V3,\n): ActivityItem | null {\n if (!isEvm(tx.chain)) return null;\n const deployment = deployments[evmRef(tx.chain)];\n if (!deployment || !matchesCall(tx, [deployment.router], UNISWAP_ROUTER_SELECTORS)) return null;\n return describeSwapLike(tx, ctx, {protocol: UNISWAP_MODULE, subtitle: `Uniswap v3 · ${chainLabel(tx.chain)}`, kind: \"swap\"});\n}\n","import {decodeFunctionData, getAddress, parseAbi, type Hex} from \"viem\";\nimport {sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Quote, QuoteParams, RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * Uniswap v3 deployments this module trusts. Every entry was checked on-chain\n * (2026-10-12): SwapRouter02.factory() and QuoterV2.factory() both return\n * `factory`, and both report `weth` as WETH9. The provider re-checks the same\n * facts once per chain at runtime before quoting (see `verifyDeployment`).\n */\nexport interface UniswapDeployment {\n factory: `0x${string}`;\n quoter: `0x${string}`;\n router: `0x${string}`;\n /** The chain's wrapped native token (WETH, WBNB, WPOL, WAVAX) — on a chain\n * without one (Celo), the hop token used for two-hop routes instead. */\n weth: `0x${string}`;\n /** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */\n nativeWrap?: false;\n /** false: a newer QuoterV2 build without WETH9() — only its factory is checked. */\n quoterWeth?: false;\n}\n\nexport const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>> = Object.freeze({\n 1: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"},\n 10: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x4200000000000000000000000000000000000006\"},\n 56: {factory: \"0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7\", quoter: \"0x78D78E420Da98ad378D7799bE8f4AF69033EB077\", router: \"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2\", weth: \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\"},\n 137: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270\"},\n 8453: {factory: \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\", quoter: \"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a\", router: \"0x2626664c2603336E57B271c5C0b26F421741e481\", weth: \"0x4200000000000000000000000000000000000006\"},\n 42161: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1\"},\n // zkSync Era and Celo: addresses from cp0x pi-uniswap-interface, verified on-chain 2026-10-12.\n 324: {factory: \"0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422\", quoter: \"0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28\", router: \"0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3\", weth: \"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91\"},\n 42220: {factory: \"0xAfE208a311B21f13EF87E33A90049fC17A7acDEc\", quoter: \"0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8\", router: \"0x5615CDAb10dc425a742d643d949a7F474C01abc4\", weth: \"0x471EcE3750Da237f93B8E339c536989b8978a438\", nativeWrap: false},\n // Unichain, Monad, Linea: Uniswap's sdk-core CHAIN_TO_ADDRESSES_MAP, verified on-chain 2026-10-13\n // (router + quoter report the factory; these quoters have no WETH9()).\n 130: {factory: \"0x1F98400000000000000000000000000000000003\", quoter: \"0x565AC8C7863D9bb16d07E809ff49Fe5cD467634C\", router: \"0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C\", weth: \"0x4200000000000000000000000000000000000006\", quoterWeth: false},\n 143: {factory: \"0x204FAca1764B154221e35c0d20aBb3c525710498\", quoter: \"0x2d01411773c8C24805306e89a41f7855c3C4fE65\", router: \"0xfE31F71C1b106EAc32F1A19239c9a9A72ddfb900\", weth: \"0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A\", quoterWeth: false},\n 59144: {factory: \"0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9\", quoter: \"0x58EaD433eA99708604c4dD7C9b7E80c70976E202\", router: \"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a\", weth: \"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f\", quoterWeth: false},\n // World Chain, Ink, X Layer: Uniswap's sdk-core CHAIN_TO_ADDRESSES_MAP, verified on-chain 2026-10-13\n // (router + quoter report the factory; X Layer's quoter has no WETH9(), its router wraps WOKB).\n 480: {factory: \"0x7a5028BDa40e7B173C278C5342087826455ea25a\", quoter: \"0x10158D43e6cc414deE1Bd1eB0EfC6a5cBCfF244c\", router: \"0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6\", weth: \"0x4200000000000000000000000000000000000006\"},\n 57073: {factory: \"0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424\", quoter: \"0x96b572D2d880cf2Fa2563651BD23ADE6f5516652\", router: \"0x177778F19E89dD1012BdBe603F144088A95C4B53\", weth: \"0x4200000000000000000000000000000000000006\"},\n 196: {factory: \"0x4B2ab38DBF28D31D467aA8993f6c2585981D6804\", quoter: \"0x976183AC3d09840D243A88c0268BADb3B3e3259f\", router: \"0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA\", weth: \"0xe538905cf8410324e03A5A23C1c177a474D59b2b\", quoterWeth: false},\n // Robinhood Chain: addresses from cp0x pi-uniswap-interface (constants/addresses.ts), verified on-chain 2026-10-12.\n 4663: {factory: \"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA\", quoter: \"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7\", router: \"0xCaf681a66D020601342297493863E78C959E5cb2\", weth: \"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73\"},\n 43114: {factory: \"0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD\", quoter: \"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F\", router: \"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE\", weth: \"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7\"},\n});\n\n/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */\nexport const FEE_TIERS = [100, 500, 3000, 10000] as const;\n/** Two-hop routes go through these (when the catalog knows them on the chain). */\nexport const HOP_SYMBOLS = [\"WETH\", \"USDC\", \"USDT\"] as const;\n/** SwapRouter02 recipient sentinel: \"keep the output in the router\" (then unwrapWETH9). */\nexport const ADDRESS_THIS = \"0x0000000000000000000000000000000000000002\";\n\n/** The SwapRouter02 entry points this module writes (and the deployment probes). */\nexport const ROUTER_ABI = parseAbi([\n \"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)\",\n \"function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)\",\n \"function unwrapWETH9(uint256 amountMinimum, address recipient) payable\",\n \"function multicall(uint256 deadline, bytes[] data) payable returns (bytes[] results)\",\n \"function factory() view returns (address)\",\n \"function WETH9() view returns (address)\",\n]);\n/** Most pools one `exactInput` path may cross: the provider builds direct and one-hop (two-pool) routes only. */\nconst MAX_PATH_POOLS = 2;\n\n/**\n * The swap a Uniswap quote's router call makes, opened on the client against the app's own request (scan 2026-10-28,\n * F1): one `multicall(deadline, legs)` on the chain's pinned SwapRouter02 whose legs are exactly one `exactInputSingle`\n * or `exactInput` — then `unwrapWETH9` for a native output — selling exactly the input of the source token (WETH for a\n * native input, paid as `value`) for the destination token, with `amountOutMinimum` the quote's minimum, paid to the\n * recipient (or kept in the router and unwrapped to the recipient for that same minimum). `pull`, `sweepToken` and\n * every other router call are refused. The reason it fails, or null.\n */\nexport function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;\n const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : undefined;\n if (!d || params.destChain !== params.sourceChain) return \"not a same-chain swap on a pinned Uniswap deployment\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no router call\";\n if (getAddress(tx.to) !== getAddress(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;\n const src = sourceAssetOf(params);\n if (!src) return `unknown source token ${params.sourceToken}`;\n const nativeIn = !src.contract;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if ((nativeIn || nativeOut) && d.nativeWrap === false) return \"this chain's router has no wrapped native\";\n let tokenIn: string, tokenOut: string, recipient: string, amountIn: bigint, minOut: bigint;\n try {\n tokenIn = getAddress(nativeIn ? d.weth : src.contract!);\n tokenOut = getAddress(nativeOut ? d.weth : params.destToken);\n recipient = getAddress(params.destAddress);\n amountIn = BigInt(params.amountIn);\n minOut = BigInt(quote.minDestAmount);\n } catch {\n return \"the request does not name EVM tokens, a recipient and amounts\";\n }\n if (nativeIn ? BigInt(tx.value ?? \"0\") !== amountIn || tx.approvalAddress !== undefined\n : BigInt(tx.value ?? \"0\") !== 0n || !tx.approvalAddress || getAddress(tx.approvalAddress) !== getAddress(d.router)) {\n return nativeIn ? \"a native input is paid as exactly the input in value, with no approval\" : \"a token input attaches no value and approves the SwapRouter\";\n }\n let legs: readonly Hex[];\n try {\n const outer = decodeFunctionData({abi: ROUTER_ABI, data: tx.data as Hex});\n if (outer.functionName !== \"multicall\") return `${outer.functionName} is not multicall(deadline, legs)`;\n legs = outer.args[1];\n } catch {\n return \"the router call is not multicall(deadline, legs)\";\n }\n if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? \" and an unwrap\" : \"\"}`;\n const decode = (leg: Hex) => { try { return decodeFunctionData({abi: ROUTER_ABI, data: leg}); } catch { return null; } };\n const swap = decode(legs[0]!);\n const swapTo = nativeOut ? ADDRESS_THIS : recipient;\n if (swap?.functionName === \"exactInputSingle\") {\n const a = swap.args[0];\n if (getAddress(a.tokenIn) !== tokenIn || getAddress(a.tokenOut) !== tokenOut) return \"the swap trades other tokens\";\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return \"the swap's input, minimum or price limit is not the quote's\";\n if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;\n } else if (swap?.functionName === \"exactInput\") {\n const a = swap.args[0];\n const path = a.path.slice(2);\n const pools = (path.length / 2 - 20) / 23;\n if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return \"the swap path is not 1–2 pools\";\n if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return \"the swap path trades other tokens\";\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return \"the swap's input or minimum is not the quote's\";\n if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;\n } else {\n return `${swap?.functionName ?? \"an unknown call\"} is not exactInputSingle / exactInput`;\n }\n if (nativeOut) {\n const unwrap = decode(legs[1]!);\n if (unwrap?.functionName !== \"unwrapWETH9\") return `${unwrap?.functionName ?? \"an unknown call\"} is not unwrapWETH9`;\n if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return \"the unwrap pays someone else or less than the minimum\";\n }\n return null;\n}\n\n/**\n * The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and\n * {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: \"uniswap\", baseUrl, ...uniswapPins})` (scan\n * 2026-10-27 modules, F9; scan 2026-10-28, F1).\n */\nexport const uniswapPins: RemotePins = Object.freeze({\n callTargets: (chain: string): readonly string[] => uniswapRouterFor(chain),\n spenders: (chain: string): readonly string[] => uniswapRouterFor(chain),\n verifyQuote: uniswapVerifyQuote,\n});\nfunction uniswapRouterFor(chain: string): readonly string[] {\n const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;\n const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : undefined;\n return d ? [d.router] : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAwD;AACxD,IAAAA,eAA4B;;;ACP5B,kBAAiE;AACjE,kBAA4B;AAsBrB,IAAM,aAA0D,OAAO,OAAO;AAAA,EACnF,GAAG,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EACzN,IAAI,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC1N,IAAI,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MA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AAG,QAAO;AAC7B,QAAM,aAAa,gBAAY,qBAAO,GAAG,KAAK,CAAC;AAC/C,MAAI,CAAC,cAAc,KAAC,6BAAY,IAAI,CAAC,WAAW,MAAM,GAAG,wBAAwB,EAAG,QAAO;AAC3F,aAAO,kCAAiB,IAAI,KAAK,EAAC,UAAU,gBAAgB,UAAU,uBAAgB,4BAAW,GAAG,KAAK,CAAC,IAAI,MAAM,OAAM,CAAC;AAC7H;","names":["import_util"]}
|
|
1
|
+
{"version":3,"sources":["../src/activity.ts","../src/addresses.ts"],"sourcesContent":["/**\n * Activity recognition for Uniswap v3: a call into the chain's SwapRouter02\n * (the deployment table, or the caller's override) with one of the router's\n * swap entry points → `swap`, \"Swapped A → B\" from the owner's net transfers.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {UNISWAP_V3, type UniswapDeployment} from \"./addresses.js\";\n\nexport const UNISWAP_MODULE = \"@anywalletkit/protocol-swap2-uniswap\";\n\n/** SwapRouter02 entry points (`viem toFunctionSelector`, 2026-10-14). */\nexport const UNISWAP_ROUTER_SELECTORS: ReadonlySet<string> = new Set([\n \"0x5ae401dc\", // multicall(uint256 deadline, bytes[] data)\n \"0xac9650d8\", // multicall(bytes[] data)\n \"0x1f0464d1\", // multicall(bytes32 previousBlockhash, bytes[] data)\n \"0x04e45aaf\", // exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))\n \"0xb858183f\", // exactInput((bytes,address,uint256,uint256))\n \"0x5023b4df\", // exactOutputSingle((address,address,uint24,address,uint256,uint256,uint160))\n \"0x09b81346\", // exactOutput((bytes,address,uint256,uint256))\n]);\n\nexport function describeUniswapActivity(\n tx: ChainTx,\n ctx: DescribeActivityContext,\n deployments: Readonly<Record<number, UniswapDeployment>> = UNISWAP_V3,\n): ActivityItem | null {\n if (!isEvm(tx.chain)) return null;\n const deployment = deployments[evmRef(tx.chain)];\n if (!deployment || !matchesCall(tx, [deployment.router], UNISWAP_ROUTER_SELECTORS)) return null;\n return describeSwapLike(tx, ctx, {protocol: UNISWAP_MODULE, subtitle: `Uniswap v3 · ${chainLabel(tx.chain)}`, kind: \"swap\"});\n}\n","import {decodeFunctionData, getAddress, parseAbi, type Hex} from \"viem\";\nimport {sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Quote, QuoteParams, RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * Uniswap v3 deployments this module trusts: the UniswapV3Factory, QuoterV2 and\n * SwapRouter02 that Uniswap's deployments.json lists as active on each chain\n * (re-checked 2026-11-04). Every entry was checked on-chain: SwapRouter02.factory()\n * and QuoterV2.factory() both return `factory`, and both report `weth` as WETH9\n * (on Celo both report 0x0 — see `nativeWrap`).\n * The provider re-checks the same facts once per chain at runtime before quoting\n * (see `verifyDeployment`).\n */\nexport interface UniswapDeployment {\n factory: `0x${string}`;\n quoter: `0x${string}`;\n router: `0x${string}`;\n /** The chain's wrapped native token (WETH, WBNB, WPOL, WAVAX) — on a chain\n * without one (Celo), the hop token used for two-hop routes instead. */\n weth: `0x${string}`;\n /** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */\n nativeWrap?: false;\n}\n\nexport const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>> = Object.freeze({\n 1: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"},\n 10: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x4200000000000000000000000000000000000006\"},\n 56: {factory: \"0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7\", quoter: \"0x78D78E420Da98ad378D7799bE8f4AF69033EB077\", router: \"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2\", weth: \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\"},\n 137: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270\"},\n 8453: {factory: \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\", quoter: \"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a\", router: \"0x2626664c2603336E57B271c5C0b26F421741e481\", weth: \"0x4200000000000000000000000000000000000006\"},\n 42161: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1\"},\n // zkSync Era and Celo: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04. Celo's\n // router and quoter report WETH9 0x0, so `weth` there is the CELO ERC-20, used only as the two-hop token.\n 324: {factory: \"0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422\", quoter: \"0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28\", router: \"0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3\", weth: \"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91\"},\n 42220: {factory: \"0xAfE208a311B21f13EF87E33A90049fC17A7acDEc\", quoter: \"0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8\", router: \"0x5615CDAb10dc425a742d643d949a7F474C01abc4\", weth: \"0x471EcE3750Da237f93B8E339c536989b8978a438\", nativeWrap: false},\n // Unichain, Monad, Linea: factory, QuoterV2 and SwapRouter02 as Uniswap's deployments.json lists them (status\n // active), verified on-chain 2026-11-04: router + quoter report the factory and WETH9, and the quoter's gasEstimate\n // is non-zero. The old `Quoter` on these chains (deprecated) quotes the same amounts but always reports gas 0.\n 130: {factory: \"0x1F98400000000000000000000000000000000003\", quoter: \"0x385A5cf5F83e99f7BB2852b6A19C3538b9FA7658\", router: \"0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C\", weth: \"0x4200000000000000000000000000000000000006\"},\n 143: {factory: \"0x204FAca1764B154221e35c0d20aBb3c525710498\", quoter: \"0x661E93cca42AfacB172121EF892830cA3b70F08d\", router: \"0xfE31F71C1b106EAc32F1A19239c9a9A72ddfb900\", weth: \"0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A\"},\n 59144: {factory: \"0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9\", quoter: \"0x42bE4D6527829FeFA1493e1fb9F3676d2425C3C1\", router: \"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a\", weth: \"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f\"},\n // World Chain, Ink, X Layer: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04\n // (router + quoter report the factory and WETH9; X Layer's router wraps WOKB).\n 480: {factory: \"0x7a5028BDa40e7B173C278C5342087826455ea25a\", quoter: \"0x10158D43e6cc414deE1Bd1eB0EfC6a5cBCfF244c\", router: \"0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6\", weth: \"0x4200000000000000000000000000000000000006\"},\n 57073: {factory: \"0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424\", quoter: \"0x96b572D2d880cf2Fa2563651BD23ADE6f5516652\", router: \"0x177778F19E89dD1012BdBe603F144088A95C4B53\", weth: \"0x4200000000000000000000000000000000000006\"},\n 196: {factory: \"0x4B2ab38DBF28D31D467aA8993f6c2585981D6804\", quoter: \"0xD1b797D92d87B688193A2B976eFc8D577D204343\", router: \"0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA\", weth: \"0xe538905cf8410324e03A5A23C1c177a474D59b2b\"},\n // Robinhood Chain: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04.\n 4663: {factory: \"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA\", quoter: \"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7\", router: \"0xCaf681a66D020601342297493863E78C959E5cb2\", weth: \"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73\"},\n 43114: {factory: \"0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD\", quoter: \"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F\", router: \"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE\", weth: \"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7\"},\n});\n\n/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */\nexport const FEE_TIERS = [100, 500, 3000, 10000] as const;\n/** Two-hop routes go through these (when the catalog knows them on the chain). */\nexport const HOP_SYMBOLS = [\"WETH\", \"USDC\", \"USDT\"] as const;\n/** SwapRouter02 recipient sentinel: \"keep the output in the router\" (then unwrapWETH9). */\nexport const ADDRESS_THIS = \"0x0000000000000000000000000000000000000002\";\n\n/** The SwapRouter02 entry points this module writes (and the deployment probes). */\nexport const ROUTER_ABI = parseAbi([\n \"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)\",\n \"function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)\",\n \"function unwrapWETH9(uint256 amountMinimum, address recipient) payable\",\n \"function multicall(uint256 deadline, bytes[] data) payable returns (bytes[] results)\",\n \"function factory() view returns (address)\",\n \"function WETH9() view returns (address)\",\n]);\n/** Most pools one `exactInput` path may cross: the provider builds direct and one-hop (two-pool) routes only. */\nconst MAX_PATH_POOLS = 2;\n\n/**\n * The swap a Uniswap quote's router call makes, opened on the client against the app's own request (scan 2026-10-28,\n * F1): one `multicall(deadline, legs)` on the chain's pinned SwapRouter02 whose legs are exactly one `exactInputSingle`\n * or `exactInput` — then `unwrapWETH9` for a native output — selling exactly the input of the source token (WETH for a\n * native input, paid as `value`) for the destination token, with `amountOutMinimum` the quote's minimum, paid to the\n * recipient (or kept in the router and unwrapped to the recipient for that same minimum). `pull`, `sweepToken` and\n * every other router call are refused. The reason it fails, or null.\n */\nexport function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;\n const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : undefined;\n if (!d || params.destChain !== params.sourceChain) return \"not a same-chain swap on a pinned Uniswap deployment\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no router call\";\n if (getAddress(tx.to) !== getAddress(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;\n const src = sourceAssetOf(params);\n if (!src) return `unknown source token ${params.sourceToken}`;\n const nativeIn = !src.contract;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if ((nativeIn || nativeOut) && d.nativeWrap === false) return \"this chain's router has no wrapped native\";\n let tokenIn: string, tokenOut: string, recipient: string, amountIn: bigint, minOut: bigint;\n try {\n tokenIn = getAddress(nativeIn ? d.weth : src.contract!);\n tokenOut = getAddress(nativeOut ? d.weth : params.destToken);\n recipient = getAddress(params.destAddress);\n amountIn = BigInt(params.amountIn);\n minOut = BigInt(quote.minDestAmount);\n } catch {\n return \"the request does not name EVM tokens, a recipient and amounts\";\n }\n if (nativeIn ? BigInt(tx.value ?? \"0\") !== amountIn || tx.approvalAddress !== undefined\n : BigInt(tx.value ?? \"0\") !== 0n || !tx.approvalAddress || getAddress(tx.approvalAddress) !== getAddress(d.router)) {\n return nativeIn ? \"a native input is paid as exactly the input in value, with no approval\" : \"a token input attaches no value and approves the SwapRouter\";\n }\n let legs: readonly Hex[];\n try {\n const outer = decodeFunctionData({abi: ROUTER_ABI, data: tx.data as Hex});\n if (outer.functionName !== \"multicall\") return `${outer.functionName} is not multicall(deadline, legs)`;\n legs = outer.args[1];\n } catch {\n return \"the router call is not multicall(deadline, legs)\";\n }\n if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? \" and an unwrap\" : \"\"}`;\n const decode = (leg: Hex) => { try { return decodeFunctionData({abi: ROUTER_ABI, data: leg}); } catch { return null; } };\n const swap = decode(legs[0]!);\n const swapTo = nativeOut ? ADDRESS_THIS : recipient;\n if (swap?.functionName === \"exactInputSingle\") {\n const a = swap.args[0];\n if (getAddress(a.tokenIn) !== tokenIn || getAddress(a.tokenOut) !== tokenOut) return \"the swap trades other tokens\";\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return \"the swap's input, minimum or price limit is not the quote's\";\n if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;\n } else if (swap?.functionName === \"exactInput\") {\n const a = swap.args[0];\n const path = a.path.slice(2);\n const pools = (path.length / 2 - 20) / 23;\n if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return \"the swap path is not 1–2 pools\";\n if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return \"the swap path trades other tokens\";\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return \"the swap's input or minimum is not the quote's\";\n if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;\n } else {\n return `${swap?.functionName ?? \"an unknown call\"} is not exactInputSingle / exactInput`;\n }\n if (nativeOut) {\n const unwrap = decode(legs[1]!);\n if (unwrap?.functionName !== \"unwrapWETH9\") return `${unwrap?.functionName ?? \"an unknown call\"} is not unwrapWETH9`;\n if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return \"the unwrap pays someone else or less than the minimum\";\n }\n return null;\n}\n\n/**\n * The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and\n * {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: \"uniswap\", baseUrl, ...uniswapPins})` (scan\n * 2026-10-27 modules, F9; scan 2026-10-28, F1).\n */\nexport const uniswapPins: RemotePins = Object.freeze({\n callTargets: (chain: string): readonly string[] => uniswapRouterFor(chain),\n spenders: (chain: string): readonly string[] => uniswapRouterFor(chain),\n verifyQuote: uniswapVerifyQuote,\n});\nfunction uniswapRouterFor(chain: string): readonly string[] {\n const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;\n const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : undefined;\n return d ? [d.router] : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAwD;AACxD,IAAAA,eAA4B;;;ACP5B,kBAAiE;AACjE,kBAA4B;AAuBrB,IAAM,aAA0D,OAAO,OAAO;AAAA,EACnF,GAAG,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EACzN,IAAI,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC1N,IAAI,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC1N,KAAK,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC3N,MAAM,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAA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AU,uBAAgB,4BAAW,GAAG,KAAK,CAAC,IAAI,MAAM,OAAM,CAAC;AAC7H;","names":["import_util"]}
|
package/dist/activity.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
|
|
2
|
-
import { a as UniswapDeployment } from './addresses-
|
|
2
|
+
import { a as UniswapDeployment } from './addresses-gagFZ2tJ.cjs';
|
|
3
3
|
import '@anywalletkit/protocol-swap2-core/types';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/activity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
|
|
2
|
-
import { a as UniswapDeployment } from './addresses-
|
|
2
|
+
import { a as UniswapDeployment } from './addresses-gagFZ2tJ.js';
|
|
3
3
|
import '@anywalletkit/protocol-swap2-core/types';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/activity.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { RemotePins, QuoteParams, Quote } from '@anywalletkit/protocol-swap2-core/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Uniswap v3 deployments this module trusts
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Uniswap v3 deployments this module trusts: the UniswapV3Factory, QuoterV2 and
|
|
5
|
+
* SwapRouter02 that Uniswap's deployments.json lists as active on each chain
|
|
6
|
+
* (re-checked 2026-11-04). Every entry was checked on-chain: SwapRouter02.factory()
|
|
7
|
+
* and QuoterV2.factory() both return `factory`, and both report `weth` as WETH9
|
|
8
|
+
* (on Celo both report 0x0 — see `nativeWrap`).
|
|
9
|
+
* The provider re-checks the same facts once per chain at runtime before quoting
|
|
10
|
+
* (see `verifyDeployment`).
|
|
8
11
|
*/
|
|
9
12
|
interface UniswapDeployment {
|
|
10
13
|
factory: `0x${string}`;
|
|
@@ -15,8 +18,6 @@ interface UniswapDeployment {
|
|
|
15
18
|
weth: `0x${string}`;
|
|
16
19
|
/** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */
|
|
17
20
|
nativeWrap?: false;
|
|
18
|
-
/** false: a newer QuoterV2 build without WETH9() — only its factory is checked. */
|
|
19
|
-
quoterWeth?: false;
|
|
20
21
|
}
|
|
21
22
|
declare const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>>;
|
|
22
23
|
/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { RemotePins, QuoteParams, Quote } from '@anywalletkit/protocol-swap2-core/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Uniswap v3 deployments this module trusts
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Uniswap v3 deployments this module trusts: the UniswapV3Factory, QuoterV2 and
|
|
5
|
+
* SwapRouter02 that Uniswap's deployments.json lists as active on each chain
|
|
6
|
+
* (re-checked 2026-11-04). Every entry was checked on-chain: SwapRouter02.factory()
|
|
7
|
+
* and QuoterV2.factory() both return `factory`, and both report `weth` as WETH9
|
|
8
|
+
* (on Celo both report 0x0 — see `nativeWrap`).
|
|
9
|
+
* The provider re-checks the same facts once per chain at runtime before quoting
|
|
10
|
+
* (see `verifyDeployment`).
|
|
8
11
|
*/
|
|
9
12
|
interface UniswapDeployment {
|
|
10
13
|
factory: `0x${string}`;
|
|
@@ -15,8 +18,6 @@ interface UniswapDeployment {
|
|
|
15
18
|
weth: `0x${string}`;
|
|
16
19
|
/** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */
|
|
17
20
|
nativeWrap?: false;
|
|
18
|
-
/** false: a newer QuoterV2 build without WETH9() — only its factory is checked. */
|
|
19
|
-
quoterWeth?: false;
|
|
20
21
|
}
|
|
21
22
|
declare const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>>;
|
|
22
23
|
/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ROUTER_ABI,
|
|
6
6
|
UNISWAP_V3,
|
|
7
7
|
describeUniswapActivity
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SXUKROTA.js";
|
|
9
9
|
|
|
10
10
|
// src/provider.ts
|
|
11
11
|
import { decodeFunctionResult, encodeFunctionData, encodePacked, getAddress, parseAbi } from "viem";
|
|
@@ -16,6 +16,7 @@ var ZERO = "0x0000000000000000000000000000000000000000";
|
|
|
16
16
|
var DEFAULT_SLIPPAGE_BPS = 50;
|
|
17
17
|
var DEFAULT_TTL_MS = 3e5;
|
|
18
18
|
var DEFAULT_DEADLINE_S = 600;
|
|
19
|
+
var MIN_POOL_GAS = 20000n;
|
|
19
20
|
var QUOTER_ABI = parseAbi([
|
|
20
21
|
"function quoteExactInputSingle((address tokenIn, address tokenOut, uint256 amountIn, uint24 fee, uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)",
|
|
21
22
|
"function quoteExactInput(bytes path, uint256 amountIn) returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)",
|
|
@@ -74,7 +75,7 @@ function uniswapProvider(config) {
|
|
|
74
75
|
const [rf, rw, qf, qw] = await rpc(chainId, [call(d.router, f), call(d.router, w), call(d.quoter, f), call(d.quoter, w)]);
|
|
75
76
|
const addr = (r) => typeof r === "string" && r.length >= 42 ? getAddress(`0x${r.slice(-40)}`) : null;
|
|
76
77
|
const wrapped = d.nativeWrap === false ? getAddress(ZERO) : getAddress(d.weth);
|
|
77
|
-
const ok = [rf, qf].every((r) => addr(r) === getAddress(d.factory)) && addr(rw) === wrapped &&
|
|
78
|
+
const ok = [rf, qf].every((r) => addr(r) === getAddress(d.factory)) && addr(rw) === wrapped && addr(qw) === wrapped;
|
|
78
79
|
if (!ok) throw new Error(`uniswap: the router/quoter on chain ${chainId} do not match the pinned deployment \u2014 refusing`);
|
|
79
80
|
})();
|
|
80
81
|
p.catch(() => verified.delete(chainId));
|
|
@@ -193,7 +194,8 @@ function uniswapProvider(config) {
|
|
|
193
194
|
if (nativeOut) legs.push(encodeFunctionData({ abi: ROUTER_ABI, functionName: "unwrapWETH9", args: [minOut, recipient] }));
|
|
194
195
|
const deadline = BigInt(Math.floor(Date.now() / 1e3) + deadlineS);
|
|
195
196
|
const data = encodeFunctionData({ abi: ROUTER_ABI, functionName: "multicall", args: [deadline, legs] });
|
|
196
|
-
const
|
|
197
|
+
const pools = route.single ? 1n : BigInt((route.path.length - 42) / 46);
|
|
198
|
+
const gasLimit = gas >= MIN_POOL_GAS * pools ? gas * 3n / 2n + 120000n + (nativeOut ? 40000n : 0n) : void 0;
|
|
197
199
|
return {
|
|
198
200
|
provider: "uniswap",
|
|
199
201
|
intentId: `uniswap:${chainId}`,
|
|
@@ -204,7 +206,7 @@ function uniswapProvider(config) {
|
|
|
204
206
|
data,
|
|
205
207
|
value: nativeIn ? amountIn.toString() : "0",
|
|
206
208
|
chainId,
|
|
207
|
-
gasLimit: gasLimit.toString(),
|
|
209
|
+
...gasLimit !== void 0 ? { gasLimit: gasLimit.toString() } : {},
|
|
208
210
|
...nativeIn ? {} : { approvalAddress: d.router }
|
|
209
211
|
},
|
|
210
212
|
sourceAmount: amountIn.toString(),
|
|
@@ -280,4 +282,4 @@ function uniswapProvider(config) {
|
|
|
280
282
|
export {
|
|
281
283
|
uniswapProvider
|
|
282
284
|
};
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
285
|
+
//# sourceMappingURL=chunk-7XZQD45M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import {decodeFunctionResult, encodeFunctionData, encodePacked, getAddress, parseAbi, type Hex} from \"viem\";\nimport {describeUniswapActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {evmRef, isEvm, timeoutSignal, sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {ADDRESS_THIS, FEE_TIERS, HOP_SYMBOLS, ROUTER_ABI, UNISWAP_V3, type UniswapDeployment} from \"./addresses.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Uniswap v3, straight from the contracts — the permissionless swap venue.\n *\n * Quote: QuoterV2 via `eth_call` (one JSON-RPC batch: every fee tier direct,\n * plus two-hop routes through WETH / USDC / USDT). Execution: SwapRouter02\n * `multicall(deadline, …)` — `exactInputSingle` or `exactInput`, native input\n * wrapped by the router (`value`), native output kept in the router and paid\n * out with `unwrapWETH9(min, recipient)`. No API key, no Uniswap frontend, no\n * aggregator: if the pools are live, the swap works.\n *\n * Same-chain only. ERC-20 sources approve exactly the input to the router\n * (`approvalAddress`); the engine handles that leg.\n */\n\nconst ZERO = \"0x0000000000000000000000000000000000000000\";\nconst DEFAULT_SLIPPAGE_BPS = 50;\n/** The router itself enforces amountOutMinimum and the deadline, and preflight\n * re-quotes the exact route before broadcast — so the quote may outlive an\n * approval being mined (an Ethereum approve + head wait took >30 s live). */\nconst DEFAULT_TTL_MS = 300_000;\nconst DEFAULT_DEADLINE_S = 600;\n/** Least gas one v3 pool swap can use (cold pool storage + two token transfers cost far more); a quoter figure\n * under this per pool does not measure the swap. */\nconst MIN_POOL_GAS = 20_000n;\n\nconst QUOTER_ABI = parseAbi([\n \"function quoteExactInputSingle((address tokenIn, address tokenOut, uint256 amountIn, uint24 fee, uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)\",\n \"function quoteExactInput(bytes path, uint256 amountIn) returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)\",\n \"function factory() view returns (address)\",\n \"function WETH9() view returns (address)\",\n]);\n\nexport interface UniswapProviderConfig {\n enabled?: boolean;\n /** JSON-RPC endpoints per EVM chain id, tried in order. A chain without one is not offered. */\n rpcUrls: Readonly<Record<number, readonly string[]>>;\n /** Slippage when the caller names none (bps). Default 50. */\n defaultSlippageBps?: number;\n /** Local quote lifetime (must cover an approval being mined). Default 5 min. */\n quoteTtlMs?: number;\n /** Seconds the router accepts the swap after the quote (multicall deadline). Default 600. */\n deadlineSeconds?: number;\n /** Override the deployments (tests, new chains). Still verified on-chain before use. */\n deployments?: Readonly<Record<number, UniswapDeployment>>;\n}\n\ninterface Route {\n /** Human description for the review / logs. */\n label: string;\n /** The pool fee(s) the route pays — already inside the quoted output. */\n poolFee: string;\n single?: {fee: number};\n path?: Hex;\n}\n\ntype RpcCall = {method: string; params: unknown[]};\n\n/** Largest JSON-RPC batch sent to one node (X Layer's public RPCs refuse more than 10). */\nconst RPC_BATCH_MAX = 10;\n\nexport function uniswapProvider(config: UniswapProviderConfig): CrossChainProvider {\n const deployments = config.deployments ?? UNISWAP_V3;\n const slippageDefault = config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;\n const ttl = config.quoteTtlMs ?? DEFAULT_TTL_MS;\n const deadlineS = config.deadlineSeconds ?? DEFAULT_DEADLINE_S;\n if (!Number.isInteger(slippageDefault) || slippageDefault <= 0 || slippageDefault >= 5_000) throw new Error(\"uniswap: defaultSlippageBps must be 1..4999\");\n const verified = new Map<number, Promise<void>>();\n\n const chainIdOf = (caip2: string): number | null => {\n if (!isEvm(caip2)) return null;\n const id = evmRef(caip2);\n return deployments[id] && config.rpcUrls[id]?.length ? id : null;\n };\n\n /**\n * JSON-RPC batch with endpoint failover; each slot is the result or null (reverted / errored).\n * Sent in chunks of RPC_BATCH_MAX: some public nodes cap a batch (X Layer's at 10 calls).\n */\n async function rpc(chainId: number, calls: RpcCall[], signal?: AbortSignal): Promise<(unknown | null)[]> {\n if (calls.length <= RPC_BATCH_MAX) return rpcBatch(chainId, calls, signal);\n const chunks: RpcCall[][] = [];\n for (let i = 0; i < calls.length; i += RPC_BATCH_MAX) chunks.push(calls.slice(i, i + RPC_BATCH_MAX));\n return (await Promise.all(chunks.map((c) => rpcBatch(chainId, c, signal)))).flat();\n }\n\n async function rpcBatch(chainId: number, calls: RpcCall[], signal?: AbortSignal): Promise<(unknown | null)[]> {\n let lastErr: unknown;\n for (const url of config.rpcUrls[chainId] ?? []) {\n try {\n const res = await fetch(url, {\n method: \"POST\",\n headers: {\"content-type\": \"application/json\"},\n body: JSON.stringify(calls.map((c, id) => ({jsonrpc: \"2.0\", id, ...c}))),\n signal: signal ?? timeoutSignal(12_000),\n });\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n const body = (await res.json()) as {id: number; result?: unknown; error?: unknown}[] | {error?: {message?: string}};\n if (!Array.isArray(body)) throw new Error(body.error?.message ?? \"batch refused\");\n const out: (unknown | null)[] = calls.map(() => null);\n for (const r of body) if (typeof r.id === \"number\" && r.id < out.length && r.error === undefined) out[r.id] = r.result ?? null;\n return out;\n } catch (e) {\n lastErr = e;\n }\n }\n throw new Error(`uniswap: no RPC answered on chain ${chainId} (${lastErr instanceof Error ? lastErr.message : String(lastErr)})`);\n }\n\n const call = (to: string, data: Hex): RpcCall => ({method: \"eth_call\", params: [{to, data}, \"latest\"]});\n\n /** The pinned addresses still describe one deployment (router + quoter agree on factory and WETH). */\n function verifyDeployment(chainId: number): Promise<void> {\n let p = verified.get(chainId);\n if (!p) {\n const d = deployments[chainId]!;\n p = (async () => {\n const f = encodeFunctionData({abi: ROUTER_ABI, functionName: \"factory\"});\n const w = encodeFunctionData({abi: ROUTER_ABI, functionName: \"WETH9\"});\n const [rf, rw, qf, qw] = await rpc(chainId, [call(d.router, f), call(d.router, w), call(d.quoter, f), call(d.quoter, w)]);\n const addr = (r: unknown) => (typeof r === \"string\" && r.length >= 42 ? getAddress(`0x${r.slice(-40)}`) : null);\n const wrapped = d.nativeWrap === false ? getAddress(ZERO) : getAddress(d.weth);\n const ok = [rf, qf].every((r) => addr(r) === getAddress(d.factory)) && addr(rw) === wrapped && addr(qw) === wrapped;\n if (!ok) throw new Error(`uniswap: the router/quoter on chain ${chainId} do not match the pinned deployment — refusing`);\n })();\n p.catch(() => verified.delete(chainId));\n verified.set(chainId, p);\n }\n return p;\n }\n\n /** Every candidate route for tokenIn → tokenOut on this chain. */\n function routes(chainId: number, caip2: string, tokenIn: Hex, tokenOut: Hex): Route[] {\n const d = deployments[chainId]!;\n const out: Route[] = FEE_TIERS.map((fee) => ({label: `direct ${fee / 10_000}%`, poolFee: `${fee / 10_000}%`, single: {fee}}));\n const mids = new Set<string>();\n for (const sym of HOP_SYMBOLS) {\n const mid = sym === \"WETH\" ? d.weth : ccAsset(caip2, sym)?.contract;\n if (!mid || !/^0x[0-9a-fA-F]{40}$/.test(mid)) continue;\n const m = getAddress(mid);\n if (m === getAddress(tokenIn) || m === getAddress(tokenOut) || mids.has(m)) continue;\n mids.add(m);\n for (const f1 of [100, 500, 3000]) {\n for (const f2 of [100, 500, 3000]) {\n out.push({label: `via ${sym} ${f1 / 10_000}% → ${f2 / 10_000}%`, poolFee: `${f1 / 10_000}% + ${f2 / 10_000}%`, path: encodePacked([\"address\", \"uint24\", \"address\", \"uint24\", \"address\"], [tokenIn, f1, m, f2, tokenOut])});\n }\n }\n }\n return out;\n }\n\n return {\n name: \"uniswap\",\n describeActivity: (tx, ctx) => describeUniswapActivity(tx, ctx, config.deployments ?? UNISWAP_V3),\n supportsSameChain: true,\n enabled: () => config.enabled ?? true,\n supportsChain: (caip2: string) => chainIdOf(caip2) !== null,\n supportsChainPair: (from: string, to: string) => from === to && chainIdOf(from) !== null,\n supportsRoute(from: Asset, to: Asset): boolean {\n return from.chain === to.chain && chainIdOf(from.chain) !== null;\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n const refuse = (why: string): null => {\n params.onRefusal?.(`uniswap: ${why}`);\n return null;\n };\n if (params.flex) return refuse(\"amount-flexible deposits are not supported\");\n if (params.sourceChain !== params.destChain) return refuse(\"same-chain swaps only\");\n const chainId = chainIdOf(params.sourceChain);\n if (chainId === null) return refuse(`no Uniswap v3 deployment or RPC for ${params.sourceChain}`);\n const d = deployments[chainId]!;\n const src = sourceAssetOf(params);\n if (!src) return refuse(`unknown source token ${params.sourceToken}`);\n const nativeIn = !src.contract;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if ((nativeIn || nativeOut) && d.nativeWrap === false) return refuse(\"this chain's router has no wrapped native — swap the coin's ERC-20 instead\");\n if (!nativeOut && !/^0x[0-9a-fA-F]{40}$/.test(params.destToken)) return refuse(\"destination token must be an EVM address\");\n if (!/^0x[0-9a-fA-F]{40}$/.test(params.destAddress)) return refuse(\"recipient must be an EVM address\");\n let amountIn: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n } catch {\n return refuse(\"amount is not an integer\");\n }\n if (amountIn <= 0n) return refuse(\"amount must be positive\");\n const tokenIn = getAddress(nativeIn ? d.weth : src.contract!);\n const tokenOut = getAddress(nativeOut ? d.weth : params.destToken);\n if (tokenIn === tokenOut) return refuse(nativeIn || nativeOut ? \"that is a wrap/unwrap, not a swap\" : \"same token in and out\");\n\n try {\n await verifyDeployment(chainId);\n const candidates = routes(chainId, params.sourceChain, tokenIn, tokenOut);\n const results = await rpc(\n chainId,\n candidates.map((r) =>\n call(\n d.quoter,\n r.single\n ? encodeFunctionData({abi: QUOTER_ABI, functionName: \"quoteExactInputSingle\", args: [{tokenIn, tokenOut, amountIn, fee: r.single.fee, sqrtPriceLimitX96: 0n}]})\n : encodeFunctionData({abi: QUOTER_ABI, functionName: \"quoteExactInput\", args: [r.path!, amountIn]}),\n ),\n ),\n signal,\n );\n let best: {route: Route; out: bigint; gas: bigint} | null = null;\n results.forEach((raw, i) => {\n if (typeof raw !== \"string\" || raw === \"0x\") return;\n const r = candidates[i]!;\n try {\n const [out, , , gas] = decodeFunctionResult({abi: QUOTER_ABI, functionName: r.single ? \"quoteExactInputSingle\" : \"quoteExactInput\", data: raw as Hex}) as readonly [bigint, unknown, unknown, bigint];\n if (out > 0n && (!best || out > best.out)) best = {route: r, out, gas};\n } catch {\n /* a malformed slot is just not a candidate */\n }\n });\n if (!best) return refuse(\"no Uniswap v3 pool route for this pair and amount\");\n const {route, out, gas} = best as {route: Route; out: bigint; gas: bigint};\n\n // Price impact (SDK-127): a probe 1/1000 the size on the same route gives the pool's\n // marginal rate; the full-size rate's shortfall against it is the impact. Pool fees\n // are paid on both sides, so they cancel. Informational — the Oct 16 run swapped\n // 16.78 USDT into 0.0099 USDT0 through an empty pool and nothing said a word.\n let priceImpactBps: number | undefined;\n const probeIn = amountIn / 1000n;\n if (probeIn > 0n) {\n try {\n const [raw] = await rpc(\n chainId,\n [call(d.quoter, route.single\n ? encodeFunctionData({abi: QUOTER_ABI, functionName: \"quoteExactInputSingle\", args: [{tokenIn, tokenOut, amountIn: probeIn, fee: route.single.fee, sqrtPriceLimitX96: 0n}]})\n : encodeFunctionData({abi: QUOTER_ABI, functionName: \"quoteExactInput\", args: [route.path!, probeIn]}))],\n signal,\n );\n if (typeof raw === \"string\" && raw !== \"0x\") {\n const [probeOut] = decodeFunctionResult({abi: QUOTER_ABI, functionName: route.single ? \"quoteExactInputSingle\" : \"quoteExactInput\", data: raw as Hex}) as readonly [bigint];\n if (probeOut > 0n) {\n const ratioBps = (out * probeIn * 10_000n) / (probeOut * amountIn); // (out/amountIn) ÷ (probeOut/probeIn), in bps\n priceImpactBps = Math.max(0, bigintToNumber(10_000n - ratioBps));\n }\n }\n } catch {\n /* the quote stands; impact is information, not a gate */\n }\n }\n\n const bps = params.slippageBps ?? slippageDefault;\n const minOut = (out * BigInt(10_000 - bps)) / 10_000n;\n if (params.minAmountOut !== undefined && minOut < BigInt(params.minAmountOut)) {\n return refuse(`floor breach (min=${minOut} < floor=${params.minAmountOut})`);\n }\n const recipient = getAddress(params.destAddress);\n const swapTo = nativeOut ? ADDRESS_THIS : recipient;\n const swap = route.single\n ? encodeFunctionData({abi: ROUTER_ABI, functionName: \"exactInputSingle\", args: [{tokenIn, tokenOut, fee: route.single.fee, recipient: swapTo as Hex, amountIn, amountOutMinimum: minOut, sqrtPriceLimitX96: 0n}]})\n : encodeFunctionData({abi: ROUTER_ABI, functionName: \"exactInput\", args: [{path: route.path!, recipient: swapTo as Hex, amountIn, amountOutMinimum: minOut}]});\n const legs: Hex[] = [swap];\n if (nativeOut) legs.push(encodeFunctionData({abi: ROUTER_ABI, functionName: \"unwrapWETH9\", args: [minOut, recipient]}));\n const deadline = BigInt(Math.floor(Date.now() / 1000) + deadlineS);\n const data = encodeFunctionData({abi: ROUTER_ABI, functionName: \"multicall\", args: [deadline, legs]});\n // Quoter gas covers the pool hops; the router's own overhead and an unwrap ride on top. A figure no real pool\n // swap can cost (0 from a quoter that does not measure gas) is no figure: the limit is then left to the\n // wallet, which estimates the exact call with headroom right before broadcast, as for THORChain and Chainflip.\n // A limit derived from it would be the bare overhead, and the swap would run out of gas on chain.\n const pools = route.single ? 1n : BigInt((route.path!.length - 42) / 46);\n const gasLimit = gas >= MIN_POOL_GAS * pools ? (gas * 3n) / 2n + 120_000n + (nativeOut ? 40_000n : 0n) : undefined;\n\n return {\n provider: \"uniswap\",\n intentId: `uniswap:${chainId}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {\n to: d.router,\n data,\n value: nativeIn ? amountIn.toString() : \"0\",\n chainId,\n ...(gasLimit !== undefined ? {gasLimit: gasLimit.toString()} : {}),\n ...(nativeIn ? {} : {approvalAddress: d.router}),\n },\n sourceAmount: amountIn.toString(),\n destAmount: out.toString(),\n minDestAmount: minOut.toString(),\n feeUsd: 0,\n etaSeconds: 15,\n reliability: 0.98,\n validUntilMs: Date.now() + ttl,\n providerData: {\n route: route.label,\n poolFee: route.poolFee,\n router: d.router,\n tokenIn,\n tokenOut,\n amountIn: amountIn.toString(),\n minOut: minOut.toString(),\n ...(route.single ? {fee: String(route.single.fee)} : {path: route.path!}),\n ...(priceImpactBps !== undefined ? {priceImpactBps: String(priceImpactBps)} : {}),\n },\n };\n } catch (e) {\n return refuse(e instanceof Error ? e.message.replace(/^uniswap: /, \"\") : String(e));\n }\n },\n\n /**\n * Right before broadcast (after any approval): re-quote the SAME route on\n * chain. If the pool now pays less than the signed minimum, the swap would\n * only revert and burn gas — refuse it here with the reason instead.\n */\n async preflightDeposit(quote: Quote): Promise<void> {\n const chainId = Number(quote.intentId.split(\":\")[1]);\n const d = deployments[chainId];\n const pd = quote.providerData ?? {};\n if (!d || !pd.amountIn || !pd.minOut || !pd.tokenIn || !pd.tokenOut) return;\n const data = pd.fee\n ? encodeFunctionData({abi: QUOTER_ABI, functionName: \"quoteExactInputSingle\", args: [{tokenIn: pd.tokenIn as Hex, tokenOut: pd.tokenOut as Hex, amountIn: BigInt(pd.amountIn), fee: Number(pd.fee), sqrtPriceLimitX96: 0n}]})\n : encodeFunctionData({abi: QUOTER_ABI, functionName: \"quoteExactInput\", args: [pd.path as Hex, BigInt(pd.amountIn)]});\n const [raw] = await rpc(chainId, [call(d.quoter, data)]);\n if (typeof raw !== \"string\" || raw === \"0x\") throw new Error(\"uniswap: the pool no longer quotes this route — refresh and try again\");\n const [out] = decodeFunctionResult({abi: QUOTER_ABI, functionName: pd.fee ? \"quoteExactInputSingle\" : \"quoteExactInput\", data: raw as Hex}) as readonly [bigint];\n if (out < BigInt(pd.minOut)) {\n throw new Error(`uniswap: price moved — the pool now pays ${out}, under your minimum ${pd.minOut}. Nothing was sent; refresh the quote.`);\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n if (!tx?.to || !tx.data) throw new Error(\"swap2: Uniswap quote has no transaction request\");\n return {\n chain: \"\",\n to: tx.to,\n value: tx.value ?? \"0\",\n data: tx.data,\n ...(tx.chainId !== undefined ? {chainId: tx.chainId} : {}),\n ...(tx.gasLimit ? {gasLimit: tx.gasLimit} : {}),\n ...(tx.approvalAddress ? {approvalAddress: tx.approvalAddress} : {}),\n };\n },\n\n /** Same-chain: the swap is done when its transaction is mined successfully. */\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (!ref.sourceTxHash) return {state: \"pending\"};\n const chainId = Number(ref.intentId.split(\":\")[1]);\n if (!deployments[chainId] || !config.rpcUrls[chainId]?.length) return {state: \"pending\"};\n try {\n const [receipt] = (await rpc(chainId, [{method: \"eth_getTransactionReceipt\", params: [ref.sourceTxHash]}])) as [{status?: string} | null];\n if (!receipt) return {state: \"pending\"};\n return receipt.status === \"0x1\" ? {state: \"completed\", destTxHash: ref.sourceTxHash} : {state: \"failed\"};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAQ,sBAAsB,oBAAoB,cAAc,YAAY,gBAAyB;AAErG,SAAQ,eAAc;AACtB,SAAQ,QAAQ,OAAO,eAAe,qBAAoB;AAG1D,SAAQ,sBAAqB;AAgB7B,IAAM,OAAO;AACb,IAAM,uBAAuB;AAI7B,IAAM,iBAAiB;AACvB,IAAM,qBAAqB;AAG3B,IAAM,eAAe;AAErB,IAAM,aAAa,SAAS;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AA4BD,IAAM,gBAAgB;AAEf,SAAS,gBAAgB,QAAmD;AACjF,QAAM,cAAc,OAAO,eAAe;AAC1C,QAAM,kBAAkB,OAAO,sBAAsB;AACrD,QAAM,MAAM,OAAO,cAAc;AACjC,QAAM,YAAY,OAAO,mBAAmB;AAC5C,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,mBAAmB,KAAK,mBAAmB,IAAO,OAAM,IAAI,MAAM,6CAA6C;AACzJ,QAAM,WAAW,oBAAI,IAA2B;AAEhD,QAAM,YAAY,CAAC,UAAiC;AAClD,QAAI,CAAC,MAAM,KAAK,EAAG,QAAO;AAC1B,UAAM,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} from "./chunk-
|
|
6
|
+
} from "./chunk-SXUKROTA.js";
|
|
7
7
|
|
|
8
8
|
// src/protocol.ts
|
|
9
9
|
import { SingleProviderSwap2 } from "@anywalletkit/protocol-swap2-core/swap2/single";
|
|
@@ -29,4 +29,4 @@ var UniswapSwap2Protocol = class extends SingleProviderSwap2 {
|
|
|
29
29
|
export {
|
|
30
30
|
UniswapSwap2Protocol
|
|
31
31
|
};
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-QQGCEDT3.js.map
|
|
@@ -12,20 +12,22 @@ var UNISWAP_V3 = Object.freeze({
|
|
|
12
12
|
137: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270" },
|
|
13
13
|
8453: { factory: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD", quoter: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", router: "0x2626664c2603336E57B271c5C0b26F421741e481", weth: "0x4200000000000000000000000000000000000006" },
|
|
14
14
|
42161: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" },
|
|
15
|
-
// zkSync Era and Celo:
|
|
15
|
+
// zkSync Era and Celo: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04. Celo's
|
|
16
|
+
// router and quoter report WETH9 0x0, so `weth` there is the CELO ERC-20, used only as the two-hop token.
|
|
16
17
|
324: { factory: "0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422", quoter: "0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28", router: "0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3", weth: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91" },
|
|
17
18
|
42220: { factory: "0xAfE208a311B21f13EF87E33A90049fC17A7acDEc", quoter: "0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8", router: "0x5615CDAb10dc425a742d643d949a7F474C01abc4", weth: "0x471EcE3750Da237f93B8E339c536989b8978a438", nativeWrap: false },
|
|
18
|
-
// Unichain, Monad, Linea: Uniswap's
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
19
|
+
// Unichain, Monad, Linea: factory, QuoterV2 and SwapRouter02 as Uniswap's deployments.json lists them (status
|
|
20
|
+
// active), verified on-chain 2026-11-04: router + quoter report the factory and WETH9, and the quoter's gasEstimate
|
|
21
|
+
// is non-zero. The old `Quoter` on these chains (deprecated) quotes the same amounts but always reports gas 0.
|
|
22
|
+
130: { factory: "0x1F98400000000000000000000000000000000003", quoter: "0x385A5cf5F83e99f7BB2852b6A19C3538b9FA7658", router: "0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C", weth: "0x4200000000000000000000000000000000000006" },
|
|
23
|
+
143: { factory: "0x204FAca1764B154221e35c0d20aBb3c525710498", quoter: "0x661E93cca42AfacB172121EF892830cA3b70F08d", router: "0xfE31F71C1b106EAc32F1A19239c9a9A72ddfb900", weth: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A" },
|
|
24
|
+
59144: { factory: "0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9", quoter: "0x42bE4D6527829FeFA1493e1fb9F3676d2425C3C1", router: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", weth: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f" },
|
|
25
|
+
// World Chain, Ink, X Layer: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04
|
|
26
|
+
// (router + quoter report the factory and WETH9; X Layer's router wraps WOKB).
|
|
25
27
|
480: { factory: "0x7a5028BDa40e7B173C278C5342087826455ea25a", quoter: "0x10158D43e6cc414deE1Bd1eB0EfC6a5cBCfF244c", router: "0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6", weth: "0x4200000000000000000000000000000000000006" },
|
|
26
28
|
57073: { factory: "0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424", quoter: "0x96b572D2d880cf2Fa2563651BD23ADE6f5516652", router: "0x177778F19E89dD1012BdBe603F144088A95C4B53", weth: "0x4200000000000000000000000000000000000006" },
|
|
27
|
-
196: { factory: "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804", quoter: "
|
|
28
|
-
// Robinhood Chain:
|
|
29
|
+
196: { factory: "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804", quoter: "0xD1b797D92d87B688193A2B976eFc8D577D204343", router: "0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA", weth: "0xe538905cf8410324e03A5A23C1c177a474D59b2b" },
|
|
30
|
+
// Robinhood Chain: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04.
|
|
29
31
|
4663: { factory: "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA", quoter: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7", router: "0xCaf681a66D020601342297493863E78C959E5cb2", weth: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73" },
|
|
30
32
|
43114: { factory: "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD", quoter: "0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F", router: "0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE", weth: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" }
|
|
31
33
|
});
|
|
@@ -155,4 +157,4 @@ export {
|
|
|
155
157
|
UNISWAP_ROUTER_SELECTORS,
|
|
156
158
|
describeUniswapActivity
|
|
157
159
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
160
|
+
//# sourceMappingURL=chunk-SXUKROTA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/activity.ts","../src/addresses.ts"],"sourcesContent":["/**\n * Activity recognition for Uniswap v3: a call into the chain's SwapRouter02\n * (the deployment table, or the caller's override) with one of the router's\n * swap entry points → `swap`, \"Swapped A → B\" from the owner's net transfers.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {UNISWAP_V3, type UniswapDeployment} from \"./addresses.js\";\n\nexport const UNISWAP_MODULE = \"@anywalletkit/protocol-swap2-uniswap\";\n\n/** SwapRouter02 entry points (`viem toFunctionSelector`, 2026-10-14). */\nexport const UNISWAP_ROUTER_SELECTORS: ReadonlySet<string> = new Set([\n \"0x5ae401dc\", // multicall(uint256 deadline, bytes[] data)\n \"0xac9650d8\", // multicall(bytes[] data)\n \"0x1f0464d1\", // multicall(bytes32 previousBlockhash, bytes[] data)\n \"0x04e45aaf\", // exactInputSingle((address,address,uint24,address,uint256,uint256,uint160))\n \"0xb858183f\", // exactInput((bytes,address,uint256,uint256))\n \"0x5023b4df\", // exactOutputSingle((address,address,uint24,address,uint256,uint256,uint160))\n \"0x09b81346\", // exactOutput((bytes,address,uint256,uint256))\n]);\n\nexport function describeUniswapActivity(\n tx: ChainTx,\n ctx: DescribeActivityContext,\n deployments: Readonly<Record<number, UniswapDeployment>> = UNISWAP_V3,\n): ActivityItem | null {\n if (!isEvm(tx.chain)) return null;\n const deployment = deployments[evmRef(tx.chain)];\n if (!deployment || !matchesCall(tx, [deployment.router], UNISWAP_ROUTER_SELECTORS)) return null;\n return describeSwapLike(tx, ctx, {protocol: UNISWAP_MODULE, subtitle: `Uniswap v3 · ${chainLabel(tx.chain)}`, kind: \"swap\"});\n}\n","import {decodeFunctionData, getAddress, parseAbi, type Hex} from \"viem\";\nimport {sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Quote, QuoteParams, RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\n\n/**\n * Uniswap v3 deployments this module trusts: the UniswapV3Factory, QuoterV2 and\n * SwapRouter02 that Uniswap's deployments.json lists as active on each chain\n * (re-checked 2026-11-04). Every entry was checked on-chain: SwapRouter02.factory()\n * and QuoterV2.factory() both return `factory`, and both report `weth` as WETH9\n * (on Celo both report 0x0 — see `nativeWrap`).\n * The provider re-checks the same facts once per chain at runtime before quoting\n * (see `verifyDeployment`).\n */\nexport interface UniswapDeployment {\n factory: `0x${string}`;\n quoter: `0x${string}`;\n router: `0x${string}`;\n /** The chain's wrapped native token (WETH, WBNB, WPOL, WAVAX) — on a chain\n * without one (Celo), the hop token used for two-hop routes instead. */\n weth: `0x${string}`;\n /** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */\n nativeWrap?: false;\n}\n\nexport const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>> = Object.freeze({\n 1: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"},\n 10: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x4200000000000000000000000000000000000006\"},\n 56: {factory: \"0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7\", quoter: \"0x78D78E420Da98ad378D7799bE8f4AF69033EB077\", router: \"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2\", weth: \"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c\"},\n 137: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270\"},\n 8453: {factory: \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\", quoter: \"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a\", router: \"0x2626664c2603336E57B271c5C0b26F421741e481\", weth: \"0x4200000000000000000000000000000000000006\"},\n 42161: {factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\", quoter: \"0x61fFE014bA17989E743c5F6cB21bF9697530B21e\", router: \"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45\", weth: \"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1\"},\n // zkSync Era and Celo: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04. Celo's\n // router and quoter report WETH9 0x0, so `weth` there is the CELO ERC-20, used only as the two-hop token.\n 324: {factory: \"0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422\", quoter: \"0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28\", router: \"0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3\", weth: \"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91\"},\n 42220: {factory: \"0xAfE208a311B21f13EF87E33A90049fC17A7acDEc\", quoter: \"0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8\", router: \"0x5615CDAb10dc425a742d643d949a7F474C01abc4\", weth: \"0x471EcE3750Da237f93B8E339c536989b8978a438\", nativeWrap: false},\n // Unichain, Monad, Linea: factory, QuoterV2 and SwapRouter02 as Uniswap's deployments.json lists them (status\n // active), verified on-chain 2026-11-04: router + quoter report the factory and WETH9, and the quoter's gasEstimate\n // is non-zero. The old `Quoter` on these chains (deprecated) quotes the same amounts but always reports gas 0.\n 130: {factory: \"0x1F98400000000000000000000000000000000003\", quoter: \"0x385A5cf5F83e99f7BB2852b6A19C3538b9FA7658\", router: \"0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C\", weth: \"0x4200000000000000000000000000000000000006\"},\n 143: {factory: \"0x204FAca1764B154221e35c0d20aBb3c525710498\", quoter: \"0x661E93cca42AfacB172121EF892830cA3b70F08d\", router: \"0xfE31F71C1b106EAc32F1A19239c9a9A72ddfb900\", weth: \"0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A\"},\n 59144: {factory: \"0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9\", quoter: \"0x42bE4D6527829FeFA1493e1fb9F3676d2425C3C1\", router: \"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a\", weth: \"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f\"},\n // World Chain, Ink, X Layer: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04\n // (router + quoter report the factory and WETH9; X Layer's router wraps WOKB).\n 480: {factory: \"0x7a5028BDa40e7B173C278C5342087826455ea25a\", quoter: \"0x10158D43e6cc414deE1Bd1eB0EfC6a5cBCfF244c\", router: \"0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6\", weth: \"0x4200000000000000000000000000000000000006\"},\n 57073: {factory: \"0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424\", quoter: \"0x96b572D2d880cf2Fa2563651BD23ADE6f5516652\", router: \"0x177778F19E89dD1012BdBe603F144088A95C4B53\", weth: \"0x4200000000000000000000000000000000000006\"},\n 196: {factory: \"0x4B2ab38DBF28D31D467aA8993f6c2585981D6804\", quoter: \"0xD1b797D92d87B688193A2B976eFc8D577D204343\", router: \"0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA\", weth: \"0xe538905cf8410324e03A5A23C1c177a474D59b2b\"},\n // Robinhood Chain: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04.\n 4663: {factory: \"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA\", quoter: \"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7\", router: \"0xCaf681a66D020601342297493863E78C959E5cb2\", weth: \"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73\"},\n 43114: {factory: \"0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD\", quoter: \"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F\", router: \"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE\", weth: \"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7\"},\n});\n\n/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */\nexport const FEE_TIERS = [100, 500, 3000, 10000] as const;\n/** Two-hop routes go through these (when the catalog knows them on the chain). */\nexport const HOP_SYMBOLS = [\"WETH\", \"USDC\", \"USDT\"] as const;\n/** SwapRouter02 recipient sentinel: \"keep the output in the router\" (then unwrapWETH9). */\nexport const ADDRESS_THIS = \"0x0000000000000000000000000000000000000002\";\n\n/** The SwapRouter02 entry points this module writes (and the deployment probes). */\nexport const ROUTER_ABI = parseAbi([\n \"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)\",\n \"function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)\",\n \"function unwrapWETH9(uint256 amountMinimum, address recipient) payable\",\n \"function multicall(uint256 deadline, bytes[] data) payable returns (bytes[] results)\",\n \"function factory() view returns (address)\",\n \"function WETH9() view returns (address)\",\n]);\n/** Most pools one `exactInput` path may cross: the provider builds direct and one-hop (two-pool) routes only. */\nconst MAX_PATH_POOLS = 2;\n\n/**\n * The swap a Uniswap quote's router call makes, opened on the client against the app's own request (scan 2026-10-28,\n * F1): one `multicall(deadline, legs)` on the chain's pinned SwapRouter02 whose legs are exactly one `exactInputSingle`\n * or `exactInput` — then `unwrapWETH9` for a native output — selling exactly the input of the source token (WETH for a\n * native input, paid as `value`) for the destination token, with `amountOutMinimum` the quote's minimum, paid to the\n * recipient (or kept in the router and unwrapped to the recipient for that same minimum). `pull`, `sweepToken` and\n * every other router call are refused. The reason it fails, or null.\n */\nexport function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;\n const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : undefined;\n if (!d || params.destChain !== params.sourceChain) return \"not a same-chain swap on a pinned Uniswap deployment\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no router call\";\n if (getAddress(tx.to) !== getAddress(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;\n const src = sourceAssetOf(params);\n if (!src) return `unknown source token ${params.sourceToken}`;\n const nativeIn = !src.contract;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if ((nativeIn || nativeOut) && d.nativeWrap === false) return \"this chain's router has no wrapped native\";\n let tokenIn: string, tokenOut: string, recipient: string, amountIn: bigint, minOut: bigint;\n try {\n tokenIn = getAddress(nativeIn ? d.weth : src.contract!);\n tokenOut = getAddress(nativeOut ? d.weth : params.destToken);\n recipient = getAddress(params.destAddress);\n amountIn = BigInt(params.amountIn);\n minOut = BigInt(quote.minDestAmount);\n } catch {\n return \"the request does not name EVM tokens, a recipient and amounts\";\n }\n if (nativeIn ? BigInt(tx.value ?? \"0\") !== amountIn || tx.approvalAddress !== undefined\n : BigInt(tx.value ?? \"0\") !== 0n || !tx.approvalAddress || getAddress(tx.approvalAddress) !== getAddress(d.router)) {\n return nativeIn ? \"a native input is paid as exactly the input in value, with no approval\" : \"a token input attaches no value and approves the SwapRouter\";\n }\n let legs: readonly Hex[];\n try {\n const outer = decodeFunctionData({abi: ROUTER_ABI, data: tx.data as Hex});\n if (outer.functionName !== \"multicall\") return `${outer.functionName} is not multicall(deadline, legs)`;\n legs = outer.args[1];\n } catch {\n return \"the router call is not multicall(deadline, legs)\";\n }\n if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? \" and an unwrap\" : \"\"}`;\n const decode = (leg: Hex) => { try { return decodeFunctionData({abi: ROUTER_ABI, data: leg}); } catch { return null; } };\n const swap = decode(legs[0]!);\n const swapTo = nativeOut ? ADDRESS_THIS : recipient;\n if (swap?.functionName === \"exactInputSingle\") {\n const a = swap.args[0];\n if (getAddress(a.tokenIn) !== tokenIn || getAddress(a.tokenOut) !== tokenOut) return \"the swap trades other tokens\";\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return \"the swap's input, minimum or price limit is not the quote's\";\n if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;\n } else if (swap?.functionName === \"exactInput\") {\n const a = swap.args[0];\n const path = a.path.slice(2);\n const pools = (path.length / 2 - 20) / 23;\n if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return \"the swap path is not 1–2 pools\";\n if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return \"the swap path trades other tokens\";\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return \"the swap's input or minimum is not the quote's\";\n if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;\n } else {\n return `${swap?.functionName ?? \"an unknown call\"} is not exactInputSingle / exactInput`;\n }\n if (nativeOut) {\n const unwrap = decode(legs[1]!);\n if (unwrap?.functionName !== \"unwrapWETH9\") return `${unwrap?.functionName ?? \"an unknown call\"} is not unwrapWETH9`;\n if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return \"the unwrap pays someone else or less than the minimum\";\n }\n return null;\n}\n\n/**\n * The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and\n * {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: \"uniswap\", baseUrl, ...uniswapPins})` (scan\n * 2026-10-27 modules, F9; scan 2026-10-28, F1).\n */\nexport const uniswapPins: RemotePins = Object.freeze({\n callTargets: (chain: string): readonly string[] => uniswapRouterFor(chain),\n spenders: (chain: string): readonly string[] => uniswapRouterFor(chain),\n verifyQuote: uniswapVerifyQuote,\n});\nfunction uniswapRouterFor(chain: string): readonly string[] {\n const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;\n const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : undefined;\n return d ? [d.router] : [];\n}\n"],"mappings":";AAMA,SAAQ,YAAY,kBAAkB,mBAAkB;AACxD,SAAQ,QAAQ,aAAY;;;ACP5B,SAAQ,oBAAoB,YAAY,gBAAyB;AACjE,SAAQ,qBAAoB;AAuBrB,IAAM,aAA0D,OAAO,OAAO;AAAA,EACnF,GAAG,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EACzN,IAAI,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC1N,IAAI,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC1N,KAAK,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC3N,MAAM,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC5N,OAAO,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA;AAAA;AAAA,EAG7N,KAAK,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,6CAA4C;AAAA,EAC3N,OAAO,EAAC,SAAS,8CAA8C,QAAQ,8CAA8C,QAAQ,8CAA8C,MAAM,8CAA8C,YAAY,MAAK;AAAA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AAgB,iBAAiB;AAC/F,QAAI,OAAO,KAAK,CAAC,MAAM,UAAU,WAAW,OAAO,KAAK,CAAC,CAAC,MAAM,UAAW,QAAO;AAAA,EACpF;AACA,SAAO;AACT;AAOO,IAAM,cAA0B,OAAO,OAAO;AAAA,EACnD,aAAa,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACzE,UAAU,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACtE,aAAa;AACf,CAAC;AACD,SAAS,iBAAiB,OAAkC;AAC1D,QAAM,KAAK,kBAAkB,KAAK,KAAK,IAAI,OAAO,MAAM,MAAM,CAAC,CAAC,IAAI;AACpE,QAAM,IAAI,OAAO,UAAU,eAAe,KAAK,YAAY,EAAE,IAAI,WAAW,EAAE,IAAI;AAClF,SAAO,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;AAC3B;;;ADhJO,IAAM,iBAAiB;AAGvB,IAAM,2BAAgD,oBAAI,IAAI;AAAA,EACnE;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF,CAAC;AAEM,SAAS,wBACd,IACA,KACA,cAA2D,YACtC;AACrB,MAAI,CAAC,MAAM,GAAG,KAAK,EAAG,QAAO;AAC7B,QAAM,aAAa,YAAY,OAAO,GAAG,KAAK,CAAC;AAC/C,MAAI,CAAC,cAAc,CAAC,YAAY,IAAI,CAAC,WAAW,MAAM,GAAG,wBAAwB,EAAG,QAAO;AAC3F,SAAO,iBAAiB,IAAI,KAAK,EAAC,UAAU,gBAAgB,UAAU,mBAAgB,WAAW,GAAG,KAAK,CAAC,IAAI,MAAM,OAAM,CAAC;AAC7H;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -46,20 +46,22 @@ var UNISWAP_V3 = Object.freeze({
|
|
|
46
46
|
137: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270" },
|
|
47
47
|
8453: { factory: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD", quoter: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", router: "0x2626664c2603336E57B271c5C0b26F421741e481", weth: "0x4200000000000000000000000000000000000006" },
|
|
48
48
|
42161: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" },
|
|
49
|
-
// zkSync Era and Celo:
|
|
49
|
+
// zkSync Era and Celo: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04. Celo's
|
|
50
|
+
// router and quoter report WETH9 0x0, so `weth` there is the CELO ERC-20, used only as the two-hop token.
|
|
50
51
|
324: { factory: "0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422", quoter: "0x8Cb537fc92E26d8EBBb760E632c95484b6Ea3e28", router: "0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3", weth: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91" },
|
|
51
52
|
42220: { factory: "0xAfE208a311B21f13EF87E33A90049fC17A7acDEc", quoter: "0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8", router: "0x5615CDAb10dc425a742d643d949a7F474C01abc4", weth: "0x471EcE3750Da237f93B8E339c536989b8978a438", nativeWrap: false },
|
|
52
|
-
// Unichain, Monad, Linea: Uniswap's
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//
|
|
53
|
+
// Unichain, Monad, Linea: factory, QuoterV2 and SwapRouter02 as Uniswap's deployments.json lists them (status
|
|
54
|
+
// active), verified on-chain 2026-11-04: router + quoter report the factory and WETH9, and the quoter's gasEstimate
|
|
55
|
+
// is non-zero. The old `Quoter` on these chains (deprecated) quotes the same amounts but always reports gas 0.
|
|
56
|
+
130: { factory: "0x1F98400000000000000000000000000000000003", quoter: "0x385A5cf5F83e99f7BB2852b6A19C3538b9FA7658", router: "0x73855d06DE49d0fe4A9c42636Ba96c62da12FF9C", weth: "0x4200000000000000000000000000000000000006" },
|
|
57
|
+
143: { factory: "0x204FAca1764B154221e35c0d20aBb3c525710498", quoter: "0x661E93cca42AfacB172121EF892830cA3b70F08d", router: "0xfE31F71C1b106EAc32F1A19239c9a9A72ddfb900", weth: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A" },
|
|
58
|
+
59144: { factory: "0x31FAfd4889FA1269F7a13A66eE0fB458f27D72A9", quoter: "0x42bE4D6527829FeFA1493e1fb9F3676d2425C3C1", router: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", weth: "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f" },
|
|
59
|
+
// World Chain, Ink, X Layer: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04
|
|
60
|
+
// (router + quoter report the factory and WETH9; X Layer's router wraps WOKB).
|
|
59
61
|
480: { factory: "0x7a5028BDa40e7B173C278C5342087826455ea25a", quoter: "0x10158D43e6cc414deE1Bd1eB0EfC6a5cBCfF244c", router: "0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6", weth: "0x4200000000000000000000000000000000000006" },
|
|
60
62
|
57073: { factory: "0x640887A9ba3A9C53Ed27D0F7e8246A4F933f3424", quoter: "0x96b572D2d880cf2Fa2563651BD23ADE6f5516652", router: "0x177778F19E89dD1012BdBe603F144088A95C4B53", weth: "0x4200000000000000000000000000000000000006" },
|
|
61
|
-
196: { factory: "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804", quoter: "
|
|
62
|
-
// Robinhood Chain:
|
|
63
|
+
196: { factory: "0x4B2ab38DBF28D31D467aA8993f6c2585981D6804", quoter: "0xD1b797D92d87B688193A2B976eFc8D577D204343", router: "0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA", weth: "0xe538905cf8410324e03A5A23C1c177a474D59b2b" },
|
|
64
|
+
// Robinhood Chain: as Uniswap's deployments.json lists them (status active), verified on-chain 2026-11-04.
|
|
63
65
|
4663: { factory: "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA", quoter: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7", router: "0xCaf681a66D020601342297493863E78C959E5cb2", weth: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73" },
|
|
64
66
|
43114: { factory: "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD", quoter: "0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F", router: "0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE", weth: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" }
|
|
65
67
|
});
|
|
@@ -190,6 +192,7 @@ var ZERO = "0x0000000000000000000000000000000000000000";
|
|
|
190
192
|
var DEFAULT_SLIPPAGE_BPS = 50;
|
|
191
193
|
var DEFAULT_TTL_MS = 3e5;
|
|
192
194
|
var DEFAULT_DEADLINE_S = 600;
|
|
195
|
+
var MIN_POOL_GAS = 20000n;
|
|
193
196
|
var QUOTER_ABI = (0, import_viem2.parseAbi)([
|
|
194
197
|
"function quoteExactInputSingle((address tokenIn, address tokenOut, uint256 amountIn, uint24 fee, uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)",
|
|
195
198
|
"function quoteExactInput(bytes path, uint256 amountIn) returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)",
|
|
@@ -248,7 +251,7 @@ function uniswapProvider(config) {
|
|
|
248
251
|
const [rf, rw, qf, qw] = await rpc(chainId, [call(d.router, f), call(d.router, w), call(d.quoter, f), call(d.quoter, w)]);
|
|
249
252
|
const addr = (r) => typeof r === "string" && r.length >= 42 ? (0, import_viem2.getAddress)(`0x${r.slice(-40)}`) : null;
|
|
250
253
|
const wrapped = d.nativeWrap === false ? (0, import_viem2.getAddress)(ZERO) : (0, import_viem2.getAddress)(d.weth);
|
|
251
|
-
const ok = [rf, qf].every((r) => addr(r) === (0, import_viem2.getAddress)(d.factory)) && addr(rw) === wrapped &&
|
|
254
|
+
const ok = [rf, qf].every((r) => addr(r) === (0, import_viem2.getAddress)(d.factory)) && addr(rw) === wrapped && addr(qw) === wrapped;
|
|
252
255
|
if (!ok) throw new Error(`uniswap: the router/quoter on chain ${chainId} do not match the pinned deployment \u2014 refusing`);
|
|
253
256
|
})();
|
|
254
257
|
p.catch(() => verified.delete(chainId));
|
|
@@ -367,7 +370,8 @@ function uniswapProvider(config) {
|
|
|
367
370
|
if (nativeOut) legs.push((0, import_viem2.encodeFunctionData)({ abi: ROUTER_ABI, functionName: "unwrapWETH9", args: [minOut, recipient] }));
|
|
368
371
|
const deadline = BigInt(Math.floor(Date.now() / 1e3) + deadlineS);
|
|
369
372
|
const data = (0, import_viem2.encodeFunctionData)({ abi: ROUTER_ABI, functionName: "multicall", args: [deadline, legs] });
|
|
370
|
-
const
|
|
373
|
+
const pools = route.single ? 1n : BigInt((route.path.length - 42) / 46);
|
|
374
|
+
const gasLimit = gas >= MIN_POOL_GAS * pools ? gas * 3n / 2n + 120000n + (nativeOut ? 40000n : 0n) : void 0;
|
|
371
375
|
return {
|
|
372
376
|
provider: "uniswap",
|
|
373
377
|
intentId: `uniswap:${chainId}`,
|
|
@@ -378,7 +382,7 @@ function uniswapProvider(config) {
|
|
|
378
382
|
data,
|
|
379
383
|
value: nativeIn ? amountIn.toString() : "0",
|
|
380
384
|
chainId,
|
|
381
|
-
gasLimit: gasLimit.toString(),
|
|
385
|
+
...gasLimit !== void 0 ? { gasLimit: gasLimit.toString() } : {},
|
|
382
386
|
...nativeIn ? {} : { approvalAddress: d.router }
|
|
383
387
|
},
|
|
384
388
|
sourceAmount: amountIn.toString(),
|