@anywalletkit/protocol-swap2-uniswap 0.1.9 → 0.3.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/README.md +10 -0
- package/dist/activity.cjs +91 -3
- package/dist/activity.cjs.map +1 -1
- package/dist/activity.d.cts +2 -1
- package/dist/activity.d.ts +2 -1
- package/dist/activity.js +1 -1
- package/dist/addresses-Du1Qks_b.d.cts +148 -0
- package/dist/addresses-Du1Qks_b.d.ts +148 -0
- package/dist/{chunk-24UDTYBW.js → chunk-BHGKOL3N.js} +91 -1
- package/dist/chunk-BHGKOL3N.js.map +1 -0
- package/dist/{chunk-XOEHVDJD.js → chunk-ND647CPH.js} +3 -10
- package/dist/chunk-ND647CPH.js.map +1 -0
- package/dist/{chunk-NZKA7MRK.js → chunk-OPFCIWX7.js} +3 -3
- package/dist/index.cjs +123 -41
- 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 +11 -5
- package/dist/protocol.cjs +119 -40
- 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 +117 -38
- 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/addresses-BzAnSTqe.d.cts +0 -27
- package/dist/addresses-BzAnSTqe.d.ts +0 -27
- package/dist/chunk-24UDTYBW.js.map +0 -1
- package/dist/chunk-XOEHVDJD.js.map +0 -1
- /package/dist/{chunk-NZKA7MRK.js.map → chunk-OPFCIWX7.js.map} +0 -0
package/README.md
CHANGED
|
@@ -16,6 +16,16 @@ npm install @anywalletkit/protocol-swap2-uniswap @anywalletkit/core
|
|
|
16
16
|
|
|
17
17
|
On npm: [@anywalletkit/protocol-swap2-uniswap](https://www.npmjs.com/package/@anywalletkit/protocol-swap2-uniswap), published from the [release workflow](https://github.com/ultratestbro/anywalletkit/blob/main/RELEASING.md) with provenance.
|
|
18
18
|
|
|
19
|
+
## Behind `remoteProvider`
|
|
20
|
+
|
|
21
|
+
When the provider runs on your server, spread its pins into the app's stub:
|
|
22
|
+
`remoteProvider({name: "uniswap", baseUrl, ...uniswapPins})`. The engine then lets the EVM route call and
|
|
23
|
+
approve only the SwapRouter in `UNISWAP_V3`, never an address the backend names; without the pins the stub gets no
|
|
24
|
+
EVM calldata route (fail closed). The pins carry `verifyQuote: uniswapVerifyQuote`, which opens the router call on the
|
|
25
|
+
device: one `multicall(deadline, legs)` whose legs are exactly one `exactInputSingle` / `exactInput` (at most two
|
|
26
|
+
pools), then `unwrapWETH9` for a native output, selling exactly the input of the source token for the destination
|
|
27
|
+
token with the quote's minimum, paid to the recipient. `pull`, `sweepToken` and every other router call are refused.
|
|
28
|
+
|
|
19
29
|
## Activity
|
|
20
30
|
|
|
21
31
|
`describeActivity(tx, ctx)` recognizes a call into the chain's SwapRouter02
|
package/dist/activity.cjs
CHANGED
|
@@ -26,9 +26,11 @@ __export(activity_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(activity_exports);
|
|
28
28
|
var import_activity = require("@anywalletkit/protocol-swap2-core/activity");
|
|
29
|
-
var
|
|
29
|
+
var import_util2 = require("@anywalletkit/protocol-swap2-core/util");
|
|
30
30
|
|
|
31
31
|
// src/addresses.ts
|
|
32
|
+
var import_viem = require("viem");
|
|
33
|
+
var import_util = require("@anywalletkit/protocol-swap2-core/util");
|
|
32
34
|
var UNISWAP_V3 = Object.freeze({
|
|
33
35
|
1: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" },
|
|
34
36
|
10: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x4200000000000000000000000000000000000006" },
|
|
@@ -53,6 +55,92 @@ var UNISWAP_V3 = Object.freeze({
|
|
|
53
55
|
4663: { factory: "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA", quoter: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7", router: "0xCaf681a66D020601342297493863E78C959E5cb2", weth: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73" },
|
|
54
56
|
43114: { factory: "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD", quoter: "0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F", router: "0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE", weth: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" }
|
|
55
57
|
});
|
|
58
|
+
var ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
59
|
+
var ROUTER_ABI = (0, import_viem.parseAbi)([
|
|
60
|
+
"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)",
|
|
61
|
+
"function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)",
|
|
62
|
+
"function unwrapWETH9(uint256 amountMinimum, address recipient) payable",
|
|
63
|
+
"function multicall(uint256 deadline, bytes[] data) payable returns (bytes[] results)",
|
|
64
|
+
"function factory() view returns (address)",
|
|
65
|
+
"function WETH9() view returns (address)"
|
|
66
|
+
]);
|
|
67
|
+
var MAX_PATH_POOLS = 2;
|
|
68
|
+
function uniswapVerifyQuote(params, quote) {
|
|
69
|
+
const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;
|
|
70
|
+
const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : void 0;
|
|
71
|
+
if (!d || params.destChain !== params.sourceChain) return "not a same-chain swap on a pinned Uniswap deployment";
|
|
72
|
+
const tx = quote.txRequest;
|
|
73
|
+
if (!tx?.data || !tx.to || tx.serializedTx !== void 0) return "the quote carries no router call";
|
|
74
|
+
if ((0, import_viem.getAddress)(tx.to) !== (0, import_viem.getAddress)(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;
|
|
75
|
+
const src = (0, import_util.sourceAssetOf)(params);
|
|
76
|
+
if (!src) return `unknown source token ${params.sourceToken}`;
|
|
77
|
+
const nativeIn = !src.contract;
|
|
78
|
+
const nativeOut = /^0x0+$/.test(params.destToken);
|
|
79
|
+
if ((nativeIn || nativeOut) && d.nativeWrap === false) return "this chain's router has no wrapped native";
|
|
80
|
+
let tokenIn, tokenOut, recipient, amountIn, minOut;
|
|
81
|
+
try {
|
|
82
|
+
tokenIn = (0, import_viem.getAddress)(nativeIn ? d.weth : src.contract);
|
|
83
|
+
tokenOut = (0, import_viem.getAddress)(nativeOut ? d.weth : params.destToken);
|
|
84
|
+
recipient = (0, import_viem.getAddress)(params.destAddress);
|
|
85
|
+
amountIn = BigInt(params.amountIn);
|
|
86
|
+
minOut = BigInt(quote.minDestAmount);
|
|
87
|
+
} catch {
|
|
88
|
+
return "the request does not name EVM tokens, a recipient and amounts";
|
|
89
|
+
}
|
|
90
|
+
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)) {
|
|
91
|
+
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";
|
|
92
|
+
}
|
|
93
|
+
let legs;
|
|
94
|
+
try {
|
|
95
|
+
const outer = (0, import_viem.decodeFunctionData)({ abi: ROUTER_ABI, data: tx.data });
|
|
96
|
+
if (outer.functionName !== "multicall") return `${outer.functionName} is not multicall(deadline, legs)`;
|
|
97
|
+
legs = outer.args[1];
|
|
98
|
+
} catch {
|
|
99
|
+
return "the router call is not multicall(deadline, legs)";
|
|
100
|
+
}
|
|
101
|
+
if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? " and an unwrap" : ""}`;
|
|
102
|
+
const decode = (leg) => {
|
|
103
|
+
try {
|
|
104
|
+
return (0, import_viem.decodeFunctionData)({ abi: ROUTER_ABI, data: leg });
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const swap = decode(legs[0]);
|
|
110
|
+
const swapTo = nativeOut ? ADDRESS_THIS : recipient;
|
|
111
|
+
if (swap?.functionName === "exactInputSingle") {
|
|
112
|
+
const a = swap.args[0];
|
|
113
|
+
if ((0, import_viem.getAddress)(a.tokenIn) !== tokenIn || (0, import_viem.getAddress)(a.tokenOut) !== tokenOut) return "the swap trades other tokens";
|
|
114
|
+
if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return "the swap's input, minimum or price limit is not the quote's";
|
|
115
|
+
if ((0, import_viem.getAddress)(a.recipient) !== (0, import_viem.getAddress)(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
|
|
116
|
+
} else if (swap?.functionName === "exactInput") {
|
|
117
|
+
const a = swap.args[0];
|
|
118
|
+
const path = a.path.slice(2);
|
|
119
|
+
const pools = (path.length / 2 - 20) / 23;
|
|
120
|
+
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";
|
|
121
|
+
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";
|
|
122
|
+
if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return "the swap's input or minimum is not the quote's";
|
|
123
|
+
if ((0, import_viem.getAddress)(a.recipient) !== (0, import_viem.getAddress)(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
|
|
124
|
+
} else {
|
|
125
|
+
return `${swap?.functionName ?? "an unknown call"} is not exactInputSingle / exactInput`;
|
|
126
|
+
}
|
|
127
|
+
if (nativeOut) {
|
|
128
|
+
const unwrap = decode(legs[1]);
|
|
129
|
+
if (unwrap?.functionName !== "unwrapWETH9") return `${unwrap?.functionName ?? "an unknown call"} is not unwrapWETH9`;
|
|
130
|
+
if (unwrap.args[0] !== minOut || (0, import_viem.getAddress)(unwrap.args[1]) !== recipient) return "the unwrap pays someone else or less than the minimum";
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
var uniswapPins = Object.freeze({
|
|
135
|
+
callTargets: (chain) => uniswapRouterFor(chain),
|
|
136
|
+
spenders: (chain) => uniswapRouterFor(chain),
|
|
137
|
+
verifyQuote: uniswapVerifyQuote
|
|
138
|
+
});
|
|
139
|
+
function uniswapRouterFor(chain) {
|
|
140
|
+
const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;
|
|
141
|
+
const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : void 0;
|
|
142
|
+
return d ? [d.router] : [];
|
|
143
|
+
}
|
|
56
144
|
|
|
57
145
|
// src/activity.ts
|
|
58
146
|
var UNISWAP_MODULE = "@anywalletkit/protocol-swap2-uniswap";
|
|
@@ -73,8 +161,8 @@ var UNISWAP_ROUTER_SELECTORS = /* @__PURE__ */ new Set([
|
|
|
73
161
|
// exactOutput((bytes,address,uint256,uint256))
|
|
74
162
|
]);
|
|
75
163
|
function describeUniswapActivity(tx, ctx, deployments = UNISWAP_V3) {
|
|
76
|
-
if (!(0,
|
|
77
|
-
const deployment = deployments[(0,
|
|
164
|
+
if (!(0, import_util2.isEvm)(tx.chain)) return null;
|
|
165
|
+
const deployment = deployments[(0, import_util2.evmRef)(tx.chain)];
|
|
78
166
|
if (!deployment || !(0, import_activity.matchesCall)(tx, [deployment.router], UNISWAP_ROUTER_SELECTORS)) return null;
|
|
79
167
|
return (0, import_activity.describeSwapLike)(tx, ctx, { protocol: UNISWAP_MODULE, subtitle: `Uniswap v3 \xB7 ${(0, import_activity.chainLabel)(tx.chain)}`, kind: "swap" });
|
|
80
168
|
}
|
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","/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAwD;AACxD,kBAA4B;;;ACYrB,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;AAA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;AAC7B,QAAM,aAAa,gBAAY,oBAAO,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":[]}
|
|
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,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,EAE7N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]}
|
package/dist/activity.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
|
|
2
|
-
import { a as UniswapDeployment } from './addresses-
|
|
2
|
+
import { a as UniswapDeployment } from './addresses-Du1Qks_b.cjs';
|
|
3
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Activity recognition for Uniswap v3: a call into the chain's SwapRouter02
|
package/dist/activity.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChainTx, DescribeActivityContext, ActivityItem } from '@anywalletkit/core';
|
|
2
|
-
import { a as UniswapDeployment } from './addresses-
|
|
2
|
+
import { a as UniswapDeployment } from './addresses-Du1Qks_b.js';
|
|
3
|
+
import '@anywalletkit/protocol-swap2-core/types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Activity recognition for Uniswap v3: a call into the chain's SwapRouter02
|
package/dist/activity.js
CHANGED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { RemotePins, QuoteParams, Quote } from '@anywalletkit/protocol-swap2-core/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Uniswap v3 deployments this module trusts. Every entry was checked on-chain
|
|
5
|
+
* (2026-10-12): SwapRouter02.factory() and QuoterV2.factory() both return
|
|
6
|
+
* `factory`, and both report `weth` as WETH9. The provider re-checks the same
|
|
7
|
+
* facts once per chain at runtime before quoting (see `verifyDeployment`).
|
|
8
|
+
*/
|
|
9
|
+
interface UniswapDeployment {
|
|
10
|
+
factory: `0x${string}`;
|
|
11
|
+
quoter: `0x${string}`;
|
|
12
|
+
router: `0x${string}`;
|
|
13
|
+
/** The chain's wrapped native token (WETH, WBNB, WPOL, WAVAX) — on a chain
|
|
14
|
+
* without one (Celo), the hop token used for two-hop routes instead. */
|
|
15
|
+
weth: `0x${string}`;
|
|
16
|
+
/** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */
|
|
17
|
+
nativeWrap?: false;
|
|
18
|
+
/** false: a newer QuoterV2 build without WETH9() — only its factory is checked. */
|
|
19
|
+
quoterWeth?: false;
|
|
20
|
+
}
|
|
21
|
+
declare const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>>;
|
|
22
|
+
/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */
|
|
23
|
+
declare const FEE_TIERS: readonly [100, 500, 3000, 10000];
|
|
24
|
+
/** Two-hop routes go through these (when the catalog knows them on the chain). */
|
|
25
|
+
declare const HOP_SYMBOLS: readonly ["WETH", "USDC", "USDT"];
|
|
26
|
+
/** SwapRouter02 recipient sentinel: "keep the output in the router" (then unwrapWETH9). */
|
|
27
|
+
declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
28
|
+
/** The SwapRouter02 entry points this module writes (and the deployment probes). */
|
|
29
|
+
declare const ROUTER_ABI: readonly [{
|
|
30
|
+
readonly name: "exactInputSingle";
|
|
31
|
+
readonly type: "function";
|
|
32
|
+
readonly stateMutability: "payable";
|
|
33
|
+
readonly inputs: readonly [{
|
|
34
|
+
readonly type: "tuple";
|
|
35
|
+
readonly components: readonly [{
|
|
36
|
+
readonly type: "address";
|
|
37
|
+
readonly name: "tokenIn";
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: "address";
|
|
40
|
+
readonly name: "tokenOut";
|
|
41
|
+
}, {
|
|
42
|
+
readonly type: "uint24";
|
|
43
|
+
readonly name: "fee";
|
|
44
|
+
}, {
|
|
45
|
+
readonly type: "address";
|
|
46
|
+
readonly name: "recipient";
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "uint256";
|
|
49
|
+
readonly name: "amountIn";
|
|
50
|
+
}, {
|
|
51
|
+
readonly type: "uint256";
|
|
52
|
+
readonly name: "amountOutMinimum";
|
|
53
|
+
}, {
|
|
54
|
+
readonly type: "uint160";
|
|
55
|
+
readonly name: "sqrtPriceLimitX96";
|
|
56
|
+
}];
|
|
57
|
+
readonly name: "params";
|
|
58
|
+
}];
|
|
59
|
+
readonly outputs: readonly [{
|
|
60
|
+
readonly type: "uint256";
|
|
61
|
+
readonly name: "amountOut";
|
|
62
|
+
}];
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "exactInput";
|
|
65
|
+
readonly type: "function";
|
|
66
|
+
readonly stateMutability: "payable";
|
|
67
|
+
readonly inputs: readonly [{
|
|
68
|
+
readonly type: "tuple";
|
|
69
|
+
readonly components: readonly [{
|
|
70
|
+
readonly type: "bytes";
|
|
71
|
+
readonly name: "path";
|
|
72
|
+
}, {
|
|
73
|
+
readonly type: "address";
|
|
74
|
+
readonly name: "recipient";
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
readonly name: "amountIn";
|
|
78
|
+
}, {
|
|
79
|
+
readonly type: "uint256";
|
|
80
|
+
readonly name: "amountOutMinimum";
|
|
81
|
+
}];
|
|
82
|
+
readonly name: "params";
|
|
83
|
+
}];
|
|
84
|
+
readonly outputs: readonly [{
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
readonly name: "amountOut";
|
|
87
|
+
}];
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "unwrapWETH9";
|
|
90
|
+
readonly type: "function";
|
|
91
|
+
readonly stateMutability: "payable";
|
|
92
|
+
readonly inputs: readonly [{
|
|
93
|
+
readonly type: "uint256";
|
|
94
|
+
readonly name: "amountMinimum";
|
|
95
|
+
}, {
|
|
96
|
+
readonly type: "address";
|
|
97
|
+
readonly name: "recipient";
|
|
98
|
+
}];
|
|
99
|
+
readonly outputs: readonly [];
|
|
100
|
+
}, {
|
|
101
|
+
readonly name: "multicall";
|
|
102
|
+
readonly type: "function";
|
|
103
|
+
readonly stateMutability: "payable";
|
|
104
|
+
readonly inputs: readonly [{
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
readonly name: "deadline";
|
|
107
|
+
}, {
|
|
108
|
+
readonly type: "bytes[]";
|
|
109
|
+
readonly name: "data";
|
|
110
|
+
}];
|
|
111
|
+
readonly outputs: readonly [{
|
|
112
|
+
readonly type: "bytes[]";
|
|
113
|
+
readonly name: "results";
|
|
114
|
+
}];
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "factory";
|
|
117
|
+
readonly type: "function";
|
|
118
|
+
readonly stateMutability: "view";
|
|
119
|
+
readonly inputs: readonly [];
|
|
120
|
+
readonly outputs: readonly [{
|
|
121
|
+
readonly type: "address";
|
|
122
|
+
}];
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "WETH9";
|
|
125
|
+
readonly type: "function";
|
|
126
|
+
readonly stateMutability: "view";
|
|
127
|
+
readonly inputs: readonly [];
|
|
128
|
+
readonly outputs: readonly [{
|
|
129
|
+
readonly type: "address";
|
|
130
|
+
}];
|
|
131
|
+
}];
|
|
132
|
+
/**
|
|
133
|
+
* The swap a Uniswap quote's router call makes, opened on the client against the app's own request (scan 2026-10-28,
|
|
134
|
+
* F1): one `multicall(deadline, legs)` on the chain's pinned SwapRouter02 whose legs are exactly one `exactInputSingle`
|
|
135
|
+
* or `exactInput` — then `unwrapWETH9` for a native output — selling exactly the input of the source token (WETH for a
|
|
136
|
+
* native input, paid as `value`) for the destination token, with `amountOutMinimum` the quote's minimum, paid to the
|
|
137
|
+
* recipient (or kept in the router and unwrapped to the recipient for that same minimum). `pull`, `sweepToken` and
|
|
138
|
+
* every other router call are refused. The reason it fails, or null.
|
|
139
|
+
*/
|
|
140
|
+
declare function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string | null;
|
|
141
|
+
/**
|
|
142
|
+
* The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and
|
|
143
|
+
* {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: "uniswap", baseUrl, ...uniswapPins})` (scan
|
|
144
|
+
* 2026-10-27 modules, F9; scan 2026-10-28, F1).
|
|
145
|
+
*/
|
|
146
|
+
declare const uniswapPins: RemotePins;
|
|
147
|
+
|
|
148
|
+
export { ADDRESS_THIS as A, FEE_TIERS as F, HOP_SYMBOLS as H, ROUTER_ABI as R, UNISWAP_V3 as U, type UniswapDeployment as a, uniswapVerifyQuote as b, uniswapPins as u };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { RemotePins, QuoteParams, Quote } from '@anywalletkit/protocol-swap2-core/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Uniswap v3 deployments this module trusts. Every entry was checked on-chain
|
|
5
|
+
* (2026-10-12): SwapRouter02.factory() and QuoterV2.factory() both return
|
|
6
|
+
* `factory`, and both report `weth` as WETH9. The provider re-checks the same
|
|
7
|
+
* facts once per chain at runtime before quoting (see `verifyDeployment`).
|
|
8
|
+
*/
|
|
9
|
+
interface UniswapDeployment {
|
|
10
|
+
factory: `0x${string}`;
|
|
11
|
+
quoter: `0x${string}`;
|
|
12
|
+
router: `0x${string}`;
|
|
13
|
+
/** The chain's wrapped native token (WETH, WBNB, WPOL, WAVAX) — on a chain
|
|
14
|
+
* without one (Celo), the hop token used for two-hop routes instead. */
|
|
15
|
+
weth: `0x${string}`;
|
|
16
|
+
/** false: the router has no WETH9 (reports 0x0) — no native in/out, the coin is an ERC-20 there. */
|
|
17
|
+
nativeWrap?: false;
|
|
18
|
+
/** false: a newer QuoterV2 build without WETH9() — only its factory is checked. */
|
|
19
|
+
quoterWeth?: false;
|
|
20
|
+
}
|
|
21
|
+
declare const UNISWAP_V3: Readonly<Record<number, UniswapDeployment>>;
|
|
22
|
+
/** Pool fee tiers probed for every hop (0.01%, 0.05%, 0.3%, 1%). */
|
|
23
|
+
declare const FEE_TIERS: readonly [100, 500, 3000, 10000];
|
|
24
|
+
/** Two-hop routes go through these (when the catalog knows them on the chain). */
|
|
25
|
+
declare const HOP_SYMBOLS: readonly ["WETH", "USDC", "USDT"];
|
|
26
|
+
/** SwapRouter02 recipient sentinel: "keep the output in the router" (then unwrapWETH9). */
|
|
27
|
+
declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
28
|
+
/** The SwapRouter02 entry points this module writes (and the deployment probes). */
|
|
29
|
+
declare const ROUTER_ABI: readonly [{
|
|
30
|
+
readonly name: "exactInputSingle";
|
|
31
|
+
readonly type: "function";
|
|
32
|
+
readonly stateMutability: "payable";
|
|
33
|
+
readonly inputs: readonly [{
|
|
34
|
+
readonly type: "tuple";
|
|
35
|
+
readonly components: readonly [{
|
|
36
|
+
readonly type: "address";
|
|
37
|
+
readonly name: "tokenIn";
|
|
38
|
+
}, {
|
|
39
|
+
readonly type: "address";
|
|
40
|
+
readonly name: "tokenOut";
|
|
41
|
+
}, {
|
|
42
|
+
readonly type: "uint24";
|
|
43
|
+
readonly name: "fee";
|
|
44
|
+
}, {
|
|
45
|
+
readonly type: "address";
|
|
46
|
+
readonly name: "recipient";
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "uint256";
|
|
49
|
+
readonly name: "amountIn";
|
|
50
|
+
}, {
|
|
51
|
+
readonly type: "uint256";
|
|
52
|
+
readonly name: "amountOutMinimum";
|
|
53
|
+
}, {
|
|
54
|
+
readonly type: "uint160";
|
|
55
|
+
readonly name: "sqrtPriceLimitX96";
|
|
56
|
+
}];
|
|
57
|
+
readonly name: "params";
|
|
58
|
+
}];
|
|
59
|
+
readonly outputs: readonly [{
|
|
60
|
+
readonly type: "uint256";
|
|
61
|
+
readonly name: "amountOut";
|
|
62
|
+
}];
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "exactInput";
|
|
65
|
+
readonly type: "function";
|
|
66
|
+
readonly stateMutability: "payable";
|
|
67
|
+
readonly inputs: readonly [{
|
|
68
|
+
readonly type: "tuple";
|
|
69
|
+
readonly components: readonly [{
|
|
70
|
+
readonly type: "bytes";
|
|
71
|
+
readonly name: "path";
|
|
72
|
+
}, {
|
|
73
|
+
readonly type: "address";
|
|
74
|
+
readonly name: "recipient";
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
readonly name: "amountIn";
|
|
78
|
+
}, {
|
|
79
|
+
readonly type: "uint256";
|
|
80
|
+
readonly name: "amountOutMinimum";
|
|
81
|
+
}];
|
|
82
|
+
readonly name: "params";
|
|
83
|
+
}];
|
|
84
|
+
readonly outputs: readonly [{
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
readonly name: "amountOut";
|
|
87
|
+
}];
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "unwrapWETH9";
|
|
90
|
+
readonly type: "function";
|
|
91
|
+
readonly stateMutability: "payable";
|
|
92
|
+
readonly inputs: readonly [{
|
|
93
|
+
readonly type: "uint256";
|
|
94
|
+
readonly name: "amountMinimum";
|
|
95
|
+
}, {
|
|
96
|
+
readonly type: "address";
|
|
97
|
+
readonly name: "recipient";
|
|
98
|
+
}];
|
|
99
|
+
readonly outputs: readonly [];
|
|
100
|
+
}, {
|
|
101
|
+
readonly name: "multicall";
|
|
102
|
+
readonly type: "function";
|
|
103
|
+
readonly stateMutability: "payable";
|
|
104
|
+
readonly inputs: readonly [{
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
readonly name: "deadline";
|
|
107
|
+
}, {
|
|
108
|
+
readonly type: "bytes[]";
|
|
109
|
+
readonly name: "data";
|
|
110
|
+
}];
|
|
111
|
+
readonly outputs: readonly [{
|
|
112
|
+
readonly type: "bytes[]";
|
|
113
|
+
readonly name: "results";
|
|
114
|
+
}];
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "factory";
|
|
117
|
+
readonly type: "function";
|
|
118
|
+
readonly stateMutability: "view";
|
|
119
|
+
readonly inputs: readonly [];
|
|
120
|
+
readonly outputs: readonly [{
|
|
121
|
+
readonly type: "address";
|
|
122
|
+
}];
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "WETH9";
|
|
125
|
+
readonly type: "function";
|
|
126
|
+
readonly stateMutability: "view";
|
|
127
|
+
readonly inputs: readonly [];
|
|
128
|
+
readonly outputs: readonly [{
|
|
129
|
+
readonly type: "address";
|
|
130
|
+
}];
|
|
131
|
+
}];
|
|
132
|
+
/**
|
|
133
|
+
* The swap a Uniswap quote's router call makes, opened on the client against the app's own request (scan 2026-10-28,
|
|
134
|
+
* F1): one `multicall(deadline, legs)` on the chain's pinned SwapRouter02 whose legs are exactly one `exactInputSingle`
|
|
135
|
+
* or `exactInput` — then `unwrapWETH9` for a native output — selling exactly the input of the source token (WETH for a
|
|
136
|
+
* native input, paid as `value`) for the destination token, with `amountOutMinimum` the quote's minimum, paid to the
|
|
137
|
+
* recipient (or kept in the router and unwrapped to the recipient for that same minimum). `pull`, `sweepToken` and
|
|
138
|
+
* every other router call are refused. The reason it fails, or null.
|
|
139
|
+
*/
|
|
140
|
+
declare function uniswapVerifyQuote(params: QuoteParams, quote: Quote): string | null;
|
|
141
|
+
/**
|
|
142
|
+
* The SwapRouter a Uniswap swap calls and approves on a chain (the shipped {@link UNISWAP_V3} table), and
|
|
143
|
+
* {@link uniswapVerifyQuote} — the app's pins for `remoteProvider({name: "uniswap", baseUrl, ...uniswapPins})` (scan
|
|
144
|
+
* 2026-10-27 modules, F9; scan 2026-10-28, F1).
|
|
145
|
+
*/
|
|
146
|
+
declare const uniswapPins: RemotePins;
|
|
147
|
+
|
|
148
|
+
export { ADDRESS_THIS as A, FEE_TIERS as F, HOP_SYMBOLS as H, ROUTER_ABI as R, UNISWAP_V3 as U, type UniswapDeployment as a, uniswapVerifyQuote as b, uniswapPins as u };
|
|
@@ -3,6 +3,8 @@ import { chainLabel, describeSwapLike, matchesCall } from "@anywalletkit/protoco
|
|
|
3
3
|
import { evmRef, isEvm } from "@anywalletkit/protocol-swap2-core/util";
|
|
4
4
|
|
|
5
5
|
// src/addresses.ts
|
|
6
|
+
import { decodeFunctionData, getAddress, parseAbi } from "viem";
|
|
7
|
+
import { sourceAssetOf } from "@anywalletkit/protocol-swap2-core/util";
|
|
6
8
|
var UNISWAP_V3 = Object.freeze({
|
|
7
9
|
1: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" },
|
|
8
10
|
10: { factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984", quoter: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", router: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", weth: "0x4200000000000000000000000000000000000006" },
|
|
@@ -30,6 +32,91 @@ var UNISWAP_V3 = Object.freeze({
|
|
|
30
32
|
var FEE_TIERS = [100, 500, 3e3, 1e4];
|
|
31
33
|
var HOP_SYMBOLS = ["WETH", "USDC", "USDT"];
|
|
32
34
|
var ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
35
|
+
var ROUTER_ABI = parseAbi([
|
|
36
|
+
"function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)",
|
|
37
|
+
"function exactInput((bytes path, address recipient, uint256 amountIn, uint256 amountOutMinimum) params) payable returns (uint256 amountOut)",
|
|
38
|
+
"function unwrapWETH9(uint256 amountMinimum, address recipient) payable",
|
|
39
|
+
"function multicall(uint256 deadline, bytes[] data) payable returns (bytes[] results)",
|
|
40
|
+
"function factory() view returns (address)",
|
|
41
|
+
"function WETH9() view returns (address)"
|
|
42
|
+
]);
|
|
43
|
+
var MAX_PATH_POOLS = 2;
|
|
44
|
+
function uniswapVerifyQuote(params, quote) {
|
|
45
|
+
const id = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;
|
|
46
|
+
const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : void 0;
|
|
47
|
+
if (!d || params.destChain !== params.sourceChain) return "not a same-chain swap on a pinned Uniswap deployment";
|
|
48
|
+
const tx = quote.txRequest;
|
|
49
|
+
if (!tx?.data || !tx.to || tx.serializedTx !== void 0) return "the quote carries no router call";
|
|
50
|
+
if (getAddress(tx.to) !== getAddress(d.router)) return `the call targets ${tx.to}, not the SwapRouter`;
|
|
51
|
+
const src = sourceAssetOf(params);
|
|
52
|
+
if (!src) return `unknown source token ${params.sourceToken}`;
|
|
53
|
+
const nativeIn = !src.contract;
|
|
54
|
+
const nativeOut = /^0x0+$/.test(params.destToken);
|
|
55
|
+
if ((nativeIn || nativeOut) && d.nativeWrap === false) return "this chain's router has no wrapped native";
|
|
56
|
+
let tokenIn, tokenOut, recipient, amountIn, minOut;
|
|
57
|
+
try {
|
|
58
|
+
tokenIn = getAddress(nativeIn ? d.weth : src.contract);
|
|
59
|
+
tokenOut = getAddress(nativeOut ? d.weth : params.destToken);
|
|
60
|
+
recipient = getAddress(params.destAddress);
|
|
61
|
+
amountIn = BigInt(params.amountIn);
|
|
62
|
+
minOut = BigInt(quote.minDestAmount);
|
|
63
|
+
} catch {
|
|
64
|
+
return "the request does not name EVM tokens, a recipient and amounts";
|
|
65
|
+
}
|
|
66
|
+
if (nativeIn ? BigInt(tx.value ?? "0") !== amountIn || tx.approvalAddress !== void 0 : BigInt(tx.value ?? "0") !== 0n || !tx.approvalAddress || getAddress(tx.approvalAddress) !== getAddress(d.router)) {
|
|
67
|
+
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";
|
|
68
|
+
}
|
|
69
|
+
let legs;
|
|
70
|
+
try {
|
|
71
|
+
const outer = decodeFunctionData({ abi: ROUTER_ABI, data: tx.data });
|
|
72
|
+
if (outer.functionName !== "multicall") return `${outer.functionName} is not multicall(deadline, legs)`;
|
|
73
|
+
legs = outer.args[1];
|
|
74
|
+
} catch {
|
|
75
|
+
return "the router call is not multicall(deadline, legs)";
|
|
76
|
+
}
|
|
77
|
+
if (legs.length !== (nativeOut ? 2 : 1)) return `the multicall has ${legs.length} legs, not a swap${nativeOut ? " and an unwrap" : ""}`;
|
|
78
|
+
const decode = (leg) => {
|
|
79
|
+
try {
|
|
80
|
+
return decodeFunctionData({ abi: ROUTER_ABI, data: leg });
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const swap = decode(legs[0]);
|
|
86
|
+
const swapTo = nativeOut ? ADDRESS_THIS : recipient;
|
|
87
|
+
if (swap?.functionName === "exactInputSingle") {
|
|
88
|
+
const a = swap.args[0];
|
|
89
|
+
if (getAddress(a.tokenIn) !== tokenIn || getAddress(a.tokenOut) !== tokenOut) return "the swap trades other tokens";
|
|
90
|
+
if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut || a.sqrtPriceLimitX96 !== 0n) return "the swap's input, minimum or price limit is not the quote's";
|
|
91
|
+
if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
|
|
92
|
+
} else if (swap?.functionName === "exactInput") {
|
|
93
|
+
const a = swap.args[0];
|
|
94
|
+
const path = a.path.slice(2);
|
|
95
|
+
const pools = (path.length / 2 - 20) / 23;
|
|
96
|
+
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";
|
|
97
|
+
if (getAddress(`0x${path.slice(0, 40)}`) !== tokenIn || getAddress(`0x${path.slice(-40)}`) !== tokenOut) return "the swap path trades other tokens";
|
|
98
|
+
if (a.amountIn !== amountIn || a.amountOutMinimum !== minOut) return "the swap's input or minimum is not the quote's";
|
|
99
|
+
if (getAddress(a.recipient) !== getAddress(swapTo)) return `the swap pays ${a.recipient}, not the recipient`;
|
|
100
|
+
} else {
|
|
101
|
+
return `${swap?.functionName ?? "an unknown call"} is not exactInputSingle / exactInput`;
|
|
102
|
+
}
|
|
103
|
+
if (nativeOut) {
|
|
104
|
+
const unwrap = decode(legs[1]);
|
|
105
|
+
if (unwrap?.functionName !== "unwrapWETH9") return `${unwrap?.functionName ?? "an unknown call"} is not unwrapWETH9`;
|
|
106
|
+
if (unwrap.args[0] !== minOut || getAddress(unwrap.args[1]) !== recipient) return "the unwrap pays someone else or less than the minimum";
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
var uniswapPins = Object.freeze({
|
|
111
|
+
callTargets: (chain) => uniswapRouterFor(chain),
|
|
112
|
+
spenders: (chain) => uniswapRouterFor(chain),
|
|
113
|
+
verifyQuote: uniswapVerifyQuote
|
|
114
|
+
});
|
|
115
|
+
function uniswapRouterFor(chain) {
|
|
116
|
+
const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;
|
|
117
|
+
const d = Object.prototype.hasOwnProperty.call(UNISWAP_V3, id) ? UNISWAP_V3[id] : void 0;
|
|
118
|
+
return d ? [d.router] : [];
|
|
119
|
+
}
|
|
33
120
|
|
|
34
121
|
// src/activity.ts
|
|
35
122
|
var UNISWAP_MODULE = "@anywalletkit/protocol-swap2-uniswap";
|
|
@@ -61,8 +148,11 @@ export {
|
|
|
61
148
|
FEE_TIERS,
|
|
62
149
|
HOP_SYMBOLS,
|
|
63
150
|
ADDRESS_THIS,
|
|
151
|
+
ROUTER_ABI,
|
|
152
|
+
uniswapVerifyQuote,
|
|
153
|
+
uniswapPins,
|
|
64
154
|
UNISWAP_MODULE,
|
|
65
155
|
UNISWAP_ROUTER_SELECTORS,
|
|
66
156
|
describeUniswapActivity
|
|
67
157
|
};
|
|
68
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
//# sourceMappingURL=chunk-BHGKOL3N.js.map
|