Skip to content

MichaelPaonam/arya

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

206 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARYA Logo

ARYA - Autonomous Realtime Yield Agents

A multi-agent AI swarm that collaboratively analyzes, recommends, and executes DeFi yield farming strategies - with human-in-the-loop oversight.

ETHGlobal Open Agents Hackathon


Overview

ARYA is a swarm of four specialized AI agents that work together to discover, evaluate, and execute yield farming opportunities across DeFi protocols. Unlike fully autonomous fund managers, ARYA keeps humans in control: agents analyze and recommend, users approve, and smart contracts enforce the approval gate on-chain.

Agents analyze. Humans decide. Smart contracts enforce.

Architecture

System Overview

flowchart LR
    subgraph Frontend["Frontend (Next.js)"]
        Dashboard[Dashboard UI]
        Approve[Approve / Reject]
    end

    subgraph Agents["Agent Swarm (LangGraph.js)"]
        Scout[Scout Agent]
        Risk[Risk Agent]
        Orch[Orchestrator]
        Exec[Executor Agent]
    end

    subgraph Contracts["0G Chain (Solidity)"]
        Registry[YieldSwarmRegistry\nERC-7857 iNFT]
        Vault[StrategyVault\nApproval Gate]
        Rep[AgentReputation\nPerformance Log]
    end

    subgraph External["External Services"]
        DeFiLlama[DefiLlama API]
        Uniswap[Uniswap Trading API]
        KeeperHub[KeeperHub\nAutomation]
        ZeroG[0G Storage\nAgent Memory]
    end

    Dashboard -->|Run Scan| Orch
    Scout -->|Yield Data| DeFiLlama
    Scout -->|Pool Data| Uniswap
    Orch --> Scout
    Orch --> Risk
    Orch -->|Proposal| Dashboard
    Approve -->|Sign Tx| Vault
    Vault -->|Approved| Exec
    Exec --> Uniswap
    Exec --> KeeperHub
    Vault --> Rep
    Orch --> ZeroG
    Registry -.->|Identity| Agents
Loading

Agent Pipeline Flow

sequenceDiagram
    actor User
    participant UI as Dashboard
    participant O as Orchestrator
    participant S as Scout
    participant R as Risk Agent
    participant V as StrategyVault
    participant E as Executor
    participant U as Uniswap API
    participant K as KeeperHub

    User->>UI: Click "Run Scan"
    UI->>O: POST /api/pipeline
    O->>S: Discover opportunities
    S-->>O: Yield opportunities[]
    O->>R: Assess risk
    R-->>O: Risk scores + debate
    O->>UI: Strategy proposal
    UI->>User: Present proposal (APY, risk, radar)

    alt User Approves
        User->>V: Sign approval tx (MetaMask)
        V->>E: Strategy approved on-chain
        E->>U: Build swap transaction
        U-->>E: Signed tx
        E->>K: Create monitoring workflow
        K-->>E: Workflow armed
        E-->>UI: Execution confirmed
        V->>V: Log outcome → AgentReputation
    else User Rejects
        User->>UI: Reject
        UI->>O: Feedback logged
    end
Loading

Agents

Agent Role
Scout Discovers yield opportunities via DefiLlama and Uniswap pool data
Risk Scores opportunities for impermanent loss, contract risk, and portfolio correlation
Executor Builds swap transactions via Uniswap API and creates KeeperHub monitoring workflows
Orchestrator Coordinates the swarm pipeline and manages state on 0G Storage

Smart Contracts (0G Chain Galileo Testnet)

All contracts are deployed on 0G Galileo Testnet (Chain ID: 16602).

Contract Address Purpose
YieldSwarmRegistry.sol 0x83A2bda1f2514871E805A59bA6448ec2346e2C03 ERC-7857 iNFT registry - each agent has a verifiable on-chain identity
StrategyVault.sol 0xFB7382DEc0D8B161594742cE7F6d32025729B25B Human-in-the-loop approval gate - agents propose, users approve before any fund movement
AgentReputation.sol 0x49564aA6AfDA323F62F9BC562638c272776d0D1a On-chain performance tracking - agents build verifiable reputation over time
SmartAccountFactory.sol 0x06a148eD3F8Da650a9BDd37a12a75ae960c79e40 CREATE2 deterministic smart account deployment with execute() for session key delegation
SessionKeyModule.sol 0x01be109884a05e29b4e073F0fa23D825393d0fB6 Session keys for bounded agent autonomy with spend limits and time bounds

Sponsor Integrations

Sponsor Integration
0G Agent identity (ERC-7857 iNFT on 0G Chain), agent memory and strategy history (0G Storage), multi-agent swarm architecture
Uniswap Foundation Swap quoting, routing, and execution via Trading API. Pool data for opportunity discovery
KeeperHub Execution layer via REST API. Automated workflows for position monitoring, rebalancing alerts, and yield harvesting

Tech Stack

Layer Technology
Frontend Next.js 14, React, TailwindCSS, shadcn/ui, Recharts
Wallet wagmi, viem, RainbowKit
Auth SIWE (Sign-In With Ethereum)
Agent Framework LangGraph.js (TypeScript)
LLM Claude Haiku 4.5 (BYOK — Anthropic or OpenRouter)
Contracts Solidity, Foundry, ERC-4337
Blockchain 0G Chain Testnet
Storage 0G Storage SDK
Session/User Data Upstash Redis
Swap Uniswap Trading API
Automation KeeperHub REST API
Deployment Vercel (serverless + cron)
Data DefiLlama API, CoinGecko API

Getting Started

For Users

All you need to use ARYA:

  1. A Web3 wallet (MetaMask, Rainbow, etc.) — connect via the dashboard
  2. An LLM API key (Standard plan only) — enter in Settings for AI-powered analysis. Supports Anthropic or OpenRouter

That's it. No accounts to create, no infrastructure to manage. Connect your wallet, optionally add your API key, and ARYA's agents start working for you.

Without an API key, ARYA still discovers opportunities and provides rule-based risk scores. Add a key to unlock AI-powered reasoning and strategy explanations.

For Developers

Prerequisites for running ARYA locally:

# Clone the repository
git clone https://github.com/MichaelPaonam/arya.git
cd arya

# Install Foundry (if not already installed)
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Initialize submodules (contract dependencies)
git submodule update --init --recursive

# Install frontend dependencies
npm install

# Configure environment
cp .env.example .env
# Fill in API keys and contract addresses

# Smart contracts (Solidity + Foundry)
cd packages/contracts
forge build            # Compile contracts
forge test             # Run all tests (124 tests across 4 suites)
forge test -vvv        # Verbose output for debugging
forge test --match-contract YieldSwarmRegistryTest  # Run specific test file

# Deploy to 0G Galileo testnet
cp .env.example .env
# Fill in DEPLOYER_PRIVATE_KEY and ORCHESTRATOR_ADDRESS (both need 0G testnet gas)
source .env
forge script script/Deploy.s.sol --rpc-url og_testnet --broadcast --with-gas-price 2500000000 --priority-gas-price 2500000000

# AI Agents (TypeScript + vitest)
cd ../agents
npm install
npx vitest run         # Run all tests (103 tests across 13 test files)
npx tsc --noEmit       # Type-check

# Start the dashboard (local dev)
cd ../frontend
npm install --legacy-peer-deps
npm run dev

# Run frontend tests
npx vitest run         # 66 tests across 14 files

Deploy to Vercel

The project is deployed as a monorepo on Vercel with the following build settings:

Setting Value
Root Directory (repo root)
Install Command cd packages/frontend && npm install --legacy-peer-deps && cd ../agents && npm install
Build Command cd packages/frontend && npm run build
Output Directory packages/frontend/.next

Agents run as Vercel serverless functions (/api/pipeline). The pipeline triggers on demand from the dashboard.

Project Structure

open-agent/
├── docs/
│   └── arya-logo.png
├── packages/
│   ├── contracts/           # Solidity smart contracts (Foundry)
│   │   ├── src/             # Contract source files
│   │   │   ├── interfaces/  # IAgentRegistry, IERC7857 interfaces
│   │   │   ├── YieldSwarmRegistry.sol
│   │   │   ├── StrategyVault.sol
│   │   │   ├── AgentReputation.sol
│   │   │   ├── SmartAccountFactory.sol
│   │   │   └── SessionKeyModule.sol
│   │   ├── test/            # Forge test files (124 tests)
│   │   ├── script/          # Deploy scripts
│   │   ├── broadcast/       # Deployment receipts (tx hashes, addresses)
│   │   └── lib/             # Dependencies (git submodules)
│   ├── agents/              # TypeScript agent implementations (103 tests)
│   │   └── src/
│   │       ├── types/       # Zod schemas + TypeScript types
│   │       ├── tools/       # API wrappers (DefiLlama, Uniswap, KeeperHub, 0G, wallet)
│   │       ├── agents/      # Scout, Risk, Orchestrator, Executor
│   │       ├── adapters/    # SmartAccountSigner (session key tx delegation)
│   │       ├── debate/      # 3-tier debate protocol (Fast/Standard/Deep)
│   │       ├── storage/     # Redis client + 0G memory persistence
│   │       ├── utils/       # LLM client (OpenRouter), IL math
│   │       └── graph/       # Pipeline orchestration (runPipeline)
│   └── frontend/            # Next.js 14 dashboard (66 tests across 14 files)
│       └── src/
│           ├── app/         # Pages: Command, Opportunities, Agents, Risk, History, Vaults, Settings
│           ├── components/  # App shell, providers, strategy cards, dialogs
│           ├── hooks/       # useWallet, useAppMode
│           ├── lib/         # wagmi config, feature flags
│           └── mocks/       # Faker-based mock data generators
├── .env.example
└── README.md

How It Works

  1. User connects wallet via RainbowKit and signs in with SIWE (Sign-In With Ethereum)
  2. Scout Agent scans DeFi protocols and discovers yield opportunities
  3. Risk Agent evaluates each opportunity with a multi-factor risk score
  4. Agent Debate — Risk challenges Scout's assumptions (3 tiers: Fast, Standard, Deep)
  5. Orchestrator packages the analysis into a strategy proposal with confidence score
  6. Dashboard presents the proposal to the user with risk visualizations
  7. User approves or rejects — the StrategyVault contract enforces this gate on-chain
  8. Executor Agent builds the swap transaction via Uniswap API and submits it
  9. KeeperHub monitors the position and triggers alerts if conditions change
  10. Outcome recorded on-chain — agent reputation updates based on strategy performance

Session Key Delegation (0G Storage)

Instead of exposing a raw private key for 0G Storage uploads, ARYA uses ERC-4337 session keys:

  1. User grants a bounded session key to the backend EOA during setup
  2. Session key is constrained: only the 0G FixedPriceFlow contract, max 0.01 0G/tx, 7-day expiry
  3. Backend signs uploads through SmartAccount.execute() — the session module validates permissions
  4. No private key of the contract owner is ever stored server-side

License

MIT


Built for ETHGlobal Open Agents hackathon

Releases

No releases published

Packages

 
 
 

Contributors