0xGavana/defiscanner

GitHub: 0xGavana/defiscanner

Stars: 0 | Forks: 0

# DeFi Scanner 🔍 **CLI-based DeFi protocol risk scanner** — smart contract analysis, TVL monitoring, exploit detection, governance risk assessment, and liquidity analysis. Built with Python, Click, and Rich for a polished terminal experience. ## Features - **Contract Scanner** — Detect proxy patterns (EIP-1967), selfdestruct opcodes, delegatecall usage, and upgrade mechanisms - **TVL Scanner** — Monitor Total Value Locked for anomalies: sudden drops >20%, whale concentration >30% - **Exploit Scanner** — Match against known exploit signatures: reentrancy patterns, flash loan attacks, price manipulation - **Governance Scanner** — Analyze quorum thresholds, timelock durations, multisig configurations, voting power concentration - **Liquidity Scanner** — Calculate impermanent loss, detect low-liquidity traps, analyze pool depth and slippage ## Installation git clone https://github.com/0xGavana/defiscanner.git cd defiscanner pip install -r requirements.txt pip install -e . ## Usage ### Scan a Contract defiscanner scan 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 defiscanner scan 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --network ethereum ### Monitor a Protocol defiscanner monitor --protocol uniswap defiscanner monitor --protocol aave --interval 300 ### Generate Reports defiscanner report 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --format json defiscanner report 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --format csv ### Check Alerts defiscanner alerts --severity high defiscanner alerts --protocol aave --last 24h ## Sample Output ╭─────────────────────────────────────────────╮ │ 🔍 DeFi Scanner — Risk Report │ ├─────────────────────────────────────────────┤ │ Contract: 0x1f9840a85d5aF5bf1D1762F9... │ │ Network: Ethereum Mainnet │ │ Scanned: 2026-05-22 14:30:00 UTC │ ╰─────────────────────────────────────────────╯ ┌─────────────────────┬────────┬──────────────┐ │ Module │ Score │ Status │ ├─────────────────────┼────────┼──────────────┤ │ Contract Security │ 82/100 │ 🟡 Medium │ │ TVL Stability │ 91/100 │ 🟢 Low │ │ Exploit Risk │ 75/100 │ 🟡 Medium │ │ Governance │ 88/100 │ 🟢 Low │ │ Liquidity │ 69/100 │ 🔴 High │ ├─────────────────────┼────────┼──────────────┤ │ OVERALL RISK SCORE │ 81/100 │ 🟡 Medium │ └─────────────────────┴────────┴──────────────┘ ## Architecture defiscanner/ ├── cli.py # Click CLI with subcommands ├── scanners/ │ ├── contract_scanner.py # Bytecode & proxy analysis │ ├── tvl_scanner.py # TVL anomaly detection │ ├── exploit_scanner.py # Exploit pattern matching │ ├── governance_scanner.py # Governance risk analysis │ └── liquidity_scanner.py # Liquidity & IL analysis ├── core/ │ ├── config.py # Settings & API configuration │ ├── blockchain.py # Web3 connection helpers │ └── report.py # Rich console & export └── data/ └── known_exploits.json # Exploit signature database ## Configuration Create `~/.defiscanner/config.yaml`: rpc_url: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY" etherscan_api_key: "YOUR_KEY" default_network: ethereum alert_threshold: 0.2 ## License MIT License — see [LICENSE](LICENSE)