@anywalletkit/protocol-swap2-stargate 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +502 -2
- package/dist/abi.cjs +91 -0
- package/dist/abi.cjs.map +1 -0
- package/dist/abi.d.cts +810 -0
- package/dist/abi.d.ts +810 -0
- package/dist/abi.js +13 -0
- package/dist/abi.js.map +1 -0
- package/dist/amounts.cjs +73 -0
- package/dist/amounts.cjs.map +1 -0
- package/dist/amounts.d.cts +21 -0
- package/dist/amounts.d.ts +21 -0
- package/dist/amounts.js +15 -0
- package/dist/amounts.js.map +1 -0
- package/dist/bus-Cdw8iwOv.d.cts +59 -0
- package/dist/bus-vAWqTAkq.d.ts +59 -0
- package/dist/bus.cjs +237 -0
- package/dist/bus.cjs.map +1 -0
- package/dist/bus.d.cts +4 -0
- package/dist/bus.d.ts +4 -0
- package/dist/bus.js +22 -0
- package/dist/bus.js.map +1 -0
- package/dist/chunk-3NTMZUAU.js +128 -0
- package/dist/chunk-3NTMZUAU.js.map +1 -0
- package/dist/chunk-4HU46QF2.js +256 -0
- package/dist/chunk-4HU46QF2.js.map +1 -0
- package/dist/chunk-4IDDRIE2.js +125 -0
- package/dist/chunk-4IDDRIE2.js.map +1 -0
- package/dist/chunk-EANM3EI3.js +71 -0
- package/dist/chunk-EANM3EI3.js.map +1 -0
- package/dist/chunk-ERC6LKMN.js +87 -0
- package/dist/chunk-ERC6LKMN.js.map +1 -0
- package/dist/chunk-FLAXDJPE.js +24 -0
- package/dist/chunk-FLAXDJPE.js.map +1 -0
- package/dist/chunk-N54YIG6T.js +33 -0
- package/dist/chunk-N54YIG6T.js.map +1 -0
- package/dist/chunk-OUGUX3JK.js +53 -0
- package/dist/chunk-OUGUX3JK.js.map +1 -0
- package/dist/chunk-PJXDMVW3.js +909 -0
- package/dist/chunk-PJXDMVW3.js.map +1 -0
- package/dist/chunk-QNVTQEOV.js +72 -0
- package/dist/chunk-QNVTQEOV.js.map +1 -0
- package/dist/chunk-UDJL7BUP.js +249 -0
- package/dist/chunk-UDJL7BUP.js.map +1 -0
- package/dist/chunk-YHHV3XHY.js +139 -0
- package/dist/chunk-YHHV3XHY.js.map +1 -0
- package/dist/compose-dex.cjs +148 -0
- package/dist/compose-dex.cjs.map +1 -0
- package/dist/compose-dex.d.cts +113 -0
- package/dist/compose-dex.d.ts +113 -0
- package/dist/compose-dex.js +25 -0
- package/dist/compose-dex.js.map +1 -0
- package/dist/compose-route.cjs +1019 -0
- package/dist/compose-route.cjs.map +1 -0
- package/dist/compose-route.d.cts +93 -0
- package/dist/compose-route.d.ts +93 -0
- package/dist/compose-route.js +45 -0
- package/dist/compose-route.js.map +1 -0
- package/dist/compose.cjs +287 -0
- package/dist/compose.cjs.map +1 -0
- package/dist/compose.d.cts +293 -0
- package/dist/compose.d.ts +293 -0
- package/dist/compose.js +30 -0
- package/dist/compose.js.map +1 -0
- package/dist/deployments.cjs +350 -0
- package/dist/deployments.cjs.map +1 -0
- package/dist/deployments.d.cts +12 -0
- package/dist/deployments.d.ts +12 -0
- package/dist/deployments.js +11 -0
- package/dist/deployments.js.map +1 -0
- package/dist/index.cjs +1862 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/native-drop.cjs +117 -0
- package/dist/native-drop.cjs.map +1 -0
- package/dist/native-drop.d.cts +13 -0
- package/dist/native-drop.d.ts +13 -0
- package/dist/native-drop.js +11 -0
- package/dist/native-drop.js.map +1 -0
- package/dist/pins.cjs +1618 -0
- package/dist/pins.cjs.map +1 -0
- package/dist/pins.d.cts +39 -0
- package/dist/pins.d.ts +39 -0
- package/dist/pins.js +21 -0
- package/dist/pins.js.map +1 -0
- package/dist/protocol.cjs +1851 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +24 -0
- package/dist/protocol.d.ts +24 -0
- package/dist/protocol.js +18 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +1833 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +30 -0
- package/dist/provider.d.ts +30 -0
- package/dist/provider.js +17 -0
- package/dist/provider.js.map +1 -0
- package/dist/quote-r1bA8XbO.d.cts +102 -0
- package/dist/quote-t7UJSxbU.d.ts +102 -0
- package/dist/quote.cjs +618 -0
- package/dist/quote.cjs.map +1 -0
- package/dist/quote.d.cts +3 -0
- package/dist/quote.d.ts +3 -0
- package/dist/quote.js +16 -0
- package/dist/quote.js.map +1 -0
- package/dist/registry.cjs +100 -0
- package/dist/registry.cjs.map +1 -0
- package/dist/registry.d.cts +42 -0
- package/dist/registry.d.ts +42 -0
- package/dist/registry.js +8 -0
- package/dist/registry.js.map +1 -0
- package/dist/tracking.cjs +1143 -0
- package/dist/tracking.cjs.map +1 -0
- package/dist/tracking.d.cts +57 -0
- package/dist/tracking.d.ts +57 -0
- package/dist/tracking.js +23 -0
- package/dist/tracking.js.map +1 -0
- package/package.json +134 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/quote.ts","../src/abi.ts","../src/amounts.ts","../src/registry.ts","../src/deployments.ts","../src/availability.ts","../src/rpc.ts"],"sourcesContent":["import {encodePacked, getAddress, pad, type Address, type Hex} from \"viem\";\nimport {STARGATE_ABI} from \"./abi.js\";\nimport {conversionRate, destinationAmount, sourceMinimum, splitFeeDetails, splitSourceAmount} from \"./amounts.js\";\nimport {stargateRegistry} from \"./deployments.js\";\nimport {STARGATE_BUS_RETIRED, stargateChainActive, stargateChainCutoff} from \"./availability.js\";\nimport type {StargateDeployment, StargateRegistry} from \"./registry.js\";\nimport {assertNotAborted, assertStargate, nonzeroAddress, safeReadError, stargateRpc, type StargateBlock, type StargateRpcConfig} from \"./rpc.js\";\n\n/** Bus is retained for historical intents; new quotes accept Taxi only. */\nexport type StargateMode = \"taxi\" | \"bus\";\nexport interface StargateQuoteRequest {\n sourceChain: string;\n /** Exact token address; zero address denotes native coin. No symbol aliases. */\n sourceToken: string;\n destinationChain: string;\n destinationToken: string;\n sender: string;\n recipient: string;\n amount: bigint;\n minimum?: bigint;\n /** Defaults to zero: the entire expected output is protected. */\n slippageBps?: number;\n mode: StargateMode;\n /** Taxi specifies a uint128 amount. The legacy Bus option is refused for new quotes. */\n nativeDrop?: {amount: bigint} | {bus: true};\n /**\n * Taxi compose: the bridge output must arrive exactly (no slippage on the bridge\n * leg), and `message` builds the composeMsg for that exact destination amount.\n */\n compose?: {gas: bigint; message: (received: bigint, signal?: AbortSignal) => Promise<Hex>};\n}\nexport interface StargateSendParam {\n readonly dstEid: number;\n readonly to: Hex;\n readonly amountLD: bigint;\n readonly minAmountLD: bigint;\n readonly extraOptions: Hex;\n readonly composeMsg: Hex;\n readonly oftCmd: Hex;\n}\nexport interface StargateQuote {\n readonly mode: StargateMode;\n readonly source: StargateDeployment;\n readonly destination: StargateDeployment;\n readonly sender: Address;\n readonly recipient: Address;\n readonly sourceBlock: StargateBlock;\n readonly destinationBlock: StargateBlock;\n readonly requestedAmount: bigint;\n readonly sentAmount: bigint;\n readonly dust: bigint;\n readonly destinationAmount: bigint;\n readonly minimumDestinationAmount: bigint;\n readonly protocolFee: bigint;\n readonly protocolReward: bigint;\n readonly messagingFee: bigint;\n /** Fee including configured headroom. Surplus is sent to sender as the refund address. */\n readonly messagingFeeCap: bigint;\n /** Native input (including refundable dust) plus messagingFeeCap. */\n readonly nativeValue: bigint;\n readonly nativeDrop: bigint;\n readonly creditSD: bigint;\n readonly sendParam: StargateSendParam;\n readonly validUntilMs: number;\n /** A quote does not reserve credits or promise a delivery time (especially for queued Bus). */\n readonly liquidityReserved: false;\n readonly etaSeconds: null;\n /** Wallet simulation determines gas; an unavailable estimate is never reported as zero. */\n readonly sourceGas: null;\n readonly approvalGas: null;\n}\nexport interface StargateQuoteConfig extends StargateRpcConfig {\n /** Locally reviewed pins; never populate this from an untrusted discovery API. */\n registry?: StargateRegistry;\n quoteTtlMs?: number;\n /** Integer 0..10000, default 2500. This is a cap, not an additional charged fee. */\n feeHeadroomBps?: number;\n}\n\nconst UINT64_MAX = (1n << 64n) - 1n;\nconst UINT256_MAX = (1n << 256n) - 1n;\n\n/** Type-3 index-zero compose gas. No arbitrary native value or extra executor options. */\nexport function stargateComposeOptions(gas: bigint): Hex {\n assertStargate(typeof gas === \"bigint\" && gas > 0n && gas < (1n << 128n), \"compose gas must be a positive uint128\");\n return encodePacked([\"uint16\", \"uint8\", \"uint16\", \"uint8\", \"uint16\", \"uint128\"], [3, 1, 19, 3, 0, gas]);\n}\n\n/** Type 3 / executor worker 1 / native-drop option 2, with a 48-byte payload. */\nexport function taxiNativeDrop(amount: bigint, recipient: Address): Hex {\n assertStargate(typeof amount === \"bigint\" && amount > 0n && amount < (1n << 128n), \"native drop must be a positive uint128\");\n assertStargate(nonzeroAddress(recipient), \"invalid native drop recipient\");\n return encodePacked([\"uint16\", \"uint8\", \"uint16\", \"uint8\", \"uint128\", \"bytes32\"], [3, 1, 49, 2, amount, pad(recipient, {size: 32})]);\n}\n\n/** Read-only direct Stargate quotes. No transaction is signed, sent, or liquidity reserved. */\nexport function createStargateQuoter(config: StargateQuoteConfig) {\n const registry = config.registry ?? stargateRegistry;\n const rpc = stargateRpc(config);\n const ttl = config.quoteTtlMs ?? 60_000;\n const headroom = config.feeHeadroomBps ?? 2500;\n assertStargate(Number.isSafeInteger(ttl) && ttl > 0 && ttl <= 300_000, \"invalid quote lifetime\");\n assertStargate(Number.isInteger(headroom) && headroom >= 0 && headroom <= 10_000, \"invalid messaging fee headroom\");\n\n function supportsRoute(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string): boolean {\n return stargateChainActive(sourceChain) && stargateChainActive(destinationChain) && rpc.has(sourceChain) && rpc.has(destinationChain) && !!registry.route(sourceChain, sourceToken, destinationChain, destinationToken);\n }\n\n async function quote(input: StargateQuoteRequest, signal?: AbortSignal): Promise<StargateQuote> {\n // Copy mutable caller objects before any await.\n const request = {...input, ...(input.nativeDrop ? {nativeDrop: {...input.nativeDrop}} : {})};\n const started = Date.now();\n try {\n assertNotAborted(signal);\n assertStargate(request.mode === \"taxi\" || request.mode === \"bus\", \"invalid transport mode\");\n assertStargate(request.mode !== \"bus\", STARGATE_BUS_RETIRED);\n assertStargate(stargateChainActive(request.sourceChain) && stargateChainActive(request.destinationChain), \"chain support has ended for new transfers\");\n const route = registry.route(request.sourceChain, request.sourceToken, request.destinationChain, request.destinationToken);\n assertStargate(route, \"unsupported token route\");\n const {source, destination} = route;\n assertStargate(nonzeroAddress(request.sender) && nonzeroAddress(request.recipient), \"sender and recipient must be nonzero EVM addresses\");\n const sender = getAddress(request.sender), recipient = getAddress(request.recipient);\n const slippage = request.slippageBps ?? 0;\n assertStargate(Number.isInteger(slippage) && slippage >= 0 && slippage < 10_000, \"invalid slippage\");\n const minimum = request.minimum ?? 0n;\n assertStargate(typeof minimum === \"bigint\" && minimum >= 0n && minimum <= UINT256_MAX, \"invalid minimum\");\n const split = splitSourceAmount(request.amount, source.localDecimals, source.sharedDecimals);\n assertStargate(split.amountSD > 0n, \"amount is below shared-decimal precision\");\n const src = rpc.client(source.chain, signal), dst = rpc.client(destination.chain, signal);\n const [sourceBlock, destinationBlock] = await Promise.all([rpc.snapshot(src, source.chainId), rpc.snapshot(dst, destination.chainId)]);\n await Promise.all([rpc.verify(src, source, destination, sourceBlock), rpc.verify(dst, destination, source, destinationBlock)]);\n assertNotAborted(signal);\n const at = {address: source.address, abi: STARGATE_ABI, blockNumber: sourceBlock.number, account: sender};\n const creditSD = await src.readContract({...at, functionName: \"paths\", args: [destination.eid]});\n let extraOptions: Hex = \"0x\", nativeDrop = 0n;\n const compose = request.compose;\n assertStargate(!compose || (!request.nativeDrop && slippage === 0 && minimum === 0n), \"compose takes an exact bridge output without native drop\");\n if (request.nativeDrop) {\n assertStargate(\"amount\" in request.nativeDrop && !(\"bus\" in request.nativeDrop), \"Taxi requires an explicit native drop amount\");\n nativeDrop = request.nativeDrop.amount;\n extraOptions = taxiNativeDrop(nativeDrop, recipient);\n }\n const probe: StargateSendParam = {dstEid: destination.eid, to: pad(recipient, {size: 32}), amountLD: request.amount, minAmountLD: 0n, extraOptions, composeMsg: \"0x\", oftCmd: \"0x\"};\n const [limit, details, receipt] = await src.readContract({...at, functionName: \"quoteOFT\", args: [probe]});\n assertStargate(limit.minAmountLD <= split.sentLD && split.sentLD <= limit.maxAmountLD, \"amount exceeds available OFT limits\");\n assertStargate(receipt.amountSentLD === split.sentLD, \"quote clipped the exact input amount\");\n const received = destinationAmount(receipt.amountReceivedLD, source.localDecimals, destination.localDecimals, source.sharedDecimals);\n assertStargate(received > 0n, \"quote has no output\");\n const receivedSD = receipt.amountReceivedLD / conversionRate(source.localDecimals, source.sharedDecimals);\n assertStargate(creditSD === UINT64_MAX || receivedSD <= creditSD, \"insufficient credits for output including reward\");\n const fees = splitFeeDetails(details);\n assertStargate(receipt.amountSentLD - fees.feeLD + fees.rewardLD === receipt.amountReceivedLD, \"protocol fee accounting mismatch\");\n // Ceil the slippage floor, then ceil again to a representable shared amount.\n const slipFloor = (received * BigInt(10_000 - slippage) + 9999n) / 10_000n;\n const minAmountLD = sourceMinimum(minimum > slipFloor ? minimum : slipFloor, source.localDecimals, destination.localDecimals, source.sharedDecimals);\n assertStargate(minAmountLD <= receipt.amountReceivedLD, \"output is below the caller's minimum\");\n const sendParam = Object.freeze(compose\n ? {...probe, minAmountLD, extraOptions: stargateComposeOptions(compose.gas), composeMsg: await compose.message(received, signal)}\n : {...probe, minAmountLD});\n assertNotAborted(signal);\n const fee = await src.readContract({...at, functionName: \"quoteSend\", args: [sendParam, false]});\n assertStargate(fee.lzTokenFee === 0n, \"LZ token fees are unsupported\");\n const cap = fee.nativeFee + (fee.nativeFee * BigInt(headroom) + 9999n) / 10_000n;\n const nativeValue = cap + (source.kind === \"native\" ? request.amount : 0n);\n assertStargate(nativeValue <= UINT256_MAX, \"native value overflow\");\n await Promise.all([rpc.unchanged(src, sourceBlock), rpc.unchanged(dst, destinationBlock)]);\n assertNotAborted(signal);\n const validUntilMs = Math.min(started + ttl, stargateChainCutoff(source.chain), stargateChainCutoff(destination.chain));\n assertStargate(Date.now() < validUntilMs, \"quote expired during RPC reads\");\n return Object.freeze({mode: request.mode, source, destination, sender, recipient, sourceBlock, destinationBlock, requestedAmount: request.amount, sentAmount: split.sentLD, dust: split.dustLD, destinationAmount: received, minimumDestinationAmount: destinationAmount(minAmountLD, source.localDecimals, destination.localDecimals, source.sharedDecimals), protocolFee: fees.feeLD, protocolReward: fees.rewardLD, messagingFee: fee.nativeFee, messagingFeeCap: cap, nativeValue, nativeDrop, creditSD, sendParam, validUntilMs, liquidityReserved: false, etaSeconds: null, sourceGas: null, approvalGas: null});\n } catch (error) { throw safeReadError(error); }\n }\n return Object.freeze({supportsRoute, quote});\n}\n","import {parseAbi} from \"viem\";\n\n// LayerZero-v2 592625b9e5967643853476445ffe0e777360b906: historical Executor/IExecutor.\nexport const EXECUTOR_ABI = parseAbi([\n \"struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }\",\n \"struct NativeDropParams { address receiver; uint256 amount; }\",\n \"function endpoint() view returns (address)\",\n \"function localEid() view returns (uint32)\",\n \"event NativeDropApplied(Origin origin, uint32 dstEid, address oapp, NativeDropParams[] params, bool[] success)\",\n]);\n\nexport const ENDPOINT_ABI = parseAbi([\n \"struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }\",\n \"function inboundPayloadHash(address receiver, uint32 srcEid, bytes32 sender, uint64 nonce) view returns (bytes32)\",\n \"function lzReceive(Origin origin, address receiver, bytes32 guid, bytes message, bytes extraData) payable\",\n \"event PacketSent(bytes encodedPayload, bytes options, address sendLibrary)\",\n \"event PacketDelivered(Origin origin, address receiver)\",\n]);\n\n// SDK-322: checked against pinned upstream deployment ABI by abi.test.ts.\n// Provenance: tests/fixtures/upstream.json. This is an interface, not a deployment allowlist.\nexport const STARGATE_ABI = parseAbi([\n \"struct SendParam { uint32 dstEid; bytes32 to; uint256 amountLD; uint256 minAmountLD; bytes extraOptions; bytes composeMsg; bytes oftCmd; }\",\n \"struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }\",\n \"struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }\",\n \"struct OFTLimit { uint256 minAmountLD; uint256 maxAmountLD; }\",\n \"struct OFTFeeDetail { int256 feeAmountLD; string description; }\",\n \"struct OFTReceipt { uint256 amountSentLD; uint256 amountReceivedLD; }\",\n \"struct Ticket { uint72 ticketId; bytes passengerBytes; }\",\n \"struct AddressConfig { address feeLib; address planner; address treasurer; address tokenMessaging; address creditMessaging; address lzToken; }\",\n \"function token() view returns (address)\",\n \"function sharedDecimals() view returns (uint8)\",\n \"function approvalRequired() pure returns (bool)\",\n \"function localEid() view returns (uint32)\",\n \"function endpoint() view returns (address)\",\n \"function status() view returns (uint8)\",\n \"function stargateType() pure returns (uint8)\",\n \"function paths(uint32 eid) view returns (uint64 credit)\",\n \"function getAddressConfig() view returns (AddressConfig)\",\n \"function quoteOFT(SendParam s) view returns (OFTLimit limit, OFTFeeDetail[] oftFeeDetails, OFTReceipt receipt)\",\n \"function quoteSend(SendParam s, bool payInLzToken) view returns (MessagingFee fee)\",\n \"function send(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt)\",\n \"function sendToken(SendParam s, MessagingFee fee, address refundAddress) payable returns (MessagingReceipt msgReceipt, OFTReceipt oftReceipt, Ticket ticket)\",\n \"function unreceivedTokens(bytes32 guid, uint8 index) view returns (bytes32)\",\n \"function retryReceiveToken(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)\",\n \"event OFTSent(bytes32 indexed guid, uint32 dstEid, address indexed fromAddress, uint256 amountSentLD, uint256 amountReceivedLD)\",\n \"event OFTReceived(bytes32 indexed guid, uint32 srcEid, address indexed toAddress, uint256 amountReceivedLD)\",\n \"event UnreceivedTokenCached(bytes32 guid, uint8 index, uint32 srcEid, address receiver, uint256 amountLD, bytes composeMsg)\",\n]);\n\nexport const TOKEN_MESSAGING_ABI = parseAbi([\n \"error Bus_InvalidFare(bool nativeDrop)\",\n \"struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }\",\n \"struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; }\",\n \"function assetIds(address stargateImpl) view returns (uint16)\",\n \"function stargateImpls(uint16 assetId) view returns (address)\",\n \"function peers(uint32 eid) view returns (bytes32)\",\n \"function endpoint() view returns (address)\",\n \"function nativeDropAmounts(uint32 eid) view returns (uint128)\",\n \"function queueCapacity() view returns (uint16)\",\n \"function busQueues(uint32 eid) view returns (uint8 maxNumPassengers, uint80 busFare, uint80 busAndNativeDropFare, uint16 qLength, uint72 nextTicketId)\",\n \"function getPassengerHash(uint32 eid, uint16 index) view returns (bytes32)\",\n \"function quoteDriveBus(uint32 dstEid, bytes passengers) view returns (MessagingFee fee)\",\n \"function driveBus(uint32 dstEid, bytes passengers) payable returns (MessagingReceipt receipt)\",\n \"event BusRode(uint32 dstEid, uint72 ticketId, uint80 fare, bytes passenger)\",\n \"event BusDriven(uint32 dstEid, uint72 startTicketId, uint8 numPassengers, bytes32 guid)\",\n \"event NativeDropApplied(address receiver, uint128 amount)\",\n \"event NativeDropFailed(address receiver, uint128 amount)\",\n]);\n","const UINT64_MAX = (1n << 64n) - 1n;\nconst UINT256_MAX = (1n << 256n) - 1n;\n\nfunction uint256(amount: bigint): void {\n if (typeof amount !== \"bigint\" || amount < 0n || amount > UINT256_MAX) throw new RangeError(\"stargate: amount must be uint256 bigint\");\n}\n\n/** Stargate converts through a uint64 shared-decimal amount. */\nexport function conversionRate(localDecimals: number, sharedDecimals: number): bigint {\n if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {\n throw new RangeError(\"stargate: invalid local/shared decimals\");\n }\n return 10n ** BigInt(localDecimals - sharedDecimals);\n}\n\n/** Source amount that can be represented on the wire; dust is not silently added to the output. */\nexport function splitSourceAmount(amountLD: bigint, localDecimals: number, sharedDecimals: number): {amountSD: bigint; sentLD: bigint; dustLD: bigint} {\n uint256(amountLD);\n const rate = conversionRate(localDecimals, sharedDecimals);\n const amountSD = amountLD / rate;\n if (amountSD > UINT64_MAX) throw new RangeError(\"stargate: shared amount exceeds uint64\");\n return {amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate};\n}\n\n/** quoteOFT's received amount uses SOURCE local decimals, not destination decimals. */\nexport function destinationAmount(receivedSourceLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n const {amountSD, dustLD} = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);\n if (dustLD !== 0n) throw new RangeError(\"stargate: quote receipt is not shared-decimal aligned\");\n const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);\n uint256(amount);\n return amount;\n}\n\n/** Round the caller's destination floor UP, then encode it in source local units. */\nexport function sourceMinimum(minDestinationLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n uint256(minDestinationLD);\n const destinationRate = conversionRate(destinationDecimals, sharedDecimals);\n const minimumSD = (minDestinationLD + destinationRate - 1n) / destinationRate;\n if (minimumSD > UINT64_MAX) throw new RangeError(\"stargate: minimum exceeds uint64 shared amount\");\n const minimumLD = minimumSD * conversionRate(sourceDecimals, sharedDecimals);\n uint256(minimumLD);\n return minimumLD;\n}\n\n/** Stargate fee details are negative for charges, positive for rewards. Both use source local units. */\nexport function splitFeeDetails(details: readonly {feeAmountLD: bigint}[]): {feeLD: bigint; rewardLD: bigint} {\n let feeLD = 0n, rewardLD = 0n;\n for (const {feeAmountLD} of details) {\n if (typeof feeAmountLD !== \"bigint\" || feeAmountLD < -(1n << 255n) || feeAmountLD >= (1n << 255n)) throw new RangeError(\"stargate: fee must be int256 bigint\");\n if (feeAmountLD < 0n) feeLD -= feeAmountLD;\n else rewardLD += feeAmountLD;\n }\n return {feeLD, rewardLD};\n}\n","import {getAddress, isAddress, zeroAddress, type Address} from \"viem\";\nimport {conversionRate} from \"./amounts.js\";\n\n/** Reviewed deployment identity. Discovery metadata is never a runtime trust source. */\nexport interface StargateDeployment {\n readonly chain: string;\n readonly chainId: number;\n readonly eid: number;\n readonly assetId: number;\n readonly symbol: string;\n readonly token: Address;\n readonly address: Address;\n readonly tokenMessaging: Address;\n readonly endpoint: Address;\n readonly localDecimals: number;\n readonly sharedDecimals: number;\n readonly kind: \"pool\" | \"oft\" | \"native\";\n readonly approvalRequired: boolean;\n}\n\n/** Source TokenMessaging peer evidence. Credits/fees/paused state must still be read live. */\nexport interface StargatePath {\n readonly source: string;\n readonly destination: string;\n}\n\nexport interface StargateRegistry {\n readonly deployments: readonly StargateDeployment[];\n readonly paths: readonly StargatePath[];\n find(chain: string, token: string): StargateDeployment | undefined;\n route(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string): {source: StargateDeployment; destination: StargateDeployment} | undefined;\n callTargets(chain: string): readonly Address[];\n spenders(chain: string): readonly Address[];\n}\n\nfunction boundedInteger(value: number, max: number, name: string): void {\n if (!Number.isSafeInteger(value) || value <= 0 || value > max) throw new Error(`stargate registry: invalid ${name}`);\n}\nfunction address(value: string, nonzero: boolean): Address {\n if (!isAddress(value) || (nonzero && value.toLowerCase() === zeroAddress)) throw new Error(\"stargate registry: invalid address\");\n return getAddress(value);\n}\n\n/**\n * Builds immutable lookup/pin data from a reviewed static manifest. Token symbols\n * are deliberately not resolved here: a symbol can name a different token in the\n * app's catalog (USDC/USDC.e and USDT/USDT0 are not interchangeable).\n */\nexport function createStargateRegistry(input: readonly StargateDeployment[], inputPaths: readonly StargatePath[]): StargateRegistry {\n const ids = new Map<string, StargateDeployment>();\n const tokens = new Map<string, StargateDeployment>();\n const contracts = new Set<string>();\n const chains = new Map<string, StargateDeployment>();\n const eids = new Map<number, string>();\n const shared = new Map<number, number>();\n const deployments = Object.freeze(input.map((raw) => {\n boundedInteger(raw.chainId, Number.MAX_SAFE_INTEGER, \"chainId\");\n boundedInteger(raw.eid, 0xffffffff, \"eid\");\n boundedInteger(raw.assetId, 0xffff, \"assetId\");\n if (raw.chain !== `eip155:${raw.chainId}`) throw new Error(\"stargate registry: chainId mismatch\");\n conversionRate(raw.localDecimals, raw.sharedDecimals);\n 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\");\n 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)});\n if ((d.kind === \"native\") !== (d.token === zeroAddress)) throw new Error(\"stargate registry: native token mismatch\");\n const identity = `${d.chain}:${d.assetId}`;\n const tokenKey = `${d.chain}:${d.token.toLowerCase()}`;\n const contractKey = `${d.chain}:${d.address.toLowerCase()}`;\n if (ids.has(identity) || tokens.has(tokenKey) || contracts.has(contractKey)) throw new Error(\"stargate registry: duplicate deployment\");\n const chain = chains.get(d.chain);\n if (chain && (chain.eid !== d.eid || chain.tokenMessaging !== d.tokenMessaging || chain.endpoint !== d.endpoint)) throw new Error(\"stargate registry: inconsistent chain messaging\");\n if (eids.has(d.eid) && eids.get(d.eid) !== d.chain) throw new Error(\"stargate registry: eid names multiple chains\");\n if (shared.has(d.assetId) && shared.get(d.assetId) !== d.sharedDecimals) throw new Error(\"stargate registry: incompatible shared decimals\");\n ids.set(identity, d); tokens.set(tokenKey, d); contracts.add(contractKey);\n chains.set(d.chain, d); eids.set(d.eid, d.chain); shared.set(d.assetId, d.sharedDecimals);\n return d;\n }));\n const pathKeys = new Set<string>();\n const paths = Object.freeze(inputPaths.map((path) => {\n if (path.source === path.destination || !chains.has(path.source) || !chains.has(path.destination)) throw new Error(\"stargate registry: invalid path\");\n const key = `${path.source}>${path.destination}`;\n if (pathKeys.has(key)) throw new Error(\"stargate registry: duplicate path\");\n pathKeys.add(key);\n return Object.freeze({source: path.source, destination: path.destination});\n }));\n const lookup = (chain: string, token: string) => chains.has(chain) && isAddress(token, {strict: false})\n ? tokens.get(`${chain}:${token.toLowerCase()}`) : undefined;\n return Object.freeze({\n deployments, paths,\n find: lookup,\n route(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string) {\n if (!pathKeys.has(`${sourceChain}>${destinationChain}`)) return undefined;\n const source = lookup(sourceChain, sourceToken), destination = lookup(destinationChain, destinationToken);\n return source && destination && source.assetId === destination.assetId ? {source, destination} : undefined;\n },\n callTargets: (chain: string) => Object.freeze(deployments.filter((d) => d.chain === chain).map((d) => d.address)),\n spenders: (chain: string) => Object.freeze(deployments.filter((d) => d.chain === chain && d.kind !== \"native\" && d.approvalRequired).map((d) => d.address)),\n });\n}\n","// Reviewed from tests/fixtures/registry.json; discovery never changes these runtime pins.\nimport {createStargateRegistry, type StargateDeployment, type StargatePath} from \"./registry.js\";\n\nexport const STARGATE_REGISTRY_EVIDENCE = Object.freeze({\n \"upstreamCommit\": \"414f47412123d7737520c6ba331c1376ec874a88\",\n \"capturedAt\": \"2026-11-16T14:40:36.782Z\",\n \"sha256\": \"ab4fba3cc845a3dcb8a804bffc6a53d7f7982bf974b45cec686095eefb70426f\"\n});\n\nconst deployments: readonly StargateDeployment[] = [\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"chain\":\"eip155:5000\",\"chainId\":5000,\"eid\":30181,\"assetId\":1,\"symbol\":\"USDC\",\"token\":\"0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9\",\"address\":\"0xAc290Ad4e0c891FDc295ca4F0a6214cf6dC6acDC\",\"tokenMessaging\":\"0x41B491285A4f888F9f636cEc8a363AB9770a0AEF\",\"endpoint\":\"0x1a44076050125825900e736c501f859c50fE728c\",\"localDecimals\":6,\"sharedDecimals\":6,\"kind\":\"pool\",\"approvalRequired\":true},\n {\"chain\":\"eip155:5000\",\"chainId\":5000,\"eid\":30181,\"assetId\":13,\"symbol\":\"WETH\",\"token\":\"0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111\",\"address\":\"0x4c1d3Fc3fC3c177c3b633427c2F769276c547463\",\"tokenMessaging\":\"0x41B491285A4f888F9f636cEc8a363AB9770a0AEF\",\"endpoint\":\"0x1a44076050125825900e736c501f859c50fE728c\",\"localDecimals\":18,\"sharedDecimals\":6,\"kind\":\"pool\",\"approvalRequired\":true},\n {\"chain\":\"eip155:5000\",\"chainId\":5000,\"eid\":30181,\"assetId\":22,\"symbol\":\"mETH\",\"token\":\"0xcDA86A272531e8640cD7F1a92c01839911B90bb0\",\"address\":\"0xF7628d84a2BbD9bb9c8E686AC95BB5d55169F3F1\",\"tokenMessaging\":\"0x41B491285A4f888F9f636cEc8a363AB9770a0AEF\",\"endpoint\":\"0x1a44076050125825900e736c501f859c50fE728c\",\"localDecimals\":18,\"sharedDecimals\":6,\"kind\":\"pool\",\"approvalRequired\":true},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n {\"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},\n];\n\nconst paths: readonly StargatePath[] = [\n {\"source\":\"eip155:1\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:1\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:10\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:130\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:1329\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:137\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:14\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:146\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:42161\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:43114\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:5000\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:534352\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:56\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:9745\"},\n {\"source\":\"eip155:8453\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:9745\",\"destination\":\"eip155:98866\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:1\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:10\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:130\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:1329\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:137\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:14\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:146\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:42161\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:43114\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:5000\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:534352\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:56\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:8453\"},\n {\"source\":\"eip155:98866\",\"destination\":\"eip155:9745\"},\n];\n\n/** Verified identities and messaging peers; route liquidity and mode availability remain live checks. */\nexport const stargateRegistry = createStargateRegistry(deployments, paths);\n","/** Reviewed service policy, separate from deployment identity and historical tracking.\n * https://layerzero.network/blog/ecosystem-update-september-2026 (2026-09-15)\n * https://layerzero.network/blog/support-update-july-24-2026 (updated 2026-10-29)\n */\nexport const STARGATE_BUS_RETIRED = \"Stargate Bus is retired for new transfers; use Taxi\";\n\n// Scroll is the only currently pinned chain in the announced Stargate sunset list.\n// Fail closed at the beginning of the effective day (UTC); tracking stays available.\nexport function stargateChainCutoff(chain: string): number {\n return chain === \"eip155:534352\" ? Date.UTC(2026, 11, 8) : Infinity;\n}\n\nexport function stargateChainActive(chain: string, now = Date.now()): boolean {\n return now < stargateChainCutoff(chain);\n}\n","import {createPublicClient, fallback, http, pad, parseAbi, type Address, type Hex, type PublicClient} from \"viem\";\nimport {STARGATE_ABI, TOKEN_MESSAGING_ABI} from \"./abi.js\";\nimport type {StargateDeployment} from \"./registry.js\";\n\nexport class StargateReadError extends Error {\n constructor(message: string) { super(`stargate: ${message}`); this.name = \"StargateReadError\"; }\n}\n\nexport interface StargateRpcConfig {\n /** Both source and destination RPCs are required. URLs are never included in errors. */\n rpcUrls: Readonly<Record<string, string | readonly string[]>>;\n fetchImpl?: typeof fetch;\n}\nexport interface StargateBlock {readonly number: bigint; readonly hash: Hex; readonly timestamp: bigint}\nexport interface StargateRpc {\n has(chain: string): boolean;\n client(chain: string, signal?: AbortSignal): PublicClient;\n snapshot(client: PublicClient, chainId: number): Promise<StargateBlock>;\n verify(client: PublicClient, deployment: StargateDeployment, peer: StargateDeployment, block: StargateBlock): Promise<void>;\n unchanged(client: PublicClient, block: StargateBlock): Promise<void>;\n}\nconst auxiliaryAbi = parseAbi([\"function decimals() view returns (uint8)\", \"function eid() view returns (uint32)\"]);\nexport const sameAddress = (a: string, b: string): boolean => a.toLowerCase() === b.toLowerCase();\nexport function assertStargate(condition: unknown, message: string): asserts condition {\n if (!condition) throw new StargateReadError(message);\n}\nexport function assertNotAborted(signal?: AbortSignal): void {\n if (signal?.aborted) throw new StargateReadError(\"request cancelled\");\n}\n\n/** No mutable deployment/peer/paused-state cache: every quote verifies a fresh snapshot. */\nexport function stargateRpc(config: StargateRpcConfig): StargateRpc {\n const urls = new Map(Object.entries(config.rpcUrls).map(([chain, value]) => {\n const list = typeof value === \"string\" ? [value] : [...value];\n assertStargate(list.length && list.every((url) => /^https?:\\/\\//.test(url)), \"invalid RPC configuration\");\n return [chain, list] as const;\n }));\n function client(chain: string, signal?: AbortSignal): PublicClient {\n const list = urls.get(chain);\n assertStargate(list, `no RPC configured for ${chain}`);\n assertNotAborted(signal);\n const transport = (url: string) => http(url, {timeout: 12_000, retryCount: 0, ...(config.fetchImpl ? {fetchFn: config.fetchImpl} : {}), ...(signal ? {fetchOptions: {signal}} : {})});\n return createPublicClient({transport: list.length === 1 ? transport(list[0]!) : fallback(list.map(transport), {retryCount: 0}), ccipRead: false});\n }\n type Client = ReturnType<typeof client>;\n async function snapshot(c: Client, chainId: number): Promise<StargateBlock> {\n const [actual, block] = await Promise.all([c.getChainId(), c.getBlock({blockTag: \"latest\"})]);\n assertStargate(actual === chainId, \"RPC chain id mismatch\");\n assertStargate(block.hash && block.number !== null, \"RPC returned an unmined block\");\n // Stale nodes must not turn old fees/credits into a new, apparently fresh quote.\n const now = BigInt(Math.floor(Date.now() / 1000));\n assertStargate(block.timestamp >= now - 300n && block.timestamp <= now + 60n, \"RPC block is stale or in the future\");\n return Object.freeze({number: block.number, hash: block.hash, timestamp: block.timestamp});\n }\n async function verify(c: Client, d: StargateDeployment, peer: StargateDeployment, block: StargateBlock): Promise<void> {\n const at = {blockNumber: block.number};\n const pool = {address: d.address, abi: STARGATE_ABI, ...at};\n const messaging = {address: d.tokenMessaging, abi: TOKEN_MESSAGING_ABI, ...at};\n const [token, shared, approval, eid, endpoint, status, kind, roles, assetId, implementation, messagingEndpoint, remotePeer, endpointEid, decimals] = await Promise.all([\n c.readContract({...pool, functionName: \"token\"}),\n c.readContract({...pool, functionName: \"sharedDecimals\"}),\n c.readContract({...pool, functionName: \"approvalRequired\"}),\n c.readContract({...pool, functionName: \"localEid\"}),\n c.readContract({...pool, functionName: \"endpoint\"}),\n c.readContract({...pool, functionName: \"status\"}),\n c.readContract({...pool, functionName: \"stargateType\"}),\n c.readContract({...pool, functionName: \"getAddressConfig\"}),\n c.readContract({...messaging, functionName: \"assetIds\", args: [d.address]}),\n c.readContract({...messaging, functionName: \"stargateImpls\", args: [d.assetId]}),\n c.readContract({...messaging, functionName: \"endpoint\"}),\n c.readContract({...messaging, functionName: \"peers\", args: [peer.eid]}),\n c.readContract({address: d.endpoint, abi: auxiliaryAbi, functionName: \"eid\", ...at}),\n d.kind === \"native\" ? Promise.resolve(d.localDecimals) : c.readContract({address: d.token, abi: auxiliaryAbi, functionName: \"decimals\", ...at}),\n ]);\n 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}`);\n assertStargate(status === 1, `deployment is not active on ${d.chain}`);\n assertStargate(sameAddress(remotePeer, pad(peer.tokenMessaging, {size: 32})), `messaging peer mismatch on ${d.chain}`);\n }\n async function unchanged(c: Client, block: StargateBlock): Promise<void> {\n assertStargate((await c.getBlock({blockNumber: block.number})).hash === block.hash, \"block changed during quote\");\n }\n return {has: (chain: string) => urls.has(chain), client, snapshot, verify, unchanged};\n}\n\n/** Never propagate viem errors: they can contain credential-bearing URLs and request bodies. */\nexport function safeReadError(error: unknown): StargateReadError {\n return error instanceof StargateReadError ? error : new StargateReadError(\"RPC read, quote or decoding failed\");\n}\n\nexport function nonzeroAddress(value: string): value is Address {\n return /^0x[0-9a-fA-F]{40}$/.test(value) && !/^0x0{40}$/.test(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAoE;;;ACApE,kBAAuB;AAGhB,IAAM,mBAAe,sBAAS;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,mBAAe,sBAAS;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,mBAAe,sBAAS;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,0BAAsB,sBAAS;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;;;ACpED,IAAM,cAAc,MAAM,OAAO;AACjC,IAAM,eAAe,MAAM,QAAQ;AAEnC,SAAS,QAAQ,QAAsB;AACrC,MAAI,OAAO,WAAW,YAAY,SAAS,MAAM,SAAS,YAAa,OAAM,IAAI,WAAW,yCAAyC;AACvI;AAGO,SAAS,eAAe,e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,aAAa,YAAY,UAAU,WAAW,cAAc,mBAAmB,OAAO,YAAY,MAAM,WAAW,MAAM,aAAa,KAAI,CAAC;AAAA,IACvlB,SAAS,OAAO;AAAE,YAAM,cAAc,KAAK;AAAA,IAAG;AAAA,EAChD;AACA,SAAO,OAAO,OAAO,EAAC,eAAe,MAAK,CAAC;AAC7C;","names":["import_viem","import_viem","deployments","paths","import_viem","UINT64_MAX","UINT256_MAX"]}
|
package/dist/quote.d.cts
ADDED
package/dist/quote.d.ts
ADDED
package/dist/quote.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createStargateQuoter,
|
|
3
|
+
stargateComposeOptions,
|
|
4
|
+
taxiNativeDrop
|
|
5
|
+
} from "./chunk-3NTMZUAU.js";
|
|
6
|
+
import "./chunk-ERC6LKMN.js";
|
|
7
|
+
import "./chunk-EANM3EI3.js";
|
|
8
|
+
import "./chunk-4HU46QF2.js";
|
|
9
|
+
import "./chunk-QNVTQEOV.js";
|
|
10
|
+
import "./chunk-OUGUX3JK.js";
|
|
11
|
+
export {
|
|
12
|
+
createStargateQuoter,
|
|
13
|
+
stargateComposeOptions,
|
|
14
|
+
taxiNativeDrop
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
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/registry.ts
|
|
21
|
+
var registry_exports = {};
|
|
22
|
+
__export(registry_exports, {
|
|
23
|
+
createStargateRegistry: () => createStargateRegistry
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(registry_exports);
|
|
26
|
+
var import_viem = require("viem");
|
|
27
|
+
|
|
28
|
+
// src/amounts.ts
|
|
29
|
+
var UINT64_MAX = (1n << 64n) - 1n;
|
|
30
|
+
var UINT256_MAX = (1n << 256n) - 1n;
|
|
31
|
+
function conversionRate(localDecimals, sharedDecimals) {
|
|
32
|
+
if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {
|
|
33
|
+
throw new RangeError("stargate: invalid local/shared decimals");
|
|
34
|
+
}
|
|
35
|
+
return 10n ** BigInt(localDecimals - sharedDecimals);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/registry.ts
|
|
39
|
+
function boundedInteger(value, max, name) {
|
|
40
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > max) throw new Error(`stargate registry: invalid ${name}`);
|
|
41
|
+
}
|
|
42
|
+
function address(value, nonzero) {
|
|
43
|
+
if (!(0, import_viem.isAddress)(value) || nonzero && value.toLowerCase() === import_viem.zeroAddress) throw new Error("stargate registry: invalid address");
|
|
44
|
+
return (0, import_viem.getAddress)(value);
|
|
45
|
+
}
|
|
46
|
+
function createStargateRegistry(input, inputPaths) {
|
|
47
|
+
const ids = /* @__PURE__ */ new Map();
|
|
48
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
49
|
+
const contracts = /* @__PURE__ */ new Set();
|
|
50
|
+
const chains = /* @__PURE__ */ new Map();
|
|
51
|
+
const eids = /* @__PURE__ */ new Map();
|
|
52
|
+
const shared = /* @__PURE__ */ new Map();
|
|
53
|
+
const deployments = Object.freeze(input.map((raw) => {
|
|
54
|
+
boundedInteger(raw.chainId, Number.MAX_SAFE_INTEGER, "chainId");
|
|
55
|
+
boundedInteger(raw.eid, 4294967295, "eid");
|
|
56
|
+
boundedInteger(raw.assetId, 65535, "assetId");
|
|
57
|
+
if (raw.chain !== `eip155:${raw.chainId}`) throw new Error("stargate registry: chainId mismatch");
|
|
58
|
+
conversionRate(raw.localDecimals, raw.sharedDecimals);
|
|
59
|
+
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");
|
|
60
|
+
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) });
|
|
61
|
+
if (d.kind === "native" !== (d.token === import_viem.zeroAddress)) throw new Error("stargate registry: native token mismatch");
|
|
62
|
+
const identity = `${d.chain}:${d.assetId}`;
|
|
63
|
+
const tokenKey = `${d.chain}:${d.token.toLowerCase()}`;
|
|
64
|
+
const contractKey = `${d.chain}:${d.address.toLowerCase()}`;
|
|
65
|
+
if (ids.has(identity) || tokens.has(tokenKey) || contracts.has(contractKey)) throw new Error("stargate registry: duplicate deployment");
|
|
66
|
+
const chain = chains.get(d.chain);
|
|
67
|
+
if (chain && (chain.eid !== d.eid || chain.tokenMessaging !== d.tokenMessaging || chain.endpoint !== d.endpoint)) throw new Error("stargate registry: inconsistent chain messaging");
|
|
68
|
+
if (eids.has(d.eid) && eids.get(d.eid) !== d.chain) throw new Error("stargate registry: eid names multiple chains");
|
|
69
|
+
if (shared.has(d.assetId) && shared.get(d.assetId) !== d.sharedDecimals) throw new Error("stargate registry: incompatible shared decimals");
|
|
70
|
+
ids.set(identity, d);
|
|
71
|
+
tokens.set(tokenKey, d);
|
|
72
|
+
contracts.add(contractKey);
|
|
73
|
+
chains.set(d.chain, d);
|
|
74
|
+
eids.set(d.eid, d.chain);
|
|
75
|
+
shared.set(d.assetId, d.sharedDecimals);
|
|
76
|
+
return d;
|
|
77
|
+
}));
|
|
78
|
+
const pathKeys = /* @__PURE__ */ new Set();
|
|
79
|
+
const paths = Object.freeze(inputPaths.map((path) => {
|
|
80
|
+
if (path.source === path.destination || !chains.has(path.source) || !chains.has(path.destination)) throw new Error("stargate registry: invalid path");
|
|
81
|
+
const key = `${path.source}>${path.destination}`;
|
|
82
|
+
if (pathKeys.has(key)) throw new Error("stargate registry: duplicate path");
|
|
83
|
+
pathKeys.add(key);
|
|
84
|
+
return Object.freeze({ source: path.source, destination: path.destination });
|
|
85
|
+
}));
|
|
86
|
+
const lookup = (chain, token) => chains.has(chain) && (0, import_viem.isAddress)(token, { strict: false }) ? tokens.get(`${chain}:${token.toLowerCase()}`) : void 0;
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
deployments,
|
|
89
|
+
paths,
|
|
90
|
+
find: lookup,
|
|
91
|
+
route(sourceChain, sourceToken, destinationChain, destinationToken) {
|
|
92
|
+
if (!pathKeys.has(`${sourceChain}>${destinationChain}`)) return void 0;
|
|
93
|
+
const source = lookup(sourceChain, sourceToken), destination = lookup(destinationChain, destinationToken);
|
|
94
|
+
return source && destination && source.assetId === destination.assetId ? { source, destination } : void 0;
|
|
95
|
+
},
|
|
96
|
+
callTargets: (chain) => Object.freeze(deployments.filter((d) => d.chain === chain).map((d) => d.address)),
|
|
97
|
+
spenders: (chain) => Object.freeze(deployments.filter((d) => d.chain === chain && d.kind !== "native" && d.approvalRequired).map((d) => d.address))
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=registry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/registry.ts","../src/amounts.ts"],"sourcesContent":["import {getAddress, isAddress, zeroAddress, type Address} from \"viem\";\nimport {conversionRate} from \"./amounts.js\";\n\n/** Reviewed deployment identity. Discovery metadata is never a runtime trust source. */\nexport interface StargateDeployment {\n readonly chain: string;\n readonly chainId: number;\n readonly eid: number;\n readonly assetId: number;\n readonly symbol: string;\n readonly token: Address;\n readonly address: Address;\n readonly tokenMessaging: Address;\n readonly endpoint: Address;\n readonly localDecimals: number;\n readonly sharedDecimals: number;\n readonly kind: \"pool\" | \"oft\" | \"native\";\n readonly approvalRequired: boolean;\n}\n\n/** Source TokenMessaging peer evidence. Credits/fees/paused state must still be read live. */\nexport interface StargatePath {\n readonly source: string;\n readonly destination: string;\n}\n\nexport interface StargateRegistry {\n readonly deployments: readonly StargateDeployment[];\n readonly paths: readonly StargatePath[];\n find(chain: string, token: string): StargateDeployment | undefined;\n route(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string): {source: StargateDeployment; destination: StargateDeployment} | undefined;\n callTargets(chain: string): readonly Address[];\n spenders(chain: string): readonly Address[];\n}\n\nfunction boundedInteger(value: number, max: number, name: string): void {\n if (!Number.isSafeInteger(value) || value <= 0 || value > max) throw new Error(`stargate registry: invalid ${name}`);\n}\nfunction address(value: string, nonzero: boolean): Address {\n if (!isAddress(value) || (nonzero && value.toLowerCase() === zeroAddress)) throw new Error(\"stargate registry: invalid address\");\n return getAddress(value);\n}\n\n/**\n * Builds immutable lookup/pin data from a reviewed static manifest. Token symbols\n * are deliberately not resolved here: a symbol can name a different token in the\n * app's catalog (USDC/USDC.e and USDT/USDT0 are not interchangeable).\n */\nexport function createStargateRegistry(input: readonly StargateDeployment[], inputPaths: readonly StargatePath[]): StargateRegistry {\n const ids = new Map<string, StargateDeployment>();\n const tokens = new Map<string, StargateDeployment>();\n const contracts = new Set<string>();\n const chains = new Map<string, StargateDeployment>();\n const eids = new Map<number, string>();\n const shared = new Map<number, number>();\n const deployments = Object.freeze(input.map((raw) => {\n boundedInteger(raw.chainId, Number.MAX_SAFE_INTEGER, \"chainId\");\n boundedInteger(raw.eid, 0xffffffff, \"eid\");\n boundedInteger(raw.assetId, 0xffff, \"assetId\");\n if (raw.chain !== `eip155:${raw.chainId}`) throw new Error(\"stargate registry: chainId mismatch\");\n conversionRate(raw.localDecimals, raw.sharedDecimals);\n 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\");\n 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)});\n if ((d.kind === \"native\") !== (d.token === zeroAddress)) throw new Error(\"stargate registry: native token mismatch\");\n const identity = `${d.chain}:${d.assetId}`;\n const tokenKey = `${d.chain}:${d.token.toLowerCase()}`;\n const contractKey = `${d.chain}:${d.address.toLowerCase()}`;\n if (ids.has(identity) || tokens.has(tokenKey) || contracts.has(contractKey)) throw new Error(\"stargate registry: duplicate deployment\");\n const chain = chains.get(d.chain);\n if (chain && (chain.eid !== d.eid || chain.tokenMessaging !== d.tokenMessaging || chain.endpoint !== d.endpoint)) throw new Error(\"stargate registry: inconsistent chain messaging\");\n if (eids.has(d.eid) && eids.get(d.eid) !== d.chain) throw new Error(\"stargate registry: eid names multiple chains\");\n if (shared.has(d.assetId) && shared.get(d.assetId) !== d.sharedDecimals) throw new Error(\"stargate registry: incompatible shared decimals\");\n ids.set(identity, d); tokens.set(tokenKey, d); contracts.add(contractKey);\n chains.set(d.chain, d); eids.set(d.eid, d.chain); shared.set(d.assetId, d.sharedDecimals);\n return d;\n }));\n const pathKeys = new Set<string>();\n const paths = Object.freeze(inputPaths.map((path) => {\n if (path.source === path.destination || !chains.has(path.source) || !chains.has(path.destination)) throw new Error(\"stargate registry: invalid path\");\n const key = `${path.source}>${path.destination}`;\n if (pathKeys.has(key)) throw new Error(\"stargate registry: duplicate path\");\n pathKeys.add(key);\n return Object.freeze({source: path.source, destination: path.destination});\n }));\n const lookup = (chain: string, token: string) => chains.has(chain) && isAddress(token, {strict: false})\n ? tokens.get(`${chain}:${token.toLowerCase()}`) : undefined;\n return Object.freeze({\n deployments, paths,\n find: lookup,\n route(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string) {\n if (!pathKeys.has(`${sourceChain}>${destinationChain}`)) return undefined;\n const source = lookup(sourceChain, sourceToken), destination = lookup(destinationChain, destinationToken);\n return source && destination && source.assetId === destination.assetId ? {source, destination} : undefined;\n },\n callTargets: (chain: string) => Object.freeze(deployments.filter((d) => d.chain === chain).map((d) => d.address)),\n spenders: (chain: string) => Object.freeze(deployments.filter((d) => d.chain === chain && d.kind !== \"native\" && d.approvalRequired).map((d) => d.address)),\n });\n}\n","const UINT64_MAX = (1n << 64n) - 1n;\nconst UINT256_MAX = (1n << 256n) - 1n;\n\nfunction uint256(amount: bigint): void {\n if (typeof amount !== \"bigint\" || amount < 0n || amount > UINT256_MAX) throw new RangeError(\"stargate: amount must be uint256 bigint\");\n}\n\n/** Stargate converts through a uint64 shared-decimal amount. */\nexport function conversionRate(localDecimals: number, sharedDecimals: number): bigint {\n if (!Number.isInteger(localDecimals) || !Number.isInteger(sharedDecimals) || sharedDecimals < 0 || localDecimals < sharedDecimals || localDecimals > 255 || localDecimals - sharedDecimals > 77) {\n throw new RangeError(\"stargate: invalid local/shared decimals\");\n }\n return 10n ** BigInt(localDecimals - sharedDecimals);\n}\n\n/** Source amount that can be represented on the wire; dust is not silently added to the output. */\nexport function splitSourceAmount(amountLD: bigint, localDecimals: number, sharedDecimals: number): {amountSD: bigint; sentLD: bigint; dustLD: bigint} {\n uint256(amountLD);\n const rate = conversionRate(localDecimals, sharedDecimals);\n const amountSD = amountLD / rate;\n if (amountSD > UINT64_MAX) throw new RangeError(\"stargate: shared amount exceeds uint64\");\n return {amountSD, sentLD: amountSD * rate, dustLD: amountLD % rate};\n}\n\n/** quoteOFT's received amount uses SOURCE local decimals, not destination decimals. */\nexport function destinationAmount(receivedSourceLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n const {amountSD, dustLD} = splitSourceAmount(receivedSourceLD, sourceDecimals, sharedDecimals);\n if (dustLD !== 0n) throw new RangeError(\"stargate: quote receipt is not shared-decimal aligned\");\n const amount = amountSD * conversionRate(destinationDecimals, sharedDecimals);\n uint256(amount);\n return amount;\n}\n\n/** Round the caller's destination floor UP, then encode it in source local units. */\nexport function sourceMinimum(minDestinationLD: bigint, sourceDecimals: number, destinationDecimals: number, sharedDecimals: number): bigint {\n uint256(minDestinationLD);\n const destinationRate = conversionRate(destinationDecimals, sharedDecimals);\n const minimumSD = (minDestinationLD + destinationRate - 1n) / destinationRate;\n if (minimumSD > UINT64_MAX) throw new RangeError(\"stargate: minimum exceeds uint64 shared amount\");\n const minimumLD = minimumSD * conversionRate(sourceDecimals, sharedDecimals);\n uint256(minimumLD);\n return minimumLD;\n}\n\n/** Stargate fee details are negative for charges, positive for rewards. Both use source local units. */\nexport function splitFeeDetails(details: readonly {feeAmountLD: bigint}[]): {feeLD: bigint; rewardLD: bigint} {\n let feeLD = 0n, rewardLD = 0n;\n for (const {feeAmountLD} of details) {\n if (typeof feeAmountLD !== \"bigint\" || feeAmountLD < -(1n << 255n) || feeAmountLD >= (1n << 255n)) throw new RangeError(\"stargate: fee must be int256 bigint\");\n if (feeAmountLD < 0n) feeLD -= feeAmountLD;\n else rewardLD += feeAmountLD;\n }\n return {feeLD, rewardLD};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+D;;;ACA/D,IAAM,cAAc,MAAM,OAAO;AACjC,IAAM,eAAe,MAAM,QAAQ;AAO5B,SAAS,eAAe,eAAuB,gBAAgC;AACpF,MAAI,CAAC,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C;AAAA,EAC5J,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
|
|
3
|
+
/** Reviewed deployment identity. Discovery metadata is never a runtime trust source. */
|
|
4
|
+
interface StargateDeployment {
|
|
5
|
+
readonly chain: string;
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly eid: number;
|
|
8
|
+
readonly assetId: number;
|
|
9
|
+
readonly symbol: string;
|
|
10
|
+
readonly token: Address;
|
|
11
|
+
readonly address: Address;
|
|
12
|
+
readonly tokenMessaging: Address;
|
|
13
|
+
readonly endpoint: Address;
|
|
14
|
+
readonly localDecimals: number;
|
|
15
|
+
readonly sharedDecimals: number;
|
|
16
|
+
readonly kind: "pool" | "oft" | "native";
|
|
17
|
+
readonly approvalRequired: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Source TokenMessaging peer evidence. Credits/fees/paused state must still be read live. */
|
|
20
|
+
interface StargatePath {
|
|
21
|
+
readonly source: string;
|
|
22
|
+
readonly destination: string;
|
|
23
|
+
}
|
|
24
|
+
interface StargateRegistry {
|
|
25
|
+
readonly deployments: readonly StargateDeployment[];
|
|
26
|
+
readonly paths: readonly StargatePath[];
|
|
27
|
+
find(chain: string, token: string): StargateDeployment | undefined;
|
|
28
|
+
route(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string): {
|
|
29
|
+
source: StargateDeployment;
|
|
30
|
+
destination: StargateDeployment;
|
|
31
|
+
} | undefined;
|
|
32
|
+
callTargets(chain: string): readonly Address[];
|
|
33
|
+
spenders(chain: string): readonly Address[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Builds immutable lookup/pin data from a reviewed static manifest. Token symbols
|
|
37
|
+
* are deliberately not resolved here: a symbol can name a different token in the
|
|
38
|
+
* app's catalog (USDC/USDC.e and USDT/USDT0 are not interchangeable).
|
|
39
|
+
*/
|
|
40
|
+
declare function createStargateRegistry(input: readonly StargateDeployment[], inputPaths: readonly StargatePath[]): StargateRegistry;
|
|
41
|
+
|
|
42
|
+
export { type StargateDeployment, type StargatePath, type StargateRegistry, createStargateRegistry };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
|
|
3
|
+
/** Reviewed deployment identity. Discovery metadata is never a runtime trust source. */
|
|
4
|
+
interface StargateDeployment {
|
|
5
|
+
readonly chain: string;
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly eid: number;
|
|
8
|
+
readonly assetId: number;
|
|
9
|
+
readonly symbol: string;
|
|
10
|
+
readonly token: Address;
|
|
11
|
+
readonly address: Address;
|
|
12
|
+
readonly tokenMessaging: Address;
|
|
13
|
+
readonly endpoint: Address;
|
|
14
|
+
readonly localDecimals: number;
|
|
15
|
+
readonly sharedDecimals: number;
|
|
16
|
+
readonly kind: "pool" | "oft" | "native";
|
|
17
|
+
readonly approvalRequired: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Source TokenMessaging peer evidence. Credits/fees/paused state must still be read live. */
|
|
20
|
+
interface StargatePath {
|
|
21
|
+
readonly source: string;
|
|
22
|
+
readonly destination: string;
|
|
23
|
+
}
|
|
24
|
+
interface StargateRegistry {
|
|
25
|
+
readonly deployments: readonly StargateDeployment[];
|
|
26
|
+
readonly paths: readonly StargatePath[];
|
|
27
|
+
find(chain: string, token: string): StargateDeployment | undefined;
|
|
28
|
+
route(sourceChain: string, sourceToken: string, destinationChain: string, destinationToken: string): {
|
|
29
|
+
source: StargateDeployment;
|
|
30
|
+
destination: StargateDeployment;
|
|
31
|
+
} | undefined;
|
|
32
|
+
callTargets(chain: string): readonly Address[];
|
|
33
|
+
spenders(chain: string): readonly Address[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Builds immutable lookup/pin data from a reviewed static manifest. Token symbols
|
|
37
|
+
* are deliberately not resolved here: a symbol can name a different token in the
|
|
38
|
+
* app's catalog (USDC/USDC.e and USDT/USDT0 are not interchangeable).
|
|
39
|
+
*/
|
|
40
|
+
declare function createStargateRegistry(input: readonly StargateDeployment[], inputPaths: readonly StargatePath[]): StargateRegistry;
|
|
41
|
+
|
|
42
|
+
export { type StargateDeployment, type StargatePath, type StargateRegistry, createStargateRegistry };
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|