Skip to content

AI-Powered DeFi Portfolio Analysis & Token Swap Platform

Notifications You must be signed in to change notification settings

Modolo-oss/AuraMCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AURA MCP Server

AI-Powered DeFi Portfolio Analysis & Token Swap Platform

A production-ready REST API server that enables ChatGPT and AI assistants to interact with AURA API for real-time DeFi portfolio analysis, AI-powered strategy recommendations, and decentralized token swaps across 200+ blockchain networks.

Run on Replit

🌟 Features

πŸ”„ Token Swap (0x DEX Aggregation)

  • Multi-chain support: Ethereum, Base, Polygon, Arbitrum, Optimism, Base Sepolia
  • MetaMask browser wallet integration for secure transaction signing
  • 0x API DEX aggregation across 100+ liquidity sources
  • Guard Engine validation (slippage limits, gas caps)
  • Web-based swap interface at /swap
  • Real-time price quotes and route optimization

πŸ’Ό Portfolio Management (AURA API)

  • Real-time wallet balances across 200+ blockchain networks
  • Cross-chain DeFi position monitoring
  • USD value calculations with 9M+ token support
  • Native tokens and ERC-20 support

πŸ€– AI Strategy Recommendations (AURA API)

  • DCA Event-Aware: Dollar-cost averaging with market event detection
  • Liquidation Guard: Automated position protection strategies
  • Basket Rotation: Dynamic portfolio rebalancing
  • AI-powered strategy proposals based on portfolio analysis

πŸ›‘οΈ Guard Engine (Risk Management)

  • Configurable slippage limits and gas price caps
  • Swap quote validation before execution
  • Emergency stop capability
  • Per-user customizable safety rules

⚑ System Health Monitoring

  • Real-time server status and uptime tracking
  • Component health checks
  • API endpoint diagnostics

πŸš€ Quick Start

Prerequisites

Installation

# Clone repository
git clone https://github.com/aura-mcp/server.git
cd aura-mcp-server

# Install dependencies
npm install

# Configure environment secrets in Replit
# Add: AURA_API_KEY and ZEROEX_API_KEY

Development

# Start HTTP server (Replit)
npm run dev

# Build for production
npm run build

# Start production server
npm start

Server runs on Port 5000 (configured for Replit)

βš™οΈ Configuration

Required Environment Variables

# AURA API Configuration (Required)
AURA_API_KEY=your_aura_api_key_here

# 0x Swap API Configuration (Required for swap features)
ZEROEX_API_KEY=your_0x_api_key_here

# Optional Configuration
AURA_API_URL=https://aura.adex.network  # Default AURA API endpoint
PORT=5000                                 # Server port
NODE_ENV=production                       # Environment

πŸ“– Usage Examples

Token Swap (Browser Interface)

  1. Open /swap in your browser
  2. Connect MetaMask wallet
  3. Select network (Base, Ethereum, Polygon, etc.)
  4. Enter token addresses and amount
  5. Get quote and execute swap

Portfolio Analysis (API)

# Get wallet balance across all chains
curl -X POST http://localhost:5000/api/portfolio/balance \
  -H "Content-Type: application/json" \
  -d '{"address":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"}'

# Response: Portfolio with USD valuations across 200+ chains

Token Swap (API)

# Get supported networks
curl http://localhost:5000/api/swap/chains

# Prepare swap transaction (ETH β†’ USDC on Base)
curl -X POST http://localhost:5000/api/swap/prepare \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": 8453,
    "sellToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    "buyToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "sellAmount": "10000000000000000",
    "taker": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
  }'

# Response: Transaction data ready for MetaMask signing

AI Strategy Recommendations (API)

# Get DCA strategy proposal
curl -X POST http://localhost:5000/api/strategy/propose \
  -H "Content-Type: application/json" \
  -d '{
    "intent": "dca_event_aware",
    "params": {
      "asset": "ETH",
      "budgetUsd": 1000,
      "cadence": "weekly"
    },
    "address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
  }'

# Response: AI-powered strategy with AURA recommendations

Guard Engine Configuration

# Set risk management rules
curl -X POST http://localhost:5000/api/guard/setRules \
  -H "Content-Type: application/json" \
  -d '{
    "rules": {
      "risk": {
        "maxSlippagePct": 1.0,
        "maxGasGwei": 100
      }
    }
  }'

# Enable emergency stop
curl -X POST http://localhost:5000/api/guard/setEmergencyStop \
  -H "Content-Type: application/json" \
  -d '{"enabled": true}'

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   ChatGPT / AI  β”‚    β”‚  AURA MCP Serverβ”‚    β”‚    AURA API     β”‚
β”‚                 │◄──►│                 │◄──►│                 β”‚
β”‚  - HTTP Calls   β”‚    β”‚  - Fastify API  β”‚    β”‚  - Portfolio    β”‚
β”‚  - Responses    β”‚    β”‚  - Guard Engine β”‚    β”‚  - Strategies   β”‚
β”‚                 β”‚    β”‚  - Swap Adapter β”‚    β”‚  - AI Insights  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚   0x Swap API   β”‚
                       β”‚                 β”‚
                       β”‚  - DEX Agg.     β”‚
                       β”‚  - Quote        β”‚
                       β”‚  - 100+ DEXes   β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚  200+ Chains    β”‚
                       β”‚                 β”‚
                       β”‚  - Ethereum     β”‚
                       β”‚  - Base         β”‚
                       β”‚  - Arbitrum     β”‚
                       β”‚  - Polygon      β”‚
                       β”‚  - Optimism     β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

  • Runtime: Node.js 18+ with TypeScript
  • Framework: Fastify (HTTP server)
  • Validation: Zod schemas for type safety
  • Blockchain: Ethers.js v6
  • APIs:
  • Frontend: Vanilla JS with MetaMask integration
  • Logging: Winston for structured logs

πŸ“š API Reference

HTTP Endpoints

Portfolio Endpoints

  • POST /api/portfolio/balance - Get wallet balance across all chains
  • POST /api/portfolio/positions - Get DeFi positions with health factors

Swap Endpoints

  • GET /api/swap/chains - Get supported networks (6 chains)
  • POST /api/swap/quote - Get swap quote from 0x API
  • POST /api/swap/price - Get price estimate (detailed)
  • POST /api/swap/prepare - Prepare transaction for signing
  • GET /api/swap/sources/:chainId - Get DEX sources for chain

Strategy Endpoints

  • POST /api/strategy/propose - Get AI strategy recommendations

Guard Endpoints

  • POST /api/guard/setRules - Configure risk management rules
  • POST /api/guard/setEmergencyStop - Enable/disable emergency stop

System Endpoints

  • GET /api/health - Health check with uptime

Web Interface

  • GET / - Landing page with feature overview
  • GET /swap - Swap interface with MetaMask integration

πŸ§ͺ Testing

All features have been tested and validated:

βœ… Portfolio balance across 200+ chains
βœ… Token swap quotes with 0x API (ETH β†’ USDC on Base)
βœ… Guard Engine validation (slippage & gas limits)
βœ… Swap interface with MetaMask integration
βœ… AI strategy proposals with AURA API

# Test portfolio endpoint
curl -X POST http://localhost:5000/api/portfolio/balance \
  -H "Content-Type: application/json" \
  -d '{"address":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"}'

# Test swap chains
curl http://localhost:5000/api/swap/chains

# Test swap quote (requires taker address)
curl -X POST http://localhost:5000/api/swap/prepare \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": 8453,
    "sellToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    "buyToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "sellAmount": "10000000000000000",
    "taker": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
  }'

πŸ“Š Performance

  • Swap Quote: < 300ms (0x API aggregation)
  • Portfolio Analysis: < 2s across 200+ chains
  • Strategy Proposal: ~30s (AI-powered recommendations)
  • Throughput: 100+ requests/minute
  • Uptime: 99.9% on Replit

πŸ”’ Security

  • βœ… Input validation with Zod schemas
  • βœ… Guard engine risk management (slippage, gas limits)
  • βœ… MetaMask browser signing (no server-side private keys)
  • βœ… CORS enabled for secure wallet connections
  • βœ… Environment variable encryption (Replit Secrets)
  • βœ… TypeScript type safety

πŸš€ Deployment

Replit (Current Deployment)

  1. Import GitHub repository to Replit
  2. Add secrets in Replit Secrets:
    • AURA_API_KEY
    • ZEROEX_API_KEY
  3. Click Run (auto-configured on port 5000)
  4. Access at your Replit URL

Manual Deployment

# Build production bundle
npm run build

# Start production server
npm start

Server will run on port 5000 by default.

πŸ“„ Technical Documentation

For detailed technical documentation, architecture decisions, and implementation details, see:

🀝 Contributing

Contributions welcome! Please follow these steps:

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

πŸ“„ License

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

πŸ“ž Support


Built with ❀️ for DeFi

Powered by AURA API β€’ 0x Protocol β€’ Web3

About

AI-Powered DeFi Portfolio Analysis & Token Swap Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published