@arcadia-finance/mcp-server 0.6.1 → 0.7.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/LICENSE.md +249 -248
- package/README.md +152 -95
- package/dist/clients/chain.js +3 -3
- package/dist/config/cache-hints.js +10 -0
- package/dist/index.js +2 -1
- package/dist/prompts/workflows.js +2 -2
- package/dist/tools/dev/send.js +5 -19
- package/dist/tools/read/asset-managers.js +3 -8
- package/dist/tools/read/assets.js +1 -1
- package/dist/tools/read/strategy.js +3 -3
- package/dist/tools/read/wallet.js +1 -1
- package/llms-full.txt +5 -5
- package/llms.txt +3 -3
- package/package.json +21 -18
- package/server.json +9 -2
- package/skills/clamm-liquidity/SKILL.md +45 -43
- package/skills/clamm-liquidity/selection.md +24 -27
- package/skills/clamm-liquidity/strategies.md +29 -30
- package/skills/openclaw/SKILL.md +0 -104
- package/skills/openclaw/arcadia.sh +0 -80
- package/skills/openclaw/contracts.md +0 -66
- package/skills/openclaw/wallet-signing.md +0 -11
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcadia-finance/mcp-server",
|
|
3
3
|
"mcpName": "io.github.arcadia-finance/mcp-server",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "MCP server for Arcadia Finance. Deploy concentrated liquidity on Uniswap/Aero, Aerodrome and Velodrome with automated rebalancing, compounding, yield optimization, and leverage, or single-sided liquidity into lending pools. Base, Optimism, Unichain and Robinhood.",
|
|
4
|
+
"version": "0.7.1",
|
|
5
|
+
"description": "MCP server for Arcadia Finance. Deploy concentrated liquidity on Uniswap/Aero, Aerodrome and Velodrome with automated rebalancing, compounding, yield optimization, and leverage, or single-sided liquidity into lending pools. Live on Base, Optimism, Unichain and Robinhood.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"packageManager": "yarn@4.13.0",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"slipstream",
|
|
28
28
|
"base",
|
|
29
29
|
"unichain",
|
|
30
|
+
"optimism",
|
|
31
|
+
"robinhood",
|
|
30
32
|
"ethereum",
|
|
31
33
|
"leverage",
|
|
32
34
|
"yield-farming",
|
|
@@ -67,27 +69,28 @@
|
|
|
67
69
|
"access": "public"
|
|
68
70
|
},
|
|
69
71
|
"dependencies": {
|
|
70
|
-
"@modelcontextprotocol/node": "^2.1.
|
|
71
|
-
"@modelcontextprotocol/server": "^2.
|
|
72
|
-
"express": "^5.
|
|
73
|
-
"express-rate-limit": "^8.3
|
|
74
|
-
"posthog-node": "5.
|
|
75
|
-
"viem": "^2.
|
|
72
|
+
"@modelcontextprotocol/node": "^2.1.2",
|
|
73
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
74
|
+
"express": "^5.3.0",
|
|
75
|
+
"express-rate-limit": "^8.7.3",
|
|
76
|
+
"posthog-node": "5.63.2",
|
|
77
|
+
"viem": "^2.57.17",
|
|
76
78
|
"zod": "^4.2.0"
|
|
77
79
|
},
|
|
78
80
|
"devDependencies": {
|
|
79
|
-
"@eslint/js": "^
|
|
80
|
-
"@modelcontextprotocol/client": "^2.
|
|
81
|
+
"@eslint/js": "^10",
|
|
82
|
+
"@modelcontextprotocol/client": "^2.4.0",
|
|
81
83
|
"@types/express": "^5.0.6",
|
|
82
84
|
"@types/node": "^22.0.0",
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
84
|
-
"@typescript-eslint/parser": "^8.
|
|
85
|
-
"eslint": "^
|
|
86
|
-
"eslint-config-prettier": "^10.
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
|
86
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
87
|
+
"eslint": "^10",
|
|
88
|
+
"eslint-config-prettier": "^10.1.8",
|
|
87
89
|
"prettier": "^3.0.0",
|
|
88
|
-
"tsx": "^4.
|
|
89
|
-
"typescript": "
|
|
90
|
-
"typescript-eslint": "^8.
|
|
91
|
-
"
|
|
90
|
+
"tsx": "^4.23.15",
|
|
91
|
+
"typescript": "~6.0.3",
|
|
92
|
+
"typescript-eslint": "^8.72.1",
|
|
93
|
+
"vite": "^8.3.6",
|
|
94
|
+
"vitest": "^5.1.0"
|
|
92
95
|
}
|
|
93
96
|
}
|
package/server.json
CHANGED
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
"name": "io.github.arcadia-finance/mcp-server",
|
|
4
4
|
"title": "Arcadia Finance",
|
|
5
5
|
"description": "Concentrated liquidity on Uniswap/Aero (rebalance, compound, leverage) or single-sided lending.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.7.1",
|
|
7
7
|
"websiteUrl": "https://arcadia.finance",
|
|
8
|
+
"icons": [
|
|
9
|
+
{
|
|
10
|
+
"src": "https://arcadia.finance/arcadia_logo_green_bg_2.svg",
|
|
11
|
+
"mimeType": "image/svg+xml",
|
|
12
|
+
"sizes": ["any"]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
8
15
|
"repository": {
|
|
9
16
|
"url": "https://github.com/arcadia-finance/mcp-server",
|
|
10
17
|
"source": "github"
|
|
@@ -13,7 +20,7 @@
|
|
|
13
20
|
{
|
|
14
21
|
"registryType": "npm",
|
|
15
22
|
"identifier": "@arcadia-finance/mcp-server",
|
|
16
|
-
"version": "0.
|
|
23
|
+
"version": "0.7.1",
|
|
17
24
|
"transport": {
|
|
18
25
|
"type": "stdio"
|
|
19
26
|
},
|
|
@@ -4,18 +4,19 @@ description: Agent guide for clAMM management on Arcadia Finance. Covers 37 MCP
|
|
|
4
4
|
user-invocable: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# Arcadia Finance
|
|
7
|
+
# Arcadia Finance clAMM Agent Guide
|
|
8
8
|
|
|
9
|
-
Arcadia is a platform for managing concentrated liquidity positions with automated rebalancing, compounding, yield optimization, and leverage. Positions live in Arcadia accounts, which can also borrow against their collateral. This skill covers
|
|
9
|
+
Arcadia is a platform for managing concentrated liquidity positions with automated rebalancing, compounding, yield optimization, and leverage. Positions live in Arcadia accounts, which can also borrow against their collateral. This skill covers clAMM position management for agents.
|
|
10
10
|
|
|
11
11
|
## Key Constraints
|
|
12
12
|
|
|
13
13
|
- **All `write_*` tools return unsigned transactions** (`{ to, data, value, chainId }`): you must sign and broadcast them. See "Transaction Signing" below.
|
|
14
|
-
- **Automation strategy
|
|
14
|
+
- **Automation settings**: rebalance triggers, cooldowns and the POL and take-profit parameters go in the `strategy` of the `rebalance` intent in `write_account_automations`. You choose the range width when opening the position, with `tick_lower` and `tick_upper` in `write_account_add_liquidity`.
|
|
15
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
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. `write_account_add_liquidity` also validates deposits against per-asset minimum amounts from strategy risk factors.
|
|
17
|
+
- **Price warnings**: if `write_account_add_liquidity` finds a pool price off market or a token with no price, it returns the warnings, an `accept_price_checks` list and no transaction. Show the warnings to the user and call again with that list only after the user explicitly confirms. Never set `accept_price_checks` on the first call. New warnings on a rebuild need a new confirmation. The acknowledgement never bypasses a backend refusal.
|
|
17
18
|
- **`asset_id`** is always an integer (NFT token ID for LP positions, 0 for ERC20 tokens).
|
|
18
|
-
- **Wrapping ETH
|
|
19
|
+
- **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.
|
|
19
20
|
|
|
20
21
|
## Transaction Signing
|
|
21
22
|
|
|
@@ -27,10 +28,10 @@ Write tools (`write_*`) return unsigned transaction calldata. This server does N
|
|
|
27
28
|
|
|
28
29
|
How you sign depends on your setup:
|
|
29
30
|
|
|
30
|
-
- **MPC wallet** (Fireblocks, Dfns, Turnkey)
|
|
31
|
-
- **Smart account** (Safe, Biconomy)
|
|
32
|
-
- **Embedded wallet** (Privy, Dynamic)
|
|
33
|
-
- **Direct private key** (development only): use the built-in `dev_send` tool
|
|
31
|
+
- **MPC wallet** (Fireblocks, Dfns, Turnkey): pass the unsigned tx to your provider's signing API
|
|
32
|
+
- **Smart account** (Safe, Biconomy): wrap the tx as a UserOperation or Safe transaction
|
|
33
|
+
- **Embedded wallet** (Privy, Dynamic): use the provider's `sendTransaction` method
|
|
34
|
+
- **Direct private key** (development only): use the built-in `dev_send` tool, which the server lists only when `PK` is set in a `.env` file or the MCP client config, or viem/ethers `sendTransaction` with a local signer
|
|
34
35
|
|
|
35
36
|
Example with viem:
|
|
36
37
|
|
|
@@ -41,7 +42,7 @@ const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
|
41
42
|
|
|
42
43
|
## Batching Philosophy
|
|
43
44
|
|
|
44
|
-
Arcadia's flash-action tools can batch multiple DeFi operations into a single atomic transaction. **Always prefer batched tools
|
|
45
|
+
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.
|
|
45
46
|
|
|
46
47
|
**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.
|
|
47
48
|
|
|
@@ -51,29 +52,29 @@ Arcadia's flash-action tools can batch multiple DeFi operations into a single at
|
|
|
51
52
|
|
|
52
53
|
### Read Tools
|
|
53
54
|
|
|
54
|
-
| Tool | When to use
|
|
55
|
-
| ------------------------------ |
|
|
56
|
-
| `read_account_info` | Account overview + liquidation price. Pass `account_address` for detail (returns positions with `asset_address`/`asset_id`/`dex_protocol`, collateral, debt).
|
|
57
|
-
| `read_account_history` | Historical account value over time. Optional `days` param (default 14).
|
|
58
|
-
| `read_account_pnl` | PnL and yield earned: use to check if a strategy is still profitable.
|
|
59
|
-
| `read_asset_list` | List supported collateral assets (symbol, address, decimals). Use `search` to filter by symbol substring.
|
|
60
|
-
| `read_asset_prices` | USD prices for one or more assets by address. Pass `asset_addresses` (single or comma-separated).
|
|
61
|
-
| `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.
|
|
62
|
-
| `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.
|
|
63
|
-
| `read_wallet_accounts` | List all Arcadia accounts owned by a wallet address.
|
|
64
|
-
| `read_wallet_points` | Points earned by a wallet address.
|
|
65
|
-
| `read_pool_list` | Lending pool TVL, APY, utilization, liquidity. Pass `pool_address` for detail + APY history (optional `days`, default 14).
|
|
66
|
-
| `read_pool_info` | Detail + APY history for a specific lending pool. Pass `pool_address`.
|
|
67
|
-
| `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). **
|
|
68
|
-
| `read_strategy_info` | Detail for a
|
|
69
|
-
| `read_point_leaderboard` | Points leaderboard. No `chain_id` needed: points are cross-chain.
|
|
70
|
-
| `read_strategy_recommendation` | Rebalancing recommendation for an account. Uses
|
|
71
|
-
| `read_asset_manager_intents` | List the automation intents and their params. Pass `account_address` for live per-account availability plus the rule blocking anything unavailable.
|
|
72
|
-
| `read_asset_manager_current` | What is enabled on an account now: decoded per-manager config, the intents it maps to, Merkl claim state, and superseded managers to clear.
|
|
73
|
-
| `read_account_aero_upgrade` | Aero upgrade check: what a wallet's accounts (or one account) still have to move to Aero, with status and counts and no calldata. Empty accounts and failed_accounts lists mean nothing to do.
|
|
74
|
-
| `read_guides` | Reference guides: `automation` (AM setup), `selection` (pool evaluation), `strategies` (step-by-step templates).
|
|
75
|
-
|
|
76
|
-
### Preferred Write Tools (atomic/multi-step
|
|
55
|
+
| Tool | When to use |
|
|
56
|
+
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `read_account_info` | Account overview + liquidation price. Pass `account_address` for detail (returns positions with `asset_address`/`asset_id`/`dex_protocol`, collateral, debt). |
|
|
58
|
+
| `read_account_history` | Historical account value over time. Optional `days` param (default 14). |
|
|
59
|
+
| `read_account_pnl` | PnL and yield earned: use to check if a strategy is still profitable. |
|
|
60
|
+
| `read_asset_list` | List supported collateral assets (symbol, address, decimals). Use `search` to filter by symbol substring. |
|
|
61
|
+
| `read_asset_prices` | USD prices for one or more assets by address. Pass `asset_addresses` (single or comma-separated). |
|
|
62
|
+
| `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. |
|
|
63
|
+
| `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. |
|
|
64
|
+
| `read_wallet_accounts` | List all Arcadia accounts owned by a wallet address. |
|
|
65
|
+
| `read_wallet_points` | Points earned by a wallet address. |
|
|
66
|
+
| `read_pool_list` | Lending pool TVL, APY, utilization, liquidity. Pass `pool_address` for detail + APY history (optional `days`, default 14). |
|
|
67
|
+
| `read_pool_info` | Detail + APY history for a specific lending pool. Pass `pool_address`. |
|
|
68
|
+
| `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). **Call `read_strategy_info` to see 24h APY per range width** (very_narrow → very_wide): narrower range = higher APY but more rebalancing cost/risk. Use `featured_only: true` for curated top strategies. |
|
|
69
|
+
| `read_strategy_info` | Detail for a concentrated-liquidity strategy by `strategy_id`: APY per range width over the last 24 hours, and the 7-day average at the default range in `yield`. For basic pools, use the 7d APY from `read_strategy_list`. |
|
|
70
|
+
| `read_point_leaderboard` | Points leaderboard. No `chain_id` needed: points are cross-chain. |
|
|
71
|
+
| `read_strategy_recommendation` | Rebalancing recommendation for an account. Uses 24h APY where possible (not the 7d average of `read_strategy_list`), so numbers may differ. |
|
|
72
|
+
| `read_asset_manager_intents` | List the automation intents and their params. Pass `account_address` for live per-account availability plus the rule blocking anything unavailable. |
|
|
73
|
+
| `read_asset_manager_current` | What is enabled on an account now: decoded per-manager config, the intents it maps to, Merkl claim state, and superseded managers to clear. |
|
|
74
|
+
| `read_account_aero_upgrade` | Aero upgrade check: what a wallet's accounts (or one account) still have to move to Aero, with status and counts and no calldata. Empty accounts and failed_accounts lists mean nothing to do. |
|
|
75
|
+
| `read_guides` | Reference guides: `automation` (AM setup), `selection` (pool evaluation), `strategies` (step-by-step templates). |
|
|
76
|
+
|
|
77
|
+
### Preferred Write Tools (atomic/multi-step, use these first)
|
|
77
78
|
|
|
78
79
|
These tools batch multiple operations into ONE atomic transaction. Always prefer these over individual tools.
|
|
79
80
|
|
|
@@ -117,13 +118,14 @@ These tools batch multiple operations into ONE atomic transaction. Always prefer
|
|
|
117
118
|
|
|
118
119
|
### Lending Pools
|
|
119
120
|
|
|
120
|
-
Use as `pool_address` in `write_account_borrow` / `write_account_repay`, as `creditor` in `write_account_create` / `write_account_deleverage`.
|
|
121
|
+
Use as `pool_address` in `write_account_borrow` / `write_account_repay`, as `creditor` in `write_account_create` / `write_account_deleverage`. A pool has the same CREATE2 address on every chain where it exists. Unichain has no lending pools.
|
|
121
122
|
|
|
122
|
-
| Asset | Pool Address | Chains
|
|
123
|
-
| ----- | -------------------------------------------- |
|
|
124
|
-
| WETH | `0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2` | Base, Optimism |
|
|
125
|
-
| USDC | `0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1` | Base, Optimism
|
|
126
|
-
| cbBTC | `0xa37E9b4369dc20940009030BfbC2088F09645e3B` | Base only
|
|
123
|
+
| Asset | Pool Address | Chains |
|
|
124
|
+
| ----- | -------------------------------------------- | ------------------------- |
|
|
125
|
+
| WETH | `0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2` | Base, Optimism, Robinhood |
|
|
126
|
+
| USDC | `0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1` | Base, Optimism |
|
|
127
|
+
| cbBTC | `0xa37E9b4369dc20940009030BfbC2088F09645e3B` | Base only |
|
|
128
|
+
| USDG | `0xf37c0C5996503Fdd2b5CCCE36E659cD30393AE59` | Robinhood only |
|
|
127
129
|
|
|
128
130
|
### Asset Manager Addresses
|
|
129
131
|
|
|
@@ -178,9 +180,9 @@ Slipstream V3 on Optimism uses different addresses (exception to the determinist
|
|
|
178
180
|
|
|
179
181
|
Spot vs margin is determined by whether a **creditor** (lending pool) is set at account creation, not by version number.
|
|
180
182
|
|
|
181
|
-
- `account_version: 3
|
|
182
|
-
- `account_version: 4` or `0` (latest)
|
|
183
|
-
- `account_version: 1` or `2
|
|
183
|
+
- `account_version: 3`: **margin account** (created with a `creditor`). Can borrow, leverage, and mint LP. Uses an onchain whitelist of allowed collateral tokens.
|
|
184
|
+
- `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).
|
|
185
|
+
- `account_version: 1` or `2`: legacy. Not supported by current MCP tools (the automation tools require V3/V4).
|
|
184
186
|
- For **leveraged LP strategies**, use `account_version: 3` with a creditor.
|
|
185
187
|
- To check an existing account's version: call `read_account_info`: the response includes the account version.
|
|
186
188
|
|
|
@@ -236,6 +238,6 @@ Protocols: Uniswap V3, Uniswap V4, Aero CL (MetadexCL V1). No Slipstream V1-V3.
|
|
|
236
238
|
|
|
237
239
|
## Reference Files
|
|
238
240
|
|
|
239
|
-
- [automation.md](automation.md)
|
|
240
|
-
- [selection.md](selection.md)
|
|
241
|
+
- [automation.md](automation.md): How to enable each automation type
|
|
242
|
+
- [selection.md](selection.md): How to evaluate pools, choose range width, size leverage, combine automation
|
|
241
243
|
- [strategies.md](strategies.md): Step-by-step strategy templates: delta neutral LP, protocol-owned liquidity, and the upgrade to Aero
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Strategy Selection & Parameterization
|
|
2
2
|
|
|
3
|
-
Use this guide to evaluate whether a strategy makes sense and how to configure it. Apply to any LP strategy
|
|
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
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## 1. Pool / Strategy Selection
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
read_strategy_list(chain_id: 8453) // browse all LP strategies + fee APY
|
|
10
|
+
read_strategy_list(chain_id: 8453) // browse all LP strategies + fee APY (7-day average at the default range)
|
|
11
11
|
read_pool_list(chain_id: 8453) // check borrow cost for leveraged strategies
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -32,28 +32,25 @@ Must be positive to justify the leverage cost. Higher leverage amplifies both si
|
|
|
32
32
|
|
|
33
33
|
- Fee tier: higher fee tier (0.3%, 1%) = more fee per trade, better for volatile pairs
|
|
34
34
|
- Volume + TVL: high volume/TVL ratio = fees are being earned actively
|
|
35
|
-
- Active Merkl rewards: extra yield on top
|
|
35
|
+
- Active Merkl rewards: extra yield on top of the fee APY
|
|
36
36
|
|
|
37
|
-
**`numeraire`
|
|
38
|
-
|
|
39
|
-
- **`write_account_add_liquidity`**: `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
|
-
- **`write_account_deleverage`**: `numeraire` = the debt token you're repaying (e.g. WETH address when repaying WETH debt). This differs from the add liquidity usage.
|
|
37
|
+
**`numeraire`**: `write_account_add_liquidity` detects the account's numeraire itself. In `write_account_deleverage`, `numeraire` is the debt token you repay (e.g. the WETH address when repaying WETH debt).
|
|
41
38
|
|
|
42
39
|
---
|
|
43
40
|
|
|
44
41
|
## 2. Range Width
|
|
45
42
|
|
|
46
|
-
Range width is the central tradeoff in any LP strategy.
|
|
43
|
+
Range width is the central tradeoff in any LP strategy. You choose it when opening the position, by passing `tick_lower` and `tick_upper` for each position in `write_account_add_liquidity`. Understanding the full tradeoff is essential for choosing parameters: a simple fee APY comparison is not enough.
|
|
47
44
|
|
|
48
|
-
**Core principle:** The `strategy_apy` from `read_strategy_list` (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 `
|
|
45
|
+
**Core principle:** The `strategy_apy` from `read_strategy_list` (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 `read_strategy_info(strategy_id: <id>)` to see APY over the last 24 hours broken down by range width (very_narrow, narrow, balanced, wide, very_wide). The net return after rebalancing costs, IL, and gas determines the optimal width: see the model below.
|
|
49
46
|
|
|
50
47
|
### The full tradeoff
|
|
51
48
|
|
|
52
49
|
**Narrower range → higher fee capture, but three compounding costs:**
|
|
53
50
|
|
|
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
|
|
51
|
+
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
52
|
|
|
56
|
-
2. **IL crystallized per rebalance:** Every rebalance permanently locks in accumulated impermanent loss. It doesn't disappear by rebalancing
|
|
53
|
+
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
54
|
|
|
58
55
|
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
56
|
|
|
@@ -108,9 +105,9 @@ Leverage multiplies both fee income and liquidation risk.
|
|
|
108
105
|
| ----------------------------- | ------------------------------------------- | ------------------------- | ---------------------- |
|
|
109
106
|
| 1× (no borrow, `leverage: 0`) | Safe LP, no liquidation risk | N/A | 1.0 (no debt) |
|
|
110
107
|
| 2× | Classic delta neutral, volatile/stable pair | ~1.5–2× | ~0.5–0.7 |
|
|
111
|
-
| 3×+ | Aggressive yield, only in stable conditions | < 1.5
|
|
108
|
+
| 3×+ | Aggressive yield, only in stable conditions | < 1.5×, watch carefully | < 0.5, watch closely |
|
|
112
109
|
|
|
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
|
|
110
|
+
**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
111
|
|
|
115
112
|
**Profitability check:**
|
|
116
113
|
|
|
@@ -118,11 +115,11 @@ Leverage multiplies both fee income and liquidation risk.
|
|
|
118
115
|
borrow_APY × (leverage - 1) < fee_APY × leverage → leverage is profitable
|
|
119
116
|
```
|
|
120
117
|
|
|
121
|
-
**Two safety metrics
|
|
118
|
+
**Two safety metrics, collateral ratio vs health factor:**
|
|
122
119
|
|
|
123
120
|
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
121
|
|
|
125
|
-
A useful complementary metric is the **collateral ratio
|
|
122
|
+
A useful complementary metric is the **collateral ratio**, a rough estimate of how much buffer you have:
|
|
126
123
|
|
|
127
124
|
```
|
|
128
125
|
collateral_value × collateral_factor
|
|
@@ -130,27 +127,27 @@ collateral_value × collateral_factor
|
|
|
130
127
|
debt_value
|
|
131
128
|
```
|
|
132
129
|
|
|
133
|
-
Target collateral ratio ≥ 1.5 at entry (
|
|
130
|
+
Target collateral ratio ≥ 1.5 at entry (health factor about 0.5 or higher). Never open below 1.3 (health factor about 0.3).
|
|
134
131
|
|
|
135
132
|
**When to use less leverage:**
|
|
136
133
|
|
|
137
134
|
- Borrow APY rising (utilization climbing in lending pool)
|
|
138
135
|
- Market showing high volatility (gap risk)
|
|
139
|
-
- Position already near support/resistance
|
|
136
|
+
- Position already near support/resistance: a breakout would spike debt fast
|
|
140
137
|
- Health factor dropping toward 0.5 (check with `read_account_info`)
|
|
141
138
|
|
|
142
139
|
---
|
|
143
140
|
|
|
144
141
|
## 4. Combining Automation
|
|
145
142
|
|
|
146
|
-
| Combination | Compatible
|
|
147
|
-
| --------------------------------- |
|
|
148
|
-
| `rebalance` + `compound_fees` |
|
|
149
|
-
| `rebalance` + `claim_rewards` |
|
|
150
|
-
| `rebalance` + `claim_merkl` |
|
|
151
|
-
| `compound_fees` + `claim_merkl` |
|
|
152
|
-
| `compound_fees` + `claim_rewards` |
|
|
153
|
-
| `add_to_lp` + anything |
|
|
143
|
+
| Combination | Compatible | Notes |
|
|
144
|
+
| --------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
145
|
+
| `rebalance` + `compound_fees` | Yes | Rebalance compounds at rebalance time; compound_fees adds compounding between rebalances. |
|
|
146
|
+
| `rebalance` + `claim_rewards` | Yes | Claims yield between rebalances. Order is handled by the keeper's claim-before guard. |
|
|
147
|
+
| `rebalance` + `claim_merkl` | Yes | Always combine when the pool has Merkl incentives. Zero conflict. |
|
|
148
|
+
| `compound_fees` + `claim_merkl` | Yes | Merkl rewards are claimed separately from trading fees. |
|
|
149
|
+
| `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. |
|
|
150
|
+
| `add_to_lp` + anything | Yes | Independent fold. Only constraint: a folded token cannot be a convert `buy_token`. |
|
|
154
151
|
|
|
155
152
|
---
|
|
156
153
|
|
|
@@ -160,7 +157,7 @@ Monitor periodically with `read_account_info` and `read_account_pnl`. Exit or ad
|
|
|
160
157
|
|
|
161
158
|
| Signal | Threshold | Action |
|
|
162
159
|
| -------------------------------- | ------------------------ | ------------------------------------- |
|
|
163
|
-
| Borrow APY > fee APY | Persists 3+ checks | Exit strategy
|
|
160
|
+
| Borrow APY > fee APY | Persists 3+ checks | Exit strategy, no longer profitable |
|
|
164
161
|
| Health factor falling | < 0.5 | Add collateral or reduce debt |
|
|
165
162
|
| Health factor critical | < 0.2 | Immediate action required |
|
|
166
163
|
| Position out-of-range repeatedly | Bot can't keep up | Widen range or reduce leverage |
|
|
@@ -173,7 +170,7 @@ Monitor periodically with `read_account_info` and `read_account_pnl`. Exit or ad
|
|
|
173
170
|
## 6. Quick Checklist Before Opening a Position
|
|
174
171
|
|
|
175
172
|
```
|
|
176
|
-
[ ] read_strategy_list → fee_APY noted (7d avg for default range;
|
|
173
|
+
[ ] read_strategy_list → fee_APY noted (7d avg for default range; read_strategy_info for 24h per-range APY)
|
|
177
174
|
[ ] read_pool_list → borrow_APY noted (if leveraged)
|
|
178
175
|
[ ] net_APY = fee_APY - (leverage-1) × borrow_APY > 0
|
|
179
176
|
[ ] Pair type matches strategy (volatile/stable for delta neutral)
|