All projects

nexis alpha

AI-powered DeFi risk monitoring terminal with on-chain alerts via Chainlink CRE Workflows

Risk & Compliance

What it is

Nexis is an institutional-grade DeFi risk monitoring terminal that computes a real-time Market Risk Index (MRI) from Chainlink Data Feeds, generates AI-driven intelligence reports via Chainlink Functions, and triggers automated threshold alerts via Chainlink Automation — all orchestrated through a CRE Workflow.

The problem: DeFi participants lack a unified, real-time view of cross-market risk. Liquidation cascades, stablecoin depegs, and whale movements happen fast — but existing dashboards show lagging, siloed data with no automated response layer. There is no "Bloomberg Terminal" for on-chain risk.

What Nexis does:

  • Aggregates BTC/USD and ETH/USD prices from Chainlink Data Feeds into a single composite Market Risk Index (0–100)
  • Classifies market state (Expansion, Distribution, Contraction, Panic, Recovery) based on volatility signals
  • Uses Chainlink Functions to call an LLM (GPT-4o-mini) that generates a structured AI intelligence report — including primary risk driver, 7-day outlook, and executive summary — delivered verifiably on-chain
  • Implements Chainlink Automation (checkUpkeep/performUpkeep) to auto-trigger on-chain alerts when risk crosses critical thresholds (≥80 = Critical, ≥60 = High)
  • The entire pipeline is defined as a CRE Workflow: cron trigger → Data Feeds → custom compute (MRI calculation) → Chainlink Functions (AI report) → OCR3 consensus → write to NexisRiskOracle contract

The frontend is a Next.js dashboard with 7 risk modules (Liquidity, Derivatives, Whale, Stablecoin, Systemic, Simulation, Replay) that reads live data from the on-chain oracle via wagmi hooks, with graceful fallback to mock data when the contract isn't deployed.

How it Works

Smart Contracts: Solidity 0.8.24, built and tested with Foundry (forge). The NexisRiskOracle contract consumes Chainlink AggregatorV3Interface for BTC/USD and ETH/USD price feeds, implements Automation-compatible checkUpkeep/performUpkeep, and stores AI-generated intelligence reports written by the CRE Workflow.

CRE Workflow: Defined in workflow. toml with 4 stages — (1) cron trigger every 5 min, (2) data_feeds_read for BTC/USD and ETH/USD from Chainlink, (3) custom_compute running compute-risk.js to calculate MRI from price data, (4) functions_call running ai-report.js that calls OpenAI via Chainlink Functions to generate risk intelligence. OCR3 consensus aggregates results before writing to the NexisRiskOracle on Sepolia.

Frontend: Next.js 16 (App Router), React 19, Tailwind CSS 4, Recharts for charts. Web3 integration via wagmi + viem reading from the Sepolia contract. Three custom hooks (use-risk-index, use-ai-report, use-alerts) poll the contract and listen for real-time RiskAlertTriggered events. The dashboard gracefully falls back to mock data when the oracle isn't deployed — a live green pulse indicator shows when data is coming from Chainlink.

Testing: 17 Foundry unit tests with MockV3Aggregator simulating Chainlink feeds. All tests pass.

Stack: Solidity, Foundry, Chainlink (Data Feeds, Automation, Functions, CRE Workflows), Next.js, wagmi, viem, TypeScript, Tailwind CSS.

Links

Created by

  • Rakyavara Artomily