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

Autonomous-Finance/dexi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Dexi

AO License Status Lua

Global liquidity tracking hub for decentralized finance on AO

Aggregate AMM data, subscribe to real-time market feeds, and power autonomous trading agents

FeaturesArchitectureData FeedsGetting StartedLicense


⚠️ ARCHIVED PROJECT

This project is archived and no longer maintained. It is provided as-is for educational and reference purposes. No support, updates, or bug fixes will be provided.


🌟 Features

📈 Candles & Stats

OHLCV candlestick data with configurable intervals. Track volume, price history, and trading activity across all registered AMMs.

🔗 Multi-Hop Routing

Price discovery across token pairs via intelligent routing. Find optimal swap paths through multiple liquidity pools.

🤖 Agent-Ready Subscriptions

Subscribe to real-time feeds across all AMMs. Power autonomous agents that react to sophisticated market signals and execute strategies.

💧 Pool Analytics

TVL tracking, locked liquidity metrics, historical volume analysis, and LP PnL calculations for every pool.

🏗️ Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         AMM POOLS                               │
│           Swaps • Liquidity Events • Fee Changes                │
└─────────────────────────────────────────────────────────────────┘
                              │
                              │ Raw market data
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                         DEXI CORE                               │
│  • Aggregates & processes    • Manages subscriptions            │
│  • Stores in SQLite          • Computes analytics               │
│  • Multi-hop routing         • Tracks locked liquidity          │
└─────────────────────────────────────────────────────────────────┘
                              │
                              │ Processed feeds
              ┌───────────────┼───────────────┐
              ▼               ▼               ▼
      ┌───────────────┐ ┌───────────────┐ ┌───────────────┐
      │  MICRODEXI    │ │  SUBSCRIBERS  │ │   INDEXERS    │
      │  ──────────   │ │  ──────────   │ │  ──────────   │
      │  Per-AMM      │ │  • Agents     │ │  • dApps      │
      │  child procs  │ │  • Bots       │ │  • Analytics  │
      └───────────────┘ └───────────────┘ └───────────────┘

How It Works

  1. AMM Registration — Pool creators register their AMMs with Dexi via payment
  2. Dexi Subscribes — Dexi subscribes to registered AMMs for swap & liquidity events
  3. Data Aggregation — Swaps, reserves, and fee changes are ingested into SQLite
  4. Feed Distribution — Subscribers receive real-time updates on their topics of interest

📡 Data Feeds

Subscription Topics

Topic Description Parameters
Swap Notifications Real-time swap events for agent triggers AMM-Process-Id
Reserve Changes Liquidity additions/removals AMM-Process-Id
Locked Liquidity LP token lock/unlock events AMM-Process-Id

Pull-Based Queries

┌──────────────────────────────────────────────────────────────────┐
│  Get-Candles          │  OHLCV data for any interval (1m → 1d)   │
│  Get-Overview         │  All AMMs with 24h stats                 │
│  Get-Stats            │  Volume, traders, price changes          │
│  Get-Global-Liquidity │  Cross-AMM liquidity metrics             │
│  Get-Price-For-Token  │  Multi-hop price discovery               │
│  Get-Oracle-Price     │  USD price from RedStone oracle          │
│  Get-Locked-Share     │  Locked liquidity percentage             │
│  Get-Pool-Pnl-History │  LP profit/loss over time                │
└──────────────────────────────────────────────────────────────────┘

🔄 Data Flow

                AMM Pools                          External Sources
                    │                                     │
    ┌───────────────┼───────────────┐                    │
    ▼               ▼               ▼                    ▼
┌───────┐       ┌───────┐       ┌───────┐         ┌──────────┐
│ Swaps │       │ Liq.  │       │ Fees  │         │ RedStone │
│       │       │ Events│       │Changes│         │  Oracle  │
└───┬───┘       └───┬───┘       └───┬───┘         └────┬─────┘
    │               │               │                   │
    └───────────────┴───────┬───────┴───────────────────┘
                            ▼
              ┌─────────────────────────┐
              │      INGEST LAYER       │
              │   Validate & Normalize  │
              └───────────┬─────────────┘
                          ▼
              ┌─────────────────────────┐
              │    SQLite Database      │
              │  ───────────────────    │
              │  • amm_transactions     │
              │  • amm_registry         │
              │  • token_registry       │
              │  • swap_params_changes  │
              └───────────┬─────────────┘
                          ▼
              ┌─────────────────────────┐
              │  DISPATCH TO            │
              │  SUBSCRIBERS            │
              └─────────────────────────┘

📋 Usage Examples

Get Candlestick Data

ao.send({
  Target = DEXI,
  Action = "Get-Candles",
  AMM = "<pool-process-id>",
  Days = "7",
  Interval = "1h"
})

Get Market Overview

ao.send({
  Target = DEXI,
  Action = "Get-Overview",
  ["Order-By"] = "volume"  -- volume | transactions | date
})

Subscribe to Swaps

ao.send({
  Target = DEXI,
  Action = "Subscribe-Swaps",
  ["AMM-Process-Id"] = "<pool-process-id>"
})

Register an AMM

ao.send({
  Target = PAYMENT_TOKEN,
  Action = "Transfer",
  Recipient = DEXI,
  Quantity = "5",
  ["X-Action"] = "Register-AMM",
  ["X-AMM-Process"] = "<amm-process-id>"
})

📁 Project Structure

dexi/
├── 📂 dexi-core/           # Core aggregator logic
│   ├── candles.lua         # OHLCV calculations
│   ├── stats.lua           # Trading statistics
│   ├── overview.lua        # Market overview
│   ├── liquidity.lua       # TVL & liquidity tracking
│   └── lookups.lua         # Price lookups
├── 📂 subscriptions/       # Subscription management
├── 📂 ingest/              # Data ingestion handlers
├── 📂 factory/             # Microdexi spawning
├── 📂 microdexi/           # Per-AMM child processes
├── 📂 global-liquidity/    # Cross-AMM liquidity
├── 📂 amm-analytics/       # Pool analytics & PnL
├── 📂 integrate-amm/       # AMM registration flow
├── 📂 integrate-auction/   # Dutch auction tracking
├── 📂 hopper/              # Multi-hop price routing
├── 📂 liquidity-router/    # Swap route optimization
├── 📂 oracle/              # RedStone price feeds
├── 📂 db/                  # SQLite schema & utils
├── 📂 ops/                 # Operations & config
├── 📂 utils/               # Shared utilities
├── 📂 test/                # Unit tests
└── process.lua             # Main entry point

🚀 Getting Started

Prerequisites

  • Lua 5.4+
  • Node.js 18+
  • amalg.lua (Lua bundler)
  • aoform (AO deployment tool)

Installation

# Clone the repository
git clone https://github.com/Autonomous-Finance/dexi.git
cd dexi

# Install Node dependencies
npm install

# Build the project
npm run build

# Deploy to AO
npx aoform apply

Build Output

The build process produces:

  • build/output.lua — Bundled Dexi process code ready for deployment

⚙️ Configuration

Dexi uses process tags and global variables for configuration:

Variable Description
PAYMENT_TOKEN_PROCESS Token process for subscription payments
OPERATOR Authorized operator address
TOKEN_LOCKER_PROCESS Token lock tracking process
REDSTONE_PROXY_PROCESS Oracle price feed proxy
DISPATCH_ACTIVE Enable/disable feed dispatch

Payment Configuration

PAYMENT_PRICES = {
  ["Update-Token-Metadata"] = 1,  -- USD
  ["Subscribe-Pool"] = 5          -- USD
}

🛠️ Tech Stack

Technology Purpose
Lua Core process logic
AO Decentralized compute on Arweave
SQLite Embedded database for aggregation
aoform Deployment management
amalg Lua module bundling

⚠️ Disclaimer

This software is provided "as is" without warranty of any kind. Use at your own risk. The authors are not responsible for any financial losses incurred through the use of this software.

This is experimental DeFi infrastructure. Always:

  • Test integrations thoroughly before production use
  • Understand the data latency characteristics
  • Review the code before relying on it for trading decisions

📄 License

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

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published