
Polaris
Trustless cross-chain swaps between Bitcoin, Lightning Network & EVM chains using HTLCs
Demo
About
# Description **Polaris** is a cross-chain swap protocol that extends the 1inch Fusion+ architecture to connect the Native Bitcoin and Lightning Network ecosystem with EVM-compatible blockchains. Built for ETHGlobal Unite 2025, it solves the critical problem of Bitcoin's isolation from DeFi liquidity networks. ## The Problem We Solve While 1inch Fusion+ enables trustless swaps between EVM chains and Solana, Bitcoin—holding over $1.9 trillion in value—remains mostly isolated. Users have to rely on centralized bridges with custody risks, high fees, and slow settlement times, or simply can't access cross-chain opportunities at all. ## Our Solution Polaris implements a trustless, intent-based swap protocol that treats Bitcoin's Lightning Network as a native HTLC (Hash Time-Locked Contract) system. By leveraging Lightning's HODL invoices and native Bitcoin scripting, we enable: - **Instant Bitcoin Swaps**: Sub-second settlements via Lightning Network instead of 60-minute Bitcoin confirmations - **True Atomic Swaps**: No bridges, no wrapped tokens—pure cryptographic guarantees ensure trustless execution - **Gasless UX**: Users only sign intents; professional resolvers handle all gas costs and execution - **Unified Liquidity**: Connects Bitcoin's massive liquidity to EVM ecosystems, improving rates and reducing slippage ## How It Works 1. **Users create swap intents** specifying source/destination assets and amounts 2. **Automated resolvers** monitor these intents and compete to fulfill them 3. **Smart contracts on EVM chains** lock funds using HTLCs with SHA256 hash locks 4. **Lightning invoices or Bitcoin scripts** create matching HTLCs on the Bitcoin side 5. **Atomic execution** ensures either both sides complete or neither does—no trust required ## Technical Innovation - **Lightning-as-HTLC**: First protocol to use Lightning HODL invoices as native HTLCs for cross-chain swaps - **Dual Bitcoin Support**: Handles both Lightning (instant) and on-chain Bitcoin (secure but slower) - **Intent-Based Architecture**: Users express desired outcomes; resolvers handle complex execution - **Opinionated UX/UI**: ¯\_(ツ)_/¯ Polaris demonstrates that Bitcoin doesn't need to remain isolated—with the right cryptographic primitives and architecture, it can participate fully in the cross-chain future of finance.
How it's made
# How it's made ## Core Technology Stack ### Frontend - **Next.js 15** with App Router for server-side rendering and optimal performance - **TypeScript** for type-safe development across the entire codebase - **Ethers.js v6** for Web3 interactions and wallet connections ### Backend & Infrastructure - **Next.js API Routes** for serverless backend endpoints - **Supabase** (PostgreSQL) for real-time order tracking and swap state management - **WebSocket connections** for live status updates ### Blockchain Integration - **Solidity 0.8.20** with Foundry framework for smart contract development - **OpenZeppelin** contracts for security primitives - **bitcoinjs-lib** for native Bitcoin transaction construction - **ln-service** for Lightning Network integration via LND ## Architectural Innovations ### 1. Dual Bitcoin Integration We implemented two parallel approaches for Bitcoin integration: **Lightning Network Path:** - Uses HODL invoices as native HTLCs - Leverages `ln-service` to communicate with LND nodes - Enables sub-second settlements - Perfect for smaller, time-sensitive swaps **Native Bitcoin Path:** - Custom P2SH HTLC scripts using `bitcoinjs-lib` - Direct on-chain settlements for larger amounts - Fallback option when Lightning liquidity is insufficient ### 2. Intent-Based Architecture To extend 1inch Fusion+, we built an intent system where: - Users express desired outcomes, not execution steps - Professional resolvers (will) compete to fulfill swaps - Smart contracts enforce atomic execution - State machine tracks 12 distinct swap states for reliability ### 3. Smart Contract Design ```solidity contract EVMHtlcEscrow { // Core HTLC functionality with SHA256 hash locks // 0.3% protocol fee for sustainability // Emergency withdrawal mechanisms // Multi-asset support (ETH, ERC20) } ``` ### 4. Unified Cross-Chain Abstraction ```typescript export enum ChainType { EVM = "evm", BITCOIN = "bitcoin", LIGHTNING = "lightning" } ``` This abstraction allows seamless addition of new chains while maintaining consistent swap logic. ## Partner Technology Integration ### 1inch Integration - **Fusion+ Architecture**: We studied and adapted their intent-based design - **Spot Price API**: Real-time pricing for accurate quotes - **Resolver Pattern**: Professional market makers can plug into our system ### Lightning Network - **LND Integration**: Direct node communication for invoice management - **HODL Invoices**: Revolutionary use as cross-chain HTLCs - **Payment Hash Coordination**: SHA256 hashes link Lightning to EVM ### Bitcoin Infrastructure - **Blockstream API**: UTXO management and transaction broadcasting - **Custom HTLC Scripts**: Native Bitcoin script engineering - **Fee Estimation**: Dynamic fee calculation for timely confirmations ## Notable Hacks & Innovations ### 1. Lightning-as-HTLC The biggest hack: treating Lightning HODL invoices as first-class HTLCs. By using the payment hash as the cross-chain secret, we achieve instant Bitcoin settlements without any protocol modifications. ### 2. Unified State Machine We built a comprehensive state machine that tracks swaps across blockchains: ```typescript CREATED → WAITING_FOR_DEPOSIT → DEPOSIT_DETECTED → HTLC_CREATED → HTLC_CLAIMED → COMPLETED ``` ### 3. Core Infrastructure for Development Created services for Lightning nodes and Bitcoin operations, allowing rapid development without real infrastructure. ### 4. Opinionated UI/UX Extensive Tailwind customization with: - Matrix rain animations - Holographic effects - Terminal-style components - ASCII art integration - All contributing to an immersive cross-chain experience ## Security Considerations - **Cryptographic Security**: SHA256 hash locks ensure atomic execution - **Timeout Protection**: Both sides have timeout mechanisms to reclaim funds - **No Custody Risk**: Users maintain control until atomic swap completes - **Auditable Events**: Comprehensive event logging for transparency ## Scalability Features - **Modular Architecture**: Easy to add new chains or assets - **Resolver Competition**: Market-driven efficiency - **Real-time Updates**: WebSocket connections for responsive UX - **Gas Optimization**: Batched operations where possible This project represents a fusion of Bitcoin's security, Lightning's speed, and Ethereum's programmability—demonstrating that trustless cross-chain swaps are not just possible, but can be elegant and user-friendly.