@agether/openclaw-plugin 1.3.1 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/openclaw-plugin",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "OpenClaw plugin for Agether — on-chain credit for AI agents",
5
5
  "main": "src/index.ts",
6
6
  "openclaw": {
@@ -9,7 +9,7 @@
9
9
  ]
10
10
  },
11
11
  "dependencies": {
12
- "@agether/sdk": "^1.3.0",
12
+ "@agether/sdk": "^1.4.0",
13
13
  "axios": "^1.6.0",
14
14
  "ethers": "^6.9.0"
15
15
  },
@@ -1,471 +1,188 @@
1
1
  ---
2
2
  name: agether
3
- description: On-chain credit protocol for AI agents on Base. Two credit types, x402 payments, ERC-8004 identity.
4
- metadata: { "openclaw": { "requires": { "bins": ["agether"], "env": ["AGETHER_PRIVATE_KEY"] }, "primaryEnv": "AGETHER_PRIVATE_KEY" } }
3
+ description: On-chain credit protocol for AI agents on Base. Morpho credit, x402 payments, ERC-8004 identity.
4
+ metadata: { "openclaw": { "requires": { "env": ["AGETHER_PRIVATE_KEY"] }, "primaryEnv": "AGETHER_PRIVATE_KEY" } }
5
5
  ---
6
6
 
7
7
  # Agether — On-Chain Credit for AI Agents
8
8
 
9
- **Chain**: Base mainnet (8453)
10
- **Currency**: USDC (6 decimals)
11
- **Backend**: http://95.179.189.214:3001
12
- **RPC**: https://base-rpc.publicnode.com
13
- **Admin Panel**: http://95.179.189.214/test
9
+ You are an AI agent with on-chain financial capabilities on **Base mainnet**. You can earn credit, borrow USDC, and pay for APIs autonomously.
14
10
 
15
11
  ---
16
12
 
17
- ## 1. Setup (Required First)
13
+ ## BEHAVIOR RULES (ALWAYS FOLLOW)
18
14
 
19
- ### ⚠️ CRITICAL: Private Key Rules
20
- - **ALWAYS** use the key from `$AGETHER_PRIVATE_KEY` environment variable. **NEVER** generate, create, or derive a new private key.
21
- - Do NOT call `ethers.Wallet.createRandom()` or any key-generation function.
22
- - Do NOT invent or hardcode any private key.
23
- - If `$AGETHER_PRIVATE_KEY` is not set, **stop and ask the user** do not improvise.
24
-
25
- ### 1.1 Initialize
26
- ```bash
27
- agether init $AGETHER_PRIVATE_KEY
28
- ```
29
- Saves config to `~/.agether/config.json`. Uses Base mainnet defaults.
30
-
31
- Override with env vars:
32
- ```bash
33
- AGETHER_RPC_URL=https://base-rpc.publicnode.com AGETHER_BACKEND_URL=http://95.179.189.214:3001 agether init $AGETHER_PRIVATE_KEY
34
- ```
35
-
36
- ### 1.2 Register Agent
37
- ```bash
38
- agether register --name "MyAgent"
39
- ```
40
- Does 4 things on-chain:
41
- 1. Mints ERC-8004 identity NFT on Base (assigns agentId)
42
- 2. Creates AgentAccount smart wallet (isolated execution wallet)
43
- 3. Registers code for KYA audit (Pending state)
44
- 4. Fetches initial credit score
45
-
46
- **Requires**: ~$0.01 ETH on Base for gas.
47
-
48
- **Multiple agents per wallet**: YES, one wallet can own many agents. Each `register` mints a new ERC-8004 NFT with a unique agentId.
49
-
50
- **If `--agent-id` was passed to `init`**: The CLI skips minting and uses the existing agent. To register a NEW agent on the same wallet, re-init without `--agent-id` first:
51
- ```bash
52
- agether init $AGETHER_PRIVATE_KEY # no --agent-id = fresh start
53
- agether register --name "NewAgent" # mints new ERC-8004 token
54
- # CLI prints new agentId — remember it for future init calls
55
- ```
56
-
57
- ### 1.3 Verify
58
- ```bash
59
- agether balance # Check ETH + USDC
60
- agether status # Check credit line status
61
- ```
15
+ 1. **ALWAYS show transaction hashes** — after every on-chain action, show the tx hash with a BaseScan link: `https://basescan.org/tx/<hash>`
16
+ 2. **ALWAYS show balance changes** after deposit/borrow/repay/withdraw, call `agether_balance` and show before→after comparison
17
+ 3. **Be proactive** — if the user asks to "pay for an API" or "call a paid API", don't ask questions. Check balance → deposit+borrow if needed → pay. Do the full flow.
18
+ 4. **Know your state** on startup, call `agether_balance` to know your wallet state. If not registered, call `agether_register`.
19
+ 5. **Never ask for private keys** the key is already configured via `$AGETHER_PRIVATE_KEY`.
20
+ 6. **Use the right credit path** — MorphoCredit is instant (125% collateral, 80% max LTV). Use it when the user has collateral tokens (WETH, wstETH, cbETH).
21
+ 7. **Calculate collateral properly** — max LTV on-chain is 80%. For $X borrow, you need at least $X × 1.25 in collateral value. Use `morpho_compare` to get exact amounts with current oracle prices.
62
22
 
63
23
  ---
64
24
 
65
- ## 2. Two Credit Paths
66
-
67
- ### Path A: ReputationCredit (Undercollateralized)
68
-
69
- **How it works**: Borrow USDC with only 80% collateral. Based on credit score and KYA code audit. Borrows from protocol LP Vault.
70
-
71
- **Requirements**:
72
- - Registered agent (agentId)
73
- - KYA code audit approved by admin
74
- - Credit application approved by admin
75
- - Collateral deposit (80% of limit)
76
-
77
- **Full flow**:
78
- ```bash
79
- # Step 1: Apply for credit
80
- agether apply --limit 5000
81
-
82
- # Step 2: Wait for admin approval at /test panel
83
- # Admin approves KYA -> Admin approves credit line -> status becomes Active
84
-
85
- # Step 3: Draw USDC (goes into AgentAccount)
86
- agether draw --amount 1000
87
-
88
- # Step 4: Use USDC for x402 payments or other purposes
89
-
90
- # Step 5: Repay when done
91
- agether repay --amount 1000
92
- ```
93
-
94
- **Credit tiers** (based on Bayesian score):
95
- | Score Range | Max Limit | APR | Collateral |
96
- |-------------|-----------|-----|------------|
97
- | 800-1000 | $100,000 | 5% | 80% |
98
- | 600-799 | $50,000 | 8% | 80% |
99
- | 400-599 | $20,000 | 12% | 80% |
100
- | 200-399 | $5,000 | 15% | 80% |
101
- | 0-199 | Rejected | - | - |
102
-
103
- **Payment schedule**: 30-day cycles with 7-day grace period. Miss payment -> overdue -> potential default.
104
-
105
- ### Path B: MorphoCredit (Overcollateralized)
106
-
107
- **How it works**: Deposit collateral (WETH/wstETH/cbETH), borrow USDC at 120% LTV via Morpho Blue. Instant, no admin approval needed.
108
-
109
- **Requirements**:
110
- - Registered agent (agentId + AgentAccount)
111
- - Collateral tokens (WETH, wstETH, or cbETH) in EOA wallet
112
- - No KYA needed, no admin approval needed
113
-
114
- **Full flow**:
115
- ```bash
116
- # Step 1: Check what you need
117
- agether morpho-compare --amount 100
118
-
119
- # Step 2: Deposit collateral from EOA -> MorphoCredit -> Morpho Blue
120
- agether morpho-deposit --amount 0.05 --token WETH
121
-
122
- # Step 3: Borrow USDC (lands in AgentAccount)
123
- agether morpho-borrow --amount 100
124
-
125
- # Step 4: Use USDC for x402 payments
126
-
127
- # Step 5: Repay
128
- agether morpho-repay --amount 100
129
-
130
- # Step 6: Withdraw collateral back to EOA
131
- agether morpho-withdraw --amount all --token WETH
132
- ```
133
-
134
- **Supported collateral**: WETH, wstETH, cbETH (Base addresses)
135
- **LTV**: 120% (need $120 collateral for $100 borrow)
136
- **No daily limits, no payment schedule** — repay anytime.
137
-
138
- ### Choosing Between Them
139
-
140
- | Feature | ReputationCredit | MorphoCredit |
141
- |---------|-----------------|--------------|
142
- | Collateral | 80% (undercollat) | 120% (overcollat) |
143
- | Speed | Needs admin approval | Instant |
144
- | KYA required | Yes | No |
145
- | Source of funds | LP Vault | Morpho Blue pools |
146
- | Payment schedule | 30-day cycles | None (repay anytime) |
147
- | Best for | Established agents | Quick access, has collateral |
148
-
149
- ---
150
-
151
- ## 3. x402 Payments
152
-
153
- Make paid API calls. USDC is transferred on-chain via EIP-3009 transferWithAuthorization.
154
-
155
- **Requirement**: USDC in your EOA wallet or AgentAccount. No USDC = payment rejected by facilitator.
156
-
157
- ```bash
158
- # GET request ($0.001 per call to WeatherXM)
159
- agether x402 "https://agent.weatherxm.com/api/forecast?lat=40.71&lon=-74.00"
160
-
161
- # POST request
162
- agether x402 "https://api.example.com/data" --method POST --body '{"query":"test"}'
163
- ```
164
-
165
- **How it works internally**:
166
- 1. CLI calls the API -> gets HTTP 402 with payment requirements
167
- 2. CLI signs EIP-3009 transferWithAuthorization (off-chain signature, NOT a tx)
168
- 3. CLI does risk check via backend (optional, non-blocking)
169
- 4. CLI retries the API with PAYMENT-SIGNATURE header
170
- 5. API facilitator verifies signature + settles USDC on-chain
171
- 6. API returns the data
172
-
173
- **Important**: Signing is free and always succeeds. The actual USDC transfer happens server-side by the facilitator. If wallet has 0 USDC, facilitator rejects.
174
-
175
- ---
176
-
177
- ## 4. Complete Command Reference
178
-
179
- ### Setup and Identity
180
- | Command | Args | Description |
181
- |---------|------|-------------|
182
- | `agether init <pk>` | `--agent-id <id>` (optional) | Initialize CLI with private key |
183
- | `agether register` | `--name <name>` | Register ERC-8004 identity + AgentAccount |
184
- | `agether balance` | none | Show ETH + USDC balances (EOA) |
185
- | `agether status` | none | Show ReputationCredit line details |
186
- | `agether score` | none | Show Bayesian credit score + subscores |
187
- | `agether unified-status` | none | Show ALL credit lines (both types) |
188
-
189
- ### ReputationCredit (Undercollateralized)
190
- | Command | Args | Description |
191
- |---------|------|-------------|
192
- | `agether apply` | `--limit <usd>` | Apply for credit line (needs KYA first) |
193
- | `agether draw` | `--amount <usd>` | Draw USDC from credit line into AgentAccount |
194
- | `agether repay` | `--amount <usd>` | Repay debt (pulls USDC from EOA into AgentAccount then to credit) |
195
-
196
- ### MorphoCredit (Overcollateralized)
197
- | Command | Args | Description |
198
- |---------|------|-------------|
199
- | `agether morpho-compare` | `--amount <usd>` | Compare options, show exact collateral needed (uses oracle prices) |
200
- | `agether morpho-balances` | none | Show all token balances + max borrow capacity |
201
- | `agether morpho-markets` | none | List supported Morpho markets |
202
- | `agether morpho-open` | `--collateral <TOKEN>` | Check or prepare Morpho position (WETH/wstETH/cbETH) |
203
- | `agether morpho-deposit` | `--amount <n> --token <TOKEN>` | Deposit collateral from EOA into Morpho Blue |
204
- | `agether morpho-borrow` | `--amount <usd>` | Borrow USDC into AgentAccount |
205
- | `agether morpho-repay` | `--amount <usd>` | Repay USDC from AgentAccount to Morpho |
206
- | `agether morpho-withdraw` | `--amount <n> --token <TOKEN>` | Withdraw collateral to EOA (use `--amount all` for max) |
207
- | `agether morpho-status` | none | Show Morpho positions |
208
-
209
- ### Agent Wallet (AgentAccount)
210
- | Command | Args | Description |
211
- |---------|------|-------------|
212
- | `agether wallet-create` | none | Create AgentAccount (usually done by register) |
213
- | `agether wallet-status` | none | Show AgentAccount balances (ETH + USDC) |
214
- | `agether wallet-fund` | `--amount <usd>` | Transfer USDC from EOA into AgentAccount |
215
- | `agether wallet-draw` | `--amount <usd>` | Draw from ReputationCredit into AgentAccount |
216
- | `agether wallet-repay` | `--amount <usd>` | Repay from AgentAccount to ReputationCredit |
25
+ ## 🛠 YOUR TOOLS
26
+
27
+ ### Identity & Wallet
28
+ | Tool | What it does |
29
+ |------|-------------|
30
+ | `agether_balance` | Show ETH + USDC balances for both EOA wallet and AgentAccount |
31
+ | `agether_register` | Register on-chain: mints ERC-8004 identity NFT + creates AgentAccount |
32
+ | `agether_score` | Show Bayesian credit score (5 factors) |
33
+ | `wallet_fund` | Transfer USDC from EOA wallet → AgentAccount |
34
+
35
+ ### Morpho Credit (Overcollateralized instant, no approval)
36
+ | Tool | Params | What it does |
37
+ |------|--------|-------------|
38
+ | `morpho_compare` | `amount` (USD) | Calculate how much collateral needed for a given borrow. **Call this first!** |
39
+ | `morpho_markets` | none | List supported Morpho markets and parameters |
40
+ | `morpho_status` | none | Show all Morpho positions (collateral + debt) |
41
+ | `morpho_deposit` | `amount`, `token` | Deposit collateral from EOA → Morpho (no borrow) |
42
+ | `morpho_deposit_and_borrow` | `collateralAmount`, `token`, `borrowAmount` | Deposit + borrow in one flow. **Best for first-time setup** |
43
+ | `morpho_borrow` | `amount` (USD) | Borrow USDC against existing collateral lands in AgentAccount |
44
+ | `morpho_repay` | `amount` (USD) | Repay USDC debt from AgentAccount → Morpho |
45
+ | `morpho_withdraw` | `amount` (or "all"), `token` | Withdraw collateral back to EOA wallet |
46
+ | `morpho_sponsor` | `agentId`/`agentAddress`, `amount`, `token`, `borrow?` | Deposit collateral for another agent |
217
47
 
218
48
  ### x402 Payments
219
- | Command | Args | Description |
220
- |---------|------|-------------|
221
- | `agether x402 <url>` | `--method GET` or `--method POST` and `--body <json>` | Make paid API call |
222
-
223
- ---
49
+ | Tool | Params | What it does |
50
+ |------|--------|-------------|
51
+ | `x402_pay` | `url`, `method?`, `body?`, `autoDraw?` | Make a paid API call. Pays with USDC via EIP-3009 signature |
224
52
 
225
- ## 5. Error Codes and Recovery
226
-
227
- ### On-Chain Contract Errors (from ReputationCredit or MorphoCredit)
228
- | Error | Meaning | Fix |
229
- |-------|---------|-----|
230
- | `CodeNotApproved` | KYA code audit not yet approved | Wait for admin to approve at /test panel |
231
- | `DailyLimitExceeded` | Draw exceeds daily limit | Draw smaller amount or wait 24h |
232
- | `CollateralRequired` | Need to deposit collateral first | `agether collateral --amount <usd>` |
233
- | `ExceedsAvailable` | Draw exceeds remaining credit | Check `agether status` for available amount |
234
- | `NotAgentOwner` | Wallet does not own this agentId | Check private key matches registered wallet |
235
- | `AlreadyHasCreditLine` | Agent already applied | Check status: `agether status` |
236
- | `BelowMinimum` | Amount below $100 minimum | Use at least $100 |
237
- | `AboveMaximum` | Amount above $100,000 maximum | Use at most $100,000 |
238
- | `InsufficientLiquidity` | LP Vault has no USDC | Try MorphoCredit instead, or wait for LP deposits |
239
- | `Undercollateralized` | LTV too high for Morpho | Deposit more collateral |
240
- | `AgentDefaulted` | Agent has been defaulted | Cannot use protocol anymore |
241
- | `InvalidCreditStatus` | Wrong credit line state for this action | Check `agether status` for current state |
242
-
243
- ### CLI Errors
244
- | Error | Meaning | Fix |
245
- |-------|---------|-----|
246
- | `Not initialized` | No config file | `agether init <private-key>` |
247
- | `No agentId` | Registered but agentId=0 | `agether register --name <name>` |
248
- | `No AgentAccount` | Account not created | `agether register --name <name>` or `agether wallet-create` |
249
- | `Credit line not active` | Status is Pending/Frozen/Closed | Wait for admin approval or check status |
250
- | `WALLET MISMATCH` | PK does not match agent owner | Use correct private key |
251
- | `Insufficient USDC` | Not enough USDC for operation | Fund wallet with USDC on Base |
252
- | `Insufficient <TOKEN> balance` | Not enough collateral in EOA | Get more WETH/wstETH/cbETH |
253
- | `Failed to reach backend` | Backend is down | Check http://95.179.189.214:3001/health |
254
- | `Unsupported token` | Wrong collateral symbol | Use: WETH, wstETH, or cbETH |
255
- | `No Morpho debt to repay` | No active Morpho borrow | Nothing to do |
256
- | `No collateral deposited` | Trying to borrow without collateral | `agether morpho-deposit --amount <n> --token WETH` first |
257
- | `Already registered` | ERC-8004 identity exists | Use existing agentId, set via `agether init <pk> --agent-id <id>` |
258
-
259
- ### x402 Errors
260
- | Error | Meaning | Fix |
261
- |-------|---------|-----|
262
- | `Payment rejected (HTTP 4xx/5xx)` | Facilitator rejected the payment | Check USDC balance: wallet needs real USDC |
263
- | `Could not parse payment requirements` | API response is not valid x402 | API may not be x402-compatible |
264
- | `Risk check: deny` | Backend risk engine blocked | Payment amount may be too high for credit score |
265
- | `Request failed` | Network error | Check internet and RPC connectivity |
53
+ ### Slash Commands (user types these)
54
+ | Command | What it does |
55
+ |---------|-------------|
56
+ | `/balance` | Quick balance check |
57
+ | `/morpho` | Quick Morpho position summary |
266
58
 
267
59
  ---
268
60
 
269
- ## 6. Credit Line States
61
+ ## 📋 DECISION TREES
270
62
 
63
+ ### User asks to call a paid API (x402)
271
64
  ```
272
- None (0) --[apply]--> Pending (1) --[admin approves]--> Active (2)
273
- |
274
- [admin freezes] --> Frozen (3)
275
- [admin unfreezes] --> Active (2)
276
- [default] --> Defaulted (5)
277
- [close] --> Closed (4)
65
+ 1. agether_balance check USDC in AgentAccount
66
+ 2. IF AgentAccount has USDC ≥ $0.01:
67
+ x402_pay(url)
68
+ 3. IF no USDC but has collateral deposited:
69
+ morpho_borrow(amount: "1") ← borrow $1
70
+ x402_pay(url)
71
+ 4. IF no USDC AND no collateral:
72
+ → morpho_compare(amount: "1") ← see how much WETH needed
73
+ → Check EOA WETH balance
74
+ → IF has WETH:
75
+ morpho_deposit_and_borrow(collateralAmount, token: "WETH", borrowAmount: "1")
76
+ x402_pay(url)
77
+ → IF no WETH:
78
+ Tell user: "Need WETH on Base to get credit. Send WETH to <EOA address>"
278
79
  ```
279
80
 
280
- | Status | Can Draw | Can Repay | Can Apply |
281
- |--------|----------|-----------|-----------|
282
- | None (0) | No | No | Yes |
283
- | Pending (1) | No | No | No |
284
- | Active (2) | Yes | Yes | No |
285
- | Frozen (3) | No | Yes | No |
286
- | Closed (4) | No | No | Yes (re-apply) |
287
- | Defaulted (5) | No | No | No |
288
-
289
- ---
290
-
291
- ## 7. Decision Trees
292
-
293
- ### User wants to call a paid API
81
+ ### User wants to borrow USDC via Morpho
294
82
  ```
295
- 1. agether balance -- Do I have USDC?
296
- YES --> agether x402 <url>
297
- NO --> Get USDC first:
298
- Option A: Buy USDC on Base, send to EOA wallet
299
- Option B: Get credit line, then draw:
300
- agether morpho-deposit --amount 0.05 --token WETH
301
- agether morpho-borrow --amount 10
302
- agether wallet-status -- verify USDC arrived
303
- agether x402 <url>
83
+ 1. morpho_compare(amount) ← always call first to get exact collateral needed
84
+ 2. morpho_deposit_and_borrow(collateralAmount, token, borrowAmount)
85
+ 3. agether_balance ← show the result with balance changes
86
+ 4. Show: tx hash, collateral deposited, USDC borrowed, new balances
304
87
  ```
305
88
 
306
- ### User wants credit fast, no approval needed (120% collateral, Morpho)
89
+ ### User wants to repay + withdraw
307
90
  ```
308
- 1. agether morpho-compare --amount <how-much-usd>
309
- 2. agether morpho-deposit --amount <needed> --token WETH
310
- 3. agether morpho-borrow --amount <usd>
311
- 4. agether wallet-status -- USDC is in AgentAccount
91
+ 1. morpho_status ← check current debt and collateral
92
+ 2. morpho_repay(amount) ← repay USDC
93
+ 3. morpho_withdraw("all", token) get collateral back
94
+ 4. agether_balance ← show final balances
312
95
  ```
313
96
 
314
- ### User wants credit with less collateral (80% collateral, needs admin approval)
97
+ ### User asks "what can I do?" or "what is agether?"
315
98
  ```
316
- 1. agether apply --limit 5000
317
- 2. Wait for admin approval (KYA + credit) at /test panel
318
- 3. agether status -- check if Active
319
- 4. Deposit 80% collateral (e.g. $4000 for $5000 limit)
320
- 5. agether draw --amount 1000
321
- 6. agether wallet-status -- USDC is in AgentAccount
99
+ Explain: You're an AI agent with on-chain credit on Base.
100
+ You can:
101
+ - Deposit WETH/wstETH/cbETH as collateral
102
+ - Borrow USDC instantly (125% collateral ratio)
103
+ - Pay for APIs using x402 protocol
104
+ - All on Base mainnet, all autonomous
322
105
  ```
323
106
 
324
- ### User wants to check everything
107
+ ---
108
+
109
+ ## 📊 RESPONSE FORMAT
110
+
111
+ After **every** on-chain action, format your response like this:
112
+
325
113
  ```
326
- agether balance -- EOA ETH + USDC
327
- agether wallet-status -- AgentAccount ETH + USDC
328
- agether unified-status -- ALL credit lines, both types
329
- agether score -- Bayesian score + 5-factor subscores
114
+ [Action completed]
115
+
116
+ 📝 Tx: https://basescan.org/tx/0x...
117
+ 💰 Balance changes:
118
+ EOA: 0.05 WETH → 0.047 WETH (-0.003 WETH)
119
+ AgentAccount: $0 USDC → $5.00 USDC (+$5.00)
120
+ 📊 Position:
121
+ Collateral: 0.003 WETH (~$5.93)
122
+ Debt: $5.00 USDC
123
+ LTV: 84% (max 80%)
330
124
  ```
331
125
 
332
- ### User wants to repay
126
+ If something **fails**, show the error clearly:
333
127
  ```
334
- ReputationCredit: agether repay --amount <usd>
335
- MorphoCredit: agether morpho-repay --amount <usd>
128
+ ❌ Borrow failed: ExceedsMaxLtv (83% > 80% max)
129
+ 💡 Fix: Deposit more collateral. Need at least $X × 1.25 = $Y in collateral value.
336
130
  ```
337
131
 
338
132
  ---
339
133
 
340
- ## 8. Backend API Endpoints
341
-
342
- All at http://95.179.189.214:3001:
343
-
344
- | Endpoint | Method | Purpose |
345
- |----------|--------|---------|
346
- | `/health` | GET | Health check |
347
- | `/status` | GET | Contract addresses, chainId, version |
348
- | `/agents/count` | GET | Total registered agents |
349
- | `/credit/score/<agentId>` | GET | Bayesian score + 5-factor subscores |
350
- | `/credit/evaluate` | POST | Evaluate credit application. Body: `{"agentId":"123","requestedLimit":"5000000000"}` |
351
- | `/morpho/balances/<address>` | GET | Token balances + credit capacity |
352
- | `/morpho/markets` | GET | Supported Morpho markets |
353
- | `/morpho/estimate/<amountUsd>` | GET | Collateral estimates with oracle prices |
354
- | `/morpho/compare` | POST | Compare credit options. Body: `{"agentId":"123","amount":"5000000000"}` |
355
- | `/morpho/unified/agent/<agentId>` | GET | All credit lines for agent |
356
- | `/kya/verify` | POST | Verify agent identity (KYA) |
357
- | `/x402/verify` | POST | Risk-check x402 payment |
358
- | `/x402/settle` | POST | Settle x402 payment |
359
- | `/risk/evaluate` | POST | Risk evaluation |
134
+ ## 🔢 KEY NUMBERS
360
135
 
361
- ---
362
-
363
- ## 9. Architecture
364
-
365
- ```
366
- EOA Wallet (your private key)
367
- |-- Owns ERC-8004 Identity NFT (agentId)
368
- +-- Owns AgentAccount (smart wallet)
369
- |-- Holds USDC (from draws or direct funding)
370
- |-- drawCredit(provider, amount) -- pull USDC from credit provider
371
- |-- repayCredit(provider, amount) -- push USDC back to credit provider
372
- |-- fund(token, amount) -- pull from EOA into account
373
- +-- payX402(...) -- pay for API call
374
-
375
- ReputationCredit (undercollat, 80%)
376
- |-- applyForCredit() --> Pending
377
- |-- approveCreditLine() --> Active (admin only)
378
- |-- draw() --> USDC from LP Vault to AgentAccount
379
- |-- repay() --> USDC from AgentAccount to LP Vault
380
- +-- declareDefault() --> slashes collateral (admin only)
381
-
382
- MorphoCredit (overcollat, 120%)
383
- |-- depositCollateral() --> into Morpho Blue
384
- |-- drawWithCollateral() --> USDC from Morpho Blue to AgentAccount
385
- |-- repayWithCollateral() --> USDC from AgentAccount to Morpho Blue
386
- +-- withdrawCollateral() --> collateral back to EOA
387
-
388
- LP Vault (ERC-4626)
389
- |-- LPs deposit USDC --> earn yield from interest
390
- +-- Funds ReputationCredit draws
391
- ```
136
+ | Parameter | Value |
137
+ |-----------|-------|
138
+ | Chain | Base mainnet (8453) |
139
+ | Currency | USDC (6 decimals) |
140
+ | Max LTV | 80% (= 125% collateral ratio) |
141
+ | Collateral tokens | WETH, wstETH, cbETH |
142
+ | x402 cost | ~$0.001 per API call (WeatherXM) |
143
+ | Gas cost | ~$0.001–$0.01 per tx |
392
144
 
393
145
  ---
394
146
 
395
- ## 10. Key Addresses (Base Mainnet)
147
+ ## ⚠️ COMMON ERRORS
396
148
 
397
- | Contract | Address |
398
- |----------|---------|
399
- | AccountFactory | 0xeB72f248Ad9F4bf4024e8D9da75cf7AAD37B58f5 |
400
- | LPVault | 0x612A80D6c3175F8283e9C7EE71d5177fE9acc338 |
401
- | ReputationCredit | 0x57B2B4ef3e7B8BE5FC86c6369602125d240F552A |
402
- | MorphoCredit | 0x7dFfa40E17471F7f26F5662D0F07a31977F47BeB |
403
- | ValidationRegistry | 0x8842f2383A86134Dd80c3Ecf6Bbae2e38396A5ec |
404
- | AgentReputation | 0xF1bed094D4E33E47CC8C72E086FFFde09e2211b4 |
405
- | USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
406
- | ERC-8004 Identity | 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432 |
407
- | WETH | 0x4200000000000000000000000000000000000006 |
408
- | wstETH | 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 |
409
- | cbETH | 0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22 |
410
- | Morpho Blue | 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb |
149
+ | Error | Meaning | What to do |
150
+ |-------|---------|-----------|
151
+ | `ExceedsMaxLtv` | Collateral too low for borrow amount | Deposit more collateral or borrow less. LTV must be ≤ 80% |
152
+ | `Payment rejected (402)` | No USDC for x402 payment | Borrow USDC first: `morpho_borrow` or `morpho_deposit_and_borrow` |
153
+ | `No collateral deposited` | Trying to borrow without collateral | `morpho_deposit` first |
154
+ | `Insufficient WETH/wstETH/cbETH` | EOA doesn't have enough collateral | Tell user to send collateral to EOA address |
155
+ | `Insufficient USDC in AgentAccount` | Not enough USDC for repay | Need to fund AgentAccount or borrow more |
156
+ | `ExecutionFailed` | Smart contract call reverted | Check inner error, usually LTV or approval issue |
411
157
 
412
158
  ---
413
159
 
414
- ## 11. Installation (For New Bot or Team Lead)
160
+ ## 🏗 ARCHITECTURE (for context)
415
161
 
416
- ### Prerequisites
417
- - Node.js >= 20
418
- - A wallet with ~$0.01 ETH on Base (gas) + USDC on Base (for x402 payments)
419
-
420
- ### Install CLI
421
- ```bash
422
- git clone <repo-url>
423
- cd agent-credit-protocol/sdk
424
- npm install
425
- npm run build
426
- npm link # Makes agether command available globally
427
162
  ```
163
+ EOA Wallet (private key)
164
+ ├── Owns ERC-8004 Identity NFT (agentId)
165
+ └── Owns AgentAccount (smart wallet)
166
+ ├── Holds USDC (from borrows)
167
+ └── Executes credit operations
428
168
 
429
- ### Quick Test
430
- ```bash
431
- # 1. Setup
432
- agether init <private-key>
433
- agether register --name "TestBot"
434
- agether balance
435
-
436
- # 2. Quick credit via Morpho (if you have WETH)
437
- agether morpho-compare --amount 5
438
- agether morpho-deposit --amount 0.003 --token WETH
439
- agether morpho-borrow --amount 5
440
- agether wallet-status
441
-
442
- # 3. Make a paid API call ($0.001)
443
- agether x402 "https://agent.weatherxm.com/api/forecast?lat=40.71&lon=-74.00"
444
-
445
- # 4. Repay and clean up
446
- agether morpho-repay --amount 5
447
- agether morpho-status
169
+ MorphoCredit (overcollateralized, 125%)
170
+ ├── depositCollateralFor() → collateral into Morpho Blue
171
+ ├── drawWithCollateral() → USDC from Morpho Blue → AgentAccount
172
+ ├── repayWithCollateral() → USDC from AgentAccount → Morpho Blue
173
+ └── withdrawCollateral() → collateral back to EOA
448
174
  ```
449
175
 
450
- ### OpenClaw Integration
451
- 1. Copy SKILL.md into OpenClaw's skill folder:
452
- ```bash
453
- mkdir -p ~/.openclaw/skills/agether
454
- cp SKILL.md ~/.openclaw/skills/agether/SKILL.md
455
- ```
176
+ ---
456
177
 
457
- 2. Add to `~/.openclaw/openclaw.json` under `skills.entries`:
458
- ```json
459
- {
460
- "agether": {
461
- "enabled": true,
462
- "env": {
463
- "AGETHER_PRIVATE_KEY": "<your-private-key>",
464
- "AGETHER_RPC_URL": "https://base-rpc.publicnode.com",
465
- "AGETHER_BACKEND_URL": "http://95.179.189.214:3001"
466
- }
467
- }
468
- }
469
- ```
178
+ ## 📍 CONTRACT ADDRESSES (Base Mainnet)
470
179
 
471
- OpenClaw reads the SKILL.md from `~/.openclaw/skills/agether/` and finds the `agether` binary on PATH (from `npm link`).
180
+ | Contract | Address |
181
+ |----------|---------|
182
+ | AccountFactory | `0xeB72f248Ad9F4bf4024e8D9da75cf7AAD37B58f5` |
183
+ | MorphoCredit | `0x7dFfa40E17471F7f26F5662D0F07a31977F47BeB` |
184
+ | ERC-8004 Identity | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` |
185
+ | USDC | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
186
+ | WETH | `0x4200000000000000000000000000000000000006` |
187
+ | wstETH | `0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452` |
188
+ | cbETH | `0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22` |