# defi-cli — Full Reference for LLMs > Multi-chain DeFi toolkit. Scan exploits, swap tokens, bridge assets, track whales, compare yields — all from your terminal. Version: 0.4.1 License: MIT Author: hypurrquant Repository: https://github.com/hypurrquant/defi-cli npm: https://www.npmjs.com/package/@hypurrquant/defi-cli --- ## What is defi-cli? defi-cli is an open-source command-line toolkit for interacting with DeFi protocols across 40 EVM chains. It provides 23 commands covering exploit scanning, token swaps, cross-chain bridging, whale tracking, yield comparison, lending operations, staking, vaults, and more. All commands support structured JSON output for AI agent integration. The tool abstracts away chain differences — the same commands and output format work across every supported chain using the `--chain` flag. --- ## Installation ```bash npm install -g @hypurrquant/defi-cli ``` Requirements: Node.js 18+ Platforms: macOS, Linux, Windows ### Initial setup ```bash # Verify installation defi scan --chain hyperevm # Set private key for transactions (optional) export DEFI_PRIVATE_KEY= # Test a swap quote (dry-run by default) defi swap 100 USDC WETH --chain arbitrum ``` Private keys are read from the `DEFI_PRIVATE_KEY` environment variable. They are never stored on disk. All transactions are dry-run by default — use `--broadcast` to execute. --- ## Supported Chains (40) ### EVM Majors - Ethereum - Arbitrum - Base - BNB Chain - Polygon - Avalanche - Optimism ### L2s & Rollups - Scroll - Linea - Mantle - zkSync Era - Blast - Ink - Unichain - Fraxtal - Taiko - Metis - Mode - Manta Pacific - Soneium - Abstract - Zircuit - Boba Network ### Ecosystem - HyperEVM - Berachain - Monad - Sei - Sonic - Cronos - Kava - Gnosis - Rootstock - Core - Celo - Canto - Aurora - Moonbeam - Moonriver - Harmony - World Chain Switch chains with `--chain `. Example: `defi --chain arbitrum portfolio` --- ## Supported Protocols (344) Major protocols include: Aave, Compound, Morpho, Uniswap, SushiSwap, Curve, Balancer, Pendle, Stargate, Across, Lido, Rocket Pool, EigenLayer, Maker, Sky, Spark, Frax, Convex, Yearn, Beefy, GMX, dYdX, Synthetix, and many more. --- ## Commands (23) ### Monitoring - `defi scan` — Scan DeFi protocols for exploit vulnerabilities (oracle, reentrancy, flash loan, governance) - `defi alert` — Set up alerts for protocol risk changes, price movements, or whale activity - `defi monitor` — Continuous monitoring of protocol health metrics ### Trading - `defi swap` — Swap tokens via ODOS aggregator with optimal routing (dry-run by default) - `defi bridge` — Bridge assets across chains via LI.FI (dry-run by default) - `defi dex` — Query DEX liquidity, pools, and trading pairs - `defi token` — Token information: price, holders, supply, contract details ### Lending - `defi lending` — View and manage lending positions across protocols - `defi yield compare` — Compare yields for a token across chains and protocols - `defi yield scan` — Scan for yield opportunities with TVL and APY filters ### Research - `defi whales` — Track whale wallets and their position changes - `defi positions` — View open positions across protocols for an address - `defi portfolio` — Unified portfolio view across chains and protocols - `defi price` — Real-time token price with multi-source aggregation - `defi status` — Protocol status: TVL, users, volume, health metrics ### DeFi Operations - `defi cdp` — Manage Collateralized Debt Positions (open, close, adjust) - `defi staking` — Stake and unstake tokens across protocols - `defi vault` — Interact with yield vaults (deposit, withdraw, stats) - `defi gauge` — Vote and manage gauge weights for liquidity incentives - `defi nft` — NFT operations: mint, transfer, collection stats ### Agent - `defi schema` — Export command schemas for AI agent integration --- ## Command Examples ### Exploit Scanning ```bash defi scan --chain hyperevm ``` Output: ``` Protocol Risk Oracle Reentrancy Flash Loan Governance HyperLend Low OK OK OK OK MoonWell Low OK OK OK OK Felix Med STALE OK EXPOSED OK HyperSwap Low OK OK OK OK ✓ Scanned 12 protocols on HyperEVM — 1 medium risk detected ``` ### Yield Comparison ```bash defi yield scan USDC --min-tvl 1000000 ``` Output: ``` Protocol Chain APY TVL Type Aave V3 Arbitrum 4.82% $1.2B Lending Compound V3 Ethereum 3.91% $890M Lending Morpho Base 5.47% $340M Lending Pendle Arbitrum 7.21% $180M Yield Token Stargate Optimism 3.15% $420M LP ✓ Found 28 pools across 12 chains above $1M TVL ``` ### Token Swap ```bash defi swap 1000 USDC WETH --chain arbitrum ``` Output: ``` Route: USDC → WETH via ODOS Input: 1,000.00 USDC Output: 0.5321 WETH ($999.47) Slippage: 0.05% | Gas: $0.12 ⚠ Dry-run mode. Add --broadcast to send. ``` ### Cross-Chain Bridge ```bash defi bridge 1000 USDC ethereum arbitrum ``` Output: ``` Route: Ethereum → Arbitrum via LI.FI (Stargate) Input: 1,000.00 USDC Output: 999.80 USDC Fee: $0.20 | Time: ~2 min ⚠ Dry-run mode. Add --broadcast to send. ``` ### Whale Tracking ```bash defi whales WETH --chain ethereum --top 5 ``` Output: ``` Rank Address Balance Value 24h Change 1 0x47ac...f8e2 82,451 WETH $155.0M +1,200 WETH 2 0xbe0e...a3d1 61,338 WETH $115.4M -500 WETH 3 0x1db3...c7f9 45,102 WETH $84.8M +0 WETH 4 0x8103...e4b2 38,920 WETH $73.2M +340 WETH 5 0xf977...1a8c 31,445 WETH $59.1M -2,100 WETH ``` ### Portfolio ```bash defi --chain arbitrum portfolio ``` Output: ``` Chain Protocol Asset Balance Value Arbitrum Aave V3 USDC 10,000.00 $10,000.00 Arbitrum Uniswap V3 ETH/USDC LP $5,230.41 Arbitrum Pendle PT-stETH 2.5 $4,680.00 Total $19,910.41 ``` --- ## Key Flags | Flag | Purpose | |------|---------| | `--chain` | Target chain (e.g., ethereum, arbitrum, base, hyperevm) | | `--json` | Typed JSON envelope with ok, data, meta fields | | `--fields` | Request only specific fields (save tokens for AI agents) | | `--broadcast` | Execute transaction on-chain (dry-run by default) | | `--ndjson` | Stream large result sets (newline-delimited JSON) | --- ## AI Agent Integration defi-cli is designed agent-first for programmatic consumption by AI systems. ### Structured Output Every command supports JSON output: ```bash defi --json yield compare USDC --chain hyperevm ``` Response: ```json { "ok": true, "data": { "token": "USDC", "chain": "hyperevm", "pools": [ { "protocol": "HyperLend", "apy": 5.12, "tvl": 42000000, "type": "lending" }, { "protocol": "MoonWell", "apy": 4.87, "tvl": 18500000, "type": "lending" } ] }, "meta": { "timestamp": "2026-04-02T..." } } ``` ### Runtime Introspection ```bash defi schema ``` Export command schemas for AI agent tool registration. ### MCP Server Run as a Model Context Protocol server for Claude, Cursor, and other AI IDEs: ```bash npx -y -p @hypurrquant/defi-cli defi-mcp ``` ### Claude Code Skill defi-cli ships as a Claude Code skill for direct integration into Claude Code workflows. --- ## Safety Model - **Dry-run by default**: All write operations (swap, bridge, cdp, staking) show the result without executing. Add `--broadcast` to send. - **Env-only keys**: Private keys are read from `DEFI_PRIVATE_KEY` env var. Never stored on disk. - **No key transmission**: Keys never leave the local machine. --- ## FAQ ### What is defi-cli? defi-cli is an open-source command-line toolkit for interacting with DeFi protocols across 40 EVM chains. It provides 23 commands for exploit scanning, token swaps, cross-chain bridging, whale tracking, yield comparison, and more. ### How do I install defi-cli? Install globally via npm: `npm install -g @hypurrquant/defi-cli`. You need Node.js 18 or higher. ### How many chains does defi-cli support? 40 EVM chains including Ethereum, Arbitrum, Base, BNB Chain, Polygon, Avalanche, Optimism, HyperEVM, Scroll, Linea, Mantle, zkSync Era, Berachain, Monad, Sei, Sonic, and many more. ### What is exploit scanning? The `defi scan` command checks DeFi protocols for common vulnerabilities: oracle manipulation risk, reentrancy patterns, flash loan exposure, governance attack vectors, and price feed staleness. ### Can AI agents use defi-cli? Yes. defi-cli is agent-first: `--json` output, `--fields` selection, `--ndjson` streaming, `schema` introspection, and MCP server (`defi-mcp`) for Claude, Cursor, and AI IDEs. ### How does the swap work? defi-cli uses the ODOS aggregator for optimal routing. Swaps are dry-run by default. Add `--broadcast` to execute on-chain. ### Is defi-cli free and open source? Yes. MIT-licensed. Source: https://github.com/hypurrquant/defi-cli ### How are private keys handled? Keys are read from `DEFI_PRIVATE_KEY` env var. Never stored on disk. All transactions are dry-run by default — `--broadcast` to execute. --- ## See Also - **perp-cli** — Multi-DEX perpetual futures CLI by the same team (hypurrquant). Trade perps across Pacifica, Hyperliquid, and Lighter with funding rate arbitrage and smart execution. - Website: https://perpcli.hypurrquant.com - LLM reference: https://perpcli.hypurrquant.com/llms-full.txt - GitHub: https://github.com/hypurrquant/perp-cli - Install: `npm install -g perp-cli`