@agent-shield/plugin-solana-agent-kit 0.1.0 → 0.1.2

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,78 @@
1
+ # @agent-shield/plugin-solana-agent-kit
2
+
3
+ AgentShield plugin for [Solana Agent Kit](https://github.com/sendaifun/solana-agent-kit) — routes agent DeFi actions through permission-guarded vaults with spending limits, token whitelists, and leverage controls.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @agent-shield/plugin-solana-agent-kit @agent-shield/sdk
9
+ ```
10
+
11
+ Peer dependencies: `solana-agent-kit >=2.0.0`, `@agent-shield/sdk >=0.1.0`, `@solana/web3.js >=1.90.0`, `@coral-xyz/anchor >=0.30.0`
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { createAgentShieldPlugin } from "@agent-shield/plugin-solana-agent-kit";
17
+ import { SolanaAgentKit } from "solana-agent-kit";
18
+ import { PublicKey } from "@solana/web3.js";
19
+ import { BN } from "@coral-xyz/anchor";
20
+
21
+ const plugin = createAgentShieldPlugin({
22
+ vaultOwner: new PublicKey("..."), // vault owner pubkey
23
+ vaultId: new BN(1), // vault identifier
24
+ });
25
+
26
+ const agent = new SolanaAgentKit(wallet, rpcUrl, {
27
+ plugins: [plugin],
28
+ });
29
+ ```
30
+
31
+ ## Tools
32
+
33
+ The plugin registers 6 tools on the agent:
34
+
35
+ ### Trading
36
+
37
+ | Tool | Description | Parameters |
38
+ |------|-------------|------------|
39
+ | `shield_swap` | Execute a token swap through Jupiter, routed through the AgentShield vault with policy enforcement | `inputMint`, `outputMint`, `amount`, `slippageBps` |
40
+ | `shield_open_position` | Open a leveraged perpetual position on Flash Trade. Enforces leverage limits and position count caps | `collateralMint`, `targetMint`, `collateralAmount`, `side`, `leverage` |
41
+ | `shield_close_position` | Close an existing perpetual position on Flash Trade | `positionMint`, `targetMint`, `side` |
42
+
43
+ ### Read-Only
44
+
45
+ | Tool | Description | Parameters |
46
+ |------|-------------|------------|
47
+ | `shield_check_policy` | Read the vault policy: spending caps, allowed tokens/protocols, leverage limits, fee BPS | *(none)* |
48
+ | `shield_check_balance` | Read vault balances, status, and statistics (total volume, open positions, fees collected) | *(none)* |
49
+ | `shield_check_spending` | Read the rolling 24h spending tracker: per-token spend vs daily cap, recent transaction history | *(none)* |
50
+
51
+ ## Configuration
52
+
53
+ ```typescript
54
+ interface AgentShieldPluginConfig {
55
+ /** Vault owner public key */
56
+ vaultOwner: PublicKey;
57
+ /** Vault identifier (u64) */
58
+ vaultId: BN;
59
+ /** Optional program ID override (defaults to mainnet deployment) */
60
+ programId?: PublicKey;
61
+ }
62
+ ```
63
+
64
+ The plugin creates an `AgentShieldClient` on initialization using the agent's connection and wallet. The client is cached per agent instance.
65
+
66
+ ## How It Works
67
+
68
+ All trading tools (`shield_swap`, `shield_open_position`, `shield_close_position`) build atomic composed transactions:
69
+
70
+ ```
71
+ [ValidateAndAuthorize, DeFi instruction(s), FinalizeSession]
72
+ ```
73
+
74
+ The on-chain program checks the agent's action against the vault policy (spending cap, token whitelist, protocol whitelist, leverage limits) before the DeFi instruction executes. If any check fails, the entire transaction reverts.
75
+
76
+ ## License
77
+
78
+ MIT
@@ -32,7 +32,7 @@ async function checkPolicy(agent, config, input) {
32
32
  `Max Leverage: ${policy.maxLeverageBps} bps (${(policy.maxLeverageBps / 100).toFixed(1)}x)`,
33
33
  `Can Open Positions: ${policy.canOpenPositions}`,
34
34
  `Max Concurrent Positions: ${policy.maxConcurrentPositions}`,
35
- `Fee: ${policy.feeBps} bps (${(policy.feeBps / 100).toFixed(2)}%)`,
35
+ `Developer Fee Rate: ${policy.developerFeeRate} (${(policy.developerFeeRate / 10000).toFixed(4)}%)`,
36
36
  ].join("\n");
37
37
  }
38
38
  //# sourceMappingURL=checkPolicy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkPolicy.js","sourceRoot":"","sources":["../../src/tools/checkPolicy.ts"],"names":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AAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;IACrF,MAAM,YAAY,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;IAE3F,OAAO;QACL,sBAAsB;QACtB,uBAAuB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW;QACpE,yBAAyB,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,WAAW;QACxE,mBAAmB,SAAS,EAAE;QAC9B,sBAAsB,YAAY,EAAE;QACpC,iBAAiB,MAAM,CAAC,cAAc,SAAS,CAAC,MAAM,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;QAC3F,uBAAuB,MAAM,CAAC,gBAAgB,EAAE;QAChD,6BAA6B,MAAM,CAAC,sBAAsB,EAAE;QAC5D,uBAAuB,MAAM,CAAC,gBAAgB,KAAK,CAAC,MAAM,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;KACpG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-shield/plugin-solana-agent-kit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "AgentShield plugin for Solana Agent Kit — routes agent DeFi actions through permission-guarded vaults",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "prepublishOnly": "npm run build"
11
11
  },
12
12
  "files": [
13
- "dist/**/*"
13
+ "dist/**/*",
14
+ "README.md"
14
15
  ],
15
16
  "peerDependencies": {
16
17
  "solana-agent-kit": ">=2.0.0",
@@ -21,7 +22,7 @@
21
22
  "devDependencies": {
22
23
  "typescript": "^5.3.0",
23
24
  "solana-agent-kit": "^2.0.0",
24
- "@agent-shield/sdk": "0.1.0",
25
+ "@agent-shield/sdk": "0.1.2",
25
26
  "@solana/web3.js": "^1.95.0",
26
27
  "@coral-xyz/anchor": "^0.32.0",
27
28
  "zod": "^3.22.0"