@anywalletkit/protocol-swap2-stargate 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +502 -2
  3. package/dist/abi.cjs +91 -0
  4. package/dist/abi.cjs.map +1 -0
  5. package/dist/abi.d.cts +810 -0
  6. package/dist/abi.d.ts +810 -0
  7. package/dist/abi.js +13 -0
  8. package/dist/abi.js.map +1 -0
  9. package/dist/amounts.cjs +73 -0
  10. package/dist/amounts.cjs.map +1 -0
  11. package/dist/amounts.d.cts +21 -0
  12. package/dist/amounts.d.ts +21 -0
  13. package/dist/amounts.js +15 -0
  14. package/dist/amounts.js.map +1 -0
  15. package/dist/bus-Cdw8iwOv.d.cts +59 -0
  16. package/dist/bus-vAWqTAkq.d.ts +59 -0
  17. package/dist/bus.cjs +237 -0
  18. package/dist/bus.cjs.map +1 -0
  19. package/dist/bus.d.cts +4 -0
  20. package/dist/bus.d.ts +4 -0
  21. package/dist/bus.js +22 -0
  22. package/dist/bus.js.map +1 -0
  23. package/dist/chunk-3NTMZUAU.js +128 -0
  24. package/dist/chunk-3NTMZUAU.js.map +1 -0
  25. package/dist/chunk-4HU46QF2.js +256 -0
  26. package/dist/chunk-4HU46QF2.js.map +1 -0
  27. package/dist/chunk-4IDDRIE2.js +125 -0
  28. package/dist/chunk-4IDDRIE2.js.map +1 -0
  29. package/dist/chunk-EANM3EI3.js +71 -0
  30. package/dist/chunk-EANM3EI3.js.map +1 -0
  31. package/dist/chunk-ERC6LKMN.js +87 -0
  32. package/dist/chunk-ERC6LKMN.js.map +1 -0
  33. package/dist/chunk-FLAXDJPE.js +24 -0
  34. package/dist/chunk-FLAXDJPE.js.map +1 -0
  35. package/dist/chunk-N54YIG6T.js +33 -0
  36. package/dist/chunk-N54YIG6T.js.map +1 -0
  37. package/dist/chunk-OUGUX3JK.js +53 -0
  38. package/dist/chunk-OUGUX3JK.js.map +1 -0
  39. package/dist/chunk-PJXDMVW3.js +909 -0
  40. package/dist/chunk-PJXDMVW3.js.map +1 -0
  41. package/dist/chunk-QNVTQEOV.js +72 -0
  42. package/dist/chunk-QNVTQEOV.js.map +1 -0
  43. package/dist/chunk-UDJL7BUP.js +249 -0
  44. package/dist/chunk-UDJL7BUP.js.map +1 -0
  45. package/dist/chunk-YHHV3XHY.js +139 -0
  46. package/dist/chunk-YHHV3XHY.js.map +1 -0
  47. package/dist/compose-dex.cjs +148 -0
  48. package/dist/compose-dex.cjs.map +1 -0
  49. package/dist/compose-dex.d.cts +113 -0
  50. package/dist/compose-dex.d.ts +113 -0
  51. package/dist/compose-dex.js +25 -0
  52. package/dist/compose-dex.js.map +1 -0
  53. package/dist/compose-route.cjs +1019 -0
  54. package/dist/compose-route.cjs.map +1 -0
  55. package/dist/compose-route.d.cts +93 -0
  56. package/dist/compose-route.d.ts +93 -0
  57. package/dist/compose-route.js +45 -0
  58. package/dist/compose-route.js.map +1 -0
  59. package/dist/compose.cjs +287 -0
  60. package/dist/compose.cjs.map +1 -0
  61. package/dist/compose.d.cts +293 -0
  62. package/dist/compose.d.ts +293 -0
  63. package/dist/compose.js +30 -0
  64. package/dist/compose.js.map +1 -0
  65. package/dist/deployments.cjs +350 -0
  66. package/dist/deployments.cjs.map +1 -0
  67. package/dist/deployments.d.cts +12 -0
  68. package/dist/deployments.d.ts +12 -0
  69. package/dist/deployments.js +11 -0
  70. package/dist/deployments.js.map +1 -0
  71. package/dist/index.cjs +1862 -0
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.cts +23 -0
  74. package/dist/index.d.ts +23 -0
  75. package/dist/index.js +46 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/native-drop.cjs +117 -0
  78. package/dist/native-drop.cjs.map +1 -0
  79. package/dist/native-drop.d.cts +13 -0
  80. package/dist/native-drop.d.ts +13 -0
  81. package/dist/native-drop.js +11 -0
  82. package/dist/native-drop.js.map +1 -0
  83. package/dist/pins.cjs +1618 -0
  84. package/dist/pins.cjs.map +1 -0
  85. package/dist/pins.d.cts +39 -0
  86. package/dist/pins.d.ts +39 -0
  87. package/dist/pins.js +21 -0
  88. package/dist/pins.js.map +1 -0
  89. package/dist/protocol.cjs +1851 -0
  90. package/dist/protocol.cjs.map +1 -0
  91. package/dist/protocol.d.cts +24 -0
  92. package/dist/protocol.d.ts +24 -0
  93. package/dist/protocol.js +18 -0
  94. package/dist/protocol.js.map +1 -0
  95. package/dist/provider.cjs +1833 -0
  96. package/dist/provider.cjs.map +1 -0
  97. package/dist/provider.d.cts +30 -0
  98. package/dist/provider.d.ts +30 -0
  99. package/dist/provider.js +17 -0
  100. package/dist/provider.js.map +1 -0
  101. package/dist/quote-r1bA8XbO.d.cts +102 -0
  102. package/dist/quote-t7UJSxbU.d.ts +102 -0
  103. package/dist/quote.cjs +618 -0
  104. package/dist/quote.cjs.map +1 -0
  105. package/dist/quote.d.cts +3 -0
  106. package/dist/quote.d.ts +3 -0
  107. package/dist/quote.js +16 -0
  108. package/dist/quote.js.map +1 -0
  109. package/dist/registry.cjs +100 -0
  110. package/dist/registry.cjs.map +1 -0
  111. package/dist/registry.d.cts +42 -0
  112. package/dist/registry.d.ts +42 -0
  113. package/dist/registry.js +8 -0
  114. package/dist/registry.js.map +1 -0
  115. package/dist/tracking.cjs +1143 -0
  116. package/dist/tracking.cjs.map +1 -0
  117. package/dist/tracking.d.cts +57 -0
  118. package/dist/tracking.d.ts +57 -0
  119. package/dist/tracking.js +23 -0
  120. package/dist/tracking.js.map +1 -0
  121. package/package.json +134 -3
@@ -0,0 +1,1143 @@
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/tracking.ts
21
+ var tracking_exports = {};
22
+ __export(tracking_exports, {
23
+ checkStargateReceipt: () => checkStargateReceipt,
24
+ createStargateTracker: () => createStargateTracker,
25
+ stargateComposedTaxiProof: () => stargateComposedTaxiProof,
26
+ stargateTaxiPayout: () => stargateTaxiPayout,
27
+ stargateTaxiProof: () => stargateTaxiProof
28
+ });
29
+ module.exports = __toCommonJS(tracking_exports);
30
+ var import_viem10 = require("viem");
31
+ var import_util = require("@anywalletkit/protocol-swap2-core/util");
32
+
33
+ // src/abi.ts
34
+ var import_viem = require("viem");
35
+ var EXECUTOR_ABI = (0, import_viem.parseAbi)([
36
+ "struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }",
37
+ "struct NativeDropParams { address receiver; uint256 amount; }",
38
+ "function endpoint() view returns (address)",
39
+ "function localEid() view returns (uint32)",
40
+ "event NativeDropApplied(Origin origin, uint32 dstEid, address oapp, NativeDropParams[] params, bool[] success)"
41
+ ]);
42
+ var ENDPOINT_ABI = (0, import_viem.parseAbi)([
43
+ "struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }",
44
+ "function inboundPayloadHash(address receiver, uint32 srcEid, bytes32 sender, uint64 nonce) view returns (bytes32)",
45
+ "function lzReceive(Origin origin, address receiver, bytes32 guid, bytes message, bytes extraData) payable",
46
+ "event PacketSent(bytes encodedPayload, bytes options, address sendLibrary)",
47
+ "event PacketDelivered(Origin origin, address receiver)"
48
+ ]);
49
+ var STARGATE_ABI = (0, import_viem.parseAbi)([
50
+ "struct SendParam { uint32 dstEid; bytes32 to; uint256 amountLD; uint256 minAmountLD; bytes extraOptions; bytes composeMsg; bytes oftCmd; }",
51
+ "struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }",
52
+ "struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }",
53
+ "struct OFTLimit { uint256 minAmountLD; uint256 maxAmountLD; }",
54
+ "struct OFTFeeDetail { int256 feeAmountLD; string description; }",
55
+ "struct OFTReceipt { uint256 amountSentLD; uint256 amountReceivedLD; }",
56
+ "struct Ticket { uint72 ticketId; bytes passengerBytes; }",
57
+ "struct AddressConfig { address feeLib; address planner; address treasurer; address tokenMessaging; address creditMessaging; address lzToken; }",
58
+ "function token() view returns (address)",
59
+ "function sharedDecimals() view returns (uint8)",
60
+ "function approvalRequired() pure returns (bool)",
61
+ "function localEid() view returns (uint32)",
62
+ "function endpoint() view returns (address)",
63
+ "function status() view returns (uint8)",
64
+ "function stargateType() pure returns (uint8)",
65
+ "function paths(uint32 eid) view returns (uint64 credit)",
66
+ "function getAddressConfig() view returns (AddressConfig)",
67
+ "function quoteOFT(SendParam s) view returns (OFTLimit limit, OFTFeeDetail[] oftFeeDetails, OFTReceipt receipt)",
68
+ "function quoteSend(SendParam s, bool payInLzToken) view returns (MessagingFee fee)",
69
+ "function send(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt)",
70
+ "function sendToken(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt, Ticket ticket)",
71
+ "function unreceivedTokens(bytes32 guid, uint8 index) view returns (bytes32)",
72
+ "function retryReceiveToken(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)",
73
+ "event OFTSent(bytes32 indexed guid, uint32 dstEid, address indexed fromAddress, uint256 amountSentLD, uint256 amountReceivedLD)",
74
+ "event OFTReceived(bytes32 indexed guid, uint32 srcEid, address indexed toAddress, uint256 amountReceivedLD)",
75
+ "event UnreceivedTokenCached(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)"
76
+ ]);
77
+ var TOKEN_MESSAGING_ABI = (0, import_viem.parseAbi)([
78
+ "error Bus_InvalidFare(bool nativeDrop)",
79
+ "struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }",
80
+ "struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }",
81
+ "function assetIds(address stargateImpl) view returns (uint16)",
82
+ "function stargateImpls(uint16 assetId) view returns (address)",
83
+ "function peers(uint32 eid) view returns (bytes32)",
84
+ "function endpoint() view returns (address)",
85
+ "function nativeDropAmounts(uint32 eid) view returns (uint128)",
86
+ "function queueCapacity() view returns (uint16)",
87
+ "function busQueues(uint32 eid) view returns (uint8 maxNumPassengers, uint80 busFare, uint80 busAndNativeDropFare, uint16 qLength, uint72 nextTicketId)",
88
+ "function getPassengerHash(uint32 eid, uint16 index) view returns (bytes32)",
89
+ "function quoteDriveBus(uint32 dstEid, bytes passengers) view returns (MessagingFee fee)",
90
+ "function driveBus(uint32 dstEid, bytes passengers) payable returns (MessagingReceipt receipt)",
91
+ "event BusRode(uint32 dstEid, uint72 ticketId, uint80 fare, bytes passenger)",
92
+ "event BusDriven(uint32 dstEid, uint72 startTicketId, uint8 numPassengers, bytes32 guid)",
93
+ "event NativeDropApplied(address receiver, uint128 amount)",
94
+ "event NativeDropFailed(address receiver, uint128 amount)"
95
+ ]);
96
+
97
+ // src/amounts.ts
98
+ var UINT64_MAX = (1n << 64n) - 1n;
99
+ var UINT256_MAX = (1n << 256n) - 1n;
100
+ function uint256(amount) {
101
+ if (typeof amount !== "bigint" || amount < 0n || amount > UINT256_MAX) throw new RangeError("stargate: amount must be uint256 bigint");
102
+ }
103
+ function conversionRate(localDecimals, sharedDecimals) {
104
+ if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {
105
+ throw new RangeError("stargate: invalid local/shared decimals");
106
+ }
107
+ return 10n ** BigInt(localDecimals - sharedDecimals);
108
+ }
109
+ function splitSourceAmount(amountLD, localDecimals, sharedDecimals) {
110
+ uint256(amountLD);
111
+ const rate = conversionRate(localDecimals, sharedDecimals);
112
+ const amountSD = amountLD / rate;
113
+ if (amountSD > UINT64_MAX) throw new RangeError("stargate: shared amount exceeds uint64");
114
+ return { amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate };
115
+ }
116
+ function destinationAmount(receivedSourceLD, sourceDecimals, destinationDecimals, sharedDecimals) {
117
+ const { amountSD, dustLD } = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);
118
+ if (dustLD !== 0n) throw new RangeError("stargate: quote receipt is not shared-decimal aligned");
119
+ const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);
120
+ uint256(amount);
121
+ return amount;
122
+ }
123
+ function sourceMinimum(minDestinationLD, sourceDecimals, destinationDecimals, sharedDecimals) {
124
+ uint256(minDestinationLD);
125
+ const destinationRate = conversionRate(destinationDecimals, sharedDecimals);
126
+ const minimumSD = (minDestinationLD + destinationRate - 1n) / destinationRate;
127
+ if (minimumSD > UINT64_MAX) throw new RangeError("stargate: minimum exceeds uint64 shared amount");
128
+ const minimumLD = minimumSD * conversionRate(sourceDecimals, sharedDecimals);
129
+ uint256(minimumLD);
130
+ return minimumLD;
131
+ }
132
+
133
+ // src/registry.ts
134
+ var import_viem2 = require("viem");
135
+ function boundedInteger(value, max, name) {
136
+ if (!Number.isSafeInteger(value) || value <= 0 || value > max) throw new Error(`stargate registry: invalid ${name}`);
137
+ }
138
+ function address(value, nonzero) {
139
+ if (!(0, import_viem2.isAddress)(value) || nonzero && value.toLowerCase() === import_viem2.zeroAddress) throw new Error("stargate registry: invalid address");
140
+ return (0, import_viem2.getAddress)(value);
141
+ }
142
+ function createStargateRegistry(input, inputPaths) {
143
+ const ids = /* @__PURE__ */ new Map();
144
+ const tokens = /* @__PURE__ */ new Map();
145
+ const contracts = /* @__PURE__ */ new Set();
146
+ const chains = /* @__PURE__ */ new Map();
147
+ const eids = /* @__PURE__ */ new Map();
148
+ const shared = /* @__PURE__ */ new Map();
149
+ const deployments2 = Object.freeze(input.map((raw) => {
150
+ boundedInteger(raw.chainId, Number.MAX_SAFE_INTEGER, "chainId");
151
+ boundedInteger(raw.eid, 4294967295, "eid");
152
+ boundedInteger(raw.assetId, 65535, "assetId");
153
+ if (raw.chain !== `eip155:${raw.chainId}`) throw new Error("stargate registry: chainId mismatch");
154
+ conversionRate(raw.localDecimals, raw.sharedDecimals);
155
+ if (!["pool", "oft", "native"].includes(raw.kind) || typeof raw.approvalRequired !== "boolean" || typeof raw.symbol !== "string" || !raw.symbol.trim()) throw new Error("stargate registry: malformed deployment");
156
+ const d = Object.freeze({ ...raw, token: address(raw.token, false), address: address(raw.address, true), tokenMessaging: address(raw.tokenMessaging, true), endpoint: address(raw.endpoint, true) });
157
+ if (d.kind === "native" !== (d.token === import_viem2.zeroAddress)) throw new Error("stargate registry: native token mismatch");
158
+ const identity = `${d.chain}:${d.assetId}`;
159
+ const tokenKey = `${d.chain}:${d.token.toLowerCase()}`;
160
+ const contractKey = `${d.chain}:${d.address.toLowerCase()}`;
161
+ if (ids.has(identity) || tokens.has(tokenKey) || contracts.has(contractKey)) throw new Error("stargate registry: duplicate deployment");
162
+ const chain = chains.get(d.chain);
163
+ if (chain && (chain.eid !== d.eid || chain.tokenMessaging !== d.tokenMessaging || chain.endpoint !== d.endpoint)) throw new Error("stargate registry: inconsistent chain messaging");
164
+ if (eids.has(d.eid) && eids.get(d.eid) !== d.chain) throw new Error("stargate registry: eid names multiple chains");
165
+ if (shared.has(d.assetId) && shared.get(d.assetId) !== d.sharedDecimals) throw new Error("stargate registry: incompatible shared decimals");
166
+ ids.set(identity, d);
167
+ tokens.set(tokenKey, d);
168
+ contracts.add(contractKey);
169
+ chains.set(d.chain, d);
170
+ eids.set(d.eid, d.chain);
171
+ shared.set(d.assetId, d.sharedDecimals);
172
+ return d;
173
+ }));
174
+ const pathKeys = /* @__PURE__ */ new Set();
175
+ const paths2 = Object.freeze(inputPaths.map((path) => {
176
+ if (path.source === path.destination || !chains.has(path.source) || !chains.has(path.destination)) throw new Error("stargate registry: invalid path");
177
+ const key = `${path.source}>${path.destination}`;
178
+ if (pathKeys.has(key)) throw new Error("stargate registry: duplicate path");
179
+ pathKeys.add(key);
180
+ return Object.freeze({ source: path.source, destination: path.destination });
181
+ }));
182
+ const lookup = (chain, token) => chains.has(chain) && (0, import_viem2.isAddress)(token, { strict: false }) ? tokens.get(`${chain}:${token.toLowerCase()}`) : void 0;
183
+ return Object.freeze({
184
+ deployments: deployments2,
185
+ paths: paths2,
186
+ find: lookup,
187
+ route(sourceChain, sourceToken, destinationChain, destinationToken) {
188
+ if (!pathKeys.has(`${sourceChain}>${destinationChain}`)) return void 0;
189
+ const source = lookup(sourceChain, sourceToken), destination = lookup(destinationChain, destinationToken);
190
+ return source && destination && source.assetId === destination.assetId ? { source, destination } : void 0;
191
+ },
192
+ callTargets: (chain) => Object.freeze(deployments2.filter((d) => d.chain === chain).map((d) => d.address)),
193
+ spenders: (chain) => Object.freeze(deployments2.filter((d) => d.chain === chain && d.kind !== "native" && d.approvalRequired).map((d) => d.address))
194
+ });
195
+ }
196
+
197
+ // src/deployments.ts
198
+ var STARGATE_REGISTRY_EVIDENCE = Object.freeze({
199
+ "upstreamCommit": "414f47412123d7737520c6ba331c1376ec874a88",
200
+ "capturedAt": "2026-11-16T14:40:36.782Z",
201
+ "sha256": "ab4fba3cc845a3dcb8a804bffc6a53d7f7982bf974b45cec686095eefb70426f"
202
+ });
203
+ var deployments = [
204
+ { "chain": "eip155:42161", "chainId": 42161, "eid": 30110, "assetId": 1, "symbol": "USDC", "token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "address": "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3", "tokenMessaging": "0x19cFCE47eD54a88614648DC3f19A5980097007dD", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
205
+ { "chain": "eip155:42161", "chainId": 42161, "eid": 30110, "assetId": 13, "symbol": "ETH", "token": "0x0000000000000000000000000000000000000000", "address": "0xA45B5130f36CDcA45667738e2a258AB09f4A5f7F", "tokenMessaging": "0x19cFCE47eD54a88614648DC3f19A5980097007dD", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "native", "approvalRequired": true },
206
+ { "chain": "eip155:43114", "chainId": 43114, "eid": 30106, "assetId": 1, "symbol": "USDC", "token": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", "address": "0x5634c4a5FEd09819E3c46D86A965Dd9447d86e47", "tokenMessaging": "0x17E450Be3Ba9557F2378E20d64AD417E59Ef9A34", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
207
+ { "chain": "eip155:43114", "chainId": 43114, "eid": 30106, "assetId": 2, "symbol": "USDt", "token": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", "address": "0x12dC9256Acc9895B076f6638D628382881e62CeE", "tokenMessaging": "0x17E450Be3Ba9557F2378E20d64AD417E59Ef9A34", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
208
+ { "chain": "eip155:8453", "chainId": 8453, "eid": 30184, "assetId": 1, "symbol": "USDC", "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "address": "0x27a16dc786820B16E5c9028b75B99F6f604b5d26", "tokenMessaging": "0x5634c4a5FEd09819E3c46D86A965Dd9447d86e47", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
209
+ { "chain": "eip155:8453", "chainId": 8453, "eid": 30184, "assetId": 13, "symbol": "ETH", "token": "0x0000000000000000000000000000000000000000", "address": "0xdc181Bd607330aeeBEF6ea62e03e5e1Fb4B6F7C7", "tokenMessaging": "0x5634c4a5FEd09819E3c46D86A965Dd9447d86e47", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "native", "approvalRequired": true },
210
+ { "chain": "eip155:56", "chainId": 56, "eid": 30102, "assetId": 1, "symbol": "USDC", "token": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d", "address": "0x962Bd449E630b0d928f308Ce63f1A21F02576057", "tokenMessaging": "0x6E3d884C96d640526F273C61dfcF08915eBd7e2B", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
211
+ { "chain": "eip155:56", "chainId": 56, "eid": 30102, "assetId": 2, "symbol": "USDT", "token": "0x55d398326f99059fF775485246999027B3197955", "address": "0x138EB30f73BC423c6455C53df6D89CB01d9eBc63", "tokenMessaging": "0x6E3d884C96d640526F273C61dfcF08915eBd7e2B", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
212
+ { "chain": "eip155:1", "chainId": 1, "eid": 30101, "assetId": 1, "symbol": "USDC", "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "address": "0xc026395860Db2d07ee33e05fE50ed7bD583189C7", "tokenMessaging": "0x6d6620eFa72948C5f68A3C8646d58C00d3f4A980", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
213
+ { "chain": "eip155:1", "chainId": 1, "eid": 30101, "assetId": 2, "symbol": "USDT", "token": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "address": "0x933597a323Eb81cAe705C5bC29985172fd5A3973", "tokenMessaging": "0x6d6620eFa72948C5f68A3C8646d58C00d3f4A980", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
214
+ { "chain": "eip155:1", "chainId": 1, "eid": 30101, "assetId": 13, "symbol": "ETH", "token": "0x0000000000000000000000000000000000000000", "address": "0x77b2043768d28E9C9aB44E1aBfC95944bcE57931", "tokenMessaging": "0x6d6620eFa72948C5f68A3C8646d58C00d3f4A980", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "native", "approvalRequired": true },
215
+ { "chain": "eip155:14", "chainId": 14, "eid": 30295, "assetId": 1, "symbol": "USDC.e", "token": "0xFbDa5F676cB37624f28265A144A48B0d6e87d3b6", "address": "0x77C71633C34C3784ede189d74223122422492a0f", "tokenMessaging": "0x45d417612e177672958dC0537C45a8f8d754Ac2E", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "oft", "approvalRequired": true },
216
+ { "chain": "eip155:14", "chainId": 14, "eid": 30295, "assetId": 13, "symbol": "WETH", "token": "0x1502FA4be69d526124D453619276FacCab275d3D", "address": "0x8e8539e4CcD69123c623a106773F2b0cbbc58746", "tokenMessaging": "0x45d417612e177672958dC0537C45a8f8d754Ac2E", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "oft", "approvalRequired": true },
217
+ { "chain": "eip155:5000", "chainId": 5e3, "eid": 30181, "assetId": 1, "symbol": "USDC", "token": "0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9", "address": "0xAc290Ad4e0c891FDc295ca4F0a6214cf6dC6acDC", "tokenMessaging": "0x41B491285A4f888F9f636cEc8a363AB9770a0AEF", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
218
+ { "chain": "eip155:5000", "chainId": 5e3, "eid": 30181, "assetId": 13, "symbol": "WETH", "token": "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111", "address": "0x4c1d3Fc3fC3c177c3b633427c2F769276c547463", "tokenMessaging": "0x41B491285A4f888F9f636cEc8a363AB9770a0AEF", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
219
+ { "chain": "eip155:5000", "chainId": 5e3, "eid": 30181, "assetId": 22, "symbol": "mETH", "token": "0xcDA86A272531e8640cD7F1a92c01839911B90bb0", "address": "0xF7628d84a2BbD9bb9c8E686AC95BB5d55169F3F1", "tokenMessaging": "0x41B491285A4f888F9f636cEc8a363AB9770a0AEF", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
220
+ { "chain": "eip155:10", "chainId": 10, "eid": 30111, "assetId": 1, "symbol": "USDC", "token": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", "address": "0xcE8CcA271Ebc0533920C83d39F417ED6A0abB7D0", "tokenMessaging": "0xF1fCb4CBd57B67d683972A59B6a7b1e2E8Bf27E6", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
221
+ { "chain": "eip155:10", "chainId": 10, "eid": 30111, "assetId": 13, "symbol": "ETH", "token": "0x0000000000000000000000000000000000000000", "address": "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3", "tokenMessaging": "0xF1fCb4CBd57B67d683972A59B6a7b1e2E8Bf27E6", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "native", "approvalRequired": true },
222
+ { "chain": "eip155:9745", "chainId": 9745, "eid": 30383, "assetId": 13, "symbol": "WETH", "token": "0x9895D81bB462A195b4922ED7De0e3ACD007c32CB", "address": "0x0cEb237E109eE22374a567c6b09F373C73FA4cBb", "tokenMessaging": "0x102d758f688a4C1C5a80b116bD945d4455460282", "endpoint": "0x6F475642a6e85809B1c36Fa62763669b1b48DD5B", "localDecimals": 18, "sharedDecimals": 6, "kind": "oft", "approvalRequired": true },
223
+ { "chain": "eip155:98866", "chainId": 98866, "eid": 30370, "assetId": 13, "symbol": "WETH", "token": "0xca59cA09E5602fAe8B629DeE83FfA819741f14be", "address": "0x4683CE822272CD66CEa73F5F1f9f5cBcaEF4F066", "tokenMessaging": "0xf26d57bbE1D99561B13003783b5e040B71AdCb14", "endpoint": "0xC1b15d3B262bEeC0e3565C11C9e0F6134BdaCB36", "localDecimals": 18, "sharedDecimals": 6, "kind": "oft", "approvalRequired": true },
224
+ { "chain": "eip155:137", "chainId": 137, "eid": 30109, "assetId": 1, "symbol": "USDC", "token": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", "address": "0x9Aa02D4Fae7F58b8E8f34c66E756cC734DAc7fe4", "tokenMessaging": "0x6CE9bf8CDaB780416AD1fd87b318A077D2f50EaC", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
225
+ { "chain": "eip155:534352", "chainId": 534352, "eid": 30214, "assetId": 13, "symbol": "ETH", "token": "0x0000000000000000000000000000000000000000", "address": "0xC2b638Cb5042c1B3c5d5C969361fB50569840583", "tokenMessaging": "0x4e422B0aCb2Bd7e3aC70B5c0E5eb806e86a94038", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "native", "approvalRequired": true },
226
+ { "chain": "eip155:1329", "chainId": 1329, "eid": 30280, "assetId": 13, "symbol": "WETH", "token": "0x160345fC359604fC6e70E3c5fAcbdE5F7A9342d8", "address": "0x5c386D85b1B82FD9Db681b9176C8a4248bb6345B", "tokenMessaging": "0x1502FA4be69d526124D453619276FacCab275d3D", "endpoint": "0x1a44076050125825900e736c501f859c50fE728c", "localDecimals": 18, "sharedDecimals": 6, "kind": "oft", "approvalRequired": true },
227
+ { "chain": "eip155:146", "chainId": 146, "eid": 30332, "assetId": 1, "symbol": "USDC", "token": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894", "address": "0xA272fFe20cFfe769CdFc4b63088DCD2C82a2D8F9", "tokenMessaging": "0x2086f755A6d9254045C257ea3d382ef854849B0f", "endpoint": "0x6F475642a6e85809B1c36Fa62763669b1b48DD5B", "localDecimals": 6, "sharedDecimals": 6, "kind": "pool", "approvalRequired": true },
228
+ { "chain": "eip155:130", "chainId": 130, "eid": 30320, "assetId": 13, "symbol": "ETH", "token": "0x0000000000000000000000000000000000000000", "address": "0xe9aBA835f813ca05E50A6C0ce65D0D74390F7dE7", "tokenMessaging": "0xB1EeAD6959cb5bB9B20417d6689922523B2B86C3", "endpoint": "0x6F475642a6e85809B1c36Fa62763669b1b48DD5B", "localDecimals": 18, "sharedDecimals": 6, "kind": "native", "approvalRequired": true }
229
+ ];
230
+ var paths = [
231
+ { "source": "eip155:1", "destination": "eip155:10" },
232
+ { "source": "eip155:1", "destination": "eip155:130" },
233
+ { "source": "eip155:1", "destination": "eip155:1329" },
234
+ { "source": "eip155:1", "destination": "eip155:137" },
235
+ { "source": "eip155:1", "destination": "eip155:14" },
236
+ { "source": "eip155:1", "destination": "eip155:146" },
237
+ { "source": "eip155:1", "destination": "eip155:42161" },
238
+ { "source": "eip155:1", "destination": "eip155:43114" },
239
+ { "source": "eip155:1", "destination": "eip155:5000" },
240
+ { "source": "eip155:1", "destination": "eip155:534352" },
241
+ { "source": "eip155:1", "destination": "eip155:56" },
242
+ { "source": "eip155:1", "destination": "eip155:8453" },
243
+ { "source": "eip155:1", "destination": "eip155:9745" },
244
+ { "source": "eip155:1", "destination": "eip155:98866" },
245
+ { "source": "eip155:10", "destination": "eip155:1" },
246
+ { "source": "eip155:10", "destination": "eip155:130" },
247
+ { "source": "eip155:10", "destination": "eip155:1329" },
248
+ { "source": "eip155:10", "destination": "eip155:137" },
249
+ { "source": "eip155:10", "destination": "eip155:14" },
250
+ { "source": "eip155:10", "destination": "eip155:146" },
251
+ { "source": "eip155:10", "destination": "eip155:42161" },
252
+ { "source": "eip155:10", "destination": "eip155:43114" },
253
+ { "source": "eip155:10", "destination": "eip155:5000" },
254
+ { "source": "eip155:10", "destination": "eip155:534352" },
255
+ { "source": "eip155:10", "destination": "eip155:56" },
256
+ { "source": "eip155:10", "destination": "eip155:8453" },
257
+ { "source": "eip155:10", "destination": "eip155:9745" },
258
+ { "source": "eip155:10", "destination": "eip155:98866" },
259
+ { "source": "eip155:130", "destination": "eip155:1" },
260
+ { "source": "eip155:130", "destination": "eip155:10" },
261
+ { "source": "eip155:130", "destination": "eip155:1329" },
262
+ { "source": "eip155:130", "destination": "eip155:137" },
263
+ { "source": "eip155:130", "destination": "eip155:14" },
264
+ { "source": "eip155:130", "destination": "eip155:146" },
265
+ { "source": "eip155:130", "destination": "eip155:42161" },
266
+ { "source": "eip155:130", "destination": "eip155:43114" },
267
+ { "source": "eip155:130", "destination": "eip155:5000" },
268
+ { "source": "eip155:130", "destination": "eip155:534352" },
269
+ { "source": "eip155:130", "destination": "eip155:56" },
270
+ { "source": "eip155:130", "destination": "eip155:8453" },
271
+ { "source": "eip155:130", "destination": "eip155:9745" },
272
+ { "source": "eip155:130", "destination": "eip155:98866" },
273
+ { "source": "eip155:1329", "destination": "eip155:1" },
274
+ { "source": "eip155:1329", "destination": "eip155:10" },
275
+ { "source": "eip155:1329", "destination": "eip155:130" },
276
+ { "source": "eip155:1329", "destination": "eip155:137" },
277
+ { "source": "eip155:1329", "destination": "eip155:14" },
278
+ { "source": "eip155:1329", "destination": "eip155:146" },
279
+ { "source": "eip155:1329", "destination": "eip155:42161" },
280
+ { "source": "eip155:1329", "destination": "eip155:43114" },
281
+ { "source": "eip155:1329", "destination": "eip155:5000" },
282
+ { "source": "eip155:1329", "destination": "eip155:534352" },
283
+ { "source": "eip155:1329", "destination": "eip155:56" },
284
+ { "source": "eip155:1329", "destination": "eip155:8453" },
285
+ { "source": "eip155:1329", "destination": "eip155:9745" },
286
+ { "source": "eip155:1329", "destination": "eip155:98866" },
287
+ { "source": "eip155:137", "destination": "eip155:1" },
288
+ { "source": "eip155:137", "destination": "eip155:10" },
289
+ { "source": "eip155:137", "destination": "eip155:130" },
290
+ { "source": "eip155:137", "destination": "eip155:1329" },
291
+ { "source": "eip155:137", "destination": "eip155:14" },
292
+ { "source": "eip155:137", "destination": "eip155:146" },
293
+ { "source": "eip155:137", "destination": "eip155:42161" },
294
+ { "source": "eip155:137", "destination": "eip155:43114" },
295
+ { "source": "eip155:137", "destination": "eip155:5000" },
296
+ { "source": "eip155:137", "destination": "eip155:534352" },
297
+ { "source": "eip155:137", "destination": "eip155:56" },
298
+ { "source": "eip155:137", "destination": "eip155:8453" },
299
+ { "source": "eip155:137", "destination": "eip155:9745" },
300
+ { "source": "eip155:137", "destination": "eip155:98866" },
301
+ { "source": "eip155:14", "destination": "eip155:1" },
302
+ { "source": "eip155:14", "destination": "eip155:10" },
303
+ { "source": "eip155:14", "destination": "eip155:130" },
304
+ { "source": "eip155:14", "destination": "eip155:1329" },
305
+ { "source": "eip155:14", "destination": "eip155:137" },
306
+ { "source": "eip155:14", "destination": "eip155:146" },
307
+ { "source": "eip155:14", "destination": "eip155:42161" },
308
+ { "source": "eip155:14", "destination": "eip155:43114" },
309
+ { "source": "eip155:14", "destination": "eip155:5000" },
310
+ { "source": "eip155:14", "destination": "eip155:534352" },
311
+ { "source": "eip155:14", "destination": "eip155:56" },
312
+ { "source": "eip155:14", "destination": "eip155:8453" },
313
+ { "source": "eip155:14", "destination": "eip155:9745" },
314
+ { "source": "eip155:14", "destination": "eip155:98866" },
315
+ { "source": "eip155:146", "destination": "eip155:1" },
316
+ { "source": "eip155:146", "destination": "eip155:10" },
317
+ { "source": "eip155:146", "destination": "eip155:130" },
318
+ { "source": "eip155:146", "destination": "eip155:1329" },
319
+ { "source": "eip155:146", "destination": "eip155:137" },
320
+ { "source": "eip155:146", "destination": "eip155:14" },
321
+ { "source": "eip155:146", "destination": "eip155:42161" },
322
+ { "source": "eip155:146", "destination": "eip155:43114" },
323
+ { "source": "eip155:146", "destination": "eip155:5000" },
324
+ { "source": "eip155:146", "destination": "eip155:534352" },
325
+ { "source": "eip155:146", "destination": "eip155:56" },
326
+ { "source": "eip155:146", "destination": "eip155:8453" },
327
+ { "source": "eip155:146", "destination": "eip155:9745" },
328
+ { "source": "eip155:146", "destination": "eip155:98866" },
329
+ { "source": "eip155:42161", "destination": "eip155:1" },
330
+ { "source": "eip155:42161", "destination": "eip155:10" },
331
+ { "source": "eip155:42161", "destination": "eip155:130" },
332
+ { "source": "eip155:42161", "destination": "eip155:1329" },
333
+ { "source": "eip155:42161", "destination": "eip155:137" },
334
+ { "source": "eip155:42161", "destination": "eip155:14" },
335
+ { "source": "eip155:42161", "destination": "eip155:146" },
336
+ { "source": "eip155:42161", "destination": "eip155:43114" },
337
+ { "source": "eip155:42161", "destination": "eip155:5000" },
338
+ { "source": "eip155:42161", "destination": "eip155:534352" },
339
+ { "source": "eip155:42161", "destination": "eip155:56" },
340
+ { "source": "eip155:42161", "destination": "eip155:8453" },
341
+ { "source": "eip155:42161", "destination": "eip155:9745" },
342
+ { "source": "eip155:42161", "destination": "eip155:98866" },
343
+ { "source": "eip155:43114", "destination": "eip155:1" },
344
+ { "source": "eip155:43114", "destination": "eip155:10" },
345
+ { "source": "eip155:43114", "destination": "eip155:130" },
346
+ { "source": "eip155:43114", "destination": "eip155:1329" },
347
+ { "source": "eip155:43114", "destination": "eip155:137" },
348
+ { "source": "eip155:43114", "destination": "eip155:14" },
349
+ { "source": "eip155:43114", "destination": "eip155:146" },
350
+ { "source": "eip155:43114", "destination": "eip155:42161" },
351
+ { "source": "eip155:43114", "destination": "eip155:5000" },
352
+ { "source": "eip155:43114", "destination": "eip155:534352" },
353
+ { "source": "eip155:43114", "destination": "eip155:56" },
354
+ { "source": "eip155:43114", "destination": "eip155:8453" },
355
+ { "source": "eip155:43114", "destination": "eip155:9745" },
356
+ { "source": "eip155:43114", "destination": "eip155:98866" },
357
+ { "source": "eip155:5000", "destination": "eip155:1" },
358
+ { "source": "eip155:5000", "destination": "eip155:10" },
359
+ { "source": "eip155:5000", "destination": "eip155:130" },
360
+ { "source": "eip155:5000", "destination": "eip155:1329" },
361
+ { "source": "eip155:5000", "destination": "eip155:137" },
362
+ { "source": "eip155:5000", "destination": "eip155:14" },
363
+ { "source": "eip155:5000", "destination": "eip155:146" },
364
+ { "source": "eip155:5000", "destination": "eip155:42161" },
365
+ { "source": "eip155:5000", "destination": "eip155:43114" },
366
+ { "source": "eip155:5000", "destination": "eip155:534352" },
367
+ { "source": "eip155:5000", "destination": "eip155:56" },
368
+ { "source": "eip155:5000", "destination": "eip155:8453" },
369
+ { "source": "eip155:5000", "destination": "eip155:9745" },
370
+ { "source": "eip155:5000", "destination": "eip155:98866" },
371
+ { "source": "eip155:534352", "destination": "eip155:1" },
372
+ { "source": "eip155:534352", "destination": "eip155:10" },
373
+ { "source": "eip155:534352", "destination": "eip155:130" },
374
+ { "source": "eip155:534352", "destination": "eip155:1329" },
375
+ { "source": "eip155:534352", "destination": "eip155:137" },
376
+ { "source": "eip155:534352", "destination": "eip155:14" },
377
+ { "source": "eip155:534352", "destination": "eip155:146" },
378
+ { "source": "eip155:534352", "destination": "eip155:42161" },
379
+ { "source": "eip155:534352", "destination": "eip155:43114" },
380
+ { "source": "eip155:534352", "destination": "eip155:5000" },
381
+ { "source": "eip155:534352", "destination": "eip155:56" },
382
+ { "source": "eip155:534352", "destination": "eip155:8453" },
383
+ { "source": "eip155:534352", "destination": "eip155:9745" },
384
+ { "source": "eip155:534352", "destination": "eip155:98866" },
385
+ { "source": "eip155:56", "destination": "eip155:1" },
386
+ { "source": "eip155:56", "destination": "eip155:10" },
387
+ { "source": "eip155:56", "destination": "eip155:130" },
388
+ { "source": "eip155:56", "destination": "eip155:1329" },
389
+ { "source": "eip155:56", "destination": "eip155:137" },
390
+ { "source": "eip155:56", "destination": "eip155:14" },
391
+ { "source": "eip155:56", "destination": "eip155:146" },
392
+ { "source": "eip155:56", "destination": "eip155:42161" },
393
+ { "source": "eip155:56", "destination": "eip155:43114" },
394
+ { "source": "eip155:56", "destination": "eip155:5000" },
395
+ { "source": "eip155:56", "destination": "eip155:534352" },
396
+ { "source": "eip155:56", "destination": "eip155:8453" },
397
+ { "source": "eip155:56", "destination": "eip155:9745" },
398
+ { "source": "eip155:56", "destination": "eip155:98866" },
399
+ { "source": "eip155:8453", "destination": "eip155:1" },
400
+ { "source": "eip155:8453", "destination": "eip155:10" },
401
+ { "source": "eip155:8453", "destination": "eip155:130" },
402
+ { "source": "eip155:8453", "destination": "eip155:1329" },
403
+ { "source": "eip155:8453", "destination": "eip155:137" },
404
+ { "source": "eip155:8453", "destination": "eip155:14" },
405
+ { "source": "eip155:8453", "destination": "eip155:146" },
406
+ { "source": "eip155:8453", "destination": "eip155:42161" },
407
+ { "source": "eip155:8453", "destination": "eip155:43114" },
408
+ { "source": "eip155:8453", "destination": "eip155:5000" },
409
+ { "source": "eip155:8453", "destination": "eip155:534352" },
410
+ { "source": "eip155:8453", "destination": "eip155:56" },
411
+ { "source": "eip155:8453", "destination": "eip155:9745" },
412
+ { "source": "eip155:8453", "destination": "eip155:98866" },
413
+ { "source": "eip155:9745", "destination": "eip155:1" },
414
+ { "source": "eip155:9745", "destination": "eip155:10" },
415
+ { "source": "eip155:9745", "destination": "eip155:130" },
416
+ { "source": "eip155:9745", "destination": "eip155:1329" },
417
+ { "source": "eip155:9745", "destination": "eip155:137" },
418
+ { "source": "eip155:9745", "destination": "eip155:14" },
419
+ { "source": "eip155:9745", "destination": "eip155:146" },
420
+ { "source": "eip155:9745", "destination": "eip155:42161" },
421
+ { "source": "eip155:9745", "destination": "eip155:43114" },
422
+ { "source": "eip155:9745", "destination": "eip155:5000" },
423
+ { "source": "eip155:9745", "destination": "eip155:534352" },
424
+ { "source": "eip155:9745", "destination": "eip155:56" },
425
+ { "source": "eip155:9745", "destination": "eip155:8453" },
426
+ { "source": "eip155:9745", "destination": "eip155:98866" },
427
+ { "source": "eip155:98866", "destination": "eip155:1" },
428
+ { "source": "eip155:98866", "destination": "eip155:10" },
429
+ { "source": "eip155:98866", "destination": "eip155:130" },
430
+ { "source": "eip155:98866", "destination": "eip155:1329" },
431
+ { "source": "eip155:98866", "destination": "eip155:137" },
432
+ { "source": "eip155:98866", "destination": "eip155:14" },
433
+ { "source": "eip155:98866", "destination": "eip155:146" },
434
+ { "source": "eip155:98866", "destination": "eip155:42161" },
435
+ { "source": "eip155:98866", "destination": "eip155:43114" },
436
+ { "source": "eip155:98866", "destination": "eip155:5000" },
437
+ { "source": "eip155:98866", "destination": "eip155:534352" },
438
+ { "source": "eip155:98866", "destination": "eip155:56" },
439
+ { "source": "eip155:98866", "destination": "eip155:8453" },
440
+ { "source": "eip155:98866", "destination": "eip155:9745" }
441
+ ];
442
+ var stargateRegistry = createStargateRegistry(deployments, paths);
443
+
444
+ // src/intent.ts
445
+ var import_viem4 = require("viem");
446
+ var import_swap2_assets = require("@anywalletkit/swap2-assets");
447
+
448
+ // src/rpc.ts
449
+ var import_viem3 = require("viem");
450
+ var StargateReadError = class extends Error {
451
+ constructor(message) {
452
+ super(`stargate: ${message}`);
453
+ this.name = "StargateReadError";
454
+ }
455
+ };
456
+ var auxiliaryAbi = (0, import_viem3.parseAbi)(["function decimals() view returns (uint8)", "function eid() view returns (uint32)"]);
457
+ var sameAddress = (a, b) => a.toLowerCase() === b.toLowerCase();
458
+ function assertStargate(condition, message) {
459
+ if (!condition) throw new StargateReadError(message);
460
+ }
461
+ function assertNotAborted(signal) {
462
+ if (signal?.aborted) throw new StargateReadError("request cancelled");
463
+ }
464
+ function stargateRpc(config) {
465
+ const urls = new Map(Object.entries(config.rpcUrls).map(([chain, value]) => {
466
+ const list = typeof value === "string" ? [value] : [...value];
467
+ assertStargate(list.length && list.every((url) => /^https?:\/\//.test(url)), "invalid RPC configuration");
468
+ return [chain, list];
469
+ }));
470
+ function client(chain, signal) {
471
+ const list = urls.get(chain);
472
+ assertStargate(list, `no RPC configured for ${chain}`);
473
+ assertNotAborted(signal);
474
+ const transport = (url) => (0, import_viem3.http)(url, { timeout: 12e3, retryCount: 0, ...config.fetchImpl ? { fetchFn: config.fetchImpl } : {}, ...signal ? { fetchOptions: { signal } } : {} });
475
+ return (0, import_viem3.createPublicClient)({ transport: list.length === 1 ? transport(list[0]) : (0, import_viem3.fallback)(list.map(transport), { retryCount: 0 }), ccipRead: false });
476
+ }
477
+ async function snapshot(c, chainId) {
478
+ const [actual, block] = await Promise.all([c.getChainId(), c.getBlock({ blockTag: "latest" })]);
479
+ assertStargate(actual === chainId, "RPC chain id mismatch");
480
+ assertStargate(block.hash && block.number !== null, "RPC returned an unmined block");
481
+ const now = BigInt(Math.floor(Date.now() / 1e3));
482
+ assertStargate(block.timestamp >= now - 300n && block.timestamp <= now + 60n, "RPC block is stale or in the future");
483
+ return Object.freeze({ number: block.number, hash: block.hash, timestamp: block.timestamp });
484
+ }
485
+ async function verify(c, d, peer, block) {
486
+ const at = { blockNumber: block.number };
487
+ const pool = { address: d.address, abi: STARGATE_ABI, ...at };
488
+ const messaging = { address: d.tokenMessaging, abi: TOKEN_MESSAGING_ABI, ...at };
489
+ const [token, shared, approval, eid, endpoint, status, kind, roles, assetId, implementation, messagingEndpoint, remotePeer, endpointEid, decimals] = await Promise.all([
490
+ c.readContract({ ...pool, functionName: "token" }),
491
+ c.readContract({ ...pool, functionName: "sharedDecimals" }),
492
+ c.readContract({ ...pool, functionName: "approvalRequired" }),
493
+ c.readContract({ ...pool, functionName: "localEid" }),
494
+ c.readContract({ ...pool, functionName: "endpoint" }),
495
+ c.readContract({ ...pool, functionName: "status" }),
496
+ c.readContract({ ...pool, functionName: "stargateType" }),
497
+ c.readContract({ ...pool, functionName: "getAddressConfig" }),
498
+ c.readContract({ ...messaging, functionName: "assetIds", args: [d.address] }),
499
+ c.readContract({ ...messaging, functionName: "stargateImpls", args: [d.assetId] }),
500
+ c.readContract({ ...messaging, functionName: "endpoint" }),
501
+ c.readContract({ ...messaging, functionName: "peers", args: [peer.eid] }),
502
+ c.readContract({ address: d.endpoint, abi: auxiliaryAbi, functionName: "eid", ...at }),
503
+ d.kind === "native" ? Promise.resolve(d.localDecimals) : c.readContract({ address: d.token, abi: auxiliaryAbi, functionName: "decimals", ...at })
504
+ ]);
505
+ assertStargate(sameAddress(token, d.token) && shared === d.sharedDecimals && decimals === d.localDecimals && approval === d.approvalRequired && eid === d.eid && endpointEid === d.eid && sameAddress(endpoint, d.endpoint) && sameAddress(messagingEndpoint, d.endpoint) && sameAddress(roles.tokenMessaging, d.tokenMessaging) && assetId === d.assetId && sameAddress(implementation, d.address) && kind === (d.kind === "oft" ? 1 : 0), `deployment identity changed on ${d.chain}`);
506
+ assertStargate(status === 1, `deployment is not active on ${d.chain}`);
507
+ assertStargate(sameAddress(remotePeer, (0, import_viem3.pad)(peer.tokenMessaging, { size: 32 })), `messaging peer mismatch on ${d.chain}`);
508
+ }
509
+ async function unchanged(c, block) {
510
+ assertStargate((await c.getBlock({ blockNumber: block.number })).hash === block.hash, "block changed during quote");
511
+ }
512
+ return { has: (chain) => urls.has(chain), client, snapshot, verify, unchanged };
513
+ }
514
+ function nonzeroAddress(value) {
515
+ return /^0x[0-9a-fA-F]{40}$/.test(value) && !/^0x0{40}$/.test(value);
516
+ }
517
+
518
+ // src/intent.ts
519
+ function parseStargateIntent(id, registry) {
520
+ const fields = id.split("~", 1)[0].split(":");
521
+ const [tag, version, srcEid, dstEid, assetId, mode, sender, recipient, amountText, minText, dropText] = fields;
522
+ assertStargate(fields.length === 11 && tag === "stargate" && version === "1" && (mode === "taxi" || mode === "bus"), "invalid intent identity");
523
+ assertStargate([srcEid, dstEid, assetId, amountText, minText, dropText].every((v) => typeof v === "string" && /^(0|[1-9][0-9]{0,77})$/.test(v)), "invalid intent amounts");
524
+ assertStargate(sender && recipient && nonzeroAddress(sender) && nonzeroAddress(recipient), "invalid intent actors");
525
+ const source = registry.deployments.find((d) => String(d.eid) === srcEid && String(d.assetId) === assetId);
526
+ const destination = registry.deployments.find((d) => String(d.eid) === dstEid && String(d.assetId) === assetId);
527
+ assertStargate(source && destination && registry.route(source.chain, source.token, destination.chain, destination.token), "unreviewed intent route");
528
+ const amount = BigInt(amountText), minimum = BigInt(minText), nativeDrop = BigInt(dropText);
529
+ assertStargate(splitSourceAmount(amount, source.localDecimals, source.sharedDecimals).amountSD > 0n && minimum > 0n && nativeDrop < 1n << 128n, "invalid intent bounds");
530
+ assertStargate(destinationAmount(sourceMinimum(minimum, source.localDecimals, destination.localDecimals, source.sharedDecimals), source.localDecimals, destination.localDecimals, source.sharedDecimals) === minimum, "unaligned intent minimum");
531
+ return { source, destination, mode, sender: (0, import_viem4.getAddress)(sender), recipient: (0, import_viem4.getAddress)(recipient), amount, minimum, nativeDrop };
532
+ }
533
+
534
+ // src/bus.ts
535
+ var import_viem5 = require("viem");
536
+ var ZERO_HASH = `0x${"00".repeat(32)}`;
537
+ var byteLength = (hex) => (hex.length - 2) / 2;
538
+ function decodeBusPassenger(bytes) {
539
+ assertStargate(/^0x[0-9a-f]{86}$/i.test(bytes), "invalid Bus passenger bytes");
540
+ const flag = (0, import_viem5.slice)(bytes, 42, 43);
541
+ assertStargate(flag === "0x00" || flag === "0x01", "invalid Bus native-drop flag");
542
+ return { assetId: BigInt((0, import_viem5.slice)(bytes, 0, 2)), receiver: (0, import_viem5.slice)(bytes, 2, 34), amountSD: BigInt((0, import_viem5.slice)(bytes, 34, 42)), nativeDrop: flag === "0x01", bytes };
543
+ }
544
+ function stargateBusTicket(i, receipt) {
545
+ assertStargate(i.mode === "bus" && receipt.status === "success", "not a successful Bus source receipt");
546
+ const sent = (0, import_viem5.parseEventLogs)({ abi: STARGATE_ABI, eventName: "OFTSent", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.address)), strict: true }).filter((l) => l.args.guid === ZERO_HASH && l.args.dstEid === i.destination.eid && sameAddress(l.args.fromAddress, i.sender));
547
+ assertStargate(sent.length === 1, "missing or ambiguous Bus send");
548
+ const a = sent[0].args;
549
+ assertStargate(a.amountSentLD === splitSourceAmount(i.amount, i.source.localDecimals, i.source.sharedDecimals).sentLD, "Bus source amount mismatch");
550
+ const amount = destinationAmount(a.amountReceivedLD, i.source.localDecimals, i.destination.localDecimals, i.source.sharedDecimals);
551
+ assertStargate(amount >= i.minimum, "Bus output below minimum");
552
+ const passenger = (0, import_viem5.encodePacked)(["uint16", "bytes32", "uint64", "bool"], [i.source.assetId, (0, import_viem5.pad)(i.recipient, { size: 32 }), a.amountReceivedLD / conversionRate(i.source.localDecimals, i.source.sharedDecimals), i.nativeDrop > 0n]);
553
+ const rides = (0, import_viem5.parseEventLogs)({ abi: TOKEN_MESSAGING_ABI, eventName: "BusRode", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.tokenMessaging)), strict: true }).filter((l) => l.args.dstEid === i.destination.eid && sameAddress(l.args.passenger, passenger));
554
+ assertStargate(rides.length === 1, "missing or ambiguous Bus ticket");
555
+ return { intent: i, ticketId: rides[0].args.ticketId, passenger, amount, sourceHash: receipt.transactionHash, sourceBlock: receipt.blockNumber };
556
+ }
557
+ function stargateBusProof(ticket, receipt) {
558
+ const i = ticket.intent;
559
+ assertStargate(receipt.status === "success" && receipt.blockNumber >= ticket.sourceBlock, "invalid Bus drive receipt");
560
+ const drives = (0, import_viem5.parseEventLogs)({ abi: TOKEN_MESSAGING_ABI, eventName: "BusDriven", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.tokenMessaging)), strict: true }).filter((l) => l.args.dstEid === i.destination.eid && l.args.startTicketId <= ticket.ticketId && ticket.ticketId < l.args.startTicketId + BigInt(l.args.numPassengers));
561
+ assertStargate(drives.length === 1, "ticket not uniquely covered by BusDriven");
562
+ const drive = drives[0].args;
563
+ assertStargate(drive.guid !== ZERO_HASH, "Bus drive has no GUID");
564
+ const packets = (0, import_viem5.parseEventLogs)({ abi: ENDPOINT_ABI, eventName: "PacketSent", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.endpoint)), strict: true }).filter((l) => byteLength(l.args.encodedPayload) >= 113 && sameAddress((0, import_viem5.slice)(l.args.encodedPayload, 81, 113), drive.guid));
565
+ assertStargate(packets.length === 1, "missing Bus endpoint packet");
566
+ const packet = packets[0].args.encodedPayload;
567
+ assertStargate((0, import_viem5.slice)(packet, 0, 1) === "0x01" && BigInt((0, import_viem5.slice)(packet, 9, 13)) === BigInt(i.source.eid) && BigInt((0, import_viem5.slice)(packet, 45, 49)) === BigInt(i.destination.eid) && sameAddress((0, import_viem5.slice)(packet, 13, 45), (0, import_viem5.pad)(i.source.tokenMessaging, { size: 32 })) && sameAddress((0, import_viem5.slice)(packet, 49, 81), (0, import_viem5.pad)(i.destination.tokenMessaging, { size: 32 })), "Bus packet pathway mismatch");
568
+ const message = (0, import_viem5.slice)(packet, 113);
569
+ assertStargate(byteLength(message) === 33 + drive.numPassengers * 43 && (0, import_viem5.slice)(message, 0, 1) === "0x02" && drive.numPassengers > 0, "Bus message size/type mismatch");
570
+ const passengers = Array.from({ length: drive.numPassengers }, (_, index) => decodeBusPassenger((0, import_viem5.slice)(message, 33 + index * 43, 33 + (index + 1) * 43)));
571
+ const seat = passengers.findIndex((_, index) => drive.startTicketId + BigInt(index) === ticket.ticketId);
572
+ assertStargate(seat >= 0 && sameAddress(passengers[seat].bytes, ticket.passenger), "ticket passenger differs from driven message");
573
+ const totalNativeDrops = BigInt((0, import_viem5.slice)(message, 1, 17)), nativeDropAmount = BigInt((0, import_viem5.slice)(message, 17, 33));
574
+ assertStargate(totalNativeDrops === BigInt(passengers.filter((p) => p.nativeDrop).length), "Bus native drop count mismatch");
575
+ return { ...ticket, guid: drive.guid, driveHash: receipt.transactionHash, nonce: BigInt((0, import_viem5.slice)(packet, 1, 9)), message, seat, passengers, totalNativeDrops, nativeDropAmount };
576
+ }
577
+ function stargateBusPayout(p, receipt) {
578
+ if (receipt.status !== "success") return null;
579
+ const i = p.intent;
580
+ const events = (0, import_viem5.parseEventLogs)({ abi: STARGATE_ABI, logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.address)), strict: true }).filter((l) => (l.eventName === "OFTReceived" || l.eventName === "UnreceivedTokenCached") && sameAddress(l.args.guid, p.guid));
581
+ const expected = p.passengers.flatMap((passenger, seat) => passenger.assetId === BigInt(i.source.assetId) ? [{ passenger, seat }] : []);
582
+ if (events.length !== expected.length) return null;
583
+ let result = null;
584
+ for (let index = 0; index < expected.length; index++) {
585
+ const { passenger, seat } = expected[index], event = events[index];
586
+ const amount = passenger.amountSD * conversionRate(i.destination.localDecimals, i.destination.sharedDecimals);
587
+ if (event.eventName === "OFTReceived") {
588
+ if (event.args.srcEid !== i.source.eid || !sameAddress((0, import_viem5.pad)(event.args.toAddress, { size: 32 }), passenger.receiver) || event.args.amountReceivedLD !== amount) return null;
589
+ if (seat === p.seat) result = "paid";
590
+ } else if (event.eventName === "UnreceivedTokenCached") {
591
+ if (event.args.index !== seat || event.args.srcEid !== i.source.eid || !sameAddress((0, import_viem5.pad)(event.args.receiver, { size: 32 }), passenger.receiver) || event.args.amountLD !== amount || event.args.composeMsg !== "0x") return null;
592
+ if (seat === p.seat) result = "cached";
593
+ } else return null;
594
+ }
595
+ return result;
596
+ }
597
+ function stargateBusNativeDrop(p, receipt) {
598
+ if (receipt.status !== "success" || !p.passengers[p.seat]?.nativeDrop || p.nativeDropAmount === 0n) return false;
599
+ const i = p.intent;
600
+ const deliveries = (0, import_viem5.parseEventLogs)({ abi: ENDPOINT_ABI, eventName: "PacketDelivered", logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.endpoint)), strict: true }).filter((l) => sameAddress(l.args.receiver, i.destination.tokenMessaging));
601
+ if (deliveries.length !== 1) return false;
602
+ const origin = deliveries[0].args.origin;
603
+ if (origin.nonce !== p.nonce || origin.srcEid !== i.source.eid || !sameAddress(origin.sender, (0, import_viem5.pad)(i.source.tokenMessaging, { size: 32 }))) return false;
604
+ const drops = (0, import_viem5.parseEventLogs)({ abi: TOKEN_MESSAGING_ABI, logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.tokenMessaging)), strict: true }).filter((l) => l.eventName === "NativeDropApplied" || l.eventName === "NativeDropFailed");
605
+ const expected = p.passengers.flatMap((passenger, seat) => passenger.nativeDrop ? [{ passenger, seat }] : []);
606
+ if (drops.length !== expected.length) return false;
607
+ let paid = false;
608
+ for (let index = 0; index < expected.length; index++) {
609
+ const event = drops[index], target = expected[index];
610
+ if (!sameAddress((0, import_viem5.pad)(event.args.receiver, { size: 32 }), target.passenger.receiver) || event.args.amount !== p.nativeDropAmount || event.logIndex >= deliveries[0].logIndex) return false;
611
+ if (target.seat === p.seat) paid = event.eventName === "NativeDropApplied";
612
+ }
613
+ return paid;
614
+ }
615
+ function busPassengerPrefix(rows, first, count, previousHash, expectedHash, ticket) {
616
+ assertStargate(Number.isInteger(count) && count >= 1 && count <= 255 && ticket.ticketId >= first && ticket.ticketId < first + BigInt(count), "drive prefix does not include this ticket");
617
+ const selected = Array.from({ length: count }, (_, index) => {
618
+ const matches = rows.filter((row2) => row2.ticketId === first + BigInt(index));
619
+ assertStargate(matches.length === 1, "missing or duplicate queued passenger");
620
+ const row = matches[0];
621
+ decodeBusPassenger(row.passenger);
622
+ if (row.ticketId === ticket.ticketId) assertStargate(sameAddress(row.passenger, ticket.passenger), "queued passenger differs from source receipt");
623
+ return row.passenger;
624
+ });
625
+ let current = previousHash;
626
+ for (const passenger of selected) current = (0, import_viem5.keccak256)((0, import_viem5.concatHex)([current, passenger]));
627
+ assertStargate(sameAddress(current, expectedHash), "queued passenger hash chain mismatch");
628
+ return (0, import_viem5.concatHex)(selected);
629
+ }
630
+ function busDriveData(dstEid, passengers) {
631
+ return (0, import_viem5.encodeFunctionData)({ abi: TOKEN_MESSAGING_ABI, functionName: "driveBus", args: [dstEid, passengers] });
632
+ }
633
+
634
+ // src/native-drop.ts
635
+ var import_viem6 = require("viem");
636
+ var STARGATE_TAXI_EXECUTORS = Object.freeze({
637
+ "eip155:8453": Object.freeze(["0x2cca08ae69e0c44b18a57ab2a87644234daebae4"])
638
+ });
639
+ function stargateTaxiNativeDrop(p, receipt, executors) {
640
+ if (receipt.status !== "success" || p.intent.nativeDrop <= 0n) return false;
641
+ const i = p.intent;
642
+ const events = (0, import_viem6.parseEventLogs)({ abi: EXECUTOR_ABI, eventName: "NativeDropApplied", logs: receipt.logs.filter((l) => executors.some((a) => sameAddress(a, l.address))), strict: true });
643
+ for (const { args } of events) {
644
+ if (args.origin.srcEid !== i.source.eid || args.origin.nonce !== p.nonce || !sameAddress(args.origin.sender, (0, import_viem6.pad)(i.source.tokenMessaging, { size: 32 })) || args.dstEid !== i.destination.eid || !sameAddress(args.oapp, i.destination.tokenMessaging) || args.params.length !== args.success.length) continue;
645
+ let received = 0n;
646
+ for (let index = 0; index < args.params.length; index++) {
647
+ const drop = args.params[index];
648
+ if (args.success[index] && sameAddress(drop.receiver, i.recipient)) received += drop.amount;
649
+ }
650
+ if (received >= i.nativeDrop) return true;
651
+ }
652
+ return false;
653
+ }
654
+
655
+ // src/compose.ts
656
+ var import_viem7 = require("viem");
657
+ var COMPOSE_ABI = (0, import_viem7.parseAbi)([
658
+ "function composeQueue(address from, address to, bytes32 guid, uint16 index) view returns (bytes32)",
659
+ "function lzCompose(address from, address to, bytes32 guid, uint16 index, bytes message, bytes extraData) payable",
660
+ "event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message)",
661
+ "event ComposeDelivered(address from, address to, bytes32 guid, uint16 index)"
662
+ ]);
663
+ var LIFI_COMPOSE_ABI = (0, import_viem7.parseAbi)([
664
+ "function executor() view returns (address)",
665
+ "function endpointV2() view returns (address)",
666
+ "function tokenMessaging() view returns (address)",
667
+ "function recoverGas() view returns (uint256)",
668
+ "event LiFiTransferCompleted(bytes32 indexed transactionId, address receivingAssetId, address receiver, uint256 amount, uint256 timestamp)",
669
+ "event LiFiTransferRecovered(bytes32 indexed transactionId, address receivingAssetId, address receiver, uint256 amount, uint256 timestamp)",
670
+ "event AssetSwapped(bytes32 transactionId, address dex, address fromAssetId, address toAssetId, uint256 fromAmount, uint256 toAmount, uint256 timestamp)",
671
+ "event Transfer(address indexed from, address indexed to, uint256 value)"
672
+ ]);
673
+ var LIFI_COMPOSE_PAYLOAD = (0, import_viem7.parseAbiParameters)("bytes32 transactionId, (address callTo, address approveTo, address sendingAssetId, address receivingAssetId, uint256 fromAmount, bytes callData, bool requiresDeposit)[] swaps, address receiver");
674
+ var LIFI_ETHEREUM_COMPOSER = Object.freeze({
675
+ chain: "eip155:1",
676
+ receiver: "0xB539B40793171211DCA8834da044fC14bCe64BDC",
677
+ executor: "0xd9B2Da9C45b118e4e93A004FB1452bCDB6cC0E88",
678
+ receiverCodeHash: "0x535b6e74e5bbb38e9a469de60ff2587cf498b92a99be01f34d20c37a77e4cea2",
679
+ executorCodeHash: "0xf937f13890d789171f0bcf3c558a64869105000b6771dc182ddc165bde92ddfe"
680
+ });
681
+ function stargateComposeQueueState(messageHash, queue) {
682
+ assertStargate(/^0x[0-9a-f]{64}$/i.test(messageHash) && /^0x[0-9a-f]{64}$/i.test(queue), "invalid compose commitment");
683
+ if (BigInt(queue) === 0n) return "absent";
684
+ if (BigInt(queue) === 1n) return "consumed";
685
+ return sameAddress(messageHash, queue) ? "pending" : "mismatch";
686
+ }
687
+ function lifiStargateComposeOutcome(p, receipt) {
688
+ const unknown = { state: "unverified" };
689
+ try {
690
+ let paid2 = function(token, from, before) {
691
+ const transfers = (0, import_viem7.parseEventLogs)({ abi: LIFI_COMPOSE_ABI, eventName: "Transfer", logs: receipt.logs.filter((l) => sameAddress(l.address, token) && l.logIndex < before), strict: true });
692
+ let net = 0n;
693
+ for (const { args } of transfers) {
694
+ if (sameAddress(args.to, p.recipient) && sameAddress(args.from, from)) net += args.value;
695
+ if (sameAddress(args.from, p.recipient)) net -= args.value;
696
+ }
697
+ return net;
698
+ };
699
+ var paid = paid2;
700
+ if (receipt.status !== "success") return unknown;
701
+ checkStargateReceipt(receipt, receipt.transactionHash, receipt.blockHash);
702
+ const pins = LIFI_ETHEREUM_COMPOSER, d = p.bridge.intent.destination;
703
+ const delivered = (0, import_viem7.parseEventLogs)({ abi: COMPOSE_ABI, eventName: "ComposeDelivered", logs: receipt.logs.filter((l) => sameAddress(l.address, d.endpoint)), strict: true });
704
+ if (delivered.length !== 1) return unknown;
705
+ const end = delivered[0];
706
+ if (!sameAddress(end.args.guid, p.bridge.guid) || !sameAddress(end.args.from, d.address) || !sameAddress(end.args.to, pins.receiver) || end.args.index !== 0) return unknown;
707
+ const recovered = (0, import_viem7.parseEventLogs)({ abi: LIFI_COMPOSE_ABI, eventName: "LiFiTransferRecovered", logs: receipt.logs.filter((l) => sameAddress(l.address, pins.receiver)), strict: true }).filter((l) => sameAddress(l.args.transactionId, p.transactionId));
708
+ const completed = (0, import_viem7.parseEventLogs)({ abi: LIFI_COMPOSE_ABI, eventName: "LiFiTransferCompleted", logs: receipt.logs.filter((l) => sameAddress(l.address, pins.executor)), strict: true }).filter((l) => sameAddress(l.args.transactionId, p.transactionId));
709
+ if (recovered.length === 1 && completed.length === 0) {
710
+ const event2 = recovered[0];
711
+ if (event2.logIndex >= end.logIndex || !sameAddress(event2.args.receivingAssetId, d.token) || !sameAddress(event2.args.receiver, p.recipient) || event2.args.amount !== p.bridge.amount) return unknown;
712
+ if (d.token !== import_viem7.zeroAddress && paid2(d.token, pins.receiver, event2.logIndex) !== p.bridge.amount) return unknown;
713
+ return { state: "intermediate-refunded", token: d.token, amount: p.bridge.amount, transactionHash: receipt.transactionHash };
714
+ }
715
+ if (completed.length !== 1 || recovered.length !== 0 || p.finalToken === import_viem7.zeroAddress) return unknown;
716
+ const event = completed[0];
717
+ if (event.logIndex >= end.logIndex || !sameAddress(event.args.receiver, p.recipient) || !sameAddress(event.args.receivingAssetId, d.token)) return unknown;
718
+ const swaps = (0, import_viem7.parseEventLogs)({ abi: LIFI_COMPOSE_ABI, eventName: "AssetSwapped", logs: receipt.logs.filter((l) => sameAddress(l.address, pins.executor)), strict: true }).filter((l) => sameAddress(l.args.transactionId, p.transactionId));
719
+ if (swaps.length !== 1) return unknown;
720
+ const swap = swaps[0];
721
+ if (swap.logIndex >= event.logIndex || !sameAddress(swap.args.dex, p.swap.callTo) || !sameAddress(swap.args.fromAssetId, d.token) || !sameAddress(swap.args.toAssetId, p.finalToken) || swap.args.fromAmount !== p.swap.fromAmount) return unknown;
722
+ const amount = paid2(p.finalToken, pins.executor, event.logIndex);
723
+ if (amount < p.minimum || amount !== swap.args.toAmount) return unknown;
724
+ return { state: "completed", token: p.finalToken, amount, transactionHash: receipt.transactionHash };
725
+ } catch {
726
+ return unknown;
727
+ }
728
+ }
729
+
730
+ // src/compose-route.ts
731
+ var import_viem9 = require("viem");
732
+
733
+ // src/compose-dex.ts
734
+ var import_viem8 = require("viem");
735
+ var COMPOSE_UNOSWAP_ABI = (0, import_viem8.parseAbi)(["function unoswap2(uint256 token, uint256 amount, uint256 minReturn, uint256 dex, uint256 dex2) returns (uint256)"]);
736
+ var COMPOSE_POOL_ABI = (0, import_viem8.parseAbi)([
737
+ "function token0() view returns (address)",
738
+ "function token1() view returns (address)",
739
+ "function fee() view returns (uint24)",
740
+ "function getPool(address tokenA, address tokenB, uint24 fee) view returns (address)"
741
+ ]);
742
+ var COMPOSE_DEX_PINS = Object.freeze({
743
+ router: "0x111111125421cA6dc452d289314280a0f8842A65",
744
+ routerCodeHash: "0xa5a286be4b80006cc547d7e899871aa01a0e0551e2a509233375405f92098c2f",
745
+ factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
746
+ factoryCodeHash: "0x4d7b8525cd5d14343fa67a732fba5b24cddba11620ca88392f4ec6c52f91fd69",
747
+ /** Observed four-byte suffix; its ownership/meaning is not an authorization signal. */
748
+ calldataSuffix: "2a94d114"
749
+ });
750
+ var UNOSWAP_FLAGS = Object.freeze({ V3: 1n << 253n, NO_WRAP: 1n << 251n, ZERO_FOR_ONE: 1n << 247n });
751
+ var ADDRESS = (1n << 160n) - 1n;
752
+ var { V3, NO_WRAP, ZERO_FOR_ONE } = UNOSWAP_FLAGS;
753
+
754
+ // src/compose-route.ts
755
+ var STARGATE_COMPOSE_CHAIN = "eip155:1";
756
+ var ONE_BATCH = 1 << 16;
757
+ var COMPOSE_INTERMEDIATES = Object.freeze([
758
+ "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
759
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
760
+ "0xdAC17F958D2ee523a2206206994597C13D831ec7"
761
+ ]);
762
+ var MIN_SWAP_GAS = 250000n;
763
+ var MAX_COMPOSE_GAS = 2000000n;
764
+ var RETRY_OVERHEAD = 250000n;
765
+ var QUOTER_ABI = (0, import_viem9.parseAbi)(["function quoteExactInput(bytes path, uint256 amountIn) view returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)"]);
766
+ var ADDRESS2 = (1n << 160n) - 1n;
767
+ var { V3: V32, NO_WRAP: NO_WRAP2, ZERO_FOR_ONE: ZERO_FOR_ONE2 } = UNOSWAP_FLAGS;
768
+ var PREFIX = "stargate:2:compose";
769
+ var isStargateComposeIntent = (id) => id.startsWith(`${PREFIX}:`);
770
+ function parseStargateComposeIntent(id, registry) {
771
+ const fields = id.split("~", 1)[0].split(":");
772
+ const [tag, version, mode, srcEid, dstEid, assetId, sender, recipient, amountText, fromText, finalToken, dex0, dex1, minText, gasText, transactionId] = fields;
773
+ assertStargate(fields.length === 16 && `${tag}:${version}:${mode}` === PREFIX, "invalid compose intent identity");
774
+ assertStargate([srcEid, dstEid, assetId, amountText, fromText, minText, gasText].every((v) => typeof v === "string" && /^(0|[1-9][0-9]{0,77})$/.test(v)), "invalid compose intent amounts");
775
+ assertStargate([dex0, dex1].every((v) => typeof v === "string" && /^0x[1-9a-f][0-9a-f]{0,63}$/.test(v)) && /^0x[0-9a-f]{64}$/.test(transactionId ?? "") && BigInt(transactionId) !== 0n, "invalid compose intent fields");
776
+ assertStargate(sender && recipient && finalToken && nonzeroAddress(sender) && nonzeroAddress(recipient) && nonzeroAddress(finalToken), "invalid compose intent actors");
777
+ const source = registry.deployments.find((d) => String(d.eid) === srcEid && String(d.assetId) === assetId);
778
+ const destination = registry.deployments.find((d) => String(d.eid) === dstEid && String(d.assetId) === assetId);
779
+ assertStargate(source && destination && destination.chain === STARGATE_COMPOSE_CHAIN && source.kind !== "native" && destination.kind !== "native" && registry.route(source.chain, source.token, destination.chain, destination.token), "unreviewed compose route");
780
+ assertStargate(!sameAddress(finalToken, destination.token), "compose output equals the bridged asset");
781
+ const amount = BigInt(amountText), fromAmount = BigInt(fromText), minReturn = BigInt(minText), gas = BigInt(gasText);
782
+ assertStargate(splitSourceAmount(amount, source.localDecimals, source.sharedDecimals).amountSD > 0n && fromAmount > 0n && minReturn > 0n && minReturn < 1n << 256n && gas >= MIN_SWAP_GAS && gas <= MAX_COMPOSE_GAS, "invalid compose intent bounds");
783
+ assertStargate(destinationAmount(sourceMinimum(fromAmount, source.localDecimals, destination.localDecimals, source.sharedDecimals), source.localDecimals, destination.localDecimals, source.sharedDecimals) === fromAmount, "unaligned compose bridge amount");
784
+ const dex = [BigInt(dex0), BigInt(dex1)];
785
+ assertStargate(dex.every((w) => w >> 253n === 1n && (w & ~(ADDRESS2 | V32 | NO_WRAP2 | ZERO_FOR_ONE2)) === 0n && (w & ADDRESS2) !== 0n), "unsupported compose DEX word");
786
+ const bridge = Object.freeze({ source, destination, mode: "taxi", sender: (0, import_viem9.getAddress)(sender), recipient: LIFI_ETHEREUM_COMPOSER.receiver, amount, minimum: fromAmount, nativeDrop: 0n });
787
+ return Object.freeze({ bridge, recipient: (0, import_viem9.getAddress)(recipient), finalToken: (0, import_viem9.getAddress)(finalToken), dex: Object.freeze(dex), minReturn, gas, transactionId });
788
+ }
789
+ function stargateComposeSwapCall(c) {
790
+ return (0, import_viem9.encodeFunctionData)({ abi: COMPOSE_UNOSWAP_ABI, functionName: "unoswap2", args: [BigInt(c.bridge.destination.token), c.bridge.minimum, c.minReturn, c.dex[0], c.dex[1]] });
791
+ }
792
+ function stargateComposeMessage(c) {
793
+ const router = (0, import_viem9.getAddress)(COMPOSE_DEX_PINS.router);
794
+ return (0, import_viem9.encodeAbiParameters)(LIFI_COMPOSE_PAYLOAD, [c.transactionId, [{ callTo: router, approveTo: router, sendingAssetId: c.bridge.destination.token, receivingAssetId: c.finalToken, fromAmount: c.bridge.minimum, callData: stargateComposeSwapCall(c), requiresDeposit: true }], c.recipient]);
795
+ }
796
+ function stargateComposeProof(c, bridge) {
797
+ const composeMsg = stargateComposeMessage(c);
798
+ const message = (0, import_viem9.encodePacked)(["uint64", "uint32", "uint256", "bytes32", "bytes"], [bridge.nonce, c.bridge.source.eid, bridge.amount, (0, import_viem9.pad)(c.bridge.sender, { size: 32 }), composeMsg]);
799
+ return Object.freeze({
800
+ bridge,
801
+ transactionId: c.transactionId,
802
+ message,
803
+ messageHash: (0, import_viem9.keccak256)(message),
804
+ recipient: c.recipient,
805
+ finalToken: c.finalToken,
806
+ minimum: c.minReturn,
807
+ swap: Object.freeze({ callTo: (0, import_viem9.getAddress)(COMPOSE_DEX_PINS.router), fromAmount: c.bridge.minimum }),
808
+ executionSupported: true
809
+ });
810
+ }
811
+ function stargateComposeRetryGas(c, recoverGas) {
812
+ const floor = recoverGas + MIN_SWAP_GAS;
813
+ return (c.gas > floor ? c.gas : floor) + RETRY_OVERHEAD;
814
+ }
815
+ async function checkStargateComposer(client, destination, blockNumber) {
816
+ assertStargate(await client.getChainId() === 1 && destination.chain === STARGATE_COMPOSE_CHAIN, "wrong compose chain");
817
+ const pins = LIFI_ETHEREUM_COMPOSER;
818
+ for (const [address2, expected] of [[pins.receiver, pins.receiverCodeHash], [pins.executor, pins.executorCodeHash], [COMPOSE_DEX_PINS.router, COMPOSE_DEX_PINS.routerCodeHash], [COMPOSE_DEX_PINS.factory, COMPOSE_DEX_PINS.factoryCodeHash]]) {
819
+ const code = await client.getCode({ address: address2, blockNumber });
820
+ assertStargate(code && (0, import_viem9.keccak256)(code) === expected, "compose contract bytecode changed");
821
+ }
822
+ const at = { address: pins.receiver, abi: LIFI_COMPOSE_ABI, blockNumber };
823
+ const [executor, endpoint, messaging, recoverGas] = await Promise.all([
824
+ client.readContract({ ...at, functionName: "executor" }),
825
+ client.readContract({ ...at, functionName: "endpointV2" }),
826
+ client.readContract({ ...at, functionName: "tokenMessaging" }),
827
+ client.readContract({ ...at, functionName: "recoverGas" })
828
+ ]);
829
+ assertStargate(sameAddress(executor, pins.executor) && sameAddress(endpoint, destination.endpoint) && sameAddress(messaging, destination.tokenMessaging), "composer wiring changed");
830
+ assertStargate(recoverGas + MIN_SWAP_GAS <= MAX_COMPOSE_GAS, "composer recovery reserve is out of range");
831
+ return { recoverGas };
832
+ }
833
+
834
+ // src/tracking.ts
835
+ var endpointAbi = (0, import_viem10.parseAbi)(["event PacketSent(bytes encodedPayload, bytes options, address sendLibrary)"]);
836
+ var hash = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{64}$/.test(v);
837
+ var ZERO_HASH2 = `0x${"00".repeat(32)}`;
838
+ var SourceReverted = class extends Error {
839
+ };
840
+ var seatOf = (p) => "seat" in p ? p.seat : 0;
841
+ function stargateTaxiProof(i, receipt) {
842
+ return taxiProof(i, receipt);
843
+ }
844
+ function stargateComposedTaxiProof(i, receipt, composeFrom, composeMsg) {
845
+ assertStargate(nonzeroAddress(composeFrom) && /^0x(?:[0-9a-f]{2}){1,16384}$/i.test(composeMsg), "invalid expected compose payload");
846
+ return taxiProof(i, receipt, `${(0, import_viem10.pad)(composeFrom, { size: 32 })}${composeMsg.slice(2)}`);
847
+ }
848
+ function taxiProof(i, receipt, expectedCompose) {
849
+ assertStargate(i.mode === "taxi" && receipt.status === "success", "not a successful Taxi source receipt");
850
+ const sent = (0, import_viem10.parseEventLogs)({ abi: STARGATE_ABI, eventName: "OFTSent", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.address)), strict: true }).filter((l) => sameAddress(l.args.fromAddress, i.sender) && l.args.dstEid === i.destination.eid);
851
+ assertStargate(sent.length === 1, "missing or ambiguous source transfer");
852
+ const event = sent[0].args;
853
+ assertStargate(event.guid !== ZERO_HASH2 && event.amountSentLD === splitSourceAmount(i.amount, i.source.localDecimals, i.source.sharedDecimals).sentLD, "source amount mismatch");
854
+ const amount = destinationAmount(event.amountReceivedLD, i.source.localDecimals, i.destination.localDecimals, i.source.sharedDecimals);
855
+ assertStargate(amount >= i.minimum, "source output is below the intent minimum");
856
+ const packets = (0, import_viem10.parseEventLogs)({ abi: endpointAbi, eventName: "PacketSent", logs: receipt.logs.filter((l) => sameAddress(l.address, i.source.endpoint)), strict: true }).filter((l) => l.args.encodedPayload.length >= 228 && sameAddress((0, import_viem10.slice)(l.args.encodedPayload, 81, 113), event.guid));
857
+ assertStargate(packets.length === 1, "missing or ambiguous endpoint packet");
858
+ const packet = packets[0].args.encodedPayload;
859
+ assertStargate((0, import_viem10.slice)(packet, 0, 1) === "0x01" && BigInt((0, import_viem10.slice)(packet, 9, 13)) === BigInt(i.source.eid) && BigInt((0, import_viem10.slice)(packet, 45, 49)) === BigInt(i.destination.eid), "packet pathway mismatch");
860
+ assertStargate(sameAddress((0, import_viem10.slice)(packet, 13, 45), (0, import_viem10.pad)(i.source.tokenMessaging, { size: 32 })) && sameAddress((0, import_viem10.slice)(packet, 49, 81), (0, import_viem10.pad)(i.destination.tokenMessaging, { size: 32 })), "packet messaging contracts mismatch");
861
+ const message = (0, import_viem10.slice)(packet, 113);
862
+ assertStargate(expectedCompose === void 0 ? /^0x01[0-9a-f]{84}$/i.test(message) : /^0x01[0-9a-f]+$/i.test(message) && sameAddress((0, import_viem10.slice)(message, 43), expectedCompose), "unsupported Taxi compose payload");
863
+ assertStargate(BigInt((0, import_viem10.slice)(message, 1, 3)) === BigInt(i.source.assetId) && sameAddress((0, import_viem10.slice)(message, 3, 35), (0, import_viem10.pad)(i.recipient, { size: 32 })) && BigInt((0, import_viem10.slice)(message, 35, 43)) * conversionRate(i.destination.localDecimals, i.destination.sharedDecimals) === amount, "Taxi passenger mismatch");
864
+ return { intent: i, guid: event.guid, amount, packet, message, nonce: BigInt((0, import_viem10.slice)(packet, 1, 9)), sourceHash: receipt.transactionHash };
865
+ }
866
+ function stargateTaxiPayout(proof, receipt) {
867
+ if (receipt.status !== "success") return false;
868
+ const i = proof.intent;
869
+ const received = (0, import_viem10.parseEventLogs)({ abi: STARGATE_ABI, eventName: "OFTReceived", logs: receipt.logs.filter((l) => sameAddress(l.address, i.destination.address)), strict: true }).filter((l) => sameAddress(l.args.guid, proof.guid));
870
+ return received.length === 1 && received[0].args.srcEid === i.source.eid && sameAddress(received[0].args.toAddress, i.recipient) && received[0].args.amountReceivedLD === proof.amount;
871
+ }
872
+ function checkStargateReceipt(receipt, expectedHash, blockHash) {
873
+ assertStargate(sameAddress(receipt.transactionHash, expectedHash) && sameAddress(receipt.blockHash, blockHash), "receipt block/hash mismatch");
874
+ assertStargate(receipt.logs.every((l) => !l.removed && l.blockNumber === receipt.blockNumber && l.transactionHash !== null && sameAddress(l.transactionHash, expectedHash) && l.blockHash !== null && sameAddress(l.blockHash, blockHash)), "receipt contains foreign or removed logs");
875
+ assertStargate(receipt.logs.every((l, index) => l.logIndex !== null && l.logIndex >= 0 && (index === 0 || l.logIndex > receipt.logs[index - 1].logIndex)), "receipt log order is invalid");
876
+ }
877
+ function createStargateTracker(config) {
878
+ const registry = config.registry ?? stargateRegistry;
879
+ const rpc = stargateRpc(config);
880
+ const confirmations = { ...config.confirmations };
881
+ const taxiExecutors = Object.fromEntries(Object.entries(config.taxiExecutors ?? STARGATE_TAXI_EXECUTORS).map(([chain, addresses]) => {
882
+ assertStargate(/^eip155:[1-9][0-9]*$/.test(chain) && addresses.length <= 32 && addresses.every(nonzeroAddress), "invalid Taxi executor pins");
883
+ return [chain, [...addresses]];
884
+ }));
885
+ assertStargate(Object.values(confirmations).every((n) => Number.isSafeInteger(n) && n >= 1 && n <= 1e5), "invalid finality policy");
886
+ const scan = (config.scanUrl ?? "https://scan.layerzero-api.com").replace(/\/+$/, "");
887
+ assertStargate(/^https?:\/\//.test(scan), "invalid Scan URL");
888
+ const fetchImpl = config.fetchImpl ?? fetch;
889
+ const composeRetryAfter = config.composeRetryAfterS ?? 600;
890
+ assertStargate(Number.isSafeInteger(composeRetryAfter) && composeRetryAfter >= 0 && composeRetryAfter <= 7 * 86400, "invalid compose retry delay");
891
+ const pageSize = config.busLogPageSize ?? 2e3, pages = config.busLogPages ?? 8;
892
+ const findDrive = config.findBusDrive, queuedPassengers = config.queuedBusPassengers;
893
+ assertStargate(Number.isSafeInteger(pageSize) && pageSize >= 1 && pageSize <= 1e4 && Number.isSafeInteger(pages) && pages >= 1 && pages <= 32, "invalid Bus log discovery bounds");
894
+ async function receipt(c, chain, chainId, txHash) {
895
+ const [id, r] = await Promise.all([c.getChainId(), c.getTransactionReceipt({ hash: txHash })]);
896
+ assertStargate(id === chainId, "receipt RPC chain mismatch");
897
+ const depth = confirmations[chain];
898
+ const [block, head] = await Promise.all([c.getBlock({ blockNumber: r.blockNumber }), c.getBlock({ blockTag: depth === void 0 ? "finalized" : "latest" })]);
899
+ assertStargate(block.hash && head.hash && head.number !== null, "missing receipt finality evidence");
900
+ checkStargateReceipt(r, txHash, block.hash);
901
+ if (head.number < r.blockNumber + BigInt((depth ?? 1) - 1)) return null;
902
+ return r;
903
+ }
904
+ async function busProof(ticket, ref) {
905
+ const i = ticket.intent, c = rpc.client(i.source.chain);
906
+ const candidates = [];
907
+ if (ref.recoveryChain === i.source.chain && hash(ref.recoveryTxHash)) candidates.push(ref.recoveryTxHash);
908
+ if (findDrive) candidates.push(...(await findDrive(Object.freeze({ ...ticket, intent: Object.freeze({ ...ticket.intent }) }))).filter(hash).slice(0, 32));
909
+ const tryCandidates = async () => {
910
+ for (const txHash of [...new Set(candidates.splice(0))]) {
911
+ try {
912
+ const r = await receipt(c, i.source.chain, i.source.chainId, txHash);
913
+ if (r) return stargateBusProof(ticket, r);
914
+ } catch {
915
+ }
916
+ }
917
+ return null;
918
+ };
919
+ const hinted = await tryCandidates();
920
+ if (hinted) return hinted;
921
+ const head = await c.getBlockNumber();
922
+ for (let page = 0; page < pages; page++) {
923
+ const fromBlock = ticket.sourceBlock + BigInt(page * pageSize);
924
+ if (fromBlock > head) break;
925
+ const end = fromBlock + BigInt(pageSize - 1), toBlock = end < head ? end : head;
926
+ const logs = await c.getContractEvents({ address: i.source.tokenMessaging, abi: TOKEN_MESSAGING_ABI, eventName: "BusDriven", fromBlock, toBlock, strict: true });
927
+ for (const log of logs) if (!log.removed && log.args.dstEid === i.destination.eid && log.args.startTicketId <= ticket.ticketId && ticket.ticketId < log.args.startTicketId + BigInt(log.args.numPassengers) && hash(log.transactionHash)) candidates.push(log.transactionHash);
928
+ const found = await tryCandidates();
929
+ if (found) return found;
930
+ }
931
+ return null;
932
+ }
933
+ async function evidence(ref) {
934
+ const compose = isStargateComposeIntent(ref.intentId) ? parseStargateComposeIntent(ref.intentId, registry) : void 0;
935
+ const i = compose ? compose.bridge : parseStargateIntent(ref.intentId, registry);
936
+ if (!hash(ref.sourceTxHash)) return null;
937
+ const r = await receipt(rpc.client(i.source.chain), i.source.chain, i.source.chainId, ref.sourceTxHash);
938
+ if (r?.status === "reverted" && r.from && r.to && sameAddress(r.from, i.sender) && sameAddress(r.to, i.source.address)) throw new SourceReverted();
939
+ if (!r) return null;
940
+ if (compose) return { proof: stargateComposedTaxiProof(i, r, i.sender, stargateComposeMessage(compose)), compose };
941
+ if (i.mode === "taxi") return { proof: stargateTaxiProof(i, r) };
942
+ const ticket = stargateBusTicket(i, r);
943
+ return { ticket, proof: await busProof(ticket, ref) };
944
+ }
945
+ async function cached(p) {
946
+ const i = p.intent;
947
+ const c = rpc.client(i.destination.chain);
948
+ assertStargate(await c.getChainId() === i.destination.chainId, "recovery RPC chain mismatch");
949
+ const actual = await c.readContract({ address: i.destination.address, abi: STARGATE_ABI, functionName: "unreceivedTokens", args: [p.guid, seatOf(p)] });
950
+ const expected = (0, import_viem10.keccak256)((0, import_viem10.encodePacked)(["uint32", "address", "uint256", "bytes"], [i.source.eid, i.recipient, p.amount, "0x"]));
951
+ return actual === expected;
952
+ }
953
+ async function retryableMessage(p) {
954
+ const i = p.intent, c = rpc.client(i.destination.chain);
955
+ assertStargate(await c.getChainId() === i.destination.chainId, "recovery RPC chain mismatch");
956
+ const actual = await c.readContract({ address: i.destination.endpoint, abi: ENDPOINT_ABI, functionName: "inboundPayloadHash", args: [i.destination.tokenMessaging, i.source.eid, (0, import_viem10.pad)(i.source.tokenMessaging, { size: 32 }), p.nonce] });
957
+ return actual === (0, import_viem10.keccak256)((0, import_viem10.encodePacked)(["bytes32", "bytes"], [p.guid, p.message]));
958
+ }
959
+ async function destinationHashes(ref, p) {
960
+ const provided = [ref.destTxHash, ref.recoveryChain === p.intent.destination.chain ? ref.recoveryTxHash : void 0].filter(hash);
961
+ try {
962
+ const response = await fetchImpl(`${scan}/v1/messages/guid/${p.guid}`, { signal: (0, import_util.timeoutSignal)(12e3), headers: { accept: "application/json" } });
963
+ if (!response.ok) return provided;
964
+ const json = await response.json();
965
+ const data = json?.data;
966
+ if (!Array.isArray(data)) return provided;
967
+ for (const item of data.slice(0, 32)) {
968
+ const m = item;
969
+ if (typeof m.guid === "string" && sameAddress(m.guid, p.guid)) {
970
+ if (hash(m.destination?.tx?.txHash)) provided.push(m.destination.tx.txHash);
971
+ if (hash(m.destination?.nativeDrop?.tx?.txHash)) provided.push(m.destination.nativeDrop.tx.txHash);
972
+ const composed = m.destination?.lzCompose?.txs;
973
+ if (Array.isArray(composed)) {
974
+ for (const tx of composed.slice(0, 8)) if (hash(tx?.txHash)) provided.push(tx.txHash);
975
+ }
976
+ }
977
+ }
978
+ } catch {
979
+ }
980
+ return [...new Set(provided)];
981
+ }
982
+ async function composeState(ref, c, p) {
983
+ const d = p.intent.destination, client = rpc.client(d.chain), lifi = stargateComposeProof(c, p);
984
+ let deliveredAt, delivered;
985
+ for (const txHash of await destinationHashes(ref, p)) {
986
+ try {
987
+ const r = await receipt(client, d.chain, d.chainId, txHash);
988
+ if (!r) continue;
989
+ if (stargateTaxiPayout(p, r)) {
990
+ delivered = txHash;
991
+ deliveredAt = (await client.getBlock({ blockNumber: r.blockNumber })).timestamp;
992
+ }
993
+ const outcome = lifiStargateComposeOutcome(lifi, r);
994
+ if (outcome.state !== "unverified") return { outcome: outcome.state, txHash, lifi };
995
+ } catch {
996
+ }
997
+ }
998
+ assertStargate(await client.getChainId() === d.chainId, "compose RPC chain mismatch");
999
+ const queue = stargateComposeQueueState(lifi.messageHash, await client.readContract({ address: d.endpoint, abi: COMPOSE_ABI, functionName: "composeQueue", args: [d.address, LIFI_ETHEREUM_COMPOSER.receiver, p.guid, 0] }));
1000
+ const stale = deliveredAt !== void 0 && deliveredAt + BigInt(composeRetryAfter) <= BigInt(Math.floor(Date.now() / 1e3));
1001
+ return { queue, retryable: queue === "pending" && stale, delivered, lifi };
1002
+ }
1003
+ async function trackIntent(ref) {
1004
+ let deposited = false;
1005
+ try {
1006
+ const e = await evidence(ref);
1007
+ if (!e) return { state: "pending" };
1008
+ deposited = true;
1009
+ const p = e.proof;
1010
+ if (!p) return { state: "pending", depositReceived: true };
1011
+ if (e.compose && !("seat" in p)) {
1012
+ const s = await composeState(ref, e.compose, p);
1013
+ if ("outcome" in s) return { state: s.outcome === "completed" ? "completed" : "partial", depositReceived: true, destTxHash: s.txHash };
1014
+ if (s.retryable) return { state: "action-required", depositReceived: true, ...s.delivered ? { destTxHash: s.delivered } : {} };
1015
+ if (!s.delivered && (await cached(p) || await retryableMessage(p))) return { state: "action-required", depositReceived: true };
1016
+ return { state: "pending", depositReceived: true };
1017
+ }
1018
+ const d = p.intent.destination, c = rpc.client(d.chain);
1019
+ let paidHash, nativeDropProved = false;
1020
+ for (const txHash of await destinationHashes(ref, p)) {
1021
+ try {
1022
+ const r = await receipt(c, d.chain, d.chainId, txHash);
1023
+ if (r) {
1024
+ if ("seat" in p && stargateBusNativeDrop(p, r)) nativeDropProved = true;
1025
+ if (!("seat" in p) && stargateTaxiNativeDrop(p, r, taxiExecutors[d.chain] ?? [])) nativeDropProved = true;
1026
+ let paid = "seat" in p ? stargateBusPayout(p, r) === "paid" : stargateTaxiPayout(p, r);
1027
+ if (!paid && "seat" in p && stargateTaxiPayout({ ...p, packet: "0x" }, r)) {
1028
+ const tx = await c.getTransaction({ hash: txHash });
1029
+ paid = !!tx.to && sameAddress(tx.to, d.address) && tx.blockHash === r.blockHash && tx.input.toLowerCase() === retryTokenData(p).toLowerCase();
1030
+ }
1031
+ if (paid) paidHash = txHash;
1032
+ }
1033
+ } catch {
1034
+ }
1035
+ }
1036
+ if (paidHash) return { state: p.intent.nativeDrop > 0n && !nativeDropProved ? "partial" : "completed", depositReceived: true, destTxHash: paidHash };
1037
+ if (await cached(p) || await retryableMessage(p)) return { state: "action-required", depositReceived: true };
1038
+ return { state: "pending", depositReceived: true };
1039
+ } catch (error) {
1040
+ return error instanceof SourceReverted ? { state: "failed" } : { state: "pending", ...deposited ? { depositReceived: true } : {} };
1041
+ }
1042
+ }
1043
+ function retryTokenData(p) {
1044
+ const i = p.intent;
1045
+ return (0, import_viem10.encodeFunctionData)({ abi: STARGATE_ABI, functionName: "retryReceiveToken", args: [p.guid, seatOf(p), i.source.eid, i.recipient, p.amount, "0x"] });
1046
+ }
1047
+ async function driveRecovery(ticket) {
1048
+ const started = Date.now();
1049
+ const i = ticket.intent, c = rpc.client(i.source.chain), d = rpc.client(i.destination.chain);
1050
+ const [block, destinationBlock] = await Promise.all([rpc.snapshot(c, i.source.chainId), rpc.snapshot(d, i.destination.chainId)]);
1051
+ await Promise.all([rpc.verify(c, i.source, i.destination, block), rpc.verify(d, i.destination, i.source, destinationBlock)]);
1052
+ const at = { address: i.source.tokenMessaging, abi: TOKEN_MESSAGING_ABI, blockNumber: block.number };
1053
+ const [[maxPassengers, , , length, first], capacity] = await Promise.all([
1054
+ c.readContract({ ...at, functionName: "busQueues", args: [i.destination.eid] }),
1055
+ c.readContract({ ...at, functionName: "queueCapacity" })
1056
+ ]);
1057
+ if (capacity === 0 || first > ticket.ticketId || ticket.ticketId >= first + BigInt(length) || ticket.ticketId >= first + BigInt(maxPassengers)) return [];
1058
+ let count = 1;
1059
+ while (first + BigInt(count - 1) < ticket.ticketId) count++;
1060
+ const rows = [];
1061
+ if (queuedPassengers) rows.push(...await queuedPassengers({ chain: i.source.chain, tokenMessaging: i.source.tokenMessaging, dstEid: i.destination.eid, firstTicketId: first, count, blockNumber: block.number }));
1062
+ else {
1063
+ for (let page = 0; page < pages; page++) {
1064
+ const end = ticket.sourceBlock - BigInt(page * pageSize);
1065
+ if (end < 0n) break;
1066
+ const start = end - BigInt(pageSize - 1);
1067
+ const logs = await c.getContractEvents({ address: i.source.tokenMessaging, abi: TOKEN_MESSAGING_ABI, eventName: "BusRode", fromBlock: start > 0n ? start : 0n, toBlock: end, strict: true });
1068
+ for (const log of logs) if (!log.removed && log.args.dstEid === i.destination.eid && log.args.ticketId >= first && log.args.ticketId <= ticket.ticketId) rows.push({ ticketId: log.args.ticketId, passenger: log.args.passenger });
1069
+ if (rows.length >= count) break;
1070
+ }
1071
+ }
1072
+ assertStargate(rows.length <= 4096, "too many indexed queue rows");
1073
+ const previousIndex = parseInt(((first - 1n + BigInt(capacity)) % BigInt(capacity)).toString(), 10);
1074
+ const lastIndex = parseInt((ticket.ticketId % BigInt(capacity)).toString(), 10);
1075
+ const [previous, last] = await Promise.all([
1076
+ first === 0n ? Promise.resolve(ZERO_HASH2) : c.readContract({ ...at, functionName: "getPassengerHash", args: [i.destination.eid, previousIndex] }),
1077
+ c.readContract({ ...at, functionName: "getPassengerHash", args: [i.destination.eid, lastIndex] })
1078
+ ]);
1079
+ const passengers = busPassengerPrefix(rows, first, count, previous, last, ticket);
1080
+ const fee = await c.readContract({ ...at, functionName: "quoteDriveBus", args: [i.destination.eid, passengers] });
1081
+ assertStargate(fee.lzTokenFee === 0n, "unsupported drive fee token");
1082
+ await Promise.all([rpc.unchanged(c, block), rpc.unchanged(d, destinationBlock)]);
1083
+ assertStargate(Date.now() < started + 6e4, "drive quote expired during reads");
1084
+ return [{
1085
+ id: `bus-drive:${ticket.sourceHash}:${first}:${(0, import_viem10.keccak256)(passengers)}`,
1086
+ kind: "drive-bus",
1087
+ description: `Pay to drive ${count} queued passenger(s), including this ticket. The payment covers the whole batch; source transaction gas is additional.`,
1088
+ validUntilMs: started + 6e4,
1089
+ tx: { chain: i.source.chain, chainId: i.source.chainId, to: i.source.tokenMessaging, value: String(fee.nativeFee), data: busDriveData(i.destination.eid, passengers) }
1090
+ }];
1091
+ }
1092
+ async function getRecoveryQuotes(ref) {
1093
+ try {
1094
+ const e = await evidence(ref);
1095
+ if (!e) return [];
1096
+ const p = e.proof;
1097
+ if (!p) return e.ticket ? await driveRecovery(e.ticket) : [];
1098
+ const i = p.intent;
1099
+ const c = rpc.client(i.destination.chain);
1100
+ if (e.compose && !("seat" in p)) {
1101
+ const s = await composeState(ref, e.compose, p);
1102
+ if (!("outcome" in s) && s.retryable) {
1103
+ const block = await c.getBlock({ blockTag: "latest" });
1104
+ const { recoverGas } = await checkStargateComposer(c, i.destination, block.number);
1105
+ return [{
1106
+ id: `${p.guid}:compose:0`,
1107
+ kind: "compose",
1108
+ description: "Run the pending LI.FI compose on Ethereum again with the reviewed swap minimum. If the swap still fails, the composer pays the bridged token to the recipient. Ethereum transaction gas is paid separately.",
1109
+ validUntilMs: Date.now() + 6e4,
1110
+ tx: { chain: i.destination.chain, chainId: i.destination.chainId, to: i.destination.endpoint, value: "0", gasLimit: String(stargateComposeRetryGas(e.compose, recoverGas)), data: (0, import_viem10.encodeFunctionData)({ abi: COMPOSE_ABI, functionName: "lzCompose", args: [i.destination.address, LIFI_ETHEREUM_COMPOSER.receiver, p.guid, 0, s.lifi.message, "0x"] }) }
1111
+ }];
1112
+ }
1113
+ if ("outcome" in s || s.delivered || s.queue !== "absent") return [];
1114
+ }
1115
+ if (await c.readContract({ address: i.destination.address, abi: STARGATE_ABI, functionName: "status" }) !== 1) return [];
1116
+ if (await cached(p)) return [{
1117
+ id: `${p.guid}:retry-token:${seatOf(p)}`,
1118
+ kind: "retry-token",
1119
+ description: "Retry the cached Stargate token payout to the original recipient. Destination transaction gas is paid separately.",
1120
+ validUntilMs: Date.now() + 6e4,
1121
+ tx: { chain: i.destination.chain, chainId: i.destination.chainId, to: i.destination.address, value: "0", data: retryTokenData(p) }
1122
+ }];
1123
+ if (await retryableMessage(p)) return [{
1124
+ id: `${p.guid}:retry-message`,
1125
+ kind: "retry-message",
1126
+ description: "Retry the verified LayerZero message. Any attached value funds native drops for the entire Bus batch; destination transaction gas is additional.",
1127
+ validUntilMs: Date.now() + 6e4,
1128
+ tx: { chain: i.destination.chain, chainId: i.destination.chainId, to: i.destination.endpoint, value: "totalNativeDrops" in p ? String(p.totalNativeDrops * p.nativeDropAmount) : "0", data: (0, import_viem10.encodeFunctionData)({ abi: ENDPOINT_ABI, functionName: "lzReceive", args: [{ srcEid: i.source.eid, sender: (0, import_viem10.pad)(i.source.tokenMessaging, { size: 32 }), nonce: p.nonce }, i.destination.tokenMessaging, p.guid, p.message, "0x"] }) }
1129
+ }];
1130
+ return [];
1131
+ } catch {
1132
+ return [];
1133
+ }
1134
+ }
1135
+ async function verifyRecovery(ref, offered, actor) {
1136
+ if (!nonzeroAddress(actor) || !Number.isFinite(offered.validUntilMs) || offered.validUntilMs <= Date.now() || offered.validUntilMs > Date.now() + 6e4) return "stargate: invalid recovery actor or expiry";
1137
+ const fresh = (await getRecoveryQuotes(ref)).find((q) => q.id === offered.id);
1138
+ if (!fresh || fresh.kind !== offered.kind || Object.keys(offered.tx).length !== Object.keys(fresh.tx).length || Object.entries(fresh.tx).some(([key, value]) => offered.tx[key] !== value)) return "stargate: recovery no longer matches the cached on-chain payout";
1139
+ return null;
1140
+ }
1141
+ return { trackIntent, getRecoveryQuotes, verifyRecovery, recoveryTargets: (chain) => [.../* @__PURE__ */ new Set([...registry.callTargets(chain), ...registry.deployments.filter((d) => d.chain === chain).flatMap((d) => [d.endpoint, d.tokenMessaging])])] };
1142
+ }
1143
+ //# sourceMappingURL=tracking.cjs.map