XFusion

XFusion powers seamless atomic swaps across chains — no bridges, no wraps, just pure fusion

XFusion

Created At

Unite Defi

Project Description

XFusion is a non-custodial protocol designed to facilitate direct, peer-to-peer trading of native assets across disparate blockchains. The project's core mission is to solve the critical security and centralization risks posed by traditional cross-chain bridges and wrapped tokens. By leveraging Hashed Timelock Contracts (HTLCs), XFusion enables true atomic swaps, ensuring that a trade either completes successfully on both chains or safely fails, returning all funds to their original owners. This creates a secure environment for users to exchange assets like native Bitcoin for native Ethereum without ever relinquishing custody of their keys or trusting a third-party intermediary with their funds.

The architecture is built upon a unique three-actor model that carefully separates roles to maintain decentralization and security. The first actor is the Maker (the user), who initiates a swap through the XFusion frontend. The second is the Relayer, a non-custodial backend service that functions as a central order book and coordination layer, matching Makers with liquidity providers. The third actor is the Resolver, a network of independent, chain-specific bots that monitor the Relayer, claim swap orders, and provide the liquidity to complete the other side of the trade. This separation ensures that while coordination is centralized for efficiency, the execution of the swap and the custody of funds remain completely decentralized.

The cryptographic foundation of XFusion's security is the Hashed Timelock Contract (HTLC). When a Maker initiates a swap, their client-side application generates a secret and a corresponding hashlock. This hashlock is used to lock funds on both the source and destination chains. The only way for the Resolver to claim the Maker's funds is to reveal the original secret, but they can only learn this secret after the Maker has used it to claim the funds the Resolver locked for them. This creates a cryptographic dependency that guarantees atomicity. If the swap is not completed within a predefined timelock period, both parties can safely refund their locked assets, ensuring no funds are ever lost.

The frontend application, built with Next.js and React, serves as the primary user gateway to the protocol. Its architecture is centered around comprehensive multi-wallet management, supporting a wide array of browser extensions like MetaMask, Unisat, Crossmark, and Plug. The frontend is responsible for all critical client-side operations: generating secrets, constructing chain-specific transaction payloads for HTLCs (such as Ethereum smart contract deployments or Bitcoin PSBTs), prompting the user to sign these transactions with their connected wallet, and communicating with the Relayer API to submit orders and monitor their status. It is designed to be a "thick client," handling all sensitive cryptographic operations locally to ensure user secrets never leave the browser.

Supporting this frontend is the off-chain infrastructure, consisting of the Relayer and the network of Resolvers. The Relayer, built on NestJS with a PostgreSQL database and Redis for real-time messaging, acts as the information hub. It validates and stores orders, but has no access to funds or secrets. The Resolvers are independent, profit-driven agents that subscribe to the Relayer's order book. Each Resolver specializes in a specific blockchain (e.g., a "BTC Resolver," an "XRP Resolver") and is responsible for creating and funding the counter-party HTLCs. This creates a competitive, decentralized marketplace for liquidity, ensuring that user-initiated swaps are fulfilled efficiently and reliably by the an open network of participants.

How it's Made

The XFusion protocol is architected as a sophisticated, multi-component system designed for security, decentralization, and scalability. The core philosophy is a "thick client" approach, where the user-facing frontend handles all critical cryptographic operations, while a non-custodial backend Relayer acts purely as a communication and coordination hub. This deliberately separates concerns, ensuring that at no point does the central infrastructure have access to user funds or the secrets required to unlock them. The system is comprised of four key pillars: the Frontend Application, the Backend Relayer, the On-Chain Logic, and the off-chain Resolver network.

The frontend is a modern web application built with Next.js, React, and TypeScript, chosen for its robust performance, type safety, and rich user interface capabilities. Its primary responsibility is managing a complex, multi-wallet environment, interacting directly with browser extensions like MetaMask and Unisat via their injected APIs. Using powerful libraries such as ethers.js for Ethereum and bitcoinjs-lib for Bitcoin, the frontend constructs all chain-specific transactions locally. This includes generating cryptographic secrets using the Web Crypto API, creating hashlocks, and building complex transaction payloads like Partially Signed Bitcoin Transactions (PSBTs) for HTLCs or invoking smart contract functions on the EVM. This client-side architecture is the cornerstone of the protocol's security, guaranteeing that private keys and secrets never leave the user's machine.

At the heart of the off-chain infrastructure is the Relayer, a backend API built with the NestJS framework on Node.js. It functions as a stateless order book and event bus. Orders submitted by the frontend are validated and stored in a PostgreSQL database, with Redis Pub/Sub being used to broadcast new orders and status updates in real-time to all subscribed participants. The Relayer exposes a RESTful API, automatically documented with Swagger/OpenAPI, for order submission, querying, and progress tracking. Its role is strictly limited to coordination; it does not execute transactions, hold assets, or have any knowledge of the cryptographic secrets that secure the swaps, making it a highly resilient and non-custodial component.

The on-chain logic is the cryptographic foundation of the protocol, implemented using the native features of each supported blockchain. For Ethereum and EVM-compatible chains, this involves 1inch's Solidity smart contracts deployed via a factory pattern, which creates unique, immutable escrow contracts for each swap.

background image mobile

Join the mailing list

Get the latest news and updates