Comprehensive trust & security analysis for DeFi protocols
LlamaScan answers the critical question: "Is this protocol safe to use?"
Built as a contribution to DefiLlama.
β οΈ Note: This tool currently works for protocols that have a GitHub link on DefiLlama. Protocols without public GitHub repositories cannot be analyzed for code quality and activity metrics.
LlamaScan performs deep security analysis across 5 layers:
| Layer | Analysis | Status |
|---|---|---|
| 1. Source Code | GitHub activity, code quality, contributors | β Done |
| 2. Verification | Contract verified on Etherscan/Sourcify | β Done |
| 3. Privileges | Admin powers, proxy detection, ownership | β Done |
| 4. AI Audit | Automated vulnerability detection | π Planned |
| 5. On-chain | Historical behavior, suspicious patterns | π Planned |
π΄ CRITICAL
ββ withdraw() - Admin can drain funds
ββ pause() - Admin can freeze user funds
ββ blacklist() - Admin can block addresses
ββ emergencyWithdraw()
π HIGH
ββ upgradeTo() - Contract logic can be changed
ββ mint() - Can inflate token supply
ββ setImplementation()
π‘ MEDIUM
ββ setFee() - Can change fees (to 100%?)
ββ setOracle() - Can manipulate prices
ββ transferOwnership()
- EIP-1967 (UUPS/Transparent) - Upgradeable, HIGH risk
- Diamond (EIP-2535) - Modular, HIGH risk
- Beacon Proxy - All clones upgrade together, HIGH risk
- Minimal Proxy (EIP-1167) - Fixed implementation, LOW risk
- Single EOA owner
- No timelock on upgrades
- No multisig protection
- Renounced ownership (good!)
cd llamascan
npm install
cp .env.example .env # Then add your API keys (see below)
# Scan a protocol (GitHub + optional contract analysis)
npm run dev -- scan aave
# Scan with specific contract addresses
npm run dev -- scan uniswap --contracts 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984
# Verify a single contract (privilege analysis)
npm run dev -- verify 0xdAC17F958D2ee523a2206206994597C13D831ec7
# Scan with JSON output
npm run dev -- scan uniswap --json
# Scan a GitHub org directly (skip DefiLlama lookup)
npm run dev -- scan aave --github-only
# Check API rate limit
npm run dev -- rate-limitThe Etherscan API key significantly improves contract verification coverage (~90% vs ~30% with Sourcify alone).
- Go to etherscan.io/apis
- Create a free account
- Generate an API key (free tier: 5 calls/sec, 100k calls/day)
- Add to your
.envfile:
ETHERSCAN_API_KEY=your_api_key_hereWithout API key: Falls back to Sourcify (free, but lower coverage)
Increases rate limit from 60 to 5000 requests/hour:
- Go to github.com/settings/tokens
- Generate a classic token with
public_reposcope - Add to
.env:
GITHUB_TOKEN=ghp_your_token_here- You provide a protocol name (e.g.,
aave) - LlamaScan looks up the protocol on DefiLlama API
- Gets the GitHub org(s) linked to that protocol
- Analyzes GitHub activity, contributors, maturity
- (Optional) Analyzes smart contracts for privileges
- Calculates trust score
π¦ LlamaScan v0.3.0
ββββββββββββββββββββββββββββββββββββββββ
π Looking up "uniswap" on DefiLlama...
Found: Uniswap
GitHub: Uniswap
Twitter: @Uniswap
π Fetching GitHub metrics...
Found 163 repositories
Total stars: 40,200
Contributors: 10
π Analyzing 1 contract(s) on ethereum...
0x1f9840a8...4201F984
ββ Verified: β
Yes (Sourcify)
ββ Name: Uni
ββ Proxy: β
No
ββ Dangerous functions: 2
ββ Privilege Score: 85/100
ββββββββββββββββββββββββββββββββββββββββ
Trust Score: 94/100 (Grade: A)
ββββββββββββββββββββββββββββββββββββββββ
npm run dev -- verify 0xdAC17F958D2ee523a2206206994597C13D831ec7
π Fetching verification status...
Verified: β
Yes
Name: TetherToken
β οΈ Dangerous Functions Found: 3
π΄ CRITICAL (2):
- pause(): Admin can freeze funds
- unpause(): Admin can freeze funds
π‘ MEDIUM (1):
- transferOwnership()
Privilege Score: 65/100
Risk Assessment: π‘ MEDIUM RISK
llamascan/
βββ src/
β βββ types/ # TypeScript interfaces
β β βββ index.ts # Core types (GitHub)
β β βββ contracts.ts # Contract analysis types
β β βββ ai.ts # AI audit types
β β βββ report.ts # Final report types
β β
β βββ analyzers/ # Analysis modules
β β βββ source/ # Layer 1: GitHub
β β βββ verification/ # Layer 2: Etherscan/Sourcify
β β βββ privileges/ # Layer 3: Admin powers
β β βββ ai/ # Layer 4: Vulnerabilities
β β βββ onchain/ # Layer 5: Behavior
β β
β βββ data/ # Reference databases
β β βββ dangerousFunctions.ts
β β βββ proxyPatterns.ts
β β
β βββ scoring/ # Score calculation
β βββ cli.ts # Command-line interface
β
βββ data/ # Generated reports
βββ ARCHITECTURE.md # Detailed design doc
| Layer | Weight | Rationale |
|---|---|---|
| Source Code | 15% | Active development indicates maintenance |
| Verification | 20% | Verified = auditable, unverified = red flag |
| Privileges | 30% | Most important - can admin steal funds? |
| AI Audit | 20% | Automated vulnerability detection |
| On-chain | 15% | Historical behavior matters |
| Level | Score Impact | Meaning |
|---|---|---|
| π΄ CRITICAL | -40 to -50 | Immediate danger |
| π HIGH | -20 to -30 | Significant risk |
| π‘ MEDIUM | -10 to -15 | Moderate concern |
| π’ LOW | -5 | Minor issue |
| Finding | Bonus | Why |
|---|---|---|
| Timelock > 48h | +15 | Time to react to malicious upgrades |
| Multisig (3/5+) | +10 | Reduces single point of failure |
| Renounced ownership | +20 | Contract is immutable |
| Battle-tested (>1yr, >$100M TVL) | +15 | Proven track record |
# GitHub (5000 req/hr vs 60)
GITHUB_TOKEN=ghp_xxx
# Block explorers (for contract verification)
ETHERSCAN_API_KEY=xxx
ARBISCAN_API_KEY=xxx
BASESCAN_API_KEY=xxx
# AI analysis (optional)
OPENAI_API_KEY=xxx- Ethereum
- Arbitrum
- Optimism
- Polygon
- Base
- BSC
- Avalanche
- Fantom
- Gnosis
- Project structure
- GitHub analyzer
- Trust scoring algorithm
- CLI tool
- Type definitions for all layers
- Etherscan API integration
- Sourcify integration (free fallback)
- Bytecode matching
- Multi-chain support (9 chains)
- Dangerous function database (40+ patterns)
- Proxy pattern detection (EIP-1967, Diamond, Beacon, Minimal)
- Privilege score calculation
- Owner type detection (EOA/Multisig/DAO)
- Timelock detection
- Static vulnerability patterns
- Known exploit similarity matching
- LLM-powered code review
- Automated audit report generation
- Admin action history
- Fund flow analysis
- Suspicious pattern detection
- TVL history correlation
- DefiLlama protocol database integration
- Batch scanning all protocols
- API endpoint for real-time queries
- Frontend dashboard
This project is being built as a contribution to DefiLlama.
The goal is to become the "Head of Trust" - building the trust layer that helps users make informed decisions about DeFi protocols.
MIT
Built with π¦ by rontoTech