@arcadia-finance/mcp-server 0.5.2 → 0.6.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 +47 -42
- package/dist/clients/api.js +52 -5
- package/dist/clients/chain.js +1 -1
- package/dist/config/addresses.js +16 -3
- package/dist/index.js +36 -134
- package/dist/prompts/workflows.js +54 -18
- package/dist/resources/guides.js +1 -1
- package/dist/tools/aero.js +157 -0
- package/dist/tools/dev/send.js +4 -4
- package/dist/tools/index.js +6 -0
- package/dist/tools/output-schemas.js +103 -29
- package/dist/tools/read/account.js +13 -13
- package/dist/tools/read/aero-upgrade.js +53 -0
- package/dist/tools/read/asset-managers.js +9 -9
- package/dist/tools/read/assets.js +7 -7
- package/dist/tools/read/guides.js +4 -4
- package/dist/tools/read/points.js +4 -4
- package/dist/tools/read/pools.js +8 -8
- package/dist/tools/read/strategy.js +12 -12
- package/dist/tools/read/wallet.js +15 -15
- package/dist/tools/write/account/add-liquidity.js +9 -9
- package/dist/tools/write/account/aero-upgrade.js +124 -0
- package/dist/tools/write/account/borrow.js +5 -5
- package/dist/tools/write/account/close.js +8 -8
- package/dist/tools/write/account/create.js +3 -3
- package/dist/tools/write/account/deleverage.js +4 -4
- package/dist/tools/write/account/deposit.js +4 -4
- package/dist/tools/write/account/format-response.js +1 -1
- package/dist/tools/write/account/remove-liquidity.js +6 -6
- package/dist/tools/write/account/repay.js +4 -4
- package/dist/tools/write/account/stake.js +5 -5
- package/dist/tools/write/account/swap.js +4 -4
- package/dist/tools/write/account/withdraw.js +5 -5
- package/dist/tools/write/asset-managers/automations.js +14 -14
- package/dist/tools/write/asset-managers/intents.js +10 -7
- package/dist/tools/write/pool/deposit.js +5 -5
- package/dist/tools/write/pool/redeem.js +4 -4
- package/dist/tools/write/wallet/approve.js +4 -4
- package/dist/tools/write/wallet/upgrade-velo.js +76 -0
- package/dist/utils/analytics.js +68 -0
- package/dist/utils/http-config.js +4 -4
- package/llms-full.txt +83 -46
- package/llms.txt +47 -44
- package/package.json +8 -4
- package/server.json +4 -4
- package/skills/clamm-liquidity/SKILL.md +100 -82
- package/skills/clamm-liquidity/automation.md +14 -14
- package/skills/clamm-liquidity/selection.md +13 -13
- package/skills/clamm-liquidity/strategies.md +135 -53
- package/skills/openclaw/SKILL.md +3 -3
- package/skills/openclaw/arcadia.sh +24 -45
- package/skills/openclaw/contracts.md +11 -10
- package/dist/utils/tool-naming.js +0 -91
|
@@ -4,17 +4,17 @@ These are templates and examples — not the only valid approaches. Adapt parame
|
|
|
4
4
|
|
|
5
5
|
## Key Parameter Notes
|
|
6
6
|
|
|
7
|
-
- **`
|
|
7
|
+
- **`write_account_add_liquidity`** capital sources: `deposits` array (wallet tokens), `use_account_assets=true` (existing account collateral), or both. Supports depositing multiple tokens and minting multiple LP positions in one tx. The backend swaps everything to the optimal ratio for the LP. You do NOT need to `write_account_deposit` first: `write_account_add_liquidity` handles the wallet transfer atomically. Check allowances first (`read_wallet_allowances`), then approve if needed (`write_wallet_approve`).
|
|
8
8
|
- **V4 spot accounts CAN mint LP** but cannot leverage (set `leverage: 0`). V3 margin accounts (created with a `creditor`) can both mint LP and leverage. If the user wants leveraged LP, create a V3 margin account with a creditor (`account_version: 3`).
|
|
9
|
-
- **`numeraire`** in `
|
|
10
|
-
- **`leverage`**: `0` = no leverage. `2` = 2x. Do NOT use `1` for no leverage
|
|
11
|
-
- **LP NFT details**: after `
|
|
12
|
-
- **`amount: "max_uint256"`** in `
|
|
9
|
+
- **`numeraire`** in `write_account_deleverage`: the debt token you're repaying (e.g. WETH when repaying WETH debt). `write_account_add_liquidity` auto-detects numeraire: no param needed.
|
|
10
|
+
- **`leverage`**: `0` = no leverage. `2` = 2x. Do NOT use `1` for no leverage: use `0`. When `leverage > 0`, borrowing is handled internally by `write_account_add_liquidity`: do NOT call `write_account_borrow` separately.
|
|
11
|
+
- **LP NFT details**: after `write_account_add_liquidity`, call `read_account_info` to find `asset_address` (the position manager contract) and `asset_id` (NFT token ID) in the positions list: needed for unstake/remove/claim actions.
|
|
12
|
+
- **`amount: "max_uint256"`** in `write_account_repay` repays all debt in full.
|
|
13
13
|
- **`slippage`** is in basis points: 100 = 1%, 50 = 0.5%.
|
|
14
|
-
- **`salt`** in `
|
|
15
|
-
- **`creditor`** = the lending pool address you want to borrow from. Set at account creation via `
|
|
16
|
-
- **`
|
|
17
|
-
- **Getting the account address after creation:** The address is deterministic from the salt. It's visible in the tx receipt events. Or call `
|
|
14
|
+
- **`salt`** in `write_account_create` is a random uint32 used for deterministic address derivation. Use any random 32-bit integer (e.g. `Math.floor(Math.random() * 2**32)`).
|
|
15
|
+
- **`creditor`** = the lending pool address you want to borrow from. Set at account creation via `write_account_create`. Determines which asset the account can borrow. **Required for leveraged LP strategies.** Omit for spot-only accounts (no borrowing, but LP minting still works with `leverage: 0`).
|
|
16
|
+
- **`write_account_withdraw`**: pass exact amounts from `read_account_info`. Does NOT support `"max_uint256"`: will error.
|
|
17
|
+
- **Getting the account address after creation:** The address is deterministic from the salt. It's visible in the tx receipt events. Or call `read_account_info(wallet_address: ...)` after creation to list all accounts.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -22,14 +22,14 @@ These are templates and examples — not the only valid approaches. Adapt parame
|
|
|
22
22
|
|
|
23
23
|
```
|
|
24
24
|
Open: check allowances → approve tokens if needed → create account → add liquidity (atomic: deposit + swap + mint + borrow) → enable automation
|
|
25
|
-
Monitor:
|
|
25
|
+
Monitor: read_account_info (health), read_account_pnl (profitability)
|
|
26
26
|
Adjust: add collateral or repay debt if health drops; remove + re-add liquidity to manually rebalance range
|
|
27
27
|
Close: disable rebalancer → unstake → atomic close (burn LP + swap + repay) → withdraw
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### Batching vs splitting
|
|
31
31
|
|
|
32
|
-
**Default: always use atomic tools.** `
|
|
32
|
+
**Default: always use atomic tools.** `write_account_add_liquidity` batches opening, `write_account_close` batches closing, `write_account_deleverage` batches debt repayment from collateral. These reduce transaction count and eliminate exposure to price movement between steps.
|
|
33
33
|
|
|
34
34
|
**When to split:** In high-volatility markets or for low-liquidity pools, atomic transactions may revert because on-chain state diverges from when the backend computed the calldata. If an atomic tool fails, fall back to individual tools with tighter slippage. Always try atomic first — split only on failure.
|
|
35
35
|
|
|
@@ -52,38 +52,38 @@ Close: disable rebalancer → unstake → atomic close (burn LP + swap + repay
|
|
|
52
52
|
|
|
53
53
|
### Step-by-step
|
|
54
54
|
|
|
55
|
-
> Addresses below are Base mainnet examples. Always verify current addresses via `
|
|
55
|
+
> Addresses below are Base mainnet examples. Always verify current addresses via `read_pool_list` and `read_asset_list` before executing.
|
|
56
56
|
|
|
57
57
|
```
|
|
58
58
|
// 1. FIND A POOL
|
|
59
|
-
|
|
59
|
+
read_strategy_list(chain_id: 8453)
|
|
60
60
|
→ Filter for volatile/stable pair (WETH/USDC, cbBTC/USDC, etc.)
|
|
61
61
|
→ Note: strategy_id (integer), pool_protocol (Slipstream V1/V2, UniV3, UniV4), fee_APY
|
|
62
62
|
|
|
63
63
|
// 2. CHECK BORROW COST
|
|
64
|
-
|
|
64
|
+
read_pool_list(chain_id: 8453)
|
|
65
65
|
→ Find the WETH lending pool (address: 0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2)
|
|
66
66
|
→ If borrow_apy > fee_apy → stop, strategy not profitable
|
|
67
67
|
|
|
68
68
|
// 3. CREATE MARGIN ACCOUNT (V3 + creditor = can borrow/leverage)
|
|
69
|
-
|
|
69
|
+
write_account_create(
|
|
70
70
|
salt: <random uint32, e.g. 3141592653>,
|
|
71
71
|
account_version: 3, // V3 margin — required for leverage
|
|
72
72
|
creditor: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH lending pool — enables borrow
|
|
73
73
|
chain_id: 8453
|
|
74
74
|
)
|
|
75
75
|
→ Submit tx, note deployed account address from tx receipt
|
|
76
|
-
→ Or call
|
|
76
|
+
→ Or call read_account_info(wallet_address: ...) to find the new account address
|
|
77
77
|
|
|
78
78
|
// 4. CHECK ALLOWANCE + APPROVE (skip approve if already sufficient)
|
|
79
|
-
|
|
79
|
+
read_wallet_allowances(
|
|
80
80
|
owner_address: <owner_wallet>,
|
|
81
81
|
spender_address: <account_address>,
|
|
82
82
|
token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], // USDC
|
|
83
83
|
chain_id: 8453
|
|
84
84
|
)
|
|
85
85
|
// → If allowance is insufficient or zero:
|
|
86
|
-
|
|
86
|
+
write_wallet_approve(
|
|
87
87
|
token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
|
|
88
88
|
spender_address: <account_address>,
|
|
89
89
|
amount: "max_uint256",
|
|
@@ -91,8 +91,8 @@ write.wallet.approve(
|
|
|
91
91
|
)
|
|
92
92
|
|
|
93
93
|
// 5. OPEN LEVERAGED LP (atomic: pull USDC from wallet + borrow WETH + swap to ratio + mint LP)
|
|
94
|
-
// No separate
|
|
95
|
-
|
|
94
|
+
// No separate write_account_deposit needed: write_account_add_liquidity handles the wallet transfer atomically.
|
|
95
|
+
write_account_add_liquidity(
|
|
96
96
|
account_address: <account_address>,
|
|
97
97
|
wallet_address: <owner_wallet>,
|
|
98
98
|
positions: [{ strategy_id: <integer from step 1> }],
|
|
@@ -105,7 +105,7 @@ write.account.add_liquidity(
|
|
|
105
105
|
// 6. ENABLE AUTOMATIONS — one call, one transaction
|
|
106
106
|
// Include every automation you want active: the intents array is the full desired state.
|
|
107
107
|
// Add claim_merkl only if the pool has Merkl incentives (check fee APY breakdown in step 1).
|
|
108
|
-
|
|
108
|
+
write_account_automations(
|
|
109
109
|
account_address: <account>,
|
|
110
110
|
position_id: <lp_nft_id>, // backend resolves protocol + tokens from this
|
|
111
111
|
intents: [
|
|
@@ -122,7 +122,7 @@ write.account.automations(
|
|
|
122
122
|
|
|
123
123
|
```
|
|
124
124
|
// Run periodically (daily or on request)
|
|
125
|
-
|
|
125
|
+
read_account_info(account_address: <account_address>, chain_id: 8453)
|
|
126
126
|
→ health_factor = 1 - (used_margin / liquidation_value). Higher = safer.
|
|
127
127
|
1 → no debt (safest)
|
|
128
128
|
> 0.5 → healthy
|
|
@@ -137,10 +137,10 @@ typically a few dollars in value) to the debt when computing used_margin
|
|
|
137
137
|
dominates, pushing HF lower than the leverage ratio suggests — e.g. HF ~0.3 at 2×
|
|
138
138
|
instead of ~0.5–0.7. Increase position size for a healthier starting HF.
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
read_account_pnl(account_address: <account_address>, chain_id: 8453)
|
|
141
141
|
→ If net yield is consistently negative → evaluate exit
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
read_pool_list(chain_id: 8453)
|
|
144
144
|
→ If borrow_APY risen above fee_APY → exit signal
|
|
145
145
|
```
|
|
146
146
|
|
|
@@ -149,15 +149,15 @@ read.pool.list(chain_id: 8453)
|
|
|
149
149
|
```
|
|
150
150
|
// Option A: Add collateral (raises health factor, cheapest)
|
|
151
151
|
// Check allowance first — skip approve if already sufficient
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
read_wallet_allowances(owner_address: <wallet>, spender_address: <account>, token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], chain_id: 8453)
|
|
153
|
+
write_wallet_approve(token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", spender_address: <account>, amount: "max_uint256", chain_id: 8453)
|
|
154
|
+
write_account_deposit(account_address: <account>, asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], asset_amounts: ["<amount>"], chain_id: 8453)
|
|
155
155
|
|
|
156
156
|
// Option B: Repay some WETH debt (reduces leverage)
|
|
157
157
|
// NOTE: you must approve the WETH pool to spend WETH from your wallet first — check allowance, then approve if needed
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
read_wallet_allowances(owner_address: <wallet>, spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", token_addresses: ["0x4200000000000000000000000000000000000006"], chain_id: 8453)
|
|
159
|
+
write_wallet_approve(token_address: "0x4200000000000000000000000000000000000006", spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", amount: "max_uint256", chain_id: 8453)
|
|
160
|
+
write_account_repay(
|
|
161
161
|
pool_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH pool
|
|
162
162
|
account_address: <account>,
|
|
163
163
|
amount: "<raw_weth_amount_in_wei>", // e.g. "100000000000000000" = 0.1 WETH
|
|
@@ -165,7 +165,7 @@ write.account.repay(
|
|
|
165
165
|
)
|
|
166
166
|
|
|
167
167
|
// Option C: Atomic sell USDC collateral → repay WETH debt (one flash tx, no wallet WETH needed)
|
|
168
|
-
|
|
168
|
+
write_account_deleverage(
|
|
169
169
|
account_address: <account>,
|
|
170
170
|
asset_from: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // sell USDC from account
|
|
171
171
|
amount_in: "<usdc_amount_to_sell>", // collateral amount to sell (input side, NOT debt amount)
|
|
@@ -184,22 +184,22 @@ write.account.deleverage(
|
|
|
184
184
|
|
|
185
185
|
```
|
|
186
186
|
// 0. Disable automation first (prevents the rebalancer from acting during close)
|
|
187
|
-
|
|
187
|
+
read_asset_manager_current(account_address: <account>, chain_id: 8453)
|
|
188
188
|
// → take the rebalancer's address from `enabled`, then:
|
|
189
|
-
|
|
189
|
+
write_account_automations_delta(
|
|
190
190
|
account_address: <account>,
|
|
191
191
|
disable: [<rebalancer_address>],
|
|
192
192
|
chain_id: 8453
|
|
193
193
|
)
|
|
194
194
|
|
|
195
195
|
// 1. Get account state — need asset list for the close call
|
|
196
|
-
|
|
196
|
+
read_account_info(account_address: <account>, chain_id: 8453)
|
|
197
197
|
|
|
198
198
|
// 2. Unstake if staked (required before close)
|
|
199
|
-
|
|
199
|
+
write_account_stake(action: "unstake", asset_address: <staked_pm_address>, asset_id: <nft_id>, account_address: <account>, chain_id: 8453)
|
|
200
200
|
|
|
201
201
|
// 3. Atomic close: burns LP + swaps all tokens to USDC + repays debt — ONE transaction
|
|
202
|
-
|
|
202
|
+
write_account_close(
|
|
203
203
|
account_address: <account>,
|
|
204
204
|
assets: [
|
|
205
205
|
{ asset_address: "<position_manager>", asset_id: <nft_id>, amount: "1", decimals: 1 }
|
|
@@ -210,7 +210,7 @@ write.account.close(
|
|
|
210
210
|
)
|
|
211
211
|
|
|
212
212
|
// 4. Withdraw remaining assets to wallet
|
|
213
|
-
|
|
213
|
+
write_account_withdraw(
|
|
214
214
|
account_address: <account>,
|
|
215
215
|
asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],
|
|
216
216
|
asset_amounts: ["<balance>"],
|
|
@@ -222,19 +222,19 @@ write.account.withdraw(
|
|
|
222
222
|
|
|
223
223
|
If the full atomic close fails, split into two steps:
|
|
224
224
|
|
|
225
|
-
1. `
|
|
226
|
-
2. Then use individual tools: `
|
|
225
|
+
1. `write_account_close(close_lp_only=true)`: burns LP only, tokens stay in account
|
|
226
|
+
2. Then use individual tools: `write_account_deleverage` → `write_account_withdraw`
|
|
227
227
|
|
|
228
228
|
#### Last resort: Manual step-by-step
|
|
229
229
|
|
|
230
230
|
Only if both atomic approaches fail:
|
|
231
231
|
|
|
232
232
|
```
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
write_account_stake(action: "claim", ...) // claim fees
|
|
234
|
+
write_account_remove_liquidity(adjustment: <amount>) // partial decrease
|
|
235
|
+
write_account_deleverage(...) // swap collateral → repay debt
|
|
236
|
+
write_account_repay(amount: "max_uint256") // repay remaining from wallet
|
|
237
|
+
write_account_withdraw(...) // withdraw all to wallet
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
**Key risks:**
|
|
@@ -277,23 +277,23 @@ The `protocol_owned_liquidity` strategy type uses a dynamic range algorithm (k1/
|
|
|
277
277
|
// Same tools, different intent — no leverage, wider slippage tolerance
|
|
278
278
|
|
|
279
279
|
// 1. Check allowance + approve treasury tokens (skip approve if already sufficient)
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
read_wallet_allowances(owner_address: <treasury_wallet>, spender_address: <account>, token_addresses: [<token>], chain_id: 8453)
|
|
281
|
+
write_wallet_approve(token_address: <token>, spender_address: <account>, amount: "max_uint256", chain_id: 8453)
|
|
282
282
|
|
|
283
283
|
// 2. Create account (separate from retail positions)
|
|
284
284
|
// For POL without leverage, a spot account (V4) works fine.
|
|
285
285
|
// Use V3 + creditor only if you want the option to leverage later.
|
|
286
|
-
|
|
286
|
+
write_account_create(
|
|
287
287
|
salt: <random uint32>,
|
|
288
288
|
account_version: 0, // V4 spot — no leverage needed for POL
|
|
289
289
|
chain_id: 8453
|
|
290
290
|
)
|
|
291
291
|
|
|
292
292
|
// 3. Deposit treasury tokens
|
|
293
|
-
|
|
293
|
+
write_account_deposit(account_address: <account>, ...)
|
|
294
294
|
|
|
295
295
|
// 4. Open LP (no leverage — deposits are pulled from wallet)
|
|
296
|
-
|
|
296
|
+
write_account_add_liquidity(
|
|
297
297
|
account_address: <account>,
|
|
298
298
|
wallet_address: <treasury_wallet>,
|
|
299
299
|
positions: [{ strategy_id: <from step 1> }],
|
|
@@ -306,7 +306,7 @@ write.account.add_liquidity(
|
|
|
306
306
|
// 5. Enable the rebalancer on the POL strategy
|
|
307
307
|
// The backend routes POL to the unified rebalancer and its POL strategy hook;
|
|
308
308
|
// tuning params are part of the intent, all optional with the defaults shown.
|
|
309
|
-
|
|
309
|
+
write_account_automations(
|
|
310
310
|
account_address: <account>,
|
|
311
311
|
position_id: <lp_nft_id>,
|
|
312
312
|
intents: [{
|
|
@@ -333,11 +333,93 @@ POL runs on the unified V2.1.1 rebalancer, which is the only deployment that spe
|
|
|
333
333
|
### Monitoring for POL
|
|
334
334
|
|
|
335
335
|
```
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
read_account_info → verify position is in range (primary check: no liquidation risk since no leverage)
|
|
337
|
+
read_account_pnl → track IL vs. fee income
|
|
338
338
|
Note: net negative IL is EXPECTED and ACCEPTABLE for POL
|
|
339
339
|
The treasury is "paying" for market liquidity
|
|
340
|
-
|
|
340
|
+
read_strategy_recommendation → check if rebalancing is needed
|
|
341
341
|
```
|
|
342
342
|
|
|
343
343
|
**POL monitoring goal:** Ensure sufficient liquidity is deployed and treasury capital is not eroding excessively — not maximizing return.
|
|
344
|
+
|
|
345
|
+
## Upgrade to Aero (MetadexCL V1)
|
|
346
|
+
|
|
347
|
+
Aero CL succeeds the Slipstream pools (Aerodrome on Base, Velodrome on Optimism) at the Aero launch, and the new AERO token succeeds the old one on Base. `write_account_aero_upgrade` upgrades one account in one flashAction signed by the owner: every Slipstream V1, V2 and V3 position, staked or not, moves into the Aero CL pool with the same pair and variant at the same range and tick spacing (when Aero has no pool at that tick spacing, the user picks another one), and every unit of old AERO (loose in the account, unclaimed rewards, an old-AERO pair) becomes the new AERO. Chains: Base and Optimism. Robinhood has nothing to upgrade.
|
|
348
|
+
|
|
349
|
+
The backend decides what can move. Report its statuses and reasons as given; never decide eligibility yourself.
|
|
350
|
+
|
|
351
|
+
### Step-by-step
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
// 1. The cheap check: status and counts per account, no calldata. Empty accounts and failed_accounts: nothing to do.
|
|
355
|
+
read_account_aero_upgrade(wallet_address: <wallet>, chain_id: 8453)
|
|
356
|
+
|
|
357
|
+
// 2. If automations are enabled, keep their intents and config: the old managers are replaced after the move
|
|
358
|
+
read_asset_manager_current(account_address: <account>, chain_id: 8453)
|
|
359
|
+
|
|
360
|
+
// 3. The plan and, when anything can go now, the one transaction
|
|
361
|
+
write_account_aero_upgrade(account_address: <account>, chain_id: 8453)
|
|
362
|
+
|
|
363
|
+
// 4. Sign and broadcast as the account owner
|
|
364
|
+
|
|
365
|
+
// 5. Reconnect automations when managers_to_reconnect is not empty (new position id from read_account_info)
|
|
366
|
+
write_account_automations(account_address: <account>, position_id: <new_aero_id>, intents: [<from step 2>], mode: "save", chain_id: 8453)
|
|
367
|
+
|
|
368
|
+
// 6. Verify: dex_protocol metadexcl_v1 or staked_metadexcl_v1, old AERO shown as the new AERO, automation lists the reconnected managers
|
|
369
|
+
read_account_info(account_address: <account>, chain_id: 8453)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Plan statuses
|
|
373
|
+
|
|
374
|
+
| `status` | Meaning and next step |
|
|
375
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
376
|
+
| `ready` | Sign `transaction` (`gas` is the backend's estimate). Items whose status is `waiting` or `blocked` stay where they are; their `reason` says why. |
|
|
377
|
+
| `choices_required` | A position has status `choose`: Aero has no pool at its tick spacing, and another tick spacing can take it. Ask the user to pick one of its `options` whose `disabled_reason` is null (`tick_spacing`, `fee`, `apy`, `tvl_usd`, `is_new`, `range_widened`) and call again with `choices`, so one transaction moves everything. When ready items exist the plan already carries a `transaction` that moves only those: sign it alone only when the user wants to leave the `choose` position where it is. |
|
|
378
|
+
| `waiting` | Nothing moves on its own. Each item's `reason` says why (see below). A waiting item with an option whose `disabled_reason` is null can still move with that option in `choices`; ask the user. Otherwise do not retry in a loop. |
|
|
379
|
+
| `not_open` | The AERO token upgrade contract does not accept deposits at the moment (it opens at `opens_at`). An upgrade that converts old AERO cannot be built until it does. |
|
|
380
|
+
| `nothing_to_upgrade` | Nothing can move: no Slipstream position and no old AERO on the account, or every item is `blocked`. If `managers_to_reconnect` still lists active managers, the positions already moved but the automations were never reconnected: reconnect them (below). |
|
|
381
|
+
|
|
382
|
+
### Item reasons
|
|
383
|
+
|
|
384
|
+
| `reason.code` | Status | Meaning |
|
|
385
|
+
| --------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
386
|
+
| `pool_not_on_aero` | waiting | Aero has no pool with an Arcadia strategy on this pair yet. |
|
|
387
|
+
| `staking_not_open` | waiting | The Aero pool's gauge is not live on Arcadia yet. The position stays staked where it is. |
|
|
388
|
+
| `no_reward_feed` | waiting | The chain has no price feed for the staked Aero reward token yet. The position stays staked where it is. |
|
|
389
|
+
| `target_price_mismatch` | waiting | The Aero pool's price is too far from the market price to move safely now. |
|
|
390
|
+
| `range_price_mismatch` | waiting | The Aero pool's price and the old pool's price sit on different sides of the range edge, so the position's tokens cannot open the same range yet. |
|
|
391
|
+
| `widened_range_holds_price` | waiting | Only other tick spacings exist, and the widened range there holds the price, which the one-sided position cannot fill. It can move once the price leaves that range. |
|
|
392
|
+
| `old_aero_at_range_edge` | waiting | The old pool's price is near the range edge where the position holds no old AERO, so the upgrade cannot count on converting it. It can move once the price moves away, or with loose old AERO in the account. |
|
|
393
|
+
| `migration_paused` | waiting | Aero has paused the AERO token upgrade. |
|
|
394
|
+
| `budget_exhausted` | waiting | The AERO token upgrade has too little new AERO left for this account now. |
|
|
395
|
+
| `new_aero_cap_reached` | waiting | The account's lending pool is at its limit for the new AERO, so old AERO in this margin account waits until the limit is raised. |
|
|
396
|
+
| `account_unhealthy` | waiting | The account's collateral is below what its debt requires, so the upgrade would revert. Add collateral or repay debt first. |
|
|
397
|
+
| `exposure_limit` | waiting | A lending pool limit for one of the account's assets is reached, so the upgrade would revert. It can go once the limit is raised. |
|
|
398
|
+
| `empty_position` | blocked | The position holds no liquidity. Close it from the position page. |
|
|
399
|
+
| `dust_position` | blocked | The position is too small to re-create on Aero. Close it from the position page. |
|
|
400
|
+
| `range_not_alignable` | blocked | The range fits no Aero tick spacing. Close the position and open a new one on Aero. |
|
|
401
|
+
| `no_target_pair` | blocked | The position pairs old AERO with the new AERO, so there is no Aero pair to move it to. Close it from the position page. |
|
|
402
|
+
|
|
403
|
+
An option's `disabled_reason` uses `staking_not_open`, `no_reward_feed`, `range_price_mismatch`, `price_mismatch` (its pool is too far from the market price) or `range_mismatch` (its tick spacing cannot hold the range).
|
|
404
|
+
|
|
405
|
+
When the transaction's simulation reverts, the tool returns the plan with an `error` and no transaction. Rebuild once and report if it fails again. `tenderly_sim_status: unavailable` means Tenderly did not answer and the transaction is unsimulated: call once more before signing. A 422 saying a pool is not selectable: drop that pick and ask again. After a transaction confirms, pass its block as `min_block` on the next call.
|
|
406
|
+
|
|
407
|
+
A moved position's `old_aero_leg.converted: false` means this upgrade returns that leg to the account as old AERO, which a later upgrade converts. `rewards.becomes: null` means the rewards keep their token (VELO stays usable on Optimism). A plan without a transaction can still show `tenderly_sim_status: failure`: the account's health or a lending pool limit refused the move, and its items wait on `account_unhealthy` or `exposure_limit`. Report those reasons and do not rebuild.
|
|
408
|
+
|
|
409
|
+
`slippage` (bps, 1 to 1000) bounds the price the mint accepts. Omit it: the backend uses 150, or 500 when the owner is a contract such as a Safe.
|
|
410
|
+
|
|
411
|
+
### Several accounts
|
|
412
|
+
|
|
413
|
+
Pass `accounts` (up to 10 of one owner) instead of `account_address` for one plan and transaction per account in `results[]`. `multisends` groups the accounts that got a transaction, in order, so that each group's `gas` adds up to at most `max_gas_per_tx`: a Safe signs one MultiSend per group with those accounts' transactions. The accounts share one AERO upgrade budget, so plan them together. A result with `status: error` keeps its slot.
|
|
414
|
+
|
|
415
|
+
### Reconnecting automations
|
|
416
|
+
|
|
417
|
+
The move mints a new position, so automations on the old Slipstream position stop applying. `managers_to_reconnect` lists the old managers (`kind`, `old_address`) and their Aero replacements (`new_address`). Call `write_account_automations` in `save` mode with the new `position_id` and the intents the account had. Omit `protocol` so the backend resolves `metadexcl_v1` from the position: a stale `slipstream_*` value would compile Slipstream managers. The save disables the old managers in the same transaction. When `old_managers_still_needed` is true a Slipstream position stays on the account (it waits for its Aero pool), so keep the old managers: enable the Aero position with `write_account_automations_delta` instead. Settings are recompiled from intents, not copied: restate custom rebalancer settings from `read_asset_manager_current`. Each Aero manager holds one config per account, so when several old Slipstream managers of one kind had different settings, ask the user which to keep. When an item has `target.tokens_flipped: true` the pair sorts the other way on Aero: swap `token0` and `token1` in the intents' token fields (`tokens`, `convert_tokens`, `profit_token`) use 1e6 minus the token0 ratios and swap `trigger_lower_tick_ratio` with `trigger_upper_tick_ratio`, or leave that automation off and tell the user. The reconnect is a separate transaction: until it confirms, the Aero positions run without automations, so a Safe should queue it right after the upgrade. On Optimism and Robinhood there is no CoW Swapper, so compounding a staked Aero position's xAERO reward is rejected there; `claim_rewards` works.
|
|
418
|
+
|
|
419
|
+
### Margin vs spot
|
|
420
|
+
|
|
421
|
+
Spot and margin accounts hold Aero positions, staked or not, on Base, Optimism and Robinhood, within each lending pool's limits. A staked position whose Aero pool has no gauge on Arcadia yet waits with `staking_not_open`, or with `no_reward_feed` where the reward token has no price feed; it is never unstaked.
|
|
422
|
+
|
|
423
|
+
### VELO in the wallet
|
|
424
|
+
|
|
425
|
+
Separate from the account upgrade: `write_wallet_upgrade_velo` with `owner_address` (Optimism only) upgrades VELO in the wallet to 0.044 new AERO per VELO, paid to the same address on Base after the Hyperlane message lands. It returns ordered `transactions` (an approve when needed, then the payable deposit). VELO inside an account must be withdrawn first with `write_account_withdraw`. VELO stays usable, so this is optional. Errors name the reason: `not_open` (with the opening time), `paused`, `budget_exhausted`, `recipient_not_deployed` (a contract wallet that does not exist on Base).
|
package/skills/openclaw/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: arcadia-finance
|
|
3
|
-
version: 1.
|
|
4
|
-
description: "DeFi liquidity management on Uniswap and
|
|
3
|
+
version: 1.4.0
|
|
4
|
+
description: "DeFi liquidity management on Uniswap and Aero, live on Base, Optimism, Unichain and Robinhood. Deploy concentrated liquidity positions with automated rebalancing, compounding, yield optimization, and leverage, or provide single-sided liquidity to lending pools."
|
|
5
5
|
metadata:
|
|
6
6
|
openclaw:
|
|
7
7
|
homepage: https://arcadia.finance
|
|
@@ -13,7 +13,7 @@ metadata:
|
|
|
13
13
|
|
|
14
14
|
> **Agent note:** `{baseDir}` refers to the directory containing this SKILL.md file. Resolve all `{baseDir}` paths relative to it.
|
|
15
15
|
|
|
16
|
-
Arcadia helps users deploy concentrated liquidity positions on Uniswap,
|
|
16
|
+
Arcadia helps users deploy concentrated liquidity positions on Uniswap, Aero, Aerodrome and Velodrome with automated rebalancing, compounding, yield optimization, and optional leverage, or provide single-sided liquidity to lending pools to earn borrower interest. Supported chains: Base (8453), Unichain (130), Optimism (10), Robinhood (4663).
|
|
17
17
|
|
|
18
18
|
## CLI Usage
|
|
19
19
|
|
|
@@ -28,60 +28,42 @@ if [[ -z "$TOOL_NAME" ]]; then
|
|
|
28
28
|
exit 1
|
|
29
29
|
fi
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
# Request metadata MCP 2026-07-28 requires on every call.
|
|
32
|
+
META='{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{},"io.modelcontextprotocol/clientInfo":{"name":"arcadia-openclaw","version":"1.4.0"}}'
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
# POST one request; the body is plain JSON or a single SSE data: line.
|
|
35
|
+
mcp_post() {
|
|
36
|
+
local method="$1" name="$2" payload="$3" body json message
|
|
37
|
+
body=$(curl -sf -X POST "$MCP_URL" \
|
|
38
|
+
-H "Content-Type: application/json" \
|
|
39
|
+
-H "Accept: application/json, text/event-stream" \
|
|
40
|
+
-H "Mcp-Protocol-Version: 2026-07-28" \
|
|
41
|
+
-H "Mcp-Method: $method" \
|
|
42
|
+
${name:+-H "Mcp-Name: $name"} \
|
|
43
|
+
-d "$payload") || { echo "ERROR: request to $MCP_URL failed" >&2; return 1; }
|
|
44
|
+
json=$(printf '%s\n' "$body" | sed -n 's/^data: //p; /^{/p' | head -1)
|
|
45
|
+
message=$(jq -r '.error.message // empty' <<<"$json")
|
|
46
|
+
if [[ -n "$message" ]]; then
|
|
47
|
+
echo "ERROR: $message" >&2
|
|
48
|
+
return 1
|
|
49
|
+
fi
|
|
50
|
+
printf '%s\n' "$json"
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
# Initialize session
|
|
40
|
-
INIT_RESPONSE=$(curl -s -X POST "$MCP_URL" \
|
|
41
|
-
-H "Content-Type: application/json" \
|
|
42
|
-
-H "Accept: application/json, text/event-stream" \
|
|
43
|
-
-D "$HEADERS_FILE" \
|
|
44
|
-
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"arcadia-openclaw","version":"1.0.0"}}}' 2>/dev/null) || true
|
|
45
|
-
|
|
46
|
-
SESSION_ID=$(grep -i 'mcp-session-id' "$HEADERS_FILE" 2>/dev/null | awk '{print $2}' | tr -d '\r') || true
|
|
47
|
-
|
|
48
|
-
if [[ -z "$SESSION_ID" ]]; then
|
|
49
|
-
echo "Failed to connect to $MCP_URL" >&2
|
|
50
|
-
exit 1
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
# Send initialized notification
|
|
54
|
-
curl -sf -X POST "$MCP_URL" \
|
|
55
|
-
-H "Content-Type: application/json" \
|
|
56
|
-
-H "Accept: application/json, text/event-stream" \
|
|
57
|
-
-H "Mcp-Session-Id: $SESSION_ID" \
|
|
58
|
-
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
|
|
59
|
-
-o /dev/null 2>/dev/null || true
|
|
60
|
-
|
|
61
53
|
if [[ "$TOOL_NAME" == "--list" ]]; then
|
|
62
|
-
|
|
63
|
-
-H "Content-Type: application/json" \
|
|
64
|
-
-H "Accept: application/json, text/event-stream" \
|
|
65
|
-
-H "Mcp-Session-Id: $SESSION_ID" \
|
|
66
|
-
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}')
|
|
54
|
+
PAYLOAD=$(jq -nc --argjson meta "$META" '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{"_meta":$meta}}')
|
|
67
55
|
|
|
68
|
-
|
|
56
|
+
mcp_post "tools/list" "" "$PAYLOAD" | jq -r '.result.tools | sort_by(.name)[] | "\(.name): \(.description[0:120])"'
|
|
69
57
|
else
|
|
70
58
|
if ! echo "$ARGS_JSON" | jq . >/dev/null 2>&1; then
|
|
71
59
|
echo "ERROR: Invalid JSON arguments: $ARGS_JSON" >&2
|
|
72
60
|
exit 1
|
|
73
61
|
fi
|
|
74
62
|
|
|
75
|
-
PAYLOAD=$(jq -nc --arg name "$TOOL_NAME" --argjson args "$ARGS_JSON" \
|
|
76
|
-
'{"jsonrpc":"2.0","id":
|
|
63
|
+
PAYLOAD=$(jq -nc --arg name "$TOOL_NAME" --argjson args "$ARGS_JSON" --argjson meta "$META" \
|
|
64
|
+
'{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":$name,"arguments":$args,"_meta":$meta}}')
|
|
77
65
|
|
|
78
|
-
|
|
79
|
-
-H "Content-Type: application/json" \
|
|
80
|
-
-H "Accept: application/json, text/event-stream" \
|
|
81
|
-
-H "Mcp-Session-Id: $SESSION_ID" \
|
|
82
|
-
-d "$PAYLOAD")
|
|
83
|
-
|
|
84
|
-
RESULT=$(echo "$RESPONSE" | parse_sse)
|
|
66
|
+
RESULT=$(mcp_post "tools/call" "$TOOL_NAME" "$PAYLOAD")
|
|
85
67
|
IS_ERROR=$(echo "$RESULT" | jq -r '.result.isError // false')
|
|
86
68
|
TEXT=$(echo "$RESULT" | jq -r '.result.content[0].text // empty')
|
|
87
69
|
|
|
@@ -96,6 +78,3 @@ else
|
|
|
96
78
|
echo "$TEXT"
|
|
97
79
|
fi
|
|
98
80
|
fi
|
|
99
|
-
|
|
100
|
-
# Cleanup session
|
|
101
|
-
curl -sf -X DELETE "$MCP_URL" -H "Mcp-Session-Id: $SESSION_ID" -o /dev/null 2>/dev/null || true
|
|
@@ -25,23 +25,24 @@ Rebalancers, compounders, and yield claimers are deployed per DEX protocol. Most
|
|
|
25
25
|
|
|
26
26
|
Protocol availability per chain:
|
|
27
27
|
|
|
28
|
-
- **Base**: Slipstream V1, V2, V3, Uniswap V3, V4, CoW Swap
|
|
29
|
-
- **Optimism**: Slipstream V1, V3, Uniswap V3, V4 (no V2, no CoW Swap). V3 uses different AM addresses than Base (exception to the deterministic deployment pattern).
|
|
28
|
+
- **Base**: Slipstream V1, V2, V3, Uniswap V3, V4, Aero CL (MetadexCL V1), CoW Swap.
|
|
29
|
+
- **Optimism**: Slipstream V1, V3, Uniswap V3, V4, Aero CL (MetadexCL V1) (no V2, no CoW Swap). V3 uses different AM addresses than Base (exception to the deterministic deployment pattern).
|
|
30
30
|
- **Unichain**: Slipstream V1, Uniswap V3, V4 (no V2/V3, no CoW Swap)
|
|
31
|
-
- **Robinhood**: Uniswap V3, V4
|
|
31
|
+
- **Robinhood**: Uniswap V3, V4 and Aero CL (no Slipstream V1-V3, no Aerodrome V1, no CoW Swap). Lending pools are WETH and USDG, there is no USDC on this chain.
|
|
32
32
|
|
|
33
|
-
Use `
|
|
33
|
+
Use `read_asset_manager_intents` to discover available automations and their addresses per chain.
|
|
34
34
|
|
|
35
35
|
## Chain-Specific Tokens
|
|
36
36
|
|
|
37
37
|
### Base (8453)
|
|
38
38
|
|
|
39
|
-
| Token
|
|
40
|
-
|
|
|
41
|
-
| WETH
|
|
42
|
-
| USDC
|
|
43
|
-
| cbBTC
|
|
44
|
-
| AERO
|
|
39
|
+
| Token | Address | Decimals |
|
|
40
|
+
| ------------- | ------------------------------------------ | -------- |
|
|
41
|
+
| WETH | 0x4200000000000000000000000000000000000006 | 18 |
|
|
42
|
+
| USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | 6 |
|
|
43
|
+
| cbBTC | 0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf | 8 |
|
|
44
|
+
| AERO | 0x3f5bF3EdAc59d650D8fDf9657a71F2f904A3a4Ee | 18 |
|
|
45
|
+
| AERO (legacy) | 0x940181a94A35A4569E4529A3CDfB74e38FD98631 | 18 |
|
|
45
46
|
|
|
46
47
|
### Optimism (10)
|
|
47
48
|
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
const TOOL_NAME_RE = /\b(read|write|dev)\.[a-z_]+(?:\.[a-z_]+)*/g;
|
|
2
|
-
export function convertToolNames(text) {
|
|
3
|
-
return text.replace(TOOL_NAME_RE, (match) => match.replace(/\./g, "_"));
|
|
4
|
-
}
|
|
5
|
-
function deepConvertToolNames(value) {
|
|
6
|
-
if (typeof value === "string")
|
|
7
|
-
return convertToolNames(value);
|
|
8
|
-
if (Array.isArray(value))
|
|
9
|
-
return value.map(deepConvertToolNames);
|
|
10
|
-
if (value !== null && typeof value === "object") {
|
|
11
|
-
const result = {};
|
|
12
|
-
for (const [k, v] of Object.entries(value)) {
|
|
13
|
-
result[k] = deepConvertToolNames(v);
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
export function wrapServerForHttp(server) {
|
|
20
|
-
return new Proxy(server, {
|
|
21
|
-
get(target, prop, receiver) {
|
|
22
|
-
if (prop === "registerTool") {
|
|
23
|
-
return (name, config, cb) => {
|
|
24
|
-
const newName = convertToolNames(name);
|
|
25
|
-
const newConfig = { ...config };
|
|
26
|
-
if (typeof newConfig.description === "string") {
|
|
27
|
-
newConfig.description = convertToolNames(newConfig.description);
|
|
28
|
-
}
|
|
29
|
-
const wrappedCb = async (...args) => {
|
|
30
|
-
const result = (await cb(...args));
|
|
31
|
-
const content = result.content;
|
|
32
|
-
const structuredContent = result.structuredContent;
|
|
33
|
-
return {
|
|
34
|
-
...result,
|
|
35
|
-
...(content && {
|
|
36
|
-
content: content.map((c) => ({
|
|
37
|
-
...c,
|
|
38
|
-
...(typeof c.text === "string" && { text: convertToolNames(c.text) }),
|
|
39
|
-
})),
|
|
40
|
-
}),
|
|
41
|
-
...(structuredContent !== undefined && {
|
|
42
|
-
structuredContent: deepConvertToolNames(structuredContent),
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
return target.registerTool(newName, newConfig, wrappedCb);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (prop === "registerResource") {
|
|
50
|
-
return (name, uriOrTemplate, config, readCallback) => {
|
|
51
|
-
const wrappedCallback = async (...args) => {
|
|
52
|
-
const result = (await readCallback(...args));
|
|
53
|
-
const contents = result.contents;
|
|
54
|
-
return {
|
|
55
|
-
...result,
|
|
56
|
-
...(contents && {
|
|
57
|
-
contents: contents.map((c) => ({
|
|
58
|
-
...c,
|
|
59
|
-
...(typeof c.text === "string" && { text: convertToolNames(c.text) }),
|
|
60
|
-
})),
|
|
61
|
-
}),
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
return target.registerResource(name, uriOrTemplate, config, wrappedCallback);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (prop === "registerPrompt") {
|
|
68
|
-
return (name, config, cb) => {
|
|
69
|
-
const wrappedCb = async (...args) => {
|
|
70
|
-
const result = (await cb(...args));
|
|
71
|
-
const messages = result.messages;
|
|
72
|
-
return {
|
|
73
|
-
...result,
|
|
74
|
-
...(messages && {
|
|
75
|
-
messages: messages.map((m) => {
|
|
76
|
-
const content = m.content;
|
|
77
|
-
if (content && typeof content.text === "string") {
|
|
78
|
-
return { ...m, content: { ...content, text: convertToolNames(content.text) } };
|
|
79
|
-
}
|
|
80
|
-
return m;
|
|
81
|
-
}),
|
|
82
|
-
}),
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
return target.registerPrompt(name, config, wrappedCb);
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return Reflect.get(target, prop, receiver);
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|