dev-analyshd/trion-behavioral-oracle-mantle
GitHub: dev-analyshd/trion-behavioral-oracle-mantle
Stars: 1 | Forks: 0
# TRION Behavioral Oracle — Mantle Intelligence Suite
[](LICENSE)
[](https://mantle.xyz)
[](#architecture)
[](#)
[](https://dorahacks.io/hackathon/mantleturingtesthackathon2026)
## What Is TRION
TRION is a multi-chain **behavioral truth oracle**. Where Chainlink, Pyth, and Band aggregate CEX prices and deliver them faster — faster pipes carrying the same compromised water — TRION derives truth from the actual record of what every entity did on every chain, stripped of manipulation, weighted by coherence, bounded by liquidity health.
**The Inverted Truth Hierarchy:**
Layer 4 Retail behavior (most manipulable)
Layer 3 DeFi on-chain flows ↑
Layer 2 Oracles (band-aid) ↑
Layer 1 CEX prices (root problem) ↑
─────────────────────────────────────────────────
Layer 0 TRION behavioral ground truth ← we are here
Every Mantle transaction flows through TRION's Rust indexer (`trion-evm`, chain ID 5000), producing a canonical 93-byte Behavioral Hash per transaction: `entity(32) || event(1) || magnitude(8) || context(8) || timestamp(8) || chain_id(4) || block_hash(32)`. These hashes accumulate in FAISS (11,000–15,000+ 128-dimensional vectors), enabling behavioral pattern recognition that CEX price feeds cannot provide.
## Mantle Turing Test Hackathon 2026 — Phase 2: AI Awakening
This repository contains five production-quality track submissions, each powered by a single unified behavioral intelligence engine.
| # | Track | Module | Key Capability |
|---|-------|--------|----------------|
| 1 | AI Trading & Strategy | `track-1-trading-signal-engine/` | BTV + MF → BUY/SELL/HOLD/AVOID + Kelly fraction |
| 2 | AI Alpha & Data | `track-2-alpha-sentinel/` | Real-time Telegram/Discord anomaly alerts |
| 3 | AI × RWA | `track-3-rwa-risk-monitor/` | USDY/mETH risk tiers + yield recommendations |
| 5 | AI DevTools | `track-5-devtools-auditor/` | Behavioral contract audit CLI + web UI |
| 6 | Agentic Wallets & Economy | `track-6-agentic-execution-gate/` | ERC-8004 reputation + Byreal Skill |
## Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ Mantle DeFi: Merchant Moe · Agni Finance · Fluxion · USDY · mETH │
└──────────────────────────┬──────────────────────────────────────────┘
│ every transaction
┌──────────────────────────▼──────────────────────────────────────────┐
│ trion-evm Rust Indexer (Chain ID 5000) │
│ Per-tx canonical BH: entity||event||mag||ctx||ts||chain||blockhash │
│ → FAISS ANIMA (128-dim behavioral vectors, 15,000+ indexed) │
└──────────────────────────┬──────────────────────────────────────────┘
│ REST
┌──────────────────────────▼──────────────────────────────────────────┐
│ TRION Oracle API (Flask, port 5000) — 139 endpoints │
│ BTV · MF fingerprint · coherence · planes · agent safety │
│ /api/v1/signal /api/v1/security /api/v1/audit /api/v1/agent │
└────┬───────────┬─────────────┬───────────────┬────────────┬─────────┘
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
Track 1 Track 2 Track 3 Track 5 Track 6
Trading Alpha RWA Risk DevTools Agentic
Signals Sentinel Monitor Auditor ExecutionGate
Bot + CLI + Web Byreal Skill
Dashboard ERC-8004 NFT
│ │ │
└───────────────┴────────────┘
│
┌───────────────▼──────────────────────────┐
│ On-chain: TRIONMantleExecutionGate.sol │
│ TRIONAgentReputation.sol (ERC-8004) │
│ Mantle Mainnet (Chain ID 5000) │
└──────────────────────────────────────────┘
## Deployed Contracts
### Mantle Mainnet (Chain ID 5000)
| Contract | Address | Explorer |
|----------|---------|----------|
| TRIONMantleExecutionGate | `0xA85B49C73B5710d9ddB1CB5a94c52D0F33c4199b` | [View](https://mantlescan.xyz/address/0xA85B49C73B5710d9ddB1CB5a94c52D0F33c4199b) |
| TRIONAgentReputation (ERC-8004) | Deploy via `scripts/deploy_reputation.js` | — |
### 0G Galileo Testnet (Chain ID 16602)
| Contract | Address |
|----------|---------|
| TRIONOracleV3 | `0x0471B2BE25c2eBbAe7FAc17383F1692979F0A87C` |
| TRIONExecutionGate | `0xDB5910Dc6CfD219D00F64be1F23DA0289901356d` |
## Quick Start
### Prerequisites
- TRION Oracle API running on `localhost:5000` (see [trion-core](https://github.com/dev-analyshd/trion-core))
- Python 3.11+ with `uv` or `pip`
- Node.js 20+ for Track 6
git clone https://github.com/dev-analyshd/trion-behavioral-oracle-mantle
cd trion-behavioral-oracle-mantle
cp .env.example .env
# edit .env with your API keys
## Track 1 — AI Trading & Strategy
**Manipulation-stripped price signals for Mantle DeFi.**
TRION's Behavioral True Value formula:
BTV = P_ref × Ω × (1 − MF_discount) × C_weight × NL_weight
Where:
Ω = tanh(chains/10) × D_eff (37-chain consensus weight)
MF_discount = 2.5% + MF_score × 35% (manipulation stripped out)
C_weight = 0.95 + 0.07 × C(t) (coherence weighting)
NL_weight = 0.95 + 0.07 × NL (natural liquidity)
Signal logic: **BUY** when BTV < market × 0.95 AND MF clean AND C(t) ≥ 0.60.
Position sizing: Kelly fraction × coherence × (1 − MF_score).
cd track-1-trading-signal-engine
pip install -r requirements.txt
python trion_trading_signals.py --assets ETH,BTC,MNT --once
python trion_trading_signals.py --run --interval 60
## Track 2 — AI Alpha & Data (Alpha Sentinel)
**Real-time behavioral anomaly detection for Mantle DeFi.**
Monitors Merchant Moe, Agni Finance, Fluxion, USDY, mETH — fires to Telegram/Discord when TRION detects:
- 🔄 **WASH** — cyclic flow ratio > 0.60 with < 5 counterparties
- 👥 **SYBIL** — funding concentration anomaly
- ⚡ **MEV** — sandwich / front-run extraction rate spike
- 📈 **PUMP** — synchronized buy ratio > 0.85
- 📊 **FAKE_VOL** — volume entropy below baseline
- 🏛️ **GOV_CAPTURE** — HHI > 2500 governance concentration
cd track-2-alpha-sentinel
pip install -r requirements.txt
# Configure alerts (optional — stdout if unset)
export TELEGRAM_BOT_TOKEN=your_token
export TELEGRAM_CHAT_ID=your_chat_id
export DISCORD_WEBHOOK_URL=your_webhook
# Start the sentinel bot
python mantle_alpha_sentinel.py --threshold 0.35 --interval 30
# Start the live dashboard (separate terminal)
python dashboard.py
# → http://localhost:5010
**Dashboard preview:** Live MF score table + alert history for all Mantle protocols.
## Track 3 — AI × RWA
**Dynamic risk monitoring for USDY, mETH, and Mantle RWA assets.**
Risk classification:
SAFE — C(t) ≥ 0.70 | MF < 0.25 | NL > 0.70 → HOLD/ACCUMULATE
ELEVATED — C(t) ≥ 0.55 or MF ≥ 0.25 → HEDGE (50% allocation)
HIGH — C(t) < 0.45 or MF ≥ 0.50 → REDUCE (25% allocation)
CRITICAL — MF ≥ 0.70 or coherence collapse → EXIT
Peg deviation from Behavioral True Value is tracked for stablecoins (USDY, USDT, USDC). If `|BTV − $1.00| / $1.00 ≥ 2%` → automatic HIGH tier escalation.
cd track-3-rwa-risk-monitor
pip install -r requirements.txt
python trion_rwa_risk_monitor.py --assets usdy,meth --once
python trion_rwa_risk_monitor.py --run --interval 60 --report json
## Track 5 — AI DevTools (Behavioral Contract Auditor)
**Behavioral contract audit CLI + web UI for Mantle.**
Unlike static analysis (Slither, MythX), TRION audits the *behavioral record* of a contract and its deployer across 37 chains:
- **20-point vulnerability scan** via TRION's Living Security CRISPR library
- **8 historical attack pattern matches**: Harvest, Beanstalk, Mango, Jimbos, Euler, Curve, Ronin, Wormhole
- **Deployer cross-chain reputation** — was this deployer involved in exploits on other chains?
- **Risk tier** output: SAFE / LOW / MEDIUM / HIGH / CRITICAL
cd track-5-devtools-auditor
pip install -r requirements.txt
# CLI — outputs to terminal
python mantle_contract_auditor.py 0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9
# CLI — HTML report
python mantle_contract_auditor.py 0x... --format html --output report.html
# Web UI
python mantle_contract_auditor.py --serve --port 5011
# → http://localhost:5011
## Track 6 — Agentic Wallets & Economy
**TRION ExecutionGate as a Byreal Skill with ERC-8004 agent reputation.**
Every AI agent action on Mantle is validated through TRION's 5-gate behavioral safety pipeline before execution. The agent's ERC-8004 reputation score is updated with each interaction.
**5-gate pipeline:**
1. **Coherence Gate** — C(t) ≥ threshold (structural silence check)
2. **Manipulation Gate** — MF_score < block threshold
3. **Liquidity Gate** — Natural Liquidity NL = LD·LO·LC·LS > minimum
4. **Archetype Gate** — behavioral archetype not in hostile list
5. **Systemic Risk Gate** — SYSTEMIC_RISK signal not active
**Trust tiers (ERC-8004 extended):**
| Tier | Score | Interactions | Benefits |
|------|-------|-------------|---------|
| BOOTSTRAP | 0–199 | any | Standard limits |
| ACTIVE | 200–499 | ≥10 | Elevated tx limits |
| PRIME | 500–799 | ≥100 | Reduced gas, priority |
| APEX | 800+ | ≥500 | Maximum trust, governance access |
cd track-6-agentic-execution-gate
npm install
# Run demos
npm run demo:check
npm run demo:reputation
npm run demo:audit
npm run demo:alerts
# Or directly:
node trion_byreal_skill.js check demo-agent-001 SWAP 0x4515... 10000
node trion_byreal_skill.js reputation 0xYourAgentAddress
node trion_byreal_skill.js audit 0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9
**Byreal Skill registration:**
import TRIONSkill from "./trion_byreal_skill.js";
// Register with Byreal Skills CLI
const result = await TRIONSkill.invoke("trion.checkExecution", {
agentId: "my-agent-001",
actionType: "SWAP",
entityId: "0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9",
valueUsd: 10000,
});
## Shared Client SDK
All tracks import from `shared/trion_client.py` — a typed, retry-safe Python client for all 139 TRION Oracle API endpoints.
from shared.trion_client import TRIONClient, MANTLE_PROTOCOLS
client = TRIONClient(base_url="http://127.0.0.1:5000")
# Five-plane behavioral coherence signal
sig = client.signal("0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9")
# Manipulation fingerprint
mf = client.mf_severity("0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9")
print(f"MF Score: {mf['mf_score']} Severity: {mf['severity']}")
# Behavioral True Value
btv = client.btv("ETH", "USD")
# Agent safety validation (5-gate pipeline)
result = client.agent_validate(
agent_id="byreal-agent-001",
action_type="SWAP",
entity_id="0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9",
value_usd=10000,
chain_id=5000,
)
## Chain Coverage: 37 Chains
TRION indexes Mantle natively as one of 14 EVM chains via `trion-evm`. The 37-chain behavioral graph provides cross-chain context that single-chain analytics cannot:
| Cluster | Chains |
|---------|--------|
| EVM Mainnet | ETH · ARB · BASE · OP · BNB · POLYGON · AVALANCHE · **MANTLE** · LINEA · SCROLL · CELO · GNOSIS · HASHKEY · ZG |
| EVM Testnet | ARB Sepolia · ETH Sepolia · BASE Sepolia · OP Sepolia · HASHKEY Sepolia |
| SVM | Solana |
| Native VM | NEAR · TON · StarkNet · Polkadot |
| Extended VM | Bitcoin · Cosmos · Kava · Injective · SEI · dYdX · Initia · Aptos · SUI · TRON · Pi · Movement · 0G |
## Five Behavioral Planes
| Plane | Symbol | What It Measures |
|-------|--------|-----------------|
| Physical | Φ | On-chain entropy, tx velocity, MEV, liquidity patterns |
| Mental | M | Predictive accuracy, Genesis Inference, valuation coherence |
| Spiritual | Σ | Validator diversity-weighted BFT consensus quality |
| Conscious | K | Governance participation, stake-weighted human signal |
| ANIMA | A | Pre-manifestation — off-chain narrative, sentiment, intent |
**Five-plane coherence:** `C(t) = α·Φ + β·M + γ·Σ + δ·K + ε·A`
Signal emits only when `C(t) ≥ Θ(t)`. Below threshold: **Structured Silence** (meaningful absence of signal).
## Why TRION Instead of LLM-Based Analytics
| Capability | LLM Summarizer | TRION |
|-----------|----------------|-------|
| Source of truth | On-chain text + prices | Per-tx behavioral hashes |
| Manipulation resistance | Low (mirrors CEX data) | Native (MF discount applied) |
| Cross-chain context | Single chain | 37 chains, homomorphic mapping |
| Structured silence | No | Yes — absence of signal is meaningful |
| Agent safety gate | No | 5-gate behavioral pipeline |
| Cryptographic integrity | No | Dual-strand SHA3 + PQC |
| Historical attack memory | No | CRISPR library: 8 known DeFi attacks |
## TRION Core Repository
The full TRION protocol, 139 API endpoints, 13 Rust crates, FAISS ANIMA engine, and all 84 whitepaper formulas live at:
**[github.com/dev-analyshd/trion-core](https://github.com/dev-analyshd/trion-core)**
## License
MIT — This knowledge belongs to everyone.
**Author & Originator:** Hudu Yusuf (Analys)
**Hackathon:** Mantle Turing Test Hackathon 2026 — Phase 2: AI Awakening
**Submission tag:** `#MantleAIHackathon`