AI Dex is an intelligent, multi-model agent designed for the QuickNode Hackathon. It provides users with the ability to create, manage, and swap cryptocurrency assets directly through an interactive chatbot interface powered by advanced language models. The project leverages the power of the Coinbase SDK and the Odos DEX aggregator to enable seamless wallet interactions and token swaps.
Ensure you have Python 3 installed. If not, download and install it from python.org.
-
Install
virtualenv
if you haven't already:pip3 install virtualenv
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
- On Unix or MacOS:
source venv/bin/activate
- On Windows:
venv\Scripts\activate
- On Unix or MacOS:
-
Install the required packages:
pip install -r requirements.txt
Note: If you don't have a
requirements.txt
file, you can install the packages individually:pip install cdp-sdk langchain langchain-openai python-dotenv openai
-
Run the project:
python main.py
- LangChain: Used for building advanced conversational AI.
- Coinbase SDK: Provides wallet functionalities and enables ERC-20 token interactions.
- Odos DEX Aggregator: Used for fetching token swap quotes and executing swaps.
- The chatbot interacts with users to create an AI-powered wallet using the Coinbase SDK.
- The wallet can receive ERC-20 tokens, and users can check their balance at any time.
- Users can inquire about the tokens held within their wallet via the chatbot.
- The user initiates a swap by specifying the asset they want to swap (asset A) for another asset (asset B).
- The bot checks the user's wallet balance to ensure there are sufficient funds for the swap.
- The bot calls the Odos DEX aggregator's API to get a quote for the swap.
- The bot presents the swap quote to the user in the chat.
- The user confirms or declines the quote.
- If approved, the bot executes the swap using the Odos API.
- The bot returns the swap metadata to the user once the transaction is complete.
- The user begins by chatting with the bot.
- The bot guides the user through wallet creation and funding.
- The user can check their wallet balance and request a token swap.
- The bot verifies funds, fetches a swap quote from Odos, and presents it.
- The user approves or denies the swap.
- Successful swaps return complete metadata to the user for confirmation.
- Integrate a frontend to facilitate real-time chat interactions.
- Enhance the user experience by adding swap history tracking and notifications.
- Bot: "Howdy, do you want to create a wallet?"
- User: "Yes"
- Bot: (Calls `create_wallet` and returns the wallet address)
- Bot: "Do you want to fund the wallet?"
- User: "Yes {sends USDC}"
- User: "Check Balance"
- Bot: "Nice, your wallet is funded."
- Bot: "Would you like to make a swap?"
- User: "Yes, swap my USDC for Base/Ether."
- Bot: "Great, I'm on it."
- Bot: (Makes an API call to Odos to get a quote for a USDC to Base Ether swap)
- Bot: "Here's your swap quote: {quote}. Do you want to perform this swap?"
- User: "Yes"
- Bot: (Makes an API call to Odos to execute the swap)
- Bot: (Returns swap metadata)