@grinta-mcp/server 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 +49 -0
- package/dist/config.d.ts +38 -0
- package/dist/config.js +45 -0
- package/dist/grinta.d.ts +99 -0
- package/dist/grinta.js +561 -0
- package/dist/identity.d.ts +24 -0
- package/dist/identity.js +74 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +284 -0
- package/dist/mcp.d.ts +8 -0
- package/dist/mcp.js +322 -0
- package/dist/price-feed.d.ts +23 -0
- package/dist/price-feed.js +151 -0
- package/dist/scan-safes.d.ts +5 -0
- package/dist/scan-safes.js +87 -0
- package/dist/swap.d.ts +25 -0
- package/dist/swap.js +271 -0
- package/dist/test-swap.d.ts +5 -0
- package/dist/test-swap.js +93 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.js +35 -0
- package/package.json +35 -0
package/dist/utils.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for Starknet Agent
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Format a token amount from raw units to human-readable
|
|
6
|
+
*/
|
|
7
|
+
export function formatAmount(raw, decimals) {
|
|
8
|
+
const str = raw.toString();
|
|
9
|
+
if (decimals === 0)
|
|
10
|
+
return str;
|
|
11
|
+
const padded = str.padStart(decimals + 1, "0");
|
|
12
|
+
const whole = padded.slice(0, -decimals);
|
|
13
|
+
const frac = padded.slice(-decimals).replace(/0+$/, "");
|
|
14
|
+
return frac ? `${whole}.${frac}` : whole;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse a human-readable amount to raw units
|
|
18
|
+
*/
|
|
19
|
+
export function parseAmount(amount, decimals) {
|
|
20
|
+
const [whole, frac = ""] = amount.split(".");
|
|
21
|
+
const paddedFrac = frac.padEnd(decimals, "0").slice(0, decimals);
|
|
22
|
+
return BigInt(whole + paddedFrac);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sleep for the specified milliseconds
|
|
26
|
+
*/
|
|
27
|
+
export function sleep(ms) {
|
|
28
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validate a Starknet address format
|
|
32
|
+
*/
|
|
33
|
+
export function isValidAddress(address) {
|
|
34
|
+
return /^0x[0-9a-fA-F]{1,64}$/.test(address);
|
|
35
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grinta-mcp/server",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for Grinta CDP protocol on Starknet — open SAFEs, borrow GRIT, swap, monitor health",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/mcp.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"grinta-mcp": "dist/mcp.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"start": "tsx src/index.ts",
|
|
15
|
+
"dev": "tsx watch src/index.ts",
|
|
16
|
+
"mcp": "tsx src/mcp.ts",
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
22
|
+
"dotenv": "^16.4.7",
|
|
23
|
+
"starknet": "^8.9.1",
|
|
24
|
+
"zod": "^3.23.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@avnu/avnu-sdk": "^4.0.1",
|
|
28
|
+
"@types/node": "^22.0.0",
|
|
29
|
+
"tsx": "^4.0.0",
|
|
30
|
+
"typescript": "^5.9.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|