starkfi 0.4.4 β 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/MCP.md +35 -1
- package/README.md +42 -13
- package/dist/index.js +145 -129
- package/package.json +6 -5
- package/skills/README.md +5 -2
- package/skills/lending/SKILL.md +95 -6
- package/skills/portfolio/SKILL.md +76 -11
package/MCP.md
CHANGED
|
@@ -21,7 +21,7 @@ To integrate StarkFi into your AI environment, configure your MCP client setting
|
|
|
21
21
|
|
|
22
22
|
## Tool Registry
|
|
23
23
|
|
|
24
|
-
Upon initialization, the StarkFi server dynamically provisions **
|
|
24
|
+
Upon initialization, the StarkFi server dynamically provisions **30 tool schemas** to the connected AI client. Tools are organized into domain-specific registration modules (`src/mcp/tools/`): **auth** (2), **wallet** (6), **trade** (5), **staking** (8), and **lending** (9).
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
@@ -268,6 +268,40 @@ Atomically closes an active Vesu V2 lending position. Repays all outstanding deb
|
|
|
268
268
|
| `collateral_token` | string | **Yes** | Collateral token symbol of the position (e.g. `STRK`, `ETH`) |
|
|
269
269
|
| `debt_token` | string | **Yes** | Borrowed token symbol of the position (e.g. `USDC`, `USDT`) |
|
|
270
270
|
|
|
271
|
+
#### `monitor_lending_position`
|
|
272
|
+
|
|
273
|
+
Monitors health factors across lending positions. Returns alerts and actionable recommendations when health factor drops below configurable thresholds.
|
|
274
|
+
|
|
275
|
+
| Parameter | Type | Required | Description |
|
|
276
|
+
| ------------------- | ------ | -------- | -------------------------------------------------------------------------------- |
|
|
277
|
+
| `pool` | string | No | Pool name or address. Omit to scan all pools for active borrow positions. |
|
|
278
|
+
| `collateral_token` | string | No | Collateral token symbol. Required when specifying a pool. |
|
|
279
|
+
| `borrow_token` | string | No | Debt token symbol. Required when specifying a pool. |
|
|
280
|
+
| `warning_threshold` | number | No | Custom warning threshold (default: `1.3`). |
|
|
281
|
+
|
|
282
|
+
#### `auto_rebalance_lending`
|
|
283
|
+
|
|
284
|
+
Automatically adjusts a lending position to restore health factor via debt repayment or additional collateral. Supports simulation mode.
|
|
285
|
+
|
|
286
|
+
| Parameter | Type | Required | Description |
|
|
287
|
+
| ---------------------- | ------- | -------- | ------------------------------------------------------------------------ |
|
|
288
|
+
| `pool` | string | **Yes** | Pool name or address |
|
|
289
|
+
| `collateral_token` | string | **Yes** | Collateral token symbol |
|
|
290
|
+
| `borrow_token` | string | **Yes** | Debt token symbol |
|
|
291
|
+
| `strategy` | enum | No | `repay`, `add-collateral`, or `auto` (default: `auto`) |
|
|
292
|
+
| `target_health_factor` | number | No | Target health factor (default: `1.3`) |
|
|
293
|
+
| `simulate` | boolean | No | Set `true` to preview adjustment without executing |
|
|
294
|
+
|
|
295
|
+
#### `rebalance_portfolio`
|
|
296
|
+
|
|
297
|
+
Rebalances a portfolio to match a target allocation. Calculates optimal swaps and executes as a single batch transaction via Fibrous routing.
|
|
298
|
+
|
|
299
|
+
| Parameter | Type | Required | Description |
|
|
300
|
+
| ----------- | ------- | -------- | ----------------------------------------------------------------- |
|
|
301
|
+
| `target` | string | **Yes** | Target allocation, e.g. `"50 ETH, 30 USDC, 20 STRK"` |
|
|
302
|
+
| `slippage` | number | No | Slippage tolerance % (default: `1`) |
|
|
303
|
+
| `simulate` | boolean | No | Set `true` to preview plan without executing |
|
|
304
|
+
|
|
271
305
|
---
|
|
272
306
|
|
|
273
307
|
### Configuration Utilities
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npx starkfi@latest --help
|
|
|
23
23
|
|
|
24
24
|
Most DeFi tools are built for humans clicking buttons. StarkFi is built for **agents**.
|
|
25
25
|
|
|
26
|
-
- π€ **
|
|
26
|
+
- π€ **30 MCP tools** β Any AI assistant (Cursor, Claude, Antigravity) can execute DeFi operations autonomously
|
|
27
27
|
- β‘ **Atomic Batching** β Combine swap + stake + lend + send into a single multicall transaction
|
|
28
28
|
- πΈ **Gas Abstraction Built-In** β Pay gas in STRK, ETH, USDC, USDT, or DAI via AVNU Paymaster, or let the developer sponsor gas entirely (gasfree mode)
|
|
29
29
|
- π **Full Portfolio** β Unified view of balances, staking positions, and lending positions with USD values
|
|
@@ -40,7 +40,7 @@ Most DeFi tools are built for humans clicking buttons. StarkFi is built for **ag
|
|
|
40
40
|
β β
|
|
41
41
|
β ββββββββββββ ββββββββββββββββββ ββββββββββββββββββ βββββββββββββββββββββββββββ β
|
|
42
42
|
β β CLI β β MCP Server β β Agent Skills β β Telegram Bot β β
|
|
43
|
-
β β (30+ β β (
|
|
43
|
+
β β (30+ β β (30 tools) β β (10 workflows) β β (BYOAI Β· Chat DeFi) β β
|
|
44
44
|
β β commands)β β stdio transportβ β npx starkfi β β OpenAI / Claude / β β
|
|
45
45
|
β ββββββ¬ββββββ ββββββββ¬ββββββββββ βββββββ¬βββββββββββ β Gemini β β
|
|
46
46
|
β β β β βββββββββββββ¬ββββββββββββββ β
|
|
@@ -136,6 +136,17 @@ npx starkfi@latest lend-status -p Prime --collateral-token STRK --borrow-token U
|
|
|
136
136
|
npx starkfi@latest lend-close -p Prime --collateral-token STRK --borrow-token USDC
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
+
### π©Ί Lending Agent (Health Monitoring)
|
|
140
|
+
|
|
141
|
+
Real-time health factor monitoring with risk classification and automated position rebalancing.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npx starkfi@latest lend-monitor # Scan all positions
|
|
145
|
+
npx starkfi@latest lend-monitor -p Prime --collateral-token ETH --borrow-token USDC
|
|
146
|
+
npx starkfi@latest lend-auto -p Prime --collateral-token ETH --borrow-token USDC
|
|
147
|
+
npx starkfi@latest lend-auto -p Prime --collateral-token ETH --borrow-token USDC --simulate
|
|
148
|
+
```
|
|
149
|
+
|
|
139
150
|
### πΈ Gas Abstraction
|
|
140
151
|
|
|
141
152
|
Users pay gas fees in their preferred ERC-20 token via AVNU Paymaster β no native STRK or ETH required. Alternatively, developers can sponsor gas entirely.
|
|
@@ -171,11 +182,20 @@ npx starkfi@latest portfolio
|
|
|
171
182
|
# β Token Balances (USD), Staking Positions, Lending Positions, Total Value
|
|
172
183
|
```
|
|
173
184
|
|
|
185
|
+
### π Portfolio Optimization
|
|
186
|
+
|
|
187
|
+
Rebalance your portfolio to a target allocation via automated batch swaps.
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npx starkfi@latest portfolio-rebalance --target "50 ETH, 30 USDC, 20 STRK"
|
|
191
|
+
npx starkfi@latest portfolio-rebalance --target "60 ETH, 40 STRK" --simulate
|
|
192
|
+
```
|
|
193
|
+
|
|
174
194
|
---
|
|
175
195
|
|
|
176
196
|
## AI Integration (MCP)
|
|
177
197
|
|
|
178
|
-
StarkFi exposes **
|
|
198
|
+
StarkFi exposes **30 MCP tools** via stdio transport, enabling AI assistants to execute DeFi operations.
|
|
179
199
|
|
|
180
200
|
```bash
|
|
181
201
|
# Start the MCP server
|
|
@@ -184,13 +204,13 @@ npx starkfi@latest mcp-start
|
|
|
184
204
|
|
|
185
205
|
### Tool Categories
|
|
186
206
|
|
|
187
|
-
| Category | Tools
|
|
188
|
-
| ----------------- |
|
|
189
|
-
| **Auth & Config** | `get_auth_status`, `config_action`
|
|
190
|
-
| **Wallet** | `get_balance`, `get_portfolio`, `deploy_account`, `send_tokens`, `get_tx_status`
|
|
191
|
-
| **Trade** | `get_swap_quote`, `swap_tokens`, `get_multi_swap_quote`, `multi_swap`, `batch_execute`
|
|
192
|
-
| **Staking** | `list_validators`, `list_pools`, `get_staking_info`, `get_stake_status`, `stake_tokens`, `unstake_tokens`, `claim_rewards`, `compound_rewards`
|
|
193
|
-
| **Lending** | `list_lending_pools`, `get_lending_position`, `supply_assets`, `withdraw_assets`, `borrow_assets`, `repay_debt`, `close_position`
|
|
207
|
+
| Category | Tools | Count |
|
|
208
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
209
|
+
| **Auth & Config** | `get_auth_status`, `config_action` | 2 |
|
|
210
|
+
| **Wallet** | `get_balance`, `get_portfolio`, `deploy_account`, `send_tokens`, `get_tx_status`, `rebalance_portfolio` | 6 |
|
|
211
|
+
| **Trade** | `get_swap_quote`, `swap_tokens`, `get_multi_swap_quote`, `multi_swap`, `batch_execute` | 5 |
|
|
212
|
+
| **Staking** | `list_validators`, `list_pools`, `get_staking_info`, `get_stake_status`, `stake_tokens`, `unstake_tokens`, `claim_rewards`, `compound_rewards` | 8 |
|
|
213
|
+
| **Lending** | `list_lending_pools`, `get_lending_position`, `supply_assets`, `withdraw_assets`, `borrow_assets`, `repay_debt`, `close_position`, `monitor_lending_position`, `auto_rebalance_lending` | 9 |
|
|
194
214
|
|
|
195
215
|
### Example β AI Agent Workflow
|
|
196
216
|
|
|
@@ -328,6 +348,15 @@ npx starkfi@latest trade 10 STRK ETH # Execute
|
|
|
328
348
|
| `lend-repay <amount> -p <pool> -t <token> --collateral-token <t>` | Repay debt |
|
|
329
349
|
| `lend-status [-p <pool> --collateral-token <t> [--borrow-token <t>]]` | Position status (auto-scan if no args) |
|
|
330
350
|
| `lend-close -p <pool> --collateral-token <t> --borrow-token <t>` | Close position atomically |
|
|
351
|
+
| `lend-monitor [-p <pool> --collateral-token <t> --borrow-token <t>]` | Monitor health factors |
|
|
352
|
+
| `lend-auto -p <pool> --collateral-token <t> --borrow-token <t> [--strategy <type>]` | Auto-rebalance position |
|
|
353
|
+
|
|
354
|
+
### Portfolio
|
|
355
|
+
|
|
356
|
+
| Command | Description |
|
|
357
|
+
| -------------------------------------------------------------------------------------- | ------------------------------- |
|
|
358
|
+
| `portfolio [--json]` | Full DeFi dashboard |
|
|
359
|
+
| `portfolio-rebalance --target "<allocation>" [--slippage <%>] [--simulate] [--json]` | Rebalance to target allocation |
|
|
331
360
|
|
|
332
361
|
### Configuration
|
|
333
362
|
|
|
@@ -413,15 +442,15 @@ See [`starkfi-telegram-bot/`](https://github.com/ahmetenesdur/starkfi-telegram-b
|
|
|
413
442
|
|
|
414
443
|
## Error Handling
|
|
415
444
|
|
|
416
|
-
StarkFi implements a robust error handling system with a custom `StarkfiError` class and **
|
|
445
|
+
StarkFi implements a robust error handling system with a custom `StarkfiError` class and **28 specific error codes** organized by domain:
|
|
417
446
|
|
|
418
447
|
| Domain | Error Codes |
|
|
419
448
|
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
420
449
|
| **Auth** | `AUTH_REQUIRED`, `AUTH_FAILED`, `SESSION_EXPIRED` |
|
|
421
450
|
| **Wallet** | `WALLET_NOT_DEPLOYED`, `WALLET_NOT_FOUND`, `INSUFFICIENT_BALANCE` |
|
|
422
451
|
| **Network** | `NETWORK_ERROR`, `RATE_LIMITED`, `TX_FAILED`, `TX_NOT_FOUND`, `PAYMASTER_ERROR` |
|
|
423
|
-
| **Validation** | `INVALID_CONFIG`, `INVALID_ADDRESS`, `INVALID_AMOUNT` |
|
|
424
|
-
| **DeFi** | `SWAP_FAILED`, `NO_ROUTE_FOUND`, `SLIPPAGE_EXCEEDED`, `STAKING_FAILED`, `LENDING_FAILED`, `POOL_NOT_FOUND`, `EXIT_NOT_READY`, `VALIDATOR_NOT_FOUND` |
|
|
452
|
+
| **Validation** | `INVALID_CONFIG`, `INVALID_ADDRESS`, `INVALID_AMOUNT`, `INVALID_ALLOCATION` |
|
|
453
|
+
| **DeFi** | `SWAP_FAILED`, `NO_ROUTE_FOUND`, `SLIPPAGE_EXCEEDED`, `STAKING_FAILED`, `LENDING_FAILED`, `POOL_NOT_FOUND`, `EXIT_NOT_READY`, `VALIDATOR_NOT_FOUND`, `MONITOR_FAILED`, `REBALANCE_FAILED` |
|
|
425
454
|
| **System** | `SIMULATION_FAILED`, `BATCH_LIMIT_EXCEEDED`, `UNKNOWN` |
|
|
426
455
|
|
|
427
456
|
All network operations include **automatic retry with exponential backoff** (500ms base, max 2 retries). Parallel operations use a **sliding-window concurrency pool** to prevent RPC rate-limiting.
|