@hypurrquant/defi-cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hypurrquant/defi-cli",
3
- "version": "0.4.0",
4
- "description": "Multi-chain DeFi CLI lending, DEX, LP, bridge, vault, staking from your terminal",
3
+ "version": "0.5.0",
4
+ "description": "Multi-chain DeFi CLI \u2014 lending, DEX, LP, bridge, vault, staking from your terminal",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
+ "skills",
13
14
  "config",
14
15
  "mcp-config.example.json"
15
16
  ],
@@ -45,7 +46,7 @@
45
46
  "prepublishOnly": "pnpm run build"
46
47
  },
47
48
  "dependencies": {
48
- "@modelcontextprotocol/sdk": "^1.27.1",
49
+ "@modelcontextprotocol/sdk": "^1.29.0",
49
50
  "commander": "^13.0.0",
50
51
  "dotenv": "^17.3.1",
51
52
  "picocolors": "^1.1.0",
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: defi-cli
3
+ description: "Multi-chain DeFi operations CLI for HyperEVM (Hyperliquid) and Mantle. Use when user asks to: supply/withdraw from lending, swap tokens, add/remove LP, bridge assets, manage LP autopilot, claim rewards, compare APYs, check prices, track portfolio, or mentions defi-cli, HyperEVM, Hyperliquid EVM, Mantle, HypurrFi, HyperLend, Felix, KittenSwap, NEST, Ramses, Merchant Moe, KyberSwap, OpenOcean, LiquidSwap."
4
+ allowed-tools: "Bash(defi:*), Bash(npx defi-cli:*), Bash(npx -y defi-cli:*)"
5
+ license: MIT
6
+ metadata:
7
+ author: hypurrquant
8
+ version: "0.4.0"
9
+ ---
10
+
11
+ # defi-cli Agent Guide
12
+
13
+ Multi-chain DeFi CLI — lending, DEX swaps, LP management, bridging, yield comparison — all from your terminal.
14
+
15
+ 2 chains: **HyperEVM** (Hyperliquid EVM, chain ID 999) and **Mantle** (chain ID 5000).
16
+ 21 protocols across lending, DEX, vault, CDP.
17
+
18
+ ## Rules
19
+
20
+ 1. **Always use `--json`** on every command.
21
+ 2. **Always use `--dry-run`** (default) before any mutating transaction. Only add `--broadcast` after user confirms.
22
+ 3. **Always use `--chain`** for transaction commands (`lending supply`, `swap`, `lp`, `token`, `price`, `wallet`, `bridge`). Query commands (`yield`, `status`) scan all chains by default.
23
+ 4. **NEVER broadcast without user confirmation.**
24
+ 5. **NEVER read private key files or `~/.` config files.**
25
+ 6. **Amounts are in wei** (18 decimals for most tokens, 6 for USDC/USDT). Use `BigInt(humanAmount * 10**decimals)` to convert.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ defi --version 2>/dev/null # check if installed
31
+ npm install -g @hypurrquant/defi-cli@latest 2>/dev/null || npx -y @hypurrquant/defi-cli@latest --json status
32
+ ```
33
+
34
+ Use `defi` if global install works, otherwise `npx -y @hypurrquant/defi-cli@latest` as prefix.
35
+
36
+ ## Global Flags
37
+
38
+ `--json` (required) | `--chain <chain>` (hyperevm or mantle, required for tx commands) | `--dry-run` (default, safe) | `--broadcast` (executes tx) | `--fields <f1,f2>` | `--ndjson`
39
+
40
+ **Wallet**: set `DEFI_WALLET_ADDRESS` env for read queries. Set `DEFI_PRIVATE_KEY` for tx signing.
41
+
42
+ ## Environment
43
+
44
+ ```bash
45
+ export DEFI_WALLET_ADDRESS=0xYourAddress
46
+ export DEFI_PRIVATE_KEY=0xYourPrivateKey # only needed for broadcasting
47
+ ```
48
+
49
+ ## Chains
50
+
51
+ | Alias | Full Name | Chain ID |
52
+ |-------|-----------|----------|
53
+ | `hyperevm` | HyperEVM (Hyperliquid) | 999 |
54
+ | `mantle` | Mantle | 5000 |
55
+
56
+ ## Protocol Slugs
57
+
58
+ ### HyperEVM Lending
59
+ | Slug | Protocol | Interface |
60
+ |------|----------|-----------|
61
+ | `hyperlend` | HyperLend | aave_v3 |
62
+ | `hypurrfi` | HypurrFi | aave_v3 |
63
+ | `felix-morpho` | Felix Morpho | morpho_blue |
64
+
65
+ ### HyperEVM DEX
66
+ | Slug | Protocol | Interface |
67
+ |------|----------|-----------|
68
+ | `kittenswap` | KittenSwap | algebra_v3 |
69
+ | `nest-v1` | NEST V1 | algebra_v3 |
70
+ | `ramses-cl` | Ramses CL | uniswap_v3 |
71
+ | `ramses-hl` | Ramses HL | solidly_v2 |
72
+ | `hybra` | Hybra | solidly_v2 |
73
+ | `project-x` | Project X | uniswap_v2 |
74
+
75
+ ### HyperEVM Vaults / CDP
76
+ | Slug | Protocol | Interface |
77
+ |------|----------|-----------|
78
+ | `felix` | Felix CDP | liquity_v2 |
79
+ | `felix-vaults` | Felix Vaults | erc4626 |
80
+ | `hyperbeat` | Hyperbeat | erc4626 |
81
+ | `looping` | Looping | erc4626 |
82
+ | `upshift` | Upshift | erc4626 |
83
+ | `lazy-summer` | Lazy Summer | erc4626 |
84
+
85
+ ### Mantle Protocols
86
+ | Slug | Protocol | Interface |
87
+ |------|----------|-----------|
88
+ | `aave-v3-mantle` | Aave V3 Mantle | aave_v3 |
89
+ | `lendle-mantle` | Lendle | aave_v3 |
90
+ | `uniswap-v3-mantle` | Uniswap V3 | uniswap_v3 |
91
+ | `merchantmoe-mantle` | Merchant Moe | uniswap_v2 + lb |
92
+
93
+ ## Core Workflow: Lending
94
+
95
+ ```
96
+ 1. defi --json yield --asset USDC # compare APYs (all chains)
97
+ 2. defi --json --chain hyperevm lending position --protocol hyperlend # check position
98
+ 3. defi --json --chain hyperevm lending supply --protocol hyperlend --asset USDC --amount 1000000000 # dry-run
99
+ 4. [show result to user, get confirmation]
100
+ 5. defi --json --chain hyperevm lending supply --protocol hyperlend --asset USDC --amount 1000000000 --broadcast
101
+ 6. defi --json --chain hyperevm lending position --protocol hyperlend # verify
102
+ ```
103
+
104
+ ## Core Workflow: Swap (DEX Aggregator)
105
+
106
+ Aggregates KyberSwap, OpenOcean, LiquidSwap for best price automatically.
107
+
108
+ ```
109
+ 1. defi --json --chain hyperevm swap --from WHYPE --to USDC --amount 1000000000000000000 # dry-run
110
+ 2. [confirm with user]
111
+ 3. defi --json --chain hyperevm swap --from WHYPE --to USDC --amount 1000000000000000000 --broadcast
112
+ ```
113
+
114
+ ## Core Workflow: LP Autopilot
115
+
116
+ ```
117
+ 1. defi --json --chain hyperevm lp discover # find pools with APR/TVL
118
+ 2. [user reviews, edits ~/.defi/pools.toml with chosen pools]
119
+ 3. defi --json --chain hyperevm lp autopilot --budget 1000000000 # dry-run allocation
120
+ 4. [confirm with user]
121
+ 5. defi --json --chain hyperevm lp autopilot --budget 1000000000 --broadcast # execute
122
+ ```
123
+
124
+ ## Core Workflow: Yield Comparison
125
+
126
+ ```
127
+ 1. defi --json yield # all chains USDC rates
128
+ 2. defi --json --chain mantle yield --asset USDC # Mantle only
129
+ ```
130
+
131
+ ## Error Handling
132
+
133
+ | Error | Action |
134
+ |-------|--------|
135
+ | `Chain not found: X` | use `hyperevm` or `mantle` |
136
+ | `Protocol not found: X` | run `defi --json status` to list valid slugs |
137
+ | `No route found` | swap aggregator has no route — try smaller amount or different pair |
138
+ | `No prices fetched` | asset not listed in registry — use token address directly |
139
+ | `Multicall failed` | RPC issue — retry or check `status` |
140
+ | `DEFI_WALLET_ADDRESS not set` | set env var or pass `--address` |
141
+
142
+ ## Examples
143
+
144
+ **"What are the best USDC lending rates?"**
145
+ ```bash
146
+ defi --json yield --asset USDC
147
+ ```
148
+
149
+ **"Supply 1000 USDC to HyperLend"**
150
+ ```bash
151
+ defi --json yield --asset USDC
152
+ defi --json --chain hyperevm lending supply --protocol hyperlend --asset USDC --amount 1000000000
153
+ # after user confirms:
154
+ defi --json --chain hyperevm lending supply --protocol hyperlend --asset USDC --amount 1000000000 --broadcast
155
+ ```
156
+
157
+ **"Swap 1 WHYPE to USDC"**
158
+ ```bash
159
+ defi --json --chain hyperevm swap --from WHYPE --to USDC --amount 1000000000000000000
160
+ defi --json --chain hyperevm swap --from WHYPE --to USDC --amount 1000000000000000000 --broadcast
161
+ ```
162
+
163
+ **"Find Mantle LP pools with rewards"**
164
+ ```bash
165
+ defi --json --chain mantle lp discover
166
+ ```
167
+
168
+ **"Bridge 100 USDC from HyperEVM to Mantle"**
169
+ ```bash
170
+ defi --json --chain hyperevm bridge --token USDC --amount 100000000 --to-chain mantle
171
+ ```
172
+
173
+ **"Check my portfolio on HyperEVM"**
174
+ ```bash
175
+ defi --json --chain hyperevm portfolio show --address 0xYourAddress
176
+ ```
177
+
178
+ **"Claim LP rewards from KittenSwap"**
179
+ ```bash
180
+ defi --json --chain hyperevm lp claim --protocol kittenswap --pool 0xYourPool --broadcast
181
+ ```
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@hypurrquant/defi-cli-skill",
3
+ "version": "0.2.0",
4
+ "description": "AI agent skill for defi-cli — multi-chain DeFi operations via CLI",
5
+ "keywords": [
6
+ "ai-skill",
7
+ "claude",
8
+ "defi",
9
+ "lending",
10
+ "dex",
11
+ "swap",
12
+ "bridge",
13
+ "vault",
14
+ "staking",
15
+ "hyperevm",
16
+ "hyperliquid",
17
+ "mantle",
18
+ "aave",
19
+ "uniswap",
20
+ "yield"
21
+ ],
22
+ "author": "hypurrquant",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/hypurrquant/defi-cli",
27
+ "directory": "ts/packages/defi-cli/skills/defi-cli"
28
+ },
29
+ "homepage": "https://github.com/hypurrquant/defi-cli#ai-agent-skill",
30
+ "files": [
31
+ "SKILL.md",
32
+ "references",
33
+ "scripts"
34
+ ],
35
+ "peerDependencies": {
36
+ "@hypurrquant/defi-cli": ">=0.2.0"
37
+ }
38
+ }
@@ -0,0 +1,162 @@
1
+ # defi-cli Command Reference
2
+
3
+ All commands support `--json` for structured output. Always use `--json` when calling from an agent.
4
+ All amounts are in **wei** unless noted. USDC/USDT use 6 decimals; native tokens and most ERC-20s use 18.
5
+
6
+ ## Dashboard (read-only, safe)
7
+
8
+ ```bash
9
+ defi --json # multicall balance dashboard
10
+ defi --json --chain mantle # Mantle dashboard
11
+ ```
12
+
13
+ ## Status & Discovery (read-only, safe)
14
+
15
+ ```bash
16
+ defi --json status # list all protocols for current chain
17
+ defi --json --chain mantle status # list Mantle protocols
18
+ defi --json schema # full CLI schema as JSON
19
+ ```
20
+
21
+ ## Yield (read-only, safe)
22
+
23
+ ```bash
24
+ defi --json yield # lending APY comparison (default: USDC, HyperEVM)
25
+ defi --json yield --asset USDT # compare for a different asset
26
+ defi --json --chain mantle yield --asset USDC # Mantle lending rates
27
+ ```
28
+
29
+ ## Price (read-only, safe)
30
+
31
+ ```bash
32
+ defi --json price --asset WHYPE # oracle + DEX prices for an asset
33
+ defi --json price --asset USDC --source oracle # oracle prices only
34
+ defi --json price --asset WHYPE --source dex # DEX spot prices only
35
+ defi --json --chain mantle price --asset WMNT # price on Mantle
36
+ ```
37
+
38
+ ## Lending (read-only queries, then mutating)
39
+
40
+ ```bash
41
+ # Read-only
42
+ defi --json lending rates --protocol <slug> --asset <token>
43
+ defi --json lending position --protocol <slug>
44
+
45
+ # Mutating (dry-run first, then --broadcast)
46
+ defi --json lending supply --protocol <slug> --asset <token> --amount <wei>
47
+ defi --json lending supply --protocol <slug> --asset <token> --amount <wei> --on-behalf-of <addr>
48
+ defi --json lending withdraw --protocol <slug> --asset <token> --amount <wei> [--to <addr>]
49
+ ```
50
+
51
+ Auto-approve: if token allowance is insufficient, the CLI checks, approves the exact amount, then supplies — all in one `--broadcast` call.
52
+
53
+ ## Swap (DEX aggregator — KyberSwap, OpenOcean, LiquidSwap)
54
+
55
+ ```bash
56
+ defi --json swap --token-in <token> --token-out <token> --amount <wei> [--slippage <bps>]
57
+ defi --json swap --token-in WHYPE --token-out USDC --amount 1000000000000000000 --slippage 50
58
+ ```
59
+
60
+ Note: `swap` aggregates multiple DEX APIs for best route. Use `--broadcast` to execute.
61
+
62
+ ## LP Operations
63
+
64
+ ### Discover Pools
65
+
66
+ ```bash
67
+ defi --json lp discover # all 134 emission pools
68
+ defi --json lp discover --protocol kittenswap # filter by protocol
69
+ defi --json lp discover --min-apr 10 # filter by minimum APR
70
+ ```
71
+
72
+ ### Add Liquidity
73
+
74
+ ```bash
75
+ defi --json lp add --protocol <slug> --pool-address <addr> --amount-a <wei> --amount-b <wei>
76
+ ```
77
+
78
+ ### Farm (Add + Auto-stake)
79
+
80
+ ```bash
81
+ # Add liquidity and stake into gauge/farming for emissions
82
+ defi --json lp farm --protocol <slug> --pool-address <addr> --amount-a <wei> --amount-b <wei>
83
+ ```
84
+
85
+ ### Claim Rewards
86
+
87
+ ```bash
88
+ defi --json lp claim --protocol <slug> --pool-address <addr>
89
+ ```
90
+
91
+ ### Remove Liquidity
92
+
93
+ ```bash
94
+ # Auto-unstake (if staked) then remove liquidity
95
+ defi --json lp remove --protocol <slug> --pool-address <addr>
96
+ ```
97
+
98
+ ### LP Positions
99
+
100
+ ```bash
101
+ defi --json lp positions # all LP positions across protocols
102
+ ```
103
+
104
+ ### LP Autopilot
105
+
106
+ Reads `~/.defi/pools.toml` for whitelisted pools and allocates budget automatically.
107
+
108
+ ```bash
109
+ defi --json lp autopilot --budget <wei> # dry-run (default)
110
+ defi --json lp autopilot --budget 1000000000 --broadcast # execute
111
+ ```
112
+
113
+ **pools.toml format:**
114
+ ```toml
115
+ [[pools]]
116
+ protocol = "kittenswap"
117
+ pool_address = "0x..."
118
+ weight = 50
119
+
120
+ [[pools]]
121
+ protocol = "nest-v1"
122
+ pool_address = "0x..."
123
+ weight = 50
124
+ ```
125
+
126
+ ## Portfolio
127
+
128
+ ```bash
129
+ defi --json portfolio # aggregate positions across all protocols
130
+ ```
131
+
132
+ ## Token
133
+
134
+ ```bash
135
+ # Read-only
136
+ defi --json token balance --token <token> [--owner <addr>]
137
+ defi --json token allowance --token <token> --spender <addr> [--owner <addr>]
138
+
139
+ # Mutating
140
+ defi --json token approve --token <token> --spender <addr> [--amount max|<wei>]
141
+ defi --json token transfer --token <token> --to <addr> --amount <wei>
142
+ ```
143
+
144
+ ## Wallet
145
+
146
+ ```bash
147
+ defi --json wallet address # show configured wallet address
148
+ defi --json wallet balance [--address <addr>] # native token balance
149
+ ```
150
+
151
+ ## Bridge (cross-chain)
152
+
153
+ ```bash
154
+ # LI.FI (default, supports most token/chain combos)
155
+ defi --json bridge --token USDC --amount 100000000 --to-chain mantle
156
+
157
+ # deBridge DLN
158
+ defi --json bridge --token USDC --amount 100000000 --to-chain arbitrum --provider debridge
159
+
160
+ # Circle CCTP V2 (native USDC only: ethereum, avalanche, optimism, arbitrum, base, polygon)
161
+ defi --json bridge --token USDC --amount 100000000 --to-chain arbitrum --provider cctp
162
+ ```
@@ -0,0 +1,115 @@
1
+ # defi-cli Protocol Reference
2
+
3
+ ## HyperEVM (chain: `hyperevm`, Chain ID: 999)
4
+
5
+ ### Lending Protocols
6
+
7
+ | Slug | Name | Interface | Notes |
8
+ |------|------|-----------|-------|
9
+ | `hyperlend` | HyperLend | aave_v3 | Main Aave V3 fork |
10
+ | `hypurrfi` | HypurrFi | aave_v3 | HypurrQuant native lending |
11
+ | `felix-morpho` | Felix Morpho | morpho_blue | Morpho Blue vaults |
12
+
13
+ ### DEX Protocols
14
+
15
+ | Slug | Name | Interface | Notes |
16
+ |------|------|-----------|-------|
17
+ | `kittenswap` | KittenSwap | algebra_v3 | Algebra V3 (concentrated); 16 gauge pools |
18
+ | `nest-v1` | NEST V1 | algebra_v3 | Algebra V3 fork; 13 gauge pools |
19
+ | `ramses-cl` | Ramses CL | uniswap_v3 | Concentrated liquidity; 25 gauge pools |
20
+ | `ramses-hl` | Ramses HL | solidly_v2 | Solidly V2 ve(3,3) |
21
+ | `hybra` | Hybra | solidly_v2 | Solidly V2; 45 gauge pools |
22
+ | `project-x` | Project X | uniswap_v2 | Uniswap V2 fork |
23
+
24
+ ### Vault Protocols (ERC-4626)
25
+
26
+ | Slug | Name | Notes |
27
+ |------|------|-------|
28
+ | `felix-vaults` | Felix Vaults | CDP-backed vaults |
29
+ | `hyperbeat` | Hyperbeat | Auto-compounding vault |
30
+ | `looping` | Looping | Leverage looping |
31
+ | `upshift` | Upshift | Yield optimization |
32
+ | `lazy-summer` | Lazy Summer | Yield aggregator |
33
+
34
+ ### CDP Protocols
35
+
36
+ | Slug | Name | Interface | Stablecoin |
37
+ |------|------|-----------|------------|
38
+ | `felix` | Felix CDP | liquity_v2 | feUSD |
39
+
40
+ ### Other
41
+
42
+ | Slug | Name | Category |
43
+ |------|------|----------|
44
+ | `hypersurface` | Hypersurface | options |
45
+ | `seaport-hyperevm` | Seaport | nft marketplace |
46
+
47
+ ---
48
+
49
+ ## Mantle (chain: `mantle`, Chain ID: 5000)
50
+
51
+ ### Lending Protocols
52
+
53
+ | Slug | Name | Interface | Notes |
54
+ |------|------|-----------|-------|
55
+ | `aave-v3-mantle` | Aave V3 Mantle | aave_v3 | Official Aave V3 |
56
+ | `lendle-mantle` | Lendle | aave_v3 | Mantle native lending |
57
+
58
+ ### DEX Protocols
59
+
60
+ | Slug | Name | Interface | Notes |
61
+ |------|------|-----------|-------|
62
+ | `uniswap-v3-mantle` | Uniswap V3 | uniswap_v3 | Concentrated liquidity |
63
+ | `merchantmoe-mantle` | Merchant Moe | uniswap_v2 + lb | V2 AMM + Liquidity Book; 35 LB pools |
64
+
65
+ ---
66
+
67
+ ## DEX Aggregator Providers (swap command)
68
+
69
+ | Provider | Chains | Notes |
70
+ |----------|--------|-------|
71
+ | KyberSwap | HyperEVM, Mantle | Default for HyperEVM |
72
+ | OpenOcean | HyperEVM, Mantle | Fallback aggregator |
73
+ | LiquidSwap | HyperEVM | HyperEVM-native |
74
+
75
+ ---
76
+
77
+ ## Common Token Symbols
78
+
79
+ ### HyperEVM
80
+ - `HYPE` — native token (use WHYPE for ERC-20 swaps)
81
+ - `WHYPE` — wrapped HYPE (0x5555555555555555555555555555555555555555)
82
+ - `USDC` — USD Coin
83
+ - `USDT` — Tether
84
+ - `WBTC` — Wrapped Bitcoin
85
+ - `WETH` — Wrapped Ether
86
+
87
+ ### Mantle
88
+ - `MNT` — native token
89
+ - `WMNT` — wrapped MNT
90
+ - `USDC` — USD Coin
91
+ - `USDT` — Tether
92
+ - `WETH` — Wrapped Ether
93
+
94
+ ---
95
+
96
+ ## Decimal Reference
97
+
98
+ | Token | Decimals | 1 token in wei |
99
+ |-------|----------|----------------|
100
+ | HYPE/WHYPE/WETH/WBTC | 18 | `1000000000000000000` |
101
+ | USDC | 6 | `1000000` |
102
+ | USDT | 6 | `1000000` |
103
+ | MNT/WMNT | 18 | `1000000000000000000` |
104
+
105
+ ---
106
+
107
+ ## Bridge Provider Support
108
+
109
+ | Provider | Flag | Best For |
110
+ |----------|------|----------|
111
+ | LI.FI (default) | `--provider lifi` | Any token, any chain |
112
+ | deBridge DLN | `--provider debridge` | Cross-chain arbitrary tokens |
113
+ | Circle CCTP V2 | `--provider cctp` | Native USDC transfers |
114
+
115
+ CCTP supported chains: `ethereum`, `avalanche`, `optimism`, `arbitrum`, `base`, `polygon`
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # exploit-scan.sh — run a one-shot exploit detection scan across all chains
3
+ # Usage: bash exploit-scan.sh [chain]
4
+ set -euo pipefail
5
+
6
+ DEFI="${DEFI_CMD:-defi}"
7
+ CHAIN="${1:-hyperevm}"
8
+
9
+ echo "[exploit-scan] Scanning $CHAIN for oracle divergence, stablecoin depeg, exchange rate anomalies..." >&2
10
+ "$DEFI" --json --chain "$CHAIN" scan --once --patterns oracle,stable,exchange_rate
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ # portfolio-snapshot.sh — take a portfolio snapshot and print PnL since last snapshot
3
+ # Usage: WALLET=0xABC... bash portfolio-snapshot.sh [chain]
4
+ set -euo pipefail
5
+
6
+ DEFI="${DEFI_CMD:-defi}"
7
+ WALLET="${DEFI_WALLET_ADDRESS:-${WALLET:-}}"
8
+ CHAIN="${1:-hyperevm}"
9
+
10
+ if [[ -z "$WALLET" ]]; then
11
+ echo '{"error":"Set DEFI_WALLET_ADDRESS or WALLET env var"}' >&2
12
+ exit 1
13
+ fi
14
+
15
+ echo "[portfolio] Taking snapshot for $WALLET on $CHAIN..." >&2
16
+ "$DEFI" --json --chain "$CHAIN" portfolio snapshot --address "$WALLET"
17
+
18
+ echo "[portfolio] Calculating PnL..." >&2
19
+ "$DEFI" --json --chain "$CHAIN" portfolio pnl --address "$WALLET" || true
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ # preflight.sh — verify defi-cli is installed and wallet is configured
3
+ set -euo pipefail
4
+
5
+ DEFI="${DEFI_CMD:-defi}"
6
+
7
+ # Check install
8
+ if ! command -v "$DEFI" &>/dev/null; then
9
+ echo '{"ok":false,"error":"defi-cli not found. Install: npm install -g @hypurrquant/defi-cli@latest"}' >&2
10
+ exit 1
11
+ fi
12
+
13
+ VERSION=$("$DEFI" --version 2>/dev/null || echo "unknown")
14
+ echo "{\"ok\":true,\"version\":\"$VERSION\",\"wallet\":\"${DEFI_WALLET_ADDRESS:-not_set}\"}"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ # yield-scan.sh — scan all chains for best yield on an asset
3
+ # Usage: ASSET=USDC bash yield-scan.sh
4
+ set -euo pipefail
5
+
6
+ DEFI="${DEFI_CMD:-defi}"
7
+ ASSET="${ASSET:-USDC}"
8
+
9
+ echo "[yield-scan] Scanning all chains for $ASSET yield opportunities..." >&2
10
+ "$DEFI" --json yield scan --asset "$ASSET"