ποΈ 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, with all decisions recorded on-chain via ERC-8004 agent identity NFTs.
π What It Does
The Dynamic RWA Yield Router manages a portfolio across three core RWA assets on Mantle L2:
| Asset | Type | Target APY | Risk Profile |
|---|---|---|---|
| USDY (Ondo Finance) | Tokenized US T-Bills | ~4.25% | Low β USD-pegged, regulated |
| mETH (Mantle LSP) | Liquid Staked ETH | ~3-5% | Medium β ETH price exposure |
| MI4 (Mantle Index Four) | Tokenized Index Fund | ~5-8% | Medium β diversified basket |
The agent uses a PPO (Proximal Policy Optimization) reinforcement learning policy to learn optimal allocation weights given real-time market conditions, yield rates, and risk signals.
ποΈ Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DYNAMIC RWA YIELD ROUTER β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β OBSERVE βββ REASON βββ PLAN βββ AUTHORIZEβ β
β β β β β β β β β β
β βDeFiLlamaβ βRL Policy β βRebalance β β Risk β β
β βCoinGeckoβ β (PPO) β β Trades β β Manager β β
β βMantle β β β β β β β β
β βRPC/FRED β β β β β β β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β β β
β ββββββββββββ ββββββββββββ β
β β EXECUTE ββββββββββββββββββββββββββββββ VERIFY β β
β β β β β β
β βUnsigned β Mantle L2 (Chain 5000) βOn-chain β β
β βTx Builderβ Fluxion / Agni DEX βConfirm β β
β ββββββββββββ ββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β ON-CHAIN CONTRACTS β β
β β YieldRouterAgent.sol β AgentIdentity8004.sol β β
β β (Allocation Records) β (ERC-8004 Reputation) β β
β β RiskRegistry.sol β (Risk Parameters) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
6-Stage Agent Pipeline
- OBSERVE β Fetch real-time yield rates, prices, and macro data from DeFiLlama, CoinGecko/Bybit, Mantle RPC, and FRED
- REASON β RL policy (PPO with actor-critic MLP) predicts optimal allocation weights
- PLAN β Compute required trades if weights drift beyond threshold (5%)
- AUTHORIZE β Multi-layer risk manager validates: depeg detection, volatility guard, position limits, drawdown protection, circuit breaker
- EXECUTE β Construct unsigned transaction payloads (construct-only safety: never holds private keys)
- VERIFY β Confirm execution, update portfolio state, record on-chain via ERC-8004
π§ RL Model
Algorithm: Proximal Policy Optimization (PPO)
State Space (18-dimensional):
- Yield rates: USDY APY, mETH APY, MI4 APY, Aave supply APYs
- Prices: ETH, BTC, MNT (normalized)
- Macro: Fed funds rate, BTC dominance
- Risk: USDY peg, mETH peg, ETH 30d volatility
- Portfolio: current weights [USDY, mETH, MI4]
Action Space (3-dimensional, continuous):
- Raw logits β softmax β portfolio weights [USDY, mETH, MI4]
- Position limits enforced: 5-60% per asset
Reward Function:
reward = sharpe_ratio Γ 100
- drawdown Γ 50
- depeg_penalty
- rebalance_cost Γ 1000
Training Environment: Custom Gymnasium env with synthetic yield processes (Ornstein-Uhlenbeck for mean-reverting yields, GBM for prices).
π‘οΈ Risk Management
| Layer | Description | Trigger |
|---|---|---|
| Depeg Detection | Monitors USDY/USD and mETH/ETH pegs | USDY > 0.5%, mETH > 2% deviation |
| Volatility Guard | Reduces risky assets in high-vol regimes | ETH 30d vol > 80% |
| Concentration Limits | Enforces min/max position sizes | Any asset > 60% or < 5% |
| Smart Contract Risk | Weights by protocol audit status | Per-protocol risk scores |
| Drawdown Protection | Circuit breaker on losses | Portfolio DD > 10% |
| Emergency Exit | Flee to USDC on critical risk | Severe depeg or compounding risks |
π Smart Contracts
YieldRouterAgent.sol
- Records allocation decisions on-chain (audit trail)
- Enforces position limits and rebalance intervals
- Circuit breaker mechanism (OPEN/CLOSED/HALF_OPEN)
- Operator authorization for ERC-4337 wallets
AgentIdentity8004.sol (ERC-8004)
- Soulbound agent identity NFT (non-transferable)
- Capability registration and verification
- Attestation system (performance audits, security reviews)
- On-chain reputation scoring (0-10000 bps)
- Decision history references with outcome scoring
RiskRegistry.sol
- Per-asset risk parameters (max/min weights, depeg thresholds)
- Global risk parameters (max drawdown, slippage, gas limits)
- Depeg event tracking and resolution
- Allocation validation function
π Quick Start
# Clone
git clone https://huggingface.co/muthuk1/mantle-rwa-yield-router
cd mantle-rwa-yield-router
# Install dependencies
pip install -r requirements.txt
# Run demo (3 cycles, live data)
python scripts/demo.py
# Train RL agent (optional, uses synthetic data)
python scripts/train.py
# Run continuous agent
python -m agent.main --mode run --interval 3600 --capital 100000
# Run tests
pytest tests/ -v
Environment Variables
cp .env.example .env
# Edit .env with your configuration
π Project Structure
mantle-rwa-yield-router/
βββ agent/
β βββ main.py # 6-stage orchestrator pipeline
β βββ data_pipeline.py # Real-time yield & price data aggregation
β βββ rl_optimizer.py # PPO agent + Gymnasium environment
β βββ risk_manager.py # Multi-layer risk management
β βββ executor.py # Unsigned transaction builder
β βββ strategy_reporter.py # LLM strategy letter generator
βββ contracts/
β βββ YieldRouterAgent.sol # On-chain allocation router
β βββ AgentIdentity8004.sol # ERC-8004 agent identity NFT
β βββ RiskRegistry.sol # On-chain risk parameters
βββ telegram_bot/
β βββ bot.py # Telegram UI (/status, /yields, /risk)
βββ config/
β βββ constants.py # 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
π Key Design Decisions
Construct-Only Safety β The agent constructs unsigned transaction payloads but NEVER holds private keys. Execution requires external signing via ERC-4337 wallet or multisig.
Python-Native β Built in Python (not TypeScript) because RL/ML libraries (PyTorch, stable-baselines3, Gymnasium) are Python-native.
Fluxion DEX Primary β Fluxion is Mantle's native RWA-focused AMM, primary routing for RWA token swaps.
Risk-Parity Adaptive β Portfolio construction adapts to risk regimes. High volatility β more USDY (safe haven). Depeg β emergency exit to USDC.
On-Chain Audit Trail β Every allocation decision is recorded on-chain with content hashes linking to IPFS-stored strategy reports.
ERC-8004 + ERC-4337 β Agent identity via ERC-8004 (reputation, capabilities, attestations) + account abstraction via ERC-4337 (spending limits, session keys).
π Contract Addresses (Mantle Mainnet)
| Contract | Address |
|---|---|
| USDY (Ondo) | 0x5bE26527e817998A7206475496fDE1E68957c5A6 |
| mETH | 0xcDA86A272531e8640cD7F1a92c01839911B90bb0 |
| USDC | 0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9 |
| WMNT | 0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8 |
| Fluxion Router | 0x5628a59df0ecac3f3171f877a94beb26ba6dfaa0 |
| Agni Router | 0x319B69888b0d11cEC22caA5034e25FfFBDc88421 |
| Aave V3 Pool | 0x458F293454fE0d67EC0655f3672301301DD51422 |
π Hackathon Track
Mantle Turing Test Hackathon 2026 β Phase 2 "AI Awakening"
- Track: AI Γ RWA
- Focus: Autonomous AI agents managing tokenized real-world assets
- Key Technologies: RL optimization, ERC-8004 agent identity, Mantle L2
π License
MIT
Built with π€ for the Mantle Turing Test Hackathon 2026