ultron-swap

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

ultron-swap

Created At

ETHGlobal New Delhi

Project Description

💡 Ultron Swap — Description

Ultron 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.

🚩 Problem

Cross-chain swaps are either:

Manual: users handle multiple steps across bridges

Risky: funds rely on custodial middlemen

Inefficient: large trades cause high slippage or MEV front-runs

🚀 Ultron Swap’s Solution

Ultron 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 Intent

The 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 TWAP

Ultron’s AI engine analyzes:

Trade size

Liquidity depth on both chains

Pyth price volatility

Network congestion

Finality speeds

It 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 Hermes

Pushes 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 Settlement

Once accepted:

Resolver locks Maker’s ETH in an Ethereum escrow

Resolver locks equivalent TON in a TON escrow

Both escrows share a secret hash (like a password lock)

When both escrows are confirmed:

A relayer/watchtower releases the secret

Maker uses it to withdraw TON

Resolver uses it to withdraw ETH ✅ Atomic: both complete or neither does

If resolver fails → Maker’s ETH unlocks after timeout, and resolver’s safety deposit is slashed.

🔁 6. Repeat for Each Slice

AI’s schedule triggers the next slice automatically until the full swap is complete or expiry reached.

🧠 AI Adds Value

Decides slice count, size, interval

Selects best resolvers per slice

Reacts to volatility or congestion in real time

Optimizes 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)

How it's Made

🛠️ How We Built Ultron Swap

Ultron 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 Overview

We 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 Integration

Fetched 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 Bits

AI 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 RPCs

Ultron 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.

background image mobile

Join the mailing list

Get the latest news and updates