@arcadia-finance/mcp-server 0.1.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/LICENSE.md +97 -0
- package/README.md +186 -0
- package/dist/abis/account.json +1012 -0
- package/dist/abis/account_v4.json +1027 -0
- package/dist/abis/chainlink.json +509 -0
- package/dist/abis/erc20.json +299 -0
- package/dist/abis/factory.json +938 -0
- package/dist/abis/gauge_helper.json +84 -0
- package/dist/abis/index.js +26 -0
- package/dist/abis/mainreg.json +1172 -0
- package/dist/abis/nftmanager.json +1221 -0
- package/dist/abis/nftmanager_v4.json +1297 -0
- package/dist/abis/pool.json +2136 -0
- package/dist/abis/slipstream_nftmanager.json +1312 -0
- package/dist/abis/staked_aero_am.json +1220 -0
- package/dist/abis/staked_slipstream_am.json +1131 -0
- package/dist/abis/state_viewer.json +365 -0
- package/dist/abis/tranche.json +1004 -0
- package/dist/abis/wrapped_aero_am.json +1232 -0
- package/dist/abis/wrapped_staked_slipstream_am.json +338 -0
- package/dist/clients/api.js +189 -0
- package/dist/clients/chain.js +30 -0
- package/dist/config/addresses.js +94 -0
- package/dist/config/chains.js +31 -0
- package/dist/index.js +29 -0
- package/dist/skills/clamm-liquidity/SKILL.md +167 -0
- package/dist/skills/clamm-liquidity/automation.md +138 -0
- package/dist/skills/clamm-liquidity/selection.md +183 -0
- package/dist/skills/clamm-liquidity/strategies.md +337 -0
- package/dist/tools/advanced/account-metadata.js +46 -0
- package/dist/tools/advanced/add-liquidity.js +310 -0
- package/dist/tools/advanced/close-position.js +208 -0
- package/dist/tools/advanced/format-response.js +26 -0
- package/dist/tools/advanced/position-actions.js +95 -0
- package/dist/tools/advanced/remove-liquidity.js +68 -0
- package/dist/tools/advanced/repay-with-collateral.js +66 -0
- package/dist/tools/advanced/swap.js +64 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/read/accounts.js +243 -0
- package/dist/tools/read/allowances.js +86 -0
- package/dist/tools/read/assets.js +54 -0
- package/dist/tools/read/balances.js +93 -0
- package/dist/tools/read/guides.js +59 -0
- package/dist/tools/read/points.js +25 -0
- package/dist/tools/read/pools.js +48 -0
- package/dist/tools/read/protocol.js +94 -0
- package/dist/tools/write/approve.js +99 -0
- package/dist/tools/write/borrow.js +87 -0
- package/dist/tools/write/configure-asset-manager.js +258 -0
- package/dist/tools/write/create-account.js +112 -0
- package/dist/tools/write/deposit.js +104 -0
- package/dist/tools/write/repay.js +56 -0
- package/dist/tools/write/set-asset-manager.js +65 -0
- package/dist/tools/write/sign-and-send.js +90 -0
- package/dist/tools/write/withdraw.js +114 -0
- package/dist/types/api.js +5 -0
- package/dist/utils/attribution.js +20 -0
- package/dist/utils/validation.js +17 -0
- package/package.json +67 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
try {
|
|
3
|
+
const existing = { ...process.env };
|
|
4
|
+
process.loadEnvFile();
|
|
5
|
+
// MCP client env block takes precedence over .env
|
|
6
|
+
Object.assign(process.env, existing);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
// No .env file — expected in production / npx usage
|
|
10
|
+
}
|
|
11
|
+
import { createRequire } from "module";
|
|
12
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { ArcadiaApiClient } from "./clients/api.js";
|
|
15
|
+
import { getChainConfigs } from "./config/chains.js";
|
|
16
|
+
import { registerAllTools } from "./tools/index.js";
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const pkg = require("../package.json");
|
|
19
|
+
const server = new McpServer({
|
|
20
|
+
name: "arcadia-finance",
|
|
21
|
+
version: pkg.version,
|
|
22
|
+
description: "Arcadia Finance — manage concentrated liquidity positions with leverage, automated rebalancing, and yield optimization. Read protocol data and build unsigned transactions for LP management, borrowing, deposits, and more.",
|
|
23
|
+
});
|
|
24
|
+
const apiClient = new ArcadiaApiClient();
|
|
25
|
+
const chainConfigs = getChainConfigs();
|
|
26
|
+
registerAllTools(server, apiClient, chainConfigs);
|
|
27
|
+
const transport = new StdioServerTransport();
|
|
28
|
+
await server.connect(transport);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clamm-liquidity
|
|
3
|
+
description: Agent guide for clAMM management on Arcadia Finance. Covers 25 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
|
+
user-invokable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Arcadia Finance — clAMM Agent Guide
|
|
8
|
+
|
|
9
|
+
Arcadia is a platform for managing concentrated liquidity positions — with built-in leverage, automated rebalancing, compounding, and yield optimization. Positions live in Arcadia accounts, which can also borrow against their collateral. This skill covers everything needed to manage clAMM positions as an agent.
|
|
10
|
+
|
|
11
|
+
## Key Constraints
|
|
12
|
+
|
|
13
|
+
- **All `build_*_tx` tools return unsigned transactions** (`{ to, data, value, chainId }`) — you must sign and broadcast them. See "Transaction Signing" below.
|
|
14
|
+
- **Automation strategy config** (tick range, rebalance thresholds) is not currently settable via MCP — this requires Arcadia platform access.
|
|
15
|
+
- **Health factor** = `1 - (used_margin / liquidation_value)`. Higher is safer. `1` = no debt, `>0` = healthy, `0` = liquidation threshold, `<0` = past liquidation. Keep above 0.5 for leveraged positions; act immediately below 0.2.
|
|
16
|
+
- **Minimum margin** — each lending pool enforces a fixed minimum margin denominated in the pool's numeraire (e.g. WETH for the WETH pool, USDC for the USDC pool), typically a few dollars in value. This gets **added to the debt** when computing `used_margin` (i.e. `used_margin = open_debt + minimum_margin`). It ensures liquidations remain profitable (covering gas costs) and prevents dust attacks. For small positions the fixed minimum margin dominates the used margin, pushing health factor lower than the leverage ratio alone would suggest (e.g. HF ~0.3 at 2× leverage). Increase position size for a healthier starting HF. `build_add_liquidity_tx` also validates deposits against per-asset minimum amounts from strategy risk factors.
|
|
17
|
+
|
|
18
|
+
## Transaction Signing
|
|
19
|
+
|
|
20
|
+
Write and advanced tools (`build_*_tx`) return unsigned transaction calldata. This server does NOT sign or broadcast. After receiving a transaction object, you must:
|
|
21
|
+
|
|
22
|
+
1. **Sign** the transaction with the account owner's private key or wallet
|
|
23
|
+
2. **Broadcast** it to the appropriate chain (Base 8453, Optimism 10, or Unichain 130)
|
|
24
|
+
3. **Wait** for the transaction receipt to confirm success
|
|
25
|
+
|
|
26
|
+
How you sign depends on your setup:
|
|
27
|
+
|
|
28
|
+
- **MPC wallet** (Fireblocks, Dfns, Turnkey) — pass the unsigned tx to your provider's signing API
|
|
29
|
+
- **Smart account** (Safe, Biconomy) — wrap the tx as a UserOperation or Safe transaction
|
|
30
|
+
- **Embedded wallet** (Privy, Dynamic) — use the provider's `sendTransaction` method
|
|
31
|
+
- **Direct private key** (development only) — use the built-in `sign_and_send_tx` tool (set `PK` in a `.env` file or MCP client config), or viem/ethers `sendTransaction` with a local signer
|
|
32
|
+
|
|
33
|
+
Example with viem:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const hash = await walletClient.sendTransaction(tx);
|
|
37
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Batching Philosophy
|
|
41
|
+
|
|
42
|
+
Arcadia's flash-action tools can batch multiple DeFi operations into a single atomic transaction. **Always prefer batched tools** — they reduce transaction count, gas cost, and exposure to price movement between steps.
|
|
43
|
+
|
|
44
|
+
**When to split:** In high-volatility markets or for low-liquidity pools, batched transactions may revert because on-chain state changes between when the backend computes calldata and when the transaction executes. If a batched tool fails, fall back to individual tools with tighter slippage. Always try batched first, split only on failure.
|
|
45
|
+
|
|
46
|
+
**All advanced tools 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
|
+
|
|
48
|
+
## MCP Tools (25 + 1 dev)
|
|
49
|
+
|
|
50
|
+
### Read Tools
|
|
51
|
+
|
|
52
|
+
| Tool | When to use |
|
|
53
|
+
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| `get_account_info` | Account overview + liquidation price. Pass `account_address` for detail (returns positions with `asset_address`/`asset_id`, collateral, debt) or `wallet_address` to list accounts. |
|
|
55
|
+
| `get_account_history` | Historical account value over time. Optional `days` param (default 14). |
|
|
56
|
+
| `get_account_pnl` | PnL and yield earned — use to check if a strategy is still profitable. |
|
|
57
|
+
| `get_assets` | Supported collateral assets with prices. Pass `asset_addresses` (single or comma-separated) for price lookup. |
|
|
58
|
+
| `get_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
|
+
| `get_allowance` | Check ERC20 token allowances for a spender. Use before `build_approve_tx` to avoid redundant approvals — skip if the current allowance is already sufficient. |
|
|
60
|
+
| `get_lending_pools` | Pool TVL, APY, utilization, liquidity. Pass `pool_address` for detail + APY history (optional `days`, default 14). |
|
|
61
|
+
| `get_strategies` | 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
|
+
| `get_points` | Points for a wallet or leaderboard. No `chain_id` needed — points are cross-chain. |
|
|
63
|
+
| `get_recommendation` | Rebalancing recommendation for an account. Uses 1d APY (not 7d like `get_strategies`), so numbers may differ. |
|
|
64
|
+
| `get_guide` | Reference guides: `automation` (AM setup), `selection` (pool evaluation), `strategies` (step-by-step templates). |
|
|
65
|
+
|
|
66
|
+
### Preferred Write Tools (atomic/multi-step — use these first)
|
|
67
|
+
|
|
68
|
+
These tools batch multiple operations into ONE atomic transaction. Always prefer these over individual tools.
|
|
69
|
+
|
|
70
|
+
| Tool | Batches | When to use |
|
|
71
|
+
| ---------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `build_add_liquidity_tx` | deposit + swap + mint LP + optional borrow | Open LP position. Do NOT call `build_deposit_tx` separately — this handles wallet transfer atomically. |
|
|
73
|
+
| `build_close_position_tx` | burn LP + swap + repay debt (up to 3 steps) | Close/exit a position. ALWAYS try this first. Tokens stay in account — follow up with `build_withdraw_tx`. |
|
|
74
|
+
| `build_repay_with_collateral_tx` | swap collateral + repay debt | Repay debt using account collateral (no wallet tokens needed). Preferred for health factor fixes. |
|
|
75
|
+
| `build_configure_asset_manager_tx` | grant permission + set initiator/fees/strategy params | Enable AND configure an automation (rebalancer, compounder, yield claimer, merkl) in one transaction. |
|
|
76
|
+
|
|
77
|
+
### Individual Write Tools (use when batched tools fail or for standalone operations)
|
|
78
|
+
|
|
79
|
+
| Tool | When to use |
|
|
80
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
81
|
+
| `build_approve_tx` | Approve a token for spending. **Required before `build_deposit_tx`** and before `build_add_liquidity_tx` (when depositing from wallet). Call `get_allowance` first to check if already approved. |
|
|
82
|
+
| `build_create_account_tx` | Create a new Arcadia account (one-time setup). Use `account_version: 0` for the latest version (recommended). |
|
|
83
|
+
| `build_deposit_tx` | Deposit ERC20 tokens as collateral. NOT needed before `build_add_liquidity_tx` — that tool handles deposits atomically. |
|
|
84
|
+
| `build_withdraw_tx` | 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
|
+
| `build_borrow_tx` | Borrow from a lending pool. NOT needed for leveraged LP — `build_add_liquidity_tx` handles borrowing internally. |
|
|
86
|
+
| `build_repay_tx` | Repay debt from wallet (approve pool first). Use `amount: "max_uint256"` to repay in full. For repaying with account collateral, prefer `build_repay_with_collateral_tx`. |
|
|
87
|
+
| `build_swap_tx` | Swap assets within account (backend handles routing). For closing positions, prefer `build_close_position_tx`. |
|
|
88
|
+
| `build_remove_liquidity_tx` | PARTIAL liquidity decrease only (position stays open). For full LP removal/exit, use `build_close_position_tx`. |
|
|
89
|
+
| `build_position_action_tx` | Stake, unstake, or claim rewards for an LP position. Direction auto-detected from `asset_address`. |
|
|
90
|
+
| `build_set_asset_manager_tx` | Grant/revoke AM permission only (no configuration). Use to revoke; for full setup prefer `build_configure_asset_manager_tx`. |
|
|
91
|
+
|
|
92
|
+
### Dev Tools (only available when `PK` env var is set)
|
|
93
|
+
|
|
94
|
+
| Tool | When to use |
|
|
95
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| `sign_and_send_tx` | Sign and broadcast an unsigned transaction using a local private key. Pass the `{ to, data, value, chainId }` from any `build_*_tx` tool. **Not for production** — use a dedicated wallet MCP server (Fireblocks, Safe, Turnkey, etc.) instead. |
|
|
97
|
+
|
|
98
|
+
## Token Addresses (Base 8453)
|
|
99
|
+
|
|
100
|
+
| Token | Address | Decimals |
|
|
101
|
+
| ----- | -------------------------------------------- | -------- |
|
|
102
|
+
| WETH | `0x4200000000000000000000000000000000000006` | 18 |
|
|
103
|
+
| USDC | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | 6 |
|
|
104
|
+
| cbBTC | `0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf` | 8 |
|
|
105
|
+
| AERO | `0x940181a94A35A4569E4529A3CDfB74e38FD98631` | 18 |
|
|
106
|
+
| AAA | `0xaaa843fb2916c0B57454270418E121C626402AAa` | 18 |
|
|
107
|
+
| stAAA | `0xDeA1531d8a1505785eb517C7A28526443df223F3` | 18 |
|
|
108
|
+
|
|
109
|
+
**Wrapping ETH:** ETH must be wrapped to WETH before depositing. Call WETH's `deposit()` function (payable) with the ETH amount. No MCP tool for this — use your wallet.
|
|
110
|
+
|
|
111
|
+
## Contract Addresses (Base 8453)
|
|
112
|
+
|
|
113
|
+
| Contract | Address |
|
|
114
|
+
| -------- | -------------------------------------------- |
|
|
115
|
+
| Factory | `0xDa14Fdd72345c4d2511357214c5B89A919768e59` |
|
|
116
|
+
|
|
117
|
+
**`asset_id`** is always an integer (NFT token ID for LP positions, 0 for ERC20 tokens).
|
|
118
|
+
|
|
119
|
+
## Lending Pool Addresses (Base 8453)
|
|
120
|
+
|
|
121
|
+
Use as `pool_address` in `build_borrow_tx` / `build_repay_tx`, as `creditor` in `build_create_account_tx` / `build_repay_with_collateral_tx`:
|
|
122
|
+
|
|
123
|
+
| Asset | Pool Address |
|
|
124
|
+
| ----- | -------------------------------------------- |
|
|
125
|
+
| WETH | `0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2` |
|
|
126
|
+
| USDC | `0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1` |
|
|
127
|
+
| cbBTC | `0xa37E9b4369dc20940009030BfbC2088F09645e3B` |
|
|
128
|
+
|
|
129
|
+
## Asset Manager Addresses (Base 8453)
|
|
130
|
+
|
|
131
|
+
Use with `build_configure_asset_manager_tx` (enable + configure) or `build_set_asset_manager_tx` (grant/revoke only). Both require V3/V4 accounts.
|
|
132
|
+
|
|
133
|
+
| Type | Protocol | Address |
|
|
134
|
+
| -------------- | ------------- | -------------------------------------------- |
|
|
135
|
+
| Rebalancer | Slipstream V1 | `0x5802454749cc0c4A6F28D5001B4cD84432e2b79F` |
|
|
136
|
+
| Rebalancer | Slipstream V2 | `0x953Ff365d0b562ceC658dc46B394E9282338d9Ea` |
|
|
137
|
+
| Rebalancer | Uniswap V3 | `0xbA1D0c99c261F94b9C8b52465890Cca27dd993Bd` |
|
|
138
|
+
| Rebalancer | Uniswap V4 | `0x01EDaF0067a10D18c88D2876c0A85Ee0096a5Ac0` |
|
|
139
|
+
| Compounder | Slipstream V1 | `0x467837f44A71e3eAB90AEcfC995c84DC6B3cfCF7` |
|
|
140
|
+
| Compounder | Slipstream V2 | `0x35e59448C7145482E56212510cC689612AB4F61f` |
|
|
141
|
+
| Compounder | Uniswap V3 | `0x02e1fa043214E51eDf1F0478c6D0d3D5658a2DC3` |
|
|
142
|
+
| Compounder | Uniswap V4 | `0xAA95c9c402b195D8690eCaea2341a76e3266B189` |
|
|
143
|
+
| Yield Claimer | Slipstream V1 | `0x5a8278D37b7a787574b6Aa7E18d8C02D994f18Ba` |
|
|
144
|
+
| Yield Claimer | Slipstream V2 | `0xc8bF4B2c740FF665864E9494832520f18822871C` |
|
|
145
|
+
| Yield Claimer | Uniswap V3 | `0x75Ed28EA8601Ce9F5FbcAB1c2428f04A57aFaA16` |
|
|
146
|
+
| Yield Claimer | Uniswap V4 | `0xD8aa21AB7f9B8601CB7d7A776D3AFA1602d5D8D4` |
|
|
147
|
+
| Merkl Operator | All | `0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6` |
|
|
148
|
+
| CoW Swapper | All | `0xc928013A219EC9F18dE7B2dee6A50Ba626811854` |
|
|
149
|
+
| Gas Relayer | All | `0xD938C8d04cF91094fecAF0A2018EAac483a40137` |
|
|
150
|
+
|
|
151
|
+
**Slipstream V1 vs V2:** The pool determines the version — some pools are V1, some are V2. The API currently returns `protocol: "slipstream"` without V1/V2 distinction. To identify the version, check the position manager address from `get_account_info` against the known addresses (V1: `0x8279...`, V2: `0xa990...`). Alternatively, pass `pool_protocol` directly to `build_configure_asset_manager_tx` to auto-resolve the correct AM address. Staked and wrapped staked positions use the same asset managers as their base protocol.
|
|
152
|
+
|
|
153
|
+
## Account Versions
|
|
154
|
+
|
|
155
|
+
Spot vs margin is determined by whether a **creditor** (lending pool) is set at account creation, not by version number.
|
|
156
|
+
|
|
157
|
+
- `account_version: 3` — **margin account** (created with a `creditor`). Can borrow, leverage, and mint LP. Uses an onchain whitelist of allowed collateral tokens.
|
|
158
|
+
- `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 (`build_set_asset_manager_tx` and `build_configure_asset_manager_tx` require V3/V4).
|
|
160
|
+
- For **leveraged LP strategies**, use `account_version: 3` with a creditor.
|
|
161
|
+
- To check an existing account's version: call `get_account_info` — the response includes the account version.
|
|
162
|
+
|
|
163
|
+
## Reference Files
|
|
164
|
+
|
|
165
|
+
- [automation.md](automation.md) — How to enable each automation type
|
|
166
|
+
- [selection.md](selection.md) — How to evaluate pools, choose range width, size leverage, combine automation
|
|
167
|
+
- [strategies.md](strategies.md) — Step-by-step strategy templates: delta neutral LP and protocol-owned liquidity
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Automation Setup
|
|
2
|
+
|
|
3
|
+
All automation on Arcadia uses one of two tools (both V3/V4 accounts only), then Arcadia's backend bots do the work.
|
|
4
|
+
|
|
5
|
+
## Which tool to use
|
|
6
|
+
|
|
7
|
+
**To enable + configure (recommended):** Use `build_configure_asset_manager_tx`. 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 `build_set_asset_manager_tx`. This only grants or revokes permission — no configuration. Use this to revoke an asset manager.
|
|
10
|
+
|
|
11
|
+
## Configure + enable
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
build_configure_asset_manager_tx(
|
|
15
|
+
account_address: <account>,
|
|
16
|
+
asset_manager_address: <address from table below>,
|
|
17
|
+
am_type: "rebalancer" | "compounder" | "yield_claimer" | "merkl_operator",
|
|
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
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Grant/revoke only
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
build_set_asset_manager_tx(
|
|
36
|
+
account_address: <account>,
|
|
37
|
+
asset_manager_address: <address from table below>,
|
|
38
|
+
enabled: true, // false to revoke
|
|
39
|
+
chain_id: 8453
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To revoke any AM: `build_set_asset_manager_tx(..., enabled: false)` or `build_configure_asset_manager_tx` is not used for revocation — use `build_set_asset_manager_tx` with `enabled: false`.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Rebalancer
|
|
48
|
+
|
|
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. As part of every rebalance, the old position is burned and all pending fees and staking rewards are claimed — these are automatically compounded into the new position. The rebalancer therefore also acts as a compounder at every rebalance event.
|
|
50
|
+
|
|
51
|
+
**Which address:** Match to your LP protocol (Base):
|
|
52
|
+
|
|
53
|
+
| Protocol | Address |
|
|
54
|
+
| ----------------------- | -------------------------------------------- |
|
|
55
|
+
| Aerodrome Slipstream V1 | `0x5802454749cc0c4A6F28D5001B4cD84432e2b79F` |
|
|
56
|
+
| Aerodrome Slipstream V2 | `0x953Ff365d0b562ceC658dc46B394E9282338d9Ea` |
|
|
57
|
+
| Uniswap V3 | `0xbA1D0c99c261F94b9C8b52465890Cca27dd993Bd` |
|
|
58
|
+
| Uniswap V4 | `0x01EDaF0067a10D18c88D2876c0A85Ee0096a5Ac0` |
|
|
59
|
+
|
|
60
|
+
**Free rebalance quota (per owner across all accounts):**
|
|
61
|
+
|
|
62
|
+
| stAAA held | Daily | Weekly |
|
|
63
|
+
| ---------- | ----- | ------ |
|
|
64
|
+
| 0 | 1 | 3 |
|
|
65
|
+
| 3,000 | 2 | 10 |
|
|
66
|
+
| 6,000 | 3 | 17 |
|
|
67
|
+
| 9,000 | 4 | 24 |
|
|
68
|
+
| 30,000 | 11 | 73 |
|
|
69
|
+
|
|
70
|
+
Quota is also bypassed automatically when: gas cost < pending fees ÷ 2, or position value ≥ $50k.
|
|
71
|
+
|
|
72
|
+
**Pay for extra rebalances with AAA:** Deposit AAA tokens into the account, then approve them to the gas relayer `0xD938C8d04cF91094fecAF0A2018EAac483a40137`. Each rebalance consumes AAA proportional to gas cost.
|
|
73
|
+
|
|
74
|
+
**Fees:** 7.5% of yield earned, max 1% liquidity decrease per rebalance (MDL).
|
|
75
|
+
|
|
76
|
+
**`strategy_hook`** (optional): For POL, pass `strategy_hook: "0x13beD1A58d87c0454872656c5328103aAe5eB86A"` to use the dynamic range algorithm. Omit for standard rebalancer behavior.
|
|
77
|
+
|
|
78
|
+
**Strategy config:** Range width and reposition mode are configured in the Arcadia platform after enabling the rebalancer — not settable via MCP.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Compounder
|
|
83
|
+
|
|
84
|
+
**What it does:** Bot claims accumulated LP fees and reinvests them back into the position (compound interest instead of cash flow).
|
|
85
|
+
|
|
86
|
+
**Which address (Base):**
|
|
87
|
+
|
|
88
|
+
| Protocol | Address |
|
|
89
|
+
| ----------------------- | -------------------------------------------- |
|
|
90
|
+
| Aerodrome Slipstream V1 | `0x467837f44A71e3eAB90AEcfC995c84DC6B3cfCF7` |
|
|
91
|
+
| Aerodrome Slipstream V2 | `0x35e59448C7145482E56212510cC689612AB4F61f` |
|
|
92
|
+
| Uniswap V3 | `0x02e1fa043214E51eDf1F0478c6D0d3D5658a2DC3` |
|
|
93
|
+
| Uniswap V4 | `0xAA95c9c402b195D8690eCaea2341a76e3266B189` |
|
|
94
|
+
|
|
95
|
+
**When to add a compounder on top of a rebalancer:** The rebalancer compounds fees at rebalance time. Adding a compounder also compounds fees between rebalances — more frequent compounding, higher effective APY.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Yield Claimer
|
|
100
|
+
|
|
101
|
+
**What it does:** Bot periodically claims pending fees/emissions and sends them to a designated recipient (owner wallet, another account, or any address).
|
|
102
|
+
|
|
103
|
+
**Which address (Base):**
|
|
104
|
+
|
|
105
|
+
| Protocol | Address |
|
|
106
|
+
| ----------------------- | -------------------------------------------- |
|
|
107
|
+
| Aerodrome Slipstream V1 | `0x5a8278D37b7a787574b6Aa7E18d8C02D994f18Ba` |
|
|
108
|
+
| Aerodrome Slipstream V2 | `0xc8bF4B2c740FF665864E9494832520f18822871C` |
|
|
109
|
+
| Uniswap V3 | `0x75Ed28EA8601Ce9F5FbcAB1c2428f04A57aFaA16` |
|
|
110
|
+
| Uniswap V4 | `0xD8aa21AB7f9B8601CB7d7A776D3AFA1602d5D8D4` |
|
|
111
|
+
|
|
112
|
+
**Recipient config:** Set `fee_recipient` in `build_configure_asset_manager_tx` (V3/V4 accounts). Pass your wallet address or any destination address.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Merkl Operator
|
|
117
|
+
|
|
118
|
+
**What it does:** Bot claims external Merkl protocol incentive rewards into the account. These are additional rewards paid by token teams on top of regular LP fees — completely separate from trading fee yield.
|
|
119
|
+
|
|
120
|
+
**When to enable:** When the pool you LP into has active Merkl campaigns. Check by looking at the pool APY breakdown in `get_strategies` — if there's a "Merkl" or "external rewards" component, enable this.
|
|
121
|
+
|
|
122
|
+
**Address:**
|
|
123
|
+
|
|
124
|
+
**Address (all chains):** `0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6`
|
|
125
|
+
|
|
126
|
+
**Always combine with rebalancer** when both are relevant — no conflict, extra free yield.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## CoW Swapper
|
|
131
|
+
|
|
132
|
+
**What it does:** Bot places CoW Protocol batch auction swap orders to sell tokens accumulated in the account (e.g., claimed AERO emissions → USDC). Uses MEV-protected execution via CoW's batch auction mechanism.
|
|
133
|
+
|
|
134
|
+
**Address (Base):** `0xc928013A219EC9F18dE7B2dee6A50Ba626811854`
|
|
135
|
+
|
|
136
|
+
**Config:** Which tokens to sell and what to buy is configured in the Arcadia platform — not settable via MCP.
|
|
137
|
+
|
|
138
|
+
**Use case:** When using a yield claimer to collect emissions in a volatile token, pair it with the CoW Swapper to automatically convert those tokens into a stablecoin or preferred asset.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Strategy Selection & Parameterization
|
|
2
|
+
|
|
3
|
+
Use this guide to evaluate whether a strategy makes sense and how to configure it. Apply to any LP strategy — not just the delta neutral example in strategies.md.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Pool / Strategy Selection
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
get_strategies(chain_id: 8453) // browse all LP strategies + fee APY
|
|
11
|
+
get_lending_pools(chain_id: 8453) // check borrow cost for leveraged strategies
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Viability check (leveraged):**
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
net_APY = fee_APY - (leverage - 1) × borrow_APY
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Must be positive to justify the leverage cost. Higher leverage amplifies both sides.
|
|
21
|
+
|
|
22
|
+
**Pair type guidance:**
|
|
23
|
+
|
|
24
|
+
| Pair Type | Example | IL Risk | Leverage Fit | Range |
|
|
25
|
+
| ------------------- | ---------- | -------- | -------------------- | --------- |
|
|
26
|
+
| Volatile / Stable | WETH/USDC | High | Good (delta neutral) | Medium |
|
|
27
|
+
| Correlated volatile | cbBTC/WETH | Moderate | Moderate | Wider |
|
|
28
|
+
| Stable / Stable | USDC/USDT | Very low | Low value | Very wide |
|
|
29
|
+
| Same asset | wstETH/ETH | Minimal | Low value | Tight |
|
|
30
|
+
|
|
31
|
+
**Other signals to check:**
|
|
32
|
+
|
|
33
|
+
- Fee tier: higher fee tier (0.3%, 1%) = more fee per trade, better for volatile pairs
|
|
34
|
+
- Volume + TVL: high volume/TVL ratio = fees are being earned actively
|
|
35
|
+
- Active Merkl rewards: extra yield on top, check `get_strategies` APY breakdown
|
|
36
|
+
|
|
37
|
+
**`numeraire` — context-dependent meaning:**
|
|
38
|
+
|
|
39
|
+
- **`build_add_liquidity_tx`**: `numeraire` = account base currency (typically the stable side, e.g. USDC for a WETH/USDC position). The backend uses it to denominate calculations and determine the optimal swap ratio. For WETH/USDC: `numeraire = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` (USDC).
|
|
40
|
+
- **`build_repay_with_collateral_tx`**: `numeraire` = the debt token you're repaying (e.g. WETH address when repaying WETH debt). This differs from the add liquidity usage.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Range Width
|
|
45
|
+
|
|
46
|
+
Range width is the central tradeoff in any LP strategy. It is set in the Arcadia platform after enabling the rebalancer. Understanding the full tradeoff is essential for choosing parameters — a simple fee APY comparison is not enough.
|
|
47
|
+
|
|
48
|
+
**Core principle:** The `strategy_apy` from `get_strategies` (list view) is the 7-day average APY computed for that strategy's **default range width** (configured per strategy — e.g. very narrow for stables, ±7.5% / balanced for most volatile pairs). It is sampled every ~3 hours and averaged over 7d. It already reflects a concentrated range — NOT a full-range / pool-level number. Choosing a different range width changes your actual yield: narrower = higher fee capture but more rebalancing cost/risk, wider = lower fees but fewer rebalances. Call `get_strategies(strategy_id: <id>)` to see APY broken down by range width (very_narrow, narrow, balanced, wide, very_wide, full_range). The net return after rebalancing costs, IL, and gas determines the optimal width — see the model below.
|
|
49
|
+
|
|
50
|
+
### The full tradeoff
|
|
51
|
+
|
|
52
|
+
**Narrower range → higher fee capture, but three compounding costs:**
|
|
53
|
+
|
|
54
|
+
1. **Delta risk:** A narrow position changes composition rapidly as price moves. A WETH/USDC position that was 50/50 quickly becomes 100% WETH or 100% USDC when price moves even slightly. Your net exposure to the volatile asset fluctuates heavily — you are not truly delta neutral across the range.
|
|
55
|
+
|
|
56
|
+
2. **IL crystallized per rebalance:** Every rebalance permanently locks in accumulated impermanent loss. It doesn't disappear by rebalancing — it gets realized. More frequent rebalancing means more IL crystallized over time.
|
|
57
|
+
|
|
58
|
+
3. **Rebalancing costs:** Each rebalance incurs gas costs plus swap slippage (the rebalancer must swap tokens to re-establish the target ratio for the new range). For small or low-fee positions, rebalancing costs can easily exceed earned fees.
|
|
59
|
+
|
|
60
|
+
**Wider range → lower fee capture, but lower compounding costs:**
|
|
61
|
+
|
|
62
|
+
- Position stays in range longer → fewer rebalances → less IL crystallized, lower costs
|
|
63
|
+
- Delta exposure is spread over a wider price band → composition changes slowly
|
|
64
|
+
- Suitable when rebalancing quota is limited (few stAAA, no AAA to pay gas)
|
|
65
|
+
|
|
66
|
+
### Model-based parameter selection (recommended)
|
|
67
|
+
|
|
68
|
+
Rather than guessing range width, build a simple expected value model using market data:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
expected_net_return =
|
|
72
|
+
fee_APY × (time_in_range_fraction)
|
|
73
|
+
− rebalance_frequency × (gas_cost_per_rebalance + slippage_cost_per_rebalance)
|
|
74
|
+
− IL_rate × rebalance_frequency
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Inputs to estimate from market data:
|
|
78
|
+
|
|
79
|
+
- **time_in_range_fraction**: given the pool's historical volatility, how often does price stay within ±X% of the current price? Use `get_strategies` APY + historical vol data.
|
|
80
|
+
- **rebalance_frequency**: how many rebalances per day does the chosen range width require? Wider range = fewer rebalances.
|
|
81
|
+
- **gas_cost_per_rebalance**: check current chain gas price × ~4M units per rebalance.
|
|
82
|
+
- **IL_rate**: IL as a function of how far price moved before the rebalance; wider ranges accumulate less IL per rebalance.
|
|
83
|
+
|
|
84
|
+
Vary range width in the model and pick the width that maximizes expected net return for the current market regime. Reassess if volatility regime changes.
|
|
85
|
+
|
|
86
|
+
**Practical reference (starting point only):**
|
|
87
|
+
|
|
88
|
+
| Range Width | Fee Multiplier | Rebalance Frequency (volatile pair) |
|
|
89
|
+
| -------------- | ------------------ | ----------------------------------- |
|
|
90
|
+
| Narrow ±2–5% | Very high (10–50×) | Potentially multiple per day |
|
|
91
|
+
| Medium ±10–20% | Moderate (3–10×) | Every few days in normal markets |
|
|
92
|
+
| Wide ±30–50% | Low (1.5–3×) | Weekly or less |
|
|
93
|
+
|
|
94
|
+
**Decision shortcuts:**
|
|
95
|
+
|
|
96
|
+
- **Limited stAAA quota** (1 free rebalance/day) → wider range to avoid burning quota
|
|
97
|
+
- **High stAAA holdings** (≥9,000) → can sustain narrower range with the increased quota
|
|
98
|
+
- **Large position (≥$50k)** → automatically bypasses rate limits; narrower range viable
|
|
99
|
+
- **POL / capital preservation** → use wider range or dynamic POL algorithm. See strategies.md.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 3. Leverage Sizing
|
|
104
|
+
|
|
105
|
+
Leverage multiplies both fee income and liquidation risk.
|
|
106
|
+
|
|
107
|
+
| Leverage | Use case | Collateral ratio at entry | Health factor at entry |
|
|
108
|
+
| ----------------------------- | ------------------------------------------- | ------------------------- | ---------------------- |
|
|
109
|
+
| 1× (no borrow, `leverage: 0`) | Safe LP, no liquidation risk | N/A | 1.0 (no debt) |
|
|
110
|
+
| 2× | Classic delta neutral, volatile/stable pair | ~1.5–2× | ~0.5–0.7 |
|
|
111
|
+
| 3×+ | Aggressive yield, only in stable conditions | < 1.5× — watch carefully | < 0.5 — watch closely |
|
|
112
|
+
|
|
113
|
+
**Minimum margin and small positions:** Each lending pool enforces a fixed minimum margin denominated in the pool's numeraire (e.g. WETH, USDC, cbBTC), typically a few dollars in value. This gets added to the debt in the health factor formula: `used_margin = open_debt + minimum_margin`. It ensures liquidations remain profitable (gas costs) and prevents dust attacks. For small positions, this fixed overhead dominates used margin, pushing health factor lower than the leverage ratio alone would suggest — e.g. 2× leverage normally targets HF ~0.5–0.7, but a small position might start at HF ~0.3. Increase position size for a healthier starting HF.
|
|
114
|
+
|
|
115
|
+
**Profitability check:**
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
borrow_APY × (leverage - 1) < fee_APY × leverage → leverage is profitable
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Two safety metrics — collateral ratio vs health factor:**
|
|
122
|
+
|
|
123
|
+
The API returns `health_factor = 1 - (used_margin / liquidation_value)`. This is between 0 and 1: higher is safer. `1` = no debt, `0` = liquidation threshold. See SKILL.md Key Constraints.
|
|
124
|
+
|
|
125
|
+
A useful complementary metric is the **collateral ratio** — a rough estimate of how much buffer you have:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
collateral_value × collateral_factor
|
|
129
|
+
───────────────────────────────────── ≈ collateral ratio
|
|
130
|
+
debt_value
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Target collateral ratio ≥ 1.5 at entry (≈ health factor ~0.5+). Never open below 1.3 (≈ health factor ~0.3).
|
|
134
|
+
|
|
135
|
+
**When to use less leverage:**
|
|
136
|
+
|
|
137
|
+
- Borrow APY rising (utilization climbing in lending pool)
|
|
138
|
+
- Market showing high volatility (gap risk)
|
|
139
|
+
- Position already near support/resistance — a breakout would spike debt fast
|
|
140
|
+
- Health factor dropping toward 0.5 (check with `get_account_info`)
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 4. Combining Automation
|
|
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. |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 5. Exit Signals
|
|
157
|
+
|
|
158
|
+
Monitor periodically with `get_account_info` and `get_account_pnl`. Exit or adjust when:
|
|
159
|
+
|
|
160
|
+
| Signal | Threshold | Action |
|
|
161
|
+
| -------------------------------- | ----------------------- | ------------------------------------- |
|
|
162
|
+
| Borrow APY > fee APY | Persists 3+ checks | Exit strategy — no longer profitable |
|
|
163
|
+
| Health factor falling | < 0.5 | Add collateral or reduce debt |
|
|
164
|
+
| Health factor critical | < 0.2 | Immediate action required |
|
|
165
|
+
| Position out-of-range repeatedly | Bot can't keep up | Widen range or reduce leverage |
|
|
166
|
+
| Net PnL negative over time | Check `get_account_pnl` | Evaluate whether IL is outpacing fees |
|
|
167
|
+
|
|
168
|
+
**Closing in volatile conditions:** Atomic close (`build_close_position_tx`) may revert during high volatility or for low-liquidity pools because on-chain state diverges from when the backend computed the calldata. If atomic close fails, fall back to individual tools with tighter slippage — see strategies.md closing section for the full fallback sequence.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 6. Quick Checklist Before Opening a Position
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
[ ] get_strategies → fee_APY noted (7d avg for default range; call with strategy_id for per-range APY)
|
|
176
|
+
[ ] get_lending_pools → borrow_APY noted (if leveraged)
|
|
177
|
+
[ ] net_APY = fee_APY - (leverage-1) × borrow_APY > 0
|
|
178
|
+
[ ] Pair type matches strategy (volatile/stable for delta neutral)
|
|
179
|
+
[ ] Range width: modeled or estimated for pair volatility + stAAA quota
|
|
180
|
+
[ ] Leverage targets collateral ratio ≥ 1.5 at entry (health factor ≥ 0.5)
|
|
181
|
+
[ ] Merkl rewards active? → plan to enable Merkl Operator
|
|
182
|
+
[ ] Prefer compounding or cash flow? → Compounder vs. Yield Claimer
|
|
183
|
+
```
|