@continuumdao/ctm-mpc-defi 0.2.7 → 0.2.9

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.
@@ -0,0 +1,20 @@
1
+ ## Gas and MCP submit (all `build_*_multisign` tools)
2
+
3
+ All `ctm_*_build_*_multisign` tools **build, sign the management envelope, and POST** `/multiSignRequest`. They return **`{ requestId }`** — that is success. **Do not call the same build tool again** unless the user explicitly wants a new order; use `list_sign_requests` to verify pending requests.
4
+
5
+ Before creating, call `get_multi_sign_gas_options({ chainId })` when gas preference is unclear:
6
+
7
+ | Setting | Meaning |
8
+ |---------|---------|
9
+ | `useCustomGas: false` | Live RPC fee estimates at proposal time (default) |
10
+ | `useCustomGas: true` | Chain registry Custom Gas Config — **empty or omitted `baseFee` / `priorityFee` is valid** (live RPC used at proposal; configured values are optional floors/multipliers) |
11
+
12
+ - **`proposalTxParams`** on the sign request records gas limit and fee snapshot at create time.
13
+ - **Get Sig** (`trigger_sign_result`) refreshes fees via `feeSpeedTier` (default from `defaultGetSigFeeSpeed`).
14
+
15
+ ### After submit (`{ requestId }`)
16
+
17
+ 1. `wait_for_sign_request_ready` (if needed)
18
+ 2. `sign_request_agree` (multi-agree)
19
+ 3. `trigger_sign_result`
20
+ 4. `broadcast_sign_result`
@@ -105,13 +105,6 @@ For **withdraw**, **borrow**, and **repay**, the server calls the Aave v4 previe
105
105
 
106
106
  Set `skipHealthPreview: true` only when the user explicitly accepts skipping simulation (not recommended).
107
107
 
108
- ## After submit (`{ requestId }`)
109
-
110
- 1. `wait_for_sign_request_ready` (if needed)
111
- 2. `sign_request_agree` (multi-agree)
112
- 3. `trigger_sign_result`
113
- 4. `broadcast_sign_result`
114
-
115
108
  ## Example: deposit 0.001 ETH on Ethereum
116
109
 
117
110
  ```json
@@ -109,13 +109,6 @@ Ethereum (1), Optimism (10), BSC (56), Gnosis (100), Polygon (137), Sonic (146),
109
109
  }
110
110
  ```
111
111
 
112
- ## After submit (`{ requestId }`)
113
-
114
- 1. `wait_for_sign_request_ready` (if needed)
115
- 2. `sign_request_agree` (multi-agree)
116
- 3. `trigger_sign_result`
117
- 4. `broadcast_sign_result`
118
-
119
112
  ## Troubleshooting
120
113
 
121
114
  | Symptom | Likely cause |
@@ -7,4 +7,4 @@ description: Ethena USDe stake, redeem, cooldown, and claim on Ethereum mainnet.
7
7
 
8
8
  Stake/redeem MCP tools target **mainnet (chainId 1)**. Use `get_defi_protocol_supported_tokens` for USDe/sUSDe addresses.
9
9
 
10
- Tools: `ctm_ethena_build_stake_multisign`, `_redeem_`, `_cooldown_`, `_claim_`.
10
+ Tools: `ctm_ethena_build_stake_multisign`, `_redeem_`, `_cooldown_`, `_claim_`. Each returns `{ requestId }` on success (shared gas/submit section appended by the server).
@@ -7,4 +7,4 @@ description: Euler v2 isolated lend/borrow, vault withdraw, and collateral opera
7
7
 
8
8
  Supported chains from `get_defi_protocol_supported_chains` (subgraph map). Pass `vault` and asset addresses from Euler UI.
9
9
 
10
- Tools include isolated lend/borrow, collateral deposit/withdraw, vault withdraw, borrow repay.
10
+ Tools include isolated lend/borrow, collateral deposit/withdraw, vault withdraw, borrow repay. All `ctm_euler_v2_build_*_multisign` tools return `{ requestId }` on success (shared gas/submit section appended by the server).
@@ -16,13 +16,32 @@ Perpetuals on Arbitrum (42161) and Avalanche (43114) via `@gmx-io/sdk` v2 **clas
16
16
  3. `ctm_gmx_fetch_market_prices({ chainId, symbol, collateralSymbol })` — index/collateral USD mark
17
17
  4. `ctm_gmx_fetch_ohlcv({ chainId, symbol, timeframe: "15m" })` — tabular OHLCV candles (USD index)
18
18
  5. `ctm_gmx_fetch_positions({ chainId, executorAddress })` — for close flows
19
- 6. `ctm_gmx_build_increase_multisign` or `ctm_gmx_build_decrease_multisign` with `keyGenId`, `chainId`, `purposeText`
20
- 7. Base MPC: agree trigger signbroadcast
19
+ 6. `get_multi_sign_gas_options({ chainId })` confirm `useCustomGas` with the user
20
+ 7. `ctm_gmx_build_increase_multisign` or `ctm_gmx_build_decrease_multisign` with `keyGenId`, `chainId`, `purposeText`, `useCustomGas` **`{ requestId }`**
21
+ 8. Base MPC lifecycle (see shared gas/submit section below)
21
22
 
22
23
  ## Limit orders
23
24
 
24
25
  Set `orderType: "limit"` and `triggerPriceUsdHuman` on increase/decrease builders.
25
26
 
27
+ Example short limit on Arbitrum (ETH/USDC collateral):
28
+
29
+ ```json
30
+ {
31
+ "keyGenId": "<keygen-id>",
32
+ "chainId": 42161,
33
+ "purposeText": "GMX short ETH limit at 1750 USDC",
34
+ "useCustomGas": false,
35
+ "symbol": "ETH/USD [WETH-USDC]",
36
+ "direction": "short",
37
+ "orderType": "limit",
38
+ "triggerPriceUsdHuman": "1750",
39
+ "sizeUsdHuman": "200",
40
+ "collateralAmountHuman": "50",
41
+ "collateralSymbol": "USDC"
42
+ }
43
+ ```
44
+
26
45
  ## Cancel
27
46
 
28
47
  Use `orderId` from `fetchOrders` with `ctm_gmx_build_cancel_multisign`.
@@ -43,3 +62,11 @@ Keeper execution is asynchronous (same as perp orders). Execution fee is paid in
43
62
  1. `ctm_gmx_fetch_staking_power({ chainId, executorAddress })`
44
63
  2. `ctm_gmx_build_stake_gmx_multisign` — approve GMX + `RewardRouter.stakeGmx`
45
64
  3. `ctm_gmx_build_unstake_gmx_multisign` — `RewardRouter.unstakeGmx`
65
+
66
+ ## Troubleshooting
67
+
68
+ | Symptom | Likely cause |
69
+ |---------|----------------|
70
+ | Agent says custom gas "will fail" without baseFee | Wrong — empty registry fees are valid; use `get_multi_sign_gas_options` |
71
+ | Multiple duplicate sign requests | Retried `ctm_gmx_build_*` after `{ requestId }` — do not retry on success |
72
+ | Order pending after broadcast | Normal — GMX keeper executes asynchronously |
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: hyperliquid
3
+ description: Hyperliquid perps, vaults, and HYPE staking via HyperEVM CoreWriter — Continuum MPC multi-sign.
4
+ ---
5
+
6
+ # Hyperliquid (MCP)
7
+
8
+ Hyperliquid is a perpetuals and spot exchange with on-chain actions routed through **HyperEVM CoreWriter** (`0x3333…3333`). Continuum MPC sends **single-tx CoreWriter batches** from the KeyGen executor on HyperEVM.
9
+
10
+ Supported chains (must be in node chain registry with `rpcGateway`):
11
+
12
+ | chainId | Network |
13
+ |--------:|---------|
14
+ | **999** | HyperEVM mainnet |
15
+ | **998** | Hyperliquid testnet |
16
+
17
+ The MPC **executor address** (`keyGen.ethereumaddress`) is the Hyperliquid **user account** for balances, positions, and orders.
18
+
19
+ ## What Hyperliquid does (explain to users)
20
+
21
+ - **Perps:** USD-margined perpetuals (BTC, ETH, …) plus optional **HIP-3** builder dexes.
22
+ - **Spot ↔ Perp:** USDC is one asset split between **spot** and **perp margin** ledgers (not separate ERC20s). Move with `usdClassTransfer`.
23
+ - **Vaults:** Deposit/withdraw USD into protocol vaults (withdraw includes accrued PnL).
24
+ - **Staking:** Stake/unstake **HYPE** and delegate to validators.
25
+
26
+ Trading reads use Hyperliquid **REST `/info`**. Writes use **CoreWriter** on HyperEVM (not the signed `/exchange` API).
27
+
28
+ ## Getting started (funding)
29
+
30
+ Before first trade, the user typically needs:
31
+
32
+ 1. **USDC on Hyperliquid** — deposit via the official Hyperliquid bridge (commonly from **Arbitrum** USDC). Funds appear in the spot/perp account tied to the MPC address.
33
+ 2. **Perp margin** — for perp orders, USDC must be in the **perp** bucket. Use `ctm_hyperliquid_fetch_usd_class_balances` then `ctm_hyperliquid_build_usd_transfer_multisign` with `toPerp: true` if spot USDC is high but perp withdrawable is low.
34
+ 3. **HYPE on HyperEVM for gas** — CoreWriter txs on chain **999** / **998** require **native HYPE** on the executor for gas. Ensure the KeyGen wallet holds enough HYPE on HyperEVM (bridge/deposit separately from USDC trading balance).
35
+ 4. **Leverage** — Hyperliquid stores a per-market leverage setting. Check `ctm_hyperliquid_fetch_open_context` (`leverageLabel`, `availableToBuy` / `availableToSell`). Changing leverage on-exchange is **not** exposed in v1 MCP (user adjusts on Hyperliquid UI if needed).
36
+
37
+ Positions and orders from MCP reflect **live HyperCore state** after prior txs are **broadcast** — pending multi-sign requests are not visible until executed.
38
+
39
+ ## Typical agent flow (open perp)
40
+
41
+ 1. `load_defi_protocol({ protocolId: "hyperliquid" })`
42
+ 2. `get_defi_protocol_skill` — this file (+ shared gas/submit section appended)
43
+ 3. Confirm chain **999** or **998** in `get_chain_registry` with RPC
44
+ 4. `ctm_hyperliquid_fetch_markets({ chainId: 999 })` — pick `coin` (e.g. `BTC`); note `maxLeverage`
45
+ 5. `ctm_hyperliquid_fetch_market_snapshot({ chainId, coin, interval: "15m" })` — mid + candles
46
+ 6. `ctm_hyperliquid_fetch_open_context({ chainId, executorAddress, coin })` — account, leverage, max size
47
+ 7. `ctm_hyperliquid_fetch_usd_class_balances({ chainId, executorAddress })` — spot vs perp USD if needed
48
+ 8. `get_multi_sign_gas_options({ chainId })` — confirm `useCustomGas` with user
49
+ 9. `ctm_hyperliquid_build_limit_order_multisign` → **`{ requestId }`**
50
+ 10. Base MPC lifecycle (shared gas/submit section below)
51
+
52
+ ## Tool selection
53
+
54
+ ### Read-only
55
+
56
+ | User intent | MCP tool |
57
+ |-------------|----------|
58
+ | List perp markets + HIP-3 dexes | `ctm_hyperliquid_fetch_markets` |
59
+ | Mid price + OHLCV | `ctm_hyperliquid_fetch_market_snapshot` |
60
+ | Account + capacity for one coin | `ctm_hyperliquid_fetch_open_context` |
61
+ | Open positions | `ctm_hyperliquid_fetch_positions` |
62
+ | Open orders | `ctm_hyperliquid_fetch_open_orders` |
63
+ | Spot vs perp USDC | `ctm_hyperliquid_fetch_usd_class_balances` |
64
+ | Vault catalog (+ APR) | `ctm_hyperliquid_fetch_vaults` |
65
+ | User vault equity | `ctm_hyperliquid_fetch_user_vault_equities` |
66
+ | HYPE stake summary | `ctm_hyperliquid_fetch_staking_summary` |
67
+ | Validator delegations | `ctm_hyperliquid_fetch_delegations` |
68
+
69
+ ### Multi-sign (writes)
70
+
71
+ | User intent | MCP tool |
72
+ |-------------|----------|
73
+ | Open / add limit or IoC order | `ctm_hyperliquid_build_limit_order_multisign` |
74
+ | Close / reduce position | `ctm_hyperliquid_build_close_multisign` |
75
+ | Cancel open order | `ctm_hyperliquid_build_cancel_multisign` |
76
+ | Move USDC spot ↔ perp | `ctm_hyperliquid_build_usd_transfer_multisign` |
77
+ | Vault deposit | `ctm_hyperliquid_build_vault_deposit_multisign` |
78
+ | Vault withdraw | `ctm_hyperliquid_build_vault_withdraw_multisign` |
79
+ | Stake HYPE | `ctm_hyperliquid_build_stake_multisign` |
80
+ | Unstake HYPE | `ctm_hyperliquid_build_unstake_multisign` |
81
+ | Delegate to validator | `ctm_hyperliquid_build_delegate_multisign` |
82
+ | Undelegate | `ctm_hyperliquid_build_undelegate_multisign` |
83
+
84
+ ## Common multisign inputs (all `build_*` tools)
85
+
86
+ | Field | Required | Notes |
87
+ |-------|----------|-------|
88
+ | `keyGen` | yes | `{ pubkeyhex, keylist?, ClientKeys? }` |
89
+ | `chainId` | yes | **999** or **998** |
90
+ | `rpcUrl` | yes | HyperEVM RPC from chain registry |
91
+ | `executorAddress` | yes | MPC `ethereumaddress` |
92
+ | `chainDetail` | yes | Gas config row from registry |
93
+ | `purposeText` | yes | Human-readable sign request purpose |
94
+ | `useCustomGas` | yes | See gas section below |
95
+ | `customGasChainDetails` | no | Snapshot when `useCustomGas: true` |
96
+
97
+ ## Limit order example
98
+
99
+ ```json
100
+ {
101
+ "keyGen": { "pubkeyhex": "…", "keylist": ["…"] },
102
+ "chainId": 999,
103
+ "rpcUrl": "https://…",
104
+ "executorAddress": "0x…",
105
+ "chainDetail": {},
106
+ "purposeText": "Hyperliquid: long BTC 0.01 @ 95000",
107
+ "useCustomGas": false,
108
+ "coin": "BTC",
109
+ "isBuy": true,
110
+ "limitPxHuman": "95000",
111
+ "szHuman": "0.01",
112
+ "tif": "gtc"
113
+ }
114
+ ```
115
+
116
+ - `tif`: `gtc` (default), `ioc`, or `alo`
117
+ - `marketKind`: optional `perp` (default) or `spot`
118
+ - `dex`: optional HIP-3 dex name; coin may be prefixed e.g. `xyz:SYMBOL`
119
+
120
+ Validate `szHuman` against `availableToBuy` / `availableToSell` from `fetch_open_context`.
121
+
122
+ ## Close position example
123
+
124
+ Use `isLong: true` for a **long** position (submits sell reduce-only IoC):
125
+
126
+ ```json
127
+ {
128
+ "coin": "BTC",
129
+ "isLong": true,
130
+ "limitPxHuman": "94000",
131
+ "szHuman": "0.01",
132
+ "tif": "ioc"
133
+ }
134
+ ```
135
+
136
+ ## Cancel example
137
+
138
+ ```json
139
+ {
140
+ "coin": "BTC",
141
+ "oid": 123456789
142
+ }
143
+ ```
144
+
145
+ `oid` from `ctm_hyperliquid_fetch_open_orders`.
146
+
147
+ ## Spot ↔ Perp USD transfer
148
+
149
+ ```json
150
+ {
151
+ "usdHuman": "100",
152
+ "toPerp": true
153
+ }
154
+ ```
155
+
156
+ Check balances first with `ctm_hyperliquid_fetch_usd_class_balances`.
157
+
158
+ ## Vault / stake
159
+
160
+ - **Vault deposit/withdraw:** `vaultAddress` from `fetch_vaults`; `usdHuman` amount. Mainnet vault catalog fetch can take ~10–15s (large stats feed). Testnet catalog is empty.
161
+ - **Stake/unstake:** `hypeHuman` amount in HYPE units.
162
+ - **Delegate/undelegate:** `validator` address + `hypeHuman`.
163
+
164
+ ## HIP-3 dexes
165
+
166
+ `fetch_markets` returns `dexes[]`. Pass `dex` on reads and on limit/cancel/close when trading builder-deployed perps. Coin names may include a dex prefix.
167
+
168
+ ## Troubleshooting
169
+
170
+ | Symptom | Likely cause |
171
+ |---------|----------------|
172
+ | `availableToBuy` / `availableToSell` is 0 | No perp margin, leverage too high, or USDC still in spot — transfer to perp |
173
+ | Order succeeds on-chain but no position | Limit not filled yet; IoC may partially/fully reject |
174
+ | Position missing after multi-sign | Request not yet broadcast; or wrong dex filter |
175
+ | Vault list empty on 998 | Expected — catalog is mainnet-only |
176
+ | CoreWriter tx fails on broadcast | Insufficient **HYPE** on HyperEVM for gas |
177
+ | Size rejected | Exceeds `availableToBuy`/`availableToSell` at current leverage |
@@ -19,4 +19,4 @@ Mainnet only (`chainId: 1`). Use `get_defi_protocol_supported_chains` and confir
19
19
  | Wrap stETH → wstETH | `ctm_lido_build_wrap_steth_multisign` |
20
20
  | Unwrap wstETH | `ctm_lido_build_unwrap_wsteth_multisign` |
21
21
 
22
- Complete flow with base MCP: `trigger_sign_result` `broadcast_sign_result`.
22
+ All `ctm_lido_build_*_multisign` tools return `{ requestId }` on success (shared gas/submit section appended by the server).
@@ -7,4 +7,4 @@ description: Maple Syrup pool deposit and redeem request flows.
7
7
 
8
8
  Chains: mainnet and Sepolia. Pass `syrupRouter`, `pool`, and `asset` from Maple UI/GraphQL.
9
9
 
10
- Tools: `ctm_maple_build_deposit_multisign`, `ctm_maple_build_request_redeem_multisign`.
10
+ Tools: `ctm_maple_build_deposit_multisign`, `ctm_maple_build_request_redeem_multisign`. Each returns `{ requestId }` on success (shared gas/submit section appended by the server).
@@ -7,4 +7,4 @@ description: Sky Lockstake and sUSDS deposit/redeem on Ethereum mainnet.
7
7
 
8
8
  Mainnet only. Tools for Lockstake stake/draw/wipe/close/reward and sUSDS deposit/redeem.
9
9
 
10
- Use `get_defi_protocol_supported_chains` and base registry for USDS/SKY addresses.
10
+ Use `get_defi_protocol_supported_chains` and base registry for USDS/SKY addresses. All `ctm_sky_build_*_multisign` tools return `{ requestId }` on success (shared gas/submit section appended by the server).
@@ -138,13 +138,6 @@ Use the same `swapTransactionDeadlineUnix` in step 2 and `swapDeadlineUnix` in s
138
138
  - **On-chain batch** may add approve headroom; for `EXACT_OUTPUT`, optional `slippagePercent` on build adjusts approval sizing.
139
139
  - Explain expected input/output from quote JSON before submitting the sign request.
140
140
 
141
- ## After submit (`{ requestId }`)
142
-
143
- 1. `wait_for_sign_request_ready` (if needed)
144
- 2. `sign_request_agree` (multi-agree)
145
- 3. `trigger_sign_result`
146
- 4. `broadcast_sign_result`
147
-
148
141
  ## Troubleshooting
149
142
 
150
143
  | Symptom | Likely cause |