Prompt Fusion Swap

An AI-powered DeFi terminal to execute swaps via natural language, using multiple 1inch APIs

Prompt Fusion Swap

Created At

Unite Defi

Project Description

Prompt Fusion Swap is a dApp designed to dramatically simplify the DeFi trading experience. It merges a real-time portfolio dashboard with an AI-powered command interface, allowing users to manage assets and execute trades as easily as talking to an assistant. The core problem this project solves is the complexity of typical swap interfaces, which can be intimidating for new users and inefficient for experienced traders. Our application provides a clean, intuitive dashboard where users can instantly see their asset allocation after connecting their wallet. The main feature is the AI Command Bar; instead of filling out forms, users can simply type commands like "swap 0.1 WETH for USDC". The system then parses this intent, fetches the best quote, and presents a clear confirmation before the user signs the transaction. This project heavily utilizes the 1inch developer suite to provide a comprehensive experience, integrating the 1inch Swap API for trade execution, the 1inch Balance API for real-time wallet balances, the 1inch Spot Price API for accurate asset valuation, and the 1inch Token API for rich metadata like token logos and names.

How it's Made

This project is a full-stack dApp built with Next.js (App Router) and TypeScript. The frontend, which handles the user interface and wallet interactions, is built with React and styled using shadcn/ui and Tailwind CSS. Wallet connectivity is managed by wagmi and Viem, providing a seamless and secure connection to the user's MetaMask wallet. The core logic resides in two main areas. First, the portfolio dashboard, which uses several 1inch APIs to provide a comprehensive view of user assets. Our backend, running on Next.js API Routes, calls the 1inch Balance API (getWalletBalances) to fetch all token balances, the 1inch Spot Price API (getTokensPrices) to get their USD values, and the 1inch Token API (getTokensInfo) to retrieve metadata like logos and decimals. Second, the AI-powered swap functionality. When a user enters a command, the frontend sends the text to our backend. The backend then uses the Gemini API's Function Calling feature to parse the natural language prompt into a structured JSON object. This object contains the exact parameters needed to execute a trade, such as the source token, destination token, and amount. Using this structured data, the backend then orchestrates a series of calls to the 1inch Swap API: getSwapQuote to find the best rate, checkAllowance and getApproveTransaction for token approvals if necessary, and finally getSwapTransactionData to prepare the transaction for the user to sign. This fusion of AI intent-parsing and the comprehensive 1inch API suite creates a powerful yet simple user experience.

background image mobile

Join the mailing list

Get the latest news and updates