# πŸ—οΈ Dynamic RWA Yield Router > **Mantle Turing Test Hackathon 2026 β€” Phase 2 "AI Awakening" β€” AI Γ— RWA Track** An autonomous AI agent that dynamically allocates capital across Mantle's Real World Asset (RWA) stack using reinforcement learning + LSTM yield prediction, with MEV-protected execution, auto-compounding, social sentiment analysis, and all decisions recorded on-chain via ERC-8004 agent identity NFTs. Ships with a **Binance-grade Next.js dashboard**. --- ## πŸ”₯ What Makes This 10x Different | Innovation | Description | Status | |-----------|-------------|--------| | **Ensemble AI Engine** | PPO RL optimizer + LSTM yield predictor + sentiment analyzer working in concert | βœ… Active | | **MEV Protection Layer** | Sandwich detection, trade splitting, private mempool routing, optimal slippage | βœ… Active | | **Auto-Compounding** | Gas-optimized yield restaking with mathematically optimal compound frequency | βœ… Active | | **LSTM Yield Predictor** | 7-day yield forecasting with MC Dropout confidence intervals & regime detection | βœ… Active | | **Social Sentiment** | Real-time crypto sentiment aggregation (Fear & Greed, social volume, news) | βœ… Active | | **ERC-8004 Agent Identity** | Soulbound NFT with capabilities, attestations, reputation scoring, decision history | βœ… On-chain | | **zkML-Ready Architecture** | Verifiable inference proofs for on-chain AI transparency (EZKL/Giza compatible) | πŸ”œ Planned | | **Binance-Grade Dashboard** | Next.js + Tailwind + Recharts with full Binance design system (dark theme, trading UI) | βœ… Built | --- ## πŸ“Š Portfolio Assets | Asset | Type | Target APY | Risk | Protocol | |-------|------|-----------|------|----------| | **USDY** | Tokenized US T-Bills | ~4.25% + lending | Low | Ondo Finance | | **mETH** | Liquid Staked ETH | ~3.9% + lending | Medium | Mantle LSP | | **MI4** | Tokenized Index Fund | ~5.4% + lending | Medium | Securitize | The agent captures **base yield + lending yield** (Aave V3 supply) for each asset, achieving total APYs of 4.7-6.2%. --- ## πŸ›οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DYNAMIC RWA YIELD ROUTER v2.0 β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ OBSERVE β”‚β†’β”‚ PREDICT β”‚β†’β”‚ REASON β”‚β†’β”‚ PLAN β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ DeFiLlama β”‚ β”‚ LSTM Yield β”‚ β”‚ PPO Policy β”‚ β”‚ Rebalance β”‚ β”‚ β”‚ β”‚ CoinGecko β”‚ β”‚ Predictor β”‚ β”‚ + Ensembleβ”‚ β”‚ + MEV Opt β”‚ β”‚ β”‚ β”‚ Mantle RPCβ”‚ β”‚ + Sentimentβ”‚ β”‚ β”‚ β”‚ + Splitter β”‚ β”‚ β”‚ β”‚ FRED/News β”‚ β”‚ + Regime β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ ↓ ↓ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ AUTHORIZE β”‚β†’β”‚ EXECUTE β”‚β†’β”‚AUTOCOMPOUNDβ”‚β†’β”‚ VERIFY β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ 6-Layer β”‚ β”‚ Unsigned Txβ”‚ β”‚ Gas-Optimalβ”‚ β”‚ On-chain β”‚ β”‚ β”‚ β”‚ Risk Mgr β”‚ β”‚ + MEV Prot β”‚ β”‚ Restaking β”‚ β”‚ + ERC-8004 β”‚ β”‚ β”‚ β”‚ + Sentimentβ”‚ β”‚ + Whitelistβ”‚ β”‚ Automation β”‚ β”‚ Attestationβ”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ ON-CHAIN CONTRACTS β”‚ β”‚ β”‚ β”‚ YieldRouterAgent.sol β”‚ AgentIdentity8004.sol β”‚ RiskRegistry.solβ”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ BINANCE-STYLE NEXT.JS DASHBOARD β”‚ β”‚ β”‚ β”‚ Portfolio β”‚ Markets β”‚ AI Optimizer β”‚ Risk β”‚ Agent Identity β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ### 8-Stage Agent Pipeline (v2.0) 1. **OBSERVE** β€” Fetch real-time yield, price, macro, and sentiment data 2. **PREDICT** β€” LSTM yield forecasting with MC Dropout confidence + regime detection 3. **REASON** β€” PPO policy + ensemble (combine RL action with LSTM prediction + sentiment) 4. **PLAN** β€” Compute trades with MEV analysis (sandwich detection, trade splitting) 5. **AUTHORIZE** β€” 6-layer risk manager (depeg, volatility, concentration, drawdown, circuit breaker, sentiment) 6. **EXECUTE** β€” Construct MEV-protected unsigned transactions (private mempool, optimal deadline) 7. **AUTO-COMPOUND** β€” Gas-optimized yield restaking at mathematically optimal frequency 8. **VERIFY** β€” Confirm on-chain, update ERC-8004 reputation, generate strategy report --- ## 🧠 AI/ML Stack ### PPO Reinforcement Learning - **Algorithm:** Proximal Policy Optimization with Actor-Critic MLP - **State Space:** 18-dimensional (yields, prices, macro, risk signals, portfolio weights) - **Action Space:** 3-dimensional continuous β†’ softmax β†’ weights [USDY, mETH, MI4] - **Reward:** Risk-adjusted Sharpe ratio - drawdown penalty - depeg penalty - gas costs ### LSTM Yield Predictor *(Novel)* - **Architecture:** 2-layer LSTM with attention mechanism - **Input:** Yield history, price momentum, fed rate, volatility, sentiment - **MC Dropout:** 50 forward passes for uncertainty estimation (confidence intervals) - **Regime Detection:** Bull/Bear/Sideways classification head - **Feature Importance:** Attention weights reveal which features drove the prediction ### Social Sentiment Analyzer *(Novel)* - **Sources:** Fear & Greed Index, social volume, news sentiment - **Integration:** Sentiment score feeds into both LSTM predictor and risk manager - **Impact:** High fear β†’ increase USDY (safe haven), High greed β†’ lean into mETH/MI4 --- ## πŸ›‘οΈ Novel Risk & Execution Features ### MEV Protection Layer *(Novel)* - **Sandwich Attack Detection:** Estimates price impact per trade - **Trade Splitting:** Automatically splits large trades to reduce MEV exposure - **Private Mempool:** Routes high-impact trades through private channels - **Optimal Deadlines:** Shorter deadlines for high-risk trades, longer for low-risk ### Auto-Compounding Engine *(Novel)* - **Optimal Frequency:** Calculates gas-optimal compound interval using calculus optimization - **Formula:** `n* = √(APY Γ— Principal / (2 Γ— GasCost))` compounds per year - **Break-even:** Computes minimum principal where compounding beats simple yield - **Smart Triggers:** Only compounds when accumulated yield > 3Γ— gas cost ### 6-Layer Risk Management | Layer | Description | Trigger | |-------|-------------|---------| | Depeg Detection | USDY/USD and mETH/ETH peg monitoring | >0.5% / >2% | | Volatility Guard | Dynamic exposure reduction in high-vol regimes | ETH 30d vol >80% | | Concentration Limits | Position size enforcement | >60% or <5% | | Smart Contract Risk | Protocol-weighted risk scoring | Per-protocol scores | | Drawdown Protection | Circuit breaker on portfolio losses | DD >10% | | Sentiment Guard *(Novel)* | Reduces risky exposure on extreme fear | Score <20 | --- ## 🎨 Dashboard (Next.js + Binance Design) Full-featured financial dashboard built with the **Binance Design System**: - **Dark canvas** (#0b0e11) with card surfaces (#1e2329) - **Binance Yellow** (#FCD535) accent for CTAs and brand elements - **Trading green/red** (#0ecb81/#f6465d) for price direction semantics - **BinancePlex substitute** (JetBrains Mono) for all financial numbers - **6 dashboard sections:** Portfolio, Markets, AI Optimizer, Risk Monitor, Reports, Agent Identity ### Dashboard Features - πŸ“ˆ Real-time portfolio value chart with timeframe selector - πŸ₯§ Live allocation pie chart + weight history area chart - πŸ“Š RWA markets table with yield comparison bar chart - 🧠 LSTM yield predictions with confidence bars + AI recommendations - 🌑️ Social sentiment gauge with source breakdown - πŸ›‘οΈ Risk score ring, protection layer status, activity log - πŸ€– ERC-8004 agent identity card with reputation, capabilities, attestations - πŸ“± Fully responsive (mobile hamburger, tablet 2-up, desktop full layout) ```bash # Run the dashboard cd dashboard && npm install && npm run dev ``` --- ## πŸš€ Quick Start ```bash # Clone from HuggingFace git clone https://huggingface.co/muthuk1/mantle-rwa-yield-router cd mantle-rwa-yield-router # Install Python dependencies pip install -r requirements.txt # Run demo (3 cycles with live data) python scripts/demo.py # Train RL agent python scripts/train.py # Run continuous agent python -m agent.main --mode run --interval 3600 --capital 100000 # Run tests (25 passing) pytest tests/ -v # Run dashboard cd dashboard && npm install && npm run dev ``` --- ## πŸ“‚ Project Structure ``` mantle-rwa-yield-router/ β”œβ”€β”€ agent/ β”‚ β”œβ”€β”€ main.py # 8-stage orchestrator pipeline β”‚ β”œβ”€β”€ data_pipeline.py # Real-time data aggregation (8 sources) β”‚ β”œβ”€β”€ rl_optimizer.py # PPO agent + Gymnasium environment β”‚ β”œβ”€β”€ risk_manager.py # 6-layer risk management β”‚ β”œβ”€β”€ executor.py # MEV-protected unsigned tx builder β”‚ β”œβ”€β”€ strategy_reporter.py # LLM strategy letter generator β”‚ └── novel_features.py # LSTM predictor, MEV shield, auto-compound, sentiment β”œβ”€β”€ contracts/ β”‚ β”œβ”€β”€ YieldRouterAgent.sol # On-chain allocation router β”‚ β”œβ”€β”€ AgentIdentity8004.sol # ERC-8004 soulbound agent identity β”‚ └── RiskRegistry.sol # On-chain risk parameters β”œβ”€β”€ dashboard/ # Next.js Binance-style UI β”‚ β”œβ”€β”€ src/app/page.tsx # Main dashboard page β”‚ β”œβ”€β”€ src/components/ # TopNav, Charts, RiskMonitor, AIOptimizer, AgentIdentity β”‚ └── src/lib/data.ts # Data generators and mock data β”œβ”€β”€ telegram_bot/ β”‚ └── bot.py # Telegram UI (/status, /yields, /risk) β”œβ”€β”€ config/ β”‚ └── constants.py # All contract addresses, ABIs, parameters β”œβ”€β”€ scripts/ β”‚ β”œβ”€β”€ demo.py # Demo runner β”‚ └── train.py # RL training script β”œβ”€β”€ tests/ β”‚ └── test_agent.py # 25 unit + integration tests β”œβ”€β”€ requirements.txt β”œβ”€β”€ .env.example └── README.md ``` --- ## πŸ“œ Smart Contracts ### `YieldRouterAgent.sol` On-chain allocation records, position limits, circuit breaker, operator authorization. ### `AgentIdentity8004.sol` (ERC-8004) Soulbound agent identity NFT: capabilities, attestations, reputation (0-10000), decision history. ### `RiskRegistry.sol` On-chain risk parameters, depeg event tracking, allocation validation. --- ## πŸ“Š Contract Addresses (Mantle Mainnet, Chain ID 5000) | Contract | Address | |----------|---------| | USDY (Ondo) | `0x5bE26527e817998A7206475496fDE1E68957c5A6` | | mETH | `0xcDA86A272531e8640cD7F1a92c01839911B90bb0` | | USDC | `0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9` | | WMNT | `0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8` | | Fluxion Router | `0x5628a59df0ecac3f3171f877a94beb26ba6dfaa0` | | Agni Router | `0x319B69888b0d11cEC22caA5034e25FfFBDc88421` | | Aave V3 Pool | `0x458F293454fE0d67EC0655f3672301301DD51422` | --- ## πŸ”‘ Key Design Decisions 1. **Construct-Only Safety** β€” Never holds private keys. All outputs are unsigned tx payloads. 2. **Ensemble Intelligence** β€” PPO + LSTM + Sentiment provide richer signals than any single model. 3. **MEV-Aware** β€” Every trade goes through sandwich detection + optimal splitting. 4. **Gas-Optimized Compounding** β€” Mathematical optimization of compound frequency vs gas costs. 5. **On-Chain Audit Trail** β€” ERC-8004 records every decision with content hashes. 6. **Binance-Grade UI** β€” Production dashboard, not a demo. Full dark theme, live charts, responsive. --- ## πŸ† Hackathon Track **Mantle Turing Test Hackathon 2026 β€” Phase 2 "AI Awakening"** - **Track:** AI Γ— RWA ($100K prize pool) - **Focus:** Autonomous AI agents managing tokenized real-world assets - **Key Tech:** RL optimization, LSTM prediction, ERC-8004, MEV protection, Mantle L2 ## πŸ“ License MIT --- *Built with πŸ€– for the Mantle Turing Test Hackathon 2026*