@hypurrquant/defi-cli 0.1.0 → 0.2.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/README.md +356 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/main.js +8 -2
- package/dist/main.js.map +1 -1
- package/dist/mcp-server.js +5592 -0
- package/dist/mcp-server.js.map +1 -0
- package/mcp-config.example.json +13 -0
- package/package.json +38 -6
- package/config/protocols/lending/.omc/state/last-tool-error.json +0 -7
package/README.md
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
# defi-cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@hypurrquant/defi-cli)
|
|
4
|
+
[](https://www.npmjs.com/package/@hypurrquant/defi-cli)
|
|
5
|
+
[](https://github.com/hypurrquant/defi-cli/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
Multi-chain DeFi CLI — **HyperEVM** and **Mantle** with 32 protocols for lending, DEX, LP, bridge, vault, staking, gauge, and farm operations.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @hypurrquant/defi-cli # global install
|
|
11
|
+
defi --json status
|
|
12
|
+
|
|
13
|
+
# Or without global install (restricted environments)
|
|
14
|
+
npx -y @hypurrquant/defi-cli --json status
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **2 Chains** — HyperEVM (chain 999) and Mantle (chain 5000)
|
|
20
|
+
- **32 Protocols** — 14 DEX (Uniswap, Algebra, Balancer, Curve, Solidly, etc.), 9 lending (Aave, Compound, Euler, Morpho, etc.), vaults, liquid staking, CDP, yield aggregators
|
|
21
|
+
- **Lending** — rates, positions, supply, borrow, repay, withdraw across all lending protocols
|
|
22
|
+
- **DEX** — quote, swap, LP add/remove, compare prices across DEXes
|
|
23
|
+
- **LP Management** — add/remove liquidity, manage concentrated positions
|
|
24
|
+
- **Bridge** — cross-chain token transfer via Lifi and deBridge
|
|
25
|
+
- **Vault** — deposit, withdraw, yield tracking
|
|
26
|
+
- **Staking** — stake, unstake, claim rewards
|
|
27
|
+
- **Gauge** — deposit, withdraw, lock, vote, claim rewards
|
|
28
|
+
- **Farm** — deposit, withdraw, claim yields
|
|
29
|
+
- **Portfolio** — unified balance and position overview
|
|
30
|
+
- **Agent-First Design** — `--json`, `--fields`, `--ndjson`, `--dry-run`, runtime schema introspection
|
|
31
|
+
- **Safety** — pre-flight checks, dry-run validation, schema introspection
|
|
32
|
+
|
|
33
|
+
## Setup
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Set wallet credentials
|
|
37
|
+
export DEFI_PRIVATE_KEY="0x..." # Private key for transactions
|
|
38
|
+
export DEFI_WALLET_ADDRESS="0x..." # Wallet address for queries
|
|
39
|
+
|
|
40
|
+
# Optional: override RPC endpoints (defaults provided)
|
|
41
|
+
export HYPEREVM_RPC_URL="https://..."
|
|
42
|
+
export MANTLE_RPC_URL="https://..."
|
|
43
|
+
|
|
44
|
+
# Verify setup
|
|
45
|
+
defi --json status
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Command Groups
|
|
49
|
+
|
|
50
|
+
| Group | Subcommands | Description |
|
|
51
|
+
|-------|------------|-------------|
|
|
52
|
+
| `status` | — | Unified dashboard: balances, positions, rates |
|
|
53
|
+
| `schema` | — | Runtime schema introspection for agents |
|
|
54
|
+
| `dex` | quote, swap, lp-add, lp-remove, compare | DEX operations: prices, trades, liquidity |
|
|
55
|
+
| `lending` | rates, position, supply, borrow, repay, withdraw | Lending protocol operations |
|
|
56
|
+
| `gauge` | deposit, withdraw, lock, vote, claim | Gauge voting and reward claims |
|
|
57
|
+
| `farm` | deposit, withdraw, claim, info | Yield farming operations |
|
|
58
|
+
| `cdp` | open, adjust, close, info | Collateralized debt position management |
|
|
59
|
+
| `staking` | stake, unstake, info | Staking and reward management |
|
|
60
|
+
| `vault` | deposit, withdraw, info | Vault deposits and yield tracking |
|
|
61
|
+
| `bridge` | — | Cross-chain token bridge (LI.FI, deBridge, CCTP) |
|
|
62
|
+
| `yield` | compare, scan, execute, optimize | Yield aggregator and strategy tracking |
|
|
63
|
+
| `portfolio` | — | Cross-protocol unified portfolio view |
|
|
64
|
+
| `positions` | — | Summary of all open positions |
|
|
65
|
+
| `price` | token, dex | Token prices and DEX aggregation |
|
|
66
|
+
| `token` | balance, allowance, approve, transfer | ERC20 token operations |
|
|
67
|
+
| `wallet` | balance, nonce, gas | Wallet info and on-chain data |
|
|
68
|
+
| `whales` | watch, track, alerts | Large holder tracking |
|
|
69
|
+
| `scan` | exploits, arbitrage, opportunities | Protocol scanning and opportunity detection |
|
|
70
|
+
| `compare` | yields, rates, costs | Cross-protocol comparison |
|
|
71
|
+
| `swap` | aggregator | Aggregated DEX swap finder |
|
|
72
|
+
| `arb` | scan, execute, monitor | Arbitrage opportunities |
|
|
73
|
+
| `monitor` | positions, yields, risks | Live monitoring and alerts |
|
|
74
|
+
| `alert` | setup, add, test, list, start, stop | Telegram price and yield alerts |
|
|
75
|
+
| `nft` | collections, balances | NFT portfolio tracking |
|
|
76
|
+
|
|
77
|
+
## Supported Protocols
|
|
78
|
+
|
|
79
|
+
### DEX (14 protocols)
|
|
80
|
+
|
|
81
|
+
| Chain | Protocol | Type |
|
|
82
|
+
|-------|----------|------|
|
|
83
|
+
| HyperEVM | HyperSwap V3 | Uniswap V3 AMM |
|
|
84
|
+
| HyperEVM | HyperSwap V2 | Uniswap V2 AMM |
|
|
85
|
+
| HyperEVM | KittenSwap | Solidly V2 AMM |
|
|
86
|
+
| HyperEVM | Ramses CL | Algebra V3 AMM |
|
|
87
|
+
| HyperEVM | Ramses HL | Solidly CL AMM |
|
|
88
|
+
| HyperEVM | Project X | Uniswap V2 AMM |
|
|
89
|
+
| HyperEVM | Nest | Solidly V2 AMM |
|
|
90
|
+
| HyperEVM | Ring Few | Solidly CL AMM |
|
|
91
|
+
| HyperEVM | WooFi | Spot Trading |
|
|
92
|
+
| Mantle | Uniswap V3 | Uniswap V3 AMM |
|
|
93
|
+
| Mantle | Merchant Joe | Solidly V2 AMM |
|
|
94
|
+
| Both | Balancer V3 | Weighted Pool AMM |
|
|
95
|
+
| Both | Curve | Stablecoin Swap |
|
|
96
|
+
| Both | DEX Price Feed | Oracle |
|
|
97
|
+
|
|
98
|
+
### Lending (9 protocols)
|
|
99
|
+
|
|
100
|
+
| Chain | Protocol | Type |
|
|
101
|
+
|-------|----------|------|
|
|
102
|
+
| HyperEVM | HyperLend | Aave V3 Fork |
|
|
103
|
+
| HyperEVM | HyperYield | Supply Market |
|
|
104
|
+
| HyperEVM | PurrlendV2 | Lendable Market |
|
|
105
|
+
| HyperEVM | PrimeFi | Lending |
|
|
106
|
+
| Mantle | Aave V3 | Lending |
|
|
107
|
+
| Mantle | Lendle | Aave V3 Fork |
|
|
108
|
+
| Both | Euler V2 | Lending |
|
|
109
|
+
| Both | Morpho Blue | Lending |
|
|
110
|
+
| Both | Felix Morpho | CDP + Lending |
|
|
111
|
+
|
|
112
|
+
### Other Protocols
|
|
113
|
+
|
|
114
|
+
| Category | Chain | Protocol |
|
|
115
|
+
|----------|-------|----------|
|
|
116
|
+
| **Liquid Staking** | HyperEVM | stHYPE (Generic LST) |
|
|
117
|
+
| — | HyperEVM | Kinetiq (Mantle LST) |
|
|
118
|
+
| **Vaults** | HyperEVM | Hyperbeat (ERC4626) |
|
|
119
|
+
| — | HyperEVM | Hypersurface (ERC4626) |
|
|
120
|
+
| — | HyperEVM | Looping (ERC4626) |
|
|
121
|
+
| — | Mantle | Upshift (ERC4626) |
|
|
122
|
+
| — | Both | Felix Vaults (ERC4626) |
|
|
123
|
+
| **CDP** | Both | Felix (MorphoBlue) |
|
|
124
|
+
| **Yield Aggregator** | HyperEVM | Lazy Summer |
|
|
125
|
+
| **NFT** | HyperEVM | Seaport |
|
|
126
|
+
|
|
127
|
+
## Core Commands
|
|
128
|
+
|
|
129
|
+
### Status & Portfolio
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Unified dashboard: balances + positions + yields
|
|
133
|
+
defi --json status
|
|
134
|
+
|
|
135
|
+
# Cross-protocol portfolio view
|
|
136
|
+
defi --json portfolio
|
|
137
|
+
|
|
138
|
+
# Open positions across all protocols
|
|
139
|
+
defi --json positions
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### DEX Operations
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Get swap quote (no execution)
|
|
146
|
+
defi --json dex quote --protocol hyperswap --token-in HYPE --token-out USDC --amount 1000000000000000000
|
|
147
|
+
|
|
148
|
+
# Execute swap
|
|
149
|
+
defi --json dex swap --protocol hyperswap --token-in HYPE --token-out USDC --amount 1000000000000000000 --broadcast
|
|
150
|
+
|
|
151
|
+
# Add liquidity
|
|
152
|
+
defi --json dex lp-add --protocol hyperswap --token-a HYPE --token-b USDC --amount-a 1000000000000000000 --amount-b 5000000000 --broadcast
|
|
153
|
+
|
|
154
|
+
# Remove liquidity
|
|
155
|
+
defi --json dex lp-remove --protocol hyperswap --lp-token <ADDRESS> --amount <AMOUNT> --broadcast
|
|
156
|
+
|
|
157
|
+
# Compare prices across DEXes
|
|
158
|
+
defi --json dex compare --token-in HYPE --token-out USDC --amount 1000000000000000000
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Lending Operations
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Get lending rates across all protocols
|
|
165
|
+
defi --json lending rates
|
|
166
|
+
|
|
167
|
+
# Check user position in a protocol
|
|
168
|
+
defi --json lending position --protocol hyperlend
|
|
169
|
+
|
|
170
|
+
# Supply collateral
|
|
171
|
+
defi --json lending supply --protocol hyperlend --token USDC --amount 1000000000 --broadcast
|
|
172
|
+
|
|
173
|
+
# Borrow assets
|
|
174
|
+
defi --json lending borrow --protocol hyperlend --token HYPE --amount 1000000000000000000 --broadcast
|
|
175
|
+
|
|
176
|
+
# Repay debt
|
|
177
|
+
defi --json lending repay --protocol hyperlend --token HYPE --amount 500000000000000000 --broadcast
|
|
178
|
+
|
|
179
|
+
# Withdraw collateral
|
|
180
|
+
defi --json lending withdraw --protocol hyperlend --token USDC --amount 500000000 --broadcast
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Staking
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Stake tokens
|
|
187
|
+
defi --json staking stake --protocol kinetiq --amount 1000000000000000000 --broadcast
|
|
188
|
+
|
|
189
|
+
# Unstake tokens
|
|
190
|
+
defi --json staking unstake --protocol kinetiq --amount 500000000000000000 --broadcast
|
|
191
|
+
|
|
192
|
+
# Check staking info
|
|
193
|
+
defi --json staking info --protocol kinetiq
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Gauge & Voting
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Deposit into gauge
|
|
200
|
+
defi --json gauge deposit --protocol kinetiq --amount 1000000000000000000 --broadcast
|
|
201
|
+
|
|
202
|
+
# Lock tokens for voting power
|
|
203
|
+
defi --json gauge lock --protocol kinetiq --amount 1000000000000000000 --weeks 52 --broadcast
|
|
204
|
+
|
|
205
|
+
# Vote on proposals
|
|
206
|
+
defi --json gauge vote --protocol kinetiq --gauge <ADDRESS> --weight 100 --broadcast
|
|
207
|
+
|
|
208
|
+
# Claim gauge rewards
|
|
209
|
+
defi --json gauge claim --protocol kinetiq --broadcast
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Vaults
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Deposit into vault
|
|
216
|
+
defi --json vault deposit --protocol hyperbeat --amount 1000000000000000000 --broadcast
|
|
217
|
+
|
|
218
|
+
# Withdraw from vault
|
|
219
|
+
defi --json vault withdraw --protocol hyperbeat --shares 1000000000000000000 --broadcast
|
|
220
|
+
|
|
221
|
+
# Check vault info and yield
|
|
222
|
+
defi --json vault info --protocol hyperbeat
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Bridge
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Bridge tokens (LI.FI, deBridge, or CCTP)
|
|
229
|
+
defi --json bridge --token USDC --amount 1000000000 --to-chain mantle --provider lifi
|
|
230
|
+
|
|
231
|
+
# Bridge via deBridge
|
|
232
|
+
defi --json bridge --token USDC --amount 1000000000 --to-chain mantle --provider debridge --broadcast
|
|
233
|
+
|
|
234
|
+
# Cross-chain transfer via CCTP
|
|
235
|
+
defi --json bridge --token USDC --amount 1000000000 --to-chain mantle --provider cctp --broadcast
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Yield & Farming
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Get yield comparison across protocols
|
|
242
|
+
defi --json yield compare
|
|
243
|
+
|
|
244
|
+
# Scan yield opportunities
|
|
245
|
+
defi --json yield scan
|
|
246
|
+
|
|
247
|
+
# Execute yield strategy
|
|
248
|
+
defi --json yield execute --strategy lazy-summer --amount 1000000000000000000 --broadcast
|
|
249
|
+
|
|
250
|
+
# Farm deposit via MasterChef
|
|
251
|
+
defi --json farm deposit --protocol lazy-summer --amount 1000000000000000000 --broadcast
|
|
252
|
+
|
|
253
|
+
# Farm withdraw
|
|
254
|
+
defi --json farm withdraw --protocol lazy-summer --amount 500000000000000000 --broadcast
|
|
255
|
+
|
|
256
|
+
# Farm claim rewards
|
|
257
|
+
defi --json farm claim --protocol lazy-summer --broadcast
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Scanning & Arbitrage
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Scan for exploits and opportunities
|
|
264
|
+
defi --json scan exploits
|
|
265
|
+
|
|
266
|
+
# Scan arbitrage opportunities
|
|
267
|
+
defi --json arb scan --min 0.5
|
|
268
|
+
|
|
269
|
+
# Execute arbitrage
|
|
270
|
+
defi --json arb execute --symbol token --buy-exchange exchange1 --sell-exchange exchange2 --amount 1000000000000000000 --broadcast
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Token & Wallet Operations
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Check token balance
|
|
277
|
+
defi --json token balance --address 0x... --token USDC
|
|
278
|
+
|
|
279
|
+
# Approve token spending
|
|
280
|
+
defi --json token approve --token USDC --spender 0x... --amount 1000000000 --broadcast
|
|
281
|
+
|
|
282
|
+
# Check wallet balance
|
|
283
|
+
defi --json wallet balance --address 0x...
|
|
284
|
+
|
|
285
|
+
# Get wallet nonce
|
|
286
|
+
defi --json wallet nonce --address 0x...
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Price & Market Data
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# Get token price from oracles and DEXes
|
|
293
|
+
defi --json price --asset HYPE
|
|
294
|
+
|
|
295
|
+
# Get price from DEX sources only
|
|
296
|
+
defi --json price --asset HYPE --source dex
|
|
297
|
+
|
|
298
|
+
# Get price from oracle sources only
|
|
299
|
+
defi --json price --asset HYPE --source oracle
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Agent-First Design
|
|
303
|
+
|
|
304
|
+
Built for AI agents and automation with structured output, schema introspection, and validation:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Every command returns JSON envelope
|
|
308
|
+
defi --json status
|
|
309
|
+
# → { "ok": true, "data": {...}, "meta": { "timestamp": "..." } }
|
|
310
|
+
|
|
311
|
+
# Runtime schema introspection (query available commands)
|
|
312
|
+
defi --json schema
|
|
313
|
+
|
|
314
|
+
# Filter output to specific fields (saves tokens)
|
|
315
|
+
defi --json --fields balance,positions status
|
|
316
|
+
|
|
317
|
+
# Stream large lists as NDJSON (one JSON per line)
|
|
318
|
+
defi --json --ndjson dex quote --protocol hyperswap --token-in HYPE --token-out USDC --amount 1000000000000000000
|
|
319
|
+
|
|
320
|
+
# Pre-validate before executing
|
|
321
|
+
defi --json --dry-run dex swap --protocol hyperswap --token-in HYPE --token-out USDC --amount 1000000000000000000
|
|
322
|
+
|
|
323
|
+
# Safe by default: --dry-run is on, use --broadcast to execute
|
|
324
|
+
defi --json dex swap --protocol hyperswap --token-in HYPE --token-out USDC --amount 1000000000000000000 --broadcast
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
All responses are auto-sanitized (control chars stripped, prompt injection patterns blocked).
|
|
328
|
+
Errors include `retryable` flag — only retry when `true`.
|
|
329
|
+
|
|
330
|
+
## Global Flags
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
--json # Output as JSON (structured for agents)
|
|
334
|
+
--ndjson # Output as newline-delimited JSON
|
|
335
|
+
--fields <f> # Select output fields (comma-separated)
|
|
336
|
+
--chain <chain> # Target chain: hyperevm (default) or mantle
|
|
337
|
+
--dry-run # Dry-run mode (default, no broadcast)
|
|
338
|
+
--broadcast # Execute transaction on-chain
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Environment Variables
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
DEFI_PRIVATE_KEY # Private key for signing transactions
|
|
345
|
+
DEFI_WALLET_ADDRESS # Wallet address for queries and execution
|
|
346
|
+
HYPEREVM_RPC_URL # Override HyperEVM RPC endpoint
|
|
347
|
+
MANTLE_RPC_URL # Override Mantle RPC endpoint
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## MCP Server (Coming Soon)
|
|
351
|
+
|
|
352
|
+
MCP server support for Claude Desktop, Cursor, and other MCP clients is in development. Full tool integrations for lending, DEX, staking, and portfolio tracking will be available soon.
|
|
353
|
+
|
|
354
|
+
## License
|
|
355
|
+
|
|
356
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -1012,9 +1012,11 @@ var DEFAULT_PRIORITY_FEE_WEI = 100000000n;
|
|
|
1012
1012
|
var Executor = class _Executor {
|
|
1013
1013
|
dryRun;
|
|
1014
1014
|
rpcUrl;
|
|
1015
|
-
|
|
1015
|
+
explorerUrl;
|
|
1016
|
+
constructor(broadcast, rpcUrl, explorerUrl) {
|
|
1016
1017
|
this.dryRun = !broadcast;
|
|
1017
1018
|
this.rpcUrl = rpcUrl;
|
|
1019
|
+
this.explorerUrl = explorerUrl;
|
|
1018
1020
|
}
|
|
1019
1021
|
/** Apply 20% buffer to a gas estimate */
|
|
1020
1022
|
static applyGasBuffer(gas) {
|
|
@@ -1149,7 +1151,10 @@ var Executor = class _Executor {
|
|
|
1149
1151
|
maxFeePerGas: maxFeePerGas > 0n ? maxFeePerGas : void 0,
|
|
1150
1152
|
maxPriorityFeePerGas: maxPriorityFeePerGas > 0n ? maxPriorityFeePerGas : void 0
|
|
1151
1153
|
});
|
|
1154
|
+
const txUrl = this.explorerUrl ? `${this.explorerUrl}/tx/${txHash}` : void 0;
|
|
1152
1155
|
process.stderr.write(`Transaction sent: ${txHash}
|
|
1156
|
+
`);
|
|
1157
|
+
if (txUrl) process.stderr.write(`Explorer: ${txUrl}
|
|
1153
1158
|
`);
|
|
1154
1159
|
process.stderr.write("Waiting for confirmation...\n");
|
|
1155
1160
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
@@ -1165,6 +1170,7 @@ var Executor = class _Executor {
|
|
|
1165
1170
|
block_number: receipt.blockNumber?.toString(),
|
|
1166
1171
|
gas_limit: gasLimit.toString(),
|
|
1167
1172
|
gas_used: receipt.gasUsed?.toString(),
|
|
1173
|
+
explorer_url: txUrl,
|
|
1168
1174
|
mode: "broadcast"
|
|
1169
1175
|
}
|
|
1170
1176
|
};
|
|
@@ -8235,7 +8241,7 @@ function makeExecutor() {
|
|
|
8235
8241
|
const opts = program.opts();
|
|
8236
8242
|
const registry = Registry.loadEmbedded();
|
|
8237
8243
|
const chain = registry.getChain(opts.chain ?? "hyperevm");
|
|
8238
|
-
return new Executor(!!opts.broadcast, chain.effectiveRpcUrl());
|
|
8244
|
+
return new Executor(!!opts.broadcast, chain.effectiveRpcUrl(), chain.explorer_url);
|
|
8239
8245
|
}
|
|
8240
8246
|
registerStatus(program, getOutputMode);
|
|
8241
8247
|
registerSchema(program, getOutputMode);
|