@anywalletkit/protocol-swap2-fynd 0.1.6 → 0.2.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 CHANGED
@@ -46,6 +46,13 @@ const fynd = fyndProvider({
46
46
  })
47
47
  ```
48
48
 
49
+ Behind `remoteProvider` (the API key on your server), the app wires the router pins and the
50
+ transaction check: `remoteProvider({name: "fynd", baseUrl, ...fyndPins})`. The engine then
51
+ accepts only the Tycho router in `FYND_CHAINS` as call target and spender, and re-runs
52
+ `checkFyndTransaction` on the client against the app's own request (input, tokens, recipient,
53
+ minimum, no client fee) — a backend cannot point the swap anywhere else. Without the pins the
54
+ stub gets no route.
55
+
49
56
  | Option | Default | Meaning |
50
57
  |---|---|---|
51
58
  | `apiKey` | none | Hosted API key from Propeller Heads, sent as the raw `Authorization` header. |
package/dist/activity.cjs CHANGED
@@ -25,9 +25,10 @@ __export(activity_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(activity_exports);
27
27
  var import_activity = require("@anywalletkit/protocol-swap2-core/activity");
28
- var import_util = require("@anywalletkit/protocol-swap2-core/util");
28
+ var import_util2 = require("@anywalletkit/protocol-swap2-core/util");
29
29
 
30
30
  // src/router.ts
31
+ var import_util = require("@anywalletkit/protocol-swap2-core/util");
31
32
  var import_viem = require("viem");
32
33
  var FYND_CHAINS = Object.freeze({
33
34
  1: { slug: "ethereum", name: "Ethereum", router: "0x1644D2477f809cc2C71bCCFd6Dc9497E3F83210d" },
@@ -38,6 +39,8 @@ var FYND_CHAINS = Object.freeze({
38
39
  130: { slug: "unichain", name: "Unichain", router: "0xCba5574597Ad00EA250Fd106DAB4Fc7461949635" },
39
40
  4663: { slug: "robinhood", name: "Robinhood Chain", router: "0x09215a470bD585E59EB3F4B612fBD2678131fF9e" }
40
41
  });
42
+ var ROUTER_NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
43
+ var ZERO = "0x0000000000000000000000000000000000000000";
41
44
  var PARAMS = "uint256 amountIn, address tokenIn, address tokenOut, uint256 expectedAmountOut, uint256 minAmountOut";
42
45
  var FEE = "(uint32 clientFeeBps, address clientFeeReceiver, uint256 maxClientContribution, uint256 deadline, bytes clientSignature) clientFeeParams";
43
46
  var PERMIT = "((address token, uint160 amount, uint48 expiration, uint48 nonce) details, address spender, uint256 sigDeadline) permitSingle, bytes signature";
@@ -59,12 +62,94 @@ var TYCHO_ROUTER_SELECTORS = new Set(
59
62
  `splitSwapPermit2(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`
60
63
  ].map((sig) => (0, import_viem.toFunctionSelector)(`function ${sig}`))
61
64
  );
65
+ var FyndTransactionError = class extends Error {
66
+ constructor(message) {
67
+ super(`fynd: ${message}`);
68
+ this.name = "FyndTransactionError";
69
+ }
70
+ };
71
+ var sameAddress = (a, b) => {
72
+ try {
73
+ return (0, import_viem.getAddress)(a) === (0, import_viem.getAddress)(b);
74
+ } catch {
75
+ return false;
76
+ }
77
+ };
78
+ var routerToken = (t) => sameAddress(t, ZERO) ? ROUTER_NATIVE : t;
79
+ function checkFyndTransaction(tx, expected) {
80
+ const chain = FYND_CHAINS[expected.chainId];
81
+ if (!chain) throw new FyndTransactionError(`chain ${expected.chainId} has no pinned Tycho router`);
82
+ if (!sameAddress(tx.to, chain.router)) throw new FyndTransactionError(`the transaction targets ${/^0x[0-9a-fA-F]{40}$/.test(tx.to) ? tx.to : "something that is not an address"}, not the Tycho router on ${chain.name}`);
83
+ if (sameAddress(expected.receiver, ZERO) || sameAddress(expected.receiver, chain.router)) throw new FyndTransactionError("invalid receiver");
84
+ if (expected.amountIn <= 0n || expected.minAmountOut <= 0n || expected.minAmountOut > expected.expectedAmountOut) {
85
+ throw new FyndTransactionError("invalid quote amounts");
86
+ }
87
+ const nativeIn = sameAddress(expected.tokenIn, ZERO);
88
+ if (tx.value !== (nativeIn ? expected.amountIn : 0n)) throw new FyndTransactionError("native value does not match the input");
89
+ if (!/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(tx.data)) throw new FyndTransactionError("malformed calldata");
90
+ let call;
91
+ try {
92
+ call = (0, import_viem.decodeFunctionData)({ abi: TYCHO_ROUTER_ABI, data: tx.data });
93
+ } catch {
94
+ throw new FyndTransactionError("not a plain singleSwap / sequentialSwap / splitSwap call (Permit2 and vault variants are not used)");
95
+ }
96
+ const a = call.args;
97
+ const [amountIn, tokenIn, tokenOut, expectedAmountOut, minAmountOut] = a;
98
+ const isSplit = call.functionName === "splitSwap";
99
+ const receiver = isSplit ? a[6] : a[5];
100
+ const fee = isSplit ? a[7] : a[6];
101
+ const swaps = isSplit ? a[8] : a[7];
102
+ if (amountIn !== expected.amountIn) throw new FyndTransactionError(`calldata spends ${amountIn}, not ${expected.amountIn}`);
103
+ if (!sameAddress(tokenIn, routerToken(expected.tokenIn)) || !sameAddress(tokenOut, routerToken(expected.tokenOut))) {
104
+ throw new FyndTransactionError("calldata swaps other tokens than requested");
105
+ }
106
+ if (!sameAddress(receiver, expected.receiver)) throw new FyndTransactionError(`calldata pays ${receiver}, not ${expected.receiver}`);
107
+ if (expectedAmountOut !== expected.expectedAmountOut || minAmountOut !== expected.minAmountOut) {
108
+ throw new FyndTransactionError("calldata amounts do not match the quote");
109
+ }
110
+ if (fee.clientFeeBps !== 0 || fee.maxClientContribution !== 0n || !sameAddress(fee.clientFeeReceiver, ZERO)) {
111
+ throw new FyndTransactionError("calldata carries client-fee parameters \u2014 this module charges none");
112
+ }
113
+ if (swaps === "0x" || isSplit && a[5] < 2n) throw new FyndTransactionError("empty or invalid route");
114
+ return { method: call.functionName };
115
+ }
116
+ function fyndVerifyQuote(params, quote) {
117
+ try {
118
+ const chainId = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;
119
+ const src = (0, import_util.sourceAssetOf)(params);
120
+ if (!src) return `unknown source token ${params.sourceToken}`;
121
+ const tx = quote.txRequest;
122
+ if (!tx?.to || !tx.data) return "the quote carries no router transaction";
123
+ checkFyndTransaction({ to: tx.to, data: tx.data, value: BigInt(tx.value ?? "0") }, {
124
+ chainId,
125
+ tokenIn: src.contract ? (0, import_viem.getAddress)(src.contract) : ZERO,
126
+ tokenOut: /^0x0+$/.test(params.destToken) ? ZERO : (0, import_viem.getAddress)(params.destToken),
127
+ amountIn: BigInt(params.amountIn),
128
+ receiver: (0, import_viem.getAddress)(params.destAddress),
129
+ expectedAmountOut: BigInt(quote.providerData?.gross ?? "0"),
130
+ minAmountOut: BigInt(quote.minDestAmount)
131
+ });
132
+ return null;
133
+ } catch (e) {
134
+ return e instanceof Error ? e.message.replace(/^fynd: /, "") : String(e);
135
+ }
136
+ }
137
+ var fyndPins = Object.freeze({
138
+ callTargets: (chain) => fyndRouterFor(chain),
139
+ spenders: (chain) => fyndRouterFor(chain),
140
+ verifyQuote: fyndVerifyQuote
141
+ });
142
+ function fyndRouterFor(chain) {
143
+ const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;
144
+ const c = Object.prototype.hasOwnProperty.call(FYND_CHAINS, id) ? FYND_CHAINS[id] : void 0;
145
+ return c ? [c.router] : [];
146
+ }
62
147
 
63
148
  // src/activity.ts
64
149
  var FYND_MODULE = "@anywalletkit/protocol-swap2-fynd";
65
150
  function describeFyndActivity(tx, ctx) {
66
- if (!(0, import_util.isEvm)(tx.chain)) return null;
67
- const chain = FYND_CHAINS[(0, import_util.evmRef)(tx.chain)];
151
+ if (!(0, import_util2.isEvm)(tx.chain)) return null;
152
+ const chain = FYND_CHAINS[(0, import_util2.evmRef)(tx.chain)];
68
153
  if (!chain) return null;
69
154
  if (!(0, import_activity.matchesCall)(tx, [chain.router], TYCHO_ROUTER_SELECTORS)) return null;
70
155
  return (0, import_activity.describeSwapLike)(tx, ctx, { protocol: FYND_MODULE, subtitle: `Fynd \xB7 ${(0, import_activity.chainLabel)(tx.chain)}`, kind: "swap" });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/activity.ts","../src/router.ts"],"sourcesContent":["/**\n * Activity recognition for Fynd: a swap entry point of the pinned\n * TychoRouterV3 on a chain the module serves → `swap`, \"Swapped A → B\" from\n * 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 {FYND_CHAINS, TYCHO_ROUTER_SELECTORS} from \"./router.js\";\n\nexport const FYND_MODULE = \"@anywalletkit/protocol-swap2-fynd\";\n\nexport function describeFyndActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n if (!isEvm(tx.chain)) return null;\n const chain = FYND_CHAINS[evmRef(tx.chain)];\n if (!chain) return null;\n if (!matchesCall(tx, [chain.router], TYCHO_ROUTER_SELECTORS)) return null;\n return describeSwapLike(tx, ctx, {protocol: FYND_MODULE, subtitle: `Fynd · ${chainLabel(tx.chain)}`, kind: \"swap\"});\n}\n","/**\n * TychoRouterV3 — the only contract a Fynd quote may settle through (Fynd\n * License §3: every settlement of a Fynd output goes through the router in\n * Propeller Heads' registry). This file pins the router per chain and checks\n * Fynd's encoded transaction against the request before anything is approved\n * or sent: right contract, right method, the exact input, the requested\n * tokens, the user as receiver, the quoted output and minimum, and no client\n * fee. The route inside `swaps` is opaque and is not inspected here — the\n * router itself reverts below `minAmountOut`.\n */\nimport {decodeFunctionData, getAddress, parseAbi, toFunctionSelector, type Hex} from \"viem\";\n\n/** Router registry: github.com/propeller-heads/tycho crates/tycho-execution/config/deployment_registry.json (TychoRouterV3, effective 2026-09-01). */\nexport const FYND_CHAINS: Readonly<Record<number, {slug: string; name: string; router: `0x${string}`}>> = Object.freeze({\n 1: {slug: \"ethereum\", name: \"Ethereum\", router: \"0x1644D2477f809cc2C71bCCFd6Dc9497E3F83210d\"},\n 8453: {slug: \"base\", name: \"Base\", router: \"0xAbA5B53b03eAfaD1C5fc8BD5Fc765fC85Bb3de67\"},\n 42161: {slug: \"arbitrum\", name: \"Arbitrum\", router: \"0x924F147c50eA59f5180a26031A8b65B2aA1e81Cd\"},\n 56: {slug: \"bsc\", name: \"BNB Smart Chain\", router: \"0x7f3D12BBaFb8955E51B3ab9588b34c8ad95BDA4e\"},\n 137: {slug: \"polygon\", name: \"Polygon\", router: \"0xbd4e6011F03355C2A377Fd9Af939322A7d0A1bC1\"},\n 130: {slug: \"unichain\", name: \"Unichain\", router: \"0xCba5574597Ad00EA250Fd106DAB4Fc7461949635\"},\n 4663: {slug: \"robinhood\", name: \"Robinhood Chain\", router: \"0x09215a470bD585E59EB3F4B612fBD2678131fF9e\"},\n});\n\n/** The router's native-coin sentinel (lib/NativeETH.sol); Fynd's API uses the zero address instead. */\nexport const ROUTER_NATIVE = \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\";\nconst ZERO = \"0x0000000000000000000000000000000000000000\";\n\nconst PARAMS = \"uint256 amountIn, address tokenIn, address tokenOut, uint256 expectedAmountOut, uint256 minAmountOut\";\nconst FEE = \"(uint32 clientFeeBps, address clientFeeReceiver, uint256 maxClientContribution, uint256 deadline, bytes clientSignature) clientFeeParams\";\nconst PERMIT = \"((address token, uint160 amount, uint48 expiration, uint48 nonce) details, address spender, uint256 sigDeadline) permitSingle, bytes signature\";\n\n/** The three entry points a wallet swap uses (plain `transferFrom` from the user). */\nexport const TYCHO_ROUTER_ABI = parseAbi([\n `function singleSwap(${PARAMS}, address receiver, ${FEE}, bytes swapData) payable returns (uint256)`,\n `function sequentialSwap(${PARAMS}, address receiver, ${FEE}, bytes swaps) payable returns (uint256)`,\n `function splitSwap(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps) payable returns (uint256)`,\n]);\n\n/** Every swap entry point of the router (Permit2 and vault variants included) — for recognizing history. */\nexport const TYCHO_ROUTER_SELECTORS: ReadonlySet<string> = new Set(\n [\n `singleSwap(${PARAMS}, address receiver, ${FEE}, bytes swapData)`,\n `sequentialSwap(${PARAMS}, address receiver, ${FEE}, bytes swaps)`,\n `splitSwap(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps)`,\n `singleSwapUsingVault(${PARAMS}, address receiver, ${FEE}, bytes swapData)`,\n `sequentialSwapUsingVault(${PARAMS}, address receiver, ${FEE}, bytes swaps)`,\n `splitSwapUsingVault(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps)`,\n `singleSwapPermit2(${PARAMS}, address receiver, ${FEE}, ${PERMIT}, bytes swapData)`,\n `sequentialSwapPermit2(${PARAMS}, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`,\n `splitSwapPermit2(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`,\n ].map((sig) => toFunctionSelector(`function ${sig}`)),\n);\n\nexport class FyndTransactionError extends Error {\n constructor(message: string) {\n super(`fynd: ${message}`);\n this.name = \"FyndTransactionError\";\n }\n}\n\nexport interface ExpectedSwap {\n chainId: number;\n /** ERC-20 address, or the zero address for the native coin. */\n tokenIn: string;\n tokenOut: string;\n amountIn: bigint;\n receiver: string;\n /** Fynd's gross `amount_out` (before the router fee and slippage). */\n expectedAmountOut: bigint;\n /** Fynd's `min_amount_received` — what the router enforces on-chain. */\n minAmountOut: bigint;\n}\n\nexport interface EncodedTx {\n to: string;\n value: bigint;\n data: string;\n}\n\nconst sameAddress = (a: string, b: string) => {\n try {\n return getAddress(a) === getAddress(b);\n } catch {\n return false;\n }\n};\nconst routerToken = (t: string) => (sameAddress(t, ZERO) ? ROUTER_NATIVE : t);\n\n/** Refuses (throws {@link FyndTransactionError}) unless `tx` is exactly the swap the wallet asked for. */\nexport function checkFyndTransaction(tx: EncodedTx, expected: ExpectedSwap): {method: \"singleSwap\" | \"sequentialSwap\" | \"splitSwap\"} {\n const chain = FYND_CHAINS[expected.chainId];\n if (!chain) throw new FyndTransactionError(`chain ${expected.chainId} has no pinned Tycho router`);\n if (!sameAddress(tx.to, chain.router)) throw new FyndTransactionError(`the transaction targets ${tx.to}, not the Tycho router on ${chain.name}`);\n if (sameAddress(expected.receiver, ZERO) || sameAddress(expected.receiver, chain.router)) throw new FyndTransactionError(\"invalid receiver\");\n if (expected.amountIn <= 0n || expected.minAmountOut <= 0n || expected.minAmountOut > expected.expectedAmountOut) {\n throw new FyndTransactionError(\"invalid quote amounts\");\n }\n const nativeIn = sameAddress(expected.tokenIn, ZERO);\n if (tx.value !== (nativeIn ? expected.amountIn : 0n)) throw new FyndTransactionError(\"native value does not match the input\");\n if (!/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(tx.data)) throw new FyndTransactionError(\"malformed calldata\");\n\n let call: ReturnType<typeof decodeFunctionData<typeof TYCHO_ROUTER_ABI>>;\n try {\n call = decodeFunctionData({abi: TYCHO_ROUTER_ABI, data: tx.data as Hex});\n } catch {\n throw new FyndTransactionError(\"not a plain singleSwap / sequentialSwap / splitSwap call (Permit2 and vault variants are not used)\");\n }\n const a = call.args;\n const [amountIn, tokenIn, tokenOut, expectedAmountOut, minAmountOut] = a;\n const isSplit = call.functionName === \"splitSwap\";\n const receiver = (isSplit ? a[6] : a[5]) as string;\n const fee = (isSplit ? a[7] : a[6]) as {clientFeeBps: number; clientFeeReceiver: string; maxClientContribution: bigint; deadline: bigint; clientSignature: string};\n const swaps = (isSplit ? a[8] : a[7]) as string;\n if (amountIn !== expected.amountIn) throw new FyndTransactionError(`calldata spends ${amountIn}, not ${expected.amountIn}`);\n if (!sameAddress(tokenIn, routerToken(expected.tokenIn)) || !sameAddress(tokenOut, routerToken(expected.tokenOut))) {\n throw new FyndTransactionError(\"calldata swaps other tokens than requested\");\n }\n if (!sameAddress(receiver, expected.receiver)) throw new FyndTransactionError(`calldata pays ${receiver}, not ${expected.receiver}`);\n if (expectedAmountOut !== expected.expectedAmountOut || minAmountOut !== expected.minAmountOut) {\n throw new FyndTransactionError(\"calldata amounts do not match the quote\");\n }\n if (fee.clientFeeBps !== 0 || fee.maxClientContribution !== 0n || !sameAddress(fee.clientFeeReceiver, ZERO)) {\n throw new FyndTransactionError(\"calldata carries client-fee parameters — this module charges none\");\n }\n if (swaps === \"0x\" || (isSplit && (a[5] as bigint) < 2n)) throw new FyndTransactionError(\"empty or invalid route\");\n return {method: call.functionName};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAwD;AACxD,kBAA4B;;;ACG5B,kBAAqF;AAG9E,IAAM,cAA6F,OAAO,OAAO;AAAA,EACtH,GAAG,EAAC,MAAM,YAAY,MAAM,YAAY,QAAQ,6CAA4C;AAAA,EAC5F,MAAM,EAAC,MAAM,QAAQ,MAAM,QAAQ,QAAQ,6CAA4C;AAAA,EACvF,OAAO,EAAC,MAAM,YAAY,MAAM,YAAY,QAAQ,6CAA4C;AAAA,EAChG,IAAI,EAAC,MAAM,OAAO,MAAM,mBAAmB,QAAQ,6CAA4C;AAAA,EAC/F,KAAK,EAAC,MAAM,WAAW,MAAM,WAAW,QAAQ,6CAA4C;AAAA,EAC5F,KAAK,EAAC,MAAM,YAAY,MAAM,YAAY,QAAQ,6CAA4C;AAAA,EAC9F,MAAM,EAAC,MAAM,aAAa,MAAM,mBAAmB,QAAQ,6CAA4C;AACzG,CAAC;AAMD,IAAM,SAAS;AACf,IAAM,MAAM;AACZ,IAAM,SAAS;AAGR,IAAM,uBAAmB,sBAAS;AAAA,EACvC,uBAAuB,MAAM,uBAAuB,GAAG;AAAA,EACvD,2BAA2B,MAAM,uBAAuB,GAAG;AAAA,EAC3D,sBAAsB,MAAM,wCAAwC,GAAG;AACzE,CAAC;AAGM,IAAM,yBAA8C,IAAI;AAAA,EAC7D;AAAA,IACE,cAAc,MAAM,uBAAuB,GAAG;AAAA,IAC9C,kBAAkB,MAAM,uBAAuB,GAAG;AAAA,IAClD,aAAa,MAAM,wCAAwC,GAAG;AAAA,IAC9D,wBAAwB,MAAM,uBAAuB,GAAG;AAAA,IACxD,4BAA4B,MAAM,uBAAuB,GAAG;AAAA,IAC5D,uBAAuB,MAAM,wCAAwC,GAAG;AAAA,IACxE,qBAAqB,MAAM,uBAAuB,GAAG,KAAK,MAAM;AAAA,IAChE,yBAAyB,MAAM,uBAAuB,GAAG,KAAK,MAAM;AAAA,IACpE,oBAAoB,MAAM,wCAAwC,GAAG,KAAK,MAAM;AAAA,EAClF,EAAE,IAAI,CAAC,YAAQ,gCAAmB,YAAY,GAAG,EAAE,CAAC;AACtD;;;ADzCO,IAAM,cAAc;AAEpB,SAAS,qBAAqB,IAAa,KAAmD;AACnG,MAAI,KAAC,mBAAM,GAAG,KAAK,EAAG,QAAO;AAC7B,QAAM,QAAQ,gBAAY,oBAAO,GAAG,KAAK,CAAC;AAC1C,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,KAAC,6BAAY,IAAI,CAAC,MAAM,MAAM,GAAG,sBAAsB,EAAG,QAAO;AACrE,aAAO,kCAAiB,IAAI,KAAK,EAAC,UAAU,aAAa,UAAU,iBAAU,4BAAW,GAAG,KAAK,CAAC,IAAI,MAAM,OAAM,CAAC;AACpH;","names":[]}
1
+ {"version":3,"sources":["../src/activity.ts","../src/router.ts"],"sourcesContent":["/**\n * Activity recognition for Fynd: a swap entry point of the pinned\n * TychoRouterV3 on a chain the module serves → `swap`, \"Swapped A → B\" from\n * 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 {FYND_CHAINS, TYCHO_ROUTER_SELECTORS} from \"./router.js\";\n\nexport const FYND_MODULE = \"@anywalletkit/protocol-swap2-fynd\";\n\nexport function describeFyndActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n if (!isEvm(tx.chain)) return null;\n const chain = FYND_CHAINS[evmRef(tx.chain)];\n if (!chain) return null;\n if (!matchesCall(tx, [chain.router], TYCHO_ROUTER_SELECTORS)) return null;\n return describeSwapLike(tx, ctx, {protocol: FYND_MODULE, subtitle: `Fynd · ${chainLabel(tx.chain)}`, kind: \"swap\"});\n}\n","/**\n * TychoRouterV3 — the only contract a Fynd quote may settle through (Fynd\n * License §3: every settlement of a Fynd output goes through the router in\n * Propeller Heads' registry). This file pins the router per chain and checks\n * Fynd's encoded transaction against the request before anything is approved\n * or sent: right contract, right method, the exact input, the requested\n * tokens, the user as receiver, the quoted output and minimum, and no client\n * fee. The route inside `swaps` is opaque and is not inspected here — the\n * router itself reverts below `minAmountOut`.\n */\nimport type {Quote, QuoteParams, RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {decodeFunctionData, getAddress, parseAbi, toFunctionSelector, type Hex} from \"viem\";\n\n/** Router registry: github.com/propeller-heads/tycho crates/tycho-execution/config/deployment_registry.json (TychoRouterV3, effective 2026-09-01). */\nexport const FYND_CHAINS: Readonly<Record<number, {slug: string; name: string; router: `0x${string}`}>> = Object.freeze({\n 1: {slug: \"ethereum\", name: \"Ethereum\", router: \"0x1644D2477f809cc2C71bCCFd6Dc9497E3F83210d\"},\n 8453: {slug: \"base\", name: \"Base\", router: \"0xAbA5B53b03eAfaD1C5fc8BD5Fc765fC85Bb3de67\"},\n 42161: {slug: \"arbitrum\", name: \"Arbitrum\", router: \"0x924F147c50eA59f5180a26031A8b65B2aA1e81Cd\"},\n 56: {slug: \"bsc\", name: \"BNB Smart Chain\", router: \"0x7f3D12BBaFb8955E51B3ab9588b34c8ad95BDA4e\"},\n 137: {slug: \"polygon\", name: \"Polygon\", router: \"0xbd4e6011F03355C2A377Fd9Af939322A7d0A1bC1\"},\n 130: {slug: \"unichain\", name: \"Unichain\", router: \"0xCba5574597Ad00EA250Fd106DAB4Fc7461949635\"},\n 4663: {slug: \"robinhood\", name: \"Robinhood Chain\", router: \"0x09215a470bD585E59EB3F4B612fBD2678131fF9e\"},\n});\n\n/** The router's native-coin sentinel (lib/NativeETH.sol); Fynd's API uses the zero address instead. */\nexport const ROUTER_NATIVE = \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\";\nconst ZERO = \"0x0000000000000000000000000000000000000000\";\n\nconst PARAMS = \"uint256 amountIn, address tokenIn, address tokenOut, uint256 expectedAmountOut, uint256 minAmountOut\";\nconst FEE = \"(uint32 clientFeeBps, address clientFeeReceiver, uint256 maxClientContribution, uint256 deadline, bytes clientSignature) clientFeeParams\";\nconst PERMIT = \"((address token, uint160 amount, uint48 expiration, uint48 nonce) details, address spender, uint256 sigDeadline) permitSingle, bytes signature\";\n\n/** The three entry points a wallet swap uses (plain `transferFrom` from the user). */\nexport const TYCHO_ROUTER_ABI = parseAbi([\n `function singleSwap(${PARAMS}, address receiver, ${FEE}, bytes swapData) payable returns (uint256)`,\n `function sequentialSwap(${PARAMS}, address receiver, ${FEE}, bytes swaps) payable returns (uint256)`,\n `function splitSwap(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps) payable returns (uint256)`,\n]);\n\n/** Every swap entry point of the router (Permit2 and vault variants included) — for recognizing history. */\nexport const TYCHO_ROUTER_SELECTORS: ReadonlySet<string> = new Set(\n [\n `singleSwap(${PARAMS}, address receiver, ${FEE}, bytes swapData)`,\n `sequentialSwap(${PARAMS}, address receiver, ${FEE}, bytes swaps)`,\n `splitSwap(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps)`,\n `singleSwapUsingVault(${PARAMS}, address receiver, ${FEE}, bytes swapData)`,\n `sequentialSwapUsingVault(${PARAMS}, address receiver, ${FEE}, bytes swaps)`,\n `splitSwapUsingVault(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps)`,\n `singleSwapPermit2(${PARAMS}, address receiver, ${FEE}, ${PERMIT}, bytes swapData)`,\n `sequentialSwapPermit2(${PARAMS}, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`,\n `splitSwapPermit2(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`,\n ].map((sig) => toFunctionSelector(`function ${sig}`)),\n);\n\nexport class FyndTransactionError extends Error {\n constructor(message: string) {\n super(`fynd: ${message}`);\n this.name = \"FyndTransactionError\";\n }\n}\n\nexport interface ExpectedSwap {\n chainId: number;\n /** ERC-20 address, or the zero address for the native coin. */\n tokenIn: string;\n tokenOut: string;\n amountIn: bigint;\n receiver: string;\n /** Fynd's gross `amount_out` (before the router fee and slippage). */\n expectedAmountOut: bigint;\n /** Fynd's `min_amount_received` — what the router enforces on-chain. */\n minAmountOut: bigint;\n}\n\nexport interface EncodedTx {\n to: string;\n value: bigint;\n data: string;\n}\n\nconst sameAddress = (a: string, b: string) => {\n try {\n return getAddress(a) === getAddress(b);\n } catch {\n return false;\n }\n};\nconst routerToken = (t: string) => (sameAddress(t, ZERO) ? ROUTER_NATIVE : t);\n\n/** Refuses (throws {@link FyndTransactionError}) unless `tx` is exactly the swap the wallet asked for. */\nexport function checkFyndTransaction(tx: EncodedTx, expected: ExpectedSwap): {method: \"singleSwap\" | \"sequentialSwap\" | \"splitSwap\"} {\n const chain = FYND_CHAINS[expected.chainId];\n if (!chain) throw new FyndTransactionError(`chain ${expected.chainId} has no pinned Tycho router`);\n // `tx.to` is the API's: named in the refusal only when it is an address (scan 2026-10-27 modules, F34).\n if (!sameAddress(tx.to, chain.router)) throw new FyndTransactionError(`the transaction targets ${/^0x[0-9a-fA-F]{40}$/.test(tx.to) ? tx.to : \"something that is not an address\"}, not the Tycho router on ${chain.name}`);\n if (sameAddress(expected.receiver, ZERO) || sameAddress(expected.receiver, chain.router)) throw new FyndTransactionError(\"invalid receiver\");\n if (expected.amountIn <= 0n || expected.minAmountOut <= 0n || expected.minAmountOut > expected.expectedAmountOut) {\n throw new FyndTransactionError(\"invalid quote amounts\");\n }\n const nativeIn = sameAddress(expected.tokenIn, ZERO);\n if (tx.value !== (nativeIn ? expected.amountIn : 0n)) throw new FyndTransactionError(\"native value does not match the input\");\n if (!/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(tx.data)) throw new FyndTransactionError(\"malformed calldata\");\n\n let call: ReturnType<typeof decodeFunctionData<typeof TYCHO_ROUTER_ABI>>;\n try {\n call = decodeFunctionData({abi: TYCHO_ROUTER_ABI, data: tx.data as Hex});\n } catch {\n throw new FyndTransactionError(\"not a plain singleSwap / sequentialSwap / splitSwap call (Permit2 and vault variants are not used)\");\n }\n const a = call.args;\n const [amountIn, tokenIn, tokenOut, expectedAmountOut, minAmountOut] = a;\n const isSplit = call.functionName === \"splitSwap\";\n const receiver = (isSplit ? a[6] : a[5]) as string;\n const fee = (isSplit ? a[7] : a[6]) as {clientFeeBps: number; clientFeeReceiver: string; maxClientContribution: bigint; deadline: bigint; clientSignature: string};\n const swaps = (isSplit ? a[8] : a[7]) as string;\n if (amountIn !== expected.amountIn) throw new FyndTransactionError(`calldata spends ${amountIn}, not ${expected.amountIn}`);\n if (!sameAddress(tokenIn, routerToken(expected.tokenIn)) || !sameAddress(tokenOut, routerToken(expected.tokenOut))) {\n throw new FyndTransactionError(\"calldata swaps other tokens than requested\");\n }\n if (!sameAddress(receiver, expected.receiver)) throw new FyndTransactionError(`calldata pays ${receiver}, not ${expected.receiver}`);\n if (expectedAmountOut !== expected.expectedAmountOut || minAmountOut !== expected.minAmountOut) {\n throw new FyndTransactionError(\"calldata amounts do not match the quote\");\n }\n if (fee.clientFeeBps !== 0 || fee.maxClientContribution !== 0n || !sameAddress(fee.clientFeeReceiver, ZERO)) {\n throw new FyndTransactionError(\"calldata carries client-fee parameters — this module charges none\");\n }\n if (swaps === \"0x\" || (isSplit && (a[5] as bigint) < 2n)) throw new FyndTransactionError(\"empty or invalid route\");\n return {method: call.functionName};\n}\n\n/**\n * {@link checkFyndTransaction} on a remote quote, against the request this app sent: the pinned\n * router, the exact input, the requested tokens, the app's recipient, the quoted minimum and no\n * client fee. The reason it fails, or null.\n */\nexport function fyndVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n try {\n const chainId = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;\n const src = sourceAssetOf(params);\n if (!src) return `unknown source token ${params.sourceToken}`;\n const tx = quote.txRequest;\n if (!tx?.to || !tx.data) return \"the quote carries no router transaction\";\n checkFyndTransaction({to: tx.to, data: tx.data, value: BigInt(tx.value ?? \"0\")}, {\n chainId,\n tokenIn: src.contract ? getAddress(src.contract) : ZERO,\n tokenOut: /^0x0+$/.test(params.destToken) ? ZERO : getAddress(params.destToken),\n amountIn: BigInt(params.amountIn),\n receiver: getAddress(params.destAddress),\n expectedAmountOut: BigInt(quote.providerData?.gross ?? \"0\"),\n minAmountOut: BigInt(quote.minDestAmount),\n });\n return null;\n } catch (e) {\n return e instanceof Error ? e.message.replace(/^fynd: /, \"\") : String(e);\n }\n}\n\n/**\n * The Tycho router a Fynd swap calls and approves on a chain, and {@link fyndVerifyQuote} — the\n * app's side of `remoteProvider({name: \"fynd\", baseUrl, ...fyndPins})`, so a backend's quote is\n * checked against these routers and the app's own request, never against itself (scan 2026-10-27\n * modules, F9).\n */\nexport const fyndPins: RemotePins = Object.freeze({\n callTargets: (chain: string): readonly string[] => fyndRouterFor(chain),\n spenders: (chain: string): readonly string[] => fyndRouterFor(chain),\n verifyQuote: fyndVerifyQuote,\n});\nfunction fyndRouterFor(chain: string): readonly string[] {\n const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;\n const c = Object.prototype.hasOwnProperty.call(FYND_CHAINS, id) ? FYND_CHAINS[id] : undefined;\n return c ? [c.router] : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAwD;AACxD,IAAAA,eAA4B;;;ACI5B,kBAA4B;AAC5B,kBAAqF;AAG9E,IAAM,cAA6F,OAAO,OAAO;AAA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AM,GAAG,sBAAsB,EAAG,QAAO;AACrE,aAAO,kCAAiB,IAAI,KAAK,EAAC,UAAU,aAAa,UAAU,iBAAU,4BAAW,GAAG,KAAK,CAAC,IAAI,MAAM,OAAM,CAAC;AACpH;","names":["import_util"]}
package/dist/activity.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  FYND_MODULE,
3
3
  describeFyndActivity
4
- } from "./chunk-WVX55NNY.js";
5
- import "./chunk-F5P3PLJN.js";
4
+ } from "./chunk-Q23IYNLF.js";
5
+ import "./chunk-EF7GO24L.js";
6
6
  export {
7
7
  FYND_MODULE,
8
8
  describeFyndActivity
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  fyndProvider
3
- } from "./chunk-62LCDREE.js";
3
+ } from "./chunk-MU4JJYO3.js";
4
4
  import {
5
5
  FYND_CHAINS
6
- } from "./chunk-F5P3PLJN.js";
6
+ } from "./chunk-EF7GO24L.js";
7
7
 
8
8
  // src/protocol.ts
9
9
  import { SingleProviderSwap2 } from "@anywalletkit/protocol-swap2-core/swap2/single";
@@ -29,4 +29,4 @@ var FyndSwap2Protocol = class extends SingleProviderSwap2 {
29
29
  export {
30
30
  FyndSwap2Protocol
31
31
  };
32
- //# sourceMappingURL=chunk-TS3VLYJY.js.map
32
+ //# sourceMappingURL=chunk-DKT3R77D.js.map
@@ -1,4 +1,5 @@
1
1
  // src/router.ts
2
+ import { sourceAssetOf } from "@anywalletkit/protocol-swap2-core/util";
2
3
  import { decodeFunctionData, getAddress, parseAbi, toFunctionSelector } from "viem";
3
4
  var FYND_CHAINS = Object.freeze({
4
5
  1: { slug: "ethereum", name: "Ethereum", router: "0x1644D2477f809cc2C71bCCFd6Dc9497E3F83210d" },
@@ -49,7 +50,7 @@ var routerToken = (t) => sameAddress(t, ZERO) ? ROUTER_NATIVE : t;
49
50
  function checkFyndTransaction(tx, expected) {
50
51
  const chain = FYND_CHAINS[expected.chainId];
51
52
  if (!chain) throw new FyndTransactionError(`chain ${expected.chainId} has no pinned Tycho router`);
52
- if (!sameAddress(tx.to, chain.router)) throw new FyndTransactionError(`the transaction targets ${tx.to}, not the Tycho router on ${chain.name}`);
53
+ if (!sameAddress(tx.to, chain.router)) throw new FyndTransactionError(`the transaction targets ${/^0x[0-9a-fA-F]{40}$/.test(tx.to) ? tx.to : "something that is not an address"}, not the Tycho router on ${chain.name}`);
53
54
  if (sameAddress(expected.receiver, ZERO) || sameAddress(expected.receiver, chain.router)) throw new FyndTransactionError("invalid receiver");
54
55
  if (expected.amountIn <= 0n || expected.minAmountOut <= 0n || expected.minAmountOut > expected.expectedAmountOut) {
55
56
  throw new FyndTransactionError("invalid quote amounts");
@@ -83,6 +84,37 @@ function checkFyndTransaction(tx, expected) {
83
84
  if (swaps === "0x" || isSplit && a[5] < 2n) throw new FyndTransactionError("empty or invalid route");
84
85
  return { method: call.functionName };
85
86
  }
87
+ function fyndVerifyQuote(params, quote) {
88
+ try {
89
+ const chainId = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;
90
+ const src = sourceAssetOf(params);
91
+ if (!src) return `unknown source token ${params.sourceToken}`;
92
+ const tx = quote.txRequest;
93
+ if (!tx?.to || !tx.data) return "the quote carries no router transaction";
94
+ checkFyndTransaction({ to: tx.to, data: tx.data, value: BigInt(tx.value ?? "0") }, {
95
+ chainId,
96
+ tokenIn: src.contract ? getAddress(src.contract) : ZERO,
97
+ tokenOut: /^0x0+$/.test(params.destToken) ? ZERO : getAddress(params.destToken),
98
+ amountIn: BigInt(params.amountIn),
99
+ receiver: getAddress(params.destAddress),
100
+ expectedAmountOut: BigInt(quote.providerData?.gross ?? "0"),
101
+ minAmountOut: BigInt(quote.minDestAmount)
102
+ });
103
+ return null;
104
+ } catch (e) {
105
+ return e instanceof Error ? e.message.replace(/^fynd: /, "") : String(e);
106
+ }
107
+ }
108
+ var fyndPins = Object.freeze({
109
+ callTargets: (chain) => fyndRouterFor(chain),
110
+ spenders: (chain) => fyndRouterFor(chain),
111
+ verifyQuote: fyndVerifyQuote
112
+ });
113
+ function fyndRouterFor(chain) {
114
+ const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;
115
+ const c = Object.prototype.hasOwnProperty.call(FYND_CHAINS, id) ? FYND_CHAINS[id] : void 0;
116
+ return c ? [c.router] : [];
117
+ }
86
118
 
87
119
  export {
88
120
  FYND_CHAINS,
@@ -90,6 +122,8 @@ export {
90
122
  TYCHO_ROUTER_ABI,
91
123
  TYCHO_ROUTER_SELECTORS,
92
124
  FyndTransactionError,
93
- checkFyndTransaction
125
+ checkFyndTransaction,
126
+ fyndVerifyQuote,
127
+ fyndPins
94
128
  };
95
- //# sourceMappingURL=chunk-F5P3PLJN.js.map
129
+ //# sourceMappingURL=chunk-EF7GO24L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router.ts"],"sourcesContent":["/**\n * TychoRouterV3 — the only contract a Fynd quote may settle through (Fynd\n * License §3: every settlement of a Fynd output goes through the router in\n * Propeller Heads' registry). This file pins the router per chain and checks\n * Fynd's encoded transaction against the request before anything is approved\n * or sent: right contract, right method, the exact input, the requested\n * tokens, the user as receiver, the quoted output and minimum, and no client\n * fee. The route inside `swaps` is opaque and is not inspected here — the\n * router itself reverts below `minAmountOut`.\n */\nimport type {Quote, QuoteParams, RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {decodeFunctionData, getAddress, parseAbi, toFunctionSelector, type Hex} from \"viem\";\n\n/** Router registry: github.com/propeller-heads/tycho crates/tycho-execution/config/deployment_registry.json (TychoRouterV3, effective 2026-09-01). */\nexport const FYND_CHAINS: Readonly<Record<number, {slug: string; name: string; router: `0x${string}`}>> = Object.freeze({\n 1: {slug: \"ethereum\", name: \"Ethereum\", router: \"0x1644D2477f809cc2C71bCCFd6Dc9497E3F83210d\"},\n 8453: {slug: \"base\", name: \"Base\", router: \"0xAbA5B53b03eAfaD1C5fc8BD5Fc765fC85Bb3de67\"},\n 42161: {slug: \"arbitrum\", name: \"Arbitrum\", router: \"0x924F147c50eA59f5180a26031A8b65B2aA1e81Cd\"},\n 56: {slug: \"bsc\", name: \"BNB Smart Chain\", router: \"0x7f3D12BBaFb8955E51B3ab9588b34c8ad95BDA4e\"},\n 137: {slug: \"polygon\", name: \"Polygon\", router: \"0xbd4e6011F03355C2A377Fd9Af939322A7d0A1bC1\"},\n 130: {slug: \"unichain\", name: \"Unichain\", router: \"0xCba5574597Ad00EA250Fd106DAB4Fc7461949635\"},\n 4663: {slug: \"robinhood\", name: \"Robinhood Chain\", router: \"0x09215a470bD585E59EB3F4B612fBD2678131fF9e\"},\n});\n\n/** The router's native-coin sentinel (lib/NativeETH.sol); Fynd's API uses the zero address instead. */\nexport const ROUTER_NATIVE = \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\";\nconst ZERO = \"0x0000000000000000000000000000000000000000\";\n\nconst PARAMS = \"uint256 amountIn, address tokenIn, address tokenOut, uint256 expectedAmountOut, uint256 minAmountOut\";\nconst FEE = \"(uint32 clientFeeBps, address clientFeeReceiver, uint256 maxClientContribution, uint256 deadline, bytes clientSignature) clientFeeParams\";\nconst PERMIT = \"((address token, uint160 amount, uint48 expiration, uint48 nonce) details, address spender, uint256 sigDeadline) permitSingle, bytes signature\";\n\n/** The three entry points a wallet swap uses (plain `transferFrom` from the user). */\nexport const TYCHO_ROUTER_ABI = parseAbi([\n `function singleSwap(${PARAMS}, address receiver, ${FEE}, bytes swapData) payable returns (uint256)`,\n `function sequentialSwap(${PARAMS}, address receiver, ${FEE}, bytes swaps) payable returns (uint256)`,\n `function splitSwap(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps) payable returns (uint256)`,\n]);\n\n/** Every swap entry point of the router (Permit2 and vault variants included) — for recognizing history. */\nexport const TYCHO_ROUTER_SELECTORS: ReadonlySet<string> = new Set(\n [\n `singleSwap(${PARAMS}, address receiver, ${FEE}, bytes swapData)`,\n `sequentialSwap(${PARAMS}, address receiver, ${FEE}, bytes swaps)`,\n `splitSwap(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps)`,\n `singleSwapUsingVault(${PARAMS}, address receiver, ${FEE}, bytes swapData)`,\n `sequentialSwapUsingVault(${PARAMS}, address receiver, ${FEE}, bytes swaps)`,\n `splitSwapUsingVault(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, bytes swaps)`,\n `singleSwapPermit2(${PARAMS}, address receiver, ${FEE}, ${PERMIT}, bytes swapData)`,\n `sequentialSwapPermit2(${PARAMS}, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`,\n `splitSwapPermit2(${PARAMS}, uint256 nTokens, address receiver, ${FEE}, ${PERMIT}, bytes swaps)`,\n ].map((sig) => toFunctionSelector(`function ${sig}`)),\n);\n\nexport class FyndTransactionError extends Error {\n constructor(message: string) {\n super(`fynd: ${message}`);\n this.name = \"FyndTransactionError\";\n }\n}\n\nexport interface ExpectedSwap {\n chainId: number;\n /** ERC-20 address, or the zero address for the native coin. */\n tokenIn: string;\n tokenOut: string;\n amountIn: bigint;\n receiver: string;\n /** Fynd's gross `amount_out` (before the router fee and slippage). */\n expectedAmountOut: bigint;\n /** Fynd's `min_amount_received` — what the router enforces on-chain. */\n minAmountOut: bigint;\n}\n\nexport interface EncodedTx {\n to: string;\n value: bigint;\n data: string;\n}\n\nconst sameAddress = (a: string, b: string) => {\n try {\n return getAddress(a) === getAddress(b);\n } catch {\n return false;\n }\n};\nconst routerToken = (t: string) => (sameAddress(t, ZERO) ? ROUTER_NATIVE : t);\n\n/** Refuses (throws {@link FyndTransactionError}) unless `tx` is exactly the swap the wallet asked for. */\nexport function checkFyndTransaction(tx: EncodedTx, expected: ExpectedSwap): {method: \"singleSwap\" | \"sequentialSwap\" | \"splitSwap\"} {\n const chain = FYND_CHAINS[expected.chainId];\n if (!chain) throw new FyndTransactionError(`chain ${expected.chainId} has no pinned Tycho router`);\n // `tx.to` is the API's: named in the refusal only when it is an address (scan 2026-10-27 modules, F34).\n if (!sameAddress(tx.to, chain.router)) throw new FyndTransactionError(`the transaction targets ${/^0x[0-9a-fA-F]{40}$/.test(tx.to) ? tx.to : \"something that is not an address\"}, not the Tycho router on ${chain.name}`);\n if (sameAddress(expected.receiver, ZERO) || sameAddress(expected.receiver, chain.router)) throw new FyndTransactionError(\"invalid receiver\");\n if (expected.amountIn <= 0n || expected.minAmountOut <= 0n || expected.minAmountOut > expected.expectedAmountOut) {\n throw new FyndTransactionError(\"invalid quote amounts\");\n }\n const nativeIn = sameAddress(expected.tokenIn, ZERO);\n if (tx.value !== (nativeIn ? expected.amountIn : 0n)) throw new FyndTransactionError(\"native value does not match the input\");\n if (!/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(tx.data)) throw new FyndTransactionError(\"malformed calldata\");\n\n let call: ReturnType<typeof decodeFunctionData<typeof TYCHO_ROUTER_ABI>>;\n try {\n call = decodeFunctionData({abi: TYCHO_ROUTER_ABI, data: tx.data as Hex});\n } catch {\n throw new FyndTransactionError(\"not a plain singleSwap / sequentialSwap / splitSwap call (Permit2 and vault variants are not used)\");\n }\n const a = call.args;\n const [amountIn, tokenIn, tokenOut, expectedAmountOut, minAmountOut] = a;\n const isSplit = call.functionName === \"splitSwap\";\n const receiver = (isSplit ? a[6] : a[5]) as string;\n const fee = (isSplit ? a[7] : a[6]) as {clientFeeBps: number; clientFeeReceiver: string; maxClientContribution: bigint; deadline: bigint; clientSignature: string};\n const swaps = (isSplit ? a[8] : a[7]) as string;\n if (amountIn !== expected.amountIn) throw new FyndTransactionError(`calldata spends ${amountIn}, not ${expected.amountIn}`);\n if (!sameAddress(tokenIn, routerToken(expected.tokenIn)) || !sameAddress(tokenOut, routerToken(expected.tokenOut))) {\n throw new FyndTransactionError(\"calldata swaps other tokens than requested\");\n }\n if (!sameAddress(receiver, expected.receiver)) throw new FyndTransactionError(`calldata pays ${receiver}, not ${expected.receiver}`);\n if (expectedAmountOut !== expected.expectedAmountOut || minAmountOut !== expected.minAmountOut) {\n throw new FyndTransactionError(\"calldata amounts do not match the quote\");\n }\n if (fee.clientFeeBps !== 0 || fee.maxClientContribution !== 0n || !sameAddress(fee.clientFeeReceiver, ZERO)) {\n throw new FyndTransactionError(\"calldata carries client-fee parameters — this module charges none\");\n }\n if (swaps === \"0x\" || (isSplit && (a[5] as bigint) < 2n)) throw new FyndTransactionError(\"empty or invalid route\");\n return {method: call.functionName};\n}\n\n/**\n * {@link checkFyndTransaction} on a remote quote, against the request this app sent: the pinned\n * router, the exact input, the requested tokens, the app's recipient, the quoted minimum and no\n * client fee. The reason it fails, or null.\n */\nexport function fyndVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n try {\n const chainId = /^eip155:[0-9]+$/.test(params.sourceChain) ? Number(params.sourceChain.slice(7)) : NaN;\n const src = sourceAssetOf(params);\n if (!src) return `unknown source token ${params.sourceToken}`;\n const tx = quote.txRequest;\n if (!tx?.to || !tx.data) return \"the quote carries no router transaction\";\n checkFyndTransaction({to: tx.to, data: tx.data, value: BigInt(tx.value ?? \"0\")}, {\n chainId,\n tokenIn: src.contract ? getAddress(src.contract) : ZERO,\n tokenOut: /^0x0+$/.test(params.destToken) ? ZERO : getAddress(params.destToken),\n amountIn: BigInt(params.amountIn),\n receiver: getAddress(params.destAddress),\n expectedAmountOut: BigInt(quote.providerData?.gross ?? \"0\"),\n minAmountOut: BigInt(quote.minDestAmount),\n });\n return null;\n } catch (e) {\n return e instanceof Error ? e.message.replace(/^fynd: /, \"\") : String(e);\n }\n}\n\n/**\n * The Tycho router a Fynd swap calls and approves on a chain, and {@link fyndVerifyQuote} — the\n * app's side of `remoteProvider({name: \"fynd\", baseUrl, ...fyndPins})`, so a backend's quote is\n * checked against these routers and the app's own request, never against itself (scan 2026-10-27\n * modules, F9).\n */\nexport const fyndPins: RemotePins = Object.freeze({\n callTargets: (chain: string): readonly string[] => fyndRouterFor(chain),\n spenders: (chain: string): readonly string[] => fyndRouterFor(chain),\n verifyQuote: fyndVerifyQuote,\n});\nfunction fyndRouterFor(chain: string): readonly string[] {\n const id = /^eip155:[0-9]+$/.test(chain) ? Number(chain.slice(7)) : NaN;\n const c = Object.prototype.hasOwnProperty.call(FYND_CHAINS, id) ? FYND_CHAINS[id] : undefined;\n return c ? [c.router] : [];\n}\n"],"mappings":";AAWA,SAAQ,qBAAoB;AAC5B,SAAQ,oBAAoB,YAAY,UAAU,0BAAmC;AAG9E,IAAM,cAA6F,OAAO,OAAO;AAAA,EACtH,GAAG,EAAC,MAAM,YAAY,MAAM,YAAY,QAAQ,6CAA4C;AAAA,EAC5F,MAAM,EAAC,MAAM,QAAQ,MAAM,QAAQ,QAAQ,6CAA4C;AAAA,EACvF,OAAO,EAAC,MAAM,YAAY,MAAM,YAAY,QAAQ,6CAA4C;AAAA,EAChG,IAAI,EAAC,MAAM,OAAO,MAAM,mBAAmB,QAAQ,6CAA4C;AAAA,EAC/F,KAAK,EAAC,MAAM,WAAW,MAAM,WAAW,QAAQ,6CAA4C;AAAA,EAC5F,KAAK,EAAC,MAAM,YAAY,MAAM,YAAY,QAAQ,6CAA4C;AAAA,EAC9F,MAAM,EAAC,MAAM,aAAa,MAAM,mBAAmB,QAAQ,6CAA4C;AACzG,CAAC;AAGM,IAAM,gBAAgB;AAC7B,IAAM,OAAO;AAEb,IAAM,SAAS;AACf,IAAM,MAAM;AACZ,IAAM,SAAS;AAGR,IAAM,mBAAmB,SAAS;AAAA,EACvC,uBAAuB,MAAM,uBAAuB,GAAG;AAAA,EACvD,2BAA2B,MAAM,uBAAuB,GAAG;AAAA,EAC3D,sBAAsB,MAAM,wCAAwC,GAAG;AACzE,CAAC;AAGM,IAAM,yBAA8C,IAAI;AAAA,EAC7D;AAAA,IACE,cAAc,MAAM,uBAAuB,GAAG;AAAA,IAC9C,kBAAkB,MAAM,uBAAuB,GAAG;AAAA,IAClD,aAAa,MAAM,wCAAwC,GAAG;AAAA,IAC9D,wBAAwB,MAAM,uBAA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I,YAAY,EAAE,IAAI;AACpF,SAAO,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;AAC3B;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  describeFyndActivity
3
- } from "./chunk-WVX55NNY.js";
3
+ } from "./chunk-Q23IYNLF.js";
4
4
  import {
5
5
  FYND_CHAINS,
6
6
  checkFyndTransaction
7
- } from "./chunk-F5P3PLJN.js";
7
+ } from "./chunk-EF7GO24L.js";
8
8
 
9
9
  // src/provider.ts
10
10
  import { getAddress } from "viem";
@@ -23,6 +23,9 @@ var QUOTE_FAILURES = {
23
23
  encoding_failed: "could not encode the swap (fees + slippage leave nothing)"
24
24
  };
25
25
  var uint = (v) => typeof v === "string" && /^\d+$/.test(v) ? BigInt(v) : null;
26
+ var protocolName = (p) => p.length > 40 ? `${p.slice(0, 40)}\u2026` : p;
27
+ var sameText = (a, b) => a.length === b.length && a.toLowerCase() === b.toLowerCase();
28
+ var sameAmount = (a, b) => /^\d{1,80}$/.test(a) && /^\d{1,80}$/.test(b) && BigInt(a) === BigInt(b);
26
29
  function fyndProvider(config) {
27
30
  const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
28
31
  const slippageDefault = config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;
@@ -145,16 +148,16 @@ function fyndProvider(config) {
145
148
  }
146
149
  const allProtocols = [...new Set((q.route?.swaps ?? []).map((s) => s.protocol).filter((p) => typeof p === "string"))];
147
150
  const banned = allProtocols.find(isExcluded);
148
- if (banned) return refuse(`the route goes through ${banned}, which this wallet excludes`);
151
+ if (banned) return refuse(`the route goes through ${protocolName(banned)}, which this wallet excludes`);
149
152
  if (tokenIn === ZERO && config.rpcUrls?.[chainId]?.length) {
150
153
  try {
151
154
  await rpc(chainId, "eth_call", [{ from: sender, to: tx.to, data: tx.data, value: `0x${value.toString(16)}` }, "latest", { [sender]: { balance: `0x${(value + 10n ** 18n).toString(16)}` } }]);
152
155
  } catch (e) {
153
- if (e.rpc) return refuse(`the route does not execute on-chain right now (simulation reverted via ${allProtocols.join(", ") || "?"})`);
156
+ if (e.rpc) return refuse(`the route does not execute on-chain right now (simulation reverted via ${allProtocols.slice(0, 6).map(protocolName).join(", ") || "?"})`);
154
157
  }
155
158
  }
156
159
  const gas = uint(q.gas_estimate) ?? 0n;
157
- const protocols = allProtocols.slice(0, 6);
160
+ const protocols = allProtocols.slice(0, 6).map(protocolName);
158
161
  return {
159
162
  provider: "fynd",
160
163
  intentId: `fynd:${chainId}`,
@@ -187,13 +190,21 @@ function fyndProvider(config) {
187
190
  }
188
191
  };
189
192
  },
190
- /** Simulate the exact transaction at the latest block (allowance already in place); refuse when it would revert. */
193
+ /**
194
+ * Simulate the exact transaction at the latest block (allowance already in place); refuse when it would revert.
195
+ * Only the quote's own transaction is simulated: behind a backend `tx` is the client's and only the quote is
196
+ * sealed, so a client's call (any target, a megabyte of calldata) never reaches this RPC (scan 2026-10-27 modules, F24).
197
+ */
191
198
  async preflightDeposit(quote, tx) {
192
199
  const chainId = Number(quote.intentId.split(":")[1]);
193
200
  const sender = quote.providerData?.sender;
194
201
  if (!FYND_CHAINS[chainId] || !config.rpcUrls?.[chainId]?.length || !tx.data || !sender) return;
202
+ const quoted = quote.txRequest;
203
+ if (!quoted?.to || !quoted.data || !sameText(tx.to, quoted.to) || !sameText(tx.data, quoted.data) || !sameAmount(tx.value || "0", quoted.value ?? "0")) {
204
+ throw new Error("fynd: the transaction is not the quoted swap. Nothing was sent; refresh the quote.");
205
+ }
195
206
  try {
196
- await rpc(chainId, "eth_call", [{ from: sender, to: tx.to, data: tx.data, value: `0x${BigInt(tx.value || "0").toString(16)}` }, "latest"]);
207
+ await rpc(chainId, "eth_call", [{ from: sender, to: quoted.to, data: quoted.data, value: `0x${BigInt(quoted.value ?? "0").toString(16)}` }, "latest"]);
197
208
  } catch (e) {
198
209
  if (e.rpc) {
199
210
  throw new Error(`fynd: the swap would revert now (${e instanceof Error ? e.message.slice(0, 120) : "revert"}) \u2014 the price moved past your minimum. Nothing was sent; refresh the quote.`);
@@ -224,4 +235,4 @@ export {
224
235
  FYND_DEFAULT_EXCLUDED_PROTOCOLS,
225
236
  fyndProvider
226
237
  };
227
- //# sourceMappingURL=chunk-62LCDREE.js.map
238
+ //# sourceMappingURL=chunk-MU4JJYO3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import {getAddress} from \"viem\";\nimport {evmRef, isEvm, timeoutSignal, sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {describeFyndActivity} from \"./activity.js\";\nimport {FYND_CHAINS, checkFyndTransaction} from \"./router.js\";\n\n/**\n * Fynd — Propeller Heads' DEX aggregator (docs.fynd.xyz) as a same-chain\n * swap2 provider: exact-input swaps on Ethereum, Base, Arbitrum, BNB Chain,\n * Polygon, Unichain and Robinhood Chain, priced over the pools Tycho indexes\n * and settled through TychoRouterV3.\n *\n * Fynd outputs are licensed under the Fynd License: a swap built from a Fynd\n * quote must settle through the Tycho router with its fees intact — which is\n * the only transaction this provider builds (see README).\n *\n * Two backends: the hosted API (`apiKey` — keep it on a server, behind\n * `remoteProvider`) or your own `fynd serve` per chain (`selfHosted`).\n */\n\nconst ZERO = \"0x0000000000000000000000000000000000000000\";\nconst DEFAULT_BASE_URL = \"https://fynd-api.propellerheads.xyz\";\nconst DEFAULT_SLIPPAGE_BPS = 50;\n/** A Fynd quote is priced at one block; the router enforces the minimum, the engine re-checks this TTL before broadcast. */\nconst DEFAULT_TTL_MS = 30_000;\n/**\n * Liquidity families left out of routing by default. 2026-10-24 on the hosted\n * API: every Ethereum route through `uniswap_v4_hooks` was quoted ~0.6–1 %\n * above the market and reverted when simulated (4 of 4 native-in pairs,\n * also USDT → USDC), while the same pairs without it executed (8 of 8 across\n * Ethereum, Base and Arbitrum). Override with `excludeProtocols`.\n */\nexport const FYND_DEFAULT_EXCLUDED_PROTOCOLS: readonly string[] = Object.freeze([\"uniswap_v4_hooks\"]);\nconst QUOTE_FAILURES: Readonly<Record<string, string>> = {\n no_route_found: \"no route for this pair\",\n insufficient_liquidity: \"not enough liquidity for this amount\",\n timeout: \"the solver timed out\",\n not_ready: \"the solver is still syncing\",\n price_check_failed: \"the price guard rejected the route\",\n encoding_failed: \"could not encode the swap (fees + slippage leave nothing)\",\n};\n\nexport interface FyndProviderConfig {\n enabled?: boolean;\n /** Hosted API key (raw `Authorization` value). Server-side only. */\n apiKey?: string;\n /** Hosted API base URL; requests go to `{baseUrl}/v1/{chain}/quote`. */\n baseUrl?: string;\n /** Your own Fynd servers per EVM chain id; requests go to `{url}/v1/quote`, no key. Takes precedence over the hosted API for that chain. */\n selfHosted?: Readonly<Record<number, string>>;\n /** JSON-RPC endpoints per chain id: pre-broadcast simulation and receipts. Optional. */\n rpcUrls?: Readonly<Record<number, readonly string[]>>;\n defaultSlippageBps?: number;\n quoteTtlMs?: number;\n timeoutMs?: number;\n /** Protocol names or family prefixes ending in \":\" Fynd must not route through. Default {@link FYND_DEFAULT_EXCLUDED_PROTOCOLS}. */\n excludeProtocols?: readonly string[];\n}\n\ninterface FyndOrderQuote {\n status?: string;\n amount_in?: string;\n amount_out?: string;\n gas_estimate?: string;\n price_impact_bps?: number | null;\n route?: {swaps?: {protocol?: string}[]};\n fee_breakdown?: {router_fee?: string; client_fee?: string; max_slippage?: string; min_amount_received?: string};\n transaction?: {to?: string; value?: string; data?: string};\n}\n\nconst uint = (v: unknown): bigint | null => (typeof v === \"string\" && /^\\d+$/.test(v) ? BigInt(v) : null);\n/** A protocol name from the API as it may appear in a refusal or the quote: at most 40 characters (scan 2026-10-27 modules, F34). */\nconst protocolName = (p: string): string => (p.length > 40 ? `${p.slice(0, 40)}…` : p);\n/** Hex or an address, compared without case (length first: the client's side may be a megabyte). */\nconst sameText = (a: string, b: string): boolean => a.length === b.length && a.toLowerCase() === b.toLowerCase();\nconst sameAmount = (a: string, b: string): boolean => /^\\d{1,80}$/.test(a) && /^\\d{1,80}$/.test(b) && BigInt(a) === BigInt(b);\n\nexport function fyndProvider(config: FyndProviderConfig): CrossChainProvider {\n const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n const slippageDefault = config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;\n const ttl = config.quoteTtlMs ?? DEFAULT_TTL_MS;\n const timeoutMs = config.timeoutMs ?? 10_000;\n const excluded = [...(config.excludeProtocols ?? FYND_DEFAULT_EXCLUDED_PROTOCOLS)];\n const isExcluded = (protocol: string) => excluded.some((x) => (x.endsWith(\":\") ? protocol.startsWith(x) : protocol === x));\n\n const endpoint = (chainId: number): {url: string; headers: Record<string, string>} | null => {\n const chain = FYND_CHAINS[chainId];\n if (!chain) return null;\n const own = config.selfHosted?.[chainId];\n if (own) return {url: `${own.replace(/\\/+$/, \"\")}/v1/quote`, headers: {}};\n if (!config.apiKey) return null;\n return {url: `${baseUrl}/v1/${chain.slug}/quote`, headers: {authorization: config.apiKey}};\n };\n const chainIdOf = (caip2: string): number | null => {\n if (!isEvm(caip2)) return null;\n const id = evmRef(caip2);\n return endpoint(id) ? id : null;\n };\n\n async function rpc(chainId: number, method: string, params: unknown[]): Promise<unknown> {\n let lastErr: unknown;\n for (const url of config.rpcUrls?.[chainId] ?? []) {\n try {\n const res = await fetch(url, {method: \"POST\", headers: {\"content-type\": \"application/json\"}, body: JSON.stringify({jsonrpc: \"2.0\", id: 1, method, params}), signal: timeoutSignal(12_000)});\n if (!res.ok) throw new Error(`HTTP ${res.status}`);\n const body = (await res.json()) as {result?: unknown; error?: {message?: string}};\n if (body.error) throw Object.assign(new Error(body.error.message ?? \"rpc error\"), {rpc: true});\n return body.result ?? null;\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) throw e;\n lastErr = e;\n }\n }\n throw new Error(`fynd: no RPC answered on chain ${chainId} (${lastErr instanceof Error ? lastErr.message : String(lastErr)})`);\n }\n\n return {\n name: \"fynd\",\n describeActivity: describeFyndActivity,\n supportsSameChain: true,\n enabled: () => config.enabled ?? true,\n supportsChain: (caip2: string) => chainIdOf(caip2) !== null,\n supportsChainPair: (from: string, to: string) => from === to && chainIdOf(from) !== null,\n supportsRoute: (from: Asset, to: Asset) => from.chain === to.chain && chainIdOf(from.chain) !== null,\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n const refuse = (why: string): null => {\n params.onRefusal?.(`fynd: ${why}`);\n return null;\n };\n if (params.flex) return refuse(\"amount-flexible deposits are not supported\");\n if (params.sourceChain !== params.destChain) return refuse(\"same-chain swaps only\");\n const chainId = chainIdOf(params.sourceChain);\n if (chainId === null) return refuse(`Fynd is not configured for ${params.sourceChain}`);\n const ep = endpoint(chainId)!;\n const src = sourceAssetOf(params);\n if (!src) return refuse(`unknown source token ${params.sourceToken}`);\n const tokenIn = src.contract ? getAddress(src.contract) : ZERO;\n const nativeOut = /^0x0+$/.test(params.destToken);\n if (!nativeOut && !/^0x[0-9a-fA-F]{40}$/.test(params.destToken)) return refuse(\"destination token must be an EVM address\");\n const tokenOut = nativeOut ? ZERO : getAddress(params.destToken);\n if (tokenIn === tokenOut) return refuse(\"same token in and out\");\n if (!/^0x[0-9a-fA-F]{40}$/.test(params.destAddress)) return refuse(\"recipient must be an EVM address\");\n const receiver = getAddress(params.destAddress);\n const sender = getAddress(params.refundAddress && /^0x[0-9a-fA-F]{40}$/.test(params.refundAddress) ? params.refundAddress : params.destAddress);\n let amountIn: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n } catch {\n return refuse(\"amount is not an integer\");\n }\n if (amountIn <= 0n) return refuse(\"amount must be positive\");\n const bps = params.slippageBps ?? slippageDefault;\n if (!Number.isInteger(bps) || bps <= 0 || bps >= 10_000) return refuse(\"invalid slippage\");\n\n const body = {\n orders: [{token_in: tokenIn, token_out: tokenOut, amount: amountIn.toString(), side: \"sell\", sender, receiver}],\n options: {\n timeout_ms: Math.min(timeoutMs, 8_000),\n encoding_options: {slippage: (bps / 10_000).toString(), transfer_type: \"transfer_from\"},\n ...(excluded.length ? {route_filter: {exclude_protocols: excluded}} : {}),\n },\n };\n let res: Response;\n try {\n res = await fetch(ep.url, {method: \"POST\", headers: {\"content-type\": \"application/json\", ...ep.headers}, body: JSON.stringify(body), signal: signal ?? timeoutSignal(timeoutMs)});\n } catch (e) {\n return refuse(`API unreachable (${e instanceof Error ? e.name : \"error\"})`);\n }\n if (res.status === 401 || res.status === 403) return refuse(`API key rejected (HTTP ${res.status})`);\n if (res.status === 429) return refuse(\"rate limited (HTTP 429)\");\n if (res.status === 422) return refuse(\"no route for this pair\");\n if (!res.ok) return refuse(`API answered HTTP ${res.status}`);\n let parsed: {orders?: FyndOrderQuote[]};\n try {\n parsed = (await res.json()) as {orders?: FyndOrderQuote[]};\n } catch {\n return refuse(\"malformed API response\");\n }\n if (!Array.isArray(parsed.orders) || parsed.orders.length !== 1) return refuse(\"malformed API response (order count)\");\n const q = parsed.orders[0]!;\n if (q.status !== \"success\") return refuse(QUOTE_FAILURES[q.status ?? \"\"] ?? `quote status ${String(q.status).slice(0, 40)}`);\n\n const quotedIn = uint(q.amount_in);\n const gross = uint(q.amount_out);\n const routerFee = uint(q.fee_breakdown?.router_fee);\n const clientFee = uint(q.fee_breakdown?.client_fee);\n const maxSlippage = uint(q.fee_breakdown?.max_slippage);\n const minOut = uint(q.fee_breakdown?.min_amount_received);\n const value = uint(q.transaction?.value ?? \"\");\n if (quotedIn === null || gross === null || routerFee === null || clientFee === null || maxSlippage === null || minOut === null || value === null) {\n return refuse(\"malformed quote amounts\");\n }\n if (quotedIn !== amountIn) return refuse(`quoted ${quotedIn}, not the requested ${amountIn}`);\n if (clientFee !== 0n) return refuse(\"the quote carries a client fee\");\n if (routerFee + clientFee + maxSlippage + minOut !== gross) return refuse(\"fee breakdown does not add up to the output\");\n if (params.minAmountOut !== undefined && minOut < BigInt(params.minAmountOut)) return refuse(`floor breach (min=${minOut} < floor=${params.minAmountOut})`);\n const tx = {to: q.transaction?.to ?? \"\", value, data: q.transaction?.data ?? \"\"};\n try {\n checkFyndTransaction(tx, {chainId, tokenIn, tokenOut, amountIn, receiver, expectedAmountOut: gross, minAmountOut: minOut});\n } catch (e) {\n return refuse(e instanceof Error ? e.message.replace(/^fynd: /, \"\") : String(e));\n }\n const allProtocols = [...new Set((q.route?.swaps ?? []).map((s) => s.protocol).filter((p): p is string => typeof p === \"string\"))];\n const banned = allProtocols.find(isExcluded);\n if (banned) return refuse(`the route goes through ${protocolName(banned)}, which this wallet excludes`);\n // Native input needs no allowance: the exact transaction can be executed\n // against the latest block right now, so a route that would revert never\n // enters the auction. (ERC-20 input is simulated in preflightDeposit,\n // once the approval exists.)\n if (tokenIn === ZERO && config.rpcUrls?.[chainId]?.length) {\n try {\n await rpc(chainId, \"eth_call\", [{from: sender, to: tx.to, data: tx.data, value: `0x${value.toString(16)}`}, \"latest\", {[sender]: {balance: `0x${(value + 10n ** 18n).toString(16)}`}}]);\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) return refuse(`the route does not execute on-chain right now (simulation reverted via ${allProtocols.slice(0, 6).map(protocolName).join(\", \") || \"?\"})`);\n // no RPC answered: the router still enforces the minimum\n }\n }\n const gas = uint(q.gas_estimate) ?? 0n;\n const protocols = allProtocols.slice(0, 6).map(protocolName);\n return {\n provider: \"fynd\",\n intentId: `fynd:${chainId}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {\n to: getAddress(tx.to),\n data: tx.data,\n value: value.toString(),\n chainId,\n // the router's own overhead on top of Fynd's route estimate\n gasLimit: ((gas * 13n) / 10n + 80_000n).toString(),\n ...(tokenIn === ZERO ? {} : {approvalAddress: getAddress(tx.to)}),\n },\n sourceAmount: amountIn.toString(),\n // what the receiver gets at the quoted price: gross minus the router fee\n destAmount: (gross - routerFee).toString(),\n minDestAmount: minOut.toString(),\n feeUsd: 0,\n etaSeconds: 15,\n reliability: 0.96,\n validUntilMs: Date.now() + ttl,\n providerData: {\n minOut: minOut.toString(),\n sender,\n routerFee: routerFee.toString(),\n gross: gross.toString(),\n protocols: protocols.join(\",\"),\n ...(typeof q.price_impact_bps === \"number\" ? {priceImpactBps: String(q.price_impact_bps)} : {}),\n },\n };\n },\n\n /**\n * Simulate the exact transaction at the latest block (allowance already in place); refuse when it would revert.\n * Only the quote's own transaction is simulated: behind a backend `tx` is the client's and only the quote is\n * sealed, so a client's call (any target, a megabyte of calldata) never reaches this RPC (scan 2026-10-27 modules, F24).\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const chainId = Number(quote.intentId.split(\":\")[1]);\n const sender = quote.providerData?.sender;\n if (!FYND_CHAINS[chainId] || !config.rpcUrls?.[chainId]?.length || !tx.data || !sender) return;\n const quoted = quote.txRequest;\n if (!quoted?.to || !quoted.data || !sameText(tx.to, quoted.to) || !sameText(tx.data, quoted.data) || !sameAmount(tx.value || \"0\", quoted.value ?? \"0\")) {\n throw new Error(\"fynd: the transaction is not the quoted swap. Nothing was sent; refresh the quote.\");\n }\n try {\n await rpc(chainId, \"eth_call\", [{from: sender, to: quoted.to, data: quoted.data, value: `0x${BigInt(quoted.value ?? \"0\").toString(16)}`}, \"latest\"]);\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) {\n throw new Error(`fynd: the swap would revert now (${e instanceof Error ? e.message.slice(0, 120) : \"revert\"}) — the price moved past your minimum. Nothing was sent; refresh the quote.`);\n }\n // no RPC answered: leave it to the router's own minimum\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n if (!tx?.to || !tx.data) throw new Error(\"swap2: Fynd quote has no transaction request\");\n return {chain: \"\", to: tx.to, value: tx.value ?? \"0\", data: tx.data, ...(tx.chainId !== undefined ? {chainId: tx.chainId} : {}), ...(tx.gasLimit ? {gasLimit: tx.gasLimit} : {}), ...(tx.approvalAddress ? {approvalAddress: tx.approvalAddress} : {})};\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (!ref.sourceTxHash) return {state: \"pending\"};\n const chainId = Number(ref.intentId.split(\":\")[1]);\n if (!FYND_CHAINS[chainId] || !config.rpcUrls?.[chainId]?.length) return {state: \"pending\"};\n try {\n const receipt = (await rpc(chainId, \"eth_getTransactionReceipt\", [ref.sourceTxHash])) as {status?: string} | null;\n if (!receipt) return {state: \"pending\"};\n return receipt.status === \"0x1\" ? {state: \"completed\", destTxHash: ref.sourceTxHash} : {state: \"failed\"};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;AAAA,SAAQ,kBAAiB;AACzB,SAAQ,QAAQ,OAAO,eAAe,qBAAoB;AAmB1D,IAAM,OAAO;AACb,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAE7B,IAAM,iBAAiB;AAQhB,IAAM,kCAAqD,OAAO,OAAO,CAAC,kBAAkB,CAAC;AACpG,IAAM,iBAAmD;AAAA,EACvD,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,iBAAiB;AACnB;AA8BA,IAAM,OAAO,CAAC,MAA+B,OAAO,MAAM,YAAY,QAAQ,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI;AAEpG,IAAM,eAAe,CAAC,MAAuB,EAAE,SAAS,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,WAAM;AAEpF,IAAM,WAAW,CAAC,GAAW,MAAuB,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,MAAM,EAAE,YAAY;AAC/G,IAAM,aAAa,CAAC,GAAW,MAAuB,aAAa,KAAK,CAAC,KAAK,aAAa,KAAK,CAAC,KAAK,OAAO,CAAC,MAAM,OAAO,CAAC;AAErH,SAAS,aAAa,QAAgD;AAC3E,QAAM,WAAW,OAAO,WAAW,kBAAkB,QAAQ,QAAQ,EAAE;AAC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AAC,YAAY,OAAO,KAAK,CAAC,OAAO,UAAU,OAAO,GAAG,OAAQ,QAAO,EAAC,OAAO,UAAS;AACzF,UAAI;AACF,cAAM,UAAW,MAAM,IAAI,SAAS,6BAA6B,CAAC,IAAI,YAAY,CAAC;AACnF,YAAI,CAAC,QAAS,QAAO,EAAC,OAAO,UAAS;AACtC,eAAO,QAAQ,WAAW,QAAQ,EAAC,OAAO,aAAa,YAAY,IAAI,aAAY,IAAI,EAAC,OAAO,SAAQ;AAAA,MACzG,QAAQ;AACN,eAAO,EAAC,OAAO,UAAS;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FYND_CHAINS,
3
3
  TYCHO_ROUTER_SELECTORS
4
- } from "./chunk-F5P3PLJN.js";
4
+ } from "./chunk-EF7GO24L.js";
5
5
 
6
6
  // src/activity.ts
7
7
  import { chainLabel, describeSwapLike, matchesCall } from "@anywalletkit/protocol-swap2-core/activity";
@@ -19,4 +19,4 @@ export {
19
19
  FYND_MODULE,
20
20
  describeFyndActivity
21
21
  };
22
- //# sourceMappingURL=chunk-WVX55NNY.js.map
22
+ //# sourceMappingURL=chunk-Q23IYNLF.js.map