# Mythos DeFi Sentinel 🛡️

**Autonomous DeFi monitoring & protection agent using KeeperHub as its on-chain execution layer.**

Built for the [KeeperHub Agents Onchain Hackathon](https://dorahacks.io/hackathon/agents-onchain/detail) (Jul 27 – Aug 13, 2026).

---

## What It Does

Mythos DeFi Sentinel autonomously monitors DeFi positions, detects risks, and recommends actions — all on-chain execution through KeeperHub workflows:

| Strategy | KeeperHub Workflow | What It Checks |
|----------|-------------------|----------------|
| **Liquidation Watch** | `wallet-snapshot-base` | Aave V3 health factor, collateral/debt ratio |
| **Position Scanner** | `defi-position-aggregator-base` | All DeFi positions across protocols |
| **Yield Optimizer** | `stablecoin-yield-compare-base` | Best USDC yield across Aave, Compound, Morpho |
| **Approval Auditor** | `token-approval-risk-scanner-base` | Risky ERC-20 approvals, unlimited spenders |
| **Bridge Router** | `bridge-route-optimizer-usdc` | Cheapest USDC bridge route |
| **DeFi Intel** | `defi-onchain-intelligence-base` | Aave rates + Aerodrome liquidity pools |

## Why KeeperHub?

Most agent hackathons reward **reasoning** — an agent that decides something clever. The harder problem is **execution**: what happens after the decision.

KeeperHub is the execution layer that fills the last mile. Every strategy above runs as an **on-chain transaction through KeeperHub**, paid per-call via **x402** (USDC on Base). No API key, no subscription — just pay and execute.

## Architecture

```
┌─────────────────────────────────────────────────┐
│                Mythos DeFi Sentinel              │
│  ┌──────────┐  ┌──────────┐  ┌───────────────┐  │
│  │ Strategy │  │ x402     │  │ Result        │  │
│  │ Picker   │  │ Payment  │  │ Interpreter   │  │
│  └────┬─────┘  └────┬─────┘  └───────┬───────┘  │
│       │              │                │           │
└───────┼──────────────┼────────────────┼───────────┘
        │              │                │
        ▼              ▼                ▼
┌─────────────────────────────────────────────────┐
│              KeeperHub Execution Layer           │
│  ┌──────────┐  ┌──────────┐  ┌───────────────┐  │
│  │ MCP      │  │ x402     │  │ On-Chain      │  │
│  │ Discovery│  │ Gateway  │  │ Settlement    │  │
│  └──────────┘  └──────────┘  └───────────────┘  │
└─────────────────────────────────────────────────┘
        │              │                │
        ▼              ▼                ▼
   64 Workflows    USDC on Base    Transaction Proof
```

## Quick Start

```bash
# Install
npm install

# Run full sentinel scan (your wallet)
node agent.js

# Scan a specific wallet
node agent.js --wallet 0x...

# Run a single strategy
node agent.js --strategy liquidation

# Run demo (pre-recorded on-chain transactions)
bash demo/demo.sh
```

## On-Chain Proof

This agent executes real on-chain transactions through KeeperHub:

| Transaction | Workflow | Amount |
|------------|----------|--------|
| `0xc950850d...413f8d` | `wallet-snapshot-base` | $0.01 USDC |
| *(more as strategies execute)* | | |

All transactions settled on Base L2 via KeeperHub's x402 gateway.

## x402 Payment Flow

1. Agent calls `POST /api/mcp/workflows/{slug}/call`
2. KeeperHub returns `402 Payment Required` with `WWW-Authenticate` header
3. Agent signs EIP-3009 `TransferWithAuthorization` for USDC on Base
4. Agent retries call with `X-PAYMENT: EIP-3009 <proof>` header
5. KeeperHub settles payment on-chain, executes workflow, returns result

No API key. No account. Pay per execution.

## Hackathon Eligibility

- ✅ Uses KeeperHub as on-chain execution layer
- ✅ Real on-chain transactions (proof above)
- ✅ MCP discovery + x402 payment (two KeeperHub stack components)
- ✅ Open source (MIT)
- ✅ Any agent framework (custom, no framework dependency)

## License

MIT — Mythos 2026
