Skip to content

onryoo73/SentinelFi

Repository files navigation

SentinelFi 🛡️

SentinelFi is an Autonomous Liquidation Protection layer for DeFi, powered by the Reactive Network. It monitors borrowing health on Ethereum Sepolia and triggers on-chain callbacks to a destination contract to protect collateral—completely without off-chain keepers, bots, or centralized infrastructure.

Key Features

  • Autonomous Protection: Real-time monitoring and execution via Reactive Smart Contracts (RSC).
  • Multi-Asset Support: Track aggregate collateral across multiple assets (ETH, WBTC, USDC).
  • User-Defined Thresholds: Users configure their own "Warning" and "Emergency" levels directly on-chain.
  • Cross-Chain Reactive Loop: Origin events on Sepolia → Processing on Lasna → Callback execution on Sepolia.

Architecture

┌────────────────────────────── Sepolia (11155111) ──────────────────────────────┐
│                                                                                  │
│   ┌───────────────┐        HealthFactorUpdated event                           │
│   │  LendingPool  │ ────────────────────────────────────────────────┐          │
│   │ (Origin mock) │                                                 │          │
│   └───────────────┘                                                 │          │
│            ▲                                                        │          │
│            │ updateHealthFactor / openPosition                       │          │
│            │                                                         v          │
│   ┌────────────────────┐   Callback tx via Callback Proxy   ┌──────────────────┐ │
│   │ CollateralManager  │ <───────────────────────────────── │  Reactive flow  │ │
│   │   (Destination)    │   handleProtection(...)           │  (Lasna RSC)     │ │
│   └────────────────────┘                                   └────────▲────────┘ │
│                                                                         │          │
└─────────────────────────────────────────────────────────────────────────┼──────────┘
                                                                          │
                                           ┌──────────────────────────────┴───────────┐
                                           │ Lasna Reactive testnet (5318007)         │
                                           │                                            │
                                           │  ┌──────────────────────┐                  │
                                           │  │  LiquidationGuard    │                  │
                                           │  │  (RSC / AbstractReactive)              │
                                           │  │  react(LogRecord)    │                  │
                                           │  └──────────────────────┘                  │
                                           └────────────────────────────────────────────┘

Repo layout

sentinelfi/
├── contracts/
│   ├── LendingPool.sol             # Mock lending position manager
│   ├── LiquidationGuard.sol        # Reactive RSC on Lasna
│   ├── CollateralManager.sol       # Protection callback destination
│   └── reactive-lib/src/...        # Reactive Network interfaces
├── scripts/
│   ├── deploy-lending-pool.js
│   ├── deploy-collateral-manager.js
│   ├── deploy-liquidation-guard.js
│   └── simulate.js
├── frontend/                       # Modern React + RainbowKit UI
└── README.md

Prerequisites

  • Node.js 18+
  • A wallet funded on Sepolia and Lasna (lREACT for gas)
  • RPC URLs for both networks

Quick Start (Demo)

  1. Install Dependencies:

    npm install
    cd frontend && npm install
  2. Configure Environment: Create a .env in the root and frontend/ directories (see .env.example).

  3. Deploy & Run:

    # Deploy core system
    npx hardhat run scripts/deploy-lending-pool.js --network sepolia
    npx hardhat run scripts/deploy-collateral-manager.js --network sepolia
    npx hardhat run scripts/deploy-liquidation-guard.js --network lasna
    
    # Start Frontend
    cd frontend && npm run dev

How to Test the MVP

  1. Launch App: Open the frontend and connect your wallet via RainbowKit.
  2. Set Thresholds: Input your custom "Warning" and "Emergency" Health Factors (e.g., 1.3 and 1.2).
  3. Open Position: Click "Open Multi-Asset Position" to create a diversified mock loan.
  4. Simulate Stress: Click "Simulate Market Stress". This will lower your Health Factor on-chain.
  5. Watch the Magic:
    • The Reactive RSC on Lasna will detect the drop.
    • It will trigger a verified callback to Sepolia.
    • You will see Toast Notifications and a new entry in the Protection History automatically.

Deployed contract addresses (Latest Demo)

Network Contract Address
Sepolia LendingPool 0x1e437A0154892Fc9f6fA28125FDEB5a0B0ed44dc
Sepolia CollateralManager 0x4b65B2C065e2995EB4f9Ee11749df0b40f429DbA
Lasna LiquidationGuard 0xe94cE5D39017437B68fa9b5B694a51Dfb641abc6

License

MIT (Demo Code for Prize Grant Application).

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors