This repository contains a multi-program Solana ecosystem in Rust, architected for AI-driven tokenomics. For a complete, machine-readable architecture, see manifest.json.
This project demonstrates a hybrid blockchain architecture. Deterministic on-chain programs handle asset management, while off-chain bots use the OpenRouter API to make intelligent economic decisions.
- ICO Factory: A standard bonding curve launchpad.
- Affiliate System: An on-chain program whose commission rates are dynamically set by an AI bot.
- Barter DEX: An oracle-based DEX that uses AI-generated prices for swaps, instead of a traditional AMM formula.
manifest.json: Primary source of truth for the system architecture.programs/factory-program: The core ICO launchpad. (See README)programs/affiliate-program: Manages affiliate data, controlled by AI. (See README)programs/barter-dex-program: The AI-powered oracle DEX. (See README)bots/optimizer-bot: Off-chain bot to set affiliate commissions via AI.bots/price-keeper-bot: Off-chain bot that acts as a price oracle for the DEX.crates/genesis-common: Shared library of constants.tests/integration.rs: End-to-end tests.
graph TD
subgraph "Off-Chain (AI Decision-Making)"
OpenRouterAPI[OpenRouter API]
OptimizerBot[Optimizer Bot]
PriceKeeperBot[Price Keeper Bot]
OptimizerBot --(HTTP POST with on-chain data)--> OpenRouterAPI
OpenRouterAPI --(JSON response with new rate)--> OptimizerBot
PriceKeeperBot --(HTTP POST with token info)--> OpenRouterAPI
OpenRouterAPI --(JSON response with price)--> PriceKeeperBot
end
subgraph "On-Chain (Solana)"
AffiliateProgram[Affiliate Program]
BarterDEX[Barter DEX Program]
FactoryProgram[Factory Program]
User --(Buys Tokens)--> FactoryProgram
User --(Swaps Tokens at AI Price)--> BarterDEX
end
OptimizerBot --(TX: set_commission_rate)--> AffiliateProgram
PriceKeeperBot --(TX: update_oracle_price)--> BarterDEX
- Prerequisites: Install Rust, Solana CLI, Anchor Framework (v0.28.0).
- API Key: Create a file at
~/.api-openrouterand place your OpenRouter API key inside it. - Build:
anchor build - Test:
cargo test-bpf -- --nocapture