@arcadia-finance/mcp-server 0.4.6 → 0.5.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.
@@ -2,145 +2,222 @@
2
2
 
3
3
  All automation on Arcadia uses V3/V4 accounts only. Arcadia's backend bots do the work once configured.
4
4
 
5
+ Automations are configured as **intents**: you describe the outcome you want and the backend resolves which asset-manager contracts are needed, checks that the combination is valid, encodes their metadata and returns the finished `setAssetManagers` calldata. There is no client-side contract encoding, and no asset-manager addresses to pick.
6
+
5
7
  ## Agent Workflow
6
8
 
7
9
  ```
8
- 1. Call read.asset_manager.intents to discover available automations and their params
9
- 2. Call write.asset_manager.{intent} for each desired automation → returns encoded args
10
- 3. Optionally merge arrays from multiple intent calls to combine changes
11
- 4. Call write.account.set_asset_managers with the (merged) args → unsigned tx
10
+ 1. read.account.info → find the LP position id and what is already automated
11
+ 2. read.asset_manager.current → decoded per-manager config, plus superseded managers to clear
12
+ 3. read.asset_manager.intents → which intents this account can enable, and why any are blocked
13
+ 4. write.account.automations → pass the full intents array, get back the unsigned tx
12
14
  ```
13
15
 
14
- ## Combining Automations
16
+ Pass the LP position's `position_id` and the backend fetches the protocol, staked flag, pool tokens and reward tokens for you. Only supply `protocol` / `token0` / `token1` by hand when you have no position id. `claim_merkl` needs no position context at all.
17
+
18
+ ## The five intents
19
+
20
+ | Intent | What it does | Needs position context |
21
+ | --------------- | ------------------------------------------------------------------------------ | ---------------------- |
22
+ | `compound_fees` | Reinvest earned fees and rewards back into the LP | yes |
23
+ | `claim_rewards` | Claim yield out, as-earned or converted to one token via CowSwap | yes |
24
+ | `add_to_lp` | Fold idle pool-token balances (deposits, rebalance leftovers) back into the LP | yes |
25
+ | `rebalance` | Reposition the LP: out-of-range, take-profit, or POL strategy | yes |
26
+ | `claim_merkl` | Auto-claim Merkl incentive rewards | no |
27
+
28
+ Every intent takes `enabled` (default true) and an optional `position_id`.
29
+
30
+ ## Full desired state vs delta
31
+
32
+ `write.account.automations` takes the **complete desired state**. Any automation not in the `intents` array gets disabled, so include everything the user wants kept, not just what is new. To turn everything off, pass a single intent with `enabled: false`.
15
33
 
16
- Each intent tool returns `{ description, asset_managers: [...], statuses: [...], datas: [...] }`. To apply multiple automations in one tx, concatenate the arrays from each call before passing to `write.account.set_asset_managers`.
34
+ `mode: "save"` (the default) diffs the desired state against what is on-chain and returns a signable transaction that both enables what you asked for and disables what you left out.
17
35
 
18
- Example: enable rebalancer + merkl_operator in one tx:
36
+ `mode: "preview"` resolves and validates the intents **without** reading chain state, and deliberately returns **no transaction** (`preview_only: true`). Because it does not diff, its calldata contains no disable entries: broadcasting it would enable the new managers while leaving omitted automations running. Use preview to check that a combination is legal or to show a plan, then re-run with `save` to get something signable.
37
+
38
+ `write.account.automations_delta` is the **change-only** variant: `enable` switches intents on, `disable` takes asset-manager addresses (from `read.asset_manager.current`) to switch off, and anything unmentioned is left alone. Use it to flip one automation without restating the rest.
39
+
40
+ Example: add rebalancing to an account that is already compounding, without disturbing the compounder:
19
41
 
20
42
  ```
21
- rebalancer = write.asset_manager.rebalancer(dex_protocol: "slipstream", ...)
22
- merkl = write.asset_manager.merkl_operator(reward_recipient: "0x...", ...)
23
- write.account.set_asset_managers(
43
+ write.account.automations_delta(
24
44
  account_address: "0x...",
25
- asset_managers: [...rebalancer.asset_managers, ...merkl.asset_managers],
26
- statuses: [...rebalancer.statuses, ...merkl.statuses],
27
- datas: [...rebalancer.datas, ...merkl.datas]
45
+ position_id: 12345,
46
+ enable: [{ kind: "rebalance" }]
28
47
  )
29
48
  ```
30
49
 
31
- To disable: call any intent tool with `enabled: false`, then merge and submit.
50
+ Same thing expressed as full desired state:
32
51
 
33
- ---
52
+ ```
53
+ write.account.automations(
54
+ account_address: "0x...",
55
+ position_id: 12345,
56
+ intents: [{ kind: "compound_fees" }, { kind: "rebalance" }]
57
+ )
58
+ ```
34
59
 
35
- ## Rebalancer
60
+ ## Per-token scoping
36
61
 
37
- **What it does:** When the LP position goes out of range, Arcadia's bot repositions it to a new range centered on the current price. All pending fees and staking rewards are claimed and compounded into the new position.
62
+ `compound_fees`, `claim_rewards` and `add_to_lp` accept a `tokens` array (`token0`, `token1`, and `reward` for the yielding intents) so different tokens can be routed differently. Omitting `tokens` means all yielding tokens for the compound/claim intents.
38
63
 
39
- **Tool:** `write.asset_manager.rebalancer`
64
+ `reward` only exists on a staked position whose reward token is not one of the pool tokens. When the reward token _is_ a pool token it collapses into that token.
40
65
 
41
- **Strategy modes:**
66
+ **Every yielding token must be assigned to exactly one of `compound_fees` or `claim_rewards`.** Scoping one intent to a subset without covering the rest is rejected, and no token may appear in both. So `compound_fees` with `tokens: ["token0"]` on its own is invalid: token1's yield would be unassigned.
42
67
 
43
- - **default** (all params at defaults): uses `when_out_of_range` — rebalances exactly when price exits the position range
44
- - **custom** (any param differs): uses `time_and_price_based_triggers` — adds configurable trigger offsets, cooldowns, and token composition
68
+ A mixed partition is valid and common: compound token0's fees while claiming token1's out.
45
69
 
46
- **Key params:**
70
+ ```
71
+ write.account.automations(
72
+ account_address: "0x...",
73
+ position_id: 12345,
74
+ intents: [
75
+ { kind: "compound_fees", tokens: ["token0"] },
76
+ { kind: "claim_rewards", config: { tokens: ["token1"], destination: "account" } }
77
+ ]
78
+ )
79
+ ```
47
80
 
48
- | Param | Default | Description |
49
- | ---------------------- | -------- | ---------------------------------------------------------------- |
50
- | `compound_leftovers` | `"all"` | `"all"` / `"none"` / `"token0"` / `"token1"` |
51
- | `optimal_token0_ratio` | `500000` | Target token0 % (scaled by 1e6: 500000 = 50%) |
52
- | `trigger_lower_ratio` | `0` | Trigger offset below lower tick (scaled by 1e6, 0 = at boundary) |
53
- | `trigger_upper_ratio` | `0` | Trigger offset above upper tick (scaled by 1e6, 0 = at boundary) |
54
- | `min_rebalance_time` | `3600` | Cooldown in seconds (1 hour) |
55
- | `max_rebalance_time` | `1e12` | Max time before forced rebalance (effectively disabled) |
81
+ Note the `destination: "account"`. A **wallet** (or custom `recipient`) payout is only allowed for a pure as-earned claim: nothing converted, and every yielding token claimed. A partial claim like the one above must settle in the account.
56
82
 
57
- **Free rebalance quota (per owner across all accounts):**
83
+ Note also that `add_to_lp` is opt-in per token: folding an idle balance happens only for tokens you name.
58
84
 
59
- | stAAA held | Daily | Weekly |
60
- | ---------- | ----- | ------ |
61
- | 0 | 1 | 3 |
62
- | 3,000 | 2 | 10 |
63
- | 6,000 | 3 | 17 |
64
- | 9,000 | 4 | 24 |
65
- | 30,000 | 11 | 73 |
85
+ ## Validation
66
86
 
67
- Quota is bypassed when: gas cost < pending fees ÷ 2, or position value ≥ $50k.
87
+ The backend enforces compatibility rules rather than letting an invalid combination reach the chain. When one fires the tool returns an error with the rule name and reason, and no transaction. The full set:
68
88
 
69
- **Pay for extra rebalances with AAA:** Deposit AAA tokens into the account, then approve them to the gas relayer `0xD938C8d04cF91094fecAF0A2018EAac483a40137`.
89
+ | Rule | Meaning |
90
+ | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
91
+ | `duplicate_intent_kind` | Each intent kind may appear only once. Two rebalance strategies is ambiguous. |
92
+ | `token_double_assigned` | A token cannot be both compounded and claimed. |
93
+ | `incomplete_partition` | Every yielding token must be assigned to compound or claim. |
94
+ | `empty_token_scope` | A `tokens` list must not be explicitly empty. Omit it to mean "all". |
95
+ | `tokens_out_of_scope` | Named a token this position does not yield (e.g. `reward` on an unstaked position, or a reward that is itself a pool token). |
96
+ | `claim_to_wallet_requires_pure_claim` | A wallet/custom-recipient payout requires claiming every yielding token as-earned, nothing converted. |
97
+ | `convert_tokens_out_of_scope` | `convert_tokens` must be a subset of the claimed tokens. |
98
+ | `convert_settles_in_account` | Converted rewards must settle in the account. |
99
+ | `claim_convert_missing_buy_token` | Converting requires a `buy_token`. |
100
+ | `convert_target_is_compounded` | `buy_token` cannot be a token you also compound. |
101
+ | `convert_target_in_convert_set` | `buy_token` cannot be one of the tokens being converted. |
102
+ | `convert_target_is_folded` | `buy_token` cannot also be folded by `add_to_lp`, or the converted rewards get re-added immediately. |
103
+ | `compound_reward_buy_token_not_pool_token` | The compound CowSwap leg must buy one of the position's underlyings. |
104
+ | `multiple_convert_targets` | One account has a single CowSwapper metadata slot, so a compound-reward swap leg and a claim-and-convert leg cannot coexist. |
70
105
 
71
- **Fees:** 7.5% of yield earned, max 1% liquidity decrease per rebalance (MDL).
106
+ Read `errors[].reason`, adjust the intents, retry. `read.asset_manager.intents` with an account address tells you up front which intents are currently blocked.
72
107
 
73
- **Range width and reposition mode** are configured in the Arcadia platform after enabling — not settable via MCP.
108
+ ## Simulation
74
109
 
75
- ---
110
+ `mode: "save"` and the delta tool simulate the resulting `setAssetManagers` call on Tenderly when an `owner` is supplied, and return `tenderly_sim_status`:
111
+
112
+ - `success`: the simulation ran and passed.
113
+ - `failure`: the simulation ran and the call would revert. The tool returns an error and **no** transaction, with the Tenderly link so you can read the revert reason. Do not broadcast.
114
+ - `unavailable`: no simulation ran, or the result was inconclusive. Typically `owner` was not supplied. The transaction is returned; this status neither endorses nor condemns it.
115
+
116
+ `preview` is never simulated, so it always reports `unavailable`, which is one reason it returns no transaction.
117
+
118
+ ## When there is no transaction
76
119
 
77
- ## Compounder
120
+ Three success-path cases return no `transaction`, and an agent must not treat any of them as "nothing to do but broadcast anyway":
78
121
 
79
- **What it does:** Claims accumulated LP fees and reinvests them back into the position.
122
+ | Field | Meaning |
123
+ | ---------------------------------------- | --------------------------------------------------------- |
124
+ | `preview_only: true` | Preview mode. Re-run with `save`. |
125
+ | `no_changes_needed: true` | The account already matches the request. Nothing to send. |
126
+ | (error) `tenderly_sim_status: "failure"` | The call would revert. Fix the cause, do not broadcast. |
80
127
 
81
- **Tool:** `write.asset_manager.compounder`
128
+ ## Superseded managers
82
129
 
83
- **When to add on top of a rebalancer:** The rebalancer compounds at rebalance time. Adding a compounder also compounds between rebalances — more frequent compounding, higher effective APY.
130
+ Asset managers are redeployed over time. An account registered on an older deployment keeps working, but `read.asset_manager.current` lists those under `deprecated` (and `read.account.info` under `automation.deprecated_managers`). They should be cleared: `write.account.automations` disables them as part of a save, or pass their addresses to `write.account.automations_delta`.
84
131
 
85
132
  ---
86
133
 
87
- ## Compounder + CowSwap
134
+ ## Rebalance
88
135
 
89
- **What it does:** Claims staked CL rewards (typically AERO), swaps them to a target token via CowSwap batch auctions (MEV-protected), then compounds into the LP position.
136
+ **What it does:** When the LP position goes out of range, Arcadia's bot repositions it to a new range centered on the current price. Pending fees and staking rewards are claimed and compounded as part of the rebalance.
90
137
 
91
- **Tool:** `write.asset_manager.compounder_staked`
138
+ **Strategies** (`strategy.kind`):
92
139
 
93
- **Params:**
140
+ - `out_of_range` (default): repositions based on range triggers and cooldowns
141
+ - `take_profit`: runs on the dedicated profit-taker contract, takes profit in `profit_token`
142
+ - `protocol_owned_liquidity`: POL strategy
94
143
 
95
- - `sell_tokens`: typically `[AERO]` for staked positions
96
- - `buy_token`: a major token in the pair (USDC, WETH, cbBTC)
144
+ **Key `out_of_range` params:**
97
145
 
98
- Sets metadata on both CowSwapper and Compounder in one call. Base only.
146
+ | Param | Default | Description |
147
+ | -------------------------- | -------- | -------------------------------------------------------------------------------- |
148
+ | `optimal_token0_ratio` | `500000` | Target token0 composition (1e6-scaled: 500000 = 50%) |
149
+ | `trigger_lower_tick_ratio` | `0` | Offset from tick_lower as a fraction of tick range (1e6-scaled, 0 = at boundary) |
150
+ | `trigger_upper_tick_ratio` | `0` | Offset from tick_upper, same scaling. Asymmetric values are valid |
151
+ | `min_rebalance_time` | `3600` | Cooldown in seconds |
152
+ | `max_rebalance_time` | `1e12` | Max time before a forced rebalance (effectively disabled) |
99
153
 
100
- ---
154
+ Trigger ratios are **tick distance, not price**: a ratio of 50000 shifts the trigger by 5% of `(tick_upper - tick_lower)` ticks. Positive values delay the rebalance until price travels further beyond the range; negative values fire preemptively while price is still in range.
101
155
 
102
- ## Yield Claimer
156
+ `max_tolerance` and `min_liquidity_ratio` (both 1e18-scaled) override the MEV/slippage and value-loss caps. Omit them for the pool's defaults. AAA pools floor `max_tolerance` at 5% because they are thin and volatile.
103
157
 
104
- **What it does:** Periodically claims pending fees/emissions and sends them to a designated recipient.
158
+ **Free rebalance quota (per owner across all accounts):**
105
159
 
106
- **Tool:** `write.asset_manager.yield_claimer`
160
+ | stAAA held | Daily | Weekly |
161
+ | ---------- | ----- | ------ |
162
+ | 0 | 1 | 3 |
163
+ | 3,000 | 2 | 10 |
164
+ | 6,000 | 3 | 17 |
165
+ | 9,000 | 4 | 24 |
166
+ | 30,000 | 11 | 73 |
107
167
 
108
- **Params:** `fee_recipient` — address to receive claimed fees.
168
+ Quota is bypassed when: gas cost < pending fees / 2, or position value >= $50k.
169
+
170
+ **Pay for extra rebalances with AAA:** Deposit AAA tokens into the account, then approve them to the gas relayer `0xD938C8d04cF91094fecAF0A2018EAac483a40137`. The relayer is an asset manager but no intent configures it, so it sits outside the intent model: `read.account.info` reports it as `automation.gas_relayer`.
171
+
172
+ **Fees:** 7.5% of yield earned, max 1% liquidity decrease per rebalance (MDL).
109
173
 
110
174
  ---
111
175
 
112
- ## Yield Claimer + CowSwap
176
+ ## Compound fees
177
+
178
+ **What it does:** Claims accumulated LP fees and staking rewards and reinvests them into the position.
179
+
180
+ **When to add on top of a rebalance:** The rebalance compounds at rebalance time. Adding `compound_fees` also compounds between rebalances, which means more frequent compounding and higher effective APY.
181
+
182
+ **Staked positions:** a staked position earns staking emissions (for example AERO), not LP fees. When the reward token is not one of the pool tokens, the backend routes it through the CowSwapper automatically: the reward is swapped to a pool token via a CoW Protocol batch auction (MEV-protected) and folded into the LP. You do not enable a CowSwapper yourself and you do not pick the sell/buy tokens. When the reward token _is_ a pool token no swap is needed and none is configured.
183
+
184
+ ---
113
185
 
114
- **What it does:** Claims LP fees, swaps claimed tokens to a target token via CowSwap, sends to recipient.
186
+ ## Claim rewards
115
187
 
116
- **Tool:** `write.asset_manager.yield_claimer_cowswap`
188
+ **What it does:** Claims pending fees and emissions out of the position instead of reinvesting them.
117
189
 
118
- **Params:**
190
+ **Config:**
119
191
 
120
- - `sell_tokens`: staked LP → `[AERO]`, non-staked → `[token0, token1]` minus buy_token
121
- - `buy_token`: token to receive
122
- - `fee_recipient`: destination address
192
+ | Field | Default | Description |
193
+ | ---------------- | -------------- | ---------------------------------------------------------------------- |
194
+ | `mode` | `as_earned` | `as_earned` pays the tokens as-is, `convert_to` swaps them via CowSwap |
195
+ | `destination` | `account` | `account` or `wallet` (the owner EOA) |
196
+ | `buy_token` | none | ERC20 to swap into. Required whenever anything is being converted |
197
+ | `recipient` | none | Explicit payout address, overrides `destination` |
198
+ | `tokens` | all yielding | Which tokens' yield to claim out |
199
+ | `convert_tokens` | defers to mode | Subset of `tokens` to swap; the rest are claimed as-earned |
123
200
 
124
- Sets metadata on both CowSwapper and Yield Claimer. Base only.
201
+ CowSwap settles inside the account, so a converted claim cannot pay out to a wallet. `convert_tokens` is what enables a partial convert: swap the reward to USDC while claiming token0 and token1 as-earned.
125
202
 
126
203
  ---
127
204
 
128
- ## CoW Swapper (Direct)
205
+ ## Add to LP
129
206
 
130
- **What it does:** Swap any ERC20 → ERC20 via CoW Protocol batch auctions (MEV-protected). Each swap requires account owner signature.
207
+ **What it does:** Folds idle pool-token balances sitting in the account (from deposits, or left over after a rebalance) into the LP position.
131
208
 
132
- **Tool:** `write.asset_manager.cow_swapper`
209
+ Opt-in per token via `tokens`: a token's balance is folded only when named. This is independent of compounding, so "compound yield without folding" and "fold without compounding" are both valid configurations.
133
210
 
134
- Base only. Not coupled to any other automation.
211
+ Both a rebalance and a compound may carry the same fold instruction. The amount is read from the live account balance at execution time, so whichever runs first consumes it and the other folds nothing. There is no double-add.
135
212
 
136
213
  ---
137
214
 
138
- ## Merkl Operator
215
+ ## Claim Merkl
139
216
 
140
- **What it does:** Claims external Merkl protocol incentive rewards into the account — additional rewards paid by token teams on top of regular LP fees.
217
+ **What it does:** Claims external Merkl protocol incentive rewards into the account, which are additional rewards paid by token teams on top of regular LP fees.
141
218
 
142
- **Tool:** `write.asset_manager.merkl_operator`
219
+ **When to enable:** When the pool has active Merkl campaigns (check the APY breakdown in `read.strategy.list`).
143
220
 
144
- **When to enable:** When the pool has active Merkl campaigns (check APY breakdown in `read.strategy.list`).
221
+ **Always combine with a rebalance** when both are relevant: no conflict, extra free yield.
145
222
 
146
- **Always combine with rebalancer** when both are relevant — no conflict, extra free yield.
223
+ Merkl authorization is the Merkl distributor whitelist, not `isAssetManager`, so it is reported separately. `read.asset_manager.current` returns a `merkl` block with `connected`, `active` and `tokens_missing`. When `tokens_missing` is true the user still has to register reward tokens with Merkl before claims land.
@@ -143,13 +143,14 @@ Target collateral ratio ≥ 1.5 at entry (≈ health factor ~0.5+). Never open b
143
143
 
144
144
  ## 4. Combining Automation
145
145
 
146
- | Combination | Compatible | Notes |
147
- | -------------------------- | ---------- | --------------------------------------------------------------------------------------- |
148
- | Rebalancer + Compounder | ✅ Yes | Rebalancer compounds at rebalance time; Compounder adds compounding between rebalances. |
149
- | Rebalancer + Yield Claimer | ✅ Yes | Yield claimer claims fees between rebalances; rebalancer compounds at rebalance time. |
150
- | Rebalancer + Merkl | ✅ Yes | Always combine when pool has Merkl incentives. Zero conflict. |
151
- | Compounder + Merkl | ✅ Yes | Merkl rewards claimed separately from trading fees. |
152
- | Any AM + CoW Swapper | ✅ Yes | CoW Swapper sells accumulated tokens independently. |
146
+ | Combination | Compatible | Notes |
147
+ | --------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------- |
148
+ | `rebalance` + `compound_fees` | ✅ Yes | Rebalance compounds at rebalance time; compound_fees adds compounding between rebalances. |
149
+ | `rebalance` + `claim_rewards` | ✅ Yes | Claims yield between rebalances. Order is handled by the keeper's claim-before guard. |
150
+ | `rebalance` + `claim_merkl` | ✅ Yes | Always combine when the pool has Merkl incentives. Zero conflict. |
151
+ | `compound_fees` + `claim_merkl` | ✅ Yes | Merkl rewards are claimed separately from trading fees. |
152
+ | `compound_fees` + `claim_rewards` | ⚠️ Per token | Valid only as a partition: each yielding token must go to exactly one of the two, and every yielding token must be covered. |
153
+ | `add_to_lp` + anything | ✅ Yes | Independent fold. Only constraint: a folded token cannot be a convert `buy_token`. |
153
154
 
154
155
  ---
155
156
 
@@ -102,25 +102,20 @@ write.account.add_liquidity(
102
102
  chain_id: 8453
103
103
  )
104
104
 
105
- // 6. ENCODE AND ENABLE REBALANCER + MERKL (match dex_protocol to LP protocol from step 1)
106
- // Step 6a: Encode rebalancer intent
107
- write.asset_manager.rebalancer(
108
- dex_protocol: "slipstream_v2",
109
- enabled: true,
110
- compound_leftovers: "all",
111
- trigger_lower_ratio: 0,
112
- trigger_upper_ratio: 0,
113
- min_rebalance_time: 3600,
114
- chain_id: 8453
115
- )
116
- // → Returns { description, asset_managers, statuses, datas } for the rebalancer
117
-
118
- // 7. ENCODE MERKL (if pool has Merkl incentives — check fee APY breakdown in step 1)
119
- write.asset_manager.merkl_operator(
120
- reward_recipient: <owner_wallet>,
121
- enabled: true,
105
+ // 6. ENABLE AUTOMATIONS — one call, one transaction
106
+ // Include every automation you want active: the intents array is the full desired state.
107
+ // Add claim_merkl only if the pool has Merkl incentives (check fee APY breakdown in step 1).
108
+ write.account.automations(
109
+ account_address: <account>,
110
+ position_id: <lp_nft_id>, // backend resolves protocol + tokens from this
111
+ intents: [
112
+ { kind: "compound_fees" }, // reinvest fees/rewards between rebalances
113
+ { kind: "rebalance", strategy: { kind: "out_of_range", min_rebalance_time: 3600 } },
114
+ { kind: "claim_merkl" }
115
+ ],
122
116
  chain_id: 8453
123
117
  )
118
+ // → Returns { valid, plan, diff, human_summary, transaction } — broadcast the transaction
124
119
  ```
125
120
 
126
121
  ### Monitoring
@@ -188,13 +183,14 @@ write.account.deleverage(
188
183
  #### Preferred: Atomic close (1-2 transactions)
189
184
 
190
185
  ```
191
- // 0. Disable automation first (prevents rebalancer from acting during close)
192
- write.asset_manager.rebalancer(
193
- dex_protocol: "slipstream_v2",
194
- enabled: false,
186
+ // 0. Disable automation first (prevents the rebalancer from acting during close)
187
+ read.asset_manager.current(account_address: <account>, chain_id: 8453)
188
+ // → take the rebalancer's address from `enabled`, then:
189
+ write.account.automations_delta(
190
+ account_address: <account>,
191
+ disable: [<rebalancer_address>],
195
192
  chain_id: 8453
196
193
  )
197
- // → Merge result into write.account.set_asset_managers(account_address: <account>, ...)
198
194
 
199
195
  // 1. Get account state — need asset list for the close call
200
196
  read.account.info(account_address: <account>, chain_id: 8453)
@@ -307,22 +303,32 @@ write.account.add_liquidity(
307
303
  chain_id: 8453
308
304
  )
309
305
 
310
- // 5. Enable rebalancer with POL strategy hook
311
- write.asset_manager.rebalancer(
312
- dex_protocol: <dex_protocol>, // e.g. "slipstream_v2", "uniV3"
313
- enabled: true,
314
- strategy_hook: "0x13beD1A58d87c0454872656c5328103aAe5eB86A", // POL dynamic range algorithm
315
- trigger_lower_ratio: 0,
316
- trigger_upper_ratio: 0,
317
- compound_leftovers: "all",
318
- min_rebalance_time: 3600,
306
+ // 5. Enable the rebalancer on the POL strategy
307
+ // The backend routes POL to the unified rebalancer and its POL strategy hook;
308
+ // tuning params are part of the intent, all optional with the defaults shown.
309
+ write.account.automations(
310
+ account_address: <account>,
311
+ position_id: <lp_nft_id>,
312
+ intents: [{
313
+ kind: "rebalance",
314
+ strategy: {
315
+ kind: "protocol_owned_liquidity",
316
+ initial_range: 200000,
317
+ base_range: 50000,
318
+ k1: 0,
319
+ k2: 0,
320
+ rebalance_threshold: 25000,
321
+ limit_order_withdrawal_threshold: 50000,
322
+ fraction_excess_to_limit_order: 500000,
323
+ deadzone: 20000,
324
+ target_token0_ratio: 500000
325
+ }
326
+ }],
319
327
  chain_id: 8453
320
328
  )
321
- // → Pass result to write.account.set_asset_managers(account_address: <account>, ...)
322
- // → POL tuning params (base_range, k1, k2, rebalance_threshold) configured in Arcadia platform
323
329
  ```
324
330
 
325
- **MCP limitation:** POL tuning parameters are configured in the Arcadia platform backend, not via MCP tools. Agents can deploy and enable the rebalancer contract, but specific POL parameterization requires platform access.
331
+ POL runs on the unified V2.1.1 rebalancer, which is the only deployment that speaks the POL strategy hook ABI. You do not select it or its hook: pass `strategy.kind: "protocol_owned_liquidity"` and the backend resolves both.
326
332
 
327
333
  ### Monitoring for POL
328
334
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: arcadia-finance
3
- version: 1.1.3
3
+ version: 1.2.0
4
4
  description: "DeFi liquidity management on Uniswap and Aerodrome, live on Base, Unichain, and Optimism. 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:
@@ -78,8 +78,8 @@ All write tools return unsigned transactions `{ to, data, value, chainId }`. Sig
78
78
  {baseDir}/arcadia.sh write_account_create '{"wallet_address":"0x...","salt":1,"chain_id":8453}'
79
79
 
80
80
  # Enable automation
81
- {baseDir}/arcadia.sh write_asset_manager_rebalancer '{"dex_protocol":"slipstream"}'
82
- {baseDir}/arcadia.sh write_account_set_asset_managers '{"account_address":"0x...","asset_managers":[...],"statuses":[...],"datas":[...]}'
81
+ {baseDir}/arcadia.sh read_asset_manager_intents '{"account_address":"0x...","chain_id":8453}'
82
+ {baseDir}/arcadia.sh write_account_automations '{"account_address":"0x...","position_id":12345,"intents":[{"kind":"compound_fees"},{"kind":"rebalance"}],"chain_id":8453}'
83
83
  ```
84
84
 
85
85
  ## Configuration
@@ -1,113 +0,0 @@
1
- import { z } from "zod";
2
- import { CHAIN_ID_DESCRIPTION } from "../../../config/chains.js";
3
- import { getAmProtocolAddress, getStandaloneAmAddress } from "../../../config/addresses.js";
4
- import { validateAddress, validateChainId } from "../../../utils/validation.js";
5
- import { COMPOUNDER_INITIATOR, COWSWAPPER_INITIATOR, encodeCompounderCallbackData, encodeCompounderCoupledCallbackData, encodeCowSwapTokenMetadata, disabledIntent, } from "./encoding.js";
6
- import { IntentOutput } from "../../output-schemas.js";
7
- import { DEX_PROTOCOL_SCHEMA, dexProtocolToAmKey, formatResult } from "./shared.js";
8
- export function registerCompounderTools(server, _chains) {
9
- server.registerTool("write.asset_manager.compounder", {
10
- annotations: {
11
- title: "Encode Compounder Automation",
12
- readOnlyHint: true,
13
- destructiveHint: false,
14
- idempotentHint: true,
15
- openWorldHint: false,
16
- },
17
- description: "Encode args for the standalone compounder automation. Claims accumulated LP trading fees and reinvests them back into the position (compound interest). LP fees only — does NOT claim staking rewards like AERO; use write.asset_manager.compounder_staked for staked positions earning emission tokens. When paired with a rebalancer, the rebalancer compounds at rebalance time — adding a compounder also compounds between rebalances for higher effective APY. Returns { asset_managers, statuses, datas } — pass to write.account.set_asset_managers. Combinable with other intent tools.",
18
- outputSchema: IntentOutput,
19
- inputSchema: {
20
- dex_protocol: DEX_PROTOCOL_SCHEMA,
21
- enabled: z.boolean().default(true).describe("True to enable, false to disable"),
22
- chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
23
- },
24
- }, async (params) => {
25
- try {
26
- const validChainId = validateChainId(params.chain_id);
27
- const amKey = dexProtocolToAmKey(params.dex_protocol);
28
- const amAddress = getAmProtocolAddress(validChainId, "compounders", amKey);
29
- if (!params.enabled)
30
- return formatResult(disabledIntent([amAddress], `Disable compounder (${params.dex_protocol})`));
31
- const callbackData = encodeCompounderCallbackData(COMPOUNDER_INITIATOR);
32
- const result = {
33
- description: `Enable compounder (${params.dex_protocol})`,
34
- asset_managers: [amAddress],
35
- statuses: [true],
36
- datas: [callbackData],
37
- };
38
- return formatResult(result);
39
- }
40
- catch (err) {
41
- return {
42
- content: [
43
- {
44
- type: "text",
45
- text: `Error: ${err instanceof Error ? err.message : String(err)}`,
46
- },
47
- ],
48
- isError: true,
49
- };
50
- }
51
- });
52
- server.registerTool("write.asset_manager.compounder_staked", {
53
- annotations: {
54
- title: "Encode Compounder + CowSwap Automation",
55
- readOnlyHint: true,
56
- destructiveHint: false,
57
- idempotentHint: true,
58
- openWorldHint: false,
59
- },
60
- description: "Encode args for compounder coupled with CowSwap for staked LP positions (e.g. staked Slipstream/Aerodrome). Staked positions earn staking emission rewards (e.g. AERO on Aerodrome) — not LP fees. Claims these staking rewards, swaps them to a target token via CowSwap batch auctions (MEV-protected), then compounds back into the LP position. Sets metadata on BOTH the CowSwapper and the Compounder in a single call. sell_tokens is the list of reward token addresses (e.g. [AERO_address]). buy_token should be a major token in the pair (USDC, WETH, cbBTC). Returns { asset_managers, statuses, datas } with 2 entries (cowswapper + compounder). Base only. Combinable with other intent tools.",
61
- outputSchema: IntentOutput,
62
- inputSchema: {
63
- dex_protocol: DEX_PROTOCOL_SCHEMA,
64
- sell_tokens: z
65
- .array(z.string())
66
- .describe("Token addresses to sell via CowSwap (typically [AERO] for staked positions)"),
67
- buy_token: z
68
- .string()
69
- .describe("Token address to buy — should be a major token in the pair (USDC, WETH, cbBTC)"),
70
- enabled: z.boolean().default(true).describe("True to enable, false to disable"),
71
- chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
72
- },
73
- }, async (params) => {
74
- try {
75
- const validChainId = validateChainId(params.chain_id);
76
- const amKey = dexProtocolToAmKey(params.dex_protocol);
77
- let cowSwapperAddress;
78
- try {
79
- cowSwapperAddress = getStandaloneAmAddress(validChainId, "cowSwapper");
80
- }
81
- catch (err) {
82
- const reason = err instanceof Error ? err.message : String(err);
83
- throw new Error(`compounder_staked requires cow_swapper. ${reason}`);
84
- }
85
- const compounderAddress = getAmProtocolAddress(validChainId, "compounders", amKey);
86
- if (!params.enabled) {
87
- return formatResult(disabledIntent([cowSwapperAddress, compounderAddress], `Disable compounder_staked (${params.dex_protocol})`));
88
- }
89
- const validSellTokens = params.sell_tokens.map((t, i) => validateAddress(t, `sell_tokens[${i}]`));
90
- const validBuyToken = validateAddress(params.buy_token, "buy_token");
91
- const cowSwapperData = encodeCowSwapTokenMetadata("cow_swap_compound", validSellTokens, validBuyToken);
92
- const compounderData = encodeCompounderCoupledCallbackData(COWSWAPPER_INITIATOR, "cow_swap_compound");
93
- const result = {
94
- description: `Enable compounder_staked (${params.dex_protocol}, cowswap)`,
95
- asset_managers: [cowSwapperAddress, compounderAddress],
96
- statuses: [true, true],
97
- datas: [cowSwapperData, compounderData],
98
- };
99
- return formatResult(result);
100
- }
101
- catch (err) {
102
- return {
103
- content: [
104
- {
105
- type: "text",
106
- text: `Error: ${err instanceof Error ? err.message : String(err)}`,
107
- },
108
- ],
109
- isError: true,
110
- };
111
- }
112
- });
113
- }
@@ -1,50 +0,0 @@
1
- import { z } from "zod";
2
- import { CHAIN_ID_DESCRIPTION } from "../../../config/chains.js";
3
- import { getStandaloneAmAddress } from "../../../config/addresses.js";
4
- import { validateChainId } from "../../../utils/validation.js";
5
- import { encodeOuterMetadata, disabledIntent } from "./encoding.js";
6
- import { IntentOutput } from "../../output-schemas.js";
7
- import { formatResult } from "./shared.js";
8
- export function registerCowSwapperTool(server, _chains) {
9
- server.registerTool("write.asset_manager.cow_swapper", {
10
- annotations: {
11
- title: "Encode Direct CowSwap Automation",
12
- readOnlyHint: true,
13
- destructiveHint: false,
14
- idempotentHint: true,
15
- openWorldHint: false,
16
- },
17
- description: "Encode args for standalone direct CowSwap mode. Enables the CowSwapper to swap any ERC20 → ERC20 via CoW Protocol batch auctions (MEV-protected). Unlike compounder_staked or yield_claimer_cowswap, this is NOT coupled to any other automation — each swap requires an additional signature from the account owner. Only available on Base (8453). Returns { asset_managers, statuses, datas } — pass to write.account.set_asset_managers. Combinable with other intent tools.",
18
- outputSchema: IntentOutput,
19
- inputSchema: {
20
- enabled: z.boolean().default(true).describe("True to enable, false to disable"),
21
- chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
22
- },
23
- }, async (params) => {
24
- try {
25
- const validChainId = validateChainId(params.chain_id);
26
- const cowSwapperAddress = getStandaloneAmAddress(validChainId, "cowSwapper");
27
- if (!params.enabled)
28
- return formatResult(disabledIntent([cowSwapperAddress], "Disable cow_swapper"));
29
- const cowSwapperData = encodeOuterMetadata("cow_swap_direct", "0x");
30
- const result = {
31
- description: "Enable cow_swapper (direct mode)",
32
- asset_managers: [cowSwapperAddress],
33
- statuses: [true],
34
- datas: [cowSwapperData],
35
- };
36
- return formatResult(result);
37
- }
38
- catch (err) {
39
- return {
40
- content: [
41
- {
42
- type: "text",
43
- text: `Error: ${err instanceof Error ? err.message : String(err)}`,
44
- },
45
- ],
46
- isError: true,
47
- };
48
- }
49
- });
50
- }