@arcadia-finance/mcp-server 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -35
- package/dist/config/addresses.js +59 -4
- package/dist/index.js +37 -0
- package/dist/prompts/workflows.js +11 -8
- package/dist/tools/dev/send.js +12 -8
- package/dist/tools/index.js +16 -6
- package/dist/tools/output-schemas.js +128 -0
- package/dist/tools/read/account.js +135 -112
- package/dist/tools/read/asset-managers.js +158 -0
- package/dist/tools/read/assets.js +52 -16
- package/dist/tools/read/guides.js +24 -3
- package/dist/tools/read/points.js +14 -20
- package/dist/tools/read/pools.js +68 -39
- package/dist/tools/read/strategy.js +89 -44
- package/dist/tools/read/wallet.js +84 -6
- package/dist/tools/write/account/add-liquidity.js +9 -3
- package/dist/tools/write/account/borrow.js +13 -9
- package/dist/tools/write/account/close.js +5 -1
- package/dist/tools/write/account/create.js +14 -13
- package/dist/tools/write/account/deleverage.js +6 -2
- package/dist/tools/write/account/deposit.js +14 -10
- package/dist/tools/write/account/format-response.js +5 -4
- package/dist/tools/write/account/remove-liquidity.js +5 -1
- package/dist/tools/write/account/repay.js +14 -10
- package/dist/tools/write/account/stake.js +8 -2
- package/dist/tools/write/account/swap.js +5 -1
- package/dist/tools/write/account/withdraw.js +13 -9
- package/dist/tools/write/asset-managers/compounder.js +111 -0
- package/dist/tools/write/asset-managers/cow-swapper.js +49 -0
- package/dist/tools/write/asset-managers/encoding.js +162 -0
- package/dist/tools/write/asset-managers/merkl-operator.js +51 -0
- package/dist/tools/write/asset-managers/rebalancer.js +108 -0
- package/dist/tools/write/asset-managers/set-asset-managers.js +75 -0
- package/dist/tools/write/asset-managers/shared.js +29 -0
- package/dist/tools/write/asset-managers/yield-claimer.js +115 -0
- package/dist/tools/write/wallet/approve.js +14 -10
- package/package.json +2 -1
- package/server.json +26 -2
- package/skills/clamm-liquidity/SKILL.md +34 -28
- package/skills/clamm-liquidity/automation.md +83 -73
- package/skills/clamm-liquidity/selection.md +2 -2
- package/skills/clamm-liquidity/strategies.md +28 -30
- package/dist/tools/write/asset-manager/configure.js +0 -254
- package/dist/tools/write/asset-manager/set.js +0 -62
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clamm-liquidity
|
|
3
|
-
description: Agent guide for clAMM management on Arcadia Finance. Covers
|
|
3
|
+
description: Agent guide for clAMM management on Arcadia Finance. Covers 37 MCP tools (+1 dev), automation setup (rebalancers, compounders, yield claimers, Merkl, CoW swapper), strategy selection framework, and strategy templates including delta neutral leveraged LP and protocol-owned liquidity.
|
|
4
4
|
user-invocable: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -45,49 +45,55 @@ Arcadia's flash-action tools can batch multiple DeFi operations into a single at
|
|
|
45
45
|
|
|
46
46
|
**Batched write tools (`write.account.add_liquidity`, `write.account.close`, `write.account.deleverage`, `write.account.swap`, `write.account.remove_liquidity`, `write.account.stake`) return time-sensitive calldata** — sign and broadcast promptly; calldata may expire after 30–60 seconds depending on market conditions. If a transaction reverts due to price movement, rebuild and retry at least once before falling back to individual tools.
|
|
47
47
|
|
|
48
|
-
## MCP Tools (
|
|
48
|
+
## MCP Tools (37 + 1 dev)
|
|
49
49
|
|
|
50
50
|
### Read Tools
|
|
51
51
|
|
|
52
52
|
| Tool | When to use |
|
|
53
53
|
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
-
| `read.account.info` | Account overview + liquidation price. Pass `account_address` for detail (returns positions with `asset_address`/`asset_id`, collateral, debt)
|
|
54
|
+
| `read.account.info` | Account overview + liquidation price. Pass `account_address` for detail (returns positions with `asset_address`/`asset_id`/`dex_protocol`, collateral, debt). |
|
|
55
55
|
| `read.account.history` | Historical account value over time. Optional `days` param (default 14). |
|
|
56
56
|
| `read.account.pnl` | PnL and yield earned — use to check if a strategy is still profitable. |
|
|
57
|
-
| `read.
|
|
57
|
+
| `read.asset.list` | List supported collateral assets (symbol, address, decimals). Use `search` to filter by symbol substring. |
|
|
58
|
+
| `read.asset.prices` | USD prices for one or more assets by address. Pass `asset_addresses` (single or comma-separated). |
|
|
58
59
|
| `read.wallet.balances` | On-chain ERC20 balances and native ETH for a wallet. Use to pre-check if the wallet has enough tokens before depositing or adding liquidity. |
|
|
59
|
-
| `read.wallet.
|
|
60
|
-
| `read.
|
|
60
|
+
| `read.wallet.allowances` | Check ERC20 token allowances for a spender. Use before `write.wallet.approve` to avoid redundant approvals — skip if the current allowance is already sufficient. |
|
|
61
|
+
| `read.wallet.accounts` | List all Arcadia accounts owned by a wallet address. |
|
|
62
|
+
| `read.wallet.points` | Points earned by a wallet address. |
|
|
63
|
+
| `read.pool.list` | Lending pool TVL, APY, utilization, liquidity. Pass `pool_address` for detail + APY history (optional `days`, default 14). |
|
|
64
|
+
| `read.pool.info` | Detail + APY history for a specific lending pool. Pass `pool_address`. |
|
|
61
65
|
| `read.strategy.list` | LP strategies with fee APY, underlyings, pool protocol. List view shows 7d avg APY for the strategy's default range (e.g. ±7.5% for volatile pairs). **Pass `strategy_id` to see APY per range width** (very_narrow → full_range) — narrower range = higher APY but more rebalancing cost/risk. Use `featured_only: true` for curated top strategies. |
|
|
62
|
-
| `read.
|
|
66
|
+
| `read.strategy.info` | Detail for a specific strategy by `strategy_id`, including range-width APY breakdown. |
|
|
67
|
+
| `read.point_leaderboard` | Points leaderboard. No `chain_id` needed — points are cross-chain. |
|
|
63
68
|
| `read.strategy.recommendation` | Rebalancing recommendation for an account. Uses 1d APY (not 7d like `read.strategy.list`), so numbers may differ. |
|
|
69
|
+
| `read.asset_manager.intents` | List available automations with tool names, required params, and supported chains. Use to discover what automations can be configured. Filter by `chain_id` to exclude chain-unsupported intents. |
|
|
64
70
|
| `read.guides` | Reference guides: `automation` (AM setup), `selection` (pool evaluation), `strategies` (step-by-step templates). |
|
|
65
71
|
|
|
66
72
|
### Preferred Write Tools (atomic/multi-step — use these first)
|
|
67
73
|
|
|
68
74
|
These tools batch multiple operations into ONE atomic transaction. Always prefer these over individual tools.
|
|
69
75
|
|
|
70
|
-
| Tool
|
|
71
|
-
|
|
|
72
|
-
| `write.account.add_liquidity`
|
|
73
|
-
| `write.account.close`
|
|
74
|
-
| `write.account.deleverage`
|
|
75
|
-
| `write.
|
|
76
|
+
| Tool | Batches | When to use |
|
|
77
|
+
| ---------------------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
78
|
+
| `write.account.add_liquidity` | deposit + swap + mint LP + optional borrow | Open LP position. Do NOT call `write.account.deposit` separately — this handles wallet transfer atomically. |
|
|
79
|
+
| `write.account.close` | burn LP + swap + repay debt (up to 3 steps) | Close/exit a position. ALWAYS try this first. Tokens stay in account — follow up with `write.account.withdraw`. |
|
|
80
|
+
| `write.account.deleverage` | swap collateral + repay debt | Repay debt using account collateral (no wallet tokens needed). Preferred for health factor fixes. |
|
|
81
|
+
| `write.account.set_asset_managers` | build setAssetManagers tx from encoded intent args | Combine multiple automations by merging arrays from `write.asset_manager.*` intent tools. |
|
|
76
82
|
|
|
77
83
|
### Individual Write Tools (use when batched tools fail or for standalone operations)
|
|
78
84
|
|
|
79
|
-
| Tool | When to use
|
|
80
|
-
| -------------------------------- |
|
|
81
|
-
| `write.wallet.approve` | Approve a token for spending. **Required before `write.account.deposit`** and before `write.account.add_liquidity` (when depositing from wallet). Call `read.wallet.
|
|
82
|
-
| `write.account.create` | Create a new Arcadia account (one-time setup). Use `account_version: 0` for the latest version (recommended).
|
|
83
|
-
| `write.account.deposit` | Deposit ERC20 tokens as collateral. NOT needed before `write.account.add_liquidity` — that tool handles deposits atomically.
|
|
84
|
-
| `write.account.withdraw` | Withdraw assets to account owner. Account version auto-detected on-chain. Params: `asset_addresses[]`, `asset_amounts[]` (exact amounts, no max_uint256), optional `asset_ids[]` (0 for ERC20).
|
|
85
|
-
| `write.account.borrow` | Borrow from a lending pool. NOT needed for leveraged LP — `write.account.add_liquidity` handles borrowing internally.
|
|
86
|
-
| `write.account.repay` | Repay debt from wallet (approve pool first). Use `amount: "max_uint256"` to repay in full. For repaying with account collateral, prefer `write.account.deleverage`.
|
|
87
|
-
| `write.account.swap` | Swap assets within account (backend handles routing). For closing positions, prefer `write.account.close`.
|
|
88
|
-
| `write.account.remove_liquidity` | PARTIAL liquidity decrease only (position stays open). For full LP removal/exit, use `write.account.close`.
|
|
89
|
-
| `write.account.stake` | Stake, unstake, or claim rewards for an LP position. Direction auto-detected from `asset_address`.
|
|
90
|
-
| `write.asset_manager
|
|
85
|
+
| Tool | When to use |
|
|
86
|
+
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| `write.wallet.approve` | Approve a token for spending. **Required before `write.account.deposit`** and before `write.account.add_liquidity` (when depositing from wallet). Call `read.wallet.allowances` first to check if already approved. |
|
|
88
|
+
| `write.account.create` | Create a new Arcadia account (one-time setup). Use `account_version: 0` for the latest version (recommended). |
|
|
89
|
+
| `write.account.deposit` | Deposit ERC20 tokens as collateral. NOT needed before `write.account.add_liquidity` — that tool handles deposits atomically. |
|
|
90
|
+
| `write.account.withdraw` | Withdraw assets to account owner. Account version auto-detected on-chain. Params: `asset_addresses[]`, `asset_amounts[]` (exact amounts, no max_uint256), optional `asset_ids[]` (0 for ERC20). |
|
|
91
|
+
| `write.account.borrow` | Borrow from a lending pool. NOT needed for leveraged LP — `write.account.add_liquidity` handles borrowing internally. |
|
|
92
|
+
| `write.account.repay` | Repay debt from wallet (approve pool first). Use `amount: "max_uint256"` to repay in full. For repaying with account collateral, prefer `write.account.deleverage`. |
|
|
93
|
+
| `write.account.swap` | Swap assets within account (backend handles routing). For closing positions, prefer `write.account.close`. |
|
|
94
|
+
| `write.account.remove_liquidity` | PARTIAL liquidity decrease only (position stays open). For full LP removal/exit, use `write.account.close`. |
|
|
95
|
+
| `write.account.stake` | Stake, unstake, or claim rewards for an LP position. Direction auto-detected from `asset_address`. |
|
|
96
|
+
| `write.asset_manager.*` | Encode automation intents (rebalancer, compounder, compounder_staked, yield_claimer, yield_claimer_cowswap, cow_swapper, merkl_operator). Each returns `{ asset_managers, statuses, datas }` — merge arrays, pass to `write.account.set_asset_managers`. See automation.md and `read.asset_manager.intents` for full details. |
|
|
91
97
|
|
|
92
98
|
### Dev Tools (only available when `PK` env var is set)
|
|
93
99
|
|
|
@@ -128,7 +134,7 @@ Use as `pool_address` in `write.account.borrow` / `write.account.repay`, as `cre
|
|
|
128
134
|
|
|
129
135
|
## Asset Manager Addresses (Base 8453)
|
|
130
136
|
|
|
131
|
-
|
|
137
|
+
Addresses are auto-resolved by `write.asset_manager.*` intent tools based on `dex_protocol`. Listed here for reference. All require V3/V4 accounts.
|
|
132
138
|
|
|
133
139
|
| Type | Protocol | Address |
|
|
134
140
|
| -------------- | ------------- | -------------------------------------------- |
|
|
@@ -148,7 +154,7 @@ Use with `write.asset_manager.configure` (enable + configure) or `write.asset_ma
|
|
|
148
154
|
| CoW Swapper | All | `0xc928013A219EC9F18dE7B2dee6A50Ba626811854` |
|
|
149
155
|
| Gas Relayer | All | `0xD938C8d04cF91094fecAF0A2018EAac483a40137` |
|
|
150
156
|
|
|
151
|
-
**Slipstream V1 vs V2:** The pool determines the version — some pools are V1, some are V2.
|
|
157
|
+
**Slipstream V1 vs V2:** The pool determines the version — some pools are V1, some are V2. `read.account.info` now returns a `dex_protocol` field on LP positions (derived from the position manager address), so you can read the protocol directly from the account overview. Pass this value as `dex_protocol` to `write.asset_manager.*` intent tools to auto-resolve the correct AM address.
|
|
152
158
|
|
|
153
159
|
## Account Versions
|
|
154
160
|
|
|
@@ -156,7 +162,7 @@ Spot vs margin is determined by whether a **creditor** (lending pool) is set at
|
|
|
156
162
|
|
|
157
163
|
- `account_version: 3` — **margin account** (created with a `creditor`). Can borrow, leverage, and mint LP. Uses an onchain whitelist of allowed collateral tokens.
|
|
158
164
|
- `account_version: 4` or `0` (latest) — **spot account** (no creditor, no borrowing). Can hold assets and mint LP with `leverage: 0`. Accepts any ERC20 (no onchain whitelist).
|
|
159
|
-
- `account_version: 1` or `2` — legacy. Not supported by current MCP tools (`write.asset_manager
|
|
165
|
+
- `account_version: 1` or `2` — legacy. Not supported by current MCP tools (`write.asset_manager.*` and `write.account.set_asset_managers` require V3/V4).
|
|
160
166
|
- For **leveraged LP strategies**, use `account_version: 3` with a creditor.
|
|
161
167
|
- To check an existing account's version: call `read.account.info` — the response includes the account version.
|
|
162
168
|
|
|
@@ -1,61 +1,58 @@
|
|
|
1
1
|
# Automation Setup
|
|
2
2
|
|
|
3
|
-
All automation on Arcadia uses
|
|
3
|
+
All automation on Arcadia uses V3/V4 accounts only. Arcadia's backend bots do the work once configured.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
**To enable + configure (recommended):** Use `write.asset_manager.configure`. This grants permission AND sets strategy parameters (initiator, fee limits, trigger thresholds, fee recipient, etc.) in a single transaction.
|
|
8
|
-
|
|
9
|
-
**To grant/revoke only:** Use `write.asset_manager.set`. This only grants or revokes permission — no configuration. Use this to revoke an asset manager.
|
|
10
|
-
|
|
11
|
-
## Configure + enable
|
|
5
|
+
## Agent Workflow
|
|
12
6
|
|
|
13
7
|
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// rebalancer-specific (all optional, shown with defaults):
|
|
19
|
-
trigger_lower_ratio: 0, // 0 = trigger exactly at boundary. Values scaled by 1e6 (must be integer): 50000 = 5%, 100000 = 10%
|
|
20
|
-
trigger_upper_ratio: 0, // same as above for the upper bound
|
|
21
|
-
compound_leftovers: "all", // "all" = compound both tokens, "none" = don't compound, "token0" or "token1" = compound only that token
|
|
22
|
-
min_rebalance_time: 3600, // 1 hour cooldown between rebalances
|
|
23
|
-
// yield_claimer / merkl_operator:
|
|
24
|
-
fee_recipient: <address>, // required for yield_claimer
|
|
25
|
-
reward_recipient: <address>, // required for merkl_operator
|
|
26
|
-
chain_id: 8453
|
|
27
|
-
)
|
|
28
|
-
// Note: initiator address and fee limits are set automatically by the tool based on am_type — no need to pass them.
|
|
29
|
-
|
|
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
|
|
30
12
|
```
|
|
31
13
|
|
|
32
|
-
##
|
|
14
|
+
## Combining Automations
|
|
15
|
+
|
|
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`.
|
|
17
|
+
|
|
18
|
+
Example: enable rebalancer + merkl_operator in one tx:
|
|
33
19
|
|
|
34
20
|
```
|
|
35
|
-
write.asset_manager.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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(
|
|
24
|
+
account_address: "0x...",
|
|
25
|
+
asset_managers: [...rebalancer.asset_managers, ...merkl.asset_managers],
|
|
26
|
+
statuses: [...rebalancer.statuses, ...merkl.statuses],
|
|
27
|
+
datas: [...rebalancer.datas, ...merkl.datas]
|
|
40
28
|
)
|
|
41
29
|
```
|
|
42
30
|
|
|
43
|
-
To
|
|
31
|
+
To disable: call any intent tool with `enabled: false`, then merge and submit.
|
|
44
32
|
|
|
45
33
|
---
|
|
46
34
|
|
|
47
35
|
## Rebalancer
|
|
48
36
|
|
|
49
|
-
**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.
|
|
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.
|
|
38
|
+
|
|
39
|
+
**Tool:** `write.asset_manager.rebalancer`
|
|
50
40
|
|
|
51
|
-
**
|
|
41
|
+
**Strategy modes:**
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
|
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
|
|
45
|
+
|
|
46
|
+
**Key params:**
|
|
47
|
+
|
|
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) |
|
|
59
56
|
|
|
60
57
|
**Free rebalance quota (per owner across all accounts):**
|
|
61
58
|
|
|
@@ -67,70 +64,83 @@ To revoke any AM: `write.asset_manager.set(..., enabled: false)` or `write.asset
|
|
|
67
64
|
| 9,000 | 4 | 24 |
|
|
68
65
|
| 30,000 | 11 | 73 |
|
|
69
66
|
|
|
70
|
-
Quota is
|
|
67
|
+
Quota is bypassed when: gas cost < pending fees ÷ 2, or position value ≥ $50k.
|
|
71
68
|
|
|
72
|
-
**Pay for extra rebalances with AAA:** Deposit AAA tokens into the account, then approve them to the gas relayer `0xD938C8d04cF91094fecAF0A2018EAac483a40137`.
|
|
69
|
+
**Pay for extra rebalances with AAA:** Deposit AAA tokens into the account, then approve them to the gas relayer `0xD938C8d04cF91094fecAF0A2018EAac483a40137`.
|
|
73
70
|
|
|
74
71
|
**Fees:** 7.5% of yield earned, max 1% liquidity decrease per rebalance (MDL).
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
**Strategy config:** Range width and reposition mode are configured in the Arcadia platform after enabling the rebalancer — not settable via MCP.
|
|
73
|
+
**Range width and reposition mode** are configured in the Arcadia platform after enabling — not settable via MCP.
|
|
79
74
|
|
|
80
75
|
---
|
|
81
76
|
|
|
82
77
|
## Compounder
|
|
83
78
|
|
|
84
|
-
**What it does:**
|
|
79
|
+
**What it does:** Claims accumulated LP fees and reinvests them back into the position.
|
|
80
|
+
|
|
81
|
+
**Tool:** `write.asset_manager.compounder`
|
|
82
|
+
|
|
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.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Compounder + CowSwap
|
|
88
|
+
|
|
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.
|
|
85
90
|
|
|
86
|
-
**
|
|
91
|
+
**Tool:** `write.asset_manager.compounder_staked`
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
| ----------------------- | -------------------------------------------- | --------- |
|
|
90
|
-
| Aerodrome Slipstream V1 | `0x467837f44A71e3eAB90AEcfC995c84DC6B3cfCF7` | All |
|
|
91
|
-
| Aerodrome Slipstream V2 | `0x35e59448C7145482E56212510cC689612AB4F61f` | Base only |
|
|
92
|
-
| Uniswap V3 | `0x02e1fa043214E51eDf1F0478c6D0d3D5658a2DC3` | All |
|
|
93
|
-
| Uniswap V4 | `0xAA95c9c402b195D8690eCaea2341a76e3266B189` | All |
|
|
93
|
+
**Params:**
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
- `sell_tokens`: typically `[AERO]` for staked positions
|
|
96
|
+
- `buy_token`: a major token in the pair (USDC, WETH, cbBTC)
|
|
97
|
+
|
|
98
|
+
Sets metadata on both CowSwapper and Compounder in one call. Base only.
|
|
96
99
|
|
|
97
100
|
---
|
|
98
101
|
|
|
99
102
|
## Yield Claimer
|
|
100
103
|
|
|
101
|
-
**What it does:**
|
|
102
|
-
|
|
103
|
-
**Which address:**
|
|
104
|
+
**What it does:** Periodically claims pending fees/emissions and sends them to a designated recipient.
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
| ----------------------- | -------------------------------------------- | --------- |
|
|
107
|
-
| Aerodrome Slipstream V1 | `0x5a8278D37b7a787574b6Aa7E18d8C02D994f18Ba` | All |
|
|
108
|
-
| Aerodrome Slipstream V2 | `0xc8bF4B2c740FF665864E9494832520f18822871C` | Base only |
|
|
109
|
-
| Uniswap V3 | `0x75Ed28EA8601Ce9F5FbcAB1c2428f04A57aFaA16` | All |
|
|
110
|
-
| Uniswap V4 | `0xD8aa21AB7f9B8601CB7d7A776D3AFA1602d5D8D4` | All |
|
|
106
|
+
**Tool:** `write.asset_manager.yield_claimer`
|
|
111
107
|
|
|
112
|
-
**
|
|
108
|
+
**Params:** `fee_recipient` — address to receive claimed fees.
|
|
113
109
|
|
|
114
110
|
---
|
|
115
111
|
|
|
116
|
-
##
|
|
112
|
+
## Yield Claimer + CowSwap
|
|
117
113
|
|
|
118
|
-
**What it does:**
|
|
114
|
+
**What it does:** Claims LP fees, swaps claimed tokens to a target token via CowSwap, sends to recipient.
|
|
119
115
|
|
|
120
|
-
**
|
|
116
|
+
**Tool:** `write.asset_manager.yield_claimer_cowswap`
|
|
121
117
|
|
|
122
|
-
**
|
|
118
|
+
**Params:**
|
|
123
119
|
|
|
124
|
-
|
|
120
|
+
- `sell_tokens`: staked LP → `[AERO]`, non-staked → `[token0, token1]` minus buy_token
|
|
121
|
+
- `buy_token`: token to receive
|
|
122
|
+
- `fee_recipient`: destination address
|
|
123
|
+
|
|
124
|
+
Sets metadata on both CowSwapper and Yield Claimer. Base only.
|
|
125
125
|
|
|
126
126
|
---
|
|
127
127
|
|
|
128
|
-
## CoW Swapper
|
|
128
|
+
## CoW Swapper (Direct)
|
|
129
129
|
|
|
130
|
-
**What it does:**
|
|
130
|
+
**What it does:** Swap any ERC20 → ERC20 via CoW Protocol batch auctions (MEV-protected). Each swap requires account owner signature.
|
|
131
131
|
|
|
132
|
-
**
|
|
132
|
+
**Tool:** `write.asset_manager.cow_swapper`
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
Base only. Not coupled to any other automation.
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Merkl Operator
|
|
139
|
+
|
|
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.
|
|
141
|
+
|
|
142
|
+
**Tool:** `write.asset_manager.merkl_operator`
|
|
143
|
+
|
|
144
|
+
**When to enable:** When the pool has active Merkl campaigns (check APY breakdown in `read.strategy.list`).
|
|
145
|
+
|
|
146
|
+
**Always combine with rebalancer** when both are relevant — no conflict, extra free yield.
|
|
@@ -8,7 +8,7 @@ Use this guide to evaluate whether a strategy makes sense and how to configure i
|
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
read.strategy.list(chain_id: 8453) // browse all LP strategies + fee APY
|
|
11
|
-
read.
|
|
11
|
+
read.pool.list(chain_id: 8453) // check borrow cost for leveraged strategies
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
**Viability check (leveraged):**
|
|
@@ -173,7 +173,7 @@ Monitor periodically with `read.account.info` and `read.account.pnl`. Exit or ad
|
|
|
173
173
|
|
|
174
174
|
```
|
|
175
175
|
[ ] read.strategy.list → fee_APY noted (7d avg for default range; call with strategy_id for per-range APY)
|
|
176
|
-
[ ] read.
|
|
176
|
+
[ ] read.pool.list → borrow_APY noted (if leveraged)
|
|
177
177
|
[ ] net_APY = fee_APY - (leverage-1) × borrow_APY > 0
|
|
178
178
|
[ ] Pair type matches strategy (volatile/stable for delta neutral)
|
|
179
179
|
[ ] Range width: modeled or estimated for pair volatility + stAAA quota
|
|
@@ -4,7 +4,7 @@ These are templates and examples — not the only valid approaches. Adapt parame
|
|
|
4
4
|
|
|
5
5
|
## Key Parameter Notes
|
|
6
6
|
|
|
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.
|
|
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
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
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.
|
|
@@ -52,7 +52,7 @@ 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 `read.
|
|
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
|
|
@@ -61,7 +61,7 @@ read.strategy.list(chain_id: 8453)
|
|
|
61
61
|
→ Note: strategy_id (integer), pool_protocol (Slipstream V1/V2, UniV3, UniV4), fee_APY
|
|
62
62
|
|
|
63
63
|
// 2. CHECK BORROW COST
|
|
64
|
-
read.
|
|
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
|
|
|
@@ -76,7 +76,7 @@ write.account.create(
|
|
|
76
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
|
-
read.wallet.
|
|
79
|
+
read.wallet.allowances(
|
|
80
80
|
owner_address: <owner_wallet>,
|
|
81
81
|
spender_address: <account_address>,
|
|
82
82
|
token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], // USDC
|
|
@@ -102,25 +102,23 @@ write.account.add_liquidity(
|
|
|
102
102
|
chain_id: 8453
|
|
103
103
|
)
|
|
104
104
|
|
|
105
|
-
// 6.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
min_rebalance_time: 3600,
|
|
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
114
|
chain_id: 8453
|
|
115
115
|
)
|
|
116
|
-
// →
|
|
116
|
+
// → Returns { description, asset_managers, statuses, datas } for the rebalancer
|
|
117
117
|
|
|
118
|
-
// 7.
|
|
119
|
-
write.asset_manager.
|
|
120
|
-
account_address: <account_address>,
|
|
121
|
-
asset_manager_address: "0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6",
|
|
122
|
-
am_type: "merkl_operator",
|
|
118
|
+
// 7. ENCODE MERKL (if pool has Merkl incentives — check fee APY breakdown in step 1)
|
|
119
|
+
write.asset_manager.merkl_operator(
|
|
123
120
|
reward_recipient: <owner_wallet>,
|
|
121
|
+
enabled: true,
|
|
124
122
|
chain_id: 8453
|
|
125
123
|
)
|
|
126
124
|
```
|
|
@@ -147,7 +145,7 @@ instead of ~0.5–0.7. Increase position size for a healthier starting HF.
|
|
|
147
145
|
read.account.pnl(account_address: <account_address>, chain_id: 8453)
|
|
148
146
|
→ If net yield is consistently negative → evaluate exit
|
|
149
147
|
|
|
150
|
-
read.
|
|
148
|
+
read.pool.list(chain_id: 8453)
|
|
151
149
|
→ If borrow_APY risen above fee_APY → exit signal
|
|
152
150
|
```
|
|
153
151
|
|
|
@@ -156,13 +154,13 @@ read.pools(chain_id: 8453)
|
|
|
156
154
|
```
|
|
157
155
|
// Option A: Add collateral (raises health factor, cheapest)
|
|
158
156
|
// Check allowance first — skip approve if already sufficient
|
|
159
|
-
read.wallet.
|
|
157
|
+
read.wallet.allowances(owner_address: <wallet>, spender_address: <account>, token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], chain_id: 8453)
|
|
160
158
|
write.wallet.approve(token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", spender_address: <account>, amount: "max_uint256", chain_id: 8453)
|
|
161
159
|
write.account.deposit(account_address: <account>, asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], asset_amounts: ["<amount>"], chain_id: 8453)
|
|
162
160
|
|
|
163
161
|
// Option B: Repay some WETH debt (reduces leverage)
|
|
164
162
|
// NOTE: you must approve the WETH pool to spend WETH from your wallet first — check allowance, then approve if needed
|
|
165
|
-
read.wallet.
|
|
163
|
+
read.wallet.allowances(owner_address: <wallet>, spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", token_addresses: ["0x4200000000000000000000000000000000000006"], chain_id: 8453)
|
|
166
164
|
write.wallet.approve(token_address: "0x4200000000000000000000000000000000000006", spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", amount: "max_uint256", chain_id: 8453)
|
|
167
165
|
write.account.repay(
|
|
168
166
|
pool_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH pool
|
|
@@ -191,12 +189,12 @@ write.account.deleverage(
|
|
|
191
189
|
|
|
192
190
|
```
|
|
193
191
|
// 0. Disable automation first (prevents rebalancer from acting during close)
|
|
194
|
-
write.asset_manager.
|
|
195
|
-
|
|
196
|
-
asset_manager_address: "0x953Ff365d0b562ceC658dc46B394E9282338d9Ea",
|
|
192
|
+
write.asset_manager.rebalancer(
|
|
193
|
+
dex_protocol: "slipstream_v2",
|
|
197
194
|
enabled: false,
|
|
198
195
|
chain_id: 8453
|
|
199
196
|
)
|
|
197
|
+
// → Merge result into write.account.set_asset_managers(account_address: <account>, ...)
|
|
200
198
|
|
|
201
199
|
// 1. Get account state — need asset list for the close call
|
|
202
200
|
read.account.info(account_address: <account>, chain_id: 8453)
|
|
@@ -283,7 +281,7 @@ The `protocol_owned_liquidity` strategy type uses a dynamic range algorithm (k1/
|
|
|
283
281
|
// Same tools, different intent — no leverage, wider slippage tolerance
|
|
284
282
|
|
|
285
283
|
// 1. Check allowance + approve treasury tokens (skip approve if already sufficient)
|
|
286
|
-
read.wallet.
|
|
284
|
+
read.wallet.allowances(owner_address: <treasury_wallet>, spender_address: <account>, token_addresses: [<token>], chain_id: 8453)
|
|
287
285
|
write.wallet.approve(token_address: <token>, spender_address: <account>, amount: "max_uint256", chain_id: 8453)
|
|
288
286
|
|
|
289
287
|
// 2. Create account (separate from retail positions)
|
|
@@ -310,10 +308,9 @@ write.account.add_liquidity(
|
|
|
310
308
|
)
|
|
311
309
|
|
|
312
310
|
// 5. Enable rebalancer with POL strategy hook
|
|
313
|
-
write.asset_manager.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
am_type: "rebalancer",
|
|
311
|
+
write.asset_manager.rebalancer(
|
|
312
|
+
dex_protocol: <dex_protocol>, // e.g. "slipstream_v2", "uniV3"
|
|
313
|
+
enabled: true,
|
|
317
314
|
strategy_hook: "0x13beD1A58d87c0454872656c5328103aAe5eB86A", // POL dynamic range algorithm
|
|
318
315
|
trigger_lower_ratio: 0,
|
|
319
316
|
trigger_upper_ratio: 0,
|
|
@@ -321,6 +318,7 @@ write.asset_manager.configure(
|
|
|
321
318
|
min_rebalance_time: 3600,
|
|
322
319
|
chain_id: 8453
|
|
323
320
|
)
|
|
321
|
+
// → Pass result to write.account.set_asset_managers(account_address: <account>, ...)
|
|
324
322
|
// → POL tuning params (base_range, k1, k2, rebalance_threshold) configured in Arcadia platform
|
|
325
323
|
```
|
|
326
324
|
|