@wiimdy/openfunderse-agents 0.1.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/.env.example +51 -0
- package/README.md +252 -0
- package/dist/clawbot-cli.d.ts +1 -0
- package/dist/clawbot-cli.js +114 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +34 -0
- package/dist/lib/aa-client.d.ts +67 -0
- package/dist/lib/aa-client.js +353 -0
- package/dist/lib/relayer-client.d.ts +171 -0
- package/dist/lib/relayer-client.js +486 -0
- package/dist/lib/signer.d.ts +38 -0
- package/dist/lib/signer.js +103 -0
- package/dist/participant-cli.d.ts +1 -0
- package/dist/participant-cli.js +399 -0
- package/dist/reddit-mvp.d.ts +1 -0
- package/dist/reddit-mvp.js +546 -0
- package/dist/skills/participant/index.d.ts +116 -0
- package/dist/skills/participant/index.js +462 -0
- package/dist/skills/strategy/index.d.ts +117 -0
- package/dist/skills/strategy/index.js +879 -0
- package/dist/strategy-cli.d.ts +1 -0
- package/dist/strategy-cli.js +867 -0
- package/package.json +42 -0
package/.env.example
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Relayer client (default credentials)
|
|
2
|
+
RELAYER_URL=http://127.0.0.1:3100
|
|
3
|
+
BOT_ID=bot-participant-1
|
|
4
|
+
BOT_API_KEY=replace_me
|
|
5
|
+
BOT_ADDRESS=0x0000000000000000000000000000000000000001
|
|
6
|
+
|
|
7
|
+
# Optional participant-scoped credentials (if omitted, BOT_* is used)
|
|
8
|
+
PARTICIPANT_BOT_ID=bot-participant-1
|
|
9
|
+
PARTICIPANT_BOT_API_KEY=replace_me
|
|
10
|
+
PARTICIPANT_BOT_ADDRESS=0x0000000000000000000000000000000000000001
|
|
11
|
+
|
|
12
|
+
# Signing
|
|
13
|
+
CHAIN_ID=10143
|
|
14
|
+
BOT_PRIVATE_KEY=0xYOUR_PRIVATE_KEY
|
|
15
|
+
# Optional dedicated participant signer key (fallbacks to BOT_PRIVATE_KEY)
|
|
16
|
+
# PARTICIPANT_PRIVATE_KEY=0xYOUR_PARTICIPANT_PRIVATE_KEY
|
|
17
|
+
CLAIM_ATTESTATION_VERIFIER_ADDRESS=0x0000000000000000000000000000000000000101
|
|
18
|
+
CLAIM_BOOK_ADDRESS=0x0000000000000000000000000000000000000101
|
|
19
|
+
INTENT_BOOK_ADDRESS=0x0000000000000000000000000000000000000102
|
|
20
|
+
|
|
21
|
+
# Participant source safety
|
|
22
|
+
PARTICIPANT_ALLOWED_SOURCE_HOSTS=www.reddit.com,api.coingecko.com
|
|
23
|
+
PARTICIPANT_MAX_RESPONSE_BYTES=524288
|
|
24
|
+
# PARTICIPANT_ALLOW_HTTP_SOURCE=true
|
|
25
|
+
|
|
26
|
+
# NadFun strategy quote
|
|
27
|
+
RPC_URL=http://127.0.0.1:8545
|
|
28
|
+
CLAW_FUND_FACTORY_ADDRESS=0x0000000000000000000000000000000000000000
|
|
29
|
+
NADFUN_LENS_ADDRESS=0xB056d79CA5257589692699a46623F901a3BB76f1
|
|
30
|
+
NADFUN_BONDING_CURVE_ROUTER=0x865054F0F6A288adaAc30261731361EA7E908003
|
|
31
|
+
NADFUN_DEX_ROUTER=0x5D4a4f430cA3B1b2dB86B9cFE48a5316800F5fb2
|
|
32
|
+
NADFUN_WMON_ADDRESS=0x5a4E0bFDeF88C9032CB4d24338C5EB3d3870BfDd
|
|
33
|
+
NADFUN_EXECUTION_ADAPTER_ADDRESS=0x0000000000000000000000000000000000000000
|
|
34
|
+
VAULT_ADDRESS=0x0000000000000000000000000000000000000000
|
|
35
|
+
CLAW_CORE_ADDRESS=0x0000000000000000000000000000000000000000
|
|
36
|
+
|
|
37
|
+
# Strategy AA (Monad testnet, public bundler)
|
|
38
|
+
STRATEGY_AA_RPC_URL=https://testnet-rpc.monad.xyz
|
|
39
|
+
STRATEGY_AA_BUNDLER_URL=https://public.pimlico.io/v2/10143/rpc
|
|
40
|
+
# v06 for public Pimlico-style bundlers, v07 for packed UserOp bundlers
|
|
41
|
+
STRATEGY_AA_USER_OP_VERSION=v06
|
|
42
|
+
STRATEGY_AA_ENTRYPOINT_ADDRESS=0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
|
|
43
|
+
STRATEGY_AA_ACCOUNT_ADDRESS=0x0000000000000000000000000000000000000000
|
|
44
|
+
STRATEGY_AA_OWNER_PRIVATE_KEY=0xYOUR_STRATEGY_AA_OWNER_PRIVATE_KEY
|
|
45
|
+
STRATEGY_CREATE_MIN_AA_BALANCE_WEI=10000000000000000
|
|
46
|
+
# Optional tuning overrides:
|
|
47
|
+
# STRATEGY_AA_CALL_GAS_LIMIT=400000
|
|
48
|
+
# STRATEGY_AA_VERIFICATION_GAS_LIMIT=300000
|
|
49
|
+
# STRATEGY_AA_PRE_VERIFICATION_GAS=2000000
|
|
50
|
+
# STRATEGY_AA_MAX_PRIORITY_FEE_PER_GAS=
|
|
51
|
+
# STRATEGY_AA_MAX_FEE_PER_GAS=
|
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# agents
|
|
2
|
+
|
|
3
|
+
Runtime entry for participant/strategy MoltBots.
|
|
4
|
+
|
|
5
|
+
ER2 quickstart:
|
|
6
|
+
- runbook: `packages/agents/ER2_RUNBOOK.md`
|
|
7
|
+
- env template: `packages/agents/.env.er2.example`
|
|
8
|
+
|
|
9
|
+
Unified entrypoint:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm run clawbot:run -w @claw/agents -- \
|
|
13
|
+
--role strategy \
|
|
14
|
+
--action propose_intent \
|
|
15
|
+
--fund-id demo-fund \
|
|
16
|
+
--intent-file /tmp/intent.json \
|
|
17
|
+
--execution-route-file /tmp/route.json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
One-command smoke:
|
|
21
|
+
```bash
|
|
22
|
+
npm run bot:smoke:e2e -w @claw/agents
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Role
|
|
26
|
+
- Monorepo bot runtime package (execution code), not installer/distribution.
|
|
27
|
+
- Owns crawl/verify/propose runtime flows used by local smoke/E2E paths.
|
|
28
|
+
|
|
29
|
+
Shared protocol utilities:
|
|
30
|
+
- `@claw/protocol-sdk` from `packages/sdk`
|
|
31
|
+
|
|
32
|
+
Run:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run dev -w @claw/agents
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Reddit MVP: Data Mining + Verification
|
|
39
|
+
|
|
40
|
+
MVP baseline source is Reddit (no API key required):
|
|
41
|
+
- participant mines keyword stats from `r/<subreddit>/new.json`
|
|
42
|
+
- participant re-crawls the mined post ids via `by_id` and checks deterministic match
|
|
43
|
+
|
|
44
|
+
Commands:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 1) mine claim + save evidence/claim bundle
|
|
48
|
+
npm run crawl:reddit -w @claw/agents -- \
|
|
49
|
+
--subreddit CryptoCurrency \
|
|
50
|
+
--keywords monad,airdrop \
|
|
51
|
+
--limit 25
|
|
52
|
+
|
|
53
|
+
# 2) verify an existing claim bundle
|
|
54
|
+
npm run verify:reddit -w @claw/agents -- \
|
|
55
|
+
--claim /absolute/path/to/*.claim.json
|
|
56
|
+
|
|
57
|
+
# 3) one-shot mvp flow (crawl -> verify)
|
|
58
|
+
npm run flow:reddit -w @claw/agents -- \
|
|
59
|
+
--subreddit CryptoCurrency \
|
|
60
|
+
--keywords monad,airdrop \
|
|
61
|
+
--limit 25
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Generated files are stored in:
|
|
65
|
+
- `packages/agents/data/claims/*.claim.json`
|
|
66
|
+
- `packages/agents/data/claims/*.evidence.json`
|
|
67
|
+
- `packages/agents/data/claims/*.verification.json`
|
|
68
|
+
|
|
69
|
+
Optional env:
|
|
70
|
+
- `CRAWLER_ADDRESS=0x...`
|
|
71
|
+
- `REDDIT_USER_AGENT=openclaw-mvp-crawler/0.1`
|
|
72
|
+
|
|
73
|
+
## Wave A runtime env (relayer client + signer)
|
|
74
|
+
|
|
75
|
+
Relayer client:
|
|
76
|
+
- `RELAYER_URL`
|
|
77
|
+
- `BOT_ID`
|
|
78
|
+
- `BOT_API_KEY`
|
|
79
|
+
- `BOT_ADDRESS` (required for claim submit/attest; must match registered participant bot address)
|
|
80
|
+
|
|
81
|
+
Signer:
|
|
82
|
+
- `BOT_PRIVATE_KEY` or `VERIFIER_PRIVATE_KEY`
|
|
83
|
+
- `CHAIN_ID`
|
|
84
|
+
- `CLAIM_ATTESTATION_VERIFIER_ADDRESS` (preferred)
|
|
85
|
+
- `CLAIM_BOOK_ADDRESS` (fallback for claim attest domain)
|
|
86
|
+
- `INTENT_BOOK_ADDRESS` (required only for intent attestation signing)
|
|
87
|
+
|
|
88
|
+
Participant source safety:
|
|
89
|
+
- `PARTICIPANT_ALLOWED_SOURCE_HOSTS=www.reddit.com,api.coingecko.com`
|
|
90
|
+
- `PARTICIPANT_MAX_RESPONSE_BYTES=524288`
|
|
91
|
+
- `PARTICIPANT_ALLOW_HTTP_SOURCE=true` (local dev only)
|
|
92
|
+
|
|
93
|
+
Participant optional scoped env:
|
|
94
|
+
- `PARTICIPANT_BOT_ID`, `PARTICIPANT_BOT_API_KEY`, `PARTICIPANT_BOT_ADDRESS`
|
|
95
|
+
- if omitted, participant flow uses `BOT_ID`, `BOT_API_KEY`, `BOT_ADDRESS`
|
|
96
|
+
|
|
97
|
+
Strategy AA env:
|
|
98
|
+
- `STRATEGY_AA_BUNDLER_URL`
|
|
99
|
+
- `STRATEGY_AA_USER_OP_VERSION` (`v06` or `v07`)
|
|
100
|
+
- `STRATEGY_AA_ENTRYPOINT_ADDRESS`
|
|
101
|
+
- `STRATEGY_AA_ACCOUNT_ADDRESS`
|
|
102
|
+
- `STRATEGY_AA_OWNER_PRIVATE_KEY` (or `STRATEGY_PRIVATE_KEY`)
|
|
103
|
+
- `CLAW_FUND_FACTORY_ADDRESS`
|
|
104
|
+
- `INTENT_BOOK_ADDRESS`, `CLAW_CORE_ADDRESS`
|
|
105
|
+
- `NADFUN_EXECUTION_ADAPTER_ADDRESS` (fallback: `ADAPTER_ADDRESS`)
|
|
106
|
+
- optional preflight: `STRATEGY_CREATE_MIN_AA_BALANCE_WEI`
|
|
107
|
+
- optional tuning: `STRATEGY_AA_CALL_GAS_LIMIT`, `STRATEGY_AA_VERIFICATION_GAS_LIMIT`, `STRATEGY_AA_PRE_VERIFICATION_GAS`, `STRATEGY_AA_MAX_PRIORITY_FEE_PER_GAS`, `STRATEGY_AA_MAX_FEE_PER_GAS`
|
|
108
|
+
|
|
109
|
+
Monad testnet reference values:
|
|
110
|
+
- public bundler: `https://public.pimlico.io/v2/10143/rpc`
|
|
111
|
+
- `v06` + EntryPoint `0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789`
|
|
112
|
+
- `v07` + EntryPoint `0x0000000071727De22E5E9d8BAf0edAc6f37da032` (when your bundler supports packed UserOp)
|
|
113
|
+
|
|
114
|
+
## Participant commands
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# 1) Mine a claim from source URL
|
|
118
|
+
npm run participant:mine -w @claw/agents -- \
|
|
119
|
+
--fund-id demo-fund \
|
|
120
|
+
--epoch-id 1 \
|
|
121
|
+
--source-ref https://www.reddit.com/r/CryptoCurrency/new.json?limit=10&raw_json=1 \
|
|
122
|
+
--token-address 0x0000000000000000000000000000000000000001 \
|
|
123
|
+
--out-file /tmp/participant-mine.json
|
|
124
|
+
|
|
125
|
+
# 2) Verify mined claim
|
|
126
|
+
npm run participant:verify -w @claw/agents -- \
|
|
127
|
+
--claim-file /tmp/participant-mine.json \
|
|
128
|
+
--max-data-age-seconds 300
|
|
129
|
+
|
|
130
|
+
# 3) Submit mined claim to relayer
|
|
131
|
+
npm run participant:submit -w @claw/agents -- \
|
|
132
|
+
--claim-file /tmp/participant-mine.json
|
|
133
|
+
|
|
134
|
+
# 4) Attest submitted claim
|
|
135
|
+
npm run participant:attest -w @claw/agents -- \
|
|
136
|
+
--fund-id demo-fund \
|
|
137
|
+
--epoch-id 1 \
|
|
138
|
+
--claim-hash 0x...
|
|
139
|
+
|
|
140
|
+
# 5) One-shot e2e (mine -> verify -> submit -> attest)
|
|
141
|
+
npm run participant:e2e -w @claw/agents -- \
|
|
142
|
+
--fund-id demo-fund \
|
|
143
|
+
--epoch-id 1 \
|
|
144
|
+
--source-ref https://www.reddit.com/r/CryptoCurrency/new.json?limit=10&raw_json=1 \
|
|
145
|
+
--token-address 0x0000000000000000000000000000000000000001 \
|
|
146
|
+
--report-file /tmp/participant-e2e-report.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Strategy commands (AA)
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# 0) Create fund directly onchain via Factory (dry-run only)
|
|
153
|
+
npm run strategy:create:fund -w @claw/agents -- \
|
|
154
|
+
--fund-id demo-fund-001 \
|
|
155
|
+
--fund-name "Demo Fund 001" \
|
|
156
|
+
--deploy-config-file /absolute/path/to/deploy-config.json
|
|
157
|
+
|
|
158
|
+
# 0-a) Set default strategy AA address in agents .env
|
|
159
|
+
npm run strategy:set:aa -w @claw/agents -- \
|
|
160
|
+
--address 0xYourStrategySmartAccount
|
|
161
|
+
|
|
162
|
+
# 0-1) Submit createFund onchain + sync deployment metadata to relayer
|
|
163
|
+
npm run strategy:create:fund -w @claw/agents -- \
|
|
164
|
+
--fund-id demo-fund-001 \
|
|
165
|
+
--fund-name "Demo Fund 001" \
|
|
166
|
+
--deploy-config-file /absolute/path/to/deploy-config.json \
|
|
167
|
+
--telegram-room-id -1001234567890 \
|
|
168
|
+
--submit
|
|
169
|
+
|
|
170
|
+
# 1) READY_FOR_ONCHAIN intent attestation submit (IntentBook.attestIntent via UserOp)
|
|
171
|
+
npm run strategy:attest:onchain -w @claw/agents -- \
|
|
172
|
+
--fund-id demo-fund \
|
|
173
|
+
--intent-hash 0x...
|
|
174
|
+
|
|
175
|
+
# 2) READY execution jobs submit (ClawCore.executeIntent via UserOp)
|
|
176
|
+
npm run strategy:execute:ready -w @claw/agents -- \
|
|
177
|
+
--fund-id demo-fund \
|
|
178
|
+
--limit 10
|
|
179
|
+
|
|
180
|
+
# 3) Dry-run intent execution against core
|
|
181
|
+
npm run strategy:dry-run:intent -w @claw/agents -- \
|
|
182
|
+
--intent-hash 0x... \
|
|
183
|
+
--intent-file /tmp/intent.json \
|
|
184
|
+
--execution-route-file /tmp/route.json
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Strategy skill auto submit (recommended)
|
|
188
|
+
|
|
189
|
+
Programmatic skill path can now run proposal + submission in one call:
|
|
190
|
+
|
|
191
|
+
1. build strategy decision (`proposeIntent`)
|
|
192
|
+
2. submit canonical intent to relayer (`POST /intents/propose`)
|
|
193
|
+
3. send onchain `IntentBook.proposeIntent` via strategy AA
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { proposeIntentAndSubmit } from '@claw/agents';
|
|
197
|
+
|
|
198
|
+
const out = await proposeIntentAndSubmit({
|
|
199
|
+
taskType: 'propose_intent',
|
|
200
|
+
fundId: 'demo-fund',
|
|
201
|
+
roomId: '-1001234567890',
|
|
202
|
+
epochId: 12,
|
|
203
|
+
snapshot: {
|
|
204
|
+
snapshotHash: '0x...',
|
|
205
|
+
finalized: true,
|
|
206
|
+
claimCount: 6
|
|
207
|
+
},
|
|
208
|
+
marketState: {
|
|
209
|
+
network: 10143,
|
|
210
|
+
nadfunCurveState: {},
|
|
211
|
+
liquidity: {},
|
|
212
|
+
volatility: {}
|
|
213
|
+
},
|
|
214
|
+
riskPolicy: {
|
|
215
|
+
maxNotional: '1000000000000000000',
|
|
216
|
+
maxSlippageBps: 500,
|
|
217
|
+
allowlistTokens: ['0x...'],
|
|
218
|
+
allowlistVenues: ['nadfun']
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Implemented modules:
|
|
224
|
+
- `/Users/wiimdy/agent/packages/agents/src/lib/relayer-client.ts`
|
|
225
|
+
- `/Users/wiimdy/agent/packages/agents/src/lib/signer.ts`
|
|
226
|
+
|
|
227
|
+
## Install-pack canonical source
|
|
228
|
+
Target onboarding UX:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npx @wiimdy/openfunderse@latest install openfunderse
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Canonical pack files are maintained at:
|
|
235
|
+
- `packages/openfunderse/packs/openfunderse/config/setup-manifest.json`
|
|
236
|
+
- `packages/openfunderse/packs/openfunderse/skills/clawbot-core/SKILL.md`
|
|
237
|
+
- `packages/openfunderse/packs/openfunderse/prompts/core/system.md`
|
|
238
|
+
- `packages/openfunderse/packs/openfunderse/skills/strategy/SKILL.md`
|
|
239
|
+
- `packages/openfunderse/packs/openfunderse/skills/participant/SKILL.md`
|
|
240
|
+
- `packages/openfunderse/packs/openfunderse/skills/relayer/SKILL.md`
|
|
241
|
+
- `packages/openfunderse/packs/openfunderse/prompts/strategy/system.md`
|
|
242
|
+
- `packages/openfunderse/packs/openfunderse/prompts/participant/system.md`
|
|
243
|
+
- `packages/openfunderse/packs/openfunderse/prompts/relayer/system.md`
|
|
244
|
+
|
|
245
|
+
`packages/agents` keeps runtime code only (`src/*`, `dist/*`).
|
|
246
|
+
|
|
247
|
+
Prompt references from docs:
|
|
248
|
+
- `docs/jupyter-notebook/openclaw-agent-prompt-book.ipynb`
|
|
249
|
+
- `docs/prompts/kr/base_system.md`
|
|
250
|
+
- `docs/prompts/kr/participant_moltbot.md`
|
|
251
|
+
- `docs/prompts/kr/strategy_moltbot.md`
|
|
252
|
+
- `docs/prompts/kr/relayer_next_server.md`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runClawbotCli: (argv: string[]) => Promise<boolean>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { runParticipantCli } from './participant-cli.js';
|
|
2
|
+
import { runStrategyCli } from './strategy-cli.js';
|
|
3
|
+
const parseCli = (argv) => {
|
|
4
|
+
const [command, ...rest] = argv;
|
|
5
|
+
const options = new Map();
|
|
6
|
+
const flags = new Set();
|
|
7
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
8
|
+
const token = rest[i];
|
|
9
|
+
if (!token.startsWith('--'))
|
|
10
|
+
continue;
|
|
11
|
+
const key = token.slice(2);
|
|
12
|
+
if (key.includes('=')) {
|
|
13
|
+
const [left, ...right] = key.split('=');
|
|
14
|
+
options.set(left, right.join('='));
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const next = rest[i + 1];
|
|
18
|
+
if (next && !next.startsWith('--')) {
|
|
19
|
+
options.set(key, next);
|
|
20
|
+
i += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
flags.add(key);
|
|
24
|
+
}
|
|
25
|
+
return { command, options, flags };
|
|
26
|
+
};
|
|
27
|
+
const stripOption = (args, key) => {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
30
|
+
const token = args[i];
|
|
31
|
+
if (token === `--${key}`) {
|
|
32
|
+
const next = args[i + 1];
|
|
33
|
+
if (next && !next.startsWith('--')) {
|
|
34
|
+
i += 1;
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (token.startsWith(`--${key}=`)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
result.push(token);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
const mapCommand = (role, action) => {
|
|
46
|
+
if (role === 'strategy') {
|
|
47
|
+
if (action === 'create_fund_onchain')
|
|
48
|
+
return 'strategy-create-fund';
|
|
49
|
+
if (action === 'propose_intent')
|
|
50
|
+
return 'strategy-propose';
|
|
51
|
+
if (action === 'dry_run_intent_execution')
|
|
52
|
+
return 'strategy-dry-run-intent';
|
|
53
|
+
if (action === 'attest_intent_onchain')
|
|
54
|
+
return 'strategy-attest-onchain';
|
|
55
|
+
if (action === 'execute_intent_onchain')
|
|
56
|
+
return 'strategy-execute-ready';
|
|
57
|
+
if (action === 'set_aa')
|
|
58
|
+
return 'strategy-set-aa';
|
|
59
|
+
}
|
|
60
|
+
if (role === 'participant') {
|
|
61
|
+
if (action === 'mine_claim')
|
|
62
|
+
return 'participant-mine';
|
|
63
|
+
if (action === 'verify_claim')
|
|
64
|
+
return 'participant-verify';
|
|
65
|
+
if (action === 'verify_claim_or_intent_validity')
|
|
66
|
+
return 'participant-verify';
|
|
67
|
+
if (action === 'submit_claim')
|
|
68
|
+
return 'participant-submit';
|
|
69
|
+
if (action === 'submit_mined_claim')
|
|
70
|
+
return 'participant-submit';
|
|
71
|
+
if (action === 'attest_claim')
|
|
72
|
+
return 'participant-attest';
|
|
73
|
+
if (action === 'participant_e2e')
|
|
74
|
+
return 'participant-e2e';
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`unsupported clawbot action: role=${role}, action=${action}`);
|
|
77
|
+
};
|
|
78
|
+
const printUsage = () => {
|
|
79
|
+
console.log(`
|
|
80
|
+
[agents] clawbot-run
|
|
81
|
+
|
|
82
|
+
clawbot-run --role <strategy|participant> --action <action> [action options...]
|
|
83
|
+
|
|
84
|
+
Examples:
|
|
85
|
+
clawbot-run --role strategy --action propose_intent --fund-id demo-fund --intent-file ./intent.json --execution-route-file ./route.json
|
|
86
|
+
clawbot-run --role participant --action mine_claim --fund-id demo-fund --epoch-id 1 --source-ref https://example.com --token-address 0x...
|
|
87
|
+
`);
|
|
88
|
+
};
|
|
89
|
+
export const runClawbotCli = async (argv) => {
|
|
90
|
+
const parsed = parseCli(argv);
|
|
91
|
+
const command = parsed.command ?? '';
|
|
92
|
+
if (command !== 'clawbot-run') {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (parsed.flags.has('help')) {
|
|
96
|
+
printUsage();
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
const role = (parsed.options.get('role') ?? '').trim().toLowerCase();
|
|
100
|
+
const action = (parsed.options.get('action') ?? '').trim().toLowerCase();
|
|
101
|
+
if (!role)
|
|
102
|
+
throw new Error('missing required option --role');
|
|
103
|
+
if (!action)
|
|
104
|
+
throw new Error('missing required option --action');
|
|
105
|
+
const mapped = mapCommand(role, action);
|
|
106
|
+
const forwarded = stripOption(stripOption(argv.slice(1), 'role'), 'action');
|
|
107
|
+
const delegatedArgv = [mapped, ...forwarded];
|
|
108
|
+
if (mapped.startsWith('strategy-')) {
|
|
109
|
+
await runStrategyCli(delegatedArgv);
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
await runParticipantCli(delegatedArgv);
|
|
113
|
+
return true;
|
|
114
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { createRelayerClient, RelayerClient } from './lib/relayer-client.js';
|
|
2
|
+
export type { ClaimAttestationInput, ClaimQuery, ClaimTemplateInput, IntentAttestationInput, IntentOnchainBundleItem, IntentOnchainBundleResponse, ReadyExecutionPayloadItem, RelayerProposeIntentInput, RelayerClientOptions, RelayerHttpErrorShape, SyncFundDeploymentInput, SseEvent, SseHandlers, SseSubscription } from './lib/relayer-client.js';
|
|
3
|
+
export { createBotSigner, BotSigner } from './lib/signer.js';
|
|
4
|
+
export type { BotSignerOptions, SignedClaimAttestation, SignedIntentAttestation } from './lib/signer.js';
|
|
5
|
+
export { StrategyAaClient } from './lib/aa-client.js';
|
|
6
|
+
export type { ExecuteViaAaInput, StrategyAaClientEnvOverrides, StrategyAaClientConfig, UserOperationResult } from './lib/aa-client.js';
|
|
7
|
+
export { attestClaim, mineClaim, submitMinedClaim, verifyClaim } from './skills/participant/index.js';
|
|
8
|
+
export type { AttestClaimInput, AttestClaimOutput, MineClaimInput, MineClaimOutput, MineClaimObservation, SubmitMinedClaimInput, SubmitMinedClaimOutput, VerifyClaimInput, VerifyClaimOutput } from './skills/participant/index.js';
|
|
9
|
+
export { proposeIntent, proposeIntentAndSubmit } from './skills/strategy/index.js';
|
|
10
|
+
export type { ProposeIntentAndSubmitInput, ProposeIntentAndSubmitOutput, ProposeIntentInput, ProposeIntentOutput, ProposeDecision, HoldDecision, RiskChecks } from './skills/strategy/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { runRedditMvpCli } from './reddit-mvp.js';
|
|
2
|
+
import { runParticipantCli } from './participant-cli.js';
|
|
3
|
+
import { runStrategyCli } from './strategy-cli.js';
|
|
4
|
+
import { runClawbotCli } from './clawbot-cli.js';
|
|
5
|
+
export { createRelayerClient, RelayerClient } from './lib/relayer-client.js';
|
|
6
|
+
export { createBotSigner, BotSigner } from './lib/signer.js';
|
|
7
|
+
export { StrategyAaClient } from './lib/aa-client.js';
|
|
8
|
+
export { attestClaim, mineClaim, submitMinedClaim, verifyClaim } from './skills/participant/index.js';
|
|
9
|
+
export { proposeIntent, proposeIntentAndSubmit } from './skills/strategy/index.js';
|
|
10
|
+
console.log('[agents] boot');
|
|
11
|
+
console.log(`[agents] strategy key set=${Boolean(process.env.STRATEGY_PRIVATE_KEY)}`);
|
|
12
|
+
console.log(`[agents] participant key set=${Boolean(process.env.PARTICIPANT_PRIVATE_KEY ||
|
|
13
|
+
process.env.BOT_PRIVATE_KEY ||
|
|
14
|
+
process.env.VERIFIER_PRIVATE_KEY)}`);
|
|
15
|
+
const main = async () => {
|
|
16
|
+
const argv = process.argv.slice(2);
|
|
17
|
+
const handledByClawbot = await runClawbotCli(argv);
|
|
18
|
+
if (handledByClawbot) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const handledByStrategy = await runStrategyCli(argv);
|
|
22
|
+
if (handledByStrategy) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const handledByParticipant = await runParticipantCli(argv);
|
|
26
|
+
if (!handledByParticipant) {
|
|
27
|
+
await runRedditMvpCli(argv);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
main().catch((error) => {
|
|
31
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
32
|
+
console.error(`[agents] error: ${message}`);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
type UserOpVersion = 'v06' | 'v07';
|
|
3
|
+
export interface StrategyAaClientConfig {
|
|
4
|
+
chainId: number;
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
bundlerUrl: string;
|
|
7
|
+
entryPoint: Address;
|
|
8
|
+
smartAccount: Address;
|
|
9
|
+
ownerPrivateKey: Hex;
|
|
10
|
+
initCode?: Hex;
|
|
11
|
+
callGasLimit?: bigint;
|
|
12
|
+
verificationGasLimit?: bigint;
|
|
13
|
+
preVerificationGas?: bigint;
|
|
14
|
+
maxPriorityFeePerGas?: bigint;
|
|
15
|
+
maxFeePerGas?: bigint;
|
|
16
|
+
pollIntervalMs?: number;
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
userOpVersion?: UserOpVersion;
|
|
19
|
+
}
|
|
20
|
+
export interface StrategyAaClientEnvOverrides {
|
|
21
|
+
chainId?: number;
|
|
22
|
+
rpcUrl?: string;
|
|
23
|
+
bundlerUrl?: string;
|
|
24
|
+
entryPoint?: Address;
|
|
25
|
+
smartAccount?: Address;
|
|
26
|
+
ownerPrivateKey?: Hex;
|
|
27
|
+
initCode?: Hex;
|
|
28
|
+
callGasLimit?: bigint;
|
|
29
|
+
verificationGasLimit?: bigint;
|
|
30
|
+
preVerificationGas?: bigint;
|
|
31
|
+
maxPriorityFeePerGas?: bigint;
|
|
32
|
+
maxFeePerGas?: bigint;
|
|
33
|
+
pollIntervalMs?: number;
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
userOpVersion?: UserOpVersion;
|
|
36
|
+
}
|
|
37
|
+
export interface ExecuteViaAaInput {
|
|
38
|
+
target: Address;
|
|
39
|
+
data: Hex;
|
|
40
|
+
value?: bigint;
|
|
41
|
+
}
|
|
42
|
+
export interface UserOperationResult {
|
|
43
|
+
userOpHash: Hex;
|
|
44
|
+
receipt: Record<string, unknown> | null;
|
|
45
|
+
transactionHash: Hex | null;
|
|
46
|
+
}
|
|
47
|
+
export declare class StrategyAaClient {
|
|
48
|
+
private readonly config;
|
|
49
|
+
private readonly publicClient;
|
|
50
|
+
private readonly owner;
|
|
51
|
+
constructor(config: StrategyAaClientConfig);
|
|
52
|
+
static fromEnv(overrides?: StrategyAaClientEnvOverrides): StrategyAaClient;
|
|
53
|
+
sendExecute(input: ExecuteViaAaInput): Promise<UserOperationResult>;
|
|
54
|
+
sendUserOperation(callData: Hex): Promise<UserOperationResult>;
|
|
55
|
+
waitForUserOperationReceipt(userOpHash: Hex): Promise<Record<string, unknown> | null>;
|
|
56
|
+
private userOpVersion;
|
|
57
|
+
private submitUserOperation;
|
|
58
|
+
private resolveGasFees;
|
|
59
|
+
private parseBigIntLike;
|
|
60
|
+
private tryResolveBundlerGasFees;
|
|
61
|
+
private buildSignedUserOperationV07;
|
|
62
|
+
private buildSignedUserOperationV06;
|
|
63
|
+
private toRpcUserOperationV07;
|
|
64
|
+
private toRpcUserOperationV06;
|
|
65
|
+
private callBundler;
|
|
66
|
+
}
|
|
67
|
+
export {};
|