Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Sentinel Oracle

AI-Powered, Privacy-Preserving Oracle Layer

Detecting anomalies in real-time price feeds and automating secure DeFi actions through decentralized infrastructure.

Built with Pyth Powered by ASI Secured by Lit

πŸ”— Quick Links


πŸ“– Overview

Sentinel Oracle is an intelligent oracle system that combines:

  • πŸ”— Pyth Network - Real-time, accurate price feeds via Pull Oracle
  • πŸ€– ASI Alliance - AI-powered anomaly detection using uAgent + MeTTa reasoning
  • πŸ” Lit Protocol / Vincent - Privacy-preserving automated execution

The Problem

DeFi protocols depend on oracles for critical pricing data. However, oracles can be:

  • Manipulated (flash loan attacks, MEV)
  • Delayed (network congestion)
  • Temporarily incorrect (API failures)

This leads to cascading liquidations and financial losses.

The Solution

Sentinel Oracle continuously monitors price feeds, detects anomalies using AI, and executes privacy-preserving automations to protect user positions.

Example Flow:

1. BTC price drops 10% in 2 minutes ⚠️
2. AI agent detects anomaly (z-score > 2.5) πŸ€–
3. Lit Protocol decrypts user's private trigger πŸ”“
4. Vincent executes stop-loss automatically ⚑
5. User's position is protected πŸ›‘οΈ

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Pyth Network          β”‚
β”‚  (Hermes API β†’ On-chain)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   ASI Sentinel uAgent      β”‚
β”‚   - Fetch prices           β”‚
β”‚   - MeTTa reasoning        β”‚
β”‚   - Detect anomalies       β”‚
β”‚   - Flag on-chain          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SentinelOracle.sol        β”‚
β”‚  - Store prices            β”‚
β”‚  - Manage deposits         β”‚
β”‚  - Trigger events          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Vincent App (Lit Layer)   β”‚
β”‚  - StopLossAbility         β”‚
β”‚  - Encrypted triggers      β”‚
β”‚  - Automated execution     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend Dashboard       β”‚
β”‚   - Live prices            β”‚
β”‚   - Agent chat             β”‚
β”‚   - User controls          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Python 3.9+
  • MetaMask or compatible Web3 wallet
  • Testnet ETH (Sepolia)

Installation

# Clone the repository
git clone https://github.com/YOUR_USERNAME/sentinel-oracle.git
cd sentinel-oracle

# Install contract dependencies
cd contracts
npm install
cp .env.example .env
# Edit .env with your keys

# Install agent dependencies
cd ../agent
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your keys

# Install frontend dependencies
cd ../frontend
npm install
cp .env.local.example .env.local
# Edit .env.local with your settings

# Install Lit/Vincent dependencies
cd ../lit_vincent
npm install

πŸ“¦ Deployment

1. Deploy Smart Contract

cd contracts

# Compile
npx hardhat compile

# Deploy to Sepolia
npx hardhat run scripts/deploy.js --network sepolia

# Note the deployed contract address
# Update .env files in agent/ and frontend/

2. Start Price Pusher

cd contracts

# Start pushing prices (keep running)
node scripts/updatePythPrice.js

3. Start AI Agent

cd agent

# Activate virtual environment
source venv/bin/activate

# Start the agent (keep running)
python agent.py

# In another terminal, start API server
python api_server.py

4. Start Frontend

cd frontend

# Development mode
npm run dev

# Visit http://localhost:3000

πŸ”΅ Pyth Network

Most innovative use of Pyth Pull Oracle

βœ… What we implemented:

  • Fetch price data via Hermes API
  • Update on-chain using Pull Oracle method
  • Use prices as base layer for anomaly detection
  • Innovative security use case (not just price display)

πŸ“ Contract: SentinelOracle.sol - Deployed at 0x4c299a5c75Fd195e3418Daea67116Fd742adbFB0 πŸ“ Script: contracts/scripts/updatePythPricePull.js - Hermes Pull Oracle integration πŸ“ Innovation: AI-powered anomaly detection on multi-asset Pyth feeds πŸ“ Network: Sepolia Testnet - View on Etherscan


🟣 Lit Protocol / Vincent

DeFi automation with Vincent App

βœ… What we implemented:

  • Vincent App with StopLossAbility
  • Accepts user deposits on-chain
  • Encrypts user trigger conditions with Lit
  • Automated transaction execution when conditions met

πŸ“ App: lit_vincent/vincent_ability.js πŸ“ Encryption: lit_vincent/lit_client.js πŸ“ Contract: SentinelOracle.sol - executeAction()


🟒 ASI Alliance

uAgent + MeTTa + ASI:One

βœ… What we implemented:

  • Official uAgent with real-time anomaly detection (registered on Agentverse)
  • MeTTa knowledge graphs for explainable AI reasoning
  • ASI:One Chat Protocol for human-agent interaction
  • Multi-asset monitoring (5 cryptocurrencies: BTC, ETH, SOL, AVAX, MATIC)
  • Real-world impact: DeFi oracle security and automated protection

πŸ“ Agent: agent/uagent_sentinel.py (Official uAgent) πŸ“ Reasoning: MeTTaReasoner class with MeTTa knowledge graphs πŸ“ Chat: ASI:One protocol via Agentverse πŸ“ Agentverse: https://agentverse.ai/agents/sentinelai-oracle


🎬 Demo

Running the Demo

# 1. Ensure all services are running:
#    - Price pusher
#    - AI agent
#    - API server
#    - Frontend

# 2. Open frontend in browser
open http://localhost:3000

# 3. Connect your wallet

# 4. In a new terminal, simulate an anomaly:
cd contracts
node scripts/simulate-anomaly.js

# 5. Watch the agent detect the anomaly
# 6. See the anomaly alert in the frontend
# 7. Chat with the agent to get explanations

Demo Video

πŸŽ₯ [Link to demo video] (to be added)

What the demo shows:

  1. Multi-asset dashboard - Live price feeds from Pyth Network (5 assets)
  2. User deposits funds and sets encrypted stop-loss trigger
  3. ASI:One Chat - Interact with the AI agent via Agentverse
  4. Anomaly simulation - 10% price drop triggered
  5. AI detection - Agent detects and flags anomaly on-chain
  6. MeTTa reasoning - Explainable AI knowledge graph output
  7. Lit + Vincent execution - Automated protective action
  8. User position protected - Transaction completed

πŸ§ͺ Testing

Contract Tests

cd contracts
npx hardhat test

Agent Tests

cd agent
python -m pytest tests/

Integration Test

# Run full integration test
./scripts/integration-test.sh

πŸ“š Documentation

Key Files

  • Contracts: contracts/contracts/SentinelOracle.sol
  • Agent: agent/agent.py
  • Frontend: frontend/app/page.js
  • Lit/Vincent: lit_vincent/

API Endpoints

Agent API (http://localhost:5000)

  • GET /api/status - Get agent status
  • GET /api/price-history - Get price history
  • POST /api/chat - Chat with agent

πŸ† Hackathon Deliverables

βœ… Completed

  • Smart contract deployed on Sepolia
  • Pyth Pull Oracle integration
  • AI agent with anomaly detection
  • MeTTa reasoning logic
  • Lit Protocol encryption setup
  • Vincent App structure
  • Frontend dashboard
  • Demo simulation script
  • Documentation

πŸ“‹ Submission Checklist

  • Deploy contract to testnet
  • Register Vincent App in Registry
  • Register uAgent on Agentverse
  • Record demo video
  • Prepare presentation deck
  • Test end-to-end flow
  • Update README with live links

πŸ”§ Configuration

Environment Variables

Contracts (.env):

SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY
PRIVATE_KEY=your_private_key
SENTINEL_ORACLE_ADDRESS=0x...

Agent (.env):

ETH_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY
SENTINEL_ORACLE_ADDRESS=0x...
AGENT_PRIVATE_KEY=your_agent_key
ANOMALY_THRESHOLD=2.5

Frontend (.env.local):

NEXT_PUBLIC_ORACLE_ADDRESS=0x...
NEXT_PUBLIC_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY
NEXT_PUBLIC_AGENT_API_URL=http://localhost:5000

πŸ› οΈ Technology Stack

Component Technology
Smart Contracts Solidity 0.8.20, Hardhat
Blockchain Ethereum Sepolia Testnet
Oracle Pyth Network (Pull Model)
AI Agent Python, uAgents, MeTTa
Encryption Lit Protocol
Automation Vincent Framework
Frontend Next.js 14, React, Tailwind CSS
Charts Recharts
Web3 Ethers.js v6

🚧 Production Considerations

For production deployment, consider:

  1. Security Audits - Smart contract audit required
  2. Multi-sig - Use multi-sig for Vincent executor
  3. Rate Limiting - Implement cooldowns and gas management
  4. Monitoring - Set up The Graph or event monitoring
  5. IPFS - Store encrypted triggers on IPFS
  6. Backup Executors - Implement fallback executors
  7. Gas Optimization - Optimize contract calls
  8. Real Pyth Integration - Use full updatePriceFeeds(bytes[]) method

🀝 Contributing

This is a hackathon project. For improvements or issues:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

πŸ“„ License

MIT License - see LICENSE file for details


πŸ™ Acknowledgments

  • Pyth Network - For reliable price feeds
  • ASI Alliance / Fetch.ai - For uAgent framework
  • Lit Protocol - For encryption and programmable signing
  • Vincent - For DeFi automation framework

Sentinel Oracle is unique because it:

  1. Solves a real problem - Oracle manipulation and DeFi liquidations
  2. Integrates 3 ecosystems - Pyth + ASI + Lit working together
  3. Privacy-first - User triggers remain encrypted until execution
  4. AI-powered - Real reasoning with explainability (MeTTa)
  5. Production-ready foundation - Clear path to mainnet deployment

We're not just building a demo β€” we're building the foundation for the next generation of secure, AI-driven DeFi infrastructure.


Built with ❀️ for the hackathon

Releases

Packages

Contributors

Languages