@anywalletkit/protocol-swap2-uniswap 0.4.4 → 0.4.5

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 CHANGED
@@ -31,6 +31,7 @@ var import_util2 = require("@anywalletkit/protocol-swap2-core/util");
31
31
  // src/addresses.ts
32
32
  var import_viem = require("viem");
33
33
  var import_util = require("@anywalletkit/protocol-swap2-core/util");
34
+ var import_errors = require("@anywalletkit/protocol-swap2-core/errors");
34
35
  var UNISWAP_V3 = Object.freeze({
35
36
  1: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" },
36
37
  10: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x4200000000000000000000000000000000000006" },
@@ -68,18 +69,19 @@ var ROUTER_ABI = (0, import_viem.parseAbi)([
68
69
  "function WETH9() view returns (address)"
69
70
  ]);
70
71
  var MAX_PATH_POOLS = 2;
72
+ var notes = (0, import_errors.refusalNotes)();
71
73
  function uniswapVerifyQuote(params, quote) {
72
74
  const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;
73
75
  const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : void 0;
74
- if (!d || params.destChain !== params.sourceChain) return "not a same-chain swap on a pinned Uniswap deployment";
76
+ if (!d || params.destChain !== params.sourceChain) return notes.note("not a same-chain swap on a pinned Uniswap deployment", "unsupported_pair");
75
77
  const tx = quote.txRequest;
76
- if (!tx?.data || !tx.to || tx.serializedTx !== void 0) return "the quote carries no router call";
77
- if ((0, import_viem.getAddress)(tx.to) !== (0, import_viem.getAddress)(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;
78
+ if (!tx?.data || !tx.to || tx.serializedTx !== void 0) return notes.note("the quote carries no router call", "policy_refused");
79
+ if ((0, import_viem.getAddress)(tx.to) !== (0, import_viem.getAddress)(d.router)) return notes.note(`the call targets ${tx.to}, not the SwapRouter`, "vault_mismatch");
78
80
  const src = (0, import_util.sourceAssetOf)(params);
79
- if (!src) return `unknown source token ${params.sourceToken}`;
81
+ if (!src) return notes.note(`unknown source token ${params.sourceToken}`, "unsupported_pair");
80
82
  const nativeIn = !src.contract;
81
83
  const nativeOut = /^0x0+$/.test(params.destToken);
82
- if ((nativeIn || nativeOut) && d.nativeWrap === false) return "this chain's router has no wrapped native";
84
+ if ((nativeIn || nativeOut) && d.nativeWrap === false) return notes.note("this chain's router has no wrapped native", "unsupported_pair");
83
85
  let tokenIn, tokenOut, recipient, amountIn, minOut;
84
86
  try {
85
87
  tokenIn = (0, import_viem.getAddress)(nativeIn ? d.weth : src.contract);
@@ -91,15 +93,15 @@ function uniswapVerifyQuote(params, quote) {
91
93
  return "the request does not name EVM tokens, a recipient and amounts";
92
94
  }
93
95
  if (nativeIn ? BigInt(tx.value ?? "0") !== amountIn || tx.approvalAddress !== void 0 : BigInt(tx.value ?? "0") !== 0n || !tx.approvalAddress || (0, import_viem.getAddress)(tx.approvalAddress) !== (0, import_viem.getAddress)(d.router)) {
94
- 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";
96
+ return notes.note(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", "policy_refused");
95
97
  }
96
98
  let legs;
97
99
  try {
98
100
  const outer = (0, import_viem.decodeFunctionData)({ abi: ROUTER_ABI, data: tx.data });
99
- if (outer.functionName !== "multicall") return `${outer.functionName} is not multicall(deadline, legs)`;
101
+ if (outer.functionName !== "multicall") return notes.note(`${outer.functionName} is not multicall(deadline, legs)`, "policy_refused");
100
102
  legs = outer.args[1];
101
103
  } catch {
102
- return "the router call is not multicall(deadline, legs)";
104
+ return notes.note("the router call is not multicall(deadline, legs)", "policy_refused");
103
105
  }
104
106
  const decode = (leg) => {
105
107
  try {
@@ -109,36 +111,37 @@ function uniswapVerifyQuote(params, quote) {
109
111
  }
110
112
  };
111
113
  if (nativeIn && legs.length === 2 && decode(legs[1])?.functionName === "refundETH") legs = legs.slice(0, 1);
112
- if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? " and an unwrap" : nativeIn ? " (and a refund)" : ""}`;
114
+ if (legs.length !== (nativeOut ? 2 : 1)) return notes.note(`the multicall has ${legs.length} legs, not a swap${nativeOut ? " and an unwrap" : nativeIn ? " (and a refund)" : ""}`, "policy_refused");
113
115
  const swap = decode(legs[0]);
114
116
  const swapTo = nativeOut ? ADDRESS_THIS : recipient;
115
117
  if (swap?.functionName === "exactInputSingle") {
116
118
  const a = swap.args[0];
117
- if ((0, import_viem.getAddress)(a.tokenIn) !== tokenIn || (0, import_viem.getAddress)(a.tokenOut) !== tokenOut) return "the swap trades other tokens";
118
- if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return "the swap's input, minimum or price limit is not the quote's";
119
- if ((0, import_viem.getAddress)(a.recipient) !== (0, import_viem.getAddress)(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
119
+ if ((0, import_viem.getAddress)(a.tokenIn) !== tokenIn || (0, import_viem.getAddress)(a.tokenOut) !== tokenOut) return notes.note("the swap trades other tokens", "policy_refused");
120
+ if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return notes.note("the swap's input, minimum or price limit is not the quote's", "price_check_failed");
121
+ if ((0, import_viem.getAddress)(a.recipient) !== (0, import_viem.getAddress)(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, "recipient_mismatch");
120
122
  } else if (swap?.functionName === "exactInput") {
121
123
  const a = swap.args[0];
122
124
  const path = a.path.slice(2);
123
125
  const pools = (path.length / 2 - 20) / 23;
124
- if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return "the swap path is not 1\u20132 pools";
125
- if ((0, import_viem.getAddress)(`0x${path.slice(0, 40)}`) !== tokenIn || (0, import_viem.getAddress)(`0x${path.slice(-40)}`) !== tokenOut) return "the swap path trades other tokens";
126
- if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return "the swap's input or minimum is not the quote's";
127
- if ((0, import_viem.getAddress)(a.recipient) !== (0, import_viem.getAddress)(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
126
+ if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return notes.note("the swap path is not 1\u20132 pools", "policy_refused");
127
+ if ((0, import_viem.getAddress)(`0x${path.slice(0, 40)}`) !== tokenIn || (0, import_viem.getAddress)(`0x${path.slice(-40)}`) !== tokenOut) return notes.note("the swap path trades other tokens", "policy_refused");
128
+ if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return notes.note("the swap's input or minimum is not the quote's", "price_check_failed");
129
+ if ((0, import_viem.getAddress)(a.recipient) !== (0, import_viem.getAddress)(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, "recipient_mismatch");
128
130
  } else {
129
- return `${swap?.functionName ?? "an unknown call"} is not exactInputSingle / exactInput`;
131
+ return notes.note(`${swap?.functionName ?? "an unknown call"} is not exactInputSingle / exactInput`, "policy_refused");
130
132
  }
131
133
  if (nativeOut) {
132
134
  const unwrap = decode(legs[1]);
133
- if (unwrap?.functionName !== "unwrapWETH9") return `${unwrap?.functionName ?? "an unknown call"} is not unwrapWETH9`;
134
- if (unwrap.args[0] !== minOut || (0, import_viem.getAddress)(unwrap.args[1]) !== recipient) return "the unwrap pays someone else or less than the minimum";
135
+ if (unwrap?.functionName !== "unwrapWETH9") return notes.note(`${unwrap?.functionName ?? "an unknown call"} is not unwrapWETH9`, "policy_refused");
136
+ if (unwrap.args[0] !== minOut || (0, import_viem.getAddress)(unwrap.args[1]) !== recipient) return notes.note("the unwrap pays someone else or less than the minimum", (0, import_viem.getAddress)(unwrap.args[1]) !== recipient ? "recipient_mismatch" : "price_check_failed");
135
137
  }
136
138
  return null;
137
139
  }
138
140
  var uniswapPins = Object.freeze({
139
141
  callTargets: (chain) => uniswapRouterFor(chain),
140
142
  spenders: (chain) => uniswapRouterFor(chain),
141
- verifyQuote: uniswapVerifyQuote
143
+ verifyQuote: uniswapVerifyQuote,
144
+ reasonOf: (refusal) => notes.reasonOf(refusal)
142
145
  });
143
146
  function uniswapRouterFor(chain) {
144
147
  const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;
@@ -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: 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). USDT0 is the dollar pair on chains\n * without a native USDT (Ink, Unichain, Monad, X Layer, Arbitrum…): on Ink the WETH/USDC pools are dust, and\n * WETH → USDT0 → USDC is the only route with liquidity (matrix v8, 2026-11-07). */\nexport const HOP_SYMBOLS = [\"WETH\", \"USDC\", \"USDT\", \"USDT0\"] 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 refundETH() 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). A native input may end with\n * `refundETH()`, which returns any unspent `value` to the sender (a provider builds it only with `refundNativeInput`,\n * so it is not required). `pull`, `sweepToken` and 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 const decode = (leg: Hex) => { try { return decodeFunctionData({abi: ROUTER_ABI, data: leg}); } catch { return null; } };\n if (nativeIn && legs.length === 2 && decode(legs[1]!)?.functionName === \"refundETH\") legs = legs.slice(0, 1);\n if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? \" and an unwrap\" : nativeIn ? \" (and a refund)\" : \"\"}`;\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;A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,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;;;ADrJO,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,KAAC,oBAAM,GAAG,KAAK,EAAG,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\";\nimport {refusalNotes} from \"@anywalletkit/protocol-swap2-core/errors\";\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). USDT0 is the dollar pair on chains\n * without a native USDT (Ink, Unichain, Monad, X Layer, Arbitrum…): on Ink the WETH/USDC pools are dust, and\n * WETH → USDT0 → USDC is the only route with liquidity (matrix v8, 2026-11-07). */\nexport const HOP_SYMBOLS = [\"WETH\", \"USDC\", \"USDT\", \"USDT0\"] 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 refundETH() 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/** The reasons of the texts {@link uniswapVerifyQuote} returned, for `uniswapPins.reasonOf`. */\nconst notes = refusalNotes();\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). A native input may end with\n * `refundETH()`, which returns any unspent `value` to the sender (a provider builds it only with `refundNativeInput`,\n * so it is not required). `pull`, `sweepToken` and 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 notes.note(\"not a same-chain swap on a pinned Uniswap deployment\", \"unsupported_pair\");\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return notes.note(\"the quote carries no router call\", \"policy_refused\");\n if (getAddress(tx.to) !== getAddress(d.router)) return notes.note(`the call targets ${tx.to}, not the SwapRouter`, \"vault_mismatch\");\n const src = sourceAssetOf(params);\n if (!src) return notes.note(`unknown source token ${params.sourceToken}`, \"unsupported_pair\");\n const nativeIn = !src.contract;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if ((nativeIn || nativeOut) && d.nativeWrap === false) return notes.note(\"this chain's router has no wrapped native\", \"unsupported_pair\");\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 notes.note(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\", \"policy_refused\");\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 notes.note(`${outer.functionName} is not multicall(deadline, legs)`, \"policy_refused\");\n legs = outer.args[1];\n } catch {\n return notes.note(\"the router call is not multicall(deadline, legs)\", \"policy_refused\");\n }\n const decode = (leg: Hex) => { try { return decodeFunctionData({abi: ROUTER_ABI, data: leg}); } catch { return null; } };\n if (nativeIn && legs.length === 2 && decode(legs[1]!)?.functionName === \"refundETH\") legs = legs.slice(0, 1);\n if (legs.length !== (nativeOut ? 2 : 1)) return notes.note(`the multicall has ${legs.length} legs, not a swap${nativeOut ? \" and an unwrap\" : nativeIn ? \" (and a refund)\" : \"\"}`, \"policy_refused\");\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 notes.note(\"the swap trades other tokens\", \"policy_refused\");\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return notes.note(\"the swap's input, minimum or price limit is not the quote's\", \"price_check_failed\");\n if (getAddress(a.recipient) !== getAddress(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, \"recipient_mismatch\");\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 notes.note(\"the swap path is not 1–2 pools\", \"policy_refused\");\n if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return notes.note(\"the swap path trades other tokens\", \"policy_refused\");\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return notes.note(\"the swap's input or minimum is not the quote's\", \"price_check_failed\");\n if (getAddress(a.recipient) !== getAddress(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, \"recipient_mismatch\");\n } else {\n return notes.note(`${swap?.functionName ?? \"an unknown call\"} is not exactInputSingle / exactInput`, \"policy_refused\");\n }\n if (nativeOut) {\n const unwrap = decode(legs[1]!);\n if (unwrap?.functionName !== \"unwrapWETH9\") return notes.note(`${unwrap?.functionName ?? \"an unknown call\"} is not unwrapWETH9`, \"policy_refused\");\n // One text for two checks; the reason names the one that failed (another recipient wins over the amount).\n if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return notes.note(\"the unwrap pays someone else or less than the minimum\", getAddress(unwrap.args[1]) !== recipient ? \"recipient_mismatch\" : \"price_check_failed\");\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). `reasonOf` classifies the texts `uniswapVerifyQuote` returned.\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 reasonOf: (refusal: string) => notes.reasonOf(refusal),\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;AAE5B,oBAA2B;AAsBpB,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,8CAA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K,CAAC,CAAC,MAAM,YAAY,uBAAuB,oBAAoB;AAAA,EAC9O;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;AAAA,EACb,UAAU,CAAC,YAAoB,MAAM,SAAS,OAAO;AACvD,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;;;AD1JO,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,KAAC,oBAAM,GAAG,KAAK,EAAG,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,5 +1,5 @@
1
1
  import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
2
- import { a as UniswapDeployment } from './addresses-Dumvcb4A.cjs';
2
+ import { a as UniswapDeployment } from './addresses-B8Qq_0DN.cjs';
3
3
  import '@anywalletkit/protocol-swap2-core/types';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
2
- import { a as UniswapDeployment } from './addresses-Dumvcb4A.js';
2
+ import { a as UniswapDeployment } from './addresses-B8Qq_0DN.js';
3
3
  import '@anywalletkit/protocol-swap2-core/types';
4
4
 
5
5
  /**
package/dist/activity.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  UNISWAP_MODULE,
3
3
  UNISWAP_ROUTER_SELECTORS,
4
4
  describeUniswapActivity
5
- } from "./chunk-ZOLQRZNH.js";
5
+ } from "./chunk-32CIYNG2.js";
6
6
  export {
7
7
  UNISWAP_MODULE,
8
8
  UNISWAP_ROUTER_SELECTORS,
@@ -151,7 +151,7 @@ declare function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string |
151
151
  /**
152
152
  * The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and
153
153
  * {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: "uniswap", baseUrl, ...uniswapPins})` (scan
154
- * 2026-10-27 modules, F9; scan 2026-10-28, F1).
154
+ * 2026-10-27 modules, F9; scan 2026-10-28, F1). `reasonOf` classifies the texts `uniswapVerifyQuote` returned.
155
155
  */
156
156
  declare const uniswapPins: RemotePins;
157
157
 
@@ -151,7 +151,7 @@ declare function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string |
151
151
  /**
152
152
  * The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and
153
153
  * {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: "uniswap", baseUrl, ...uniswapPins})` (scan
154
- * 2026-10-27 modules, F9; scan 2026-10-28, F1).
154
+ * 2026-10-27 modules, F9; scan 2026-10-28, F1). `reasonOf` classifies the texts `uniswapVerifyQuote` returned.
155
155
  */
156
156
  declare const uniswapPins: RemotePins;
157
157
 
@@ -5,6 +5,7 @@ import { evmRef, isEvm } from "@anywalletkit/protocol-swap2-core/util";
5
5
  // src/addresses.ts
6
6
  import { decodeFunctionData, getAddress, parseAbi } from "viem";
7
7
  import { sourceAssetOf } from "@anywalletkit/protocol-swap2-core/util";
8
+ import { refusalNotes } from "@anywalletkit/protocol-swap2-core/errors";
8
9
  var UNISWAP_V3 = Object.freeze({
9
10
  1: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" },
10
11
  10: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x4200000000000000000000000000000000000006" },
@@ -44,18 +45,19 @@ var ROUTER_ABI = parseAbi([
44
45
  "function WETH9() view returns (address)"
45
46
  ]);
46
47
  var MAX_PATH_POOLS = 2;
48
+ var notes = refusalNotes();
47
49
  function uniswapVerifyQuote(params, quote) {
48
50
  const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;
49
51
  const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : void 0;
50
- if (!d || params.destChain !== params.sourceChain) return "not a same-chain swap on a pinned Uniswap deployment";
52
+ if (!d || params.destChain !== params.sourceChain) return notes.note("not a same-chain swap on a pinned Uniswap deployment", "unsupported_pair");
51
53
  const tx = quote.txRequest;
52
- if (!tx?.data || !tx.to || tx.serializedTx !== void 0) return "the quote carries no router call";
53
- if (getAddress(tx.to) !== getAddress(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;
54
+ if (!tx?.data || !tx.to || tx.serializedTx !== void 0) return notes.note("the quote carries no router call", "policy_refused");
55
+ if (getAddress(tx.to) !== getAddress(d.router)) return notes.note(`the call targets ${tx.to}, not the SwapRouter`, "vault_mismatch");
54
56
  const src = sourceAssetOf(params);
55
- if (!src) return `unknown source token ${params.sourceToken}`;
57
+ if (!src) return notes.note(`unknown source token ${params.sourceToken}`, "unsupported_pair");
56
58
  const nativeIn = !src.contract;
57
59
  const nativeOut = /^0x0+$/.test(params.destToken);
58
- if ((nativeIn || nativeOut) && d.nativeWrap === false) return "this chain's router has no wrapped native";
60
+ if ((nativeIn || nativeOut) && d.nativeWrap === false) return notes.note("this chain's router has no wrapped native", "unsupported_pair");
59
61
  let tokenIn, tokenOut, recipient, amountIn, minOut;
60
62
  try {
61
63
  tokenIn = getAddress(nativeIn ? d.weth : src.contract);
@@ -67,15 +69,15 @@ function uniswapVerifyQuote(params, quote) {
67
69
  return "the request does not name EVM tokens, a recipient and amounts";
68
70
  }
69
71
  if (nativeIn ? BigInt(tx.value ?? "0") !== amountIn || tx.approvalAddress !== void 0 : BigInt(tx.value ?? "0") !== 0n || !tx.approvalAddress || getAddress(tx.approvalAddress) !== getAddress(d.router)) {
70
- 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";
72
+ return notes.note(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", "policy_refused");
71
73
  }
72
74
  let legs;
73
75
  try {
74
76
  const outer = decodeFunctionData({ abi: ROUTER_ABI, data: tx.data });
75
- if (outer.functionName !== "multicall") return `${outer.functionName} is not multicall(deadline, legs)`;
77
+ if (outer.functionName !== "multicall") return notes.note(`${outer.functionName} is not multicall(deadline, legs)`, "policy_refused");
76
78
  legs = outer.args[1];
77
79
  } catch {
78
- return "the router call is not multicall(deadline, legs)";
80
+ return notes.note("the router call is not multicall(deadline, legs)", "policy_refused");
79
81
  }
80
82
  const decode = (leg) => {
81
83
  try {
@@ -85,36 +87,37 @@ function uniswapVerifyQuote(params, quote) {
85
87
  }
86
88
  };
87
89
  if (nativeIn && legs.length === 2 && decode(legs[1])?.functionName === "refundETH") legs = legs.slice(0, 1);
88
- if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? " and an unwrap" : nativeIn ? " (and a refund)" : ""}`;
90
+ if (legs.length !== (nativeOut ? 2 : 1)) return notes.note(`the multicall has ${legs.length} legs, not a swap${nativeOut ? " and an unwrap" : nativeIn ? " (and a refund)" : ""}`, "policy_refused");
89
91
  const swap = decode(legs[0]);
90
92
  const swapTo = nativeOut ? ADDRESS_THIS : recipient;
91
93
  if (swap?.functionName === "exactInputSingle") {
92
94
  const a = swap.args[0];
93
- if (getAddress(a.tokenIn) !== tokenIn || getAddress(a.tokenOut) !== tokenOut) return "the swap trades other tokens";
94
- if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return "the swap's input, minimum or price limit is not the quote's";
95
- if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
95
+ if (getAddress(a.tokenIn) !== tokenIn || getAddress(a.tokenOut) !== tokenOut) return notes.note("the swap trades other tokens", "policy_refused");
96
+ if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return notes.note("the swap's input, minimum or price limit is not the quote's", "price_check_failed");
97
+ if (getAddress(a.recipient) !== getAddress(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, "recipient_mismatch");
96
98
  } else if (swap?.functionName === "exactInput") {
97
99
  const a = swap.args[0];
98
100
  const path = a.path.slice(2);
99
101
  const pools = (path.length / 2 - 20) / 23;
100
- if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return "the swap path is not 1\u20132 pools";
101
- if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return "the swap path trades other tokens";
102
- if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return "the swap's input or minimum is not the quote's";
103
- if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
102
+ if (!/^[0-9a-fA-F]*$/.test(path) || !Number.isInteger(pools) || pools < 1 || pools > MAX_PATH_POOLS) return notes.note("the swap path is not 1\u20132 pools", "policy_refused");
103
+ if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return notes.note("the swap path trades other tokens", "policy_refused");
104
+ if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return notes.note("the swap's input or minimum is not the quote's", "price_check_failed");
105
+ if (getAddress(a.recipient) !== getAddress(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, "recipient_mismatch");
104
106
  } else {
105
- return `${swap?.functionName ?? "an unknown call"} is not exactInputSingle / exactInput`;
107
+ return notes.note(`${swap?.functionName ?? "an unknown call"} is not exactInputSingle / exactInput`, "policy_refused");
106
108
  }
107
109
  if (nativeOut) {
108
110
  const unwrap = decode(legs[1]);
109
- if (unwrap?.functionName !== "unwrapWETH9") return `${unwrap?.functionName ?? "an unknown call"} is not unwrapWETH9`;
110
- if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return "the unwrap pays someone else or less than the minimum";
111
+ if (unwrap?.functionName !== "unwrapWETH9") return notes.note(`${unwrap?.functionName ?? "an unknown call"} is not unwrapWETH9`, "policy_refused");
112
+ if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return notes.note("the unwrap pays someone else or less than the minimum", getAddress(unwrap.args[1]) !== recipient ? "recipient_mismatch" : "price_check_failed");
111
113
  }
112
114
  return null;
113
115
  }
114
116
  var uniswapPins = Object.freeze({
115
117
  callTargets: (chain) => uniswapRouterFor(chain),
116
118
  spenders: (chain) => uniswapRouterFor(chain),
117
- verifyQuote: uniswapVerifyQuote
119
+ verifyQuote: uniswapVerifyQuote,
120
+ reasonOf: (refusal) => notes.reasonOf(refusal)
118
121
  });
119
122
  function uniswapRouterFor(chain) {
120
123
  const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;
@@ -159,4 +162,4 @@ export {
159
162
  UNISWAP_ROUTER_SELECTORS,
160
163
  describeUniswapActivity
161
164
  };
162
- //# sourceMappingURL=chunk-ZOLQRZNH.js.map
165
+ //# sourceMappingURL=chunk-32CIYNG2.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\";\nimport {refusalNotes} from \"@anywalletkit/protocol-swap2-core/errors\";\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). USDT0 is the dollar pair on chains\n * without a native USDT (Ink, Unichain, Monad, X Layer, Arbitrum…): on Ink the WETH/USDC pools are dust, and\n * WETH → USDT0 → USDC is the only route with liquidity (matrix v8, 2026-11-07). */\nexport const HOP_SYMBOLS = [\"WETH\", \"USDC\", \"USDT\", \"USDT0\"] 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 refundETH() 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/** The reasons of the texts {@link uniswapVerifyQuote} returned, for `uniswapPins.reasonOf`. */\nconst notes = refusalNotes();\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). A native input may end with\n * `refundETH()`, which returns any unspent `value` to the sender (a provider builds it only with `refundNativeInput`,\n * so it is not required). `pull`, `sweepToken` and 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 notes.note(\"not a same-chain swap on a pinned Uniswap deployment\", \"unsupported_pair\");\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return notes.note(\"the quote carries no router call\", \"policy_refused\");\n if (getAddress(tx.to) !== getAddress(d.router)) return notes.note(`the call targets ${tx.to}, not the SwapRouter`, \"vault_mismatch\");\n const src = sourceAssetOf(params);\n if (!src) return notes.note(`unknown source token ${params.sourceToken}`, \"unsupported_pair\");\n const nativeIn = !src.contract;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if ((nativeIn || nativeOut) && d.nativeWrap === false) return notes.note(\"this chain's router has no wrapped native\", \"unsupported_pair\");\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 notes.note(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\", \"policy_refused\");\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 notes.note(`${outer.functionName} is not multicall(deadline, legs)`, \"policy_refused\");\n legs = outer.args[1];\n } catch {\n return notes.note(\"the router call is not multicall(deadline, legs)\", \"policy_refused\");\n }\n const decode = (leg: Hex) => { try { return decodeFunctionData({abi: ROUTER_ABI, data: leg}); } catch { return null; } };\n if (nativeIn && legs.length === 2 && decode(legs[1]!)?.functionName === \"refundETH\") legs = legs.slice(0, 1);\n if (legs.length !== (nativeOut ? 2 : 1)) return notes.note(`the multicall has ${legs.length} legs, not a swap${nativeOut ? \" and an unwrap\" : nativeIn ? \" (and a refund)\" : \"\"}`, \"policy_refused\");\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 notes.note(\"the swap trades other tokens\", \"policy_refused\");\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return notes.note(\"the swap's input, minimum or price limit is not the quote's\", \"price_check_failed\");\n if (getAddress(a.recipient) !== getAddress(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, \"recipient_mismatch\");\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 notes.note(\"the swap path is not 1–2 pools\", \"policy_refused\");\n if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return notes.note(\"the swap path trades other tokens\", \"policy_refused\");\n if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return notes.note(\"the swap's input or minimum is not the quote's\", \"price_check_failed\");\n if (getAddress(a.recipient) !== getAddress(swapTo)) return notes.note(`the swap pays ${a.recipient}, not the recipient`, \"recipient_mismatch\");\n } else {\n return notes.note(`${swap?.functionName ?? \"an unknown call\"} is not exactInputSingle / exactInput`, \"policy_refused\");\n }\n if (nativeOut) {\n const unwrap = decode(legs[1]!);\n if (unwrap?.functionName !== \"unwrapWETH9\") return notes.note(`${unwrap?.functionName ?? \"an unknown call\"} is not unwrapWETH9`, \"policy_refused\");\n // One text for two checks; the reason names the one that failed (another recipient wins over the amount).\n if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return notes.note(\"the unwrap pays someone else or less than the minimum\", getAddress(unwrap.args[1]) !== recipient ? \"recipient_mismatch\" : \"price_check_failed\");\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). `reasonOf` classifies the texts `uniswapVerifyQuote` returned.\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 reasonOf: (refusal: string) => notes.reasonOf(refusal),\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;AAE5B,SAAQ,oBAAmB;AAsBpB,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;AAAA;AAAA;AAAA,EAIhP,KAAK,EAAC,SAAS,8CAA8C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E,IAAI;AAClF,SAAO,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;AAC3B;;;AD1JO,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":[]}
@@ -5,12 +5,13 @@ import {
5
5
  ROUTER_ABI,
6
6
  UNISWAP_V3,
7
7
  describeUniswapActivity
8
- } from "./chunk-ZOLQRZNH.js";
8
+ } from "./chunk-32CIYNG2.js";
9
9
 
10
10
  // src/provider.ts
11
11
  import { decodeFunctionResult, encodeFunctionData, encodePacked, getAddress, parseAbi } from "viem";
12
12
  import { ccAsset } from "@anywalletkit/swap2-assets";
13
13
  import { evmRef, isEvm, timeoutSignal, sourceAssetOf } from "@anywalletkit/protocol-swap2-core/util";
14
+ import { httpRefusal, refusal, refusalOf, withReason } from "@anywalletkit/protocol-swap2-core/errors";
14
15
  import { bigintToNumber } from "@anywalletkit/core";
15
16
  var ZERO = "0x0000000000000000000000000000000000000000";
16
17
  var DEFAULT_SLIPPAGE_BPS = 50;
@@ -61,7 +62,11 @@ function uniswapProvider(config) {
61
62
  body: JSON.stringify(calls.map((c, id) => ({ jsonrpc: "2.0", id, ...c }))),
62
63
  signal: signal ?? timeoutSignal(12e3)
63
64
  });
64
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
65
+ if (!res.ok) {
66
+ const error2 = new Error(`HTTP ${res.status}`);
67
+ const info = httpRefusal(res.status, res.headers?.get?.("retry-after"));
68
+ throw info ? withReason(error2, info) : error2;
69
+ }
65
70
  const body = await res.json();
66
71
  if (!Array.isArray(body)) throw new Error(body.error?.message ?? "batch refused");
67
72
  const out = calls.map(() => null);
@@ -71,7 +76,8 @@ function uniswapProvider(config) {
71
76
  lastErr = e;
72
77
  }
73
78
  }
74
- throw new Error(`uniswap: no RPC answered on chain ${chainId} (${lastErr instanceof Error ? lastErr.message : String(lastErr)})`);
79
+ const error = new Error(`uniswap: no RPC answered on chain ${chainId} (${lastErr instanceof Error ? lastErr.message : String(lastErr)})`);
80
+ throw signal?.aborted ? error : withReason(error, refusalOf(lastErr) ?? "upstream_unavailable");
75
81
  }
76
82
  const call = (to, data) => ({ method: "eth_call", params: [{ to, data }, "latest"] });
77
83
  function verifyDeployment(chainId) {
@@ -85,7 +91,7 @@ function uniswapProvider(config) {
85
91
  const addr = (r) => typeof r === "string" && r.length >= 42 ? getAddress(`0x${r.slice(-40)}`) : null;
86
92
  const wrapped = d.nativeWrap === false ? getAddress(ZERO) : getAddress(d.weth);
87
93
  const ok = [rf, qf].every((r) => addr(r) === getAddress(d.factory)) && addr(rw) === wrapped && addr(qw) === wrapped;
88
- if (!ok) throw new Error(`uniswap: the router/quoter on chain ${chainId} do not match the pinned deployment \u2014 refusing`);
94
+ if (!ok) throw refusal("vault_mismatch", `uniswap: the router/quoter on chain ${chainId} do not match the pinned deployment \u2014 refusing`);
89
95
  })();
90
96
  p.catch(() => verified.delete(chainId));
91
97
  verified.set(chainId, p);
@@ -121,22 +127,22 @@ function uniswapProvider(config) {
121
127
  return from.chain === to.chain && chainIdOf(from.chain) !== null;
122
128
  },
123
129
  async getQuote(params, signal) {
124
- const refuse = (why) => {
125
- params.onRefusal?.(`uniswap: ${why}`);
130
+ const refuse = (why, info) => {
131
+ params.onRefusal?.(`uniswap: ${why}`, typeof info === "string" ? { reason: info } : info);
126
132
  return null;
127
133
  };
128
- if (params.flex) return refuse("amount-flexible deposits are not supported");
129
- if (params.sourceChain !== params.destChain) return refuse("same-chain swaps only");
134
+ if (params.flex) return refuse("amount-flexible deposits are not supported", "unsupported_pair");
135
+ if (params.sourceChain !== params.destChain) return refuse("same-chain swaps only", "unsupported_pair");
130
136
  const chainId = chainIdOf(params.sourceChain);
131
- if (chainId === null) return refuse(`no Uniswap v3 deployment or RPC for ${params.sourceChain}`);
137
+ if (chainId === null) return refuse(`no Uniswap v3 deployment or RPC for ${params.sourceChain}`, "unsupported_pair");
132
138
  const d = deployments[chainId];
133
139
  const src = sourceAssetOf(params);
134
- if (!src) return refuse(`unknown source token ${params.sourceToken}`);
140
+ if (!src) return refuse(`unknown source token ${params.sourceToken}`, "unsupported_pair");
135
141
  const nativeIn = !src.contract;
136
142
  const nativeOut = /^0x0+$/.test(params.destToken);
137
- if ((nativeIn || nativeOut) && d.nativeWrap === false) return refuse("this chain's router has no wrapped native \u2014 swap the coin's ERC-20 instead");
138
- if (!nativeOut && !/^0x[0-9a-fA-F]{40}$/.test(params.destToken)) return refuse("destination token must be an EVM address");
139
- if (!/^0x[0-9a-fA-F]{40}$/.test(params.destAddress)) return refuse("recipient must be an EVM address");
143
+ if ((nativeIn || nativeOut) && d.nativeWrap === false) return refuse("this chain's router has no wrapped native \u2014 swap the coin's ERC-20 instead", "unsupported_pair");
144
+ if (!nativeOut && !/^0x[0-9a-fA-F]{40}$/.test(params.destToken)) return refuse("destination token must be an EVM address", "unsupported_pair");
145
+ if (!/^0x[0-9a-fA-F]{40}$/.test(params.destAddress)) return refuse("recipient must be an EVM address", "recipient_mismatch");
140
146
  let amountIn;
141
147
  try {
142
148
  amountIn = BigInt(params.amountIn);
@@ -146,7 +152,7 @@ function uniswapProvider(config) {
146
152
  if (amountIn <= 0n) return refuse("amount must be positive");
147
153
  const tokenIn = getAddress(nativeIn ? d.weth : src.contract);
148
154
  const tokenOut = getAddress(nativeOut ? d.weth : params.destToken);
149
- if (tokenIn === tokenOut) return refuse(nativeIn || nativeOut ? "that is a wrap/unwrap, not a swap" : "same token in and out");
155
+ if (tokenIn === tokenOut) return refuse(nativeIn || nativeOut ? "that is a wrap/unwrap, not a swap" : "same token in and out", "unsupported_pair");
150
156
  try {
151
157
  await verifyDeployment(chainId);
152
158
  const candidates = routes(chainId, params.sourceChain, tokenIn, tokenOut);
@@ -176,7 +182,7 @@ function uniswapProvider(config) {
176
182
  } catch {
177
183
  }
178
184
  });
179
- if (!best) return refuse(partial ? PARTIAL_FILL : "no Uniswap v3 pool route for this pair and amount");
185
+ if (!best) return refuse(partial ? PARTIAL_FILL : "no Uniswap v3 pool route for this pair and amount", partial ? "insufficient_liquidity" : "no_route");
180
186
  const { route, out, gas } = best;
181
187
  let priceImpactBps;
182
188
  const probeIn = amountIn / 1000n;
@@ -199,9 +205,9 @@ function uniswapProvider(config) {
199
205
  }
200
206
  const bps = params.slippageBps ?? slippageDefault;
201
207
  const minOut = out * BigInt(1e4 - bps) / 10000n;
202
- if (minOut <= 0n) return refuse(`the minimum output rounds to 0 (quoted ${out} at ${bps} bps slippage) \u2014 the amount is too small for this pool`);
208
+ if (minOut <= 0n) return refuse(`the minimum output rounds to 0 (quoted ${out} at ${bps} bps slippage) \u2014 the amount is too small for this pool`, "amount_too_small");
203
209
  if (params.minAmountOut !== void 0 && minOut < BigInt(params.minAmountOut)) {
204
- return refuse(`floor breach (min=${minOut} < floor=${params.minAmountOut})`);
210
+ return refuse(`floor breach (min=${minOut} < floor=${params.minAmountOut})`, "price_check_failed");
205
211
  }
206
212
  const recipient = getAddress(params.destAddress);
207
213
  const swapTo = nativeOut ? ADDRESS_THIS : recipient;
@@ -247,7 +253,7 @@ function uniswapProvider(config) {
247
253
  }
248
254
  };
249
255
  } catch (e) {
250
- return refuse(e instanceof Error ? e.message.replace(/^uniswap: /, "") : String(e));
256
+ return refuse(e instanceof Error ? e.message.replace(/^uniswap: /, "") : String(e), refusalOf(e));
251
257
  }
252
258
  },
253
259
  /**
@@ -264,16 +270,22 @@ function uniswapProvider(config) {
264
270
  if (!d || !pd.amountIn || !pd.minOut || !pd.tokenIn || !pd.tokenOut) return;
265
271
  const data = pd.fee ? encodeFunctionData({ abi: QUOTER_ABI, functionName: "quoteExactInputSingle", args: [{ tokenIn: pd.tokenIn, tokenOut: pd.tokenOut, amountIn: BigInt(pd.amountIn), fee: Number(pd.fee), sqrtPriceLimitX96: 0n }] }) : encodeFunctionData({ abi: QUOTER_ABI, functionName: "quoteExactInput", args: [pd.path, BigInt(pd.amountIn)] });
266
272
  const [raw] = await rpc(chainId, [call(d.quoter, data)]);
267
- if (typeof raw !== "string" || raw === "0x") throw new Error("uniswap: the pool no longer quotes this route \u2014 refresh and try again");
268
- const { out, drained } = decodeQuote(!!pd.fee, raw);
269
- if (drained) throw new Error(`uniswap: ${PARTIAL_FILL} \u2014 the pool can no longer take this swap. Nothing was sent; refresh the quote.`);
273
+ if (typeof raw !== "string" || raw === "0x") throw refusal("no_route", "uniswap: the pool no longer quotes this route \u2014 refresh and try again");
274
+ let quoted;
275
+ try {
276
+ quoted = decodeQuote(!!pd.fee, raw);
277
+ } catch (e) {
278
+ throw e instanceof Error ? withReason(e, "upstream_unavailable") : e;
279
+ }
280
+ const { out, drained } = quoted;
281
+ if (drained) throw refusal("insufficient_liquidity", `uniswap: ${PARTIAL_FILL} \u2014 the pool can no longer take this swap. Nothing was sent; refresh the quote.`);
270
282
  if (out < BigInt(pd.minOut)) {
271
- throw new Error(`uniswap: price moved \u2014 the pool now pays ${out}, under your minimum ${pd.minOut}. Nothing was sent; refresh the quote.`);
283
+ throw refusal("price_check_failed", `uniswap: price moved \u2014 the pool now pays ${out}, under your minimum ${pd.minOut}. Nothing was sent; refresh the quote.`);
272
284
  }
273
285
  },
274
286
  async buildDeposit(quote) {
275
287
  const tx = quote.txRequest;
276
- if (!tx?.to || !tx.data) throw new Error("swap2: Uniswap quote has no transaction request");
288
+ if (!tx?.to || !tx.data) throw refusal("policy_refused", "swap2: Uniswap quote has no transaction request");
277
289
  return {
278
290
  chain: "",
279
291
  to: tx.to,
@@ -303,4 +315,4 @@ function uniswapProvider(config) {
303
315
  export {
304
316
  uniswapProvider
305
317
  };
306
- //# sourceMappingURL=chunk-XJDPJSBT.js.map
318
+ //# sourceMappingURL=chunk-6ZGWUPLL.js.map