XIRA Whitepaper
X-Layer Intelligence & Risk Analytics produces a single, auditable 0–100 risk score for each tracked tokenized equity (xStock) and commits it to X Layer as an attestation. This document describes the model exactly as implemented, so every claim below can be checked against the public code, the API, and the contract.
- contract
- 0xDe28a2EEc95E3E9Dae6311966Ce2d8B45Db3d41E
- chain
- 196 · X Layer
- assets tracked
- 50
- data
- Yahoo quotes + Finnhub news / simulated
1. Problem
Tokenized equities carry a data problem: the token trades on a chain, but the risk that matters is priced in a market elsewhere. A holder of an xStock cannot read one credible, dated number about how volatile, crowded, or news-sensitive that position is, and no off-chain vendor produces a number that can be verified without trusting them.
The mismatch is structural: xStocks trade 24/7 on-chain, while the underlying equity settles during market sessions, so volatility and liquidity risk accumulate in hours the price ticker never shows. The most active real-world use, lending against the token as collateral, under prices those hours entirely: a venue can quote a position but cannot score how risky it is to hold.
XIRA's answer is not another dashboard look. It is a pipeline whose output must survive a specific test: take the API response, recompute the evidence hash, and compare it to the bytes32 the oracle signed into the contract. The number and the proof move through the same pipeline.
| RWA problem | How XIRA answers it |
|---|---|
| Price alone is insufficient | A multi-factor 0–100 risk score built from momentum, volatility, sentiment, volume anomaly, and liquidity, with a per-factor breakdown and a human-readable reason. |
| Risk data is fragmented and off-chain | One compact, queryable attestation per market (score, confidence, factors, evidence hash) read by a single contract call or API read. |
| Agents cannot reliably use RWAs | Machine-readable attestations plus MCP tooling: one asset, the whole board, or full history. No scraping or opaque vendor API. |
| Low DeFi utilization of tokenized equities | Collateralized lending is xStocks' most active real-world use: depositing a position to borrow stablecoins without selling it. Lending venues are price-safe but risk-blind; a signed 0–100 risk score is the input their collateral logic is missing. |
| No transparency behind the number | Every meaningful score change is signed to X Layer with a replayable evidence hash; the number and its proof travel together. |
The scope is deliberate: XIRA does not attempt legal ownership, custody, or compliance. It closes the intelligence-and-usability gap, turning price-tracked tokens into assets a vault or agent can assess and use with a number it can verify.
XIRA is also deliberately single-chain. Cross-chain protocols such as Chainlink CCIP solve the movement problem: how assets and data travel between networks. XIRA solves the intelligence problem where they arrive: continuous, explainable risk context for the assets trading on X Layer. The two stack: a tokenized equity can reach X Layer over CCIP, and XIRA keeps publishing risk intelligence about it once it is there.
2. Architecture
1. Collect
Price, volume, 52-week range, and 20-day average volume per underlying ticker (Yahoo quotes & OHLCV + Finnhub news rotation when live mode is enabled; a deterministic bucket-seeded simulator otherwise).
2. Score
Each of the five factors is computed in the risk frame (0 = minimal risk, 100 = severe) and combined using fixed weights into a composite 0–100 risk score.
3. Attest
The result is hashed into an evidence fingerprint (SHA-256 over canonical JSON) and submitted to the XIRA contract on X Layer via batchUpdateAttestations or updateAttestation.
4. Verify
Anyone can read the on-chain score with getScore or getLatestAttestation, and replay the evidence hash from the API payload against the stored record.
3. The risk model
The composite risk score is the weighted sum of five normalized factor scores. Every factor measures a distinct failure mode for a tokenized position; a high factor score always means more risk.
The five factors map onto four risk dimensions identified in RWA research: momentum and volatility together cover fast market movement (30% combined), volume anomaly and liquidity proxy cover the liquidity and market-quality dimension (35% combined), sentiment covers information flow (20%), and holder concentration, an on-chain HHI over balances, is the fourth dimension, planned as the next factor once the X Layer indexer is wired in (see roadmap). Weights are chosen so the most immediately observable risks dominate, while noisier signals stay bounded.
| Factor | Weight |
|---|---|
| Momentum | 0.25 |
| Volatility | 0.2 |
| Sentiment | 0.2 |
| Volume Anomaly | 0.2 |
| Liquidity Proxy | 0.15 |
Composite score
risk = round(Σ weightᵢ × scoreᵢ), scoreᵢ ∈ [0, 100]
Weighted sum, rounded, then mapped to a band:
Anomaly and confidence
An attestation is flagged anomalous when any factor ≤ 15 or two or more factors ≤ 25. Confidence is a deterministic function of the result:
confidence = clamp(30, 100, 40 + healthy × 10 + (80 − risk) × 0.15)
where healthy counts factors scored at 50 or above. The lower clamp never binds (minimum reachable is 37), so confidence reports genuine model agreement rather than a floor artifact.
4. Attestation and verification
Each attestation stores: symbol, composite score, confidence, the five factor scores with weights and descriptions, a plain-language explanation, model version, data source, and freshness in milliseconds. The evidence fingerprint is:
hash = sha256( json.dumps({
"symbol": ..., # e.g. "NVDAx"
"score": ...,
"confidence": ...,
"factors": [ {name, label, score, weight, description}, x5 ],
"data_source": ... # "finnhub" | "mock"
}, sort_keys=True) )The backend submits updateAttestation(asset, score, confidence, evidenceHash, modelVersion, anomaly, anomalyReason) to the XIRA contract at 0xDe28a2EEc95E3E9Dae6311966Ce2d8B45Db3d41E. The contract reverts on out-of-range values and only accepts writes from the owner or an authorized updater address. On-chain, anyone can read the latest attestation or just the score:
- getScore(asset)latest uint8 score
- getScoreBatch(assets[])many scores, one call
- getLatestAttestation(asset)score, confidence, hash, timestamp, version, anomaly
Verification procedure: fetch /api/attestations/{symbol}, recompute the hash from the response fields with the canonical serializer, then compare against the stored evidenceHash on-chain and the transaction in the explorer.
5. Data pipeline
In live mode the fetcher pulls daily price history, volume, 52-week range, and market cap per underlying from Yahoo Finance and scores recent headlines with a positive/negative keyword classifier. All data is cached in memory for five minutes, so repeated reads are served from cache and the underlying feeds are not hammered. If a feed fails or falls behind, the engine serves a deterministic simulator and marks data_source accordingly. The attestation always states which world the number came from.
Publication follows a heartbeat plus deviation rule: every XIRA_HEARTBEAT_MINUTES (default 30) the backend re-scores each tracked market and writes a new on-chain attestation only if the score moved by at least XIRA_DEVIATION_THRESHOLD points (default ±3). There is no tx on a flat market. All tracked assets are passed in one pass, and simulated (non-live) data is never published on-chain, so every attestation transaction corresponds to a real score. The first pass runs 60s after startup, so the oracle self-publishes shortly after a cold start without waiting for traffic.
Failed or stale reads never manufacture risk: every factor returns the neutral 50 when its inputs are missing, keeping the composite near 50 during an outage instead of spiking.
6. History and trail
Every computed attestation is appended to an SQLite store (with a bounded in-memory buffer of the most recent 50 per symbol). The /api/attestations/{symbol}/history endpoint replays that trail, so score deltas and the exact inputs that produced each number can be audited after the fact.
7. Validation of the logic
Each invariant below is checked against the running implementation (backend services/ai_engine.py, routers, and the deployed Solidity contract), not against the design document.
Weights are a partition of 1.0
0.25 + 0.20 + 0.20 + 0.20 + 0.15 = 1.00, so the composite is guaranteed to stay within the [0, 100] range of the factor scores.
passComposite bounded and level bands exhaustive
risk = round(Σ weightᵢ × scoreᵢ) with every factor score clamped to 0–100. Bands cover the full range: ≤20 LOW, ≤40 MODERATE, ≤60 ELEVATED, ≤80 HIGH, >80 CRITICAL.
passConfidence is computable after the fact
confidence = clamp(30, 100, 40 + settled × 10 + (80 − risk) × 0.15) with settled = number of factors ≤ 50.
passAnomaly rule catches elevated risk blowouts
anomaly = (≥1 factor ≥ 85) OR (≥2 factors ≥ 75). Identifies volatility blowouts, volume spikes, and liquidity crunches consistently.
passEvidence hash is replayable
hash = SHA-256(JSON.sort_keys({symbol, score, confidence, factors, data_source})). Anyone with an API response can recompute the hash and compare it on-chain.
passOn-chain bounds enforced twice
The contract reverts on score > 100 or confidence > 100 (and on zero asset address), and only the owner or authorized updater addresses can write. These are the same bounds enforced by the engine.
passVolume factor is banded with small, honest seams
r ∈ [0.6, 1.3] maps flat to 50. The linear branches produce small steps at the band seams: 50→40 entering r < 0.6, 50→53 entering r > 1.3, and a sharper 32.5→22 drop across the r = 0.3 boundary. The 0.3 boundary is intentional (thin-volume liquidity gap), the other two are cosmetic (~3–10 points) and never alter a level band for borderline assets.
pass with noteEmpty or malformed data degrades to neutral, never to extremes
Every factor returns 50 ('insufficient data') when its inputs are missing, so a data outage cannot manufacture a critical risk score. The composite then sits near 50 and the attestation states the data source explicitly.
pass (resilience)8. Known limitations
- The current model is heuristic-only: the OpenAI path exists in the engine signature but analyze() always runs the deterministic factor model. Scores are fully reproducible given the same inputs.
- The evidence hash does not include timestamp, model version, or the anomaly flag. In v1 the on-chain block timestamp is the source of truth for time; hashing the full payload (modelVersion included) is planned so a later model revision is provable.
- Sentiment is an English keyword classifier and a price-proxy fallback. It measures headline tone, not reported fundamentals or news quality.
- The contract stores one latest attestation per asset. There is no per-asset on-chain history and no batch root, so cross-asset proofs use getScoreBatch (reads) rather than a merkle commitment.
- Attestations are timestamped by the block they land in; on a live network, the oracle key custody and gas model must stay funded.
9. Roadmap
- Include modelVersion and anomaly in the hashed evidence payload, and add a public verify() that recomputes and compares the fingerprint on-chain.
- Per-asset on-chain ring history (a bounded rolling window of attestations per token) and a merkle root for the full market snapshot.
- Backtest harness: replay the factor model over historical data and publish its calibration statistics as part of each attestation.
- Staked oracle + challenge window: a watcher can submit a corrected evidence hash; slashing mechanics are a future addition.
- Holder-concentration factor: an on-chain HHI over holder balances per xStock to catch crowded, fragile positions that price data alone misses.
Roadmap items are plans, not shipped behavior.
Disclaimer
XIRA provides informational risk analytics on X Layer. Scores are model outputs, not investment advice, not a recommendation to buy or sell, and not a guarantee of future performance. Tracking is configured across 50 tokenized equity assets. Nothing in this document is an offer of securities. See the Terms of Use for full terms.