@continuumdao/ctm-mpc-defi 0.2.4 → 0.2.6
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/dist/agent/catalog.cjs +638 -4
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +458 -14
- package/dist/agent/catalog.js +615 -5
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/gmx/SKILL.md +45 -0
- package/dist/agent/skills/uniswap-v4/SKILL.md +9 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +2251 -0
- package/dist/protocols/evm/gmx/index.cjs.map +1 -0
- package/dist/protocols/evm/gmx/index.d.ts +469 -0
- package/dist/protocols/evm/gmx/index.js +2181 -0
- package/dist/protocols/evm/gmx/index.js.map +1 -0
- package/dist/protocols/evm/uniswap-v4/index.cjs +227 -3
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +63 -1
- package/dist/protocols/evm/uniswap-v4/index.js +222 -5
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# GMX V2 (classic mode)
|
|
2
|
+
|
|
3
|
+
Perpetuals on Arbitrum (42161) and Avalanche (43114) via `@gmx-io/sdk` v2 **classic** orders only.
|
|
4
|
+
|
|
5
|
+
## Constraints
|
|
6
|
+
|
|
7
|
+
- **No express mode** — MPC multi-sign requires on-chain calldata (`prepareOrder({ mode: "classic" })`).
|
|
8
|
+
- **No subaccounts (1CT)** — incompatible with threshold MPC; executor is always `keyGen.ethereumaddress`.
|
|
9
|
+
- **No spot swaps** in v1 — perps only (increase, decrease, limit, cancel).
|
|
10
|
+
- Orders are **keeper-executed asynchronously** after broadcast; poll `fetchOrders` for status.
|
|
11
|
+
|
|
12
|
+
## Typical agent flow
|
|
13
|
+
|
|
14
|
+
1. `load_defi_protocol({ protocolId: "gmx" })`
|
|
15
|
+
2. `ctm_gmx_fetch_markets({ chainId })` — pick `symbol` e.g. `ETH/USD [WETH-USDC]`; each row includes `maxLeverageLabel`
|
|
16
|
+
3. `ctm_gmx_fetch_market_prices({ chainId, symbol, collateralSymbol })` — index/collateral USD mark
|
|
17
|
+
4. `ctm_gmx_fetch_ohlcv({ chainId, symbol, timeframe: "15m" })` — tabular OHLCV candles (USD index)
|
|
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 sign → broadcast
|
|
21
|
+
|
|
22
|
+
## Limit orders
|
|
23
|
+
|
|
24
|
+
Set `orderType: "limit"` and `triggerPriceUsdHuman` on increase/decrease builders.
|
|
25
|
+
|
|
26
|
+
## Cancel
|
|
27
|
+
|
|
28
|
+
Use `orderId` from `fetchOrders` with `ctm_gmx_build_cancel_multisign`.
|
|
29
|
+
|
|
30
|
+
## GM liquidity (phase 2)
|
|
31
|
+
|
|
32
|
+
GM pool deposit/withdraw uses **ExchangeRouter multicall** (not `prepareOrder`):
|
|
33
|
+
|
|
34
|
+
1. `ctm_gmx_fetch_gm_markets({ chainId })` — GM markets + long/short collateral symbols + estimated APY
|
|
35
|
+
2. `ctm_gmx_fetch_gm_apy({ chainId })` — same APY data sorted by yield (highest first)
|
|
36
|
+
3. `ctm_gmx_build_gm_deposit_multisign` — approve + `multicall(sendWnt + sendTokens + createDeposit)`
|
|
37
|
+
4. `ctm_gmx_build_gm_withdraw_multisign` — approve GM token + `multicall(sendWnt + sendTokens + createWithdrawal)`
|
|
38
|
+
|
|
39
|
+
Keeper execution is asynchronous (same as perp orders). Execution fee is paid in native gas token via `sendWnt`.
|
|
40
|
+
|
|
41
|
+
## GMX token staking (phase 2)
|
|
42
|
+
|
|
43
|
+
1. `ctm_gmx_fetch_staking_power({ chainId, executorAddress })`
|
|
44
|
+
2. `ctm_gmx_build_stake_gmx_multisign` — approve GMX + `RewardRouter.stakeGmx`
|
|
45
|
+
3. `ctm_gmx_build_unstake_gmx_multisign` — `RewardRouter.unstakeGmx`
|
|
@@ -164,6 +164,7 @@ MCP uses **classic ERC-20 approve** batches (Permit2 disabled), matching swaps.
|
|
|
164
164
|
|
|
165
165
|
| Action | Prep tool | Build multisign |
|
|
166
166
|
|--------|-----------|-----------------|
|
|
167
|
+
| List standard pools | `ctm_uniswap_v4_list_lp_pools` | — |
|
|
167
168
|
| Mint new position | `ctm_uniswap_v4_lp_create_position` | `ctm_uniswap_v4_build_mint_liquidity_multisign` |
|
|
168
169
|
| Increase | `ctm_uniswap_v4_lp_increase` | `ctm_uniswap_v4_build_increase_liquidity_multisign` |
|
|
169
170
|
| Decrease | `ctm_uniswap_v4_lp_decrease` | `ctm_uniswap_v4_build_decrease_liquidity_multisign` |
|
|
@@ -172,9 +173,16 @@ MCP uses **classic ERC-20 approve** batches (Permit2 disabled), matching swaps.
|
|
|
172
173
|
| Register position NFT | `ctm_uniswap_v4_register_position_nft` | — (management-signed) |
|
|
173
174
|
| Register from mint tx | `ctm_uniswap_v4_register_position_from_mint_tx` | — (after mint execute) |
|
|
174
175
|
|
|
176
|
+
### Standard pools (no manual pool id hunt)
|
|
177
|
+
|
|
178
|
+
1. `ctm_uniswap_v4_list_lp_pools` with `chainId` (optional `pair` filter, e.g. `eth-usdc`).
|
|
179
|
+
2. Pick a row — use `presetId` as `poolPreset` on `ctm_uniswap_v4_lp_create_position`, or copy `existingPool` fields (`token0Address`, `token1Address`, `poolReference`).
|
|
180
|
+
3. `poolReference` is the V4 **bytes32 pool id**, derived from token addresses + `fee` + `tickSpacing` + `hooks` (no-hook pools use `0x0`).
|
|
181
|
+
4. If LP create fails, the pool may not be initialized on-chain — try another preset, pass a custom `poolReference`, or use `newPool`.
|
|
182
|
+
|
|
175
183
|
### Mint workflow
|
|
176
184
|
|
|
177
|
-
1. Resolve pool
|
|
185
|
+
1. Resolve pool: `poolPreset` from list tool, `existingPool` (`poolReference` or `fee`+`tickSpacing` to derive id), or `newPool` to initialize.
|
|
178
186
|
2. Set price range via `priceBounds` (human prices) or `tickBounds`.
|
|
179
187
|
3. `independentToken`: one token + amount in base units; API computes the other.
|
|
180
188
|
4. `ctm_uniswap_v4_lp_create_position` → full JSON with `create` tx + `token0`/`token1` amounts.
|
package/dist/index.cjs
CHANGED
|
@@ -1336,6 +1336,7 @@ async function buildEvmMultisignBodyUniswapV4SkipPermit2Batch(args) {
|
|
|
1336
1336
|
}
|
|
1337
1337
|
});
|
|
1338
1338
|
}
|
|
1339
|
+
var UNISWAP_V4_LP_POOL_LOOKUP_HINT = "Pool may not be initialized on this chain. Call ctm_uniswap_v4_list_lp_pools for other presets, pass a custom existingPool.poolReference, or use newPool to initialize a pool.";
|
|
1339
1340
|
|
|
1340
1341
|
// src/protocols/evm/uniswap-v4/liquidityApi.ts
|
|
1341
1342
|
var LP_HEADERS_BASE = {
|
|
@@ -1400,9 +1401,9 @@ async function postUniswapLpApi(args) {
|
|
|
1400
1401
|
});
|
|
1401
1402
|
const text = await res.text();
|
|
1402
1403
|
if (!res.ok) {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
);
|
|
1404
|
+
const base2 = messageFromUniswapHttpResponseBody(text, res.status, res.statusText);
|
|
1405
|
+
const hint = args.path === "create" && args.body.existingPool ? ` ${UNISWAP_V4_LP_POOL_LOOKUP_HINT}` : "";
|
|
1406
|
+
throw new Error(`Uniswap LP POST /${args.path} failed: ${base2}${hint}`);
|
|
1406
1407
|
}
|
|
1407
1408
|
return JSON.parse(text);
|
|
1408
1409
|
}
|