Skip to content

Repository files navigation

๐ŸŒ’ Umbra

The autonomous financial circuit breaker for DeFi. Detects systemic risk (liquidity crises, depegs) through a quantitative model, and automatically evacuates users' funds into a safe stablecoin โ€” before the pool collapses.

โ–ถ Live demo: umbra-ten-iota.vercel.app ยท Risk terminal: /terminal

๐Ÿ† ETH Global Lisbon 2026 โ€” Tracks: The Graph ยท 0G ยท (Uniswap v3 execution)

๐Ÿ“„ Research paper โ€” full risk-score methodology: PDF ยท Word. Single source (paper/content.py), regenerable via python paper/build_paper.py (Word) and python paper/build_pdf.py (PDF).

๐ŸŽค Pitch deck (math, on-brand 16:9): paper/Umbra_Slides.pdf โ€” python paper/build_slides.py.


๐ŸŽฏ The problem

When a DeFi pool goes into crisis (depeg, liquidity flight), the average user realizes it too late: by the time they understand what's happening, liquidity has evaporated and exit slippage has exploded. The losses of March 2023 (USDC depeg), Terra/UST, stETHโ€ฆ run into the billions.

๐Ÿ’ก The solution

An on-chain circuit breaker that continuously monitors a Risk Score (CBRI, 0โ†’100) and triggers an emergency evacuation as soon as the optimal threshold ฯ„* is crossed.

  • Quant model (CBRI) โ€” 3 signals aggregated via Noisy-OR: liquidity-flight speed, pool imbalance, price divergence.
  • Optimal threshold ฯ„* โ€” proven by backtesting on real crashes: the exact point that maximizes net funds saved.
  • Aligned business model โ€” a success fee charged only on the loss avoided. We only earn if the user wins.

๐Ÿ—๏ธ Architecture & Sponsors

LayerTechRole
Data ๐Ÿ†The GraphHistorical + real-time Uniswap v3 pool data (tick-level swaps, liquidity, price)
AI / Infra ๐Ÿ†0GDecentralized storage & traceability of the model and risk scores
ExecutionUniswap v3Direct on-chain evacuation swap (QuoterV2 + SwapRouter02, no API)

๐Ÿ† = targeted tracks. Uniswap = data infra + execution (we are not applying to their track).

Backtest vs. production rigor: the backtest simulates execution against historical on-chain liquidity (the pool's real physics via The Graph); live execution reads an on-chain Uniswap QuoterV2 quote then swaps via SwapRouter02. We price the past with physics, and execute the present at the pool's real price.

๐Ÿ“‚ Structure

umbra/
โ”œโ”€โ”€ quant-backtest/ # Python โ€” the brain (CBRI model + backtesting)
โ””โ”€โ”€ live-execution/ # TypeScript โ€” the muscle (Uniswap execution + 0G traceability)

๐Ÿ“Š Backtest result โ€” USDC depeg (SVB, March 11, 2023)

Replayed on 48,066 real swaps ($5.57B of volume) extracted via The Graph, for a $1M USDC position.

Optimal ฯ„*66 / 100 (optimal plateau [10โ€“66], 0 false positives in calm markets)
TriggerMar 10, 14:10 UTC โ€” 17h before the bottom, USDC still at $1.0000
Depeg bottom (no action)$0.8726 โ†’ position worth $872,595
๐Ÿ’ฐ Funds saved$126,900 (12.7%) โ€” 10% success fee = $12,690

The cost of waiting (every CBRI point you wait = money lost):

ฯ„ thresholdExitPriceSlippageSaved
10โ€“66 (ฯ„*)Mar 10, 14:10$1.00005 bps$126.9k
67โ€“72Mar 11, 00:15$0.989253 bps$111.4k
73โ€“98Mar 11, 01:00$0.972691 bps$91.1k
99Mar 11, 03:00$0.9371657 bps$2.9k

The active liquidity of the USDC/USDT pool collapses by ร—23,000,000 during the crash โ†’ exit slippage explodes. Exiting at ฯ„* = near free; waiting for confirmation = a liquidity wall.

CBRI vs priceFunds saved vs ฯ„Slippage explosion

๐Ÿงฎ The model: CBRI (Composite Break-Risk Index)

3 sub-signals normalized by a sigmoid, aggregated via a weighted Noisy-OR (a breaker trips if a single signal turns red):

CBRI = 100 ยท (1 โˆ’ โˆแตข (1 โˆ’ wแตขยทsแตข)) sแตข = ฯƒ(ฮฑแตขยท(xแตข โˆ’ thresholdแตข))
SignalMeasureRoleSource
Liquidity flightLP withdrawal speed (mintsโˆ’burns / TVLยทh)early warningswaps + mints/burns
Order-Flow Imbalanceflow unidirectionalitydiagnostic (w=0 here, non-discriminant)swaps
Divergence / depeg|1 โˆ’ USDC price|confirmationUSDC/USDT stable pool

๐Ÿ”’ Decentralized traceability (0G)

A circuit breaker you have to trust blindly is worthless. Each risk score and the exact model that produced it are frozen into an attestation, whose 0G Merkle root hash is published on 0G decentralized storage. Anyone can re-download the artifact and verify the hash โ†’ auditable and tamper-proof scoring.

cd live-execution && npm run publish0g
# ๐ŸŒณ 0G Storage root hash: 0xc9926d168f786c07df854fa4774528396abee05b57a13fe260f0a64a1d47f90b

The 0G root hash is computed locally (no wallet required). The actual upload to the 0G testnet only needs a funded wallet (faucet).

๐Ÿš€ Getting started

cp .env.example .env # THEGRAPH_API_KEY (required) ยท RPC_URL (optional, public default)cd quant-backtest && pip install -r requirements.txt
python thegraph_client.py # โ‘  extract the crash data (The Graph)
python features.py # โ‘ก compute the CBRI
python backtest.py # โ‘ข backtest ฯ„* + figurescd ../live-execution && npm install
npm run publish0g # โ‘ฃ anchor model+scores on 0G (traceability)
npm run demo # โ‘ค replay the depeg โ†’ the breaker evacuates via Uniswap v3

๐Ÿงช Tests

29 unit tests covering the core logic (model, slippage, ฯ„* selection, execution):

# Quant (Python) โ€” 21 tests: sigmoid, v3 price, Noisy-OR, slippage, ฯ„*, funds savedcd quant-backtest && pip install -r requirements-dev.txt && python -m pytest
# Execution (TS) โ€” 8 tests: position conversion, slippage bps, minOut, feed parsingcd live-execution && npm test

Full-stack E2E โ€” chains the entire pipeline (data โ†’ CBRI โ†’ backtest ฯ„* โ†’ 0G anchoring โ†’ Uniswap evacuation) and verifies every step (14 checks):

./e2e.sh # ๐ŸŸข Full chain operational โ€” dress rehearsal before the demo

Plus 7 quant e2e tests on real data (pytest -m e2e) validating the pitch numbers (ฯ„*=66, ~$127k saved, bottom $0.8726).


Hackathon MVP โ€” public architecture assumed (no privacy/MEV layer in this scope).

About

๐ŸŒ’ Umbra โ€” autonomous financial circuit breaker for DeFi: detects systemic risks (depeg, liquidity crisis) via a quant model (CBRI) and evacuates funds via Uniswap v3. 0G traceability. ETH Global Lisbon 2026

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages