← Back to home

ultron-swap

AI-powered cross-chain swap protocol with smart TWAP execution and oracle pricing.

Problem Statement

💡 Ultron Swap — DescriptionUltron Swap is an AI-powered, intent-based cross-chain swap protocol inspired by 1inch Fusion+, built to make swaps across heterogeneous chains (starting with ETH ↔ TON) secure, fair, and automated.It combines Dutch auction price discovery, AI-driven TWAP slicing, oracle-verified fairness (Pyth), and HTLC atomic settlement to deliver trust-minimized cross-chain execution — no centralized bridges, no manual steps.🚩 ProblemCross-chain swaps are either:Manual: users handle multiple steps across bridgesRisky: funds rely on custodial middlemenInefficient: large trades cause high slippage or MEV front-runs🚀 Ultron Swap’s SolutionUltron Swap extends Fusion+ logic into a cross-chain environment and introduces AI and oracles to make swaps smarter, cheaper, and safer.It follows an intent-based flow, meaning the user signs what they want — not how — and the network executes optimally.⚙️ How It Works (Step-by-Step)🧩 1. Maker IntentThe user (Maker) signs an off-chain order:“Swap 1 ETH on Ethereum for TON worth ~$1800, min receive 1790 TON, within 15 minutes.”This “intent” is broadcast to resolvers — professional liquidity providers — for competition.⚔️ 2. Resolver Auction (Fusion+ style)A Dutch auction starts:Price starts slightly higher than fair market.Decreases over time until a resolver accepts.The winning resolver commits to filling the order.🧠 3. AI-Driven Cross-Chain TWAPUltron’s AI engine analyzes:Trade sizeLiquidity depth on both chainsPyth price volatilityNetwork congestionFinality speedsIt then splits the order into optimal slices (e.g., 5 × 0.2 ETH) and defines timing intervals to reduce slippage, MEV, and lockup risk. Each slice goes through its own mini-auction, possibly with different resolvers for best blended pricing.🔮 4. Oracle Verification (Pyth Pull Model)Before each slice executes:The system fetches ETH/USD & TON/USD price updates from Pyth HermesPushes them on-chain via updatePriceFeeds()Derives ETH/TON = (ETH/USD ÷ TON/USD)The resolver’s quoted rate is checked against the Pyth-derived fair value — if it deviates beyond a set threshold (e.g. ±2%), the slice is rejected.🔐 5. HTLC Atomic SettlementOnce accepted:Resolver locks Maker’s ETH in an Ethereum escrowResolver locks equivalent TON in a TON escrowBoth escrows share a secret hash (like a password lock)When both escrows are confirmed:A relayer/watchtower releases the secretMaker uses it to withdraw TONResolver uses it to withdraw ETH ✅ Atomic: both complete or neither doesIf resolver fails → Maker’s ETH unlocks after timeout, and resolver’s safety deposit is slashed.🔁 6. Repeat for Each SliceAI’s schedule triggers the next slice automatically until the full swap is complete or expiry reached.🧠 AI Adds ValueDecides slice count, size, intervalSelects best resolvers per sliceReacts to volatility or congestion in real timeOptimizes execution cost vs. risk🌟 Key Features🔄 Cross-chain TWAP execution powered by AI⚖️ Dutch auction competition for fair pricing🔮 Pyth oracle integration (pull model, real-time updates)🔐 HTLC atomic settlement (no bridge risk)🛡️ Safety deposits + timeouts ensure reliability🌐 Chain-agnostic design (ETH↔TON demo, scalable to others)

Solution

🛠️ How We Built Ultron SwapUltron Swap was built as an AI-powered evolution of 1inch Fusion+, extending it into a cross-chain swap protocol with TWAP automation, Pyth oracle integration, and HTLC-based atomic settlement. Our MVP focuses on ETH ↔ TON, but the system is chain-agnostic.⚙️ Architecture OverviewWe built everything using Node.js, integrating smart contracts, oracles, and AI logic through modular services:Frontend (Next.js + Wagmi + Ethers.js)Intent-based UI where users sign off-chain orders (swap amount, pair, slippage).Displays AI-generated TWAP plan (slices + timing) and Pyth fair price.Wallet support: MetaMask (EVM) & TonConnect (TON).AI Engine (Node.js Service)Lightweight planner that analyzes trade size, volatility, gas, and liquidity.Outputs optimal number of slices, size, and timing for TWAP execution.Adapts dynamically to conditions mid-trade (like high volatility or congestion).Smart Contracts (Solidity)IntentRegistry: Stores signed user intents.Auction: Runs Dutch auction (like 1inch Fusion+) for resolver bids.Escrow: Locks assets on both chains using HTLC secrets.OracleConsumer: Integrates Pyth pull model, updates via updatePriceFeeds, consumes getPrice() to derive ETH/TON = (ETH/USD ÷ TON/USD).SafetyModule: Manages resolver deposits + slashing on failure.Relayer / Watchtower (Node.js)Monitors both chains for escrow finality.Once both escrows confirmed → reveals shared secret for atomic unlock.Handles refunds on timeout and penalties for non-completion.🔮 Pyth Oracle IntegrationFetched live price updates from Pyth Hermes API (/v2/updates/price/latest).Updated feeds on-chain using updatePriceFeeds().Consumed ETH/USD and TON/USD prices with getPriceUnsafe(); derived ETH/TON on-chain.Validated resolver quotes within ±2% of oracle fair value → prevented unfair fills.✅ Partner Benefit: Pyth’s pull model made it easy to fetch + push price updates exactly when swaps execute — no stale data, no trust assumptions.🧠 Hacky / Creative BitsAI TWAP Planner: Custom AI module deciding slice count & schedule.On-chain Derived Pair: Computed ETH/TON from two Pyth feeds.Unified Relayer: Handles both finality check & secret reveal to simplify atomicity.🧱 Tech Stack Component Technology Frontend Next.js, Wagmi, Ethers.js, TonConnect Backend / AI Node.js Smart Contracts Solidity (EVM), Ton Solidity Oracle Pyth Network (Pull Model via Hermes) Infra Hardhat, Alchemy RPCsUltron Swap merges the proven intent + resolver model of 1inch Fusion+ with AI-driven TWAP and oracle-verified fairness — making cross-chain swaps smarter, safer, and fully automated.

Hackathon

ETHGlobal New Delhi

2025

Contributors