GIST
Atomic Swap is a decentralized, peer-to-peer (P2P) cross-chain bridge protocol that extends the 1inch Network’s Fusion+ system to enable secure, trustless token exchanges between Ethereum Sepolia and Sui Testnet. Built on Hashed Time-Locked Contracts (HTLCs) and integrated with 1inch resolvers, the protocol ensures atomic execution—swaps either complete fully for both parties or revert entirely, eliminating partial or failed transactions. As a major track sponsor, 1inch provides critical infrastructure, including its Fusion+ intent-based swap technology and resolver network, which Atomic Swap leverages to optimize cross-chain swap execution. Deployed on testnets, Atomic Swap serves as a developer-friendly proof-of-concept, with a modular architecture designed for scalability to mainnets and additional blockchains (e.g., Solana, Polygon, Aptos). By building on 1inch’s robust ecosystem, Atomic Swap enhances cross-chain interoperability while maintaining decentralization, security, and user sovereignty, addressing key challenges in Web3 asset transfers.
What Is Atomic Swap?
Atomic Swap is a protocol that enables trustless P2P token exchanges between Ethereum Sepolia (EVM-based) and Sui Testnet (Move-based), expanding the capabilities of 1inch’s Fusion+ system. It uses HTLCs to enforce atomicity, ensuring swaps are all-or-nothing, and integrates 1inch resolvers—professional market makers who compete to execute swaps efficiently under 1inch’s intent-based architecture. This eliminates reliance on centralized bridges, custodians, or wrapped tokens, aligning with Web3’s ethos of decentralization. Currently deployed on testnets, Atomic Swap provides a low-risk environment for developers to test cross-chain functionality, particularly bridging Ethereum’s EVM and Sui’s Move-based ecosystems. By leveraging 1inch’s Fusion+ technology, which supports gasless, intent-based swaps and MEV protection, Atomic Swap enhances swap efficiency and security. The protocol’s modular design supports future expansion to mainnets and other chains, making it a scalable foundation for Web3 infrastructure. As a hackathon submission under the 1inch major track, Atomic Swap builds on 1inch’s resolver network to deliver a cutting-edge solution for cross-chain interoperability.
Core Features
- Trustless P2P Swaps: Direct token exchanges via HTLCs, eliminating intermediaries and custodial risks.
- Hashed Time-Locked Contracts (HTLCs): Cryptographic hashlocks and timelocks ensure atomic execution and secure fund locking.
- 1inch Resolver Integration: Leverages 1inch’s professional resolvers to execute swaps efficiently, benefiting from Fusion+’s intent-based mechanics and MEV protection.
- Cross-Chain Interoperability: Enables swaps between Ethereum Sepolia and Sui Testnet, bridging EVM and Move ecosystems.
- Atomic Execution: Guarantees all-or-nothing swaps, ensuring fairness and no fund loss.
- Self-Custody: Users retain full control of private keys and assets throughout the process.
- No Wrapped Tokens: Direct swaps eliminate intermediary assets, reducing complexity and vulnerabilities.
- Modular Architecture: Designed for scalability to additional chains (e.g., Solana, Polygon, Aptos).
- Developer-Friendly Testnet: Low-risk environment for testing cross-chain dApps.
- Privacy-Focused: No KYC or third-party data sharing; all logic is on-chain.
Integration with 1inch
As a project under the 1inch major track, Atomic Swap builds on 1inch’s Fusion+ technology, which revolutionizes cross-chain swaps with intent-based, gasless, and MEV-resistant execution. Key integrations include:
- 1inch Resolvers: Atomic Swap uses 1inch’s network of resolvers—professional market makers who compete to fill orders under a Dutch auction model. Resolvers execute swaps on behalf of users, optimizing rates and ensuring efficiency. By integrating with 1inch’s resolver system, Atomic Swap benefits from their expertise and infrastructure, enhancing swap execution across Sepolia and Sui Testnet.
- Fusion+ Intent-Based Architecture: 1inch’s Fusion+ allows users to define swap parameters off-chain, which resolvers execute on-chain. Atomic Swap extends this by incorporating HTLCs for cross-chain atomicity, ensuring secure and efficient swaps without relying on traditional bridges.
- MEV Protection: Inherited from Fusion+, Atomic Swap protects users from maximal extractable value (MEV) exploits, a critical feature for secure DeFi transactions.
- Gasless Execution: Leveraging 1inch’s gasless swap capabilities, Atomic Swap minimizes costs for users on testnets, with resolvers covering gas fees.
- Resolver Incentive Program: Atomic Swap aligns with 1inch’s incentive model, where resolvers are rewarded with 1INCH tokens for filling orders, encouraging participation and liquidity provision.
How It Works
Atomic Swap integrates 1inch resolvers with HTLCs to enable secure cross-chain swaps between Ethereum Sepolia and Sui Testnet. Below is the detailed process, using two users, Akshat (on Sepolia) and Kartik (on Sui Testnet), swapping testnet tokens (e.g., Sepolia ETH for Sui Testnet SUI):
- Secret Generation & Hashlock Setup: Akshat generates a cryptographic secret (e.g., a random string) and creates its hash using SHA-256. Akshat shares the hash with Kartik off-chain via a secure channel or the Atomic Swap dApp, which integrates with 1inch’s off-chain intent construction.
- Deploy HTLCs with 1inch Resolver Coordination: Akshat deploys an HTLC on Sepolia, locking his testnet ETH. The contract specifies: Hashlock (requires the secret matching the provided hash), Timelock (a deadline, e.g., 24 hours, for refunds if the swap fails), Recipient (Kartik’s Sepolia address). A 1inch resolver verifies Akshat’s HTLC deployment and coordinates the swap. Kartik deploys a corresponding HTLC on Sui Testnet, locking his testnet SUI with the same hashlock and a shorter timelock (e.g., 12 hours). The resolver ensures compatibility between the Sepolia and Sui HTLCs, leveraging 1inch’s Fusion+ intent-based framework.
- Deposits and Verification: Akshat’s ETH is locked in the Sepolia HTLC, visible on-chain. Kartik confirms the deposit via the dApp or testnet explorer and locks his SUI in the Sui HTLC. The 1inch resolver monitors both contracts to ensure funds are correctly escrowed, using 1inch’s API for real-time data.
- Reveal & Redeem with Resolver Execution: Akshat redeems Kartik’s SUI on Sui Testnet by submitting the secret to the Sui HTLC, unlocking the funds. The secret is revealed on-chain, and the 1inch resolver retrieves it (e.g., via Sui’s event logs or 1inch’s API). The resolver uses the secret to unlock Akshat’s ETH on Sepolia for Kartik, completing the swap. 1inch’s Dutch auction mechanics ensure the resolver executes the swap at the most favorable rate.
- Guaranteed Atomicity: If Akshat fails to reveal the secret within the Sui timelock, Kartik’s SUI is refunded. If Kartik (or the resolver) fails to claim the ETH within the Sepolia timelock, Akshat’s ETH is refunded. The resolver’s role ensures timely execution, reducing the risk of timelock expirations.
Technical Architecture
- Blockchains: Ethereum Sepolia (EVM-based testnet for Solidity HTLCs), Sui Testnet (Move-based testnet for Move HTLCs).
- Smart Contracts: Sepolia HTLC (Solidity-based, handles escrow, hashlock, and timelock logic), Sui HTLC (Move-based, optimized for Sui’s object-oriented model), Integrated with 1inch’s Fusion+ contracts (e.g., Settlement and RouterV6) for resolver execution.
- Frontend: React-based dApp with Web3.js (Ethereum) and Sui Wallet Kit (Sui) for wallet integration. Interfaces with 1inch’s API for resolver coordination and swap monitoring.
- Backend: Node.js for off-chain tasks (e.g., secret sharing, resolver notifications). Relies on 1inch’s API for real-time swap data and resolver management.
- 1inch Integration: Uses 1inch’s Fusion+ intent-based architecture for gasless swaps and MEV protection. Leverages 1inch’s resolver network for swap execution, with resolvers competing to fill orders. Incorporates 1inch’s Pathfinder algorithm to optimize swap routes, even across testnets.
- Security: HTLCs use SHA-256 for hashlocks. Timelocks prevent indefinite fund locking. Inherits 1inch’s audited contract security and MEV protection. Post-hackathon audits planned for mainnet readiness.
Problem Statement
Cross-chain asset transfers face significant challenges:
- Centralized Bridges: Most bridges (e.g., Wormhole) rely on custodians, introducing hack risks ($2B+ lost in 2022-2023).
- Counterparty Risk: P2P swaps require trust, risking scams or non-delivery.
- Wrapped Tokens: Bridges mint wrapped assets, adding complexity and vulnerabilities.
- Testnet Gaps: Developers lack robust testnet environments for EVM-Move interoperability.
- Costs and Complexity: High gas fees and complex UX deter users and developers.
- Security Vulnerabilities: Outdated protocols (e.g., 1inch’s Fusion v1) have exposed resolvers to exploits.
Atomic Swap, built on 1inch’s Fusion+, addresses these by:
- Using HTLCs for trustless, atomic swaps.
- Leveraging 1inch resolvers for efficient, MEV-protected execution.
- Eliminating wrapped tokens and intermediaries.
- Providing a testnet playground for EVM-Move experimentation.
- Inheriting 1inch’s gasless and secure swap infrastructure.
Solution & Benefits
Atomic Swap extends 1inch’s Fusion+ to deliver a decentralized, secure, and efficient cross-chain swap solution:
- Decentralized Bridging: HTLCs and 1inch resolvers replace centralized bridges.
- Trustless Execution: Atomicity ensures no counterparty risk.
- 1inch Resolver Optimization: Resolvers compete to execute swaps at optimal rates, leveraging 1inch’s Dutch auction model.
- Gasless Testnet Swaps: Resolvers cover gas fees, making testnet swaps cost-free.
- EVM-Move Interoperability: Bridges two distinct ecosystems, fostering innovation.
- Privacy: No KYC; all logic is on-chain.
- Scalability: Modular design for multi-chain expansion.
Impact & Use Cases
- Developers: Test EVM-Move dApps using 1inch’s resolver network.
- Web3 Enthusiasts: Experiment with trustless swaps in a safe testnet environment.
- Protocol Builders: Use Atomic Swap as a foundation for mainnet bridges or DeFi protocols.
- 1inch Ecosystem: Enhances 1inch’s cross-chain capabilities, aligning with its vision to unite DeFi ecosystems.
Example: A developer can use Atomic Swap to test a cross-chain DEX, leveraging 1inch resolvers to optimize swap execution across Sepolia and Sui Testnet.
Why Atomic Swap Stands Out
- 1inch Integration: Builds on 1inch’s Fusion+ and resolver network for secure, efficient swaps.
- EVM-Move Bridge: Pioneers interoperability between Ethereum and Sui.
- Atomicity: HTLCs ensure trustless, secure swaps.
- Testnet Focus: Developer-friendly environment for innovation.
- Scalability: Ready for multi-chain expansion.
- Alignment with 1inch: Enhances 1inch’s mission as a major track sponsor to advance DeFi interoperability.
How Atomic Swap (Testnet Edition) Was Made
Building Atomic Swap, a decentralized P2P cross-chain bridge for Ethereum Sepolia and Sui Testnet, was a wild ride full of challenges and victories. As a hackathon project under the 1inch major track, we set out to extend 1inch’s Fusion+ system with Hashed Time-Locked Contracts (HTLCs) to enable trustless, gasless, and MEV-protected cross-chain swaps. We hit major roadblocks—failed contract deployments, test cases that wouldn’t pass, and complex integrations with 1inch’s resolver network. But through relentless late-night coding, a focus on quality, and a clutch performance by our teammate Kartik, we delivered a solid prototype we’re proud of. Here’s the raw story of how we made it happen.
The Vision
Our goal was to build a trustless cross-chain bridge using 1inch’s Fusion+ intent-based architecture and resolver network to swap tokens between Sepolia (EVM-based) and Sui Testnet (Move-based). We aimed to eliminate centralized bridge risks, ensure atomic execution with HTLCs, and create a developer-friendly testnet environment. Early on, we realized supporting multiple chains could lead to a half-baked product, so we focused on perfecting Sepolia ↔ Sui Testnet to deliver a polished, scalable solution.
The Build Process
Step 1: Designing the Core
We started by organizing the protocols/ folder, splitting logic into two components:
- ethereum_side/ (Solidity-based):
- AtomicVault: Locks assets with cryptographic commitments for secure swaps.
- InterchainOrderBook: Coordinates cross-chain trades, syncing Sepolia with Sui Testnet.
- PriceDiscoveryEngine: Handles dynamic pricing via Dutch auctions, optimized with 1inch Fusion+ mechanics.
- ValidatorNetwork: Manages decentralized validators for trustless consensus.
- Crypto/security libraries: Uses SHA-256 hash commitments and timelock guards for robust security.
- sui_side/ (Move-based):
- interchain_vault_protocol: Core vault logic for locking assets on Sui.
- cryptographic_proof: Verifies commitments for trustless execution.
- temporal_validation: Enforces time-based security with timelocks.
- bilateral_swap_examples: Sample scripts for P2P swap flows.
We also built applications/, including a React-based dApp (using Wagmi and RainbowKit for wallet integration) and a CLI demo for testing, plus a toolkit/ with SDKs for integration and state verification. The plan was solid, but execution was tough.
The Challenges
Contract Deployment Issues
Deploying HTLCs on Sepolia and Sui Testnet was a nightmare. Solidity contracts for AtomicVault failed due to gas limit errors and syntax issues. On Sui, Move’s object-oriented model caused compilation errors in interchain_vault_protocol. We spent hours debugging, tweaking gas estimates, and rewriting code to match each chain’s requirements.
Test Case Struggles
Our initial test cases for InterchainOrderBook and PriceDiscoveryEngine missed edge cases like timelock expirations and invalid secret hashes, leading to failures. On Sui, temporal_validation didn’t handle refunds properly, breaking tests. We rewrote test suites, simulating cross-chain scenarios to ensure atomicity, often working late into the night.
1inch Resolver Integration Challenges
Integrating with 1inch’s resolver network was our biggest hurdle. Setting up the Fusion+ intent-based system required syncing HTLCs with 1inch’s API and resolvers—market makers executing swaps via Dutch auctions. Misaligned parameters and resolver authentication errors caused repeated failures. Kartik took charge, diving into 1inch’s docs, tweaking API calls, and testing resolver interactions until we nailed gasless, MEV-protected execution.
Strategic Focus: Quality Over Quantity
We initially considered supporting multiple chains (e.g., Solana Devnet, Polygon Mumbai) but realized deployment and test case issues could derail us. Instead, we focused solely on Sepolia ↔ Sui Testnet, ensuring robust features like trustless swaps and 1inch resolver integration. This pivot let us deliver a polished product with a clear path for future expansion.
The Grind
The hackathon was a blur of sleepless nights, debugging contract errors, and stress-testing our dApp. The atomic-swap-dapp/ had to be user-friendly yet robust, integrating Web3.js (Ethereum) and Sui Wallet Kit (Sui) while syncing with 1inch’s resolver network. The atomic-swap-demo/ CLI tool was crucial for rapid testing, helping us catch bugs on the fly. Every failure pushed us to iterate faster.
Kartik’s Breakthrough
The 1inch resolver integration was a beast. Fusion+’s complexity and cross-chain HTLC coordination were daunting. Kartik dove into 1inch’s API and Fusion+ docs, restructuring resolver calls to align with the Dutch auction model and ensure MEV protection. When our first test swap—Sepolia ETH for Sui SUI—executed successfully with a resolver filling the order, we knew we’d made it. Kartik’s persistence was a game-changer.
What We Delivered
Despite the chaos, we shipped:
- Core Protocols: Functional HTLCs on Sepolia and Sui Testnet, integrated with 1inch’s Fusion+ and resolver network for secure, gasless swaps.
- Applications: A React dApp for user-friendly swaps and a CLI demo for developers.
- Toolkit: SDKs for testing and verifying cross-chain states.
- Documentation: A detailed README.md on IPFS, outlining architecture and setup.
Focusing on one chain gave us a polished prototype with atomic swaps, 1inch resolver optimization, and a testnet-ready environment.
Lessons Learned
- Prioritize Quality: Focusing on one chain ensured robust functionality.
- Embrace the Grind: Late nights and debugging paid off.
- Leverage 1inch: Fusion+ and resolvers were critical but required deep integration.
- Test Early: Failed test cases taught us to prioritize edge cases.
- Teamwork: Kartik’s resolver work and our team’s hustle turned setbacks into success.