System Internals & Rendered Architecture
Visual teardown of the Meirei on-chain execution pipeline, convex rebalance optimizer, and OKX DEX routing on X Layer (chain 196).
Full End-to-End System Topology
Client Channels
- • Telegram Bot (@MeireiXLayerBot)
- • WhatsApp Cloud API
- • Trading Web Terminal
- • OKX Wallet Bridge
In-Memory Gateway
- • SHA-256 Identity Anchor
- • Token-Bucket Rate Limiter
- • Idempotency Nonce Guard
- • /freeze Circuit Breaker
Optimizer & 2FA
- • Natural-Language NLP
- • Convex Diff Engine
- • 6-Digit OTP / WebAuthn
- • Constant-Time Timing Check
OKX DEX Router
- • 20 Allowlisted xStocks & ETFs
- • Multi-Pool Aggregation
- • Sponsored Paymaster Gas
- • Real-Time Tx Explorer Link
1. Autonomous Execution Pipeline
When an instruction is submitted, the Meirei state engine executes a synchronous four-stage pipeline:
Intent Parsing
Normalizes freeform natural language text into structured asset weights and single-stock trade legs.
On-Chain State Query
Queries live ERC-20 balances on X Layer via RPC node and fetches OKX DEX Aggregator depth.
2FA Challenge Gate
Intercepts execution. Requires verification of 6-digit challenge before granting signed authorization token.
Atomic DEX Broadcast
Executes swaps via OKX Aggregator router on X Layer, settling into USDG with protocol fee attribution.
2. Portfolio Optimization Formalism
Given a current portfolio vector W_c and a mandate target vector W_t, the rebalance optimizer minimizes the total number of swap transactions while observing maximum concentration constraints:
Any sleeve allocation exceeding max_single_weight automatically cascades into the liquid cash reserve asset (USDG).
3. Dual State Architecture: Ephemeral Redis & Durable Supabase
Meirei cleanly separates ephemeral high-frequency security state from durable user identity records:
- Ephemeral Security State (Upstash Redis): Account freeze flags (
SET freeze:{profileId} 1), atomic idempotency locks (SET idem:{hash} 1 NX EX 86400), sliding-window rate limit buckets, and HMAC-SHA256 OTP challenges bound to calldata digests. - Durable Identity & Audit State (Supabase): Persists the non-financial mapping between verified chat handles (WhatsApp, Telegram, email) and public X Layer EVM wallet addresses, alongside immutable transaction execution audit logs.
- Zero Server-Held Private Keys: Transactions are signed client-side via standard EOA wallets (OKX Wallet, MetaMask). Server-held private keys are strictly prohibited.
- Live On-Chain State: Balances, allowances, and swap execution receipts are queried and verified directly against OKX X Layer Mainnet (Chain ID 196).
4. Emergency Panic Circuit Breaker
If a client detects compromised communication credentials, they can broadcast the panic freeze directive (/freeze). This triggers an immediate in-memory freeze for that profile, revoking all active 2FA authorization tokens and rejecting any pending mandate execution until manual identity unfreeze is verified via the 6-digit recovery code (/unfreeze <code>).