@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 ADDED
@@ -0,0 +1,49 @@
1
+ # grinta-agent-tmp
2
+
3
+ A Starknet AI Agent built with [starknet-agentic](https://github.com/keep-starknet-strange/starknet-agentic).
4
+
5
+ ## Quick Start
6
+
7
+ 1. Install dependencies:
8
+ ```bash
9
+ npm install
10
+ # or
11
+ pnpm install
12
+ ```
13
+
14
+ 2. Configure your environment:
15
+ ```bash
16
+ cp .env.example .env
17
+ # Edit .env with your account address and private key
18
+ ```
19
+
20
+ 3. Run the agent:
21
+ ```bash
22
+ npm start
23
+ # or for development with auto-reload:
24
+ npm run dev
25
+ ```
26
+
27
+ ## Configuration
28
+
29
+ This agent is configured for **sepolia**.
30
+
31
+ ### Environment Variables
32
+
33
+ | Variable | Description |
34
+ |----------|-------------|
35
+ | `STARKNET_RPC_URL` | Starknet RPC endpoint |
36
+ | `STARKNET_ACCOUNT_ADDRESS` | Your agent's account address |
37
+ | `STARKNET_PRIVATE_KEY` | Private key for signing transactions |
38
+ | `AVNU_BASE_URL` | AVNU API endpoint for swaps |
39
+ | `AVNU_PAYMASTER_URL` | AVNU Paymaster for gas abstraction |
40
+
41
+ ## Template: full
42
+
43
+ The **full** template includes wallet, DeFi, on-chain identity (ERC-8004), and A2A protocol support for agent-to-agent communication.
44
+
45
+ ## Resources
46
+
47
+ - [Starknet Agentic Docs](https://starknet-agentic.vercel.app)
48
+ - [starknet.js Documentation](https://www.starknetjs.com/)
49
+ - [AVNU SDK](https://github.com/avnu-labs/avnu-sdk)
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Full Agent Configuration
3
+ *
4
+ * Uses getters for env vars so they resolve after dotenv loads.
5
+ */
6
+ export declare const CONFIG: {
7
+ readonly RPC_URL: string;
8
+ readonly ACCOUNT_ADDRESS: string;
9
+ readonly PRIVATE_KEY: string;
10
+ readonly AVNU_BASE_URL: string;
11
+ readonly AVNU_PAYMASTER_URL: string;
12
+ readonly IDENTITY_REGISTRY_ADDRESS: string;
13
+ MIN_PROFIT_BPS: number;
14
+ MAX_SLIPPAGE: number;
15
+ CHECK_INTERVAL_MS: number;
16
+ };
17
+ export declare const TOKENS: {
18
+ ETH: string;
19
+ STRK: string;
20
+ WBTC: string;
21
+ USDC: string;
22
+ };
23
+ export declare const GRINTA: {
24
+ SAFE_MANAGER: string;
25
+ SAFE_ENGINE: string;
26
+ COLLATERAL_JOIN: string;
27
+ PID_CONTROLLER: string;
28
+ GRINTA_HOOK: string;
29
+ ORACLE_RELAYER: string;
30
+ GRIT: string;
31
+ };
32
+ export declare const AGENT_METADATA: {
33
+ name: string;
34
+ version: string;
35
+ agentType: string;
36
+ framework: string;
37
+ capabilities: string[];
38
+ };
package/dist/config.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Full Agent Configuration
3
+ *
4
+ * Uses getters for env vars so they resolve after dotenv loads.
5
+ */
6
+ export const CONFIG = {
7
+ // Network
8
+ get RPC_URL() { return process.env.STARKNET_RPC_URL || "https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_10/w0WsoxSXn4Xq8DEGYETDW"; },
9
+ // Wallet
10
+ get ACCOUNT_ADDRESS() { return process.env.STARKNET_ACCOUNT_ADDRESS || ""; },
11
+ get PRIVATE_KEY() { return process.env.STARKNET_PRIVATE_KEY || ""; },
12
+ // AVNU DEX Aggregator
13
+ get AVNU_BASE_URL() { return process.env.AVNU_BASE_URL || "https://sepolia.api.avnu.fi"; },
14
+ get AVNU_PAYMASTER_URL() { return process.env.AVNU_PAYMASTER_URL || "https://sepolia.paymaster.avnu.fi"; },
15
+ // ERC-8004 Identity
16
+ get IDENTITY_REGISTRY_ADDRESS() { return process.env.IDENTITY_REGISTRY_ADDRESS || ""; },
17
+ // Trading Parameters
18
+ MIN_PROFIT_BPS: 50,
19
+ MAX_SLIPPAGE: 0.01,
20
+ CHECK_INTERVAL_MS: 30000,
21
+ };
22
+ export const TOKENS = {
23
+ ETH: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
24
+ STRK: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
25
+ WBTC: "0x055adbd6123ce69b2498fc99aec5006d00ac8b57070c99133f2c67c262e69223",
26
+ USDC: "0x0728f54606297716e46af72251733521e2c2a374abbc3dce4bcee8df4744dd30",
27
+ };
28
+ // Grinta CDP Protocol Contracts (Starknet Sepolia) — from pid/ADDRESSES.md
29
+ export const GRINTA = {
30
+ SAFE_MANAGER: "0x044728823ae43429eb96c14646077a461101a5db09ce6329a16684dcf199e552",
31
+ SAFE_ENGINE: "0x078802abe86444d116c73821c7b6aff8175bd558bf335b28247b825d49490ef2",
32
+ COLLATERAL_JOIN: "0x042a4228c74a2d8933549fb06208b1055ea628d63fa43081d76e41a9d43a8c22",
33
+ PID_CONTROLLER: "0x06928a6c33a6284d5f4c68278960ba888045856dc0ff30548972a866a838427d",
34
+ GRINTA_HOOK: "0x062347cbbb4e4da5c5eea0df072c471ffa530da08b9c04080875d2087f39f38d",
35
+ ORACLE_RELAYER: "0x04acb771661162edeb881001a38282faff841e9118230b08f6df8e3a0920516f",
36
+ // GRIT token is the SAFEEngine contract itself
37
+ GRIT: "0x078802abe86444d116c73821c7b6aff8175bd558bf335b28247b825d49490ef2",
38
+ };
39
+ export const AGENT_METADATA = {
40
+ name: "grinta-agent",
41
+ version: "0.1.0",
42
+ agentType: "cdp-manager",
43
+ framework: "starknet-agentic",
44
+ capabilities: ["swap", "monitor", "identity", "cdp", "health-management", "peg-arbitrage"],
45
+ };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Grinta CDP Protocol Client
3
+ *
4
+ * Manages SAFEs, borrows GRIT stablecoin, monitors health.
5
+ * All write operations go through SafeManager.
6
+ */
7
+ import { type Account, type RpcProvider } from "starknet";
8
+ declare const WAD: bigint;
9
+ declare const RAY: bigint;
10
+ export interface Health {
11
+ collateralValue: bigint;
12
+ debt: bigint;
13
+ ltv: bigint;
14
+ liquidationPrice: bigint;
15
+ }
16
+ export interface SafeData {
17
+ collateral: bigint;
18
+ debt: bigint;
19
+ }
20
+ export interface SystemStatus {
21
+ totalDebt: bigint;
22
+ totalCollateral: bigint;
23
+ debtCeiling: bigint;
24
+ liquidationRatio: bigint;
25
+ collateralPrice: bigint;
26
+ redemptionPrice: bigint;
27
+ redemptionRate: bigint;
28
+ marketPrice: bigint;
29
+ }
30
+ export declare class GrintaClient {
31
+ private safeManager;
32
+ private safeEngine;
33
+ private grintaHook;
34
+ private wbtc;
35
+ private account;
36
+ constructor(account: Account, provider: RpcProvider);
37
+ getPositionHealth(safeId: number): Promise<Health>;
38
+ getMaxBorrow(safeId: number): Promise<bigint>;
39
+ getSafeOwner(safeId: number): Promise<string>;
40
+ isAuthorized(safeId: number, agent: string): Promise<boolean>;
41
+ getSafe(safeId: number): Promise<SafeData>;
42
+ getSystemStatus(): Promise<SystemStatus>;
43
+ getGritBalance(address: string): Promise<bigint>;
44
+ getWbtcBalance(address: string): Promise<bigint>;
45
+ /**
46
+ * Open an empty SAFE. Returns the safe_id.
47
+ */
48
+ openSafe(): Promise<number>;
49
+ /**
50
+ * Open a SAFE, deposit WBTC collateral, and borrow GRIT in one transaction.
51
+ * @param collateralAmount WBTC in 8 decimals (e.g. 50_000_000 = 0.5 BTC)
52
+ * @param borrowAmount GRIT in WAD (e.g. 10000n * WAD = 10,000 GRIT)
53
+ */
54
+ openAndBorrow(collateralAmount: bigint, borrowAmount: bigint): Promise<string>;
55
+ /**
56
+ * Deposit WBTC collateral into an existing SAFE.
57
+ * @param amount WBTC in 8 decimals
58
+ */
59
+ deposit(safeId: number, amount: bigint): Promise<string>;
60
+ /**
61
+ * Withdraw WBTC collateral from a SAFE.
62
+ * @param amount Internal WAD amount (not 8 decimals)
63
+ */
64
+ withdraw(safeId: number, amount: bigint): Promise<string>;
65
+ /**
66
+ * Borrow additional GRIT against existing collateral.
67
+ * @param amount GRIT in WAD
68
+ */
69
+ borrow(safeId: number, amount: bigint): Promise<string>;
70
+ /**
71
+ * Repay GRIT debt. If amount > debt, only repays the debt.
72
+ * @param amount GRIT in WAD
73
+ */
74
+ repay(safeId: number, amount: bigint): Promise<string>;
75
+ /**
76
+ * Close a SAFE. Requires zero debt. Returns remaining collateral.
77
+ */
78
+ closeSafe(safeId: number): Promise<string>;
79
+ /**
80
+ * Authorize an agent address to operate on a SAFE.
81
+ */
82
+ authorizeAgent(safeId: number, agent: string): Promise<string>;
83
+ /**
84
+ * Revoke an agent's permission on a SAFE.
85
+ */
86
+ revokeAgent(safeId: number, agent: string): Promise<string>;
87
+ /**
88
+ * Trigger a price/rate update on the GrintaHook.
89
+ */
90
+ triggerUpdate(): Promise<string>;
91
+ /**
92
+ * Set the GRIT market price (WAD). Anyone can call.
93
+ * @param priceWad Price in WAD (e.g. 1e18 = $1.00)
94
+ */
95
+ setMarketPrice(priceWad: bigint): Promise<string>;
96
+ formatHealth(health: Health): string;
97
+ formatSystemStatus(status: SystemStatus): string;
98
+ }
99
+ export { WAD, RAY };