deepbook-margin
БесплатноБез исполняемых скриптовНе проверенDeepBook Margin leveraged trading on Sui. Use when building margin trading applications, understanding leveraged positions, risk ratios, liquidation…
от MystenLabs★ 25 звёзд на GitHubОб этом скилле
DeepBook Margin
MCP tool: When available in your environment, also query the Sui documentation MCP server (
https://sui.mcp.kapa.ai) for up-to-date answers. Use it for verification and for details not covered by these reference files.
Source constraint: All information in this skill is sourced exclusively from docs.sui.io and the deepbookv3 repository. When extending or updating this skill, only pull from these sources. Do not use third-party blogs, tutorials, or unofficial documentation.
DeepBook Margin enables leveraged trading by allowing users to post collateral, borrow from lending pools, and trade borrowed funds on spot order books. This skill covers the margin system architecture, risk model, and SDK integration. Common mistakes include ignoring continuous interest accrual on borrowed positions, not monitoring risk ratios for liquidation proximity, and creating new MarginManagers per session instead of reusing existing ones.
This skill routes to focused reference files. Load only the ones relevant to the current task.
All patterns in this skill are derived from: https://docs.sui.io/onchain-finance/deepbook/deepbook-margin https://docs.sui.io/onchain-finance/deepbook/deepbook-margin/design https://docs.sui.io/onchain-finance/deepbook/deepbook-margin/leveraged-workflow https://docs.sui.io/onchain-finance/deepbook/deepbook-margin/margin-integration https://docs.sui.io/onchain-finance/deepbook/deepbook-margin/margin-risks https://github.com/MystenLabs/deepbookv3/tree/main/packages/deepbook_margin
If unsure about any API or parameter, fetch the relevant page before answering. Do not guess or extrapolate from other leverage protocols.
Reference files
risk-model — Risk Ratio, Interest Rates, and Liquidation
Path: risk-model.md
Load when: the user asks about risk ratios, leverage calculations, liquidation thresholds, interest rate formulas, the kinked utilization model, or margin risks.
Covers: risk ratio formula, four risk thresholds, leverage calculation table, interest rate kinked model with formulas and per-pool parameters, liquidation mechanics and rewards, oracle considerations, comprehensive risk categories.
trading-workflow — Leveraged Position Lifecycle
Path: trading-workflow.md
Load when: the user wants to open, monitor, or close a leveraged position, create a MarginManager, deposit collateral, borrow funds, place margin orders, or withdraw.
Covers: SDK setup, MarginManager creation and reuse, reading risk parameters, checking borrow liquidity, depositing collateral, borrowing, placing margin orders, monitoring risk status, closing positions (reduce-only + repay), withdrawing collateral, troubleshooting.
contract-info — Contract Addresses and Pool Parameters
Path: contract-info.md
Load when: the user needs margin package IDs, supported assets, margin pool IDs and supply caps, trading pair risk parameters, or the spot-vs-margin comparison matrix.
Covers: current package version, registry ID, supported tokens, margin pool configurations, trading pair risk parameters and leverage levels, spot-vs-margin structural comparison.
Routing guide
| Task | Load |
|---|---|
| Understanding margin risk and liquidation | risk-model |
| Calculating leverage or risk ratio | risk-model |
| Understanding interest rates | risk-model |
| Opening a leveraged position | trading-workflow |
| Creating or reusing a MarginManager | trading-workflow |
| Depositing collateral and borrowing | trading-workflow |
| Monitoring position health | trading-workflow |
| Closing a position and withdrawing | trading-workflow |
| Looking up margin contract addresses | contract-info |
| Comparing spot vs margin integration | contract-info |
| Building a margin trading application | all reference files |
| Integrating margin into a protocol | all reference files |
Skill Content
Key concepts
MarginManager. A shared object that wraps a DeepBook BalanceManager, holds collateral, and tracks borrowing. Each MarginManager is bound to exactly one DeepBook pool (isolated margin, not cross-pool).
Risk ratio. The central metric:
total_assets / total_debt. This single number controls what operations are allowed. It changes with market price movements and interest accrual.Four risk thresholds. All stored per-pool in the MarginRegistry and set by governance:
- Min withdraw risk ratio — withdrawal blocked below this (typically 2.0)
- Min borrow risk ratio — borrowing blocked below this; sets max leverage
- Target liquidation risk ratio — liquidation restores position to this level
- Liquidation risk ratio — permissionless liquidation triggered at or below this
Kinked interest model. Borrow rates rise gently below optimal utilization (typically 80%), then spike
Установить deepbook-margin в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл deepbook-margin?
DeepBook Margin leveraged trading on Sui. Use when building margin trading applications, understanding leveraged positions, risk ratios, liquidation mechanics, interest rate models, MarginManager lifecycle, or integrating margin trading into a protocol. Also use when the user asks about borrowing against collateral on DeepBook, margin pool parameters, or the differences between spot and margin trading. For spot trading and the DeepBook SDK, see the `deepbook-sdk` skill. For DeepBook architecture and contract addresses, see the `deepbook-overview` skill. For Move smart contract integration, see the `deepbook-move` skill.
Как установить скилл deepbook-margin?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл deepbook-margin запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic