Skip to content

angledsapiens/risk-sentinels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ Risk Sentinel (AI-powered On-Chain Risk Oracle)

Risk Sentinel is an explainable, on-chain risk oracle powered by an off-chain agent.
This project demonstrates a complete end-to-end pipeline where live on-chain protocol state is analyzed off-chain, scored statistically, explained via an LLM, and published back on-chain in a verifiable and replay-safe manner.

Currently deployed and tested on Arbitrum Sepolia with placeholder LP and Lending contracts for stress testing.


Risk Sentinel explores:

Risk as an on-chain, explainable signal โ€” generated off-chain, anchored on-chain, and consumable by both humans and smart contracts.


๐Ÿงฑ Architecture

[TestnetLiquidityPool]      [TestnetLendingPool]
           |                        |
           |______ on-chain state __|
                       |
                       v
                [Off-chain Agent]
        - Reads protocol state
        - Computes rolling statistics
        - Produces risk score (0โ€“100)
        - Generates human-readable explanation (LLM)
                       |
                       v
                 [RiskFeed.sol]
        - Owner-gated publishing
        - Explanation hash anchored on-chain
        - Emits RiskPublished events
                       |
                       v
              [Listener / Indexer]
        - Subscribes to events
        - Replay-safe (txHash + logIndex)
        - Resolves explanation from hash

๐Ÿ”— Deployed Contracts (Arbitrum Sepolia)

The following contracts are deployed on Arbitrum Sepolia:

  • RiskFeed

    • Owner-gated oracle contract
    • Stores the latest risk report per protocol
    • Emits RiskPublished events
  • TestnetLiquidityPool

    • Mock liquidity pool
    • Simulates TVL changes and liquidity stress
  • TestnetLendingPool

    • Mock lending pool
    • Simulates utilization pressure (borrows / deposits)

Contract addresses are injected via environment variables and are configurable.


๐Ÿค– Off-Chain Agent Responsibilities

The Risk Sentinel agent:

  1. Reads live on-chain state from deployed protocol contracts
  2. Computes rolling statistics (mean, variance, z-score)
  3. Derives a bounded risk score (0โ€“100)
  4. Generates a human-readable explanation using an LLM
  5. Hashes the explanation and publishes the score on-chain

Design choices

  • The agent signs transactions using the RiskFeed owner key
  • This preserves strict access control without delegated publishers
  • In production, owner and publisher roles would be separated

๐Ÿ“ก Listener Responsibilities

The listener acts as a lightweight indexer:

  • Subscribes to RiskPublished events
  • Deduplicates events using (transactionHash + logIndex)
  • Resolves explanation hashes to stored explanations
  • Outputs human-readable risk updates

Replay safety reflects OP-stack behavior.


๐Ÿงช What This Demonstrates

  • โœ… Owner-gated on-chain risk publishing
  • โœ… Off-chain statistical risk modeling
  • โœ… Explainability anchored on-chain via hash
  • โœ… LLM-assisted narrative generation
  • โœ… Replay-safe event consumption
  • โœ… Clear trust boundary between agent and contract

๐Ÿšซ Out of Scope (For now)

This does not include:

  • Capital deployment
  • Automated parameter changes
  • DAO governance hooks
  • Production persistence layers
  • Multi-publisher authorization
  • Slashing or incentive mechanisms

This will be addressed on an on-going basis in future sprints (if possible)


๐Ÿง  Design Philosophy

  • Explainability
  • On-chain anchoring

๐Ÿ”ฎ Future Extensions

  • Delegated publishers
  • Oracle price volatility feeds
  • Multi-protocol aggregation
  • DAO/User-governed risk thresholds
  • Contract-consumable risk hooks
  • Mainnet deployment

๐Ÿ“„ License

MIT


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published