@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.
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 @@
1
+ {"version":3,"sources":["../src/compose-dex.ts","../src/compose.ts","../src/rpc.ts"],"sourcesContent":["import {decodeAbiParameters, decodeFunctionData, encodeFunctionData, getAddress, keccak256, parseAbi, slice, toHex, zeroAddress, type Hex, type PublicClient} from \"viem\";\nimport {LIFI_COMPOSE_PAYLOAD, LIFI_ETHEREUM_COMPOSER, type LifiStargateComposeProof} from \"./compose.js\";\nimport {assertStargate, sameAddress} from \"./rpc.js\";\n\nexport const COMPOSE_UNOSWAP_ABI = parseAbi([\"function unoswap2(uint256 token, uint256 amount, uint256 minReturn, uint256 dex, uint256 dex2) returns (uint256)\"]);\nexport const COMPOSE_POOL_ABI = parseAbi([\n \"function token0() view returns (address)\", \"function token1() view returns (address)\",\n \"function fee() view returns (uint24)\",\n \"function getPool(address tokenA, address tokenB, uint24 fee) view returns (address)\",\n]);\nexport const COMPOSE_DEX_PINS = Object.freeze({\n router: \"0x111111125421cA6dc452d289314280a0f8842A65\" as Hex,\n routerCodeHash: \"0xa5a286be4b80006cc547d7e899871aa01a0e0551e2a509233375405f92098c2f\" as Hex,\n factory: \"0x1F98431c8aD98523631AE4a59f267346ea31F984\" as Hex,\n factoryCodeHash: \"0x4d7b8525cd5d14343fa67a732fba5b24cddba11620ca88392f4ec6c52f91fd69\" as Hex,\n /** Observed four-byte suffix; its ownership/meaning is not an authorization signal. */\n calldataSuffix: \"2a94d114\",\n});\nexport const UNOSWAP_FLAGS = Object.freeze({V3: 1n << 253n, NO_WRAP: 1n << 251n, ZERO_FOR_ONE: 1n << 247n});\nconst ADDRESS = (1n << 160n) - 1n, {V3, NO_WRAP, ZERO_FOR_ONE} = UNOSWAP_FLAGS;\n\n/** Exactly two canonical Uniswap V3 pools from `input` to `output`, as read at `blockNumber`. */\nexport async function unoswap2V3Path(client: PublicClient, blockNumber: bigint, input: Hex, words: readonly [bigint, bigint], output: Hex) {\n let current = input;\n const pools: Hex[] = [], fees: number[] = [], tokens: Hex[] = [input];\n for (const encoded of words) {\n assertStargate((encoded >> 253n) === 1n && (encoded & ~(ADDRESS | V3 | NO_WRAP | ZERO_FOR_ONE)) === 0n, \"unsupported compose DEX flags\");\n const address = getAddress(toHex(encoded & ADDRESS, {size: 20}));\n const at = {address, abi: COMPOSE_POOL_ABI, blockNumber};\n const [token0, token1, fee] = await Promise.all([\n client.readContract({...at, functionName: \"token0\"}), client.readContract({...at, functionName: \"token1\"}), client.readContract({...at, functionName: \"fee\"}),\n ]);\n const canonical = await client.readContract({address: COMPOSE_DEX_PINS.factory, abi: COMPOSE_POOL_ABI, functionName: \"getPool\", args: [token0, token1, fee], blockNumber});\n assertStargate(sameAddress(canonical, address) && address !== zeroAddress && !sameAddress(token0, token1), \"unreviewed compose DEX pool\");\n const forward = (encoded & ZERO_FOR_ONE) !== 0n;\n assertStargate(sameAddress(current, forward ? token0 : token1), \"compose DEX path input mismatch\");\n current = forward ? token1 : token0;\n pools.push(address); fees.push(fee); tokens.push(current);\n }\n assertStargate(sameAddress(current, output), \"compose DEX path output mismatch\");\n return Object.freeze({pools: Object.freeze(pools), fees: Object.freeze(fees), tokens: Object.freeze(tokens)});\n}\n\n/**\n * Checks a narrow DEX operation independently of LI.FI discovery: one unoswap2\n * call, exactly two canonical Uniswap V3 pools, ERC20 in/out, no Permit2,\n * unwrapping, arbitrary target, native value or alternate recipient.\n * This is not a price quote or permission to sign. The caller must use finalized\n * RPC evidence; executable compose routes/retries are not wired into swap2 yet.\n */\nexport async function validateLifiUnoswap2Compose(p: LifiStargateComposeProof, client: PublicClient, blockNumber: bigint) {\n assertStargate(await client.getChainId() === 1 && p.bridge.intent.destination.chain === \"eip155:1\", \"wrong compose DEX chain\");\n const block = await client.getBlock({blockNumber});\n assertStargate(block.hash, \"compose DEX block unavailable\");\n const pins = COMPOSE_DEX_PINS;\n for (const [address, expectedHash] of [\n [pins.router, pins.routerCodeHash], [pins.factory, pins.factoryCodeHash],\n [LIFI_ETHEREUM_COMPOSER.receiver, LIFI_ETHEREUM_COMPOSER.receiverCodeHash],\n [LIFI_ETHEREUM_COMPOSER.executor, LIFI_ETHEREUM_COMPOSER.executorCodeHash],\n ] as const) {\n const code = await client.getCode({address, blockNumber});\n assertStargate(code && keccak256(code) === expectedHash, \"compose DEX bytecode mismatch\");\n }\n assertStargate(keccak256(p.message) === p.messageHash, \"changed compose message\");\n const [transactionId, swaps, recipient] = decodeAbiParameters(LIFI_COMPOSE_PAYLOAD, slice(p.message, 76));\n assertStargate(swaps.length === 1 && sameAddress(transactionId, p.transactionId) && sameAddress(recipient, p.recipient), \"compose DEX action mismatch\");\n const swap = swaps[0]!;\n assertStargate(sameAddress(swap.callTo, pins.router) && sameAddress(swap.approveTo, pins.router) && swap.requiresDeposit && swap.fromAmount > 0n && swap.fromAmount <= p.bridge.amount && swap.fromAmount === p.swap.fromAmount, \"unsupported compose DEX target or amount\");\n assertStargate(sameAddress(swap.sendingAssetId, p.bridge.intent.destination.token) && sameAddress(swap.receivingAssetId, p.finalToken) && swap.sendingAssetId !== zeroAddress && p.finalToken !== zeroAddress, \"unsupported compose DEX assets\");\n const call = decodeFunctionData({abi: COMPOSE_UNOSWAP_ABI, data: swap.callData});\n const [token, amount, minimum, dex, dex2] = call.args;\n // The pinned router's unoswap2 -> _unoswapTo2 -> _unoswapV3 path uses\n // decoded arguments, never trailing msg.data. Accept only the canonical\n // call or the exact four-byte suffix observed in our real receipt fixture.\n const canonicalCall = encodeFunctionData({abi: COMPOSE_UNOSWAP_ABI, functionName: \"unoswap2\", args: call.args}).toLowerCase();\n assertStargate([canonicalCall, canonicalCall + pins.calldataSuffix].includes(swap.callData.toLowerCase()), \"noncanonical compose DEX calldata\");\n assertStargate(token > 0n && token <= ADDRESS && sameAddress(toHex(token, {size: 20}), swap.sendingAssetId) && amount === swap.fromAmount && minimum > 0n && minimum >= p.minimum, \"compose DEX input or minimum mismatch\");\n const {pools} = await unoswap2V3Path(client, blockNumber, swap.sendingAssetId, [dex, dex2], p.finalToken);\n assertStargate((await client.getBlock({blockNumber})).hash === block.hash, \"compose DEX block changed\");\n return Object.freeze({adapter: \"lifi-ethereum-unoswap2-v3\" as const, amount, minimum, finalToken: p.finalToken, recipient: p.recipient, pools, blockNumber, blockHash: block.hash, executionSupported: false as const});\n}\n","import {decodeAbiParameters, encodeAbiParameters, encodePacked, keccak256, pad, parseAbi, parseAbiParameters, parseEventLogs, zeroAddress, type Address, type Hex, type TransactionReceipt} from \"viem\";\nimport type {StargateIntent} from \"./intent.js\";\nimport {assertStargate, nonzeroAddress, sameAddress} from \"./rpc.js\";\nimport {checkStargateReceipt, stargateComposedTaxiProof, stargateTaxiPayout, type StargateTaxiProof} from \"./tracking.js\";\n\nexport const COMPOSE_ABI = parseAbi([\n \"function composeQueue(address from, address to, bytes32 guid, uint16 index) view returns (bytes32)\",\n \"function lzCompose(address from, address to, bytes32 guid, uint16 index, bytes message, bytes extraData) payable\",\n \"event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message)\",\n \"event ComposeDelivered(address from, address to, bytes32 guid, uint16 index)\",\n]);\nexport const LIFI_COMPOSE_ABI = parseAbi([\n \"function executor() view returns (address)\",\n \"function endpointV2() view returns (address)\",\n \"function tokenMessaging() view returns (address)\",\n \"function recoverGas() view returns (uint256)\",\n \"event LiFiTransferCompleted(bytes32 indexed transactionId, address receivingAssetId, address receiver, uint256 amount, uint256 timestamp)\",\n \"event LiFiTransferRecovered(bytes32 indexed transactionId, address receivingAssetId, address receiver, uint256 amount, uint256 timestamp)\",\n \"event AssetSwapped(bytes32 transactionId, address dex, address fromAssetId, address toAssetId, uint256 fromAmount, uint256 toAmount, uint256 timestamp)\",\n \"event Transfer(address indexed from, address indexed to, uint256 value)\",\n]);\nexport const LIFI_COMPOSE_PAYLOAD = parseAbiParameters(\"bytes32 transactionId, (address callTo, address approveTo, address sendingAssetId, address receivingAssetId, uint256 fromAmount, bytes callData, bool requiresDeposit)[] swaps, address receiver\");\n\n/** Observational pins only; these addresses are NOT a call/spender allowlist. */\nexport const LIFI_ETHEREUM_COMPOSER = Object.freeze({\n chain: \"eip155:1\",\n receiver: \"0xB539B40793171211DCA8834da044fC14bCe64BDC\" as Address,\n executor: \"0xd9B2Da9C45b118e4e93A004FB1452bCDB6cC0E88\" as Address,\n receiverCodeHash: \"0x535b6e74e5bbb38e9a469de60ff2587cf498b92a99be01f34d20c37a77e4cea2\" as Hex,\n executorCodeHash: \"0xf937f13890d789171f0bcf3c558a64869105000b6771dc182ddc165bde92ddfe\" as Hex,\n});\n\nexport interface StargateComposeExpectation {\n /** Bridge recipient must be the pinned composer; sender is the actual OFTSent actor. */\n bridge: StargateIntent;\n composeFrom: Address;\n composeMsg: Hex;\n recipient: Address;\n finalToken: Address;\n minimum: bigint;\n}\nexport interface LifiStargateComposeProof {\n readonly bridge: StargateTaxiProof;\n readonly transactionId: Hex;\n readonly message: Hex;\n readonly messageHash: Hex;\n readonly recipient: Address;\n readonly finalToken: Address;\n readonly minimum: bigint;\n readonly swap: {readonly callTo: Address; readonly fromAmount: bigint};\n /** True only for routes this SDK encoded and checked before signing (`compose-route`); historical proofs are evidence only. */\n readonly executionSupported: boolean;\n}\n\nexport {stargateComposeOptions} from \"./quote.js\";\n\n/** Zero is absent; ONE is consumed (unlike cleared inboundPayloadHash for lzReceive). */\nexport function stargateComposeQueueState(messageHash: Hex, queue: Hex): \"absent\" | \"consumed\" | \"pending\" | \"mismatch\" {\n assertStargate(/^0x[0-9a-f]{64}$/i.test(messageHash) && /^0x[0-9a-f]{64}$/i.test(queue), \"invalid compose commitment\");\n if (BigInt(queue) === 0n) return \"absent\";\n if (BigInt(queue) === 1n) return \"consumed\";\n return sameAddress(messageHash, queue) ? \"pending\" : \"mismatch\";\n}\n\n/**\n * Read-only single-swap LI.FI adapter. Receipts/code must first be obtained from\n * canonical finalized blocks on their respective chains. Consistency is checked\n * here; untrusted JSON supplied by a remote server is not independent RPC evidence.\n */\nexport function proveLifiStargateCompose(expected: StargateComposeExpectation, source: TransactionReceipt, delivery: TransactionReceipt, code: {receiver: Hex; executor: Hex}): LifiStargateComposeProof {\n const pins = LIFI_ETHEREUM_COMPOSER, i = expected.bridge;\n assertStargate(i.destination.chain === pins.chain && sameAddress(i.recipient, pins.receiver), \"unreviewed composer\");\n assertStargate(keccak256(code.receiver) === pins.receiverCodeHash && keccak256(code.executor) === pins.executorCodeHash, \"composer bytecode changed\");\n assertStargate(nonzeroAddress(expected.recipient) && /^0x[0-9a-f]{40}$/i.test(expected.finalToken) && typeof expected.minimum === \"bigint\" && expected.minimum > 0n && expected.minimum < (1n << 256n), \"invalid final action\");\n for (const receipt of [source, delivery]) checkStargateReceipt(receipt, receipt.transactionHash, receipt.blockHash);\n const bridge = stargateComposedTaxiProof(i, source, expected.composeFrom, expected.composeMsg);\n const [transactionId, swaps, recipient] = decodeAbiParameters(LIFI_COMPOSE_PAYLOAD, expected.composeMsg);\n assertStargate(encodeAbiParameters(LIFI_COMPOSE_PAYLOAD, [transactionId, swaps, recipient]).toLowerCase() === expected.composeMsg.toLowerCase(), \"noncanonical compose message\");\n assertStargate(BigInt(transactionId) !== 0n && swaps.length === 1 && sameAddress(recipient, expected.recipient), \"unsupported compose action or recipient\");\n const swap = swaps[0]!;\n assertStargate(nonzeroAddress(swap.callTo) && nonzeroAddress(swap.approveTo) && swap.fromAmount > 0n && swap.fromAmount <= bridge.amount && sameAddress(swap.sendingAssetId, i.destination.token) && sameAddress(swap.receivingAssetId, expected.finalToken) && !sameAddress(swap.sendingAssetId, swap.receivingAssetId), \"compose asset or amount mismatch\");\n assertStargate(stargateTaxiPayout(bridge, delivery), \"bridge has not paid the composer\");\n const message = encodePacked([\"uint64\", \"uint32\", \"uint256\", \"bytes32\", \"bytes\"], [bridge.nonce, i.source.eid, bridge.amount, pad(expected.composeFrom, {size: 32}), expected.composeMsg]);\n const sent = parseEventLogs({abi: COMPOSE_ABI, eventName: \"ComposeSent\", logs: delivery.logs.filter((l) => sameAddress(l.address, i.destination.endpoint)), strict: true})\n .filter((l) => sameAddress(l.args.guid, bridge.guid));\n assertStargate(sent.length === 1 && sameAddress(sent[0]!.args.from, i.destination.address) && sameAddress(sent[0]!.args.to, pins.receiver) && sent[0]!.args.index === 0 && sameAddress(sent[0]!.args.message, message), \"compose queue message mismatch\");\n const intent = Object.freeze({...i, source: Object.freeze({...i.source}), destination: Object.freeze({...i.destination})});\n return Object.freeze({bridge: Object.freeze({...bridge, intent}), transactionId, message, messageHash: keccak256(message), recipient, finalToken: expected.finalToken, minimum: expected.minimum, swap: Object.freeze({callTo: swap.callTo, fromAmount: swap.fromAmount}), executionSupported: false as boolean});\n}\n\nexport type StargateComposeOutcome =\n | {state: \"unverified\"}\n | {state: \"completed\"; token: Address; amount: bigint; transactionHash: Hex}\n | {state: \"intermediate-refunded\"; token: Address; amount: bigint; transactionHash: Hex};\n\n/** Final token payment is separate from successful Endpoint compose delivery. */\nexport function lifiStargateComposeOutcome(p: LifiStargateComposeProof, receipt: TransactionReceipt): StargateComposeOutcome {\n const unknown = {state: \"unverified\"} as const;\n try {\n if (receipt.status !== \"success\") return unknown;\n checkStargateReceipt(receipt, receipt.transactionHash, receipt.blockHash);\n const pins = LIFI_ETHEREUM_COMPOSER, d = p.bridge.intent.destination;\n const delivered = parseEventLogs({abi: COMPOSE_ABI, eventName: \"ComposeDelivered\", logs: receipt.logs.filter((l) => sameAddress(l.address, d.endpoint)), strict: true});\n // Refuse batched attribution until every compose invocation can be delimited.\n if (delivered.length !== 1) return unknown;\n const end = delivered[0]!;\n 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;\n const recovered = 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));\n const completed = 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));\n function paid(token: Address, from: Address, before: number): bigint {\n const transfers = parseEventLogs({abi: LIFI_COMPOSE_ABI, eventName: \"Transfer\", logs: receipt.logs.filter((l) => sameAddress(l.address, token) && l.logIndex! < before), strict: true});\n let net = 0n;\n for (const {args} of transfers) {\n if (sameAddress(args.to, p.recipient) && sameAddress(args.from, from)) net += args.value;\n if (sameAddress(args.from, p.recipient)) net -= args.value;\n }\n return net;\n }\n if (recovered.length === 1 && completed.length === 0) {\n const event = recovered[0]!;\n if (event.logIndex! >= end.logIndex! || !sameAddress(event.args.receivingAssetId, d.token) || !sameAddress(event.args.receiver, p.recipient) || event.args.amount !== p.bridge.amount) return unknown;\n // Native payout is proven by the pinned receiver's event after safeTransferETH.\n if (d.token !== zeroAddress && paid(d.token, pins.receiver, event.logIndex!) !== p.bridge.amount) return unknown;\n return {state: \"intermediate-refunded\", token: d.token, amount: p.bridge.amount, transactionHash: receipt.transactionHash};\n }\n if (completed.length !== 1 || recovered.length !== 0 || p.finalToken === zeroAddress) return unknown;\n const event = completed[0]!;\n if (event.logIndex! >= end.logIndex! || !sameAddress(event.args.receiver, p.recipient) || !sameAddress(event.args.receivingAssetId, d.token)) return unknown;\n const swaps = 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));\n if (swaps.length !== 1) return unknown;\n const swap = swaps[0]!;\n 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;\n // Executor's Completed event names the INPUT asset and may report a gross balance.\n // Count actual final-token transfers instead of trusting those two fields.\n const amount = paid(p.finalToken, pins.executor, event.logIndex!);\n if (amount < p.minimum || amount !== swap.args.toAmount) return unknown;\n return {state: \"completed\", token: p.finalToken, amount, transactionHash: receipt.transactionHash};\n } catch { return unknown; }\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;AAAA;AAAA;AAAA,IAAAA,eAAmK;;;ACAnK,IAAAC,eAAiM;;;ACAjM,kBAA2G;AAIpG,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C,YAAY,SAAiB;AAAE,UAAM,aAAa,OAAO,EAAE;AAAG,SAAK,OAAO;AAAA,EAAqB;AACjG;AAeA,IAAM,mBAAe,sBAAS,CAAC,4CAA4C,sCAAsC,CAAC;AAC3G,IAAM,cAAc,CAAC,GAAW,MAAuB,EAAE,YAAY,MAAM,EAAE,YAAY;AACzF,SAAS,eAAe,WAAoB,SAAoC;AACrF,MAAI,CAAC,UAAW,OAAM,IAAI,kBAAkB,OAAO;AACrD;;;ADpBO,IAAM,kBAAc,uBAAS;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACM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,cAAc,UAAU,MAAM,WAAW,EAAE,SAAS,uCAAuC;AAC1N,QAAM,EAAC,MAAK,IAAI,MAAM,eAAe,QAAQ,aAAa,KAAK,gBAAgB,CAAC,KAAK,IAAI,GAAG,EAAE,UAAU;AACxG,kBAAgB,MAAM,OAAO,SAAS,EAAC,YAAW,CAAC,GAAG,SAAS,MAAM,MAAM,2BAA2B;AACtG,SAAO,OAAO,OAAO,EAAC,SAAS,6BAAsC,QAAQ,SAAS,YAAY,EAAE,YAAY,WAAW,EAAE,WAAW,OAAO,aAAa,WAAW,MAAM,MAAM,oBAAoB,MAAc,CAAC;AACxN;","names":["import_viem","import_viem"]}
@@ -0,0 +1,113 @@
1
+ import { Hex, PublicClient } from 'viem';
2
+ import { LifiStargateComposeProof } from './compose.cjs';
3
+ import './bus-Cdw8iwOv.cjs';
4
+ import './quote-r1bA8XbO.cjs';
5
+ import './registry.cjs';
6
+ import './tracking.cjs';
7
+ import '@anywalletkit/protocol-swap2-core/types';
8
+
9
+ declare const COMPOSE_UNOSWAP_ABI: readonly [{
10
+ readonly name: "unoswap2";
11
+ readonly type: "function";
12
+ readonly stateMutability: "nonpayable";
13
+ readonly inputs: readonly [{
14
+ readonly type: "uint256";
15
+ readonly name: "token";
16
+ }, {
17
+ readonly type: "uint256";
18
+ readonly name: "amount";
19
+ }, {
20
+ readonly type: "uint256";
21
+ readonly name: "minReturn";
22
+ }, {
23
+ readonly type: "uint256";
24
+ readonly name: "dex";
25
+ }, {
26
+ readonly type: "uint256";
27
+ readonly name: "dex2";
28
+ }];
29
+ readonly outputs: readonly [{
30
+ readonly type: "uint256";
31
+ }];
32
+ }];
33
+ declare const COMPOSE_POOL_ABI: readonly [{
34
+ readonly name: "token0";
35
+ readonly type: "function";
36
+ readonly stateMutability: "view";
37
+ readonly inputs: readonly [];
38
+ readonly outputs: readonly [{
39
+ readonly type: "address";
40
+ }];
41
+ }, {
42
+ readonly name: "token1";
43
+ readonly type: "function";
44
+ readonly stateMutability: "view";
45
+ readonly inputs: readonly [];
46
+ readonly outputs: readonly [{
47
+ readonly type: "address";
48
+ }];
49
+ }, {
50
+ readonly name: "fee";
51
+ readonly type: "function";
52
+ readonly stateMutability: "view";
53
+ readonly inputs: readonly [];
54
+ readonly outputs: readonly [{
55
+ readonly type: "uint24";
56
+ }];
57
+ }, {
58
+ readonly name: "getPool";
59
+ readonly type: "function";
60
+ readonly stateMutability: "view";
61
+ readonly inputs: readonly [{
62
+ readonly type: "address";
63
+ readonly name: "tokenA";
64
+ }, {
65
+ readonly type: "address";
66
+ readonly name: "tokenB";
67
+ }, {
68
+ readonly type: "uint24";
69
+ readonly name: "fee";
70
+ }];
71
+ readonly outputs: readonly [{
72
+ readonly type: "address";
73
+ }];
74
+ }];
75
+ declare const COMPOSE_DEX_PINS: Readonly<{
76
+ router: Hex;
77
+ routerCodeHash: Hex;
78
+ factory: Hex;
79
+ factoryCodeHash: Hex;
80
+ /** Observed four-byte suffix; its ownership/meaning is not an authorization signal. */
81
+ calldataSuffix: "2a94d114";
82
+ }>;
83
+ declare const UNOSWAP_FLAGS: Readonly<{
84
+ V3: bigint;
85
+ NO_WRAP: bigint;
86
+ ZERO_FOR_ONE: bigint;
87
+ }>;
88
+ /** Exactly two canonical Uniswap V3 pools from `input` to `output`, as read at `blockNumber`. */
89
+ declare function unoswap2V3Path(client: PublicClient, blockNumber: bigint, input: Hex, words: readonly [bigint, bigint], output: Hex): Promise<Readonly<{
90
+ pools: readonly `0x${string}`[];
91
+ fees: readonly number[];
92
+ tokens: readonly `0x${string}`[];
93
+ }>>;
94
+ /**
95
+ * Checks a narrow DEX operation independently of LI.FI discovery: one unoswap2
96
+ * call, exactly two canonical Uniswap V3 pools, ERC20 in/out, no Permit2,
97
+ * unwrapping, arbitrary target, native value or alternate recipient.
98
+ * This is not a price quote or permission to sign. The caller must use finalized
99
+ * RPC evidence; executable compose routes/retries are not wired into swap2 yet.
100
+ */
101
+ declare function validateLifiUnoswap2Compose(p: LifiStargateComposeProof, client: PublicClient, blockNumber: bigint): Promise<Readonly<{
102
+ adapter: "lifi-ethereum-unoswap2-v3";
103
+ amount: bigint;
104
+ minimum: bigint;
105
+ finalToken: `0x${string}`;
106
+ recipient: `0x${string}`;
107
+ pools: readonly `0x${string}`[];
108
+ blockNumber: bigint;
109
+ blockHash: `0x${string}`;
110
+ executionSupported: false;
111
+ }>>;
112
+
113
+ export { COMPOSE_DEX_PINS, COMPOSE_POOL_ABI, COMPOSE_UNOSWAP_ABI, UNOSWAP_FLAGS, unoswap2V3Path, validateLifiUnoswap2Compose };
@@ -0,0 +1,113 @@
1
+ import { Hex, PublicClient } from 'viem';
2
+ import { LifiStargateComposeProof } from './compose.js';
3
+ import './bus-vAWqTAkq.js';
4
+ import './quote-t7UJSxbU.js';
5
+ import './registry.js';
6
+ import './tracking.js';
7
+ import '@anywalletkit/protocol-swap2-core/types';
8
+
9
+ declare const COMPOSE_UNOSWAP_ABI: readonly [{
10
+ readonly name: "unoswap2";
11
+ readonly type: "function";
12
+ readonly stateMutability: "nonpayable";
13
+ readonly inputs: readonly [{
14
+ readonly type: "uint256";
15
+ readonly name: "token";
16
+ }, {
17
+ readonly type: "uint256";
18
+ readonly name: "amount";
19
+ }, {
20
+ readonly type: "uint256";
21
+ readonly name: "minReturn";
22
+ }, {
23
+ readonly type: "uint256";
24
+ readonly name: "dex";
25
+ }, {
26
+ readonly type: "uint256";
27
+ readonly name: "dex2";
28
+ }];
29
+ readonly outputs: readonly [{
30
+ readonly type: "uint256";
31
+ }];
32
+ }];
33
+ declare const COMPOSE_POOL_ABI: readonly [{
34
+ readonly name: "token0";
35
+ readonly type: "function";
36
+ readonly stateMutability: "view";
37
+ readonly inputs: readonly [];
38
+ readonly outputs: readonly [{
39
+ readonly type: "address";
40
+ }];
41
+ }, {
42
+ readonly name: "token1";
43
+ readonly type: "function";
44
+ readonly stateMutability: "view";
45
+ readonly inputs: readonly [];
46
+ readonly outputs: readonly [{
47
+ readonly type: "address";
48
+ }];
49
+ }, {
50
+ readonly name: "fee";
51
+ readonly type: "function";
52
+ readonly stateMutability: "view";
53
+ readonly inputs: readonly [];
54
+ readonly outputs: readonly [{
55
+ readonly type: "uint24";
56
+ }];
57
+ }, {
58
+ readonly name: "getPool";
59
+ readonly type: "function";
60
+ readonly stateMutability: "view";
61
+ readonly inputs: readonly [{
62
+ readonly type: "address";
63
+ readonly name: "tokenA";
64
+ }, {
65
+ readonly type: "address";
66
+ readonly name: "tokenB";
67
+ }, {
68
+ readonly type: "uint24";
69
+ readonly name: "fee";
70
+ }];
71
+ readonly outputs: readonly [{
72
+ readonly type: "address";
73
+ }];
74
+ }];
75
+ declare const COMPOSE_DEX_PINS: Readonly<{
76
+ router: Hex;
77
+ routerCodeHash: Hex;
78
+ factory: Hex;
79
+ factoryCodeHash: Hex;
80
+ /** Observed four-byte suffix; its ownership/meaning is not an authorization signal. */
81
+ calldataSuffix: "2a94d114";
82
+ }>;
83
+ declare const UNOSWAP_FLAGS: Readonly<{
84
+ V3: bigint;
85
+ NO_WRAP: bigint;
86
+ ZERO_FOR_ONE: bigint;
87
+ }>;
88
+ /** Exactly two canonical Uniswap V3 pools from `input` to `output`, as read at `blockNumber`. */
89
+ declare function unoswap2V3Path(client: PublicClient, blockNumber: bigint, input: Hex, words: readonly [bigint, bigint], output: Hex): Promise<Readonly<{
90
+ pools: readonly `0x${string}`[];
91
+ fees: readonly number[];
92
+ tokens: readonly `0x${string}`[];
93
+ }>>;
94
+ /**
95
+ * Checks a narrow DEX operation independently of LI.FI discovery: one unoswap2
96
+ * call, exactly two canonical Uniswap V3 pools, ERC20 in/out, no Permit2,
97
+ * unwrapping, arbitrary target, native value or alternate recipient.
98
+ * This is not a price quote or permission to sign. The caller must use finalized
99
+ * RPC evidence; executable compose routes/retries are not wired into swap2 yet.
100
+ */
101
+ declare function validateLifiUnoswap2Compose(p: LifiStargateComposeProof, client: PublicClient, blockNumber: bigint): Promise<Readonly<{
102
+ adapter: "lifi-ethereum-unoswap2-v3";
103
+ amount: bigint;
104
+ minimum: bigint;
105
+ finalToken: `0x${string}`;
106
+ recipient: `0x${string}`;
107
+ pools: readonly `0x${string}`[];
108
+ blockNumber: bigint;
109
+ blockHash: `0x${string}`;
110
+ executionSupported: false;
111
+ }>>;
112
+
113
+ export { COMPOSE_DEX_PINS, COMPOSE_POOL_ABI, COMPOSE_UNOSWAP_ABI, UNOSWAP_FLAGS, unoswap2V3Path, validateLifiUnoswap2Compose };
@@ -0,0 +1,25 @@
1
+ import {
2
+ COMPOSE_DEX_PINS,
3
+ COMPOSE_POOL_ABI,
4
+ COMPOSE_UNOSWAP_ABI,
5
+ UNOSWAP_FLAGS,
6
+ unoswap2V3Path,
7
+ validateLifiUnoswap2Compose
8
+ } from "./chunk-PJXDMVW3.js";
9
+ import "./chunk-N54YIG6T.js";
10
+ import "./chunk-3NTMZUAU.js";
11
+ import "./chunk-4IDDRIE2.js";
12
+ import "./chunk-ERC6LKMN.js";
13
+ import "./chunk-EANM3EI3.js";
14
+ import "./chunk-4HU46QF2.js";
15
+ import "./chunk-QNVTQEOV.js";
16
+ import "./chunk-OUGUX3JK.js";
17
+ export {
18
+ COMPOSE_DEX_PINS,
19
+ COMPOSE_POOL_ABI,
20
+ COMPOSE_UNOSWAP_ABI,
21
+ UNOSWAP_FLAGS,
22
+ unoswap2V3Path,
23
+ validateLifiUnoswap2Compose
24
+ };
25
+ //# sourceMappingURL=compose-dex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}