Logo di Deepbook Margin

Deepbook Margin

Organizzazione
MystenLabs
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.

Panoramica

AutoreMystenLabs
Repositoryskills
Nome della skilldeepbook-margin
Stelle
21
Fork
12
File inclusi
4
LicenzaApache-2.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 4 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da MystenLabs su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Deepbook Margin in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/MystenLabs/skills/tree/main/deepbook-margin
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MystenLabs/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/deepbook-margin .claude/skills/deepbook-margin
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Deepbook Margin in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Deepbook Margin non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Deepbook Margin non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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

TaskLoad
Understanding margin risk and liquidationrisk-model
Calculating leverage or risk ratiorisk-model
Understanding interest ratesrisk-model
Opening a leveraged positiontrading-workflow
Creating or reusing a MarginManagertrading-workflow
Depositing collateral and borrowingtrading-workflow
Monitoring position healthtrading-workflow
Closing a position and withdrawingtrading-workflow
Looking up margin contract addressescontract-info
Comparing spot vs margin integrationcontract-info
Building a margin trading applicationall reference files
Integrating margin into a protocolall 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 sharply above it. Interest accrues at event-driven intervals (whenever pool state changes), not continuously — but the effect is that debt grows over time even when prices are stable.

  • Permissionless liquidation. Once risk ratio reaches the liquidation threshold, anyone can liquidate the position. There is no grace period. Liquidators receive collateral rewards (typically 2%) and the pool takes additional rewards (typically 3%).

Rules

  1. Read risk parameters on-chain. All thresholds are governance-set and can change. Never hardcode them.
  2. Use _v2 functions for margin orders (place_limit_order_v2, place_market_order_v2). The unsuffixed originals are deprecated.
  3. Every margin operation requires Pyth PriceInfoObject arguments. Unlike spot trading, margin has an oracle dependency for all operations (borrow, withdraw, risk reads, trading).
  4. Reuse MarginManagers. Creating a new one per session fragments collateral across orphaned shared objects. Discover existing managers via the registry.
  5. Size borrows from risk parameters, not trial and error. The min borrow risk ratio defines your maximum leverage per unit of collateral.
  6. clientOrderId must be a numeric string (encoded as u64), same as spot.

Common mistakes

  • Ignoring interest accrual. Debt grows at event-driven intervals (whenever pool state changes — borrows, repays, liquidations). A position can drift toward liquidation purely from accumulated interest, even with stable prices.
  • Not monitoring risk ratio. There is no grace period before liquidation. Integrators must surface the risk ratio and its distance to the liquidation threshold to users.
  • Creating new MarginManagers per run. This fragments collateral. Use findMarginManagerId to discover existing managers before creating new ones.
  • Borrowing and trading in the same pool without oracle freshness checks. If the Pyth price exceeds the pool's maximum age, the operation reverts.
  • Confusing margin order entry with spot. Margin orders route through a pool proxy with risk checks, not the direct spot order entry.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA 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,...

Perché usare Deepbook Margin su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Deepbook Margin è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Deepbook Margin in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/MystenLabs/skills/tree/main/deepbook-margin. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Deepbook Margin?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Deepbook Margin?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Deepbook Margin: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Deepbook Margin è gratuita?

Sì. È pubblicata su GitHub da MystenLabs con licenza Apache-2.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇