Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Autonomous-Finance/index-agent

Repository files navigation

πŸ€– Token Index Agent

Autonomous Investment Agent for the AO Ecosystem

Token Index Agent Logo

License: MIT AO Arweave Status


⚠️ ARCHIVED PROJECT

This project is no longer actively maintained and is provided as-is for archival and educational purposes. No support, updates, or security patches will be provided. Use at your own risk.

Originally developed by Autonomous Finance


πŸ“‹ Overview

The Token Index Agent is an Autonomous Investment Agent (AIA) that executes dynamic token index investment strategies across liquidity pools within the AO ecosystem. It automatically manages a portfolio of tokens based on user-defined criteria and autonomously rebalances holdings using market signals from DEXI.

Key Characteristics

  • πŸ”„ Fully Autonomous: Operates independently on the AO platform with no off-chain signals or human intervention required
  • πŸ“Š Dynamic Rebalancing: Automatically adjusts portfolio based on price changes and token set membership
  • 🌐 Permaweb-Native: Management interface hosted on Arweave's permanent web
  • πŸ” Self-Custodial: Users maintain full ownership and control through their Arweave wallet

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Frontend (Next.js)                            β”‚
β”‚                   Hosted on Arweave Permaweb                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      AO Network (Hyper-Parallel Computer)            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Agent Process  β”‚  β”‚ Backend Process β”‚  β”‚   DEXI (Oracle)     β”‚  β”‚
β”‚  β”‚  (Per User)     β”‚  β”‚  (Shared)       β”‚  β”‚   Market Data       β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚           β”‚                    β”‚                      β”‚              β”‚
β”‚           β–Ό                    β–Ό                      β–Ό              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚                      AMM Liquidity Pools                      β”‚    β”‚
β”‚  β”‚              (Bark, Permaswap, and others)                    β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Components

Component Description
Agent Process Individual Lua process per user that manages portfolio, executes trades, and maintains state
Backend Process Shared registry tracking all agents and facilitating queries
Frontend Next.js application for agent creation, monitoring, and management
DEXI Integration Oracle providing real-time market data and token rankings

✨ Features

Agent Operations

  • Index Set Updates: Automatically swaps exited tokens for newly added tokens when the index composition changes
  • Price-Based Rebalancing: Rebalances portfolio when price deviations exceed configured thresholds

User Operations

  • Token Loading: Deposit quote tokens to fund the agent
  • Liquidation: Partial or total liquidation back to quote token
  • Emergency Exit: Immediate withdrawal of all assets
  • Ownership Transfer: Transfer agent control to another wallet

Configuration Options

  • Token Set Size: Number of tokens in the index (e.g., "Top 3 tokens")
  • Price Threshold: Maximum deviation before rebalancing triggers
  • Slippage Tolerance: Acceptable slippage for swap execution
  • Rebalance Interval: How frequently to check for rebalancing needs

πŸš€ Getting Started

⚠️ Note: This project is archived and may not work with current AO infrastructure.

Prerequisites

  • Node.js 18+
  • Yarn or npm
  • Lua 5.3+ (for agent development)
  • LuaRocks with Amalg

Installation

# Clone the repository
git clone https://github.com/your-org/token-index-agent.git
cd token-index-agent

# Install dependencies
yarn install

# Copy environment configuration
cp .env.example .env.local
# Edit .env.local with your configuration

Development

# Start development server
yarn dev

# Open http://localhost:3000

Building Lua Agents

# Build agent source (combines Lua modules)
yarn build-lua-agent

# Build backend source
yarn build-lua-backend

Running Tests

# Run Lua tests
yarn test

πŸ“ Project Structure

token-index-agent/
β”œβ”€β”€ ao/                          # Lua agent and backend code
β”‚   β”œβ”€β”€ agent/                   # Agent process modules
β”‚   β”‚   β”œβ”€β”€ deposits.lua         # Deposit handling
β”‚   β”‚   β”œβ”€β”€ holdings.lua         # Portfolio management
β”‚   β”‚   β”œβ”€β”€ life-cycle.lua       # Agent lifecycle
β”‚   β”‚   β”œβ”€β”€ liquidation.lua      # Liquidation logic
β”‚   β”‚   β”œβ”€β”€ rebalancing.lua      # Rebalancing algorithm
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ backend/                 # Backend process modules
β”‚   β”œβ”€β”€ permissions/             # Access control
β”‚   β”œβ”€β”€ utils/                   # Shared utilities
β”‚   β”œβ”€β”€ test/                    # Lua tests
β”‚   β”œβ”€β”€ process.lua              # Main agent entry point
β”‚   └── backend.lua              # Main backend entry point
β”œβ”€β”€ src/                         # Next.js frontend
β”‚   β”œβ”€β”€ app/                     # App router pages
β”‚   β”œβ”€β”€ components/              # React components
β”‚   β”œβ”€β”€ hooks/                   # Custom React hooks
β”‚   β”œβ”€β”€ utils/                   # Frontend utilities
β”‚   └── lua/                     # Embedded Lua source
β”œβ”€β”€ scripts/                     # Build and deploy scripts
└── public/                      # Static assets

πŸ”§ Configuration

See .env.example for all available configuration options.

Key Environment Variables

Variable Description
NEXT_PUBLIC_AGENT_BACKEND Backend process ID for agent registration
NEXT_PUBLIC_CRED_ADDRESS Quote token (CRED) process address
NEXT_PUBLIC_DEXI_MONITOR DEXI oracle contract address
NEXT_PUBLIC_AO_MODULE AO module ID for process spawning
NEXT_PUBLIC_AO_SCHEDULER AO scheduler address

⚠️ Disclaimer

IMPORTANT: This software is provided "as-is" without any warranties.

  • Financial Risk: Autonomous investment strategies carry inherent financial risks including potential loss of funds
  • Technological Risk: Blockchain technology and DeFi protocols may have bugs, vulnerabilities, or unexpected behaviors
  • Regulatory Risk: The regulatory environment for digital assets varies by jurisdiction
  • No Liability: The authors are not liable for any damages arising from the use of this software

Use at your own risk. Always conduct your own due diligence before using any investment software.


πŸ“„ License

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


πŸ™ Acknowledgments


⚑ Built for the Permaweb ⚑

This repository is archived and preserved on Arweave for posterity

]]>

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages