@anywalletkit/protocol-swap2-cctp 0.0.0-stage → 0.1.3

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.
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/protocol.ts
21
+ var protocol_exports = {};
22
+ __export(protocol_exports, {
23
+ CctpSwap2Protocol: () => CctpSwap2Protocol
24
+ });
25
+ module.exports = __toCommonJS(protocol_exports);
26
+ var import_single = require("@anywalletkit/protocol-swap2-core/swap2/single");
27
+
28
+ // src/config.ts
29
+ var import_util = require("@anywalletkit/protocol-swap2-core/util");
30
+ var TOKEN_MESSENGER_V2 = "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d";
31
+ var MESSAGE_TRANSMITTER_V2 = "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64";
32
+ var d = (chainId, domain, name, usdc) => ({
33
+ caip2: `eip155:${chainId}`,
34
+ chainId,
35
+ domain,
36
+ name,
37
+ usdc,
38
+ tokenMessenger: TOKEN_MESSENGER_V2,
39
+ messageTransmitter: MESSAGE_TRANSMITTER_V2
40
+ });
41
+ var CCTP_DOMAINS = Object.freeze(Object.fromEntries([
42
+ d(1, 0, "Ethereum", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
43
+ d(43114, 1, "Avalanche", "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
44
+ d(10, 2, "OP Mainnet", "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"),
45
+ d(42161, 3, "Arbitrum", "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
46
+ d(8453, 6, "Base", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
47
+ d(137, 7, "Polygon PoS", "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"),
48
+ d(130, 10, "Unichain", "0x078D782b760474a361dDA0AF3839290b0EF57AD6"),
49
+ d(59144, 11, "Linea", "0x176211869cA2b568f2A7D4EE941E073a821EE1ff"),
50
+ d(146, 13, "Sonic", "0x29219dd400f2Bf60E5a23d13Be72B486D4038894"),
51
+ d(480, 14, "World Chain", "0x79A02482A880bCe3F13E09da970dC34dB4cD24D1"),
52
+ d(143, 15, "Monad", "0x754704Bc059F8C67012fEd69BC8A327a5aafb603"),
53
+ d(1329, 16, "Sei", "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392"),
54
+ d(999, 19, "HyperEVM", "0xb88339CB7199b77E23DB6E890353E22632Ba630f"),
55
+ d(57073, 21, "Ink", "0x2D270e6886d130D724215A266106e6832161EAEd"),
56
+ d(98866, 22, "Plume", "0x222365EF19F7947e5484218551B56bb3965Aa7aF"),
57
+ d(9745, 33, "Plasma", "0x2d661C89D812261039AF9764eceaAee884f5F67F"),
58
+ d(196, 37, "X Layer", "0xB6CEceAB302E2E4948951eE7843FC24E92933061"),
59
+ // 2026-10-14: Arc and Morph (developers.circle.com/cctp/evm-smart-contracts + usdc-contract-addresses; TokenMessengerV2 /
60
+ // MessageTransmitterV2 have code on both chains, MessageTransmitterV2.localDomain() answers 26 / 30 and
61
+ // TokenMessengerV2.localMessageTransmitter() points at 0x81D4…). Arc's USDC is the chain's gas token: 0x3600… is its
62
+ // 6-decimal ERC-20 interface, which is what CCTP burns and mints.
63
+ d(5042, 26, "Arc", "0x3600000000000000000000000000000000000000"),
64
+ d(2818, 30, "Morph", "0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B")
65
+ ].map((x) => [x.caip2, x])));
66
+ var CCTP_BY_DOMAIN = Object.freeze(
67
+ Object.fromEntries(Object.values(CCTP_DOMAINS).map((x) => [x.domain, x]))
68
+ );
69
+ var CCTP_API = "https://iris-api.circle.com";
70
+ var FINALITY_FAST = 1e3;
71
+ var FINALITY_STANDARD = 2e3;
72
+ var cctp = {
73
+ supportsChain(chain) {
74
+ return (0, import_util.isEvm)(chain) && !!CCTP_DOMAINS[`eip155:${(0, import_util.evmRef)(chain)}`];
75
+ },
76
+ supports(from, to) {
77
+ return from !== to && this.supportsChain(from) && this.supportsChain(to);
78
+ }
79
+ };
80
+
81
+ // src/provider.ts
82
+ var import_viem = require("viem");
83
+
84
+ // src/activity.ts
85
+ var import_activity = require("@anywalletkit/protocol-swap2-core/activity");
86
+ var CCTP_MODULE = "@anywalletkit/protocol-swap2-cctp";
87
+ var CCTP_DEPOSIT_FOR_BURN = "0x8e0250ee";
88
+ var CCTP_RECEIVE_MESSAGE = "0x57ecfd28";
89
+ function describeCctpActivity(tx, ctx) {
90
+ const domain = CCTP_DOMAINS[tx.chain];
91
+ if (!domain) return null;
92
+ const subtitle = `CCTP \xB7 ${(0, import_activity.chainLabel)(tx.chain)}`;
93
+ if ((0, import_activity.matchesCall)(tx, [domain.tokenMessenger], [CCTP_DEPOSIT_FOR_BURN])) {
94
+ return (0, import_activity.describeSwapLike)(tx, ctx, { protocol: CCTP_MODULE, subtitle, kind: "bridge", title: "Bridged USDC" });
95
+ }
96
+ if ((0, import_activity.matchesCall)(tx, [domain.messageTransmitter], [CCTP_RECEIVE_MESSAGE])) {
97
+ return (0, import_activity.describeSwapLike)(tx, ctx, { protocol: CCTP_MODULE, subtitle, kind: "bridge", title: "Received USDC via CCTP" });
98
+ }
99
+ return null;
100
+ }
101
+
102
+ // src/provider.ts
103
+ var import_swap2_assets = require("@anywalletkit/swap2-assets");
104
+ var import_util2 = require("@anywalletkit/protocol-swap2-core/util");
105
+ var TOKEN_MESSENGER_ABI = (0, import_viem.parseAbi)([
106
+ "function depositForBurn(uint256 amount, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold)",
107
+ "function localMessageTransmitter() view returns (address)"
108
+ ]);
109
+ var MESSAGE_TRANSMITTER_ABI = (0, import_viem.parseAbi)([
110
+ "function receiveMessage(bytes message, bytes attestation) returns (bool)",
111
+ "function localDomain() view returns (uint32)",
112
+ "function usedNonces(bytes32 nonce) view returns (uint256)"
113
+ ]);
114
+ var EVM_PLACEHOLDER = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
115
+ var DEFAULT_QUOTE_TTL_MS = 6e4;
116
+ var GAS_DEPOSIT = "200000";
117
+ var GAS_CLAIM = "260000";
118
+ var isHexData = (v) => typeof v === "string" && /^0x(?:[0-9a-fA-F]{2})+$/.test(v);
119
+ var same = (a, b) => !!a && a.toLowerCase() === b.toLowerCase();
120
+ function feeFor(amount, bps, bufferPct) {
121
+ const hundredths = BigInt(Math.round(bps * 100));
122
+ const fee = (amount * hundredths + 999999n) / 1000000n;
123
+ if (fee === 0n) return 0n;
124
+ return fee + (fee * BigInt(Math.round(bufferPct * 100)) + 9999n) / 10000n;
125
+ }
126
+ function cctpProvider(config = {}) {
127
+ config = Object.freeze({ ...config });
128
+ const api = (config.apiUrl ?? CCTP_API).replace(/\/+$/, "");
129
+ if (!/^https?:\/\//.test(api)) throw new Error("cctp: apiUrl must use http or https");
130
+ const mode = config.mode ?? "auto";
131
+ if (!["auto", "fast", "standard"].includes(mode)) throw new Error("cctp: mode must be auto | fast | standard");
132
+ const bufferPct = config.feeBufferPct ?? 10;
133
+ if (!Number.isFinite(bufferPct) || bufferPct < 0 || bufferPct > 100) throw new Error("cctp: feeBufferPct must be between 0 and 100");
134
+ const quoteTtlMs = config.quoteTtlMs ?? DEFAULT_QUOTE_TTL_MS;
135
+ if (!Number.isInteger(quoteTtlMs) || quoteTtlMs <= 0 || quoteTtlMs > 3e5) throw new Error("cctp: quoteTtlMs must be an integer between 1 and 300000");
136
+ const doFetch = config.fetchImpl ?? fetch;
137
+ const rpcUrls = Object.freeze({ ...config.rpcUrls ?? {} });
138
+ const client = (caip2) => {
139
+ const url = rpcUrls[caip2];
140
+ return url ? (0, import_viem.createPublicClient)({ transport: (0, import_viem.http)(url, { fetchOptions: {}, ...config.fetchImpl ? { fetchFn: config.fetchImpl } : {} }) }) : null;
141
+ };
142
+ async function getJson(path, signal) {
143
+ const res = await doFetch(`${api}${path}`, { headers: { accept: "application/json" }, signal: signal ?? (0, import_util2.timeoutSignal)(12e3) });
144
+ if (res.status === 404) return null;
145
+ if (!res.ok) throw new Error(`cctp: ${path} \u2192 ${res.status}`);
146
+ return await res.json();
147
+ }
148
+ const feeRows = (src, dst, signal) => getJson(`/v2/burn/USDC/fees/${src.domain}/${dst.domain}`, signal);
149
+ function usdcOf(dom) {
150
+ const known = (0, import_swap2_assets.ccAsset)(dom.caip2, "USDC");
151
+ if (known && (!known.contract || !same(known.contract, dom.usdc))) return null;
152
+ return dom.usdc;
153
+ }
154
+ function parseIntent(intentId) {
155
+ const [tag, s, dd, t] = intentId.split(":");
156
+ if (tag !== "cctp") return null;
157
+ const src = CCTP_BY_DOMAIN[Number(s)];
158
+ const dst = CCTP_BY_DOMAIN[Number(dd)];
159
+ const threshold = Number(t);
160
+ if (!src || !dst || !(threshold === FINALITY_FAST || threshold === FINALITY_STANDARD)) return null;
161
+ return { src, dst, threshold };
162
+ }
163
+ async function fetchMessage(src, sourceTxHash) {
164
+ const out = await getJson(`/v2/messages/${src.domain}?transactionHash=${encodeURIComponent(sourceTxHash)}`);
165
+ const m = out?.messages?.find((x) => x.cctpVersion === void 0 || x.cctpVersion === 2);
166
+ return m ?? null;
167
+ }
168
+ async function minted(dst, nonce) {
169
+ const c = client(dst.caip2);
170
+ if (!c) return null;
171
+ try {
172
+ const used = await c.readContract({ address: (0, import_viem.getAddress)(dst.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: "usedNonces", args: [nonce] });
173
+ return used !== 0n;
174
+ } catch {
175
+ return null;
176
+ }
177
+ }
178
+ return {
179
+ name: "cctp",
180
+ describeActivity: describeCctpActivity,
181
+ enabled: () => config.enabled ?? true,
182
+ supportsChain: (chain) => cctp.supportsChain(chain),
183
+ supportsChainPair: (from, to) => cctp.supports(from, to),
184
+ supportsRoute(from, to) {
185
+ const src = CCTP_DOMAINS[from.chain];
186
+ const dst = CCTP_DOMAINS[to.chain];
187
+ if (!src || !dst || from.chain === to.chain) return false;
188
+ if (from.token.toUpperCase() !== "USDC") return false;
189
+ return same(to.token, dst.usdc) || to.token.toUpperCase() === "USDC";
190
+ },
191
+ async getQuote(params, signal) {
192
+ if (params.flex) return null;
193
+ const src = CCTP_DOMAINS[params.sourceChain];
194
+ const dst = CCTP_DOMAINS[params.destChain];
195
+ if (!src || !dst || src === dst) return null;
196
+ if (params.sourceToken.toUpperCase() !== "USDC") return null;
197
+ if (!(same(params.destToken, dst.usdc) || params.destToken.toUpperCase() === "USDC")) return null;
198
+ const usdc = usdcOf(src);
199
+ if (!usdc) {
200
+ params.onRefusal?.("catalog USDC on the source chain is not Circle's native USDC");
201
+ return null;
202
+ }
203
+ if (!/^\d+$/.test(params.amountIn)) return null;
204
+ const amount = BigInt(params.amountIn);
205
+ if (amount <= 0n) return null;
206
+ const recipient = params.destAddress || EVM_PLACEHOLDER;
207
+ if (!(0, import_viem.isAddress)(recipient)) {
208
+ params.onRefusal?.("destination must be an EVM address");
209
+ return null;
210
+ }
211
+ try {
212
+ const fees = await feeRows(src, dst, signal);
213
+ if (!fees || !Array.isArray(fees) || fees.length === 0) {
214
+ params.onRefusal?.("Circle publishes no fee for this pair");
215
+ return null;
216
+ }
217
+ const fast = fees.find((f) => f.finalityThreshold === FINALITY_FAST);
218
+ const standard = fees.find((f) => f.finalityThreshold === FINALITY_STANDARD);
219
+ let threshold;
220
+ let bps;
221
+ if (mode === "standard") {
222
+ if (!standard) {
223
+ params.onRefusal?.("Standard Transfer is not offered for this pair");
224
+ return null;
225
+ }
226
+ threshold = FINALITY_STANDARD;
227
+ bps = standard.minimumFee;
228
+ } else {
229
+ let fastOk = !!fast;
230
+ if (fastOk) {
231
+ const allowance = await getJson("/v2/fastBurn/USDC/allowance", signal).catch(() => null);
232
+ if (typeof allowance?.allowance === "number" && allowance.allowance * 1e6 < Number(amount)) fastOk = false;
233
+ }
234
+ if (fastOk) {
235
+ threshold = FINALITY_FAST;
236
+ bps = fast.minimumFee;
237
+ } else if (mode === "fast") {
238
+ params.onRefusal?.(fast ? "Fast Transfer allowance is exhausted" : "Fast Transfer is not offered for this pair");
239
+ return null;
240
+ } else if (standard) {
241
+ threshold = FINALITY_STANDARD;
242
+ bps = standard.minimumFee;
243
+ } else {
244
+ params.onRefusal?.("neither Fast nor Standard is offered");
245
+ return null;
246
+ }
247
+ }
248
+ if (!Number.isFinite(bps) || bps < 0) return null;
249
+ const maxFee = feeFor(amount, bps, bufferPct);
250
+ if (maxFee >= amount) {
251
+ params.onRefusal?.("amount is below the Fast Transfer fee");
252
+ return null;
253
+ }
254
+ const out = amount - maxFee;
255
+ if (params.minAmountOut !== void 0 && out < BigInt(params.minAmountOut)) return null;
256
+ const data = (0, import_viem.encodeFunctionData)({
257
+ abi: TOKEN_MESSENGER_ABI,
258
+ functionName: "depositForBurn",
259
+ args: [amount, dst.domain, (0, import_viem.pad)((0, import_viem.getAddress)(recipient), { size: 32 }), (0, import_viem.getAddress)(usdc), import_viem.zeroHash, maxFee, threshold]
260
+ });
261
+ const eta = threshold === FINALITY_FAST ? src.domain === 0 ? 180 : 45 : src.domain === 0 ? 1200 : 1e3;
262
+ return {
263
+ provider: "cctp",
264
+ intentId: `cctp:${src.domain}:${dst.domain}:${threshold}`,
265
+ depositAddress: "",
266
+ depositMemo: null,
267
+ txRequest: { to: src.tokenMessenger, data, value: "0", chainId: src.chainId, gasLimit: GAS_DEPOSIT, approvalAddress: src.tokenMessenger },
268
+ sourceAmount: amount.toString(),
269
+ destAmount: out.toString(),
270
+ minDestAmount: out.toString(),
271
+ feeUsd: Number(maxFee) / 1e6,
272
+ 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)` }] : [],
273
+ etaSeconds: eta,
274
+ reliability: 0.99,
275
+ validUntilMs: Date.now() + quoteTtlMs,
276
+ providerData: {
277
+ sourceDomain: String(src.domain),
278
+ destinationDomain: String(dst.domain),
279
+ finalityThreshold: String(threshold),
280
+ maxFee: maxFee.toString(),
281
+ mintRecipient: (0, import_viem.getAddress)(recipient),
282
+ claimChain: dst.caip2,
283
+ claimRequired: "1"
284
+ }
285
+ };
286
+ } catch {
287
+ return null;
288
+ }
289
+ },
290
+ async buildDeposit(quote) {
291
+ const tx = quote.txRequest;
292
+ const parsed = parseIntent(quote.intentId);
293
+ if (!tx || !parsed) throw new Error("swap2: CCTP quote has no transaction request");
294
+ return {
295
+ chain: parsed.src.caip2,
296
+ to: tx.to ?? "",
297
+ value: tx.value ?? "0",
298
+ ...tx.data ? { data: tx.data } : {},
299
+ ...tx.chainId !== void 0 ? { chainId: tx.chainId } : {},
300
+ ...tx.gasLimit ? { gasLimit: tx.gasLimit } : {},
301
+ ...tx.approvalAddress ? { approvalAddress: tx.approvalAddress } : {}
302
+ };
303
+ },
304
+ /**
305
+ * Fast: Circle's CURRENT fee (same source and rounding as the quote, without
306
+ * the buffer) still fits `maxFee` — Iris would otherwise hold the burn
307
+ * until it times out to Standard. With a source RPC: the target really is
308
+ * CCTP for this domain.
309
+ */
310
+ async preflightDeposit(quote, tx) {
311
+ const parsed = parseIntent(quote.intentId);
312
+ if (!parsed) throw new Error("cctp: malformed intent id");
313
+ if (!same(tx.to, parsed.src.tokenMessenger)) throw new Error("cctp: deposit target is not the TokenMessengerV2 of the source domain");
314
+ if (parsed.threshold === FINALITY_FAST) {
315
+ const fast = (await feeRows(parsed.src, parsed.dst))?.find((f) => f.finalityThreshold === FINALITY_FAST);
316
+ if (!fast || !Number.isFinite(fast.minimumFee) || fast.minimumFee < 0) throw new Error("cctp: Circle no longer publishes a Fast Transfer fee for this pair \u2014 re-quote");
317
+ const minFee = feeFor(BigInt(quote.sourceAmount), fast.minimumFee, 0);
318
+ const maxFee = BigInt(quote.providerData?.maxFee ?? "0");
319
+ if (minFee > maxFee) throw new Error(`cctp: Circle's Fast Transfer fee ${minFee} (${fast.minimumFee} bps) exceeds the quoted maxFee ${maxFee} \u2014 re-quote`);
320
+ }
321
+ const c = client(parsed.src.caip2);
322
+ if (!c) return;
323
+ const transmitter = await c.readContract({ address: (0, import_viem.getAddress)(parsed.src.tokenMessenger), abi: TOKEN_MESSENGER_ABI, functionName: "localMessageTransmitter" });
324
+ if (!same(transmitter, parsed.src.messageTransmitter)) throw new Error("cctp: TokenMessengerV2 does not point at the expected MessageTransmitterV2");
325
+ const domain = await c.readContract({ address: (0, import_viem.getAddress)(parsed.src.messageTransmitter), abi: MESSAGE_TRANSMITTER_ABI, functionName: "localDomain" });
326
+ if (Number(domain) !== parsed.src.domain) throw new Error(`cctp: MessageTransmitterV2 reports domain ${domain}, expected ${parsed.src.domain}`);
327
+ },
328
+ async trackIntent(ref) {
329
+ const parsed = parseIntent(ref.intentId);
330
+ if (!parsed) return { state: "failed" };
331
+ const claim = { chain: parsed.dst.caip2, ready: false };
332
+ if (!ref.sourceTxHash) return { state: "pending", claim };
333
+ try {
334
+ const m = await fetchMessage(parsed.src, ref.sourceTxHash);
335
+ if (!m) return { state: "pending", depositReceived: false, claim };
336
+ const nonce = m.decodedMessage?.nonce;
337
+ if (m.status === "complete" && isHexData(m.attestation) && isHexData(m.message)) {
338
+ const done = isHexData(nonce) && nonce.length === 66 ? await minted(parsed.dst, nonce) : null;
339
+ if (done) return { state: "completed", claim: { ...claim, ready: false }, ...ref.destTxHash ? { destTxHash: ref.destTxHash } : {} };
340
+ if (done === null && ref.destTxHash) return { state: "completed", destTxHash: ref.destTxHash, claim: { ...claim, ready: false } };
341
+ return { state: "action-required", depositReceived: true, claim: { ...claim, ready: true } };
342
+ }
343
+ return { state: "pending", depositReceived: true, claim };
344
+ } catch {
345
+ return { state: "pending", claim };
346
+ }
347
+ },
348
+ /** `receiveMessage(message, attestation)` on the destination once Circle attested; null while pending. */
349
+ async buildClaim(ref) {
350
+ const parsed = parseIntent(ref.intentId);
351
+ if (!parsed || !ref.sourceTxHash) return null;
352
+ const m = await fetchMessage(parsed.src, ref.sourceTxHash);
353
+ if (!m || m.status !== "complete" || !isHexData(m.attestation) || !isHexData(m.message)) return null;
354
+ if (m.decodedMessage?.destinationDomain !== void 0 && Number(m.decodedMessage.destinationDomain) !== parsed.dst.domain) {
355
+ throw new Error("cctp: attested message is for another destination domain");
356
+ }
357
+ if (m.decodedMessage?.sourceDomain !== void 0 && Number(m.decodedMessage.sourceDomain) !== parsed.src.domain) {
358
+ throw new Error("cctp: attested message is for another source domain");
359
+ }
360
+ const exp = m.decodedMessage?.decodedMessageBody?.expirationBlock;
361
+ const c = client(parsed.dst.caip2);
362
+ if (c && exp && /^\d+$/.test(exp) && BigInt(exp) > 0n) {
363
+ const head = await c.request({ method: "eth_getBlockByNumber", params: ["latest", false] }).then((b) => {
364
+ const block = b;
365
+ const raw = block?.l1BlockNumber ?? block?.number;
366
+ return raw ? BigInt(raw) : null;
367
+ }).catch(() => null);
368
+ if (head !== null && head >= BigInt(exp)) {
369
+ const nonce = m.decodedMessage?.nonce ?? m.eventNonce;
370
+ if (nonce) await doFetch(`${api}/v2/reattest/${nonce}`, { method: "POST", signal: (0, import_util2.timeoutSignal)(12e3) }).catch(() => void 0);
371
+ return null;
372
+ }
373
+ }
374
+ return {
375
+ chain: parsed.dst.caip2,
376
+ to: parsed.dst.messageTransmitter,
377
+ value: "0",
378
+ data: (0, import_viem.encodeFunctionData)({ abi: MESSAGE_TRANSMITTER_ABI, functionName: "receiveMessage", args: [m.message, m.attestation] }),
379
+ chainId: parsed.dst.chainId,
380
+ gasLimit: GAS_CLAIM
381
+ };
382
+ }
383
+ };
384
+ }
385
+
386
+ // src/protocol.ts
387
+ var CctpSwap2Protocol = class extends import_single.SingleProviderSwap2 {
388
+ provider;
389
+ constructor(account, config) {
390
+ super(account, config);
391
+ this.provider = cctpProvider(config);
392
+ }
393
+ chainSupported(caip2) {
394
+ return cctp.supportsChain(caip2);
395
+ }
396
+ pairSupported(fromChain, toChain) {
397
+ return cctp.supports(fromChain, toChain);
398
+ }
399
+ };
400
+ //# sourceMappingURL=protocol.cjs.map
@@ -0,0 +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 {createPublicClient, 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\";\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\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)}) : 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 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 const recipient = params.destAddress || EVM_PLACEHOLDER;\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 < Number(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: Number(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 * 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,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O,iBAAiB,OAAO;AAC3C,iBAAO,MAAM,OAAO,GAAG,IAAI;AAAA,QAC7B,CAAC,EACA,MAAM,MAAM,IAAI;AACnB,YAAI,SAAS,QAAQ,QAAQ,OAAO,GAAG,GAAG;AACxC,gBAAM,QAAQ,EAAE,gBAAgB,SAAS,EAAE;AAC3C,cAAI,MAAO,OAAM,QAAQ,GAAG,GAAG,gBAAgB,KAAK,IAAI,EAAC,QAAQ,QAAQ,YAAQ,4BAAc,IAAM,EAAC,CAAC,EAAE,MAAM,MAAM,MAAS;AAC9H,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,QACL,OAAO,OAAO,IAAI;AAAA,QAClB,IAAI,OAAO,IAAI;AAAA,QACf,OAAO;AAAA,QACP,UAAM,gCAAmB,EAAC,KAAK,yBAAyB,cAAc,kBAAkB,MAAM,CAAC,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;AAAA,QACzH,SAAS,OAAO,IAAI;AAAA,QACpB,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACF;;;AFxVO,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"]}
@@ -0,0 +1,16 @@
1
+ import * as _anywalletkit_protocol_swap2_core_types from '@anywalletkit/protocol-swap2-core/types';
2
+ import { SingleProviderSwap2 } from '@anywalletkit/protocol-swap2-core/swap2/single';
3
+ import { Swap2EngineConfig, Swap2Account } from '@anywalletkit/protocol-swap2-core/swap2/base';
4
+ import { CctpProviderConfig } from './provider.cjs';
5
+
6
+ interface CctpSwap2Config extends Swap2EngineConfig, CctpProviderConfig {
7
+ }
8
+ /** Standalone CCTP swap2: USDC burn-and-mint between EVM chains, claim via `claimSwap2`. */
9
+ declare class CctpSwap2Protocol extends SingleProviderSwap2 {
10
+ protected readonly provider: _anywalletkit_protocol_swap2_core_types.CrossChainProvider;
11
+ constructor(account: Swap2Account | undefined, config: CctpSwap2Config);
12
+ protected chainSupported(caip2: string): boolean;
13
+ protected pairSupported(fromChain: string, toChain: string): boolean;
14
+ }
15
+
16
+ export { type CctpSwap2Config, CctpSwap2Protocol };
@@ -0,0 +1,16 @@
1
+ import * as _anywalletkit_protocol_swap2_core_types from '@anywalletkit/protocol-swap2-core/types';
2
+ import { SingleProviderSwap2 } from '@anywalletkit/protocol-swap2-core/swap2/single';
3
+ import { Swap2EngineConfig, Swap2Account } from '@anywalletkit/protocol-swap2-core/swap2/base';
4
+ import { CctpProviderConfig } from './provider.js';
5
+
6
+ interface CctpSwap2Config extends Swap2EngineConfig, CctpProviderConfig {
7
+ }
8
+ /** Standalone CCTP swap2: USDC burn-and-mint between EVM chains, claim via `claimSwap2`. */
9
+ declare class CctpSwap2Protocol extends SingleProviderSwap2 {
10
+ protected readonly provider: _anywalletkit_protocol_swap2_core_types.CrossChainProvider;
11
+ constructor(account: Swap2Account | undefined, config: CctpSwap2Config);
12
+ protected chainSupported(caip2: string): boolean;
13
+ protected pairSupported(fromChain: string, toChain: string): boolean;
14
+ }
15
+
16
+ export { type CctpSwap2Config, CctpSwap2Protocol };
@@ -0,0 +1,10 @@
1
+ import {
2
+ CctpSwap2Protocol
3
+ } from "./chunk-TFQR5KQB.js";
4
+ import "./chunk-I33XRHH3.js";
5
+ import "./chunk-FLAON5RO.js";
6
+ import "./chunk-ZR5XR5RO.js";
7
+ export {
8
+ CctpSwap2Protocol
9
+ };
10
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}