@anywalletkit/protocol-swap2-cctp 0.4.0 → 0.5.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.
- package/README.md +8 -3
- package/dist/{chunk-NUYRISHG.js → chunk-H4W3JMYC.js} +10 -5
- package/dist/chunk-H4W3JMYC.js.map +1 -0
- package/dist/{chunk-7SJIIXXM.js → chunk-LK64TDTT.js} +2 -2
- package/dist/index.cjs +9 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/protocol.cjs +9 -4
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.js +2 -2
- package/dist/provider.cjs +9 -4
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.cts +3 -1
- package/dist/provider.d.ts +3 -1
- package/dist/provider.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-NUYRISHG.js.map +0 -1
- /package/dist/{chunk-7SJIIXXM.js.map → chunk-LK64TDTT.js.map} +0 -0
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ const res = await swap2.swap2({fromToken: "USDC", toToken: "USDC", toChain: 4216
|
|
|
32
32
|
const status = await swap2.getSwap2Status(res.id); // "pending" → "action-required" once Circle attested
|
|
33
33
|
if (status.status === "action-required") {
|
|
34
34
|
const claimed = await swap2.claimSwap2(res.id, arbitrumAccount); // receiveMessage on Arbitrum, signed there
|
|
35
|
-
await swap2.getSwap2Status(claimed.id); // this id carries the claim hash
|
|
35
|
+
await swap2.getSwap2Status(claimed.id); // this id carries the claim hash and, once the account saw it succeed, "completed" even without an Arbitrum RPC
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -75,8 +75,13 @@ EVM routes.
|
|
|
75
75
|
must fit `maxFee`. Without an RPC the on-chain check is skipped.
|
|
76
76
|
- **Tracking**: `GET /v2/messages/{src}?transactionHash=` → `pending` while
|
|
77
77
|
confirmations accrue, `action-required` once `status: complete` with the
|
|
78
|
-
attestation, `completed` once the destination's `usedNonces(nonce)` is set
|
|
79
|
-
|
|
78
|
+
attestation, `completed` once the destination's `usedNonces(nonce)` is set.
|
|
79
|
+
Without the destination chain in `rpcUrls`, `completed` comes from the id
|
|
80
|
+
`claimSwap2` returns when the destination account's `waitForTransaction`
|
|
81
|
+
saw the claim succeed (`destTxConfirmed`: a successful `receiveMessage` is
|
|
82
|
+
the mint, since it reverts once the nonce is used); a bare claim hash stays
|
|
83
|
+
`pending`, with the hash in `destTxHash`. A destination RPC that does not
|
|
84
|
+
show the mint of a confirmed claim yet reads `pending`, not `action-required`.
|
|
80
85
|
- **Claim**: `receiveMessage(message, attestation)` on the destination
|
|
81
86
|
MessageTransmitterV2; the attested message must belong to the route's
|
|
82
87
|
domains. An expired Fast message (`expirationBlock` passed) is sent to
|
|
@@ -89,7 +89,7 @@ function cctpProvider(config = {}) {
|
|
|
89
89
|
const used = await c.readContract({ address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: "usedNonces", args: [nonce] });
|
|
90
90
|
return used !== 0n;
|
|
91
91
|
} catch {
|
|
92
|
-
return
|
|
92
|
+
return "unknown";
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return {
|
|
@@ -257,9 +257,14 @@ function cctpProvider(config = {}) {
|
|
|
257
257
|
if (!m) return { state: "pending", depositReceived: false, claim };
|
|
258
258
|
const nonce = m.decodedMessage?.nonce;
|
|
259
259
|
if (m.status === "complete" && isHexData(m.attestation) && isHexData(m.message)) {
|
|
260
|
-
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;
|
|
261
|
-
if (done) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
262
|
-
if (
|
|
260
|
+
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? "unknown" : null;
|
|
261
|
+
if (done === true) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
262
|
+
if (ref.destTxHash) {
|
|
263
|
+
if (ref.destTxConfirmed === true) {
|
|
264
|
+
return done === false ? { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } } : { state: "completed", destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
265
|
+
}
|
|
266
|
+
if (done !== false) return { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
267
|
+
}
|
|
263
268
|
return { state: "action-required", depositReceived: true, claim: { ...claim, ready: true } };
|
|
264
269
|
}
|
|
265
270
|
return { state: "pending", depositReceived: true, claim };
|
|
@@ -363,4 +368,4 @@ export {
|
|
|
363
368
|
cctpVerifyQuote,
|
|
364
369
|
cctpPins
|
|
365
370
|
};
|
|
366
|
-
//# sourceMappingURL=chunk-
|
|
371
|
+
//# sourceMappingURL=chunk-H4W3JMYC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`). Without the destination chain's URL the status\n * reaches \"completed\" only through the id `claimSwap2` returns for a claim the\n * account saw succeed; a bare claim hash stays \"pending\" (hash kept).\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n /** The nonce's state on the destination: null without an RPC there, \"unknown\" when the configured RPC fails to answer. */\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null | \"unknown\"> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return \"unknown\";\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n // A message without a readable nonce cannot be checked on the destination even with an RPC there.\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? \"unknown\" : null;\n if (done === true) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n if (ref.destTxHash) {\n // A claim the sending account saw included and succeed is the mint: receiveMessage reverts once the\n // nonce is used, so a successful one minted this message. Without a destination read that is completed;\n // a destination read that does not show it yet is a node behind the claim, not a claim to send again.\n if (ref.destTxConfirmed === true) {\n return done === false\n ? {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}}\n : {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n // A claim was sent, but nothing here can read whether it minted (no destination RPC, or one that did\n // not answer): the hash is kept and the swap stays pending — a hash alone is not a mint.\n if (done !== false) return {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP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
export {
|
|
25
25
|
CctpSwap2Protocol
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-LK64TDTT.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -195,7 +195,7 @@ function cctpProvider(config = {}) {
|
|
|
195
195
|
const used = await c.readContract({ address: (0, import_viem.getAddress)(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: "usedNonces", args: [nonce] });
|
|
196
196
|
return used !== 0n;
|
|
197
197
|
} catch {
|
|
198
|
-
return
|
|
198
|
+
return "unknown";
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
return {
|
|
@@ -363,9 +363,14 @@ function cctpProvider(config = {}) {
|
|
|
363
363
|
if (!m) return { state: "pending", depositReceived: false, claim };
|
|
364
364
|
const nonce = m.decodedMessage?.nonce;
|
|
365
365
|
if (m.status === "complete" && isHexData(m.attestation) && isHexData(m.message)) {
|
|
366
|
-
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;
|
|
367
|
-
if (done) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
368
|
-
if (
|
|
366
|
+
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? "unknown" : null;
|
|
367
|
+
if (done === true) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
368
|
+
if (ref.destTxHash) {
|
|
369
|
+
if (ref.destTxConfirmed === true) {
|
|
370
|
+
return done === false ? { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } } : { state: "completed", destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
371
|
+
}
|
|
372
|
+
if (done !== false) return { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
373
|
+
}
|
|
369
374
|
return { state: "action-required", depositReceived: true, claim: { ...claim, ready: true } };
|
|
370
375
|
}
|
|
371
376
|
return { state: "pending", depositReceived: true, claim };
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/provider.ts","../src/activity.ts","../src/protocol.ts"],"sourcesContent":["export * from \"./config.js\";\nexport * from \"./provider.js\";\nexport {CctpSwap2Protocol, type CctpSwap2Config} from \"./protocol.js\";\nexport {CctpSwap2Protocol as default} from \"./protocol.js\";\nexport * from \"./activity.js\";\n","// Circle CCTP V2 — mainnet domains, contracts and the native USDC each domain\n// mints. Sources (read 2026-10-10, Arc + Morph 2026-10-14): developers.circle.com/cctp/evm-smart-contracts\n// (domains + TokenMessengerV2 / MessageTransmitterV2, the same addresses on\n// every EVM chain except EDGE), developers.circle.com/stablecoins/usdc-contract-addresses\n// (native USDC). Only chains whose USDC is Circle-native are listed: CCTP\n// burns native USDC, a bridged USDC.e (BSC, Gnosis) cannot ride it.\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\n\nexport interface CctpDomain {\n caip2: string;\n chainId: number;\n domain: number;\n name: string;\n usdc: string;\n tokenMessenger: string;\n messageTransmitter: string;\n}\n\nexport const TOKEN_MESSENGER_V2 = \"0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d\";\nexport const MESSAGE_TRANSMITTER_V2 = \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\";\n\nconst d = (chainId: number, domain: number, name: string, usdc: string): CctpDomain => ({\n caip2: `eip155:${chainId}`, chainId, domain, name, usdc, tokenMessenger: TOKEN_MESSENGER_V2, messageTransmitter: MESSAGE_TRANSMITTER_V2,\n});\n\n/** CAIP-2 → CCTP domain. */\nexport const CCTP_DOMAINS: Readonly<Record<string, CctpDomain>> = Object.freeze(Object.fromEntries([\n d(1, 0, \"Ethereum\", \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\"),\n d(43114, 1, \"Avalanche\", \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\"),\n d(10, 2, \"OP Mainnet\", \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\"),\n d(42161, 3, \"Arbitrum\", \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"),\n d(8453, 6, \"Base\", \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"),\n d(137, 7, \"Polygon PoS\", \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"),\n d(130, 10, \"Unichain\", \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\"),\n d(59144, 11, \"Linea\", \"0x176211869cA2b568f2A7D4EE941E073a821EE1ff\"),\n d(146, 13, \"Sonic\", \"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"),\n d(480, 14, \"World Chain\", \"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"),\n d(143, 15, \"Monad\", \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\"),\n d(1329, 16, \"Sei\", \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\"),\n d(999, 19, \"HyperEVM\", \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\"),\n d(57073, 21, \"Ink\", \"0x2D270e6886d130D724215A266106e6832161EAEd\"),\n d(98866, 22, \"Plume\", \"0x222365EF19F7947e5484218551B56bb3965Aa7aF\"),\n d(9745, 33, \"Plasma\", \"0x2d661C89D812261039AF9764eceaAee884f5F67F\"),\n d(196, 37, \"X Layer\", \"0xB6CEceAB302E2E4948951eE7843FC24E92933061\"),\n // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /\n // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and\n // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its\n // 6-decimal ERC-20 interface, which is what CCTP burns and mints.\n d(5042, 26, \"Arc\", \"0x3600000000000000000000000000000000000000\"),\n d(2818, 30, \"Morph\", \"0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B\"),\n].map((x) => [x.caip2, x])));\n\n/** CCTP domain → entry. */\nexport const CCTP_BY_DOMAIN: Readonly<Record<number, CctpDomain>> = Object.freeze(\n Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x])),\n);\n\n/** Solana is CCTP domain 5 (not executed by this package yet: the engine runs calldata on EVM only). */\nexport const CCTP_SOLANA_DOMAIN = 5;\n\nexport const CCTP_API = \"https://iris-api.circle.com\";\n\n/** Finality thresholds the header carries: Fast Transfer (confirmed) vs Standard (finalized). */\nexport const FINALITY_FAST = 1000;\nexport const FINALITY_STANDARD = 2000;\n\nexport const cctp = {\n supportsChain(chain: string): boolean {\n return isEvm(chain) && !!CCTP_DOMAINS[`eip155:${evmRef(chain)}`];\n },\n supports(from: string, to: string): boolean {\n return from !== to && this.supportsChain(from) && this.supportsChain(to);\n },\n};\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`) so the status reaches \"completed\" by itself.\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return null;\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;\n if (done) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n // No destination RPC: a recorded claim hash is the best evidence we have.\n if (done === null && ref.destTxHash) return {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n","/**\n * Activity recognition for Circle CCTP V2 on every domain in `config.ts`:\n * `depositForBurn` on TokenMessengerV2 is our source leg (\"Bridged USDC\"), and\n * `receiveMessage` on MessageTransmitterV2 is the claim that mints on the\n * destination (\"Received USDC via CCTP\") — whoever paid the gas, the USDC lands\n * on the `mintRecipient`. Both are `bridge`; the other leg's hash is only known\n * through the kit's journal / Circle's attestation API, so `related` stays empty.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {CCTP_DOMAINS} from \"./config.js\";\n\nexport const CCTP_MODULE = \"@anywalletkit/protocol-swap2-cctp\";\n\n/** depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32) — TokenMessengerV2 */\nexport const CCTP_DEPOSIT_FOR_BURN = \"0x8e0250ee\";\n/** receiveMessage(bytes,bytes) — MessageTransmitterV2 */\nexport const CCTP_RECEIVE_MESSAGE = \"0x57ecfd28\";\n\nexport function describeCctpActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n const domain = CCTP_DOMAINS[tx.chain];\n if (!domain) return null;\n const subtitle = `CCTP · ${chainLabel(tx.chain)}`;\n if (matchesCall(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Bridged USDC\"});\n }\n if (matchesCall(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Received USDC via CCTP\"});\n }\n return null;\n}\n","import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {cctp as cctpCfg} from \"./config.js\";\nimport {cctpProvider, type CctpProviderConfig} from \"./provider.js\";\n\nexport interface CctpSwap2Config extends Swap2EngineConfig, CctpProviderConfig {}\n\n/** Standalone CCTP swap2: USDC burn-and-mint between EVM chains, claim via `claimSwap2`. */\nexport class CctpSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: CctpSwap2Config) {\n super(account, config);\n this.provider = cctpProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return cctpCfg.supportsChain(caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return cctpCfg.supports(fromChain, toChain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAa,WAAW,OAAO,SAAS,EAAG,QAAO;AACxG,SAAO;AACT;AAOO,IAAM,WAA0E,OAAO,OAAO;AAAA,EACnG,aAAa,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACzE,UAAU,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACtE,cAAc;AAAA,EACd,aAAa;AACf,CAAC;AACD,SAAS,iBAAiB,OAAkC;AAC1D,QAAMA,KAAI,OAAO,UAAU,eAAe,KAAK,cAAc,KAAK,IAAI,aAAa,KAAK,IAAI;AAC5F,SAAOA,KAAI,CAACA,GAAE,cAAc,IAAI,CAAC;AACnC;;;AElbA,oBAAkC;AAQ3B,IAAM,oBAAN,cAAgC,kCAAoB;AAAA,EACtC;AAAA,EACnB,YAAY,SAAmC,QAAyB;AACtE,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,aAAa,MAAM;AAAA,EACrC;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,KAAQ,cAAc,KAAK;AAAA,EACpC;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,KAAQ,SAAS,WAAW,OAAO;AAAA,EAC5C;AACF;","names":["import_util","d"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/provider.ts","../src/activity.ts","../src/protocol.ts"],"sourcesContent":["export * from \"./config.js\";\nexport * from \"./provider.js\";\nexport {CctpSwap2Protocol, type CctpSwap2Config} from \"./protocol.js\";\nexport {CctpSwap2Protocol as default} from \"./protocol.js\";\nexport * from \"./activity.js\";\n","// Circle CCTP V2 — mainnet domains, contracts and the native USDC each domain\n// mints. Sources (read 2026-10-10, Arc + Morph 2026-10-14): developers.circle.com/cctp/evm-smart-contracts\n// (domains + TokenMessengerV2 / MessageTransmitterV2, the same addresses on\n// every EVM chain except EDGE), developers.circle.com/stablecoins/usdc-contract-addresses\n// (native USDC). Only chains whose USDC is Circle-native are listed: CCTP\n// burns native USDC, a bridged USDC.e (BSC, Gnosis) cannot ride it.\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\n\nexport interface CctpDomain {\n caip2: string;\n chainId: number;\n domain: number;\n name: string;\n usdc: string;\n tokenMessenger: string;\n messageTransmitter: string;\n}\n\nexport const TOKEN_MESSENGER_V2 = \"0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d\";\nexport const MESSAGE_TRANSMITTER_V2 = \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\";\n\nconst d = (chainId: number, domain: number, name: string, usdc: string): CctpDomain => ({\n caip2: `eip155:${chainId}`, chainId, domain, name, usdc, tokenMessenger: TOKEN_MESSENGER_V2, messageTransmitter: MESSAGE_TRANSMITTER_V2,\n});\n\n/** CAIP-2 → CCTP domain. */\nexport const CCTP_DOMAINS: Readonly<Record<string, CctpDomain>> = Object.freeze(Object.fromEntries([\n d(1, 0, \"Ethereum\", \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\"),\n d(43114, 1, \"Avalanche\", \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\"),\n d(10, 2, \"OP Mainnet\", \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\"),\n d(42161, 3, \"Arbitrum\", \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"),\n d(8453, 6, \"Base\", \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"),\n d(137, 7, \"Polygon PoS\", \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"),\n d(130, 10, \"Unichain\", \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\"),\n d(59144, 11, \"Linea\", \"0x176211869cA2b568f2A7D4EE941E073a821EE1ff\"),\n d(146, 13, \"Sonic\", \"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"),\n d(480, 14, \"World Chain\", \"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"),\n d(143, 15, \"Monad\", \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\"),\n d(1329, 16, \"Sei\", \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\"),\n d(999, 19, \"HyperEVM\", \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\"),\n d(57073, 21, \"Ink\", \"0x2D270e6886d130D724215A266106e6832161EAEd\"),\n d(98866, 22, \"Plume\", \"0x222365EF19F7947e5484218551B56bb3965Aa7aF\"),\n d(9745, 33, \"Plasma\", \"0x2d661C89D812261039AF9764eceaAee884f5F67F\"),\n d(196, 37, \"X Layer\", \"0xB6CEceAB302E2E4948951eE7843FC24E92933061\"),\n // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /\n // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and\n // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its\n // 6-decimal ERC-20 interface, which is what CCTP burns and mints.\n d(5042, 26, \"Arc\", \"0x3600000000000000000000000000000000000000\"),\n d(2818, 30, \"Morph\", \"0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B\"),\n].map((x) => [x.caip2, x])));\n\n/** CCTP domain → entry. */\nexport const CCTP_BY_DOMAIN: Readonly<Record<number, CctpDomain>> = Object.freeze(\n Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x])),\n);\n\n/** Solana is CCTP domain 5 (not executed by this package yet: the engine runs calldata on EVM only). */\nexport const CCTP_SOLANA_DOMAIN = 5;\n\nexport const CCTP_API = \"https://iris-api.circle.com\";\n\n/** Finality thresholds the header carries: Fast Transfer (confirmed) vs Standard (finalized). */\nexport const FINALITY_FAST = 1000;\nexport const FINALITY_STANDARD = 2000;\n\nexport const cctp = {\n supportsChain(chain: string): boolean {\n return isEvm(chain) && !!CCTP_DOMAINS[`eip155:${evmRef(chain)}`];\n },\n supports(from: string, to: string): boolean {\n return from !== to && this.supportsChain(from) && this.supportsChain(to);\n },\n};\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`). Without the destination chain's URL the status\n * reaches \"completed\" only through the id `claimSwap2` returns for a claim the\n * account saw succeed; a bare claim hash stays \"pending\" (hash kept).\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n /** The nonce's state on the destination: null without an RPC there, \"unknown\" when the configured RPC fails to answer. */\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null | \"unknown\"> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return \"unknown\";\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n // A message without a readable nonce cannot be checked on the destination even with an RPC there.\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? \"unknown\" : null;\n if (done === true) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n if (ref.destTxHash) {\n // A claim the sending account saw included and succeed is the mint: receiveMessage reverts once the\n // nonce is used, so a successful one minted this message. Without a destination read that is completed;\n // a destination read that does not show it yet is a node behind the claim, not a claim to send again.\n if (ref.destTxConfirmed === true) {\n return done === false\n ? {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}}\n : {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n // A claim was sent, but nothing here can read whether it minted (no destination RPC, or one that did\n // not answer): the hash is kept and the swap stays pending — a hash alone is not a mint.\n if (done !== false) return {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n","/**\n * Activity recognition for Circle CCTP V2 on every domain in `config.ts`:\n * `depositForBurn` on TokenMessengerV2 is our source leg (\"Bridged USDC\"), and\n * `receiveMessage` on MessageTransmitterV2 is the claim that mints on the\n * destination (\"Received USDC via CCTP\") — whoever paid the gas, the USDC lands\n * on the `mintRecipient`. Both are `bridge`; the other leg's hash is only known\n * through the kit's journal / Circle's attestation API, so `related` stays empty.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {CCTP_DOMAINS} from \"./config.js\";\n\nexport const CCTP_MODULE = \"@anywalletkit/protocol-swap2-cctp\";\n\n/** depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32) — TokenMessengerV2 */\nexport const CCTP_DEPOSIT_FOR_BURN = \"0x8e0250ee\";\n/** receiveMessage(bytes,bytes) — MessageTransmitterV2 */\nexport const CCTP_RECEIVE_MESSAGE = \"0x57ecfd28\";\n\nexport function describeCctpActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n const domain = CCTP_DOMAINS[tx.chain];\n if (!domain) return null;\n const subtitle = `CCTP · ${chainLabel(tx.chain)}`;\n if (matchesCall(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Bridged USDC\"});\n }\n if (matchesCall(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Received USDC via CCTP\"});\n }\n return null;\n}\n","import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {cctp as cctpCfg} from \"./config.js\";\nimport {cctpProvider, type CctpProviderConfig} from \"./provider.js\";\n\nexport interface CctpSwap2Config extends Swap2EngineConfig, CctpProviderConfig {}\n\n/** Standalone CCTP swap2: USDC burn-and-mint between EVM chains, claim via `claimSwap2`. */\nexport class CctpSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: CctpSwap2Config) {\n super(account, config);\n this.provider = cctpProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return cctpCfg.supportsChain(caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return cctpCfg.supports(fromChain, toChain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,kBAA4B;AAYrB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAEtC,IAAM,IAAI,CAAC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AAO,qBAAqB,MAAM,yBAAyB,KAAK;AAEjH,OAAK,2BAA2B,KAAK,MAAM,QAAQ,IAAI,CAAC,KAAK,MAAM,cAAc,QAAQ,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI,SAAS,GAAI,QAAO;AACzI,MAAI,MAAM,cAAc,WAAW,UAAa,MAAM,aAAa,WAAW,OAAO,SAAS,EAAG,QAAO;AACxG,SAAO;AACT;AAOO,IAAM,WAA0E,OAAO,OAAO;AAAA,EACnG,aAAa,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACzE,UAAU,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACtE,cAAc;AAAA,EACd,aAAa;AACf,CAAC;AACD,SAAS,iBAAiB,OAAkC;AAC1D,QAAMA,KAAI,OAAO,UAAU,eAAe,KAAK,cAAc,KAAK,IAAI,aAAa,KAAK,IAAI;AAC5F,SAAOA,KAAI,CAACA,GAAE,cAAc,IAAI,CAAC;AACnC;;;AEjcA,oBAAkC;AAQ3B,IAAM,oBAAN,cAAgC,kCAAoB;AAAA,EACtC;AAAA,EACnB,YAAY,SAAmC,QAAyB;AACtE,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,aAAa,MAAM;AAAA,EACrC;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,KAAQ,cAAc,KAAK;AAAA,EACpC;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,KAAQ,SAAS,WAAW,OAAO;AAAA,EAC5C;AACF;","names":["import_util","d"]}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CctpSwap2Protocol
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LK64TDTT.js";
|
|
4
4
|
import {
|
|
5
5
|
cctpClaimTargets,
|
|
6
6
|
cctpPins,
|
|
7
7
|
cctpProvider,
|
|
8
8
|
cctpVerifyQuote
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H4W3JMYC.js";
|
|
10
10
|
import {
|
|
11
11
|
CCTP_DEPOSIT_FOR_BURN,
|
|
12
12
|
CCTP_MODULE,
|
package/dist/protocol.cjs
CHANGED
|
@@ -177,7 +177,7 @@ function cctpProvider(config = {}) {
|
|
|
177
177
|
const used = await c.readContract({ address: (0, import_viem.getAddress)(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: "usedNonces", args: [nonce] });
|
|
178
178
|
return used !== 0n;
|
|
179
179
|
} catch {
|
|
180
|
-
return
|
|
180
|
+
return "unknown";
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
return {
|
|
@@ -345,9 +345,14 @@ function cctpProvider(config = {}) {
|
|
|
345
345
|
if (!m) return { state: "pending", depositReceived: false, claim };
|
|
346
346
|
const nonce = m.decodedMessage?.nonce;
|
|
347
347
|
if (m.status === "complete" && isHexData(m.attestation) && isHexData(m.message)) {
|
|
348
|
-
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;
|
|
349
|
-
if (done) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
350
|
-
if (
|
|
348
|
+
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? "unknown" : null;
|
|
349
|
+
if (done === true) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
350
|
+
if (ref.destTxHash) {
|
|
351
|
+
if (ref.destTxConfirmed === true) {
|
|
352
|
+
return done === false ? { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } } : { state: "completed", destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
353
|
+
}
|
|
354
|
+
if (done !== false) return { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
355
|
+
}
|
|
351
356
|
return { state: "action-required", depositReceived: true, claim: { ...claim, ready: true } };
|
|
352
357
|
}
|
|
353
358
|
return { state: "pending", depositReceived: true, claim };
|
package/dist/protocol.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/protocol.ts","../src/config.ts","../src/provider.ts","../src/activity.ts"],"sourcesContent":["import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {cctp as cctpCfg} from \"./config.js\";\nimport {cctpProvider, type CctpProviderConfig} from \"./provider.js\";\n\nexport interface CctpSwap2Config extends Swap2EngineConfig, CctpProviderConfig {}\n\n/** Standalone CCTP swap2: USDC burn-and-mint between EVM chains, claim via `claimSwap2`. */\nexport class CctpSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: CctpSwap2Config) {\n super(account, config);\n this.provider = cctpProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return cctpCfg.supportsChain(caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return cctpCfg.supports(fromChain, toChain);\n }\n}\n","// Circle CCTP V2 — mainnet domains, contracts and the native USDC each domain\n// mints. Sources (read 2026-10-10, Arc + Morph 2026-10-14): developers.circle.com/cctp/evm-smart-contracts\n// (domains + TokenMessengerV2 / MessageTransmitterV2, the same addresses on\n// every EVM chain except EDGE), developers.circle.com/stablecoins/usdc-contract-addresses\n// (native USDC). Only chains whose USDC is Circle-native are listed: CCTP\n// burns native USDC, a bridged USDC.e (BSC, Gnosis) cannot ride it.\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\n\nexport interface CctpDomain {\n caip2: string;\n chainId: number;\n domain: number;\n name: string;\n usdc: string;\n tokenMessenger: string;\n messageTransmitter: string;\n}\n\nexport const TOKEN_MESSENGER_V2 = \"0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d\";\nexport const MESSAGE_TRANSMITTER_V2 = \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\";\n\nconst d = (chainId: number, domain: number, name: string, usdc: string): CctpDomain => ({\n caip2: `eip155:${chainId}`, chainId, domain, name, usdc, tokenMessenger: TOKEN_MESSENGER_V2, messageTransmitter: MESSAGE_TRANSMITTER_V2,\n});\n\n/** CAIP-2 → CCTP domain. */\nexport const CCTP_DOMAINS: Readonly<Record<string, CctpDomain>> = Object.freeze(Object.fromEntries([\n d(1, 0, \"Ethereum\", \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\"),\n d(43114, 1, \"Avalanche\", \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\"),\n d(10, 2, \"OP Mainnet\", \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\"),\n d(42161, 3, \"Arbitrum\", \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"),\n d(8453, 6, \"Base\", \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"),\n d(137, 7, \"Polygon PoS\", \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"),\n d(130, 10, \"Unichain\", \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\"),\n d(59144, 11, \"Linea\", \"0x176211869cA2b568f2A7D4EE941E073a821EE1ff\"),\n d(146, 13, \"Sonic\", \"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"),\n d(480, 14, \"World Chain\", \"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"),\n d(143, 15, \"Monad\", \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\"),\n d(1329, 16, \"Sei\", \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\"),\n d(999, 19, \"HyperEVM\", \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\"),\n d(57073, 21, \"Ink\", \"0x2D270e6886d130D724215A266106e6832161EAEd\"),\n d(98866, 22, \"Plume\", \"0x222365EF19F7947e5484218551B56bb3965Aa7aF\"),\n d(9745, 33, \"Plasma\", \"0x2d661C89D812261039AF9764eceaAee884f5F67F\"),\n d(196, 37, \"X Layer\", \"0xB6CEceAB302E2E4948951eE7843FC24E92933061\"),\n // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /\n // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and\n // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its\n // 6-decimal ERC-20 interface, which is what CCTP burns and mints.\n d(5042, 26, \"Arc\", \"0x3600000000000000000000000000000000000000\"),\n d(2818, 30, \"Morph\", \"0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B\"),\n].map((x) => [x.caip2, x])));\n\n/** CCTP domain → entry. */\nexport const CCTP_BY_DOMAIN: Readonly<Record<number, CctpDomain>> = Object.freeze(\n Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x])),\n);\n\n/** Solana is CCTP domain 5 (not executed by this package yet: the engine runs calldata on EVM only). */\nexport const CCTP_SOLANA_DOMAIN = 5;\n\nexport const CCTP_API = \"https://iris-api.circle.com\";\n\n/** Finality thresholds the header carries: Fast Transfer (confirmed) vs Standard (finalized). */\nexport const FINALITY_FAST = 1000;\nexport const FINALITY_STANDARD = 2000;\n\nexport const cctp = {\n supportsChain(chain: string): boolean {\n return isEvm(chain) && !!CCTP_DOMAINS[`eip155:${evmRef(chain)}`];\n },\n supports(from: string, to: string): boolean {\n return from !== to && this.supportsChain(from) && this.supportsChain(to);\n },\n};\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`) so the status reaches \"completed\" by itself.\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return null;\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;\n if (done) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n // No destination RPC: a recorded claim hash is the best evidence we have.\n if (done === null && ref.destTxHash) return {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n","/**\n * Activity recognition for Circle CCTP V2 on every domain in `config.ts`:\n * `depositForBurn` on TokenMessengerV2 is our source leg (\"Bridged USDC\"), and\n * `receiveMessage` on MessageTransmitterV2 is the claim that mints on the\n * destination (\"Received USDC via CCTP\") — whoever paid the gas, the USDC lands\n * on the `mintRecipient`. Both are `bridge`; the other leg's hash is only known\n * through the kit's journal / Circle's attestation API, so `related` stays empty.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {CCTP_DOMAINS} from \"./config.js\";\n\nexport const CCTP_MODULE = \"@anywalletkit/protocol-swap2-cctp\";\n\n/** depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32) — TokenMessengerV2 */\nexport const CCTP_DEPOSIT_FOR_BURN = \"0x8e0250ee\";\n/** receiveMessage(bytes,bytes) — MessageTransmitterV2 */\nexport const CCTP_RECEIVE_MESSAGE = \"0x57ecfd28\";\n\nexport function describeCctpActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n const domain = CCTP_DOMAINS[tx.chain];\n if (!domain) return null;\n const subtitle = `CCTP · ${chainLabel(tx.chain)}`;\n if (matchesCall(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Bridged USDC\"});\n }\n if (matchesCall(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Received USDC via CCTP\"});\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAkC;;;ACMlC,kBAA4B;AAYrB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAEtC,IAAM,IAAI,CAAC,SAAiB,QAAgB,MAAc,UAA8B;AAAA,EACtF,OAAO,UAAU,OAAO;AAAA,EAAI;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAM;AAAA,EAAM,gBAAgB;AAAA,EAAoB,oBAAo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KAAK,cAAc,KAAK,IAAI,aAAa,KAAK,IAAI;AAC5F,SAAOA,KAAI,CAACA,GAAE,cAAc,IAAI,CAAC;AACnC;;;AF1aO,IAAM,oBAAN,cAAgC,kCAAoB;AAAA,EACtC;AAAA,EACnB,YAAY,SAAmC,QAAyB;AACtE,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,aAAa,MAAM;AAAA,EACrC;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,KAAQ,cAAc,KAAK;AAAA,EACpC;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,KAAQ,SAAS,WAAW,OAAO;AAAA,EAC5C;AACF;","names":["import_util","d"]}
|
|
1
|
+
{"version":3,"sources":["../src/protocol.ts","../src/config.ts","../src/provider.ts","../src/activity.ts"],"sourcesContent":["import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {cctp as cctpCfg} from \"./config.js\";\nimport {cctpProvider, type CctpProviderConfig} from \"./provider.js\";\n\nexport interface CctpSwap2Config extends Swap2EngineConfig, CctpProviderConfig {}\n\n/** Standalone CCTP swap2: USDC burn-and-mint between EVM chains, claim via `claimSwap2`. */\nexport class CctpSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: CctpSwap2Config) {\n super(account, config);\n this.provider = cctpProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return cctpCfg.supportsChain(caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return cctpCfg.supports(fromChain, toChain);\n }\n}\n","// Circle CCTP V2 — mainnet domains, contracts and the native USDC each domain\n// mints. Sources (read 2026-10-10, Arc + Morph 2026-10-14): developers.circle.com/cctp/evm-smart-contracts\n// (domains + TokenMessengerV2 / MessageTransmitterV2, the same addresses on\n// every EVM chain except EDGE), developers.circle.com/stablecoins/usdc-contract-addresses\n// (native USDC). Only chains whose USDC is Circle-native are listed: CCTP\n// burns native USDC, a bridged USDC.e (BSC, Gnosis) cannot ride it.\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\n\nexport interface CctpDomain {\n caip2: string;\n chainId: number;\n domain: number;\n name: string;\n usdc: string;\n tokenMessenger: string;\n messageTransmitter: string;\n}\n\nexport const TOKEN_MESSENGER_V2 = \"0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d\";\nexport const MESSAGE_TRANSMITTER_V2 = \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\";\n\nconst d = (chainId: number, domain: number, name: string, usdc: string): CctpDomain => ({\n caip2: `eip155:${chainId}`, chainId, domain, name, usdc, tokenMessenger: TOKEN_MESSENGER_V2, messageTransmitter: MESSAGE_TRANSMITTER_V2,\n});\n\n/** CAIP-2 → CCTP domain. */\nexport const CCTP_DOMAINS: Readonly<Record<string, CctpDomain>> = Object.freeze(Object.fromEntries([\n d(1, 0, \"Ethereum\", \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\"),\n d(43114, 1, \"Avalanche\", \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\"),\n d(10, 2, \"OP Mainnet\", \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\"),\n d(42161, 3, \"Arbitrum\", \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"),\n d(8453, 6, \"Base\", \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"),\n d(137, 7, \"Polygon PoS\", \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"),\n d(130, 10, \"Unichain\", \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\"),\n d(59144, 11, \"Linea\", \"0x176211869cA2b568f2A7D4EE941E073a821EE1ff\"),\n d(146, 13, \"Sonic\", \"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"),\n d(480, 14, \"World Chain\", \"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"),\n d(143, 15, \"Monad\", \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\"),\n d(1329, 16, \"Sei\", \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\"),\n d(999, 19, \"HyperEVM\", \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\"),\n d(57073, 21, \"Ink\", \"0x2D270e6886d130D724215A266106e6832161EAEd\"),\n d(98866, 22, \"Plume\", \"0x222365EF19F7947e5484218551B56bb3965Aa7aF\"),\n d(9745, 33, \"Plasma\", \"0x2d661C89D812261039AF9764eceaAee884f5F67F\"),\n d(196, 37, \"X Layer\", \"0xB6CEceAB302E2E4948951eE7843FC24E92933061\"),\n // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /\n // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and\n // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its\n // 6-decimal ERC-20 interface, which is what CCTP burns and mints.\n d(5042, 26, \"Arc\", \"0x3600000000000000000000000000000000000000\"),\n d(2818, 30, \"Morph\", \"0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B\"),\n].map((x) => [x.caip2, x])));\n\n/** CCTP domain → entry. */\nexport const CCTP_BY_DOMAIN: Readonly<Record<number, CctpDomain>> = Object.freeze(\n Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x])),\n);\n\n/** Solana is CCTP domain 5 (not executed by this package yet: the engine runs calldata on EVM only). */\nexport const CCTP_SOLANA_DOMAIN = 5;\n\nexport const CCTP_API = \"https://iris-api.circle.com\";\n\n/** Finality thresholds the header carries: Fast Transfer (confirmed) vs Standard (finalized). */\nexport const FINALITY_FAST = 1000;\nexport const FINALITY_STANDARD = 2000;\n\nexport const cctp = {\n supportsChain(chain: string): boolean {\n return isEvm(chain) && !!CCTP_DOMAINS[`eip155:${evmRef(chain)}`];\n },\n supports(from: string, to: string): boolean {\n return from !== to && this.supportsChain(from) && this.supportsChain(to);\n },\n};\n","import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`). Without the destination chain's URL the status\n * reaches \"completed\" only through the id `claimSwap2` returns for a claim the\n * account saw succeed; a bare claim hash stays \"pending\" (hash kept).\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n /** The nonce's state on the destination: null without an RPC there, \"unknown\" when the configured RPC fails to answer. */\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null | \"unknown\"> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return \"unknown\";\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n // A message without a readable nonce cannot be checked on the destination even with an RPC there.\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? \"unknown\" : null;\n if (done === true) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n if (ref.destTxHash) {\n // A claim the sending account saw included and succeed is the mint: receiveMessage reverts once the\n // nonce is used, so a successful one minted this message. Without a destination read that is completed;\n // a destination read that does not show it yet is a node behind the claim, not a claim to send again.\n if (ref.destTxConfirmed === true) {\n return done === false\n ? {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}}\n : {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n // A claim was sent, but nothing here can read whether it minted (no destination RPC, or one that did\n // not answer): the hash is kept and the swap stays pending — a hash alone is not a mint.\n if (done !== false) return {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n","/**\n * Activity recognition for Circle CCTP V2 on every domain in `config.ts`:\n * `depositForBurn` on TokenMessengerV2 is our source leg (\"Bridged USDC\"), and\n * `receiveMessage` on MessageTransmitterV2 is the claim that mints on the\n * destination (\"Received USDC via CCTP\") — whoever paid the gas, the USDC lands\n * on the `mintRecipient`. Both are `bridge`; the other leg's hash is only known\n * through the kit's journal / Circle's attestation API, so `related` stays empty.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {CCTP_DOMAINS} from \"./config.js\";\n\nexport const CCTP_MODULE = \"@anywalletkit/protocol-swap2-cctp\";\n\n/** depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32) — TokenMessengerV2 */\nexport const CCTP_DEPOSIT_FOR_BURN = \"0x8e0250ee\";\n/** receiveMessage(bytes,bytes) — MessageTransmitterV2 */\nexport const CCTP_RECEIVE_MESSAGE = \"0x57ecfd28\";\n\nexport function describeCctpActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n const domain = CCTP_DOMAINS[tx.chain];\n if (!domain) return null;\n const subtitle = `CCTP · ${chainLabel(tx.chain)}`;\n if (matchesCall(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Bridged USDC\"});\n }\n if (matchesCall(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Received USDC via CCTP\"});\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAkC;;;ACMlC,kBAA4B;AAYrB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAEtC,IAAM,IAAI,CAAC,SAAiB,QAAgB,MAAc,UAA8B;AAAA,EACtF,OAAO,UAAU,OAAO;AAAA,EAAI;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAM;AAAA,EAAM,gBAAgB;AAAA,EAAoB,oBAAoB;AACnH;AAGO,IAAM,eAAqD,OAAO,OAAO,OAAO,YAAY;AAAA,EACjG,EAAE,GAAG,GAAG,YAAY,4CAA4C;AAAA,EAChE,EAAE,OAAO,GAAG,aAAa,4CAA4C;AAAA,EACrE,EAAE,IAAI,GAAG,cAAc,4CAA4C;AAAA,EACnE,EAAE,OAAO,GAAG,YAAY,4CAA4C;AAAA,EACpE,EAAE,MAAM,GAAG,QAAQ,4CAA4C;AAAA,EAC/D,EAAE,KAAK,GAAG,eAAe,4CAA4C;AAAA,EACrE,EAAE,KAAK,IAAI,YAAY,4CAA4C;AAAA,EACnE,EAAE,OAAO,I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A,GAAE,cAAc,IAAI,CAAC;AACnC;;;AFzbO,IAAM,oBAAN,cAAgC,kCAAoB;AAAA,EACtC;AAAA,EACnB,YAAY,SAAmC,QAAyB;AACtE,UAAM,SAAS,MAAM;AACrB,SAAK,WAAW,aAAa,MAAM;AAAA,EACrC;AAAA,EACmB,eAAe,OAAwB;AACxD,WAAO,KAAQ,cAAc,KAAK;AAAA,EACpC;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,KAAQ,SAAS,WAAW,OAAO;AAAA,EAC5C;AACF;","names":["import_util","d"]}
|
package/dist/protocol.js
CHANGED
package/dist/provider.cjs
CHANGED
|
@@ -179,7 +179,7 @@ function cctpProvider(config = {}) {
|
|
|
179
179
|
const used = await c.readContract({ address: (0, import_viem.getAddress)(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: "usedNonces", args: [nonce] });
|
|
180
180
|
return used !== 0n;
|
|
181
181
|
} catch {
|
|
182
|
-
return
|
|
182
|
+
return "unknown";
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
return {
|
|
@@ -347,9 +347,14 @@ function cctpProvider(config = {}) {
|
|
|
347
347
|
if (!m) return { state: "pending", depositReceived: false, claim };
|
|
348
348
|
const nonce = m.decodedMessage?.nonce;
|
|
349
349
|
if (m.status === "complete" && isHexData(m.attestation) && isHexData(m.message)) {
|
|
350
|
-
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;
|
|
351
|
-
if (done) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
352
|
-
if (
|
|
350
|
+
const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? "unknown" : null;
|
|
351
|
+
if (done === true) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
|
|
352
|
+
if (ref.destTxHash) {
|
|
353
|
+
if (ref.destTxConfirmed === true) {
|
|
354
|
+
return done === false ? { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } } : { state: "completed", destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
355
|
+
}
|
|
356
|
+
if (done !== false) return { state: "pending", depositReceived: true, destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
|
|
357
|
+
}
|
|
353
358
|
return { state: "action-required", depositReceived: true, claim: { ...claim, ready: true } };
|
|
354
359
|
}
|
|
355
360
|
return { state: "pending", depositReceived: true, claim };
|
package/dist/provider.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts","../src/activity.ts","../src/config.ts"],"sourcesContent":["import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`) so the status reaches \"completed\" by itself.\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return null;\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;\n if (done) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n // No destination RPC: a recorded claim hash is the best evidence we have.\n if (done === null && ref.destTxHash) return {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n","/**\n * Activity recognition for Circle CCTP V2 on every domain in `config.ts`:\n * `depositForBurn` on TokenMessengerV2 is our source leg (\"Bridged USDC\"), and\n * `receiveMessage` on MessageTransmitterV2 is the claim that mints on the\n * destination (\"Received USDC via CCTP\") — whoever paid the gas, the USDC lands\n * on the `mintRecipient`. Both are `bridge`; the other leg's hash is only known\n * through the kit's journal / Circle's attestation API, so `related` stays empty.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {CCTP_DOMAINS} from \"./config.js\";\n\nexport const CCTP_MODULE = \"@anywalletkit/protocol-swap2-cctp\";\n\n/** depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32) — TokenMessengerV2 */\nexport const CCTP_DEPOSIT_FOR_BURN = \"0x8e0250ee\";\n/** receiveMessage(bytes,bytes) — MessageTransmitterV2 */\nexport const CCTP_RECEIVE_MESSAGE = \"0x57ecfd28\";\n\nexport function describeCctpActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n const domain = CCTP_DOMAINS[tx.chain];\n if (!domain) return null;\n const subtitle = `CCTP · ${chainLabel(tx.chain)}`;\n if (matchesCall(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Bridged USDC\"});\n }\n if (matchesCall(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Received USDC via CCTP\"});\n }\n return null;\n}\n","// Circle CCTP V2 — mainnet domains, contracts and the native USDC each domain\n// mints. Sources (read 2026-10-10, Arc + Morph 2026-10-14): developers.circle.com/cctp/evm-smart-contracts\n// (domains + TokenMessengerV2 / MessageTransmitterV2, the same addresses on\n// every EVM chain except EDGE), developers.circle.com/stablecoins/usdc-contract-addresses\n// (native USDC). Only chains whose USDC is Circle-native are listed: CCTP\n// burns native USDC, a bridged USDC.e (BSC, Gnosis) cannot ride it.\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\n\nexport interface CctpDomain {\n caip2: string;\n chainId: number;\n domain: number;\n name: string;\n usdc: string;\n tokenMessenger: string;\n messageTransmitter: string;\n}\n\nexport const TOKEN_MESSENGER_V2 = \"0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d\";\nexport const MESSAGE_TRANSMITTER_V2 = \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\";\n\nconst d = (chainId: number, domain: number, name: string, usdc: string): CctpDomain => ({\n caip2: `eip155:${chainId}`, chainId, domain, name, usdc, tokenMessenger: TOKEN_MESSENGER_V2, messageTransmitter: MESSAGE_TRANSMITTER_V2,\n});\n\n/** CAIP-2 → CCTP domain. */\nexport const CCTP_DOMAINS: Readonly<Record<string, CctpDomain>> = Object.freeze(Object.fromEntries([\n d(1, 0, \"Ethereum\", \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\"),\n d(43114, 1, \"Avalanche\", \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\"),\n d(10, 2, \"OP Mainnet\", \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\"),\n d(42161, 3, \"Arbitrum\", \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"),\n d(8453, 6, \"Base\", \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"),\n d(137, 7, \"Polygon PoS\", \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"),\n d(130, 10, \"Unichain\", \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\"),\n d(59144, 11, \"Linea\", \"0x176211869cA2b568f2A7D4EE941E073a821EE1ff\"),\n d(146, 13, \"Sonic\", \"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"),\n d(480, 14, \"World Chain\", \"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"),\n d(143, 15, \"Monad\", \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\"),\n d(1329, 16, \"Sei\", \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\"),\n d(999, 19, \"HyperEVM\", \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\"),\n d(57073, 21, \"Ink\", \"0x2D270e6886d130D724215A266106e6832161EAEd\"),\n d(98866, 22, \"Plume\", \"0x222365EF19F7947e5484218551B56bb3965Aa7aF\"),\n d(9745, 33, \"Plasma\", \"0x2d661C89D812261039AF9764eceaAee884f5F67F\"),\n d(196, 37, \"X Layer\", \"0xB6CEceAB302E2E4948951eE7843FC24E92933061\"),\n // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /\n // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and\n // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its\n // 6-decimal ERC-20 interface, which is what CCTP burns and mints.\n d(5042, 26, \"Arc\", \"0x3600000000000000000000000000000000000000\"),\n d(2818, 30, \"Morph\", \"0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B\"),\n].map((x) => [x.caip2, x])));\n\n/** CCTP domain → entry. */\nexport const CCTP_BY_DOMAIN: Readonly<Record<number, CctpDomain>> = Object.freeze(\n Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x])),\n);\n\n/** Solana is CCTP domain 5 (not executed by this package yet: the engine runs calldata on EVM only). */\nexport const CCTP_SOLANA_DOMAIN = 5;\n\nexport const CCTP_API = \"https://iris-api.circle.com\";\n\n/** Finality thresholds the header carries: Fast Transfer (confirmed) vs Standard (finalized). */\nexport const FINALITY_FAST = 1000;\nexport const FINALITY_STANDARD = 2000;\n\nexport const cctp = {\n supportsChain(chain: string): boolean {\n return isEvm(chain) && !!CCTP_DOMAINS[`eip155:${evmRef(chain)}`];\n },\n supports(from: string, to: string): boolean {\n return from !== to && this.supportsChain(from) && this.supportsChain(to);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyI;;;ACQzI,sBAAwD;;;ACHxD,kBAA4B;AAYrB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAEtC,IAAM,IAAI,CAAC,SAAiB,QAAgB,MAAc,UAA8B;AAAA,EACtF,OAAO,UAAU,OAAO;AAAA,EAAI;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAM;AAAA,EAAM,gBAAgB;AAAA,EAAoB,oBAAoB;AACnH;AAGO,IAAM,eAAqD,OAAO,OAAO,OAAO,YAAY;AAAA,EACjG,EAAE,GAAG,GAAG,YAAY,4CAA4C;AAAA,EAChE,EAAE,OAAO,GAAG,aAAa,4CAA4C;AAAA,EACrE,EAAE,IAAI,GAAG,cAAc,4CAA4C;AAAA,EACnE,EAAE,OAAO,GAAG,YAAY,4CAA4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,SAAS,IAAI,IAAI,KAAK,IAAI,MAAM;AAEpG,MAAI,OAAO,eAAe,OAAO,QAAQ,OAAO;AAC9C,QAAI,KAAC,uBAAU,OAAO,WAAW,EAAG,QAAO;AAC3C,QAAI,cAAc,YAAY,UAAM,qBAAI,wBAAW,OAAO,WAAW,GAAG,EAAC,MAAM,GAAE,CAAC,EAAE,YAAY,EAAG,QAAO,qBAAqB,aAAa;AAAA,EAC9I;AACA,MAAI,CAAC,KAAK,WAAW,IAAI,IAAI,EAAG,QAAO,mBAAmB,SAAS;AACnE,MAAI,WAAW,qBAAU,QAAO;AAChC,MAAI,cAAc,iBAAiB,cAAc,kBAAmB,QAAO,sBAAsB,SAAS;AAC1G,MAAI,UAAU,UAAU,SAAS,SAAS,MAAO,QAAO,qBAAqB,MAAM,yBAAyB,KAAK;AAEjH,OAAK,2BAA2B,KAAK,MAAM,QAAQ,IAAI,CAAC,KAAK,MAAM,cAAc,QAAQ,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI,SAAS,GAAI,QAAO;AACzI,MAAI,MAAM,cAAc,WAAW,UAAa,MAAM,aAAa,WAAW,OAAO,SAAS,EAAG,QAAO;AACxG,SAAO;AACT;AAOO,IAAM,WAA0E,OAAO,OAAO;AAAA,EACnG,aAAa,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACzE,UAAU,CAAC,UAAqC,iBAAiB,KAAK;AAAA,EACtE,cAAc;AAAA,EACd,aAAa;AACf,CAAC;AACD,SAAS,iBAAiB,OAAkC;AAC1D,QAAMA,KAAI,OAAO,UAAU,eAAe,KAAK,cAAc,KAAK,IAAI,aAAa,KAAK,IAAI;AAC5F,SAAOA,KAAI,CAACA,GAAE,cAAc,IAAI,CAAC;AACnC;","names":["import_util","d"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts","../src/activity.ts","../src/config.ts"],"sourcesContent":["import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`). Without the destination chain's URL the status\n * reaches \"completed\" only through the id `claimSwap2` returns for a claim the\n * account saw succeed; a bare claim hash stays \"pending\" (hash kept).\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n /** The nonce's state on the destination: null without an RPC there, \"unknown\" when the configured RPC fails to answer. */\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null | \"unknown\"> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return \"unknown\";\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n // A message without a readable nonce cannot be checked on the destination even with an RPC there.\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : client(parsed.dst.caip2) ? \"unknown\" : null;\n if (done === true) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n if (ref.destTxHash) {\n // A claim the sending account saw included and succeed is the mint: receiveMessage reverts once the\n // nonce is used, so a successful one minted this message. Without a destination read that is completed;\n // a destination read that does not show it yet is a node behind the claim, not a claim to send again.\n if (ref.destTxConfirmed === true) {\n return done === false\n ? {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}}\n : {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n // A claim was sent, but nothing here can read whether it minted (no destination RPC, or one that did\n // not answer): the hash is kept and the swap stays pending — a hash alone is not a mint.\n if (done !== false) return {state: \"pending\", depositReceived: true, destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n }\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n","/**\n * Activity recognition for Circle CCTP V2 on every domain in `config.ts`:\n * `depositForBurn` on TokenMessengerV2 is our source leg (\"Bridged USDC\"), and\n * `receiveMessage` on MessageTransmitterV2 is the claim that mints on the\n * destination (\"Received USDC via CCTP\") — whoever paid the gas, the USDC lands\n * on the `mintRecipient`. Both are `bridge`; the other leg's hash is only known\n * through the kit's journal / Circle's attestation API, so `related` stays empty.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {chainLabel, describeSwapLike, matchesCall} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {CCTP_DOMAINS} from \"./config.js\";\n\nexport const CCTP_MODULE = \"@anywalletkit/protocol-swap2-cctp\";\n\n/** depositForBurn(uint256,uint32,bytes32,address,bytes32,uint256,uint32) — TokenMessengerV2 */\nexport const CCTP_DEPOSIT_FOR_BURN = \"0x8e0250ee\";\n/** receiveMessage(bytes,bytes) — MessageTransmitterV2 */\nexport const CCTP_RECEIVE_MESSAGE = \"0x57ecfd28\";\n\nexport function describeCctpActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n const domain = CCTP_DOMAINS[tx.chain];\n if (!domain) return null;\n const subtitle = `CCTP · ${chainLabel(tx.chain)}`;\n if (matchesCall(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Bridged USDC\"});\n }\n if (matchesCall(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {\n return describeSwapLike(tx, ctx, {protocol: CCTP_MODULE, subtitle, kind: \"bridge\", title: \"Received USDC via CCTP\"});\n }\n return null;\n}\n","// Circle CCTP V2 — mainnet domains, contracts and the native USDC each domain\n// mints. Sources (read 2026-10-10, Arc + Morph 2026-10-14): developers.circle.com/cctp/evm-smart-contracts\n// (domains + TokenMessengerV2 / MessageTransmitterV2, the same addresses on\n// every EVM chain except EDGE), developers.circle.com/stablecoins/usdc-contract-addresses\n// (native USDC). Only chains whose USDC is Circle-native are listed: CCTP\n// burns native USDC, a bridged USDC.e (BSC, Gnosis) cannot ride it.\nimport {evmRef, isEvm} from \"@anywalletkit/protocol-swap2-core/util\";\n\nexport interface CctpDomain {\n caip2: string;\n chainId: number;\n domain: number;\n name: string;\n usdc: string;\n tokenMessenger: string;\n messageTransmitter: string;\n}\n\nexport const TOKEN_MESSENGER_V2 = \"0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d\";\nexport const MESSAGE_TRANSMITTER_V2 = \"0x81D40F21F12A8F0E3252Bccb954D722d4c464B64\";\n\nconst d = (chainId: number, domain: number, name: string, usdc: string): CctpDomain => ({\n caip2: `eip155:${chainId}`, chainId, domain, name, usdc, tokenMessenger: TOKEN_MESSENGER_V2, messageTransmitter: MESSAGE_TRANSMITTER_V2,\n});\n\n/** CAIP-2 → CCTP domain. */\nexport const CCTP_DOMAINS: Readonly<Record<string, CctpDomain>> = Object.freeze(Object.fromEntries([\n d(1, 0, \"Ethereum\", \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\"),\n d(43114, 1, \"Avalanche\", \"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E\"),\n d(10, 2, \"OP Mainnet\", \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\"),\n d(42161, 3, \"Arbitrum\", \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\"),\n d(8453, 6, \"Base\", \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\"),\n d(137, 7, \"Polygon PoS\", \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"),\n d(130, 10, \"Unichain\", \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\"),\n d(59144, 11, \"Linea\", \"0x176211869cA2b568f2A7D4EE941E073a821EE1ff\"),\n d(146, 13, \"Sonic\", \"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"),\n d(480, 14, \"World Chain\", \"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"),\n d(143, 15, \"Monad\", \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\"),\n d(1329, 16, \"Sei\", \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\"),\n d(999, 19, \"HyperEVM\", \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\"),\n d(57073, 21, \"Ink\", \"0x2D270e6886d130D724215A266106e6832161EAEd\"),\n d(98866, 22, \"Plume\", \"0x222365EF19F7947e5484218551B56bb3965Aa7aF\"),\n d(9745, 33, \"Plasma\", \"0x2d661C89D812261039AF9764eceaAee884f5F67F\"),\n d(196, 37, \"X Layer\", \"0xB6CEceAB302E2E4948951eE7843FC24E92933061\"),\n // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /\n // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and\n // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its\n // 6-decimal ERC-20 interface, which is what CCTP burns and mints.\n d(5042, 26, \"Arc\", \"0x3600000000000000000000000000000000000000\"),\n d(2818, 30, \"Morph\", \"0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B\"),\n].map((x) => [x.caip2, x])));\n\n/** CCTP domain → entry. */\nexport const CCTP_BY_DOMAIN: Readonly<Record<number, CctpDomain>> = Object.freeze(\n Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x])),\n);\n\n/** Solana is CCTP domain 5 (not executed by this package yet: the engine runs calldata on EVM only). */\nexport const CCTP_SOLANA_DOMAIN = 5;\n\nexport const CCTP_API = \"https://iris-api.circle.com\";\n\n/** Finality thresholds the header carries: Fast Transfer (confirmed) vs Standard (finalized). */\nexport const FINALITY_FAST = 1000;\nexport const FINALITY_STANDARD = 2000;\n\nexport const cctp = {\n supportsChain(chain: string): boolean {\n return isEvm(chain) && !!CCTP_DOMAINS[`eip155:${evmRef(chain)}`];\n },\n supports(from: string, to: string): boolean {\n return from !== to && this.supportsChain(from) && this.supportsChain(to);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyI;;;ACQzI,sBAAwD;;;ACHxD,kBAA4B;AAYrB,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAEtC,IAAM,IAAI,CAAC,SAAiB,QAAgB,MAAc,UAA8B;AAAA,EACtF,OAAO,UAAU,OAAO;AAAA,EAAI;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAM;AAAA,EAAM,gBAAgB;AAAA,EAAoB,oBAAoB;AACnH;AAGO,IAAM,eAAqD,OAAO,OAAO,OAAO,YAAY;AAAA,EACjG,EAAE,GAAG,GAAG,YAAY,4CAA4C;AAAA,EAChE,EAAE,OAAO,GAAG,aAAa,4CAA4C;AAAA,EACrE,EAAE,IAAI,GAAG,cAAc,4CAA4C;AAAA,EACnE,EAAE,OAAO,GAAG,YAAY,4CAA4C;AAAA,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,iBAAiB,OAAkC;AAC1D,QAAMA,KAAI,OAAO,UAAU,eAAe,KAAK,cAAc,KAAK,IAAI,aAAa,KAAK,IAAI;AAC5F,SAAOA,KAAI,CAACA,GAAE,cAAc,IAAI,CAAC;AACnC;","names":["import_util","d"]}
|
package/dist/provider.d.cts
CHANGED
|
@@ -12,7 +12,9 @@ interface CctpProviderConfig {
|
|
|
12
12
|
/**
|
|
13
13
|
* JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider
|
|
14
14
|
* verifies the contracts before the burn and detects the mint on the
|
|
15
|
-
* destination (`usedNonces`)
|
|
15
|
+
* destination (`usedNonces`). Without the destination chain's URL the status
|
|
16
|
+
* reaches "completed" only through the id `claimSwap2` returns for a claim the
|
|
17
|
+
* account saw succeed; a bare claim hash stays "pending" (hash kept).
|
|
16
18
|
*/
|
|
17
19
|
rpcUrls?: Readonly<Record<string, string>>;
|
|
18
20
|
/** Local lifetime of a quote (fees are stable; default 60 s). */
|
package/dist/provider.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ interface CctpProviderConfig {
|
|
|
12
12
|
/**
|
|
13
13
|
* JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider
|
|
14
14
|
* verifies the contracts before the burn and detects the mint on the
|
|
15
|
-
* destination (`usedNonces`)
|
|
15
|
+
* destination (`usedNonces`). Without the destination chain's URL the status
|
|
16
|
+
* reaches "completed" only through the id `claimSwap2` returns for a claim the
|
|
17
|
+
* account saw succeed; a bare claim hash stays "pending" (hash kept).
|
|
16
18
|
*/
|
|
17
19
|
rpcUrls?: Readonly<Record<string, string>>;
|
|
18
20
|
/** Local lifetime of a quote (fees are stable; default 60 s). */
|
package/dist/provider.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anywalletkit/protocol-swap2-cctp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Circle CCTP V2 for the swap2 engine: native USDC between EVM chains by burn-and-mint (Fast Transfer or Standard), attestation via Circle's Iris API, two-phase delivery with the user's own receiveMessage claim. Bound to Circle's documented contracts and native USDC per domain.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://docs.anywallet.tech",
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"viem": "^2.57.2",
|
|
53
|
-
"@anywalletkit/swap2-
|
|
54
|
-
"@anywalletkit/
|
|
53
|
+
"@anywalletkit/protocol-swap2-core": "0.10.1",
|
|
54
|
+
"@anywalletkit/swap2-assets": "0.2.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@anywalletkit/core": "0.
|
|
57
|
+
"@anywalletkit/core": "0.8.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^22",
|
|
61
61
|
"vitest": "^5.0.3",
|
|
62
|
-
"@anywalletkit/core": "0.
|
|
63
|
-
"@anywalletkit/conformance": "0.
|
|
62
|
+
"@anywalletkit/core": "0.8.0",
|
|
63
|
+
"@anywalletkit/conformance": "0.5.1"
|
|
64
64
|
},
|
|
65
65
|
"keywords": [
|
|
66
66
|
"swap2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import type {RemotePins} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {createPublicClient, decodeFunctionData, encodeFunctionData, getAddress, http, isAddress, pad, parseAbi, zeroHash, type Hex} from \"viem\";\nimport {describeCctpActivity} from \"./activity.js\";\nimport {ccAsset} from \"@anywalletkit/swap2-assets\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {CCTP_API, CCTP_BY_DOMAIN, CCTP_DOMAINS, FINALITY_FAST, FINALITY_STANDARD, cctp as cctpCfg, type CctpDomain} from \"./config.js\";\nimport {bigintToNumber} from \"@anywalletkit/core\";\n\n/**\n * Circle CCTP V2 — native USDC between chains by burn-and-mint, no spread, no\n * aggregator fee. TWO-PHASE: `depositForBurn` on the source burns the USDC and\n * emits the message; Circle's attestation service (Iris) signs it once the\n * source reached the requested finality; `receiveMessage(message, attestation)`\n * on the destination mints. That second transaction is the user's: the engine\n * exposes it through `buildClaim` / `claimSwap2` (status \"action-required\").\n *\n * - Fast Transfer (finality 1000, confirmed, ~seconds–minutes) costs a fee in\n * bps that Circle publishes per pair; Standard (2000, finalized, ~15 min)\n * is free. `mode: \"auto\"` takes Fast when the pair offers it and the Fast\n * allowance covers the amount, else Standard.\n * - `maxFee` sent on-chain is the published fee (plus a small buffer) and is\n * the only thing that can be deducted: the guaranteed output is\n * amount − maxFee. `preflightDeposit` re-reads Circle's published fee right\n * before the burn (the deployed TokenMessengerV2 has no on-chain\n * `getMinFeeAmount`/`minFee` — both revert on Ethereum, Base, Arbitrum,\n * 2026-10-12) and, with an RPC for the source chain, the transmitter's\n * `localDomain()` on the very contract the calldata targets.\n * - Everything is bound to Circle's documented contract addresses and the\n * native USDC of each domain; a catalog USDC that is not the native one\n * refuses the route (USDC.e cannot be burnt).\n */\n\nconst TOKEN_MESSENGER_ABI = parseAbi([\n \"function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)\",\n \"function localMessageTransmitter() view returns (address)\",\n]);\nconst MESSAGE_TRANSMITTER_ABI = parseAbi([\n \"function receiveMessage(bytes message, bytes attestation) returns (bool)\",\n \"function localDomain() view returns (uint32)\",\n \"function usedNonces(bytes32 nonce) view returns (uint256)\",\n]);\n\nconst EVM_PLACEHOLDER = \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\";\nconst DEFAULT_QUOTE_TTL_MS = 60_000;\n/** Fallback gas limit: a depositForBurn runs ~110–150k, receiveMessage ~150–200k. */\nconst GAS_DEPOSIT = \"200000\";\nconst GAS_CLAIM = \"260000\";\n\nexport type CctpMode = \"auto\" | \"fast\" | \"standard\";\n\nexport interface CctpProviderConfig {\n enabled?: boolean;\n /** Circle attestation API base (default https://iris-api.circle.com). */\n apiUrl?: string;\n /** Fast when offered and within the allowance (default), or force one path. */\n mode?: CctpMode;\n /** Extra headroom on the published Fast fee, in percent of the fee (default 10). The excess is never charged. */\n feeBufferPct?: number;\n /**\n * JSON-RPC URLs per CAIP-2 chain. Optional, but with them the provider\n * verifies the contracts before the burn and detects the mint on the\n * destination (`usedNonces`) so the status reaches \"completed\" by itself.\n */\n rpcUrls?: Readonly<Record<string, string>>;\n /** Local lifetime of a quote (fees are stable; default 60 s). */\n quoteTtlMs?: number;\n /** Injectable for tests. */\n fetchImpl?: typeof fetch;\n}\n\ninterface FeeRow { finalityThreshold: number; minimumFee: number }\ninterface ApiMessage {\n message?: string;\n eventNonce?: string;\n attestation?: string | null;\n status?: string;\n delayReason?: string | null;\n cctpVersion?: number;\n decodedMessage?: {\n sourceDomain?: string; destinationDomain?: string; nonce?: string; mintRecipient?: string;\n decodedMessageBody?: {amount?: string; maxFee?: string; feeExecuted?: string; expirationBlock?: string; mintRecipient?: string; burnToken?: string};\n };\n}\n\nconst isHexData = (v: unknown): v is Hex => typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);\nconst same = (a: string | undefined, b: string) => !!a && a.toLowerCase() === b.toLowerCase();\n\n/** `amount × bps` rounded up; `bps` may be fractional (Circle publishes 1.3). */\nfunction feeFor(amount: bigint, bps: number, bufferPct: number): bigint {\n const hundredths = BigInt(Math.round(bps * 100)); // 1.3 bps → 130\n const fee = (amount * hundredths + 999_999n) / 1_000_000n;\n if (fee === 0n) return 0n;\n return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9_999n) / 10_000n;\n}\n\n/**\n * The contracts a CCTP claim may call on `chain`: its MessageTransmitter (`receiveMessage`). Pass it\n * as `claimTargets` to a remote provider stub so the app, not the server, decides (round 3, M24).\n */\nexport function cctpClaimTargets(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.messageTransmitter] : [];\n}\n\nexport function cctpProvider(config: CctpProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const api = (config.apiUrl ?? CCTP_API).replace(/\\/+$/, \"\");\n if (!/^https?:\\/\\//.test(api)) throw new Error(\"cctp: apiUrl must use http or https\");\n const mode: CctpMode = config.mode ?? \"auto\";\n if (![\"auto\", \"fast\", \"standard\"].includes(mode)) throw new Error(\"cctp: mode must be auto | fast | standard\");\n const bufferPct = config.feeBufferPct ?? 10;\n if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error(\"cctp: feeBufferPct must be between 0 and 100\");\n const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;\n if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 300_000) throw new Error(\"cctp: quoteTtlMs must be an integer between 1 and 300000\");\n const doFetch = config.fetchImpl ?? fetch;\n const rpcUrls = Object.freeze({...(config.rpcUrls ?? {})});\n\n const client = (caip2: string) => {\n const url = rpcUrls[caip2];\n return url ? createPublicClient({transport: http(url, {fetchOptions: {}, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {})} as never), ccipRead: false}) : null;\n };\n\n async function getJson<T>(path: string, signal?: AbortSignal): Promise<T | null> {\n const res = await doFetch(`${api}${path}`, {headers: {accept: \"application/json\"}, signal: signal ?? timeoutSignal(12_000)});\n if (res.status === 404) return null;\n if (!res.ok) throw new Error(`cctp: ${path} → ${res.status}`);\n return (await res.json()) as T;\n }\n\n /** Circle's published fee per finality threshold, in bps of the burnt amount. */\n const feeRows = (src: CctpDomain, dst: CctpDomain, signal?: AbortSignal) =>\n getJson<FeeRow[]>(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);\n\n /** The native USDC of a domain, cross-checked against the asset catalog when it knows the chain. */\n function usdcOf(dom: CctpDomain): string | null {\n const known = ccAsset(dom.caip2, \"USDC\");\n if (known && (!known.contract || !same(known.contract, dom.usdc))) return null; // catalog has a USDC that is not Circle's → refuse\n return dom.usdc;\n }\n\n function parseIntent(intentId: string): {src: CctpDomain; dst: CctpDomain; threshold: number} | null {\n const [tag, s, dd, t] = intentId.split(\":\");\n if (tag !== \"cctp\") return null;\n const src = CCTP_BY_DOMAIN[Number(s)];\n const dst = CCTP_BY_DOMAIN[Number(dd)];\n const threshold = Number(t);\n if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;\n return {src, dst, threshold};\n }\n\n async function fetchMessage(src: CctpDomain, sourceTxHash: string): Promise<ApiMessage | null> {\n const out = await getJson<{messages?: ApiMessage[]}>(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);\n const m = out?.messages?.find((x) => x.cctpVersion === undefined || x.cctpVersion === 2);\n return m ?? null;\n }\n\n async function minted(dst: CctpDomain, nonce: Hex): Promise<boolean | null> {\n const c = client(dst.caip2);\n if (!c) return null;\n try {\n const used = await c.readContract({address: getAddress(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"usedNonces\", args: [nonce]});\n return used !== 0n;\n } catch {\n return null;\n }\n }\n\n return {\n name: \"cctp\",\n claimTargets: cctpClaimTargets,\n describeActivity: describeCctpActivity,\n enabled: () => config.enabled ?? true,\n supportsChain: (chain: string) => cctpCfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cctpCfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n const src = CCTP_DOMAINS[from.chain];\n const dst = CCTP_DOMAINS[to.chain];\n if (!src || !dst || from.chain === to.chain) return false;\n if (from.token.toUpperCase() !== \"USDC\") return false;\n // Destination is given as an address (zero = native): only the native USDC of the destination domain.\n return same(to.token, dst.usdc) || to.token.toUpperCase() === \"USDC\";\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n if (params.flex) return null; // the amount is baked into the calldata\n const src = CCTP_DOMAINS[params.sourceChain];\n const dst = CCTP_DOMAINS[params.destChain];\n if (!src || !dst || src === dst) return null;\n if (params.sourceToken.toUpperCase() !== \"USDC\") return null;\n if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return null;\n const usdc = usdcOf(src);\n if (!usdc) { params.onRefusal?.(\"catalog USDC on the source chain is not Circle's native USDC\"); return null; }\n if (!/^\\d+$/.test(params.amountIn)) return null;\n const amount = BigInt(params.amountIn);\n if (amount <= 0n) return null;\n // The placeholder prices a dry quote; a live one without a recipient would mint to it (round 3, H8).\n const recipient = params.destAddress || (params.dry !== false ? EVM_PLACEHOLDER : \"\");\n if (!recipient) { params.onRefusal?.(\"a live quote needs a recipient\"); return null; }\n if (!isAddress(recipient)) { params.onRefusal?.(\"destination must be an EVM address\"); return null; }\n\n try {\n const fees = await feeRows(src, dst, signal);\n if (!fees || !Array.isArray(fees) || fees.length === 0) { params.onRefusal?.(\"Circle publishes no fee for this pair\"); return null; }\n const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);\n const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);\n let threshold: number;\n let bps: number;\n if (mode === \"standard\") {\n if (!standard) { params.onRefusal?.(\"Standard Transfer is not offered for this pair\"); return null; }\n threshold = FINALITY_STANDARD; bps = standard.minimumFee;\n } else {\n let fastOk = !!fast;\n if (fastOk) {\n const allowance = await getJson<{allowance?: number}>(\"/v2/fastBurn/USDC/allowance\", signal).catch(() => null);\n // The allowance is in whole USDC; refuse Fast when it cannot cover the burn.\n if (typeof allowance?.allowance === \"number\" && allowance.allowance * 1e6 < bigintToNumber(amount)) fastOk = false;\n }\n if (fastOk) { threshold = FINALITY_FAST; bps = fast!.minimumFee; }\n else if (mode === \"fast\") { params.onRefusal?.(fast ? \"Fast Transfer allowance is exhausted\" : \"Fast Transfer is not offered for this pair\"); return null; }\n else if (standard) { threshold = FINALITY_STANDARD; bps = standard.minimumFee; }\n else { params.onRefusal?.(\"neither Fast nor Standard is offered\"); return null; }\n }\n if (!Number.isFinite(bps) || bps < 0) return null;\n const maxFee = feeFor(amount, bps, bufferPct);\n if (maxFee >= amount) { params.onRefusal?.(\"amount is below the Fast Transfer fee\"); return null; }\n const out = amount - maxFee;\n if (params.minAmountOut !== undefined && out < BigInt(params.minAmountOut)) return null;\n\n const data = encodeFunctionData({\n abi: TOKEN_MESSENGER_ABI,\n functionName: \"depositForBurn\",\n args: [amount, dst.domain, pad(getAddress(recipient), {size: 32}), getAddress(usdc), zeroHash, maxFee, threshold],\n });\n const eta = threshold === FINALITY_FAST ? (src.domain === 0 ? 180 : 45) : (src.domain === 0 ? 1200 : 1000);\n return {\n provider: \"cctp\",\n intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,\n depositAddress: \"\",\n depositMemo: null,\n txRequest: {to: src.tokenMessenger, data, value: \"0\", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger},\n sourceAmount: amount.toString(),\n destAmount: out.toString(),\n minDestAmount: out.toString(),\n feeUsd: bigintToNumber(maxFee) / 1e6,\n fees: maxFee > 0n ? [{type: \"protocol\", amount: maxFee.toString(), token: usdc, included: true, description: `Circle Fast Transfer fee (${bps} bps + ${bufferPct}% buffer, unused part is not charged)`}] : [],\n etaSeconds: eta,\n reliability: 0.99,\n validUntilMs: Date.now() + quoteTtlMs,\n providerData: {\n sourceDomain: String(src.domain), destinationDomain: String(dst.domain), finalityThreshold: String(threshold),\n maxFee: maxFee.toString(), mintRecipient: getAddress(recipient), claimChain: dst.caip2, claimRequired: \"1\",\n },\n };\n } catch {\n return null;\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n const parsed = parseIntent(quote.intentId);\n if (!tx || !parsed) throw new Error(\"swap2: CCTP quote has no transaction request\");\n return {\n chain: parsed.src.caip2,\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 };\n },\n\n /**\n * Fast: Circle's CURRENT fee (same source and rounding as the quote, without\n * the buffer) still fits `maxFee` — Iris would otherwise hold the burn\n * until it times out to Standard. With a source RPC: the target really is\n * CCTP for this domain.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const parsed = parseIntent(quote.intentId);\n if (!parsed) throw new Error(\"cctp: malformed intent id\");\n if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error(\"cctp: deposit target is not the TokenMessengerV2 of the source domain\");\n if (parsed.threshold === FINALITY_FAST) {\n const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);\n if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error(\"cctp: Circle no longer publishes a Fast Transfer fee for this pair — re-quote\");\n const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);\n const maxFee = BigInt(quote.providerData?.maxFee ?? \"0\");\n if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} — re-quote`);\n }\n const c = client(parsed.src.caip2);\n if (!c) return;\n const transmitter = await c.readContract({address: getAddress(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: \"localMessageTransmitter\"});\n if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error(\"cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2\");\n const domain = await c.readContract({address: getAddress(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: \"localDomain\"});\n if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed) return {state: \"failed\"};\n const claim = {chain: parsed.dst.caip2, ready: false};\n if (!ref.sourceTxHash) return {state: \"pending\", claim};\n try {\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m) return {state: \"pending\", depositReceived: false, claim};\n const nonce = m.decodedMessage?.nonce;\n if (m.status === \"complete\" && isHexData(m.attestation) && isHexData(m.message)) {\n const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;\n if (done) return {state: \"completed\", claim: {...claim, ready: false}, ...(ref.destTxHash ? {destTxHash: ref.destTxHash} : {})};\n // No destination RPC: a recorded claim hash is the best evidence we have.\n if (done === null && ref.destTxHash) return {state: \"completed\", destTxHash: ref.destTxHash, claim: {...claim, ready: false}};\n return {state: \"action-required\", depositReceived: true, claim: {...claim, ready: true}};\n }\n return {state: \"pending\", depositReceived: true, claim};\n } catch {\n return {state: \"pending\", claim};\n }\n },\n\n /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */\n async buildClaim(ref: IntentRef): Promise<UnsignedTx | null> {\n const parsed = parseIntent(ref.intentId);\n if (!parsed || !ref.sourceTxHash) return null;\n const m = await fetchMessage(parsed.src, ref.sourceTxHash);\n if (!m || m.status !== \"complete\" || !isHexData(m.attestation) || !isHexData(m.message)) return null;\n // Bind the attested message to the route it claims to complete.\n if (m.decodedMessage?.destinationDomain !== undefined && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {\n throw new Error(\"cctp: attested message is for another destination domain\");\n }\n if (m.decodedMessage?.sourceDomain !== undefined && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {\n throw new Error(\"cctp: attested message is for another source domain\");\n }\n // Fast messages expire at `expirationBlock` on the destination; an expired\n // one needs Circle's re-attestation before it can be received. The\n // transmitter compares it with `block.number`, which on Arbitrum-stack\n // chains is the L1 (Ethereum) height, not the L2 height eth_blockNumber\n // returns — the RPC block carries it as `l1BlockNumber` (live\n // 2026-10-16: a Base→Arbitrum claim was held as \"expired\" by L2 height).\n const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;\n const c = client(parsed.dst.caip2);\n if (c && exp && /^\\d+$/.test(exp) && BigInt(exp) > 0n) {\n const head = await c.request({method: \"eth_getBlockByNumber\", params: [\"latest\", false]})\n .then((b) => {\n const block = b as {number?: string; l1BlockNumber?: string} | null;\n const raw = block?.l1BlockNumber ?? block?.number;\n return raw ? BigInt(raw) : null;\n })\n .catch(() => null);\n if (head !== null && head >= BigInt(exp)) {\n const nonce = m.decodedMessage?.nonce ?? m.eventNonce;\n if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, {method: \"POST\", signal: timeoutSignal(12_000)}).catch(() => undefined);\n return null;\n }\n }\n return {\n chain: parsed.dst.caip2,\n to: parsed.dst.messageTransmitter,\n value: \"0\",\n data: encodeFunctionData({abi: MESSAGE_TRANSMITTER_ABI, functionName: \"receiveMessage\", args: [m.message, m.attestation]}),\n chainId: parsed.dst.chainId,\n gasLimit: GAS_CLAIM,\n };\n },\n };\n}\n\n/**\n * A remote CCTP quote's burn, decoded on the device against the app's own request (scan 2026-10-30, F3): exactly\n * `depositForBurn` on the source TokenMessengerV2 with no value, approving it; the input amount; the destination\n * chain's domain; the recipient as `mintRecipient`; the source domain's native USDC; no destination caller; a Fast\n * or Standard threshold; and a `maxFee` that leaves at least the quoted minimum and the caller's floor. The reason\n * it fails, or null. The engine then requires the build to repeat this quote's call.\n */\nexport function cctpVerifyQuote(params: QuoteParams, quote: Quote): string | null {\n const src = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.sourceChain) ? CCTP_DOMAINS[params.sourceChain] : undefined;\n const dst = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, params.destChain) ? CCTP_DOMAINS[params.destChain] : undefined;\n if (!src || !dst || src === dst) return \"not a CCTP route between two domains\";\n if (params.sourceToken.toUpperCase() !== \"USDC\" || !(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === \"USDC\")) return \"not USDC to USDC\";\n const tx = quote.txRequest;\n if (!tx?.data || !tx.to || tx.serializedTx !== undefined) return \"the quote carries no TokenMessenger call\";\n if (!same(tx.to, src.tokenMessenger)) return `the call targets ${tx.to}, not the TokenMessengerV2`;\n if (BigInt(tx.value ?? \"0\") !== 0n) return \"a burn attaches no value\";\n if (!tx.approvalAddress || !same(tx.approvalAddress, src.tokenMessenger)) return \"the burn approves another spender than the TokenMessengerV2\";\n if (tx.chainId !== undefined && tx.chainId !== src.chainId) return `the call is for chain ${tx.chainId}, not ${src.chainId}`;\n let args: readonly unknown[];\n try {\n const d = decodeFunctionData({abi: TOKEN_MESSENGER_ABI, data: tx.data as Hex});\n if (d.functionName !== \"depositForBurn\") return `${d.functionName} is not depositForBurn`;\n args = d.args;\n } catch {\n return \"the call is not depositForBurn\";\n }\n const [amount, domain, mintRecipient, burnToken, caller, maxFee, threshold] = args as [bigint, number, Hex, string, Hex, bigint, number];\n let amountIn: bigint, floor: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n floor = BigInt(quote.minDestAmount);\n if (params.minAmountOut !== undefined && BigInt(params.minAmountOut) > floor) floor = BigInt(params.minAmountOut);\n } catch {\n return \"the request does not name amounts\";\n }\n if (amount !== amountIn || BigInt(quote.sourceAmount) !== amountIn) return `the burn moves ${amount}, not the ${amountIn} input`;\n if (domain !== dst.domain) return `the burn mints on domain ${domain}, not ${dst.name} (${dst.domain})`;\n // A dry quote without a recipient prices the placeholder the provider uses; it is never built (the engine re-quotes live).\n if (params.destAddress || params.dry === false) {\n if (!isAddress(params.destAddress)) return \"the recipient is not an EVM address\";\n if (mintRecipient.toLowerCase() !== pad(getAddress(params.destAddress), {size: 32}).toLowerCase()) return `the burn mints to ${mintRecipient}, not the recipient`;\n }\n if (!same(burnToken, src.usdc)) return `the burn spends ${burnToken}, not the source domain's USDC`;\n if (caller !== zeroHash) return \"the burn names a destination caller\";\n if (threshold !== FINALITY_FAST && threshold !== FINALITY_STANDARD) return `finality threshold ${threshold} is neither Fast nor Standard`;\n if (maxFee >= amount || amount - maxFee < floor) return `the burn's maxFee ${maxFee} leaves less than the ${floor} minimum`;\n // The server appends its intent token (`<id>~<tag>`); the id before it is what the server's provider tracks and claims.\n if ((/^([\\s\\S]+)~[0-9a-f]{32}$/.exec(quote.intentId)?.[1] ?? quote.intentId) !== `cctp:${src.domain}:${dst.domain}:${threshold}`) return \"the intent id does not name this burn\";\n if (quote.providerData?.maxFee !== undefined && quote.providerData.maxFee !== maxFee.toString()) return \"the quoted maxFee is not the burn's\";\n return null;\n}\n\n/**\n * The TokenMessenger a CCTP burn calls and approves, and the MessageTransmitter its claim calls, per\n * chain, and {@link cctpVerifyQuote} — the app's pins for `remoteProvider({name: \"cctp\", baseUrl, ...cctpPins})`\n * (scan 2026-10-27 modules, F8/F16; claims since round 3, M24; the burn's arguments since scan 2026-10-30, F3).\n */\nexport const cctpPins: RemotePins & {claimTargets(chain: string): readonly string[]} = Object.freeze({\n callTargets: (chain: string): readonly string[] => cctpMessengerFor(chain),\n spenders: (chain: string): readonly string[] => cctpMessengerFor(chain),\n claimTargets: cctpClaimTargets,\n verifyQuote: cctpVerifyQuote,\n});\nfunction cctpMessengerFor(chain: string): readonly string[] {\n const d = Object.prototype.hasOwnProperty.call(CCTP_DOMAINS, chain) ? CCTP_DOMAINS[chain] : undefined;\n return d ? [d.tokenMessenger] : [];\n}\n"],"mappings":";;;;;;;;;;;;;AACA,SAAQ,oBAAoB,oBAAoB,oBAAoB,YAAY,MAAM,WAAW,KAAK,UAAU,gBAAyB;AAEzI,SAAQ,eAAc;AACtB,SAAQ,qBAAoB;AAG5B,SAAQ,sBAAqB;AA0B7B,IAAM,sBAAsB,SAAS;AAAA,EACnC;AAAA,EACA;AACF,CAAC;AACD,IAAM,0BAA0B,SAAS;AAAA,EACvC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