Skip to content

buct2012dbl/RACE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ RACE Protocol

RWA-Powered Autonomous Commerce Engine

License: MIT Node.js Version Python Version Solidity Next.js NestJS Hardhat TypeScript

A fully autonomous AI agent network that transforms Real World Assets (RWA) into on-chain productive capital, driving automated DeFi commerce activities.

Features β€’ Architecture β€’ Quick Start β€’ Documentation


🎯 Overview

RACE Protocol is a cutting-edge decentralized platform that bridges traditional finance with DeFi through intelligent automation. By tokenizing Real World Assets and deploying AI-powered autonomous agents, RACE enables:

  • Automated Asset Management: AI agents manage RWA-backed portfolios 24/7
  • Risk-Optimized Trading: Machine learning models assess market conditions and execute strategies
  • Multi-Chain Operations: Seamless deployment across Ethereum, Arc, and Monad networks
  • Transparent Governance: On-chain decision tracking and revenue distribution

✨ Key Features

πŸ€– Autonomous AI Agents

  • ERC-6551 Token-Bound Accounts: Each agent is a smart contract wallet with independent decision-making
  • Multi-Model Intelligence: Powered by GPT-4o and Claude 3.5 Sonnet for diverse strategy execution
  • LangChain Integration: Advanced reasoning chains for complex DeFi operations
  • Real-time Market Analysis: Continuous monitoring and adaptive strategy adjustment

🏦 RWA Tokenization

  • Vault System: Secure collateralization of real-world assets
  • Oracle Integration: Multi-source price feeds for accurate asset valuation
  • Liquidation Protection: Automated risk management and position monitoring
  • Revenue Distribution: Fair profit sharing among stakeholders

πŸ”— Multi-Chain Support

  • Ethereum Mainnet: Production-ready deployment
  • Arc Testnet: High-performance testing environment
  • Monad Testnet: Next-gen blockchain compatibility

πŸ“Š Professional Dashboard

  • Newsprint Design System: Clean, newspaper-inspired UI with Playfair Display typography
  • Real-time Monitoring: Live agent performance metrics and portfolio tracking
  • Multi-User Management: Configure and monitor multiple AI agents simultaneously
  • Automation Controls: Fine-tune agent behavior and risk parameters

πŸ—οΈ Architecture

race-protocol/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ contracts/          # Smart Contracts (Solidity)
β”‚   β”‚   β”œβ”€β”€ AIAgent.sol            # ERC-6551 autonomous agent
β”‚   β”‚   β”œβ”€β”€ RWAVault.sol           # Asset tokenization vault
β”‚   β”‚   β”œβ”€β”€ RiskManager.sol        # Liquidation protection
β”‚   β”‚   β”œβ”€β”€ OracleAggregator.sol   # Multi-oracle price feeds
β”‚   β”‚   β”œβ”€β”€ RevenueManager.sol     # Profit distribution
β”‚   β”‚   β”œβ”€β”€ LendingPool.sol        # DeFi lending integration
β”‚   β”‚   └── SimpleDEX.sol          # Decentralized exchange
β”‚   β”‚
β”‚   β”œβ”€β”€ frontend/           # Next.js 14 Web Application
β”‚   β”‚   β”œβ”€β”€ App Router              # Modern Next.js routing
β”‚   β”‚   β”œβ”€β”€ Wagmi v2 + Viem         # Multi-chain wallet connection
β”‚   β”‚   β”œβ”€β”€ RainbowKit v2           # Beautiful wallet UI
β”‚   β”‚   β”œβ”€β”€ Tailwind CSS 3          # Utility-first styling
β”‚   β”‚   β”œβ”€β”€ Recharts                # Data visualization
β”‚   β”‚   └── Jotai + TanStack Query  # State management
β”‚   β”‚
β”‚   β”œβ”€β”€ backend/            # NestJS API Server
β”‚   β”‚   β”œβ”€β”€ REST API                # Agent orchestration endpoints
β”‚   β”‚   β”œβ”€β”€ Swagger Docs            # Auto-generated API documentation
β”‚   β”‚   β”œβ”€β”€ Ethers.js v6            # Blockchain interaction
β”‚   β”‚   └── Class Validator         # Request validation
β”‚   β”‚
β”‚   └── ai-agents/          # Python AI Decision Engine
β”‚       β”œβ”€β”€ LangChain               # AI reasoning framework
β”‚       β”œβ”€β”€ OpenAI GPT-4o           # Primary decision model
β”‚       β”œβ”€β”€ Anthropic Claude 3.5    # Secondary analysis model
β”‚       └── Market Analyzers        # Trading strategy modules

πŸš€ Quick Start

Prerequisites

Node.js Python npm

Installation

# Clone the repository
git clone https://github.com/yourusername/race-protocol.git
cd race-protocol

# Install all dependencies
npm install

# Setup Python environment for AI agents
cd packages/ai-agents
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cd ../..

Environment Configuration

Create .env files in each package:

packages/contracts/.env

PRIVATE_KEY=your_wallet_private_key
ETHERSCAN_API_KEY=your_etherscan_key
ARC_RPC_URL=https://arc-testnet-rpc.example.com
MONAD_RPC_URL=https://monad-testnet-rpc.example.com

packages/frontend/.env.local

NEXT_PUBLIC_RWA_VAULT_ADDRESS=0x...
NEXT_PUBLIC_AI_AGENT_ADDRESS=0x...
NEXT_PUBLIC_RISK_MANAGER_ADDRESS=0x...
NEXT_PUBLIC_USDC_ADDRESS=0x...
NEXT_PUBLIC_API_URL=http://localhost:5000

packages/backend/.env

PORT=5000
RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your-key
CONTRACT_ADDRESS=0x...

packages/ai-agents/.env

OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your-key

Development

# Run all services concurrently (requires Turbo)
npm run dev

# Or run services individually:

# Terminal 1: Frontend (http://localhost:3000)
npm run frontend:dev

# Terminal 2: Backend API (http://localhost:5000)
npm run backend:dev

# Terminal 3: AI Agents
npm run ai:dev

# Terminal 4: Compile & deploy contracts
npm run contracts:compile
npm run contracts:deploy

πŸ“¦ Packages

πŸ” Smart Contracts (packages/contracts)

Solidity Hardhat OpenZeppelin

Core Contracts:

  • AIAgent.sol (22KB): ERC-6551 token-bound account with autonomous trading capabilities
  • RWAVault.sol (7KB): Collateral management and asset tokenization
  • RiskManager.sol (6.6KB): Liquidation protection and health factor monitoring
  • OracleAggregator.sol (4.7KB): Multi-source price feed aggregation
  • RevenueManager.sol (4.5KB): Automated profit distribution
  • LendingPool.sol (7.7KB): DeFi lending protocol integration
  • SimpleDEX.sol (9.6KB): Decentralized exchange for asset swaps

Commands:

cd packages/contracts
npm run compile          # Compile contracts
npm run test            # Run test suite
npm run deploy          # Deploy to local network
npm run deploy:arc      # Deploy to Arc Testnet
npm run deploy:monad    # Deploy to Monad Testnet

🎨 Frontend (packages/frontend)

Next.js React TypeScript Tailwind

Tech Stack:

  • Framework: Next.js 14 with App Router
  • Blockchain: Wagmi v2 + Viem v2 + RainbowKit v2
  • Styling: Tailwind CSS 3 with custom Newsprint design system
  • State: Jotai (atomic state) + TanStack Query v5 (server state)
  • Charts: Recharts with custom styling
  • Icons: Lucide React
  • Animations: Framer Motion

Design System:

  • Typography: Playfair Display (headlines), Lora (body), Inter (UI), JetBrains Mono (code)
  • Colors: Newsprint palette (#F9F9F7 bg, #111111 ink, #CC0000 accent)
  • Layout: Zero border-radius, dot-grid backgrounds, hard shadows

Commands:

cd packages/frontend
npm run dev      # Start dev server (localhost:3000)
npm run build    # Production build
npm run start    # Start production server
npm run lint     # ESLint check

βš™οΈ Backend (packages/backend)

NestJS TypeScript Swagger

Features:

  • RESTful API for agent orchestration
  • Swagger/OpenAPI documentation
  • Ethers.js v6 for blockchain interaction
  • Class-validator for request validation
  • Modular architecture with dependency injection

API Endpoints:

  • GET /api/agents - List all AI agents
  • POST /api/agents - Create new agent
  • GET /api/agents/:id - Get agent details
  • POST /api/agents/:id/execute - Execute trading strategy
  • GET /api/market/prices - Fetch current market prices
  • GET /api/portfolio/:address - Get portfolio stats

Commands:

cd packages/backend
npm run start:dev    # Development mode with hot reload
npm run start:prod   # Production mode
npm run build        # Build for production
npm run test         # Run tests

🧠 AI Agents (packages/ai-agents)

Python LangChain OpenAI

AI Models:

  • GPT-4o: Primary decision-making and strategy generation
  • Claude 3.5 Sonnet: Risk analysis and market sentiment
  • LangChain: Reasoning chains and tool orchestration

Capabilities:

  • Market trend analysis and prediction
  • Risk assessment and portfolio optimization
  • Automated trading strategy execution
  • Multi-agent coordination
  • Real-time decision logging

Commands:

cd packages/ai-agents
source venv/bin/activate
python -m src.main              # Start AI agent service
python -m src.backtest          # Run strategy backtesting
python -m pytest tests/         # Run test suite

🌐 Supported Networks

Network Chain ID Status RPC URL
Ethereum Mainnet 1 βœ… Production https://eth-mainnet.g.alchemy.com
Arc Testnet 1234 πŸ§ͺ Testing https://arc-testnet-rpc.example.com
Monad Testnet 5678 πŸ§ͺ Testing https://monad-testnet-rpc.example.com

πŸ› οΈ Technology Stack

Frontend

Next.js React TypeScript Tailwind Wagmi RainbowKit

Backend

NestJS Node.js TypeScript Ethers.js

Smart Contracts

Solidity Hardhat OpenZeppelin

AI/ML

Python LangChain OpenAI Anthropic

πŸ“š Documentation

  • Smart Contracts: See packages/contracts/README.md for contract documentation
  • API Reference: Visit http://localhost:5000/api/docs when backend is running
  • Frontend Components: Check packages/frontend/src/components/ for UI documentation
  • AI Agents: Read packages/ai-agents/docs/ for strategy documentation

πŸ§ͺ Testing

# Run all tests
npm run test

# Test specific packages
npm run contracts:test    # Smart contract tests
cd packages/frontend && npm run test    # Frontend tests
cd packages/backend && npm run test     # Backend tests
cd packages/ai-agents && pytest         # AI agent tests

🚒 Deployment

Smart Contracts

# Deploy to Arc Testnet
npm run contracts:deploy:arc

# Deploy to Monad Testnet
npm run contracts:deploy:monad

# Verify contracts
cd packages/contracts
npx hardhat verify --network arc <CONTRACT_ADDRESS>

Frontend

cd packages/frontend
npm run build
# Deploy to Vercel, Netlify, or your preferred hosting

Backend

cd packages/backend
npm run build
npm run start:prod
# Deploy to AWS, GCP, or your preferred cloud provider

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links


Built with ❀️ by the RACE Protocol Team

GitHub stars Twitter Follow

About

A fully autonomous AI agent network that transforms Real World Assets (RWA) into on-chain productive capital, driving automated DeFi commerce activities.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors