shll-skills 1.0.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/.env.example +15 -0
- package/README.md +79 -0
- package/SKILL.md +128 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1474 -0
- package/dist/index.mjs +1484 -0
- package/package.json +23 -0
- package/src/index.ts +1242 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +10 -0
package/.env.example
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ── Required ─────────────────────────────────────────────
|
|
2
|
+
# Private key for the operator/renter wallet.
|
|
3
|
+
# ⚠️ This key is used for: init (rent+fund), swap, wrap, unwrap, transfer, config.
|
|
4
|
+
# ⚠️ Use a DEDICATED wallet with limited funds. Never use your main wallet.
|
|
5
|
+
RUNNER_PRIVATE_KEY=0x_YOUR_PRIVATE_KEY_HERE
|
|
6
|
+
|
|
7
|
+
# ── Optional Overrides ───────────────────────────────────
|
|
8
|
+
# BSC RPC endpoint (default: public BSC RPC)
|
|
9
|
+
# RPC_URL=https://bsc-dataseed.binance.org
|
|
10
|
+
|
|
11
|
+
# AgentNFA contract address (default: mainnet deployment)
|
|
12
|
+
# NFA_ADDRESS=0x...
|
|
13
|
+
|
|
14
|
+
# PolicyGuardV4 contract address (default: mainnet deployment)
|
|
15
|
+
# GUARD_ADDRESS=0x...
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# SHLL OpenClaw Skill (@shll/openclaw-skill)
|
|
2
|
+
|
|
3
|
+
A native [OpenClaw](https://openclaw.ai) skill for the SHLL Agent Protocol. Execute DeFi transactions on BSC securely — every action goes through PolicyGuard.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd repos/shll-openclaw-skill
|
|
9
|
+
npm install && npm run build
|
|
10
|
+
npm link # registers `shll-onchain-runner` CLI
|
|
11
|
+
cp .env.example .env # edit with your private key
|
|
12
|
+
export RUNNER_PRIVATE_KEY="0x..." # operator key
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 🚀 Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. One-click onboarding: rent + authorize + fund
|
|
19
|
+
shll-onchain-runner init --listing-id 0xABC...DEF --days 30 --fund 0.5
|
|
20
|
+
# → Agent #5 is ready!
|
|
21
|
+
|
|
22
|
+
# 2. Start trading
|
|
23
|
+
shll-onchain-runner swap --from BNB --to USDC --amount 0.1 --token-id 5
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 📋 Full Command Reference
|
|
27
|
+
|
|
28
|
+
### Onboarding
|
|
29
|
+
| Command | Description |
|
|
30
|
+
|---------|-------------|
|
|
31
|
+
| `init --listing-id <ID> --days <N> [--fund <BNB>]` | Rent agent + authorize + fund vault |
|
|
32
|
+
|
|
33
|
+
### Trading & Asset Management
|
|
34
|
+
| Command | Description |
|
|
35
|
+
|---------|-------------|
|
|
36
|
+
| `swap --from <TOKEN> --to <TOKEN> --amount <N> -k <ID>` | Token swap via PancakeSwap V2 |
|
|
37
|
+
| `wrap --amount <BNB> -k <ID>` | BNB → WBNB |
|
|
38
|
+
| `unwrap --amount <BNB> -k <ID>` | WBNB → BNB |
|
|
39
|
+
| `transfer --token <SYM> --amount <N> --to <ADDR> -k <ID>` | Transfer from vault |
|
|
40
|
+
| `raw --target <ADDR> --data <HEX> -k <ID>` | Raw calldata execution |
|
|
41
|
+
|
|
42
|
+
### Market Data (read-only, no key needed)
|
|
43
|
+
| Command | Description |
|
|
44
|
+
|---------|-------------|
|
|
45
|
+
| `portfolio -k <ID>` | Vault holdings + USD values |
|
|
46
|
+
| `price --token <SYM>` | Real-time price from DexScreener |
|
|
47
|
+
| `search --query <TEXT>` | Find token by name on BSC |
|
|
48
|
+
| `tokens` | List known token addresses |
|
|
49
|
+
|
|
50
|
+
### Risk Management
|
|
51
|
+
| Command | Description |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `policies -k <ID>` | View active policies & current settings |
|
|
54
|
+
| `config -k <ID> --tx-limit <BNB> --daily-limit <BNB> --cooldown <SEC>` | Tighten risk parameters |
|
|
55
|
+
|
|
56
|
+
## 🔧 What Happens Internally
|
|
57
|
+
|
|
58
|
+
1. **Resolves tokens** — `BNB` → `0x0000...`, `USDC` → `0x8AC7...`
|
|
59
|
+
2. **Builds path** — Auto-bridges through WBNB if needed
|
|
60
|
+
3. **Gets quote** — On-chain `getAmountsOut()` for real-time pricing
|
|
61
|
+
4. **Auto-approve** — Checks allowance, adds approve to batch if needed
|
|
62
|
+
5. **Validates** — `PolicyClient.validate()` simulates against all policies
|
|
63
|
+
6. **Executes** — Sends through `AgentNFA.execute()` → PolicyGuard → vault
|
|
64
|
+
|
|
65
|
+
## 🛡️ Security
|
|
66
|
+
|
|
67
|
+
- **PolicyGuard enforced** — Every transaction goes through on-chain policy validation (spending limits, cooldown, DEX whitelist, receiver guard)
|
|
68
|
+
- **Vault isolation** — The operator key cannot directly access vault funds; all operations route through AgentNFA
|
|
69
|
+
- **Renter-only config** — Risk parameters can only be tightened, never loosened beyond template ceiling
|
|
70
|
+
- **⚠️ Use a dedicated wallet** for `RUNNER_PRIVATE_KEY` — this key pays gas for `init` and `config` transactions
|
|
71
|
+
|
|
72
|
+
## 📄 Environment Variables
|
|
73
|
+
|
|
74
|
+
| Variable | Required | Description |
|
|
75
|
+
|----------|----------|-------------|
|
|
76
|
+
| `RUNNER_PRIVATE_KEY` | ✅ | Operator/renter private key |
|
|
77
|
+
| `RPC_URL` | ❌ | BSC RPC (default: public endpoint) |
|
|
78
|
+
| `NFA_ADDRESS` | ❌ | AgentNFA contract override |
|
|
79
|
+
| `GUARD_ADDRESS` | ❌ | PolicyGuard contract override |
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shll-onchain-runner
|
|
3
|
+
description: Execute DeFi transactions on BSC via a SHLL AgentNFA. 12 commands covering onboarding (init), trading (swap, wrap, unwrap, transfer), market data (portfolio, price, search, tokens), risk management (policies, config), and raw execution. All write operations validated by on-chain PolicyGuard.
|
|
4
|
+
version: 3.0.0
|
|
5
|
+
author: SHLL Team
|
|
6
|
+
repository: https://github.com/kledx/shll-skills.git
|
|
7
|
+
install: |
|
|
8
|
+
git clone https://github.com/kledx/shll-skills.git /tmp/shll-skills
|
|
9
|
+
cd /tmp/shll-skills && npm install && npm run build && npm link
|
|
10
|
+
requires:
|
|
11
|
+
- RUNNER_PRIVATE_KEY: Operator private key (required for write commands)
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# SHLL On-Chain Runner
|
|
15
|
+
|
|
16
|
+
A skill that allows OpenClaw to safely interact with DeFi protocols on BSC Mainnet using a SHLL Agent NFA.
|
|
17
|
+
|
|
18
|
+
## 🎯 Purpose
|
|
19
|
+
Use this skill when the user asks you to:
|
|
20
|
+
- "Swap 0.5 BNB for USDC"
|
|
21
|
+
- "Buy some CAKE using my SHLL agent"
|
|
22
|
+
- "Swap 50 USDT for WBNB"
|
|
23
|
+
|
|
24
|
+
## 🛠 Commands
|
|
25
|
+
|
|
26
|
+
### Token Swap (recommended)
|
|
27
|
+
```bash
|
|
28
|
+
shll-onchain-runner swap --from <TOKEN> --to <TOKEN> --amount <AMOUNT> --token-id <NFA_ID>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Parameters:**
|
|
32
|
+
- `--from` / `-f`: Input token. Use a symbol (BNB, USDC, USDT, WBNB, CAKE, ETH, BTCB, DAI, BUSD) or a 0x address.
|
|
33
|
+
- `--to` / `-t`: Output token (same format).
|
|
34
|
+
- `--amount` / `-a`: Amount in human-readable format (e.g. `0.5`, `100`).
|
|
35
|
+
- `--token-id` / `-k`: The user's Agent NFA Token ID.
|
|
36
|
+
- `--slippage` / `-s`: Optional slippage % (default: 5).
|
|
37
|
+
|
|
38
|
+
**Example:**
|
|
39
|
+
```bash
|
|
40
|
+
shll-onchain-runner swap --from BNB --to USDC --amount 0.1 --token-id 1
|
|
41
|
+
shll-onchain-runner swap --from USDT --to CAKE --amount 50 --token-id 1
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The script handles everything internally:
|
|
45
|
+
1. Resolves token symbols to BSC addresses.
|
|
46
|
+
2. Builds the optimal routing path (auto-bridges through WBNB).
|
|
47
|
+
3. Queries PancakeSwap for a real-time price quote.
|
|
48
|
+
4. Checks ERC20 allowance and auto-approves if needed (via atomic batch).
|
|
49
|
+
5. Validates against PolicyGuard.
|
|
50
|
+
6. Executes on-chain.
|
|
51
|
+
|
|
52
|
+
### List Known Tokens
|
|
53
|
+
```bash
|
|
54
|
+
shll-onchain-runner tokens
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Wrap BNB → WBNB
|
|
58
|
+
```bash
|
|
59
|
+
shll-onchain-runner wrap --token-id <NFA_ID> --amount 0.5
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Unwrap WBNB → BNB
|
|
63
|
+
```bash
|
|
64
|
+
shll-onchain-runner unwrap --token-id <NFA_ID> --amount 0.5
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Transfer Tokens from Vault
|
|
68
|
+
```bash
|
|
69
|
+
shll-onchain-runner transfer --token-id <NFA_ID> --token USDC --amount 10 --to 0xRecipient
|
|
70
|
+
```
|
|
71
|
+
Note: ReceiverGuardPolicy may restrict which addresses can receive transfers.
|
|
72
|
+
|
|
73
|
+
### Raw Transaction (advanced)
|
|
74
|
+
```bash
|
|
75
|
+
shll-onchain-runner raw --target <ADDRESS> --data <CALLDATA> --token-id <NFA_ID>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### One-Click Setup (first-time users)
|
|
79
|
+
```bash
|
|
80
|
+
shll-onchain-runner init --listing-id <LISTING_BYTES32> --days 30 --fund 0.5
|
|
81
|
+
```
|
|
82
|
+
This will:
|
|
83
|
+
1. Rent an Agent from the template listing (pays rent in BNB)
|
|
84
|
+
2. Authorize your key as the operator
|
|
85
|
+
3. Fund the vault with BNB
|
|
86
|
+
|
|
87
|
+
After init completes, it outputs the Token ID you need for `swap` commands.
|
|
88
|
+
|
|
89
|
+
### Query Portfolio
|
|
90
|
+
```bash
|
|
91
|
+
shll-onchain-runner portfolio --token-id <NFA_ID>
|
|
92
|
+
```
|
|
93
|
+
Returns vault BNB balance + all ERC20 holdings with USD values.
|
|
94
|
+
|
|
95
|
+
### Check Token Price
|
|
96
|
+
```bash
|
|
97
|
+
shll-onchain-runner price --token CAKE
|
|
98
|
+
shll-onchain-runner price --token 0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82
|
|
99
|
+
```
|
|
100
|
+
Returns real-time price, 24h volume, liquidity, and price change from DexScreener.
|
|
101
|
+
|
|
102
|
+
### Search for a Token
|
|
103
|
+
```bash
|
|
104
|
+
shll-onchain-runner search --query "pancake"
|
|
105
|
+
```
|
|
106
|
+
Finds BSC tokens by name or symbol. Returns addresses and market data.
|
|
107
|
+
|
|
108
|
+
### View Active Policies
|
|
109
|
+
```bash
|
|
110
|
+
shll-onchain-runner policies --token-id <NFA_ID>
|
|
111
|
+
```
|
|
112
|
+
Returns all active policies, whether they're configurable, and current settings (limits, cooldown).
|
|
113
|
+
|
|
114
|
+
### Configure Risk Parameters
|
|
115
|
+
```bash
|
|
116
|
+
shll-onchain-runner config --token-id <NFA_ID> --tx-limit 0.5 --daily-limit 2 --cooldown 120
|
|
117
|
+
```
|
|
118
|
+
Adjusts SpendingLimitPolicy and CooldownPolicy. You can only tighten limits (not exceed template ceiling).
|
|
119
|
+
|
|
120
|
+
## 🔐 Security
|
|
121
|
+
The SHLL PolicyGuard smart contract will automatically reject any transaction that violates the agent's policies (spending limits, cooldown, blacklisted targets, etc.). You do NOT need to verify safety — just construct the intent and the on-chain guard handles the rest.
|
|
122
|
+
|
|
123
|
+
## 📤 Output Format
|
|
124
|
+
All output is JSON on stdout:
|
|
125
|
+
- Success: `{ "status": "success", "hash": "0x..." }`
|
|
126
|
+
- Rejected by policy: `{ "status": "rejected", "reason": "Exceeds per-tx limit" }`
|
|
127
|
+
- Error: `{ "status": "error", "message": "..." }`
|
|
128
|
+
- Quote info: `{ "status": "info", "message": "Quote: ..." }`
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|