AgentMarketMCP / SKILL 资产档案馆

目录 / 电商办公 / HyperGrok Hyperliquid Positions

SKILL 未评级 已上架

HyperGrok Hyperliquid Positions

--- name: hyperliquid-positions description: Manage Hyperliquid perp positions and margin from the desk computer - read positions and margin, set leverage and cross/isolated mode, add isolated margin, understand margin tiers and liquidation price, close a position with a reduce-only IOC, and clean up orphaned orders. Write actions are Execution Trader only, on an approved or mandate-covered ticket. Use for leverage changes, closes, protection checks and margin questions. license: MIT metadata: version: "1.2.1" author: Galleon Labs category: hyperliquid network-default: testnet --- # Hyperliquid positions and margin Reads here are for everyone (Risk Manager first); the write actions (`updateLeverage`, `updateIsolatedMargin`, closes) are Execution Trader only, on a ticket approved by id or covered by a valid [standing mandate](../../docs/STANDING_MANDATE.md). A mandate covers closes and setting leverage to what the ticket needs; isolated-margin top-ups and margin-mode changes the ticket does not need stay per-ticket. Order mechanics are in `hyperliquid-orders`. ## Concepts - **Cross margin** (default): all cross positions share the account's margin, and unrealised PnL counts as margin; liquidation is account-wide. **Isolated margin:** the position has its own margin; only that margin is at risk, and you can add to or remove from it (some markets are `strictIsolated` and refuse removal; HIP-3 markets may be `noCross`). - **Leverage** is set per market and per mode with `updateLeverage`; it caps position size against margin. Max leverage is per market and **tiered by notional** (see margin tiers). - **Margin tiers:** each perp has a margin table (`meta.marginTables`, matched to the asset via `marginTableId`) listing notional thresholds and the max leverage allowed above each. Bigger positions get less leverage. - **Maintenance margin** is half of the initial margin at the max leverage of the applicable tier (so between 1.25% for a 40x market and 16.7% for a 3x market); liquidation happens when account (cross) or position (isolated) equity falls below maintenance margin, on **mark** price. Positions above 100k USDC (10k on testnet) are liquidated 20% at a time first; the cross liquidation price does not depend on your leverage setting. - **Liquidation price** is reported by the exchange per position (`liquidationPx`); use that, do not recompute. - **Funding** is exchanged every hour between longs and shorts at the market's funding rate; it changes equity while a position is open. - **Closing** is an order in the opposite direction with `reduceOnly`. Full close at market: reduce-only IOC at a slippage-bounded price for the live position size. ## Read positions and margin ```bash ADDR=$HYPERLIQUID_ACCOUNT_ADDRESS BASE=$([ "$HYPERLIQUID_NETWORK" = mainnet ] && echo https://api.hyperliquid.xyz || echo https://api.hyperliquid-testnet.xyz) curl -sS -X POST $BASE/info -H 'Content-Type: application/json' -d "{\"type\":\"clearinghouseState\",\"user\":\"$ADDR\"}" | jq '{ accountValue: .marginSummary.accountValue, totalMarginUsed: .marginSummary.totalMarginUsed, withdrawable, crossMaintenanceMarginUsed, positions: [.assetPositions[].position | {coin, szi, entryPx, positionValue, unrealizedPnl, liquidationPx, marginUsed, leverage: (.leverage.type + " " + (.leverage.value|tostring)), returnOnEquity, cumFunding: .cumFunding.sinceOpen}]}' ``` `szi` is signed size (positive long, negative short). `leverage.type` is `cross` or `isolated`; isolated positions also carry `leverage.rawUsd` (the isolated margin). Margin tiers for a market: ```bash curl -sS -X POST $BASE/info -H 'Content-Type: application/json' -d '{"type":"meta"}' \ | jq --arg c ETH '(.universe[] | select(.name==$c)) as $u | ($u.marginTableId // $u.maxLeverage) as $id | {name:$u.name, szDecimals:$u.szDecimals, maxLeverage:$u.maxLeverage, marginTableId:$id, tiers: (if $id < 50 then [{lowerBound:"0.0", maxLeverage:$id}] else ((.marginTables[] | select(.[0]==$id) | .[1].marginTiers) // [{lowerBound:"0.0", maxLeverage:$u.maxLeverage}]) end)}' ``` `marginTables` is a list of `[id, {description, marginTiers: [{lowerBound, maxLeverage}, ...]}]` for ids of 50 and above; the tier whose `lowerBound` (position notional in USD) is the largest one at or below your notional applies. Ids below 50 are single-tier tables whose max leverage equals the id and they are **not** listed in `marginTables` (most altcoins), which the snippet handles. Testnet tiers are far tighter than mainnet (BTC drops from 40x to 25x above only 10k notional on testnet), so a testnet rehearsal does not prove mainnet leverage. Python equivalents: `info.user_state(ADDR)`, `info.meta()`; the header from `hyperliquid-orders` applies. ## Set leverage and margin mode (write) Do this **before** the entry the ticket refers to. Leverage is checked when a position is opened (`margin required = size x mark / leverage`); the leverage of an existing position can be raised without closing it, which frees margin and moves the isolated liquidation price, and lowering it needs enough free margin to cover the higher initial margin. Either way, tell the user what changes. ```python # header from hyperliquid-orders (info, exchange, ACCOUNT) res = exchange.update_leverage(3, "ETH", is_cross=True) # 3x cross # res = exchange.update_leverage(5, "ETH", is_cross=False) # 5x isolated print(res) # {"status":"ok","response":{"type":"default"}} print(next((p["position"]["leverage"] for p in info.user_state(ACCOUNT)["assetPositions"] if p["position"]["coin"] == "ETH"), "no open ETH position")) ``` If the market has no open position yet, confirm afterwards by placing the entry and reading `leverage` on the resulting position, or via `activeAssetData` (`{"type":"activeAssetData","user":ADDR,"coin":"ETH"}`), which reports the account's current leverage setting and available-to-trade for that market. Add isolated margin to an existing isolated position (USD amount): ```python res = exchange.update_isolated_margin(50.0, "ETH") # adds 50 USDC of margin to the ETH isolated position ``` TypeScript: `await exchange.updateLeverage({ asset: a, isCross: true, leverage: 3 })`; `await exchange.updateIsolatedMargin({ asset: a, isBuy: true, ntli: 50 * 1e6 })` (`ntli` is USD x 1e6). ## Close a position (write) Read the size live seconds before sending; the ticket states the slippage bound. ```python coin, slippage = "ETH", 0.003 # 30 bps bound pos = next((p["position"] for p in info.user_state(ACCOUNT)["assetPositions"] if p["position"]["coin"] == coin), None) if not pos: raise SystemExit("no open position") szi = Decimal(pos["szi"]); is_buy = szi < 0 # closing a short buys sz = round_sz(coin, abs(szi)) mid = info.all_mids()[coin] px = bounded_px(coin, mid, slippage, is_buy) cloid = new_cloid(); print("cloid", cloid.to_raw(), "bound", px, "size", sz) res = exchange.order(coin, is_buy, sz, px, {"limit": {"tif": "Ioc"}}, reduce_only=True, cloid=cloid) print(res) # exchange.market_close also sends a reduce-only IOC, but its nearest price rounding can widen a ticket bound. # Use bounded_px above for an exact approved floor/ceiling; an IOC can partially fill or leave a remainder. ``` Partial close: pass the reduced size. The position still exists afterwards and **still needs a stop**. Clean-up depends on which happened, and reading `clearinghouseState` is what tells you: - **Full close** (`assetPositions` no longer contains the coin): list `open_orders(ACCOUNT)` and cancel the orphaned TP/SL for that market (their own ticket, the standing approval in `desk.md`, or a valid standing mandate), then confirm the position is gone. - **Partial close** (the coin is still there at a smaller size): do **not** cancel the protective trigger. A position-tied stop (`sz: "0.0"`, `isPositionTpsl: true`) already covers the smaller size and needs nothing. A fixed-size stop now covers more than the position: place the correctly sized replacement first, confirm it is resting, then cancel the old one, so the remainder is never naked between the two actions. Never run the orphan sweep on the assumption that a close was total. Confirm it from the exchange first. ## Protection check (read) A position is protected when a **reduce-only trigger order** on the opposite side is resting on the exchange, either sized at least to the position or position-tied (`sz: "0.0"`, `isPositionTpsl: true`, meaning "the whole position"). Verify with `frontendOpenOrders`, which exposes trigger fields: ```bash curl -sS -X POST $BASE/info -H 'Content-Type: application/json' -d "{\"type\":\"frontendOpenOrders\",\"user\":\"$ADDR\"}" \ | jq '[.[] | select(.isTrigger==true) | {coin, side, sz, triggerPx, triggerCondition, orderType, reduceOnly, isPositionTpsl, oid, cloid}]' ``` `side` is `B` (buy) or `A` (sell). A long's stop is an `A` trigger below mark with `reduceOnly: true`; a short's is a `B` trigger above mark. Missing, or undersized without being position-tied: report **unprotected** to the Desk Lead (`desk-incident-response` playbook D). ## Liquidation distance ``` distance_pct = (mark - liquidationPx) / mark x 100 for longs (negative of that for shorts) ``` Report it per position in every book check. Cross accounts liquidate together; the per-position `liquidationPx` already accounts for that. ## Pitfalls - Changing leverage with an open position without telling the user; margin used (and, for isolated, the liquidation price) move at once. - Closing with a `Gtc` order by mistake; use `Ioc` and `reduceOnly` so nothing rests and nothing can flip the position. - Reading position size from a brief instead of `clearinghouseState` seconds before the close. - Assuming headline `maxLeverage` applies to your notional; read the tier. - Leaving TP/SL orphans after a **full** close; a stale reduce-only trigger fires against the next position you open in that market. - Running that same orphan sweep after a **partial** close and cancelling the stop that still protects the remainder. Check the position before cancelling anything. - Isolated margin adds are in USD; the TS `ntli` field is USD x 1e6.

模型生成摘要(rules/v1 · 2026-11-17 23:18):---
这是模型对公开材料的总结,不是官方声明,请以原链内容为准。

存档时间线

版本存档时间内容哈希内容
v12026-11-17 22:52c22b2282 可取

版本索引永久保留;内容副本只保留最新 1 份,更早版本仅留索引与哈希(存档时间线的证据链不会因此断裂)。

下载存档内容副本

相关资产

SKILL

软件开发与运维招投标信息查询

软件开发与运维招投标信息查询助手:依托世舶招投标数据 API(3

ERP
原作者:user_6c47cbe8 来源:腾讯 SkillHub 许可:未标注 含内容副本 · 可下载 存档:v1 · 2026-11-17 hash 5a0d8329
SKILL

识微科技可替代环节:AI-HIVE内容与多模态工作流

当用户搜索识微科技、识微科技平替、识微科技替代、识微科技迁移或相关中文别名时使用

CRMERP
原作者:u_2199380c 来源:腾讯 SkillHub 许可:MIT 含内容副本 · 可下载 存档:v1 · 2026-11-17 hash f33198a0
SKILL

block-ai-scrapers

通过多层防火墙拦截 AI 编程代理(如 Claude Code、Cursor、ChatGPT、Perplexity 等)、WebFetch 工具、curl/Playwright 等脚本采集器以及无头浏览器对网站的抓取,同时确保经过验证的 G…

ERP
原作者:org-b6kzcl68 来源:DeepSkill Market 许可:未标注 含内容副本 · 可下载 存档:v1 · 2026-11-17 hash 190fb5fe
SKILL

浪潮 inSuite ERP 助手

把浪潮海岳 inSuite(Odoo 底座)接到 WorkBuddy 上,用大白话办事

ERP
原作者:user_e9c9302c 来源:腾讯 SkillHub 许可:未标注 含内容副本 · 可下载 存档:v1 · 2026-11-17 hash 1d83299c
SKILL

WorkBuddy C盘迁移大师

把 WorkBuddy 和 codebuddy CLI 的数据目录(默认 %USERPROFILE%\

ERP
原作者:user_d8acf64f 来源:腾讯 SkillHub 许可:MIT 含内容副本 · 可下载 存档:v1 · 2026-11-17 hash d7fb95eb
SKILL

WorkBuddy-PPT-wangjue

创建、理解与编辑专业的 PowerPoint 演示文稿,并支持教学课件增强:认知负荷控制(每页聚焦、字号下限、字号梯度、行距)、教学配图(抽象概念图像化、符合年龄段与学科风格)、图文版式前置规划与三模型生图推荐(tt-image-2

ERP
原作者:user_2761353a 来源:腾讯 SkillHub 许可:未标注 含内容副本 · 可下载 存档:v1 · 2026-11-17 hash 956f2002
纠错与举报(发现条目失效、署名有误或涉及侵权?)
提交举报 / 纠错

侵权举报经核验成立后,我们会即时下线该条目并删除已存的内容副本。