FusionpusAptos
captures the cross-chain capability, atomic swap tech, real-time matching, and 1inch integration
Problem Statement
Core Concept: Atomic Cross-Chain Swaps This project implements atomic swaps - a cryptographic protocol that allows two parties to exchange tokens across different blockchains without needing a trusted intermediary. The "atomic" aspect means the swap either completes fully for both parties or fails completely, preventing partial execution. Technical ArchitectureDual-Chain ImplementationEthereum Side: Smart contracts written in Solidity that handle EVM-compatible tokens Aptos Side: Smart contracts written in Move language that handle Aptos-native tokens Both chains implement identical atomic swap logic with blockchain-specific optimizationsEscrow System The project uses sophisticated escrow contracts: Source Escrow (EscrowSrc):Locks the maker's tokens on the source chain Releases tokens only when the correct secret is revealed Implements timelock for automatic refunds if swap failsDestination Escrow (EscrowDst):Holds tokens that the maker will receive on destination chain Uses the same secret hash for verification Allows withdrawal once secret is revealedHashlock & Timelock Mechanism Hashlock:Uses cryptographic hash functions (like SHA-256) to create a "lock" Only someone with the original secret can "unlock" the funds Both chains use the same secret hash, ensuring coordinationTimelock:Implements expiration timestamps Prevents funds from being locked forever Allows automatic refunds if the swap doesn't complete in timeHow It Works: Step-by-Step Flow Phase 1: Order Creation & Announcement typescript// User creates an order specifying:srcAmount: Amount to swap from source chainminDstAmount: Minimum acceptable amount on destination chainexpiresInSecs: Time limit for the swapsecretHash: Hash of a secret only the user knows Phase 2: Escrow DeploymentSource Escrow: User's tokens are locked on source chain (e.g., Ethereum) Destination Escrow: Resolver deposits matching tokens on destination chain (e.g., Aptos) Both escrows use the same secret hash as the unlock conditionPhase 3: Secret Revelation & CompletionUser reveals the secret to claim tokens from destination escrow This publicly exposes the secret on the destination blockchain Resolver uses the revealed secret to claim tokens from source escrow Swap completes atomically - both parties get their tokensPhase 4: Safety MechanismsIf user doesn't reveal secret before timelock expires:User gets refund from source escrow Resolver gets refund from destination escrowNo party can steal funds from the otherKey ComponentsWebSocket Relayer System typescript// Real-time order matching and event handling wsSdk.order.onOrder((data) => { console.log('received order event', data) })Facilitates real-time communication between chains Handles order matching and status updates Manages the coordination between Ethereum and Aptos sides1inch IntegrationBuilt as an extension to 1inch's existing Fusion+ infrastructure Leverages 1inch's liquidity and routing capabilities Uses 1inch's proven security and optimization frameworksMulti-Secret Support typescript// Generate multiple secrets for complex swaps const secrets = Array.from({ length: quote.presets[preset].secretsCount }).map(() => '0x' + randomBytes(32).toString('hex'))Supports partial fills and multiple resolver scenario Uses Merkle trees for efficient secret management Enables more complex swap scenariosSecurity Features Trustless DesignNo central authority controls the swaps Cryptographic guarantees prevent fund theft Automatic refund mechanisms protect all partiesRobust ValidationImmutable contract validation ensures correct escrow deployment Type safety through TypeScript and Move's type system Comprehensive error handling for edge casesSafety Deposits moveconst SAFETY_DEPOSIT_AMOUNT: u64 = 100000; // 0.001 APTResolvers must deposit safety amounts to participate Prevents spam and ensures resolver commitment Economic incentives align all parties' interestsReal-World Usage This enables scenarios like:DeFi Arbitrage: Traders can exploit price differences between Ethereum and Aptos DEXs Portfolio Rebalancing: Users can shift assets between ecosystems seamlessly Cross-Chain Liquidity: Provides liquidity bridges between isolated blockchain ecosystems Institutional Trading: Large trades across chains without centralized exchange risksWhy This Matters This project solves a fundamental problem in the multi-chain world: secure, trustless cross-chain value transfer. Unlike bridges that often have central points of failure or custody risks, atomic swaps provide mathematical guarantees that funds cannot be stolen, only delayed or refunded.
Solution
Core Blockchain Technologies Ethereum/EVM Side:Solidity 0.8.23 - Smart contracts with advanced compiler optimizations OpenZeppelin - Battle-tested security primitives and utilities 1inch Limit Order Protocol - Leveraging existing DEX infrastructure Create2 Deterministic Deployment - Predictable escrow addresses across chainsAptos Side:Move Language - Type-safe smart contracts with resource ownership model Aptos Framework - Native coin handling and account management Generic Type System - Enables swaps for any coin type <SrcCoinType>Searched project for “technical implementation smart contracts Solidity Move blockchain technologies” 8 resultsNow I have much more detailed technical information about the project. 1sSearched project for “WebSocket API implementation Move language Aptos deployment testing” 4 resultsSynthesized project details for comprehensive technical explanation. 1sBased on the codebase analysis, here's the detailed technical breakdown of how this Ethereum ↔ Aptos Bridge project was built:Technology Stack & ArchitectureCore Blockchain Technologies Ethereum/EVM Side:Solidity 0.8.23 - Smart contracts with advanced compiler optimizations OpenZeppelin - Battle-tested security primitives and utilities 1inch Limit Order Protocol - Leveraging existing DEX infrastructure Create2 Deterministic Deployment - Predictable escrow addresses across chains Aptos Side:Move Language - Type-safe smart contracts with resource ownership model Aptos Framework - Native coin handling and account management Generic Type System - Enables swaps for any coin type <SrcCoinType> 2. Development & Testing Infrastructure Smart Contract Development:solidity // Uses Foundry/Forge for testing and deployment contract EscrowFactory is BaseEscrowFactory { constructor( address limitOrderProtocol, IERC20 feeToken, IERC20 accessToken, address owner, uint32 rescueDelaySrc, uint32 rescueDelayDst ) } Testing Framework:Foundry/Forge for Ethereum contract testing Aptos Move Testing with #[test_only] modules Integration tests with mock resolvers and real transaction flows WebSocket testing using Node.js with ws library 3. Novel Proxy-Based Escrow System Deterministic Address Generation:solidity // Clever use of Create2 for predictable addresses function computeProxyBytecodeHash(address implementation) internal pure returns (bytes32) { assembly ("memory-safe") { mstore(0x20, 0x5af43d82803e903d91602b57fd5bf3) mstore(0x11, implementation) mstore(0x00, or(shr(0x88, implementation), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) bytecodeHash := keccak256(0x09, 0x37) } } This is particularly hacky but brilliant - they're manually computing proxy bytecode hashes in assembly to enable deterministic escrow deployment across chains.Particularly Noteworthy "Hacky" ImplementationsAtomic Safety Deposit Mechanism solidity // Must send safety deposit to computed address BEFORE escrow exists (bool success,) = address(computed).call{ value: immutablesMem.safetyDeposit }(""); if (!success) revert IBaseEscrow.NativeTokenSendingFailure(); Why this is clever: They send ETH to an address that doesn't exist yet, knowing the escrow will be deployed to that exact address. This prevents race conditions and ensures atomic escrow funding.Multi-Secret Merkle Tree System typescript // Support for partial fills using Merkle proofs const hashLock = secrets.length === 1? HashLock.forSingleFill(secrets[0]): HashLock.forMultipleFills(HashLock.getMerkleLeaves(secrets)) Why this is sophisticated: Instead of simple single-secret swaps, they built a system supporting multiple secrets for partial fills, enabling market maker scenarios.Cross-Chain Type Safety move // Move's type system prevents runtime errors public entry fun announce_order<SrcCoinType>( maker: &signer, src_amount: u64, min_dst_amount: u64, expires_in_secs: u64, secret_hash: vector<u8> ) Move's resource model ensures coins can't be accidentally duplicated or lost - a significant advantage over Solidity's more permissive model.Real-Time WebSocket Coordination typescript // WebSocket handles cross-chain state synchronization wsSdk.order.onOrderSecretShared((data) => { // Automatically triggers completion on both chains resArray.push(data) }) Why this is necessary: Cross-chain swaps need real-time coordination. The WebSocket layer handles order matching, secret revelation events, and timeout management across both blockchains.Partner Technology Integration 1inch Fusion+ Integration Benefits gained:Existing liquidity - Tap into 1inch's DEX aggregation network Proven security - Leverage battle-tested order book infrastructure Gas optimization - Use 1inch's gas-efficient routing Resolver network - Access to professional market makersDeployment & Testing Strategy Testnet ImplementationEthereum Sepolia for EVM testing Aptos Testnet for Move contract testing Cross-chain integration tests with real secret revelation flowsMost Technically Impressive AspectsAssembly-optimized proxy deployment - Manual bytecode construction for gas efficiency Cross-chain type safety - Move's resource model prevents entire classes of bugs Deterministic addressing - Same escrow addresses computable on both chains Real-time cross-chain coordination - WebSocket layer handling complex state synchronization
Hackathon
ETHGlobal Unite
2025
Contributors
- ankiitagrwal
1 contributions