@anywalletkit/protocol-swap2-lifi 0.7.0 → 0.8.1

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.
@@ -71,7 +71,9 @@ declare function lifiProvider(config?: LifiProviderConfig): CrossChainProvider;
71
71
  * destination chain. A native input is paid in value (any excess is the declared bridge fee); a token input attaches
72
72
  * only that declared fee and approves the Diamond. A Solana source carries a serialized transaction instead, which the
73
73
  * account proves before signing (for a Mayan bridge, against the engine's `bridgeOut`); here only its static part is
74
- * read (paid by the sender; a Mayan route pays SOL to no other wallet). The reason it fails, or null.
74
+ * read (paid by the sender; a Mayan route pays SOL to no other wallet). A dry request without the sender, or an EVM →
75
+ * Solana one without the recipient, is priced for a placeholder: its quote must carry no transaction and is held to its
76
+ * terms only. The reason it fails, or null.
75
77
  */
76
78
  declare function lifiVerifyQuote(params: QuoteParams, quote: Quote): string | null;
77
79
  /**
@@ -71,7 +71,9 @@ declare function lifiProvider(config?: LifiProviderConfig): CrossChainProvider;
71
71
  * destination chain. A native input is paid in value (any excess is the declared bridge fee); a token input attaches
72
72
  * only that declared fee and approves the Diamond. A Solana source carries a serialized transaction instead, which the
73
73
  * account proves before signing (for a Mayan bridge, against the engine's `bridgeOut`); here only its static part is
74
- * read (paid by the sender; a Mayan route pays SOL to no other wallet). The reason it fails, or null.
74
+ * read (paid by the sender; a Mayan route pays SOL to no other wallet). A dry request without the sender, or an EVM →
75
+ * Solana one without the recipient, is priced for a placeholder: its quote must carry no transaction and is held to its
76
+ * terms only. The reason it fails, or null.
75
77
  */
76
78
  declare function lifiVerifyQuote(params: QuoteParams, quote: Quote): string | null;
77
79
  /**
package/dist/provider.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  lifiPins,
3
3
  lifiProvider,
4
4
  lifiVerifyQuote
5
- } from "./chunk-HJRWHGMX.js";
5
+ } from "./chunk-G26GE46T.js";
6
6
  import "./chunk-AARB4MBP.js";
7
7
  import "./chunk-EU7XQVZQ.js";
8
8
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anywalletkit/protocol-swap2-lifi",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "LI.FI cross-chain swaps and bridges for Any Wallet Kit: EVM routes through the LI.FI Diamond and guarded Solana transactions, standalone or as a provider of the swap2 router.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.anywallet.tech",
@@ -49,18 +49,20 @@
49
49
  "module.json"
50
50
  ],
51
51
  "dependencies": {
52
- "@anywalletkit/protocol-swap2-core": "0.10.3",
53
- "@anywalletkit/swap2-assets": "0.3.0"
52
+ "@noble/curves": "^2.4.0",
53
+ "@noble/hashes": "^2.4.0",
54
+ "@anywalletkit/swap2-assets": "0.3.0",
55
+ "@anywalletkit/protocol-swap2-core": "0.12.0"
54
56
  },
55
57
  "peerDependencies": {
56
58
  "@anywalletkit/core": "0.8.0"
57
59
  },
58
60
  "devDependencies": {
59
61
  "@types/node": "^22",
60
- "viem": "^2.57.2",
61
- "vitest": "^5.0.3",
62
- "@anywalletkit/core": "0.8.0",
63
- "@anywalletkit/conformance": "0.5.1"
62
+ "viem": "^2.57.16",
63
+ "vitest": "^5.1.0",
64
+ "@anywalletkit/conformance": "0.5.1",
65
+ "@anywalletkit/core": "0.8.0"
64
66
  },
65
67
  "keywords": [
66
68
  "swap2",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/calldata.ts","../src/solana.ts","../src/provider.ts"],"sourcesContent":["/**\n * What the LI.FI Diamond call really does, read from its calldata — not from the `action` /\n * `estimate` next to it (round 3, H9). The API (or an `apiUrl` proxy) could pair a reviewed\n * recipient and minimum with calldata that pays someone else, or accepts 1 wei.\n *\n * Same-chain swaps run through GenericSwapFacet(V3): receiver, minimum, the input token and amount,\n * and the output token are in the arguments. Bridges take `ILiFi.BridgeData` as their first\n * argument: its receiver, destination chain and bridged asset are checked, for the listed bridge\n * entry points only; a destination call (the final recipient sits in calldata for another chain)\n * and a non-EVM destination (the receiver sits in facet-specific data) are refused.\n *\n * A facet's own data also names who gets money back — unused native fee, swap leftovers, the whole input when an\n * order expires unfilled, a fallback when delivery fails ({@link FACET_DATA}); each such address must be the sender or\n * the recipient.\n *\n * Mostly not checked here: a bridge's OUTPUT. The destination minimum (and for some bridges, e.g.\n * Across, what the receiver finally gets) lives in facet-specific data, so for most bridges the\n * reviewed minimum still relies on LI.FI's API answering honestly. Eco and M0 are the exceptions\n * ({@link FacetData.delivery}): their facet data names the destination token, amount and (Eco) recipient\n * outright, and those are held to the quote.\n *\n * The receiver is only worth checking where the facet itself holds the bridge to it. Most do on\n * chain (Across V4, Mayan, Stargate, Chainflip, LI.FI Intents, GasZip, Glacis, AllBridge, M0, Polymer\n * CCTP) or through LI.FI's backend signature over BridgeData plus the off-chain order (NEAR Intents,\n * LayerSwap, Unit, the Across Swap API). Eco v3 binds its route to BridgeData.receiver by that signature\n * only, so the route itself is read here ({@link ecoDelivery}). The facets in {@link UNBOUND_BRIDGES} do\n * neither and are refused.\n */\n\n/**\n * The V3 entry points move one asset kind in and one out, and check the minimum against THAT kind's balance: a\n * `*ToNative` call measures the Diamond's native balance, so a minimum written in USDC units is enforced in wei\n * (scan 2026-10-27 modules, F20). Each selector is bound to the kinds it moves; `swapTokensGeneric` moves any.\n */\ntype Kind = \"native\" | \"erc20\";\nconst GENERIC_SWAPS: Readonly<Record<string, {single: boolean; from?: Kind; to?: Kind}>> = {\n \"0x4630a0d8\": {single: false}, // swapTokensGeneric\n \"0x4666fc80\": {single: true, from: \"erc20\", to: \"erc20\"}, // swapTokensSingleV3ERC20ToERC20\n \"0x733214a3\": {single: true, from: \"erc20\", to: \"native\"}, // swapTokensSingleV3ERC20ToNative\n \"0xaf7060fd\": {single: true, from: \"native\", to: \"erc20\"}, // swapTokensSingleV3NativeToERC20\n \"0x5fd9ae2e\": {single: false, from: \"erc20\", to: \"erc20\"}, // swapTokensMultipleV3ERC20ToERC20\n \"0x2c57e884\": {single: false, from: \"erc20\", to: \"native\"}, // swapTokensMultipleV3ERC20ToNative\n \"0x736eac0b\": {single: false, from: \"native\", to: \"erc20\"}, // swapTokensMultipleV3NativeToERC20\n};\n/** The most a bridge may keep from the input as its own fee when there are no source swaps, in basis points. */\nconst BRIDGE_INPUT_FEE_MAX_BPS = 100n;\nconst kindOf = (asset: string): Kind => (/^0x0{40}$/i.test(asset) ? \"native\" : \"erc20\");\n\n/**\n * The ABI-encoded bridge entry points of the LI.FI Diamond — `startBridgeTokensVia*` and\n * `swapAndStartBridgeTokensVia*`, whose first argument is `ILiFi.BridgeData` — computed from the\n * facet sources in lifinance/contracts (86c3729, 2026-10-26; EcoFacet v3.0.0 from 9001792, 2026-11-01, whose\n * EcoData gained `intentDestination` — the v2 selectors 0xbff90b61 / 0x762aea18 are gone from the Diamonds). Packed\n * facets and `*Min` variants read raw calldata, not BridgeData, and are not listed: any other selector is refused.\n */\nconst BRIDGE_CALLS: Readonly<Record<string, {sourceSwaps: boolean; facet: string}>> = {\n \"0x1fd8010c\": {sourceSwaps: false, facet: \"Across\"}, // startBridgeTokensViaAcross (AcrossFacet)\n \"0x3a3f7332\": {sourceSwaps: true, facet: \"Across\"}, // swapAndStartBridgeTokensViaAcross (AcrossFacet)\n \"0xa1f1ce43\": {sourceSwaps: false, facet: \"AcrossV4\"}, // startBridgeTokensViaAcrossV4 (AcrossFacetV4)\n \"0x1794958f\": {sourceSwaps: true, facet: \"AcrossV4\"}, // swapAndStartBridgeTokensViaAcrossV4 (AcrossFacetV4)\n \"0x6a90d66e\": {sourceSwaps: false, facet: \"AcrossV4Swap\"}, // startBridgeTokensViaAcrossV4Swap (AcrossV4SwapFacet)\n \"0x9b054bc4\": {sourceSwaps: true, facet: \"AcrossV4Swap\"}, // swapAndStartBridgeTokensViaAcrossV4Swap (AcrossV4SwapFacet)\n \"0x6a51e9a9\": {sourceSwaps: false, facet: \"AllBridge\"}, // startBridgeTokensViaAllBridge (AllBridgeFacet)\n \"0x63267469\": {sourceSwaps: true, facet: \"AllBridge\"}, // swapAndStartBridgeTokensViaAllBridge (AllBridgeFacet)\n \"0xc9851d0b\": {sourceSwaps: false, facet: \"ArbitrumBridge\"}, // startBridgeTokensViaArbitrumBridge (ArbitrumBridgeFacet)\n \"0x3cc9517b\": {sourceSwaps: true, facet: \"ArbitrumBridge\"}, // swapAndStartBridgeTokensViaArbitrumBridge (ArbitrumBridgeFacet)\n \"0xe0a4201c\": {sourceSwaps: false, facet: \"CelerCircleBridge\"}, // startBridgeTokensViaCelerCircleBridge (CelerCircleBridgeFacet)\n \"0x4f3b0759\": {sourceSwaps: true, facet: \"CelerCircleBridge\"}, // swapAndStartBridgeTokensViaCelerCircleBridge (CelerCircleBridgeFacet)\n \"0x0315138f\": {sourceSwaps: false, facet: \"Centrifuge\"}, // startBridgeTokensViaCentrifuge (CentrifugeFacet)\n \"0x8fd4d4dd\": {sourceSwaps: true, facet: \"Centrifuge\"}, // swapAndStartBridgeTokensViaCentrifuge (CentrifugeFacet)\n \"0x0ad553b3\": {sourceSwaps: false, facet: \"Chainflip\"}, // startBridgeTokensViaChainflip (ChainflipFacet)\n \"0xee3314a1\": {sourceSwaps: true, facet: \"Chainflip\"}, // swapAndStartBridgeTokensViaChainflip (ChainflipFacet)\n \"0x05c54990\": {sourceSwaps: false, facet: \"Eco\"}, // startBridgeTokensViaEco (EcoFacet v3.0.0, 9001792)\n \"0x8352664c\": {sourceSwaps: true, facet: \"Eco\"}, // swapAndStartBridgeTokensViaEco (EcoFacet v3.0.0, 9001792)\n \"0x678786ea\": {sourceSwaps: false, facet: \"Frax\"}, // startBridgeTokensViaFrax (FraxFacet)\n \"0x07b8e4c7\": {sourceSwaps: true, facet: \"Frax\"}, // swapAndStartBridgeTokensViaFrax (FraxFacet)\n \"0xfc5f1003\": {sourceSwaps: false, facet: \"GasZip\"}, // startBridgeTokensViaGasZip (GasZipFacet)\n \"0x606326ff\": {sourceSwaps: true, facet: \"GasZip\"}, // swapAndStartBridgeTokensViaGasZip (GasZipFacet)\n \"0x6f9206ba\": {sourceSwaps: false, facet: \"Glacis\"}, // startBridgeTokensViaGlacis (GlacisFacet)\n \"0x9c4b6dd9\": {sourceSwaps: true, facet: \"Glacis\"}, // swapAndStartBridgeTokensViaGlacis (GlacisFacet)\n \"0xf66fe519\": {sourceSwaps: false, facet: \"GnosisBridge\"}, // startBridgeTokensViaGnosisBridge (GnosisBridgeFacet)\n \"0x7bf96e0a\": {sourceSwaps: true, facet: \"GnosisBridge\"}, // swapAndStartBridgeTokensViaGnosisBridge (GnosisBridgeFacet)\n \"0xee9e98e0\": {sourceSwaps: false, facet: \"LayerSwap\"}, // startBridgeTokensViaLayerSwap (LayerSwapFacet)\n \"0x4c279d6b\": {sourceSwaps: true, facet: \"LayerSwap\"}, // swapAndStartBridgeTokensViaLayerSwap (LayerSwapFacet)\n \"0x7dbcf1d9\": {sourceSwaps: false, facet: \"LiFiIntentEscrowV2\"}, // startBridgeTokensViaLiFiIntentEscrowV2 (LiFiIntentEscrowFacetV2)\n \"0x6d21c5df\": {sourceSwaps: true, facet: \"LiFiIntentEscrowV2\"}, // swapAndStartBridgeTokensViaLiFiIntentEscrowV2 (LiFiIntentEscrowFacetV2)\n \"0x65782c4b\": {sourceSwaps: false, facet: \"M0\"}, // startBridgeTokensViaM0 (M0Facet)\n \"0xb9eaf86d\": {sourceSwaps: true, facet: \"M0\"}, // swapAndStartBridgeTokensViaM0 (M0Facet)\n \"0xb4875292\": {sourceSwaps: false, facet: \"Mayan\"}, // startBridgeTokensViaMayan (MayanFacet)\n \"0x80c65808\": {sourceSwaps: true, facet: \"Mayan\"}, // swapAndStartBridgeTokensViaMayan (MayanFacet)\n \"0x4213dfff\": {sourceSwaps: false, facet: \"MegaETHBridge\"}, // startBridgeTokensViaMegaETHBridge (MegaETHBridgeFacet)\n \"0x22256e89\": {sourceSwaps: true, facet: \"MegaETHBridge\"}, // swapAndStartBridgeTokensViaMegaETHBridge (MegaETHBridgeFacet)\n \"0x4698f032\": {sourceSwaps: false, facet: \"NEARIntents\"}, // startBridgeTokensViaNEARIntents (NEARIntentsFacet)\n \"0x02631b09\": {sourceSwaps: true, facet: \"NEARIntents\"}, // swapAndStartBridgeTokensViaNEARIntents (NEARIntentsFacet)\n \"0x782621d8\": {sourceSwaps: false, facet: \"OmniBridge\"}, // startBridgeTokensViaOmniBridge (OmniBridgeFacet)\n \"0x95726782\": {sourceSwaps: true, facet: \"OmniBridge\"}, // swapAndStartBridgeTokensViaOmniBridge (OmniBridgeFacet)\n \"0xce8a97a5\": {sourceSwaps: false, facet: \"OptimismBridge\"}, // startBridgeTokensViaOptimismBridge (OptimismBridgeFacet)\n \"0x5bb5d448\": {sourceSwaps: true, facet: \"OptimismBridge\"}, // swapAndStartBridgeTokensViaOptimismBridge (OptimismBridgeFacet)\n \"0xaf62c7d6\": {sourceSwaps: false, facet: \"PolygonBridge\"}, // startBridgeTokensViaPolygonBridge (PolygonBridgeFacet)\n \"0xb4f37581\": {sourceSwaps: true, facet: \"PolygonBridge\"}, // swapAndStartBridgeTokensViaPolygonBridge (PolygonBridgeFacet)\n \"0xf434d6ca\": {sourceSwaps: false, facet: \"PolymerCCTP\"}, // startBridgeTokensViaPolymerCCTP (PolymerCCTPFacet)\n \"0x17917a4e\": {sourceSwaps: true, facet: \"PolymerCCTP\"}, // swapAndStartBridgeTokensViaPolymerCCTP (PolymerCCTPFacet)\n \"0x14d53077\": {sourceSwaps: false, facet: \"Stargate\"}, // startBridgeTokensViaStargate (StargateFacetV2)\n \"0xa6010a66\": {sourceSwaps: true, facet: \"Stargate\"}, // swapAndStartBridgeTokensViaStargate (StargateFacetV2)\n \"0x0691ff78\": {sourceSwaps: false, facet: \"Superset\"}, // startBridgeTokensViaSuperset (SupersetFacet)\n \"0xf26e657f\": {sourceSwaps: true, facet: \"Superset\"}, // swapAndStartBridgeTokensViaSuperset (SupersetFacet)\n \"0x64261d58\": {sourceSwaps: false, facet: \"Unit\"}, // startBridgeTokensViaUnit (UnitFacet)\n \"0x21a3af52\": {sourceSwaps: true, facet: \"Unit\"}, // swapAndStartBridgeTokensViaUnit (UnitFacet)\n};\n\n/**\n * Bridge entry points that do not tie where the funds go to BridgeData.receiver (lifinance/contracts, main 2026-11-02):\n * Relay deposits against an `orderId` whose off-chain order names the recipient (\"We cannot validate / guarantee that the\n * off-chain-data associated with the provided orderId corresponds to the _bridgeData\"); Garden locks the funds for a\n * `redeemer` named in facet data, with the transfer details in an off-chain order; deBridge DLN passes its own\n * `receiver` and order authority through unchecked; ThorSwap pays a `vault` named in facet data with the destination in\n * a memo; Squid runs `sourceCalls` of any target on its multicall, which holds the funds, and bridges what is left\n * (only CallBridge bridges to BridgeData.receiver at all; LI.FI's live Squid quotes are BridgeCall, a destination\n * call); Symbiosis's MetaRouter path forwards `callTo` / `callData` verbatim and names the final recipient and the\n * revert address there (the facet: the emitted receiver \"is therefore descriptive, not an on-chain guarantee\"; its\n * other path bridges to Bitcoin only). A matching BridgeData.receiver proves nothing for these, so they are refused\n * by name.\n *\n * Relay's `orderId` is not opaque: it is a hash commitment, the EIP-712 `hashStruct` of the order (recipient, output\n * token, minimum, deadlines, refunds), signed by Relay's solver. What this path lacks is the preimage: a LI.FI quote\n * carries the id without the order behind it, and neither Relay nor any other party publishes an unauthenticated\n * lookup of an unfunded order by id (2026-11-02: `/intents/status` says \"unknown\", `/requests/v2` lists only indexed\n * deposits, `/requests/v3` needs an API key). With nothing to hash, the id cannot be held to the request here. Relay's\n * own quote does return the order, and `@anywalletkit/protocol-swap2-relay` verifies it on the device.\n */\nconst UNBOUND_BRIDGES: Readonly<Record<string, string>> = {\n \"0x092e8fa4\": \"Relay\", // startBridgeTokensViaRelayDepository\n \"0xa3443faa\": \"Relay\", // swapAndStartBridgeTokensViaRelayDepository\n \"0x5f9af35d\": \"Garden\", // startBridgeTokensViaGarden\n \"0x76ad76fe\": \"Garden\", // swapAndStartBridgeTokensViaGarden\n \"0x4004633e\": \"deBridge DLN\", // startBridgeTokensViaDeBridgeDln\n \"0x2c7d2db0\": \"deBridge DLN\", // swapAndStartBridgeTokensViaDeBridgeDln\n \"0x2541ec57\": \"ThorSwap\", // startBridgeTokensViaThorSwap\n \"0xad673d88\": \"ThorSwap\", // swapAndStartBridgeTokensViaThorSwap\n \"0x3f313808\": \"Squid\", // startBridgeTokensViaSquid\n \"0xa8f66666\": \"Squid\", // swapAndStartBridgeTokensViaSquid\n \"0xe23b7a08\": \"Symbiosis\", // startBridgeTokensViaSymbiosis\n \"0xc46059b2\": \"Symbiosis\", // swapAndStartBridgeTokensViaSymbiosis\n};\n\n/** What the quote promised, in the forms the calldata carries. */\nexport interface DiamondExpectation {\n /** Source token (EVM address; the zero address for the native coin). */\n fromToken: string;\n /** Destination token as LI.FI names it (the zero address for an EVM native coin). */\n toToken: string;\n /** Input, base units. */\n amountIn: bigint;\n /** The recipient (an EVM address, or another chain's address for a non-EVM destination). */\n receiver: string;\n /** The sender the quote was asked for (its `fromAddress`): where a bridge's refunds may go, besides the recipient. */\n sender: string;\n /** The floor the review shows. */\n minOut: bigint;\n /** LI.FI's id of the destination chain; equal to the source's for a swap. */\n destChainId: bigint;\n sameChain: boolean;\n /** The destination is an EVM chain (its receiver is a 20-byte address). */\n evmDestination: boolean;\n}\n\ninterface SwapStep {sendingAssetId: string; receivingAssetId: string; fromAmount: bigint; requiresDeposit: boolean}\n\nclass Reader {\n private readonly b: Uint8Array;\n constructor(src: string | Uint8Array) {\n if (typeof src !== \"string\") { this.b = src; return; }\n if (!/^0x([0-9a-fA-F]{2})*$/.test(src)) throw new Error(\"not hex\");\n this.b = Uint8Array.from(src.slice(2).match(/../g) ?? [], (h) => Number.parseInt(h, 16));\n }\n get length() { return this.b.length; }\n /** `n` raw bytes at `at`, as 0x-hex. */\n raw(at: number, n: number): string {\n if (at < 0 || at + n > this.b.length) throw new Error(\"out of bounds\");\n return `0x${Array.from(this.b.subarray(at, at + n), (x) => x.toString(16).padStart(2, \"0\")).join(\"\")}`;\n }\n /** The `bytes` whose offset word sits at `head` (relative to `base`), as a reader over its contents only. */\n bytes(base: number, head: number): Reader {\n const at = base + this.small(head);\n const n = this.small(at);\n if (at + 32 + n > this.b.length) throw new Error(\"bytes out of bounds\");\n return new Reader(this.b.subarray(at + 32, at + 32 + n));\n }\n word(at: number): bigint {\n if (at < 0 || at + 32 > this.b.length) throw new Error(\"out of bounds\");\n let v = 0n;\n for (let i = at; i < at + 32; i++) v = (v << 8n) | BigInt(this.b[i]!);\n return v;\n }\n /** A word that must fit a JS offset / length (bounded by the calldata). */\n small(at: number): number {\n const v = this.word(at);\n if (v > BigInt(this.b.length)) throw new Error(\"offset out of bounds\");\n return Number(v.toString()); // ≤ the calldata length\n }\n address(at: number): string {\n const v = this.word(at);\n if (v >> 160n !== 0n) throw new Error(\"not an address\");\n return `0x${v.toString(16).padStart(40, \"0\")}`;\n }\n bool(at: number): boolean {\n const v = this.word(at);\n if (v > 1n) throw new Error(\"not a bool\");\n return v === 1n;\n }\n}\n\nconst same = (a: string, b: string) => a.toLowerCase() === b.toLowerCase();\n\n/** SwapData tuple at `at`: (callTo, approveTo, sendingAssetId, receivingAssetId, fromAmount, callData, requiresDeposit). */\nfunction swapAt(r: Reader, at: number): SwapStep {\n r.address(at); r.address(at + 32);\n const step = {sendingAssetId: r.address(at + 64), receivingAssetId: r.address(at + 96), fromAmount: r.word(at + 128), requiresDeposit: false};\n const bytesAt = at + r.small(at + 160);\n r.small(bytesAt); // length within the calldata\n // The Diamond pulls `fromAmount` of `sendingAssetId` from the user for every step that requires a deposit.\n step.requiresDeposit = r.bool(at + 192);\n return step;\n}\n\n/** SwapData[] whose offset word sits at `head`, relative to `base`. */\nfunction swapsAt(r: Reader, base: number, head: number): SwapStep[] {\n const array = base + r.small(head);\n const n = r.small(array);\n if (n === 0 || n > 16) throw new Error(\"bad swap count\");\n const items = array + 32;\n return Array.from({length: n}, (_, i) => swapAt(r, items + r.small(items + 32 * i)));\n}\n\n/**\n * Every step, not only the ends (scan 2026-10-27 modules, F21–F23): the Diamond pulls `fromAmount` from the user for\n * each step that requires a deposit, so only steps that spend the source token may, and together at most the input —\n * a middle step depositing DAI under a leftover allowance is refused. The steps chain: each spends what the one before\n * delivered (a fee step on the input sends and receives the same asset).\n */\nfunction checkSteps(steps: SwapStep[], e: DiamondExpectation, finalAsset: string): string | null {\n const first = steps[0]!;\n const last = steps[steps.length - 1]!;\n if (!same(first.sendingAssetId, e.fromToken)) return `spends ${first.sendingAssetId}, not ${e.fromToken}`;\n if (first.fromAmount === 0n || first.fromAmount > e.amountIn) return `swaps ${first.fromAmount}, not the ${e.amountIn} spent`;\n let deposited = 0n;\n for (let i = 0; i < steps.length; i++) {\n const step = steps[i]!;\n if (i > 0 && !same(step.sendingAssetId, steps[i - 1]!.receivingAssetId)) return `step ${i} spends ${step.sendingAssetId}, which step ${i - 1} does not deliver`;\n if (!step.requiresDeposit) continue;\n if (!same(step.sendingAssetId, e.fromToken)) return `step ${i} pulls ${step.sendingAssetId} from the wallet, not the input ${e.fromToken}`;\n deposited += step.fromAmount;\n }\n if (deposited > e.amountIn) return `the steps pull ${deposited} from the wallet, more than the ${e.amountIn} spent`;\n if (!same(last.receivingAssetId, finalAsset)) return `delivers ${last.receivingAssetId}, not ${finalAsset}`;\n return null;\n}\n\n/** A Mayan Swift order refunds its input to `trader` when it is not filled, a Wormhole swap to `refundAddr`: their byte\n * offset in `protocolData` (Mayan's swap-sdk, src/evm; selectors as the facet lists them). MCTP and FastMCTP orders and\n * the HyperCore deposits carry no refund address: what they do not deliver settles to the destination address the facet\n * already checks against BridgeData.receiver. */\nconst MAYAN_REFUND_AT: Readonly<Record<string, number>> = {\n \"0xa3a30834\": 4 + 32 * 3, // Swift v2 createOrderWithToken(tokenIn, amountIn, (payloadType, trader, destAddr, …), customPayload)\n \"0x6147435b\": 4 + 32 * 3, // Swift v2 createOrderWithSig: the same order tuple\n \"0xb866e173\": 4, // Swift createOrderWithEth((trader, tokenOut, …))\n \"0x8e8d142b\": 4 + 32 * 2, // Swift createOrderWithToken(tokenIn, amountIn, (trader, tokenOut, …))\n \"0x6111ad25\": 4 + 32 * 9, // MayanSwap swap(relayerFees, (mayanAddr, mayanChainId, auctionAddr, destAddr, destChainId, referrer, refundAddr), …)\n \"0x1eb1cff0\": 4 + 32 * 9, // MayanSwap wrapAndSwapETH: the same recipient tuple\n};\nfunction mayanRefunds(r: Reader, at: number): Refund[] {\n const p = r.bytes(at, at + 32 * 2);\n const pos = MAYAN_REFUND_AT[p.raw(0, 4)];\n return pos === undefined ? [] : [[\"the Mayan order's refund address\", p.address(pos)]];\n}\n/** Chainflip refunds the whole input to the address in `cfParameters` when the swap misses its minimum price:\n * VersionedCfParameters V1 (SCALE) — version, retry duration (u32), then the refund address, 20 bytes from an EVM chain. */\nfunction chainflipRefunds(r: Reader, at: number): Refund[] {\n const p = r.bytes(at, at + 32 * 5);\n if (p.length < 25 || p.raw(0, 1) !== \"0x01\") throw new Error(\"unknown Chainflip parameters\");\n return [[\"the Chainflip refund address\", p.raw(5, 20)]];\n}\n/** The Across Swap API call, by target: the SpokePool deposit's depositor (DepositParams, depositor first) and the\n * periphery's `depositData.depositor` get an expired deposit back (and the periphery's positive slippage); the\n * sponsored OFT and CCTP flows refund to an unsigned `refundRecipient`. */\nfunction acrossSwapRefunds(r: Reader, at: number): Refund[] {\n const target = r.word(at);\n const c = r.bytes(at, at + 32);\n // The facet refuses a zero depositor / refundRecipient on every target.\n if (target === 0n) return [[\"the Across deposit's depositor\", c.address(c.small(0)), true]];\n if (target === 1n) {\n const swap = c.small(0); // SwapAndDepositData: (submissionFees.amount, submissionFees.recipient, depositData, …)\n return [[\"the Across deposit's depositor\", c.address(swap + c.small(swap + 64) + 96), true]]; // BaseDepositData word 3\n }\n if (target === 2n) return [[\"the sponsored OFT refund recipient\", c.address(c.small(0) + 32), true]]; // (Quote(signed, unsigned), signature)\n if (target === 3n) return [[\"the sponsored CCTP refund recipient\", c.address(64), true]]; // (quote, signature, refundRecipient)\n throw new Error(\"unknown Across Swap API target\");\n}\n\n/** The EVM native-token placeholder (the zero address) in the quote's destination token. */\n/** ERC-20 `transfer(address,uint256)`. */\nconst ERC20_TRANSFER = \"0xa9059cbb\";\n/**\n * Eco v3 (EcoFacet 3.0.0, lifinance/contracts 9001792): EcoData is (nonEVMReceiver, prover, rewardDeadline,\n * intentDestination, encodedRoute, solanaATA, refundRecipient, deadline, signature), a dynamic struct. v2 decoded the\n * route on chain and required its final `transfer` to pay BridgeData.receiver; v3 dropped that check (\"for EVM\n * destinations the receiver is therefore enforced only by the backend signature, not on-chain\") and lets the route\n * run on another chain than the destination (`intentDestination`: the source chain for a CCTP burn, HyperEVM for a\n * HyperCore deposit, a second intent), with calls the facet does not interpret. So the device checks what v2 did, and\n * more: the intent runs on the destination chain itself, and the route — abi.encode(Route(salt, deadline, portal,\n * nativeAmount, tokens, calls)), Call = (target, data, value) — ends in the destination token's `transfer` of at least\n * the reviewed minimum to the recipient. Whatever runs before it, the solver's fill either pays that or does not\n * happen, and the reward (the input) then goes back to refundRecipient, checked above.\n */\nfunction ecoDelivery(r: Reader, at: number, e: DiamondExpectation): string | null {\n // A native delivery has no token `transfer` to read (it would be a value call to the recipient), so it is refused\n // outright — not left to the token comparison below, where a `transfer` \"of\" the zero address would match.\n if (kindOf(e.toToken) === \"native\") return \"an Eco route to the native token cannot be checked here\";\n const destination = r.word(at + 32 * 3);\n if (destination !== e.destChainId) return `the Eco intent executes on chain ${destination}, not the destination ${e.destChainId} — a route whose delivery cannot be checked here`;\n const route = r.bytes(at, at + 32 * 4);\n const tuple = route.small(0);\n const calls = tuple + route.small(tuple + 32 * 5);\n const n = route.small(calls);\n if (n === 0) return \"the Eco route makes no calls on the destination chain\";\n if (n > 16) return `the Eco route makes ${n} calls on the destination chain, more than the 16 read here`;\n const last = calls + 32 + route.small(calls + 32 + 32 * (n - 1));\n const target = route.address(last);\n const data = route.bytes(last, last + 32);\n if (route.word(last + 64) !== 0n || data.length !== 68 || data.raw(0, 4) !== ERC20_TRANSFER) return \"the Eco route does not end in a token transfer\";\n const to = data.address(4);\n const amount = data.word(36);\n if (!same(target, e.toToken)) return `the Eco route delivers ${target}, not ${e.toToken}`;\n if (!same(to, e.receiver)) return `the Eco route pays ${to}, not ${e.receiver}`;\n if (amount < e.minOut) return `the Eco route delivers ${amount}, below the ${e.minOut} shown`;\n return null;\n}\n/**\n * M0 (M0Facet 1.0.0): an order on the M0 OrderBook asks a solver for `amountOut` of `tokenOut` on the destination\n * (M0Data words 3 and 5); the facet ties only the receiver to BridgeData. Both must be the quote's: the destination\n * token, and at least the reviewed minimum. On the swap entry point the facet scales amountOut by the swap's realised\n * output over the quoted input (never below 1×), so the calldata's value is a lower bound there too. amountOut is a\n * limit rate, not a fill guarantee: a partial fill delivers its share and refunds the rest to orderOwner (the sender).\n */\nfunction m0Delivery(r: Reader, at: number, e: DiamondExpectation): string | null {\n // M0Facet refuses a zero tokenOut (the OrderBook would escrow the input with nothing to fill): no native delivery.\n if (kindOf(e.toToken) === \"native\") return \"an M0 order cannot deliver the native token\";\n const tokenOut = r.address(at + 32 * 3);\n const amountOut = r.word(at + 32 * 5);\n if (!same(tokenOut, e.toToken)) return `the M0 order asks for ${tokenOut}, not ${e.toToken}`;\n if (amountOut < e.minOut) return `the M0 order asks for ${amountOut}, below the ${e.minOut} shown`;\n return null;\n}\n\n/**\n * Where a bridge facet's data names who gets money back: an unused native fee, swap leftovers or positive slippage, the\n * whole input when a deposit, intent or order expires unfilled, or a fallback when delivery fails. The facets only\n * require these to be non-zero (NEAR Intents, LayerSwap and Eco also sign them on LI.FI's backend, which an `apiUrl`\n * proxy cannot forge but LI.FI's API itself writes), so each must be the sender or the recipient; LI.FI's live quotes\n * set them to the sender. `refunds` are [field, word] in the facet data (lifinance/contracts, the same structs at\n * 86c3729 and on main 2026-11-02; Eco as at v3.0.0, 9001792, whose entry points are the listed ones); `inline` marks a static\n * struct, which is encoded in place among the arguments rather than behind an offset (its word count). A zero is\n * accepted where the facet itself refuses a zero in every field it uses (`zeroRefused`; Polymer CCTP reads its\n * refundRecipient on the swap entry point only): it pays no one. Stargate passes a zero to LayerZero, and Mayan and\n * Chainflip carry theirs into the protocol, so there a zero is refused like any other address.\n */\ninterface FacetData {\n inline?: number;\n refunds?: readonly (readonly [string, number])[];\n zeroRefused?: true;\n nested?: (r: Reader, at: number) => Refund[];\n /** What the facet data says the destination receives, held to the quote: a reason it does not match, or null. */\n delivery?: (r: Reader, at: number, e: DiamondExpectation) => string | null;\n}\n/** [what, address, a zero there is refused by the facet]. */\ntype Refund = [string, string, boolean?];\nconst FACET_DATA: Readonly<Record<string, FacetData>> = {\n AcrossV4: {refunds: [[\"refundAddress\", 1]], zeroRefused: true}, // the SpokePool depositor: an expired deposit refunds the input there\n AcrossV4Swap: {nested: acrossSwapRefunds},\n Centrifuge: {inline: 2, refunds: [[\"refundRecipient\", 1]], zeroRefused: true},\n Chainflip: {nested: chainflipRefunds},\n Eco: {refunds: [[\"refundRecipient\", 6]], zeroRefused: true, delivery: ecoDelivery}, // the intent's creator, refunded its reward (the input) on expiry\n Frax: {inline: 5, refunds: [[\"refundRecipient\", 3]], zeroRefused: true},\n Glacis: {inline: 4, refunds: [[\"refundAddress\", 1]], zeroRefused: true},\n LayerSwap: {refunds: [[\"refundRecipient\", 2]], zeroRefused: true},\n LiFiIntentEscrowV2: {refunds: [[\"depositAndRefundAddress\", 2]], zeroRefused: true}, // the escrow order's user\n M0: {inline: 7, refunds: [[\"refundRecipient\", 1], [\"orderOwner\", 2]], zeroRefused: true, delivery: m0Delivery}, // orderOwner gets a cancelled order back\n Mayan: {refunds: [[\"refundRecipient\", 7]], nested: mayanRefunds, zeroRefused: true},\n NEARIntents: {refunds: [[\"refundRecipient\", 6]], zeroRefused: true}, // also the 1Click quote's refundTo\n PolymerCCTP: {refunds: [[\"refundRecipient\", 5]], zeroRefused: true},\n Stargate: {refunds: [[\"refundAddress\", 4]]}, // (assetId, sendParams, fee.nativeFee, fee.lzTokenFee, refundAddress): LayerZero's fee refund\n Superset: {refunds: [[\"refundAddress\", 2], [\"fallbackEoA\", 3]], zeroRefused: true},\n};\n/**\n * Facets whose data names no one to pay back: Across (the SpokePool's depositor is the Diamond), AllBridge, Celer\n * Circle, GasZip, MegaETH and Optimism (no address but the receiver the facet checks), Arbitrum (its retryable's\n * refunds go to BridgeData.receiver), Gnosis, Omni and Polygon (no facet data) and Unit (its own deposit address,\n * signed). Their excess native and swap leftovers go to the caller.\n */\nconst NO_REFUND_FIELDS = new Set([\"Across\", \"AllBridge\", \"ArbitrumBridge\", \"CelerCircleBridge\", \"GasZip\", \"GnosisBridge\", \"MegaETHBridge\", \"OmniBridge\", \"OptimismBridge\", \"PolygonBridge\", \"Unit\"]);\n\n/** Where the facet data starts: the last argument, after BridgeData's offset word (and the SwapData[]'s). */\nfunction facetDataAt(r: Reader, bridge: {sourceSwaps: boolean}, spec: FacetData): number {\n const slot = 4 + (bridge.sourceSwaps ? 64 : 32);\n return spec.inline ? slot : 4 + r.small(slot);\n}\n\n/** A refund or fallback in the bridge's facet data that pays neither the sender nor the recipient, or null. */\nfunction refundMismatch(r: Reader, bridge: {sourceSwaps: boolean; facet: string}, e: DiamondExpectation): string | null {\n const spec = FACET_DATA[bridge.facet];\n if (!spec) return NO_REFUND_FIELDS.has(bridge.facet) ? null : `no known refund layout for ${bridge.facet}`;\n const at = facetDataAt(r, bridge, spec);\n const paid: Refund[] = (spec.refunds ?? []).map(([field, word]) => [`${bridge.facet} ${field}`, r.address(at + 32 * word), spec.zeroRefused === true]);\n paid.push(...(spec.nested?.(r, at) ?? []));\n for (const [what, to, zeroRefused] of paid) {\n if (zeroRefused && /^0x0{40}$/.test(to)) continue;\n if (!same(to, e.sender) && !same(to, e.receiver)) return `${what} pays ${to}, neither the sender ${e.sender} nor the recipient`;\n }\n return null;\n}\n\n/** Why the Diamond calldata does not do what the quote says, or null when it does. */\nexport function diamondCallMismatch(data: string, e: DiamondExpectation): string | null {\n let r: Reader;\n try { r = new Reader(data); } catch { return \"the calldata is not hex\"; }\n if (r.length < 4 + 32 * 2) return \"the calldata is too short\";\n const selector = data.slice(0, 10).toLowerCase();\n const generic = GENERIC_SWAPS[selector];\n try {\n if (generic) {\n if (!e.sameChain) return \"a same-chain swap call on a cross-chain route\";\n // (bytes32 txId, string integrator, string referrer, address receiver, uint256 minAmount, SwapData | SwapData[])\n const receiver = r.address(4 + 96);\n const minAmount = r.word(4 + 128);\n const steps = generic.single ? [swapAt(r, 4 + r.small(4 + 160))] : swapsAt(r, 4, 4 + 160);\n if (!e.evmDestination || !same(receiver, e.receiver)) return `pays ${receiver}, not ${e.receiver}`;\n if (minAmount < e.minOut) return `accepts ${minAmount}, below the ${e.minOut} shown`;\n if (generic.from && kindOf(e.fromToken) !== generic.from) return `${selector} swaps from ${generic.from === \"native\" ? \"the native coin\" : \"a token\"}, but the input is ${kindOf(e.fromToken) === \"native\" ? \"the native coin\" : \"a token\"}`;\n if (generic.to && (kindOf(e.toToken) !== generic.to || kindOf(steps[steps.length - 1]!.receivingAssetId) !== generic.to)) {\n return `${selector} delivers ${generic.to === \"native\" ? \"the native coin\" : \"a token\"}, but the output is ${kindOf(e.toToken) === \"native\" ? \"the native coin\" : \"a token\"} — its minimum would be counted in the wrong asset`;\n }\n return checkSteps(steps, e, e.toToken);\n }\n // Bridge facets: (BridgeData, [SwapData[],] FacetData), only the listed ABI entry points.\n // BridgeData is dynamic (it holds strings), so its offset is the head size.\n const unbound = UNBOUND_BRIDGES[selector];\n if (unbound) return `${unbound} delivers to a recipient the transaction does not bind (an off-chain order or unchecked facet data)`;\n const bridge = BRIDGE_CALLS[selector];\n if (!bridge) return `unknown Diamond call ${selector}`;\n const head = r.small(4);\n if (head < (bridge.sourceSwaps ? 96 : 64) || head % 32 !== 0 || head > 32 * 32) return `unknown Diamond call ${selector}`;\n const at = 4 + head;\n // BridgeData: (txId, string bridge, string integrator, referrer, sendingAssetId, receiver, minAmount, destinationChainId, hasSourceSwaps, hasDestinationCall)\n if (r.small(at + 32) !== 320) return `unknown Diamond call ${selector}`;\n const sendingAssetId = r.address(at + 128);\n const receiver = r.address(at + 160);\n const minAmount = r.word(at + 192);\n const destinationChainId = r.word(at + 224);\n const hasSourceSwaps = r.bool(at + 256);\n const hasDestinationCall = r.bool(at + 288);\n if (e.sameChain) return \"a bridge call on a same-chain route\";\n if (destinationChainId !== e.destChainId) return `bridges to chain ${destinationChainId}, not ${e.destChainId}`;\n if (hasDestinationCall) return \"the route runs a call on the destination chain, whose recipient cannot be checked here\";\n if (!e.evmDestination) return \"the recipient on a non-EVM destination sits in bridge-specific data and cannot be checked here\";\n if (!same(receiver, e.receiver)) return `pays ${receiver}, not ${e.receiver}`;\n if (hasSourceSwaps !== bridge.sourceSwaps) return `unknown Diamond call ${selector}`;\n const refund = refundMismatch(r, bridge, e);\n if (refund) return refund;\n const spec = FACET_DATA[bridge.facet];\n const delivery = spec?.delivery?.(r, facetDataAt(r, bridge, spec), e);\n if (delivery) return delivery;\n // After source swaps the bridged amount is in the swapped token's units: only the swaps' input is comparable.\n if (hasSourceSwaps) {\n // The swapped amount is the facet's own (it replaces minAmount after the swaps); a zero is a route that bridges nothing.\n if (minAmount === 0n) return \"bridges nothing after the source swaps\";\n return checkSteps(swapsAt(r, 4, 4 + 32), e, sendingAssetId);\n }\n // Without source swaps the Diamond pulls minAmount: the input, or the input less a bridge's own fee (Glacis takes\n // 0.25 %, matrix v7). Anything further below leaves the rest of the allowance behind for the next call to take\n // (scan 2026-10-27 modules, F22): a minAmount of 1 is refused.\n if (minAmount > e.amountIn || minAmount * 10_000n < e.amountIn * (10_000n - BRIDGE_INPUT_FEE_MAX_BPS)) return `bridges ${minAmount}, not the ${e.amountIn} spent`;\n return same(sendingAssetId, e.fromToken) ? null : `bridges ${sendingAssetId}, not ${e.fromToken}`;\n } catch (err) {\n return `the Diamond calldata does not decode (${err instanceof Error ? err.message : String(err)})`;\n }\n}\n","/**\n * A first look at LI.FI's Solana bridge transaction, from its bytes alone (no RPC: accounts loaded from lookup tables\n * stay unknown). It must be paid by the sender. A Mayan route (it calls Mayan's CPI proxy or an order program) must\n * also pay SOL directly to no wallet other than the sender or LI.FI's fee wallet: the account's guard proves its order\n * pays the reviewed recipient (`bridgeOut`). LI.FI's other Solana bridges (Relay, LayerSwap, NEAR Intents, LI.FI\n * Intents, …) deposit to an address, an order id or a program whose recipient lives off chain or in data the device\n * does not read; they pass here as they are and are held by the account to its SOL and token ceilings only.\n */\n\nimport {base64Bytes} from \"@anywalletkit/protocol-swap2-core/util\";\n\nconst ALPHABET = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n/** Mayan's CPI proxy and order programs (swap-sdk `src/addresses.ts`). */\nconst MAYAN_ENTRY_PROGRAMS = new Set([\n \"D8C8iW6zmoKg5TRr8nQ7h14TMWqQX8FiBdj2ju5MF3wa\", // CPI_PROXY_PROGRAM_ID\n \"BLZRi6frs4X4DNLw56V4EXai1b6QVESN1BhHBTYM9VcY\", // SWIFT_PROGRAM_ID\n \"mayan34VedncxdK2XobtvWFDXQASUTBXhUVzt2kKgny\", // SWIFT_V2_PROGRAM_ID\n \"dkpZqrxHFrhziEMQ931GLtfy11nFkCsfMftH9u6QwBU\", // MCTP_PROGRAM_ID\n \"Gx9rivpS3YR8pBFwMuP6omYqVxunpLvLkNn7ubNyuZZ5\", // FAST_MCTP_PROGRAM_ID\n]);\nconst SYSTEM_PROGRAM = \"11111111111111111111111111111111\";\n/** LI.FI's fee wallet on Solana (its `feeCollection` step pays SOL here, tokens to its token accounts). */\nexport const LIFI_SOLANA_FEE_WALLET = \"34FKjAdVcTax2DHqV2XnbXa9J3zmyKcFuFKWbcmgxjgm\";\n\nfunction base58(bytes: Uint8Array): string {\n let n = 0n;\n for (const b of bytes) n = (n << 8n) | BigInt(b);\n let out = \"\";\n while (n > 0n) { out = ALPHABET[Number(n % 58n)]! + out; n /= 58n; }\n for (const b of bytes) { if (b !== 0) break; out = `1${out}`; }\n return out;\n}\n\nclass Cursor {\n at = 0;\n constructor(private readonly b: Uint8Array) {}\n byte(): number {\n if (this.at >= this.b.length) throw new Error(\"truncated\");\n return this.b[this.at++]!;\n }\n bytes(n: number): Uint8Array {\n if (n < 0 || this.at + n > this.b.length) throw new Error(\"truncated\");\n const out = this.b.subarray(this.at, this.at + n);\n this.at += n;\n return out;\n }\n /** compact-u16 */\n short(): number {\n let v = 0;\n for (let shift = 0; shift < 21; shift += 7) {\n const b = this.byte();\n v |= (b & 0x7f) << shift;\n if (!(b & 0x80)) return v;\n }\n throw new Error(\"bad length\");\n }\n}\n\n/** Why the transaction is visibly wrong for `sender` (see the module note), or null when its static part is consistent with a bridge. */\nexport function solanaBridgeTxMismatch(base64: string, sender: string): string | null {\n const bytes = base64Bytes(base64);\n if (!bytes) return \"the Solana transaction is not base64\";\n const c = new Cursor(bytes);\n try {\n c.bytes(64 * c.short()); // signatures\n const first = c.byte();\n if ((first & 0x80) === 0) c.at--; // legacy message: no version prefix\n c.bytes(3); // header\n const keys = Array.from({length: c.short()}, () => base58(c.bytes(32)));\n if (keys[0] !== sender) return `the Solana transaction is paid by ${keys[0] ?? \"nobody\"}, not the sender ${sender}`;\n c.bytes(32); // recent blockhash\n let mayan = false;\n const payees: string[] = [];\n const n = c.short();\n for (let i = 0; i < n; i++) {\n const program = keys[c.byte()];\n const accounts = Array.from(c.bytes(c.short()));\n const data = c.bytes(c.short());\n if (program !== undefined && MAYAN_ENTRY_PROGRAMS.has(program)) mayan = true;\n // System Transfer: u32 tag 2, u64 lamports; [from, to]. A destination in a lookup table is left to the account.\n if (program === SYSTEM_PROGRAM && data.length === 12 && data[0] === 2 && data[1] === 0 && data[2] === 0 && data[3] === 0) {\n const to = keys[accounts[1] ?? -1];\n if (to !== undefined && to !== sender && to !== LIFI_SOLANA_FEE_WALLET) payees.push(to);\n }\n }\n // A deposit to an address is how the other bridges are paid; a Mayan route moves its funds through its order.\n return mayan && payees.length ? `the Solana transaction transfers SOL to ${payees[0]}, which is neither the sender nor LI.FI's fee wallet` : null;\n } catch (err) {\n return `the Solana transaction does not decode (${err instanceof Error ? err.message : String(err)})`;\n }\n}\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {LIFI_SOLANA_CAIP2, lifi as lifiCfg} from \"./config.js\";\nimport {describeLifiActivity} from \"./activity.js\";\nimport {diamondCallMismatch} from \"./calldata.js\";\nimport {solanaBridgeTxMismatch} from \"./solana.js\";\nimport {timeoutSignal, sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {slippageFloor} from \"@anywalletkit/protocol-swap2-core/validate\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * LI.FI meta-aggregator — the CALLDATA execution model: the quote returns a\n * `transactionRequest` the USER'S WALLET must execute. There is no deposit\n * address — a plain transfer to `transactionRequest.to` would lose funds, so\n * the client branches on `quote.txRequest`. Live-verified shapes (2026-07):\n * EVM → {to, data, value, chainId, gasLimit}; Solana → {data: base64 tx}, a\n * fully built v0 transaction (Jupiter route) the account signs after proving\n * its balance effects (`serializedTx`). Tron returns a raw protobuf we can't\n * hand to wallets yet — Tron stays on the direct NEAR Intents route (LI.FI\n * routes it through NEAR anyway, so nothing is lost).\n */\n\nconst DEFAULT_LIFI_BASE = \"https://li.quest/v1\";\n\n/** Our CAIP-2 → LI.FI chain ids. */\nconst LIFI_CHAIN: Record<string, string> = {\n \"eip155:1\": \"1\",\n \"eip155:8453\": \"8453\",\n \"eip155:56\": \"56\",\n \"eip155:137\": \"137\",\n \"eip155:42161\": \"42161\",\n \"eip155:10\": \"10\",\n \"eip155:100\": \"100\",\n \"eip155:143\": \"143\",\n \"eip155:130\": \"130\",\n \"eip155:999\": \"999\",\n \"eip155:4663\": \"4663\",\n // 2026-08 sweep additions (all live on li.quest/v1/chains).\n \"eip155:43114\": \"43114\",\n \"eip155:534352\": \"534352\",\n \"eip155:80094\": \"80094\",\n // 2026-10-12: zkSync Era, Celo, MegaETH (live on li.quest/v1/chains).\n \"eip155:324\": \"324\",\n \"eip155:42220\": \"42220\",\n \"eip155:4326\": \"4326\",\n \"eip155:9745\": \"9745\",\n \"eip155:59144\": \"59144\",\n \"eip155:146\": \"146\",\n // 2026-10-13: World Chain, Sei, Ink, Plume, X Layer (live on li.quest/v1/chains).\n \"eip155:480\": \"480\",\n \"eip155:1329\": \"1329\",\n \"eip155:57073\": \"57073\",\n \"eip155:98866\": \"98866\",\n \"eip155:196\": \"196\",\n // 2026-10-14: Arc, Mantle, Katana, Morph, Flare (live on li.quest/v1/chains). On Arc LI.FI's \"native\" is the USDC\n // ERC-20 interface 0x3600…: a 0x0 fromToken is rewritten to it and the Diamond pulls via transferFrom (value 0), so\n // the catalog lists Arc USDC as that token — the engine then runs the ordinary approve + call path.\n \"eip155:5042\": \"5042\",\n \"eip155:5000\": \"5000\",\n \"eip155:747474\": \"747474\",\n \"eip155:2818\": \"2818\",\n \"eip155:14\": \"14\",\n // 2026-11-10: Elysium (Kinetiq; li.quest/v1/chains id 99901, key \"ely\"). LI.FI's bridges there are Relay (refused\n // below: UNBOUND_TOOLS) and LI.FI Intents; same-chain swaps go through GenericSwapFacetV3 (KyberSwap, Nordstern).\n \"eip155:99901\": \"99901\",\n [LIFI_SOLANA_CAIP2]: \"1151111081099710\",\n};\nconst CAIP2_BY_LIFI_CHAIN: Record<string, string> = Object.fromEntries(Object.entries(LIFI_CHAIN).map(([caip2, id]) => [id, caip2]));\n\nconst EVM_ZERO = \"0x0000000000000000000000000000000000000000\";\n/** LI.FI's native-SOL token id (the System program address). */\nconst SOLANA_NATIVE = \"11111111111111111111111111111111\";\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\n/** Dry-quote sender on Solana: the publicly known BIP-39 \"abandon\" account 0. */\nconst SOLANA_PLACEHOLDER = \"HAgk14JpMQLgt6rVgv7cBQFJWFto5Dqxi472uT3DKpqk\";\nconst isSolana = (chain: string) => chain === LIFI_SOLANA_CAIP2;\nconst BASE58 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\nconst BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;\n/** Chain-aware address equality: EVM case-insensitive, Solana exact base58. */\n/** Longest execution a same-chain route may claim and still be an atomic swap (DEX routes report 0–30 s). */\nconst SAME_CHAIN_MAX_SECONDS = 90;\n/** Largest fee a bridge may take from the input itself (glacis ≈ 0.25 %, 2026-10). Above it the quote is refused, named. */\nconst MAX_INPUT_FEE_BPS = 300;\n\nfunction sameChainAddress(chain: string, actual: string | undefined, expected: string): boolean {\n if (isSolana(chain)) return !!actual && BASE58.test(actual) && actual === expected;\n return sameAddress(actual, expected);\n}\n/** The engine's native sentinel (`0x0…`) in the chain's own notation. */\nfunction nativeFor(chain: string, token: string): string {\n if (/^0x0+$/.test(token) || token === SOLANA_NATIVE) return isSolana(chain) ? SOLANA_NATIVE : EVM_ZERO;\n return token;\n}\n/** LI.FI's documented Diamond entry point on most supported EVM networks. */\nconst LIFI_DIAMOND = \"0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE\";\n/**\n * Chains where the Diamond lives at a different address — from\n * github.com/lifinance/contracts `deployments/<chain>.json` (`LiFiDiamond`).\n * On these chains ONLY that address is the entry point; the canonical one is\n * not deployed there and is therefore not trusted.\n */\nconst LIFI_DIAMONDS: Readonly<Record<string, string>> = {\n \"eip155:4663\": \"0xB477751B76CF82d00a686A1232f5fCD772414Af3\", // Robinhood Chain (deployments/robinhood.json, verified 2026-10-09)\n \"eip155:999\": \"0x0a0758d937d1059c356D4714e57F5df0239bce1A\", // HyperEVM (deployments/hyperevm.json, verified 2026-10-09)\n \"eip155:143\": \"0x026F252016A7C47CDEf1F05a3Fc9E20C92a49C37\", // Monad (deployments/monad.json, verified 2026-10-11)\n \"eip155:130\": \"0x864b314D4C5a0399368609581d3E8933a63b9232\", // Unichain (deployments/unichain.json, verified 2026-10-11)\n \"eip155:80094\": \"0xf909c4Ae16622898b885B89d7F839E0244851c66\", // Berachain (deployments/berachain.json, verified 2026-10-11)\n \"eip155:324\": \"0x341e94069f53234fE6DabeF707aD424830525715\", // zkSync Era (deployments/zksync.json, matches a live quote 2026-10-12)\n \"eip155:9745\": \"0x026F252016A7C47CDEf1F05a3Fc9E20C92a49C37\", // Plasma (deployments/plasma.json, 2026-10-13)\n \"eip155:59144\": \"0xDE1E598b81620773454588B85D6b5D4eEC32573e\", // Linea (deployments/linea.json, 2026-10-13)\n \"eip155:57073\": \"0x864b314D4C5a0399368609581d3E8933a63b9232\", // Ink (deployments/ink.json, 2026-10-13)\n \"eip155:98866\": \"0x6f5C8Bb0C5Fe4ECeAC40EE1C238EaB6bbb29761c\", // Plume (deployments/plume.json, 2026-10-13)\n // 2026-10-14: li.quest/v1/chains `diamondAddress`, eth_getCode non-empty on each. Mantle and Flare carry the canonical\n // 0x1231… Diamond (the default).\n \"eip155:5042\": \"0xA4072583658Fae592A3506A42431cb6316a8d40b\", // Arc\n \"eip155:747474\": \"0xC59fe32C9549e3E8B5dCcdAbC45BD287Bd5bA2bc\", // Katana\n \"eip155:2818\": \"0xF7aB42D00D2399f8A4Fba2F15466Be40709fe307\", // Morph\n \"eip155:14\": \"0x198FC70Dfe05E755C81e54bd67Bff3F729344B9b\", // Flare (li.quest diamondAddress 2026-10-14; the canonical 0x1231… has no code there)\n // Elysium: li.quest diamondAddress = deployments/elysium.json LiFiDiamond; code on 99901, DiamondLoupe facets() serves\n // GenericSwapFacetV3 + LiFiIntentEscrowFacetV2; the canonical 0x1231… has no code there (all read 2026-11-10).\n \"eip155:99901\": \"0x24E6dA91AA4A8FEe2447F542c92E006243bd6Dc5\", // Elysium\n \"eip155:4326\": \"0x026F252016A7C47CDEf1F05a3Fc9E20C92a49C37\", // MegaETH (deployments/megaeth.json, matches a live quote 2026-10-12)\n};\nconst diamondFor = (chain: string): string => LIFI_DIAMONDS[chain] ?? LIFI_DIAMOND;\nconst DEFAULT_QUOTE_TTL_MS = 55_000;\n\nfunction normalizeAddress(value: string | undefined): string | null {\n return value && /^0x[0-9a-fA-F]{40}$/.test(value) ? value.toLowerCase() : null;\n}\n\nfunction sameAddress(actual: string | undefined, expected: string): boolean {\n return normalizeAddress(actual) === normalizeAddress(expected);\n}\n\nfunction isHexData(value: string | undefined): value is string {\n return !!value && /^0x(?:[0-9a-fA-F]{2})+$/.test(value);\n}\n\nfunction trustedAddress(\n chain: string,\n address: string | undefined,\n configured: ReadonlyMap<string, ReadonlySet<string>>,\n): boolean {\n const normalized = normalizeAddress(address);\n if (!normalized) return false;\n return normalizeAddress(diamondFor(chain)) === normalized || configured.get(chain)?.has(normalized) === true;\n}\n\nfunction trustMap(input: Readonly<Record<string, readonly string[]>> | undefined, label: string): ReadonlyMap<string, ReadonlySet<string>> {\n const out = new Map<string, ReadonlySet<string>>();\n for (const [chain, addresses] of Object.entries(input ?? {})) {\n const normalized = new Set<string>();\n for (const address of addresses) {\n const value = normalizeAddress(address);\n if (!value) throw new Error(`lifi: invalid ${label} address for ${chain}`);\n normalized.add(value);\n }\n out.set(chain, normalized);\n }\n return out;\n}\n\n/** LI.FI token id on the source chain: contract, or the chain's native id. */\nfunction lifiToken(params: Pick<QuoteParams, \"sourceChain\" | \"sourceToken\" | \"sourceDecimals\">): string | null {\n const sourceChain = params.sourceChain;\n const asset = sourceAssetOf(params);\n if (!asset) return null;\n if (asset.contract) return asset.contract;\n return isSolana(sourceChain) ? SOLANA_NATIVE : EVM_ZERO;\n}\n\nfunction headers(key: string | undefined): Record<string, string> {\n const h: Record<string, string> = {accept: \"application/json\"};\n if (key) h[\"x-lifi-api-key\"] = key;\n return h;\n}\n\n/** Explicit constructor configuration; no deployment environment is read. */\nexport interface LifiProviderConfig {\n enabled?: boolean;\n /** LI.FI REST base URL. Explicitly injectable for proxies and tests; must be https unless `allowInsecureApiUrl`. */\n apiUrl?: string;\n /**\n * Allow an `http:` `apiUrl` (local development only): the quotes and the Diamond calldata travel it, and over plain\n * http anyone on the path rewrites them (scan 2026-10-27 modules, F20).\n */\n allowInsecureApiUrl?: boolean;\n apiKey?: string;\n integrator?: string;\n /** Additional audited LI.FI entry points for networks whose Diamond differs. */\n trustedTransactionTargets?: Readonly<Record<string, readonly string[]>>;\n /** Additional audited ERC-20 spenders returned by LI.FI for direct routes. */\n trustedApprovalAddresses?: Readonly<Record<string, readonly string[]>>;\n /** Fail-closed local lifetime for the provider's documented ~60s quote window. */\n quoteTtlMs?: number;\n /**\n * Slippage sent when the caller names none (bps, default 50 = LI.FI's own\n * documented default). Left unset, LI.FI picks it per request and it swings\n * (0.9%–6% within a minute on Base ETH → Robinhood, 2026-10-12): the display\n * quote's minimum then sits above the live one and the execution floor\n * refuses a route that hasn't moved.\n */\n defaultSlippageBps?: number;\n /**\n * Route policy hook. When set, a cross-chain quote first asks LI.FI's\n * `/advanced/routes` for the candidates, hands them to this function and\n * restricts `/quote` to what it returns (allowBridges / denyBridges /\n * order). Returning null/undefined, or any failure of the routes call,\n * leaves LI.FI's default pick. The policy itself (tie band, max ETA, deny\n * list) belongs to the app; the module only carries the choice.\n */\n chooseRoute?: (routes: readonly LifiRouteOption[], params: QuoteParams) => LifiRouteChoice | null | undefined;\n /**\n * Ask LI.FI for one slippage budget for the whole route (`slippageScope=route`) on EVM → EVM requests, instead of\n * its default of applying the slippage to every step. The minimum is then one floor, `ceil(expected × (1 −\n * slippage))`, that the transaction (and on Across, Mayan and Stargate V2 the bridge) enforces. Only EVM routes\n * with at most one swap and no destination call can be protected so; when LI.FI has none for a request it is asked\n * again in its default (per-step) scope, held to the same floor by the module's checks. Default off: Solana legs and\n * a disabled flag keep the per-step behaviour exactly as before.\n */\n routeWideSlippage?: boolean;\n}\n\n/** One single-transaction candidate from `/advanced/routes`, as a route policy sees it. */\nexport interface LifiRouteOption {\n /** LI.FI tool key of the bridge the route crosses with (e.g. \"stargateV2\"); a same-chain route carries its swap tool. */\n tool: string;\n toAmount: bigint;\n toAmountMin: bigint;\n /** LI.FI's execution-duration estimate, seconds. */\n etaSeconds: number;\n gasCostUsd: number;\n /** LI.FI's own labels: RECOMMENDED, CHEAPEST, FASTEST, … */\n tags: readonly string[];\n}\n\n/** What `/quote` is restricted to. LI.FI tool keys; an empty choice means LI.FI's default. */\nexport interface LifiRouteChoice {\n allowBridges?: readonly string[];\n denyBridges?: readonly string[];\n order?: \"CHEAPEST\" | \"FASTEST\";\n}\n\nconst TOOL_KEY = /^[A-Za-z0-9_-]{1,64}$/;\n/**\n * LI.FI tools whose Diamond entry point does not tie the delivery to the checked receiver (see `UNBOUND_BRIDGES` in\n * calldata.ts): every cross-chain request from an EVM chain asks LI.FI to route around them, so the pairs they would\n * have served get another bridge instead of a refusal. A Solana source has no Diamond call to check and is quoted\n * through every bridge LI.FI offers (Relay included); the account checks a Mayan order's recipient on the device, the\n * other Solana bridges only against its SOL and token ceilings.\n */\nconst UNBOUND_TOOLS: readonly string[] = Object.freeze([\"relaydepository\", \"garden\", \"squid\", \"symbiosis\"]);\nfunction routeOptions(body: unknown, excluded: readonly string[]): LifiRouteOption[] {\n const routes = (body as {routes?: unknown})?.routes;\n if (!Array.isArray(routes)) return [];\n const out: LifiRouteOption[] = [];\n for (const r of routes as {toAmount?: unknown; toAmountMin?: unknown; gasCostUSD?: unknown; containsSwitchChain?: unknown; tags?: unknown; steps?: {tool?: unknown; estimate?: {executionDuration?: unknown}; includedSteps?: {tool?: unknown; type?: unknown}[]}[]}[]) {\n // The engine executes one source transaction: multi-step routes are not candidates.\n if (!Array.isArray(r?.steps) || r.steps.length !== 1 || r.containsSwitchChain === true) continue;\n const step = r.steps[0]!;\n const cross = Array.isArray(step.includedSteps) ? step.includedSteps.find((i) => i?.type === \"cross\")?.tool : undefined;\n const tool = typeof cross === \"string\" ? cross : step.tool;\n const eta = step.estimate?.executionDuration;\n if (typeof tool !== \"string\" || !TOOL_KEY.test(tool) || excluded.includes(tool) || typeof eta !== \"number\" || !Number.isFinite(eta) || eta < 0) continue;\n if (typeof r.toAmount !== \"string\" || typeof r.toAmountMin !== \"string\" || !/^\\d{1,60}$/.test(r.toAmount) || !/^\\d{1,60}$/.test(r.toAmountMin)) continue;\n out.push({\n tool,\n toAmount: BigInt(r.toAmount),\n toAmountMin: BigInt(r.toAmountMin),\n etaSeconds: eta,\n gasCostUsd: Number(r.gasCostUSD ?? 0) || 0,\n tags: Array.isArray(r.tags) ? r.tags.filter((t): t is string => typeof t === \"string\") : [],\n });\n }\n return out;\n}\n\nfunction cleanChoice(choice: LifiRouteChoice | null | undefined): LifiRouteChoice | null {\n if (!choice) return null;\n const allow = (choice.allowBridges ?? []).filter((t) => TOOL_KEY.test(t));\n const deny = (choice.denyBridges ?? []).filter((t) => TOOL_KEY.test(t));\n const order = choice.order === \"CHEAPEST\" || choice.order === \"FASTEST\" ? choice.order : undefined;\n if (!allow.length && !deny.length && !order) return null;\n return {...(allow.length ? {allowBridges: allow} : {}), ...(deny.length ? {denyBridges: deny} : {}), ...(order ? {order} : {})};\n}\n\nexport function lifiProvider(config: LifiProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const apiKey = () => config.apiKey;\n const integrator = () => config.integrator ?? \"\";\n const parsedApiUrl = new URL(config.apiUrl ?? DEFAULT_LIFI_BASE);\n if (parsedApiUrl.protocol !== \"https:\" && !(parsedApiUrl.protocol === \"http:\" && config.allowInsecureApiUrl === true)) {\n throw new Error(\"lifi: apiUrl must use https (allowInsecureApiUrl for local development)\");\n }\n const apiBase = parsedApiUrl.toString().replace(/\\/$/, \"\");\n const trustedTransactionTargets = trustMap(config.trustedTransactionTargets, \"transaction target\");\n const trustedApprovalAddresses = trustMap(config.trustedApprovalAddresses, \"approval\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n const defaultSlippageBps = config.defaultSlippageBps ?? 50;\n if (!Number.isInteger(defaultSlippageBps) || defaultSlippageBps <= 0 || defaultSlippageBps >= 10_000) {\n throw new Error(\"lifi: defaultSlippageBps must be an integer between 1 and 9999\");\n }\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 60_000) {\n throw new Error(\"lifi: quoteTtlMs must be an integer between 1 and 60000\");\n }\n return {\n name: \"lifi\",\n describeActivity: (tx, ctx) => describeLifiActivity(tx, ctx, (chain, address) => trustedAddress(chain, address, trustedTransactionTargets)),\n supportsSameChain: true,\n enabled: () => config.enabled ?? true,\n\n // Capability discovery comes from the provider itself, so it can run alone\n // or inside the optional aggregator without a central capability table.\n supportsChain: (chain: string) => lifiCfg.supportsChain(chain),\n supportsChainPair: (fromChain: string, toChain: string) => lifiCfg.supports(fromChain, toChain),\n supportsRoute(from: Asset, to: Asset): boolean {\n // EVM only: LI.FI's Solana/Tron legs come back as provider-serialized\n // transactions, which the swap2 engine does not execute yet.\n return !!LIFI_CHAIN[from.chain] && !!LIFI_CHAIN[to.chain];\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n /** Every refusal after LI.FI answered is named — a bare null hides which check failed (matrix v7: 4 silent nulls). */\n const reject = (why: string): null => { params.onRefusal?.(`lifi: ${why}`); return null; };\n if (params.flex) return null; // calldata model — the amount is baked in\n const fromChain = LIFI_CHAIN[params.sourceChain];\n const toChain = LIFI_CHAIN[params.destChain];\n if (!fromChain || !toChain) return null;\n const fromToken = lifiToken(params);\n if (!fromToken) return null;\n\n const solanaSource = isSolana(params.sourceChain);\n const crossChain = params.sourceChain !== params.destChain;\n // The Diamond check refuses a destination call (its recipient sits in calldata for the other chain), so LI.FI is\n // asked not to offer one; the check stays as the backstop. A Solana source has no Diamond call to check.\n const noDestinationCall = crossChain && !solanaSource;\n // Route-wide slippage covers EVM routes only (LI.FI: not a route that starts or ends on a non-EVM chain).\n let routeScope = config.routeWideSlippage === true && !solanaSource && !isSolana(params.destChain);\n // The placeholders price a dry quote; a live one is built for real addresses only (round 3, H8).\n const dry = params.dry !== false;\n const fromAddress = params.refundAddress || (dry ? (solanaSource ? SOLANA_PLACEHOLDER : EVM_PLACEHOLDER) : \"\");\n const toAddress = params.destAddress || (dry ? fromAddress : \"\");\n if (!fromAddress) return reject(\"a live quote needs the sender's address\");\n if (!toAddress) return reject(\"a live quote needs a recipient\");\n\n // LI.FI applies `slippage` to EACH step of a multi-step route (bridge +\n // destination swap), so its minimum can sit ~2× the requested slippage\n // under the quote (seen 2026-10-10 on 479 of 4 000 matrix quotes), and\n // it truncates toAmountMin to a few significant digits. The engine\n // rejects a floor below the requested one, so the quote is asked once\n // more with the slippage scaled down to land the floor inside it.\n const slippageBps = params.slippageBps ?? defaultSlippageBps;\n let sentSlippage: number | undefined = slippageBps / 10_000;\n let deadline: AbortSignal | undefined;\n let choice: LifiRouteChoice | null = null;\n if (config.chooseRoute && crossChain) {\n try {\n const res = await fetch(`${apiBase}/advanced/routes`, {\n method: \"POST\",\n headers: {...headers(apiKey()), \"content-type\": \"application/json\"},\n body: JSON.stringify({\n fromChainId: Number(fromChain),\n toChainId: Number(toChain),\n fromTokenAddress: fromToken,\n toTokenAddress: nativeFor(params.destChain, params.destToken),\n fromAmount: params.amountIn,\n fromAddress,\n toAddress,\n options: {\n slippage: slippageBps / 10_000,\n ...(routeScope ? {slippageScope: \"route\"} : {}),\n ...(solanaSource ? {} : {bridges: {deny: UNBOUND_TOOLS}}),\n ...(noDestinationCall ? {allowDestinationCall: false} : {}),\n ...(integrator().trim() ? {integrator: integrator().trim()} : {}),\n },\n }),\n signal: signal ?? timeoutSignal(8_000),\n });\n if (res.ok) {\n const options = routeOptions(await res.json(), solanaSource ? [] : UNBOUND_TOOLS);\n if (options.length) choice = cleanChoice(config.chooseRoute(options, params));\n }\n } catch {\n // The policy is an optimisation: no candidates means LI.FI's default pick.\n }\n }\n for (let attempt = 0; attempt < 2; attempt++) try {\n const url = new URL(`${apiBase}/quote`);\n url.searchParams.set(\"fromChain\", fromChain);\n url.searchParams.set(\"toChain\", toChain);\n url.searchParams.set(\"fromToken\", fromToken);\n // Native dest is chain-notation-specific: EVM zero address vs the\n // Solana system program — sending the EVM zero to an SVM dest 400s.\n url.searchParams.set(\"toToken\", nativeFor(params.destChain, params.destToken));\n url.searchParams.set(\"fromAmount\", params.amountIn);\n url.searchParams.set(\"fromAddress\", fromAddress);\n url.searchParams.set(\"toAddress\", toAddress);\n const integratorId = integrator().trim();\n if (integratorId) url.searchParams.set(\"integrator\", integratorId);\n if (sentSlippage !== undefined) {\n url.searchParams.set(\"slippage\", String(sentSlippage));\n }\n if (routeScope) url.searchParams.set(\"slippageScope\", \"route\");\n if (noDestinationCall) url.searchParams.set(\"allowDestinationCall\", \"false\");\n const unbound = crossChain && !solanaSource ? UNBOUND_TOOLS : [];\n for (const t of (choice?.allowBridges ?? []).filter((b) => solanaSource || !UNBOUND_TOOLS.includes(b))) url.searchParams.append(\"allowBridges\", t);\n for (const t of new Set([...(choice?.denyBridges ?? []), ...unbound])) url.searchParams.append(\"denyBridges\", t);\n if (choice?.order) url.searchParams.set(\"order\", choice.order);\n deadline = signal ? undefined : timeoutSignal(12_000);\n const res = await fetch(url, {headers: headers(apiKey()), signal: signal ?? deadline!});\n if (!res.ok && choice) {\n // The chosen bridge went away between the two calls: LI.FI's default pick instead.\n choice = null;\n attempt--;\n continue;\n }\n if (!res.ok) {\n // LI.FI's 404 \"No available quotes for the requested transfer\" and\n // 400 validation messages are the caller's answer, not a silent null.\n const body = (await res.json().catch(() => null)) as {message?: unknown; errors?: {filteredOut?: {reason?: unknown}[]}} | null;\n // When every candidate route was dropped for the same reason (Sei: \"wallet is not linked to\n // the original SEI address\"), that reason is the real answer — the message alone is generic.\n const reasons = [...new Set((body?.errors?.filteredOut ?? []).map((f) => f.reason).filter((r): r is string => typeof r === \"string\"))];\n if (routeScope && [typeof body?.message === \"string\" ? body.message : \"\", ...reasons].some((r) => /^ROUTE_SLIPPAGE_(UNSUPPORTED|UNAVAILABLE)/.test(r))) {\n // No route LI.FI can protect route-wide (or the feature is off): its default per-step scope instead,\n // whose minimum the floor check below still holds to the requested slippage. Both reasons are LI.FI's\n // documented stable prefixes (docs.li.fi/api-reference/error-codes, \"Route-wide slippage errors\";\n // docs.li.fi/guides/route-wide-slippage#errors): ROUTE_SLIPPAGE_UNSUPPORTED in errors.filteredOut when no\n // route can be protected, ROUTE_SLIPPAGE_UNAVAILABLE (422, code 1004) in `message` when route-wide\n // slippage is switched off. This happens before any quote is shown: the user reviews the step-scope one.\n routeScope = false;\n attempt--;\n continue;\n }\n const why = reasons.length === 1 ? ` (${reasons[0]!.slice(0, 200)})` : \"\";\n params.onRefusal?.(`lifi: ${typeof body?.message === \"string\" ? body.message.slice(0, 200) : `HTTP ${res.status}`}${why}`);\n return null;\n }\n const q = (await res.json()) as {\n type?: string;\n id?: string;\n action?: {\n fromToken?: {address?: string; chainId?: number};\n toToken?: {address?: string; chainId?: number; decimals?: number};\n fromAmount?: string;\n fromChainId?: number;\n toChainId?: number;\n slippage?: number;\n fromAddress?: string;\n toAddress?: string;\n };\n estimate?: {\n fromAmount?: string;\n toAmount?: string;\n toAmountMin?: string;\n executionDuration?: number;\n approvalAddress?: string;\n feeCosts?: {amountUSD?: string}[];\n gasCosts?: {amountUSD?: string}[];\n };\n transactionRequest?: {\n to?: string;\n data?: string;\n value?: string;\n chainId?: number;\n gasLimit?: string;\n from?: string;\n };\n };\n const receivedAt = Date.now();\n const action = q.action;\n const est = q.estimate;\n const tr = q.transactionRequest;\n const expectedToToken = nativeFor(params.destChain, params.destToken);\n const expectedFromChain = Number(fromChain);\n const expectedToChain = Number(toChain);\n if (q.type !== \"lifi\" || !q.id || !action || !est?.toAmount || !est.fromAmount || !tr) return reject(\"incomplete quote (no action, estimate or transaction)\");\n const mismatch = [\n action.fromChainId !== expectedFromChain && \"source chain\",\n action.toChainId !== expectedToChain && \"destination chain\",\n (action.fromToken?.chainId !== expectedFromChain || !sameChainAddress(params.sourceChain, action.fromToken?.address, fromToken)) && \"source token\",\n (action.toToken?.chainId !== expectedToChain || !sameChainAddress(params.destChain, action.toToken?.address, expectedToToken)) && \"destination token\",\n action.fromAmount !== params.amountIn && \"amount spent\",\n !sameChainAddress(params.sourceChain, action.fromAddress, fromAddress) && \"sender\",\n !sameChainAddress(params.destChain, action.toAddress, toAddress) && \"recipient\",\n ].filter(Boolean);\n if (mismatch.length) return reject(`quote does not match the request (${mismatch.join(\", \")})`);\n // The transaction spends exactly the input (action.fromAmount, checked above). Some bridges\n // (glacis, 2026-10) take their fee from the input, so estimate.fromAmount — what is bridged —\n // is a little lower and toAmount already reflects it. Accept a bounded input-side fee instead\n // of a silent null; never an estimate that bridges MORE than is spent.\n const bridged = BigInt(est.fromAmount);\n const spent = BigInt(params.amountIn);\n if (bridged > spent) return reject(`the estimate bridges ${est.fromAmount}, more than the ${params.amountIn} spent`);\n if ((spent - bridged) * 10_000n > spent * BigInt(MAX_INPUT_FEE_BPS)) {\n return reject(`the route takes ${bigintToNumber(((spent - bridged) * 10_000n) / spent) / 100}% of the input as a fee (over ${MAX_INPUT_FEE_BPS / 100}%)`);\n }\n // Source-VM execution payload. EVM: calldata to a trusted target.\n // Solana: a base64 transaction the account proves before signing —\n // there is no target to trust here, the balance proof replaces it.\n if (solanaSource) {\n if (!tr.data || tr.data.length < 64 || tr.data.length % 4 !== 0 || !BASE64.test(tr.data)) return reject(\"the Solana transaction is not base64\");\n if (tr.to !== undefined || tr.value !== undefined || tr.gasLimit !== undefined) return reject(\"the Solana transaction carries EVM fields\");\n if (fromChain !== toChain) {\n const why = solanaBridgeTxMismatch(tr.data, fromAddress);\n if (why) return reject(why);\n }\n // `estimate.approvalAddress` is ignored for a Solana source: LI.FI\n // returns its EVM diamond here on Mayan routes too (seen 2026-10-09,\n // SOL → Base USDC via mayanFastMCTP), and Solana has no allowances —\n // the account's post-state balance proof is the guard, not an\n // approval target. It is never propagated.\n } else if (\n !isHexData(tr.data) || !normalizeAddress(tr.to) || !normalizeAddress(tr.from) ||\n tr.chainId !== expectedFromChain || !tr.value || !tr.gasLimit ||\n !trustedAddress(params.sourceChain, tr.to, trustedTransactionTargets) ||\n !sameAddress(tr.from, fromAddress)\n ) return reject(\"the transaction is malformed or targets an untrusted contract\");\n if (\n sentSlippage !== undefined &&\n (typeof action.slippage !== \"number\" || Math.abs(action.slippage - sentSlippage) > 1e-12)\n ) return reject(\"the quote ignored the requested slippage\");\n\n const sourceIsToken = fromToken !== EVM_ZERO && fromToken !== SOLANA_NATIVE;\n if (solanaSource) {\n // No allowances on Solana; nothing to trust beyond the balance proof.\n } else if (sourceIsToken) {\n if (!trustedAddress(params.sourceChain, est.approvalAddress, trustedApprovalAddresses)) return reject(\"the approval target is not a trusted LI.FI contract\");\n } else if (est.approvalAddress !== undefined) {\n // LI.FI started returning an approvalAddress for NATIVE sources too\n // (seen 2026-09 on every ETH-source quote, e.g. ETH → Robinhood via\n // relay: approvalAddress = the diamond the tx already calls). An\n // approval is meaningless for the native asset, so it is not a\n // reason to refuse the quote — but it must still be a trusted\n // target, and it is never propagated for a native source.\n if (!trustedAddress(params.sourceChain, est.approvalAddress, trustedApprovalAddresses)) return reject(\"the approval target is not a trusted LI.FI contract\");\n }\n\n let txRequest: NonNullable<Quote[\"txRequest\"]>;\n if (solanaSource) {\n // `value` declares what the account may let the tx take in native\n // coin: the input for a SOL source, nothing for a token source.\n txRequest = {serializedTx: tr.data!, value: sourceIsToken ? \"0\" : params.amountIn};\n } else {\n try {\n if (BigInt(tr.value!) < 0n || BigInt(tr.gasLimit!) <= 0n) return reject(\"the transaction has a negative value or no gas limit\");\n } catch {\n return reject(\"the transaction value or gas limit is not a number\");\n }\n // Some bridges charge a native messaging fee inside `value`: for a\n // token source the whole value is that fee; for a native source it\n // is whatever exceeds the input (seen 2026-10-10: DAI Optimism →\n // Base, POL Polygon → Optimism). Declared here, sealed with the\n // quote, bounded by the engine — never silently attached.\n const value = BigInt(tr.value!);\n const nativeFee = sourceIsToken ? value : value > BigInt(params.amountIn) ? value - BigInt(params.amountIn) : 0n;\n if (!sourceIsToken && value < BigInt(params.amountIn)) return reject(\"the transaction sends less native coin than the input\");\n txRequest = {\n to: tr.to!,\n data: tr.data!,\n value: value.toString(),\n chainId: tr.chainId!,\n gasLimit: BigInt(tr.gasLimit!).toString(),\n ...(sourceIsToken && est.approvalAddress ? {approvalAddress: est.approvalAddress} : {}),\n ...(nativeFee > 0n ? {nativeFee: nativeFee.toString()} : {}),\n };\n }\n\n // Route fees only (bridge / protocol / integrator). The source\n // transaction's gas is the network fee the wallet shows on its own line —\n // counting it here too made LI.FI look dearer than on-chain venues whose\n // fee excludes gas (2026-10-13).\n const feeUsd = (est.feeCosts ?? []).reduce((a, f) => a + Number(f.amountUSD ?? 0), 0);\n\n // The optimistic output is not a safety floor. A quote without the\n // provider's minimum cannot satisfy an exact-input execution contract.\n if (!est.toAmountMin) return reject(\"the quote has no minimum output\");\n const minDestAmount = est.toAmountMin;\n if (sentSlippage !== undefined) {\n const dest = BigInt(est.toAmount);\n const min = BigInt(minDestAmount);\n if (dest > 0n && min < slippageFloor(dest, slippageBps)) {\n const effective = bigintToNumber(((dest - min) * 1_000_000n) / dest) / 1_000_000;\n const requested = slippageBps / 10_000;\n const scaled: number = Math.floor(((sentSlippage * requested) / effective) * 0.995 * 1_000_000) / 1_000_000;\n if (attempt === 0 && effective > 0 && scaled > 0) {\n sentSlippage = scaled;\n continue;\n }\n params.onRefusal?.(\n `lifi: this route's minimum is ${(effective * 100).toFixed(2)}% under the quote (LI.FI applies slippage on every step) — more than the requested ${slippageBps / 100}%`,\n );\n return null;\n }\n }\n if (params.minAmountOut !== undefined && BigInt(minDestAmount) < BigInt(params.minAmountOut)) {\n params.onRefusal?.(`lifi: floor breach (min=${minDestAmount} < floor=${params.minAmountOut})`);\n return null;\n }\n // A same-chain swap must deliver in the same transaction. LI.FI sometimes routes a\n // same-chain pair through a solver (Relay-style intents, 2026-10: USDC → ARB on\n // Ethereum, 625 s): the tx only takes the input and the output arrives later from the\n // solver, so the engine's \"output ≥ quoted minimum\" preflight would refuse it anyway.\n // Name it here, before anything is built.\n const duration = est.executionDuration ?? 0;\n if (fromChain === toChain && duration > SAME_CHAIN_MAX_SECONDS) {\n params.onRefusal?.(`lifi: same-chain route settles asynchronously (${duration} s via ${(q as {tool?: string}).tool ?? \"unknown tool\"}) — a same-chain swap must deliver in the same transaction`);\n return null;\n }\n // The calldata is what gets signed: it must pay the reviewed recipient at least the reviewed\n // minimum, in the requested tokens (round 3, H9), and refund only the sender or the recipient.\n if (!solanaSource) {\n const why = diamondCallMismatch(tr.data!, {\n fromToken, toToken: expectedToToken, amountIn: BigInt(params.amountIn), receiver: toAddress, sender: fromAddress, minOut: BigInt(minDestAmount),\n destChainId: BigInt(toChain), sameChain: fromChain === toChain, evmDestination: !isSolana(params.destChain),\n });\n if (why) return reject(`the transaction does not match the quote: ${why}`);\n }\n return {\n provider: \"lifi\",\n // Status is tracked by SOURCE TX HASH + the chain pair.\n intentId: `lifi:${fromChain}:${toChain}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest,\n // What the wallet spends (action.fromAmount, = the input); an input-side bridge fee is inside destAmount.\n sourceAmount: params.amountIn,\n destAmount: est.toAmount,\n minDestAmount,\n ...(Number.isInteger(action.toToken?.decimals) && action.toToken!.decimals! >= 0 && action.toToken!.decimals! <= 36 ? {destDecimals: action.toToken!.decimals!} : {}),\n feeUsd,\n etaSeconds: est.executionDuration ?? 120,\n reliability: 0.97,\n // LI.FI documents an approximately 60-second lifetime. Use a slightly\n // shorter local deadline and re-quote again at execution time.\n validUntilMs: receivedAt + quoteTtlMs,\n };\n } catch {\n // Our own 12 s deadline (not the caller's signal): say so instead of a silent null.\n if (deadline?.aborted) params.onRefusal?.(\"lifi: no quote within 12 s\");\n return null;\n }\n return null;\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n if (!tx) throw new Error(\"swap2: LI.FI quote has no transaction request\");\n // The intent id carries the LI.FI source chain; a serialized leg names\n // its chain so the engine can refuse a mismatched account.\n const [, fromChain] = quote.intentId.split(\":\");\n return {\n chain: tx.serializedTx ? CAIP2_BY_LIFI_CHAIN[fromChain ?? \"\"] ?? \"\" : \"\",\n to: tx.to ?? \"\",\n value: tx.value ?? \"0\",\n ...(tx.data ? {data: tx.data} : {}),\n ...(tx.chainId !== undefined ? {chainId: tx.chainId} : {}),\n ...(tx.gasLimit ? {gasLimit: tx.gasLimit} : {}),\n ...(tx.approvalAddress ? {approvalAddress: tx.approvalAddress} : {}),\n ...(tx.serializedTx ? {serializedTx: tx.serializedTx} : {}),\n };\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (!ref.sourceTxHash) return {state: \"pending\"}; // not broadcast yet\n const [, fromChain, toChain] = ref.intentId.split(\":\");\n try {\n const url = new URL(`${apiBase}/status`);\n url.searchParams.set(\"txHash\", ref.sourceTxHash);\n if (fromChain) url.searchParams.set(\"fromChain\", fromChain);\n if (toChain) url.searchParams.set(\"toChain\", toChain);\n const res = await fetch(url, {headers: headers(apiKey()), signal: timeoutSignal(12_000)});\n if (!res.ok) return {state: \"pending\"};\n const s = (await res.json()) as {status?: string; substatus?: string; receiving?: {txHash?: string}};\n const map: Record<string, IntentStatus[\"state\"]> = {\n DONE: \"completed\",\n FAILED: \"failed\",\n // LI.FI cannot process the transaction: it never completes (round 3, L17).\n INVALID: \"failed\",\n PENDING: \"pending\",\n NOT_FOUND: \"pending\",\n };\n // LI.FI reports refunds and partial fills as top-level DONE. Treating\n // those as completed would falsely claim that the destination was fully\n // funded. Keep the explicit partial/refund lifecycle states.\n const state = s.substatus === \"REFUNDED\"\n ? \"refunded\"\n : s.substatus === \"EXPIRED\"\n ? \"expired\"\n : s.substatus === \"NOT_PROCESSABLE_REFUND_NEEDED\"\n ? \"action-required\"\n : s.substatus === \"REFUND_IN_PROGRESS\"\n ? \"refund-pending\"\n : s.status === \"DONE\" && s.substatus === \"PARTIAL\"\n ? \"partial\"\n : map[s.status ?? \"PENDING\"] ?? \"pending\";\n const depositReceived = state === \"pending\" && s.status === \"PENDING\";\n const destTxHash = typeof s.receiving?.txHash === \"string\" && s.receiving.txHash.length > 0\n ? s.receiving.txHash\n : undefined;\n return {\n state,\n depositReceived,\n ...(destTxHash ? {destTxHash} : {}),\n };\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n\n/**\n * A remote LI.FI quote's Diamond call, decoded on the device against the app's own request (scan 2026-10-30, F3) —\n * the same {@link diamondCallMismatch} the provider runs on LI.FI's answer, with the expectation it builds: the input\n * token and amount, the requested output token, the recipient, the quoted minimum (at least the caller's floor), the\n * destination chain. A native input is paid in value (any excess is the declared bridge fee); a token input attaches\n * only that declared fee and approves the Diamond. A Solana source carries a serialized transaction instead, which the\n * account proves before signing (for a Mayan bridge, against the engine's `bridgeOut`); here only its static part is\n * read (paid by the sender; a Mayan route pays SOL to no other wallet). The reason it fails, or null.\n */\nexport function lifiVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const fromChain = LIFI_CHAIN[params.sourceChain];\n const toChain = LIFI_CHAIN[params.destChain];\n if (!fromChain || !toChain) return \"not a LI.FI chain pair\";\n const tx = quote.txRequest;\n if (!tx) return \"the quote carries no transaction\";\n if (isSolana(params.sourceChain)) {\n if (!tx.serializedTx || tx.data !== undefined || tx.to !== undefined) return \"a Solana source carries a serialized transaction only\";\n // The static part of a bridge (see solanaBridgeTxMismatch); the account proves a Mayan order's recipient (bridgeOut).\n return fromChain === toChain ? null : solanaBridgeTxMismatch(tx.serializedTx, params.refundAddress || (params.dry !== false ? SOLANA_PLACEHOLDER : \"\"));\n }\n if (!isHexData(tx.data) || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no Diamond call\";\n if (!sameAddress(tx.to, diamondFor(params.sourceChain))) return `the call targets ${tx.to}, not the LI.FI Diamond`;\n if (tx.chainId !== undefined && String(tx.chainId) !== fromChain) return `the call is for chain ${tx.chainId}, not ${fromChain}`;\n const fromToken = lifiToken(params);\n if (!fromToken) return `unknown source token ${params.sourceToken}`;\n const sourceIsToken = fromToken !== EVM_ZERO;\n // The same addresses the provider quotes for: a dry quote without them prices the placeholder (never built).\n const dry = params.dry !== false;\n const fromAddress = params.refundAddress || (dry ? EVM_PLACEHOLDER : \"\");\n const toAddress = params.destAddress || (dry ? fromAddress : \"\");\n if (!fromAddress || !toAddress) return \"a live quote needs the sender and the recipient\";\n let amountIn: bigint, minOut: bigint, value: bigint, nativeFee: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n minOut = BigInt(quote.minDestAmount);\n value = BigInt(tx.value ?? \"0\");\n nativeFee = BigInt(tx.nativeFee ?? \"0\");\n } catch {\n return \"the quote's amounts are not integers\";\n }\n if (BigInt(quote.sourceAmount) !== amountIn) return `the quote spends ${quote.sourceAmount}, not the ${amountIn} input`;\n if (params.minAmountOut !== undefined && minOut < BigInt(params.minAmountOut)) return `the quoted minimum ${minOut} is below the caller's floor ${params.minAmountOut}`;\n if (sourceIsToken) {\n if (value !== nativeFee) return \"a token input attaches only its declared bridge fee\";\n if (!tx.approvalAddress || !sameAddress(tx.approvalAddress, diamondFor(params.sourceChain))) return \"a token input approves the LI.FI Diamond\";\n } else {\n if (value < amountIn || value - amountIn !== nativeFee) return \"a native input is paid as the input plus its declared bridge fee\";\n if (tx.approvalAddress !== undefined) return \"a native input approves nothing\";\n }\n if (quote.intentId.replace(/~[0-9a-f]{32}$/, \"\") !== `lifi:${fromChain}:${toChain}`) return \"the intent id does not name this route\";\n const why = diamondCallMismatch(tx.data, {\n fromToken, toToken: nativeFor(params.destChain, params.destToken), amountIn, receiver: toAddress, sender: fromAddress, minOut,\n destChainId: BigInt(toChain), sameChain: fromChain === toChain, evmDestination: !isSolana(params.destChain),\n });\n return why ? `the transaction does not match the request: ${why}` : null;\n}\n\n/**\n * The LI.FI Diamond an EVM route calls and approves on a chain (the canonical one, or the chain's own\n * where it differs), and {@link lifiVerifyQuote} — the app's pins for `remoteProvider({name: \"lifi\", baseUrl,\n * ...lifiPins})` (scan 2026-10-27 modules, F8/F16; the Diamond call itself since scan 2026-10-30, F3). Extra audited\n * targets an app configures on the provider (`trustedTransactionTargets` / `trustedApprovalAddresses`) are added on\n * the app side too.\n */\nexport const lifiPins: RemotePins = Object.freeze({\n callTargets: (chain: string): readonly string[] => (/^eip155:[0-9]+$/.test(chain) ? [diamondFor(chain)] : []),\n spenders: (chain: string): readonly string[] => (/^eip155:[0-9]+$/.test(chain) ? [diamondFor(chain)] : []),\n verifyQuote: lifiVerifyQuote,\n});\n"],"mappings":";;;;;;;;;AAmCA,IAAM,gBAAqF;AAAA,EACzF,cAAc,EAAC,QAAQ,MAAK;AAAA;AAAA,EAC5B,cAAc,EAAC,QAAQ,MAAM,MAAM,SAAS,IAAI,QAAO;AAAA;AAAA,EACvD,cAAc,EAAC,QAAQ,MAAM,MAAM,SAAS,IAAI,SAAQ;AAAA;AAAA,EACxD,cAAc,EAAC,QAAQ,MAAM,MAAM,UAAU,IAAI,QAAO;AAAA;AAAA,EACxD,cAAc,EAAC,QAAQ,OAAO,MAAM,SAAS,IAAI,QAAO;AAAA;AAAA,EACxD,cAAc,EAAC,QAAQ,OAAO,MAAM,SAAS,IAAI,SAAQ;AAAA;AAAA,EACzD,cAAc,EAAC,QAAQ,OAAO,MAAM,UAAU,IAAI,QAAO;AAAA;AAC3D;AAEA,IAAM,2BAA2B;AACjC,IAAM,SAAS,CAAC,UAAyB,aAAa,KAAK,KAAK,IAAI,WAAW;AAS/E,IAAM,eAAgF;AAAA,EACpF,cAAc,EAAC,aAAa,OAAO,OAAO,SAAQ;AAAA;AAAA,EAClD,cAAc,EAAC,aAAa,MAAM,OAAO,SAAQ;AAAA;AAAA,EACjD,cAAc,EAAC,aAAa,OAAO,OAAO,WAAU;AAAA;AAAA,EACpD,cAAc,EAAC,aAAa,MAAM,OAAO,WAAU;AAAA;AAAA,EACnD,cAAc,EAAC,aAAa,OAAO,OAAO,eAAc;AAAA;AAAA,EACxD,cAAc,EAAC,aAAa,MAAM,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