命令 Meirei
meirei命令
X Layer Mandate Agent
Docs/Internals

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).

Rendered Flow Diagram

Full End-to-End System Topology

OKX X Layer (Chain 196)
01. INGESTIONChat / Web

Client Channels

  • • Telegram Bot (@MeireiXLayerBot)
  • • WhatsApp Cloud API
  • • Trading Web Terminal
  • • OKX Wallet Bridge
02. SECURITYZero Database

In-Memory Gateway

  • • SHA-256 Identity Anchor
  • • Token-Bucket Rate Limiter
  • • Idempotency Nonce Guard
  • • /freeze Circuit Breaker
03. MANDATEOnchain OS

Optimizer & 2FA

  • • Natural-Language NLP
  • • Convex Diff Engine
  • • 6-Digit OTP / WebAuthn
  • • Constant-Time Timing Check
04. EXECUTEX Layer 196

OKX DEX Router

  • • 8 Allowlisted xStocks
  • • Multi-Pool Aggregation
  • • Sponsored Paymaster Gas
  • • Real-Time Tx Explorer Link
Direction: Natural Language Prompt → In-Memory 2FA → Atomic OKX DEX Swaps → Verified X Layer Receipt100% Non-Custodial

1. Autonomous Execution Pipeline

When an instruction is submitted, the Meirei state engine executes a synchronous four-stage pipeline:

STAGE 01

Intent Parsing

Normalizes freeform natural language text into structured asset weights and single-stock trade legs.

STAGE 02

On-Chain State Query

Queries live ERC-20 balances on X Layer via RPC node and fetches OKX DEX Aggregator depth.

STAGE 03

2FA Challenge Gate

Intercepts execution. Requires verification of 6-digit challenge before granting signed authorization token.

STAGE 04

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:

minimize: Count(legs) subject to: sum(w_target_i) = 1.0 w_target_i <= max_single_weight (default: 0.35) | w_target_i - w_current_i | >= drift_tolerance (default: 0.05) slippage <= 0.01 (1.00% max bound)

Any sleeve allocation exceeding max_single_weight automatically cascades into the liquid cash reserve asset (USDG).

3. Zero-Database In-Memory State & Cryptographic Enclaves

Meirei is engineered with a strict zero-database requirement. All user identity derivation, rate-limiting buckets, idempotency hashes, and 2FA challenge nonces reside in deterministic in-memory caches and client-side WebAuthn hardware enclaves.

  • Deterministic User Profiles: User identities are derived from verified email and messaging channel identifiers using SHA-256 digests.
  • Zero Server-Held Private Keys: Transactions are signed client-side via WebAuthn hardware passkeys or user-connected Web3 wallets.
  • Live On-Chain State: Balances, allowances, and swap execution receipts are queried and verified directly against OKX X Layer Mainnet (Chain ID 196).
  • In-Memory Idempotency: Webhook deliveries and trade requests maintain short-lived cryptographic hash sets to prevent duplicate operations.

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>).