starkfi 0.2.0 → 0.3.1
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/LICENSE +1 -1
- package/MCP.md +270 -48
- package/README.md +395 -87
- package/dist/commands/batch/batch.d.ts.map +1 -1
- package/dist/commands/batch/batch.js +12 -0
- package/dist/commands/batch/batch.js.map +1 -1
- package/dist/commands/config/config.d.ts.map +1 -1
- package/dist/commands/config/config.js +12 -6
- package/dist/commands/config/config.js.map +1 -1
- package/dist/commands/lending/lending.d.ts.map +1 -1
- package/dist/commands/lending/lending.js +15 -8
- package/dist/commands/lending/lending.js.map +1 -1
- package/dist/commands/staking/staking.d.ts.map +1 -1
- package/dist/commands/staking/staking.js +6 -4
- package/dist/commands/staking/staking.js.map +1 -1
- package/dist/commands/trade/multi-swap.d.ts.map +1 -1
- package/dist/commands/trade/multi-swap.js +3 -2
- package/dist/commands/trade/multi-swap.js.map +1 -1
- package/dist/commands/trade/swap.d.ts.map +1 -1
- package/dist/commands/trade/swap.js +3 -2
- package/dist/commands/trade/swap.js.map +1 -1
- package/dist/commands/wallet/balance.js +1 -1
- package/dist/commands/wallet/balance.js.map +1 -1
- package/dist/commands/wallet/send.js +1 -1
- package/dist/commands/wallet/send.js.map +1 -1
- package/dist/index.js +151 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/concurrency.d.ts +2 -0
- package/dist/lib/concurrency.d.ts.map +1 -0
- package/dist/lib/concurrency.js +21 -0
- package/dist/lib/concurrency.js.map +1 -0
- package/dist/lib/fetch.d.ts +4 -0
- package/dist/lib/fetch.d.ts.map +1 -0
- package/dist/lib/fetch.js +13 -0
- package/dist/lib/fetch.js.map +1 -0
- package/dist/lib/format.d.ts +12 -43
- package/dist/lib/format.d.ts.map +1 -1
- package/dist/lib/format.js +69 -52
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/retry.d.ts +0 -7
- package/dist/lib/retry.d.ts.map +1 -1
- package/dist/lib/retry.js +0 -4
- package/dist/lib/retry.js.map +1 -1
- package/dist/lib/types.d.ts +6 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/mcp/handlers/multi-swap.js +2 -2
- package/dist/mcp/handlers/multi-swap.js.map +1 -1
- package/dist/mcp/handlers/trade.js +4 -4
- package/dist/mcp/handlers/trade.js.map +1 -1
- package/dist/mcp/handlers/wallet.d.ts.map +1 -1
- package/dist/mcp/handlers/wallet.js +8 -4
- package/dist/mcp/handlers/wallet.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +45 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/auth.d.ts +3 -0
- package/dist/mcp/tools/auth.d.ts.map +1 -0
- package/dist/mcp/tools/auth.js +17 -0
- package/dist/mcp/tools/auth.js.map +1 -0
- package/dist/mcp/tools/error-handling.d.ts +12 -0
- package/dist/mcp/tools/error-handling.d.ts.map +1 -0
- package/dist/mcp/tools/error-handling.js +28 -0
- package/dist/mcp/tools/error-handling.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +11 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +19 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/lending.d.ts +3 -0
- package/dist/mcp/tools/lending.d.ts.map +1 -0
- package/dist/mcp/tools/lending.js +71 -0
- package/dist/mcp/tools/lending.js.map +1 -0
- package/dist/mcp/tools/staking.d.ts +3 -0
- package/dist/mcp/tools/staking.d.ts.map +1 -0
- package/dist/mcp/tools/staking.js +50 -0
- package/dist/mcp/tools/staking.js.map +1 -0
- package/dist/mcp/tools/trade.d.ts +3 -0
- package/dist/mcp/tools/trade.d.ts.map +1 -0
- package/dist/mcp/tools/trade.js +63 -0
- package/dist/mcp/tools/trade.js.map +1 -0
- package/dist/mcp/tools/wallet.d.ts +3 -0
- package/dist/mcp/tools/wallet.d.ts.map +1 -0
- package/dist/mcp/tools/wallet.js +27 -0
- package/dist/mcp/tools/wallet.js.map +1 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +25 -10
- package/dist/mcp/tools.js.map +1 -1
- package/dist/services/api/client.d.ts.map +1 -1
- package/dist/services/api/client.js +5 -9
- package/dist/services/api/client.js.map +1 -1
- package/dist/services/auth/session.d.ts.map +1 -1
- package/dist/services/auth/session.js +3 -2
- package/dist/services/auth/session.js.map +1 -1
- package/dist/services/batch/batch.d.ts +0 -1
- package/dist/services/batch/batch.d.ts.map +1 -1
- package/dist/services/batch/batch.js +5 -6
- package/dist/services/batch/batch.js.map +1 -1
- package/dist/services/config/config.d.ts +0 -1
- package/dist/services/config/config.d.ts.map +1 -1
- package/dist/services/config/config.js +0 -1
- package/dist/services/config/config.js.map +1 -1
- package/dist/services/fibrous/route.d.ts +0 -4
- package/dist/services/fibrous/route.d.ts.map +1 -1
- package/dist/services/fibrous/route.js +3 -3
- package/dist/services/fibrous/route.js.map +1 -1
- package/dist/services/portfolio/portfolio.d.ts +0 -4
- package/dist/services/portfolio/portfolio.d.ts.map +1 -1
- package/dist/services/portfolio/portfolio.js +56 -58
- package/dist/services/portfolio/portfolio.js.map +1 -1
- package/dist/services/simulate/simulate.d.ts +0 -8
- package/dist/services/simulate/simulate.d.ts.map +1 -1
- package/dist/services/simulate/simulate.js +1 -5
- package/dist/services/simulate/simulate.js.map +1 -1
- package/dist/services/staking/staking.d.ts +7 -20
- package/dist/services/staking/staking.d.ts.map +1 -1
- package/dist/services/staking/staking.js +2 -2
- package/dist/services/staking/staking.js.map +1 -1
- package/dist/services/starkzap/client.d.ts +2 -1
- package/dist/services/starkzap/client.d.ts.map +1 -1
- package/dist/services/starkzap/client.js +1 -3
- package/dist/services/starkzap/client.js.map +1 -1
- package/dist/services/tokens/balances.d.ts.map +1 -1
- package/dist/services/tokens/balances.js +17 -29
- package/dist/services/tokens/balances.js.map +1 -1
- package/dist/services/vesu/api.d.ts.map +1 -1
- package/dist/services/vesu/api.js +3 -9
- package/dist/services/vesu/api.js.map +1 -1
- package/dist/services/vesu/lending.d.ts +1 -4
- package/dist/services/vesu/lending.d.ts.map +1 -1
- package/dist/services/vesu/lending.js +14 -17
- package/dist/services/vesu/lending.js.map +1 -1
- package/dist/services/vesu/pools.d.ts +1 -1
- package/dist/services/vesu/pools.d.ts.map +1 -1
- package/dist/services/vesu/pools.js.map +1 -1
- package/package.json +4 -2
- package/scripts/patch-esm.mjs +151 -0
- package/skills/README.md +5 -9
- package/skills/config/SKILL.md +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../src/services/vesu/pools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAqB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../src/services/vesu/pools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAqB,MAAM,UAAU,CAAC;AAK5D,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IAClD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,aAAa,EAAE,CAAC;AACxB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,OAAgB;IAC5D,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,OAAO,CACN,QAAQ,CAAC,IAAI,CACZ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAClF,IAAI,IAAI,CACT,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starkfi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Starknet DeFi CLI + MCP Server — Swaps, multi-swap, batch (multicall), staking, lending, simulation, portfolio, gasless transactions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
|
+
"scripts",
|
|
18
19
|
"skills",
|
|
19
20
|
"README.md",
|
|
20
21
|
"MCP.md",
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
"format:check": "prettier --check src/",
|
|
31
32
|
"start": "node dist/index.js",
|
|
32
33
|
"mcp-start": "node dist/index.js mcp-start",
|
|
33
|
-
"prepublishOnly": "pnpm run build"
|
|
34
|
+
"prepublishOnly": "pnpm run build",
|
|
35
|
+
"postinstall": "node scripts/patch-esm.mjs"
|
|
34
36
|
},
|
|
35
37
|
"keywords": [
|
|
36
38
|
"starknet",
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* patch-esm.mjs — Postinstall ESM compatibility fix for starkzap
|
|
3
|
+
*
|
|
4
|
+
* starkzap@1.0.0 publishes compiled JS files with extensionless relative
|
|
5
|
+
* imports (e.g. `from "./sdk"` instead of `from "./sdk.js"`). This is
|
|
6
|
+
* invalid under Node.js ESM resolution which requires explicit file
|
|
7
|
+
* extensions. The `tsx` runtime tolerates it, but bare `node` does not,
|
|
8
|
+
* causing `npx starkfi` to hang silently.
|
|
9
|
+
*
|
|
10
|
+
* This script runs as a postinstall hook and patches all relative imports
|
|
11
|
+
* inside `node_modules/starkzap/dist/` to include the correct `.js` or
|
|
12
|
+
* `/index.js` suffix. It is idempotent — running it multiple times
|
|
13
|
+
* produces the same result.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { readdir, readFile, writeFile, stat } from "node:fs/promises";
|
|
17
|
+
import { join, dirname } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Dynamically locate starkzap's dist directory.
|
|
22
|
+
* Works both in local dev (`node scripts/patch-esm.mjs`) and when
|
|
23
|
+
* starkfi is installed as a dependency (`npm install starkfi`).
|
|
24
|
+
*/
|
|
25
|
+
async function findStarkzapDist() {
|
|
26
|
+
try {
|
|
27
|
+
// Use Node.js module resolution to find starkzap's entry point
|
|
28
|
+
const resolved = import.meta.resolve("starkzap");
|
|
29
|
+
const entryFile = fileURLToPath(resolved);
|
|
30
|
+
// starkzap entry is at .../starkzap/dist/src/index.js
|
|
31
|
+
// We need .../starkzap/dist
|
|
32
|
+
const distDir = dirname(dirname(entryFile));
|
|
33
|
+
return distDir;
|
|
34
|
+
} catch {
|
|
35
|
+
// Fallback: relative path from scripts/ directory (local dev)
|
|
36
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
37
|
+
return join(__dirname, "..", "node_modules", "starkzap", "dist");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const STARKZAP_DIST = await findStarkzapDist();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Resolves a bare relative import to its correct ESM-compliant form.
|
|
45
|
+
* "./sdk" → "./sdk.js" (if sdk.js exists)
|
|
46
|
+
* "./account" → "./account/index.js" (if account/index.js exists)
|
|
47
|
+
* "./foo.js" → "./foo.js" (already has extension, skip)
|
|
48
|
+
*/
|
|
49
|
+
async function resolveImport(baseDir, importPath) {
|
|
50
|
+
// Already has a known JS file extension — leave it alone
|
|
51
|
+
if (/\.(?:js|mjs|cjs|json)$/.test(importPath)) return null;
|
|
52
|
+
|
|
53
|
+
// 1) Try <importPath>.js
|
|
54
|
+
try {
|
|
55
|
+
const asFile = join(baseDir, importPath + ".js");
|
|
56
|
+
const s = await stat(asFile);
|
|
57
|
+
if (s.isFile()) return importPath + ".js";
|
|
58
|
+
} catch {
|
|
59
|
+
/* not a file */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2) Try <importPath>/index.js
|
|
63
|
+
try {
|
|
64
|
+
const asDir = join(baseDir, importPath, "index.js");
|
|
65
|
+
const s = await stat(asDir);
|
|
66
|
+
if (s.isFile()) return importPath + "/index.js";
|
|
67
|
+
} catch {
|
|
68
|
+
/* not a directory with index */
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return null; // Can't resolve — leave original
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Patches a single JS file, replacing extensionless relative imports.
|
|
76
|
+
* Returns true if the file was modified.
|
|
77
|
+
*/
|
|
78
|
+
async function patchFile(filePath) {
|
|
79
|
+
const content = await readFile(filePath, "utf-8");
|
|
80
|
+
const baseDir = dirname(filePath);
|
|
81
|
+
let modified = false;
|
|
82
|
+
|
|
83
|
+
// Collect all relative import specifiers
|
|
84
|
+
const importRegex = /((?:from|import)\s*["'])(\.\.?\/[^"']+)(["'])/g;
|
|
85
|
+
const replacements = [];
|
|
86
|
+
let match;
|
|
87
|
+
|
|
88
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
89
|
+
const [full, prefix, importPath, suffix] = match;
|
|
90
|
+
const resolved = await resolveImport(baseDir, importPath);
|
|
91
|
+
if (resolved) {
|
|
92
|
+
replacements.push({
|
|
93
|
+
start: match.index,
|
|
94
|
+
end: match.index + full.length,
|
|
95
|
+
replacement: `${prefix}${resolved}${suffix}`,
|
|
96
|
+
});
|
|
97
|
+
modified = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!modified) return false;
|
|
102
|
+
|
|
103
|
+
// Apply replacements from end to start to preserve indices
|
|
104
|
+
let patched = content;
|
|
105
|
+
for (let i = replacements.length - 1; i >= 0; i--) {
|
|
106
|
+
const r = replacements[i];
|
|
107
|
+
patched = patched.slice(0, r.start) + r.replacement + patched.slice(r.end);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await writeFile(filePath, patched);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Recursively walks a directory and patches all .js files.
|
|
116
|
+
*/
|
|
117
|
+
async function walkAndPatch(dir) {
|
|
118
|
+
let count = 0;
|
|
119
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
120
|
+
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
const fullPath = join(dir, entry.name);
|
|
123
|
+
if (entry.isDirectory()) {
|
|
124
|
+
count += await walkAndPatch(fullPath);
|
|
125
|
+
} else if (entry.name.endsWith(".js") && !entry.name.endsWith(".map")) {
|
|
126
|
+
if (await patchFile(fullPath)) count++;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return count;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ── Main ──────────────────────────────────────────────────────────────
|
|
134
|
+
try {
|
|
135
|
+
await stat(STARKZAP_DIST);
|
|
136
|
+
} catch {
|
|
137
|
+
// starkzap not installed or dist missing — nothing to patch
|
|
138
|
+
process.exit(0);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
const count = await walkAndPatch(STARKZAP_DIST);
|
|
143
|
+
if (count > 0) {
|
|
144
|
+
console.log(
|
|
145
|
+
`[starkfi] Patched ${count} starkzap file${count > 1 ? "s" : ""} for ESM compatibility`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.warn("[starkfi] ESM patch warning:", err.message);
|
|
150
|
+
// Don't fail the install — the CLI will still work via tsx
|
|
151
|
+
}
|
package/skills/README.md
CHANGED
|
@@ -22,19 +22,15 @@ Agent Skills for the [StarkFi](https://github.com/ahmetenesdur/starkfi) CLI —
|
|
|
22
22
|
Install with [Vercel's Skills CLI](https://skills.sh):
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
+
# Add skills to your AI assistant (e.g. Antigravity)
|
|
25
26
|
npx skills add ahmetenesdur/starkfi
|
|
26
27
|
```
|
|
27
28
|
|
|
28
|
-
Or clone directly:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
git clone https://github.com/ahmetenesdur/starkfi.git
|
|
32
|
-
```
|
|
33
|
-
|
|
34
29
|
## Getting Started
|
|
35
30
|
|
|
36
|
-
1. Install Node.js (v18+)
|
|
37
|
-
2.
|
|
31
|
+
1. Install **Node.js** (v18+).
|
|
32
|
+
2. Ensure the **StarkFi Auth Server** is running (required for authentication and signing).
|
|
33
|
+
3. No manual CLI installation needed — all skills use `npx starkfi@latest`.
|
|
38
34
|
|
|
39
35
|
## Typical Workflow
|
|
40
36
|
|
|
@@ -54,7 +50,7 @@ git clone https://github.com/ahmetenesdur/starkfi.git
|
|
|
54
50
|
| "Swap USDC to ETH and USDT to STRK" | `multi-swap` |
|
|
55
51
|
| "Swap ETH and then stake STRK" | `batch` |
|
|
56
52
|
| "Stake 1000 STRK with Juno" | `staking` |
|
|
57
|
-
| "Supply 500 USDC to
|
|
53
|
+
| "Supply 500 USDC to Prime pool" | `lending` |
|
|
58
54
|
| "Show me my portfolio" | `portfolio` |
|
|
59
55
|
| "I'm getting rate limit errors" | `config` |
|
|
60
56
|
|
package/skills/config/SKILL.md
CHANGED
|
@@ -53,16 +53,16 @@ npx starkfi@latest tx-status <hash>
|
|
|
53
53
|
|
|
54
54
|
StarkFi supports two gas abstraction modes:
|
|
55
55
|
|
|
56
|
-
| Mode | Who Pays | Command | Description
|
|
57
|
-
| ----------- | ------------- | --------------------------- |
|
|
58
|
-
| **Gasfree** | Developer | `config set-gasfree on` | Gas fees sponsored by StarkFi via
|
|
59
|
-
| **Gasless** | User (ERC-20) | `config set-gas-token STRK` | User pays gas in an ERC-20 token (default mode)
|
|
56
|
+
| Mode | Who Pays | Command | Description |
|
|
57
|
+
| ----------- | ------------- | --------------------------- | ----------------------------------------------- |
|
|
58
|
+
| **Gasfree** | Developer | `config set-gasfree on` | Gas fees sponsored by StarkFi via Paymaster |
|
|
59
|
+
| **Gasless** | User (ERC-20) | `config set-gas-token STRK` | User pays gas in an ERC-20 token (default mode) |
|
|
60
60
|
|
|
61
61
|
Supported gas tokens: **ETH**, **STRK**, **USDC**, **USDT**, **DAI**
|
|
62
62
|
|
|
63
63
|
Gasfree and Gasless are mutually exclusive — enabling one disables the other.
|
|
64
64
|
|
|
65
|
-
> **Default:** Gasless mode with STRK as gas token. Gas is paid through the
|
|
65
|
+
> **Default:** Gasless mode with STRK as gas token. Gas is paid through the Paymaster, so the user does not need native ETH for gas — any supported ERC-20 works.
|
|
66
66
|
|
|
67
67
|
## Parameters
|
|
68
68
|
|