[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-sui-deepbook-margin":3,"mdc-o5v4fq-key":36,"related-org-sui-deepbook-margin":761,"related-repo-sui-deepbook-margin":915},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":25,"repoUrl":26,"updatedAt":27,"license":28,"forks":29,"topics":30,"repo":31,"sourceUrl":34,"mdContent":35},"deepbook-margin","build margin trading applications on Sui","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.\nFor 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.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"sui","Sui (Mysten Labs)","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fsui.png","MystenLabs",[13,16,19,22],{"name":14,"slug":8,"type":15},"Sui","tag",{"name":17,"slug":18,"type":15},"Finance","finance",{"name":20,"slug":21,"type":15},"Web3","web3",{"name":23,"slug":24,"type":15},"Trading","trading",9,"https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fskills","2026-08-24T03:57:04.577326",null,2,[],{"repoUrl":26,"stars":25,"forks":29,"topics":32,"description":33},[],"Sui development skills maintained by Mysten Labs","https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fskills\u002Ftree\u002FHEAD\u002Fdeepbook-margin","---\nname: deepbook-margin\ndescription: >\n  DeepBook Margin leveraged trading on Sui. Use when building margin trading\n  applications, understanding leveraged positions, risk ratios, liquidation\n  mechanics, interest rate models, MarginManager lifecycle, or integrating\n  margin trading into a protocol. Also use when the user asks about borrowing\n  against collateral on DeepBook, margin pool parameters, or the differences\n  between spot and margin trading.\n\n  For spot trading and the DeepBook SDK, see the `deepbook-sdk` skill.\n  For DeepBook architecture and contract addresses, see the `deepbook-overview` skill.\n  For Move smart contract integration, see the `deepbook-move` skill.\n---\n\n# DeepBook Margin\n\n> **MCP tool:** When available in your environment, also query the Sui documentation MCP server (`https:\u002F\u002Fsui.mcp.kapa.ai`) for up-to-date answers. Use it for verification and for details not covered by these reference files.\n\n> **Source constraint:** All information in this skill is sourced exclusively from [docs.sui.io](https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin) and the [deepbookv3 repository](https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fdeepbookv3). When extending or updating this skill, only pull from these sources. Do not use third-party blogs, tutorials, or unofficial documentation.\n\nDeepBook 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.\n\nThis skill routes to focused reference files. Load only the ones relevant to the current task.\n\nAll patterns in this skill are derived from:\n  https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\n  https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fdesign\n  https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fleveraged-workflow\n  https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fmargin-integration\n  https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fmargin-risks\n  https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fdeepbookv3\u002Ftree\u002Fmain\u002Fpackages\u002Fdeepbook_margin\n\nIf unsure about any API or parameter, fetch the relevant page before answering.\nDo not guess or extrapolate from other leverage protocols.\n\n---\n\n## Reference files\n\n### risk-model — Risk Ratio, Interest Rates, and Liquidation\n**Path:** `risk-model.md`\n**Load when:** the user asks about risk ratios, leverage calculations, liquidation thresholds, interest rate formulas, the kinked utilization model, or margin risks.\n**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.\n\n### trading-workflow — Leveraged Position Lifecycle\n**Path:** `trading-workflow.md`\n**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.\n**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.\n\n### contract-info — Contract Addresses and Pool Parameters\n**Path:** `contract-info.md`\n**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.\n**Covers:** current package version, registry ID, supported tokens, margin pool configurations, trading pair risk parameters and leverage levels, spot-vs-margin structural comparison.\n\n---\n\n## Routing guide\n\n| Task | Load |\n|------|------|\n| Understanding margin risk and liquidation | risk-model |\n| Calculating leverage or risk ratio | risk-model |\n| Understanding interest rates | risk-model |\n| Opening a leveraged position | trading-workflow |\n| Creating or reusing a MarginManager | trading-workflow |\n| Depositing collateral and borrowing | trading-workflow |\n| Monitoring position health | trading-workflow |\n| Closing a position and withdrawing | trading-workflow |\n| Looking up margin contract addresses | contract-info |\n| Comparing spot vs margin integration | contract-info |\n| Building a margin trading application | **all reference files** |\n| Integrating margin into a protocol | **all reference files** |\n\n---\n\n## Skill Content\n\n### Key concepts\n\n- **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).\n\n- **Risk ratio.** The central metric: `total_assets \u002F total_debt`. This single number controls what operations are allowed. It changes with market price movements and interest accrual.\n\n- **Four risk thresholds.** All stored per-pool in the MarginRegistry and set by governance:\n  - **Min withdraw risk ratio** — withdrawal blocked below this (typically 2.0)\n  - **Min borrow risk ratio** — borrowing blocked below this; sets max leverage\n  - **Target liquidation risk ratio** — liquidation restores position to this level\n  - **Liquidation risk ratio** — permissionless liquidation triggered at or below this\n\n- **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.\n\n- **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%).\n\n### Rules\n\n1. **Read risk parameters on-chain.** All thresholds are governance-set and can change. Never hardcode them.\n2. **Use `_v2` functions for margin orders** (`place_limit_order_v2`, `place_market_order_v2`). The unsuffixed originals are deprecated.\n3. **Every margin operation requires Pyth `PriceInfoObject` arguments.** Unlike spot trading, margin has an oracle dependency for all operations (borrow, withdraw, risk reads, trading).\n4. **Reuse MarginManagers.** Creating a new one per session fragments collateral across orphaned shared objects. Discover existing managers via the registry.\n5. **Size borrows from risk parameters, not trial and error.** The min borrow risk ratio defines your maximum leverage per unit of collateral.\n6. **`clientOrderId` must be a numeric string** (encoded as u64), same as spot.\n\n### Common mistakes\n\n- **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.\n- **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.\n- **Creating new MarginManagers per run.** This fragments collateral. Use `findMarginManagerId` to discover existing managers before creating new ones.\n- **Borrowing and trading in the same pool without oracle freshness checks.** If the Pyth price exceeds the pool's maximum age, the operation reverts.\n- **Confusing margin order entry with spot.** Margin orders route through a pool proxy with risk checks, not the direct spot order entry.\n",{"data":37,"body":38},{"name":4,"description":6},{"type":39,"children":40},"root",[41,49,74,107,112,117,157,162,166,173,180,210,216,242,248,274,277,283,465,468,474,480,586,592,694,700],{"type":42,"tag":43,"props":44,"children":45},"element","h1",{"id":4},[46],{"type":47,"value":48},"text","DeepBook Margin",{"type":42,"tag":50,"props":51,"children":52},"blockquote",{},[53],{"type":42,"tag":54,"props":55,"children":56},"p",{},[57,63,65,72],{"type":42,"tag":58,"props":59,"children":60},"strong",{},[61],{"type":47,"value":62},"MCP tool:",{"type":47,"value":64}," When available in your environment, also query the Sui documentation MCP server (",{"type":42,"tag":66,"props":67,"children":69},"code",{"className":68},[],[70],{"type":47,"value":71},"https:\u002F\u002Fsui.mcp.kapa.ai",{"type":47,"value":73},") for up-to-date answers. Use it for verification and for details not covered by these reference files.",{"type":42,"tag":50,"props":75,"children":76},{},[77],{"type":42,"tag":54,"props":78,"children":79},{},[80,85,87,96,98,105],{"type":42,"tag":58,"props":81,"children":82},{},[83],{"type":47,"value":84},"Source constraint:",{"type":47,"value":86}," All information in this skill is sourced exclusively from ",{"type":42,"tag":88,"props":89,"children":93},"a",{"href":90,"rel":91},"https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin",[92],"nofollow",[94],{"type":47,"value":95},"docs.sui.io",{"type":47,"value":97}," and the ",{"type":42,"tag":88,"props":99,"children":102},{"href":100,"rel":101},"https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fdeepbookv3",[92],[103],{"type":47,"value":104},"deepbookv3 repository",{"type":47,"value":106},". When extending or updating this skill, only pull from these sources. Do not use third-party blogs, tutorials, or unofficial documentation.",{"type":42,"tag":54,"props":108,"children":109},{},[110],{"type":47,"value":111},"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.",{"type":42,"tag":54,"props":113,"children":114},{},[115],{"type":47,"value":116},"This skill routes to focused reference files. Load only the ones relevant to the current task.",{"type":42,"tag":54,"props":118,"children":119},{},[120,122,127,133,139,145,151],{"type":47,"value":121},"All patterns in this skill are derived from:\n",{"type":42,"tag":88,"props":123,"children":125},{"href":90,"rel":124},[92],[126],{"type":47,"value":90},{"type":42,"tag":88,"props":128,"children":131},{"href":129,"rel":130},"https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fdesign",[92],[132],{"type":47,"value":129},{"type":42,"tag":88,"props":134,"children":137},{"href":135,"rel":136},"https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fleveraged-workflow",[92],[138],{"type":47,"value":135},{"type":42,"tag":88,"props":140,"children":143},{"href":141,"rel":142},"https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fmargin-integration",[92],[144],{"type":47,"value":141},{"type":42,"tag":88,"props":146,"children":149},{"href":147,"rel":148},"https:\u002F\u002Fdocs.sui.io\u002Fonchain-finance\u002Fdeepbook\u002Fdeepbook-margin\u002Fmargin-risks",[92],[150],{"type":47,"value":147},{"type":42,"tag":88,"props":152,"children":155},{"href":153,"rel":154},"https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fdeepbookv3\u002Ftree\u002Fmain\u002Fpackages\u002Fdeepbook_margin",[92],[156],{"type":47,"value":153},{"type":42,"tag":54,"props":158,"children":159},{},[160],{"type":47,"value":161},"If unsure about any API or parameter, fetch the relevant page before answering.\nDo not guess or extrapolate from other leverage protocols.",{"type":42,"tag":163,"props":164,"children":165},"hr",{},[],{"type":42,"tag":167,"props":168,"children":170},"h2",{"id":169},"reference-files",[171],{"type":47,"value":172},"Reference files",{"type":42,"tag":174,"props":175,"children":177},"h3",{"id":176},"risk-model-risk-ratio-interest-rates-and-liquidation",[178],{"type":47,"value":179},"risk-model — Risk Ratio, Interest Rates, and Liquidation",{"type":42,"tag":54,"props":181,"children":182},{},[183,188,190,196,201,203,208],{"type":42,"tag":58,"props":184,"children":185},{},[186],{"type":47,"value":187},"Path:",{"type":47,"value":189}," ",{"type":42,"tag":66,"props":191,"children":193},{"className":192},[],[194],{"type":47,"value":195},"risk-model.md",{"type":42,"tag":58,"props":197,"children":198},{},[199],{"type":47,"value":200},"Load when:",{"type":47,"value":202}," the user asks about risk ratios, leverage calculations, liquidation thresholds, interest rate formulas, the kinked utilization model, or margin risks.\n",{"type":42,"tag":58,"props":204,"children":205},{},[206],{"type":47,"value":207},"Covers:",{"type":47,"value":209}," 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.",{"type":42,"tag":174,"props":211,"children":213},{"id":212},"trading-workflow-leveraged-position-lifecycle",[214],{"type":47,"value":215},"trading-workflow — Leveraged Position Lifecycle",{"type":42,"tag":54,"props":217,"children":218},{},[219,223,224,230,234,236,240],{"type":42,"tag":58,"props":220,"children":221},{},[222],{"type":47,"value":187},{"type":47,"value":189},{"type":42,"tag":66,"props":225,"children":227},{"className":226},[],[228],{"type":47,"value":229},"trading-workflow.md",{"type":42,"tag":58,"props":231,"children":232},{},[233],{"type":47,"value":200},{"type":47,"value":235}," the user wants to open, monitor, or close a leveraged position, create a MarginManager, deposit collateral, borrow funds, place margin orders, or withdraw.\n",{"type":42,"tag":58,"props":237,"children":238},{},[239],{"type":47,"value":207},{"type":47,"value":241}," 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.",{"type":42,"tag":174,"props":243,"children":245},{"id":244},"contract-info-contract-addresses-and-pool-parameters",[246],{"type":47,"value":247},"contract-info — Contract Addresses and Pool Parameters",{"type":42,"tag":54,"props":249,"children":250},{},[251,255,256,262,266,268,272],{"type":42,"tag":58,"props":252,"children":253},{},[254],{"type":47,"value":187},{"type":47,"value":189},{"type":42,"tag":66,"props":257,"children":259},{"className":258},[],[260],{"type":47,"value":261},"contract-info.md",{"type":42,"tag":58,"props":263,"children":264},{},[265],{"type":47,"value":200},{"type":47,"value":267}," 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.\n",{"type":42,"tag":58,"props":269,"children":270},{},[271],{"type":47,"value":207},{"type":47,"value":273}," current package version, registry ID, supported tokens, margin pool configurations, trading pair risk parameters and leverage levels, spot-vs-margin structural comparison.",{"type":42,"tag":163,"props":275,"children":276},{},[],{"type":42,"tag":167,"props":278,"children":280},{"id":279},"routing-guide",[281],{"type":47,"value":282},"Routing guide",{"type":42,"tag":284,"props":285,"children":286},"table",{},[287,306],{"type":42,"tag":288,"props":289,"children":290},"thead",{},[291],{"type":42,"tag":292,"props":293,"children":294},"tr",{},[295,301],{"type":42,"tag":296,"props":297,"children":298},"th",{},[299],{"type":47,"value":300},"Task",{"type":42,"tag":296,"props":302,"children":303},{},[304],{"type":47,"value":305},"Load",{"type":42,"tag":307,"props":308,"children":309},"tbody",{},[310,324,336,348,361,373,385,397,409,422,434,450],{"type":42,"tag":292,"props":311,"children":312},{},[313,319],{"type":42,"tag":314,"props":315,"children":316},"td",{},[317],{"type":47,"value":318},"Understanding margin risk and liquidation",{"type":42,"tag":314,"props":320,"children":321},{},[322],{"type":47,"value":323},"risk-model",{"type":42,"tag":292,"props":325,"children":326},{},[327,332],{"type":42,"tag":314,"props":328,"children":329},{},[330],{"type":47,"value":331},"Calculating leverage or risk ratio",{"type":42,"tag":314,"props":333,"children":334},{},[335],{"type":47,"value":323},{"type":42,"tag":292,"props":337,"children":338},{},[339,344],{"type":42,"tag":314,"props":340,"children":341},{},[342],{"type":47,"value":343},"Understanding interest rates",{"type":42,"tag":314,"props":345,"children":346},{},[347],{"type":47,"value":323},{"type":42,"tag":292,"props":349,"children":350},{},[351,356],{"type":42,"tag":314,"props":352,"children":353},{},[354],{"type":47,"value":355},"Opening a leveraged position",{"type":42,"tag":314,"props":357,"children":358},{},[359],{"type":47,"value":360},"trading-workflow",{"type":42,"tag":292,"props":362,"children":363},{},[364,369],{"type":42,"tag":314,"props":365,"children":366},{},[367],{"type":47,"value":368},"Creating or reusing a MarginManager",{"type":42,"tag":314,"props":370,"children":371},{},[372],{"type":47,"value":360},{"type":42,"tag":292,"props":374,"children":375},{},[376,381],{"type":42,"tag":314,"props":377,"children":378},{},[379],{"type":47,"value":380},"Depositing collateral and borrowing",{"type":42,"tag":314,"props":382,"children":383},{},[384],{"type":47,"value":360},{"type":42,"tag":292,"props":386,"children":387},{},[388,393],{"type":42,"tag":314,"props":389,"children":390},{},[391],{"type":47,"value":392},"Monitoring position health",{"type":42,"tag":314,"props":394,"children":395},{},[396],{"type":47,"value":360},{"type":42,"tag":292,"props":398,"children":399},{},[400,405],{"type":42,"tag":314,"props":401,"children":402},{},[403],{"type":47,"value":404},"Closing a position and withdrawing",{"type":42,"tag":314,"props":406,"children":407},{},[408],{"type":47,"value":360},{"type":42,"tag":292,"props":410,"children":411},{},[412,417],{"type":42,"tag":314,"props":413,"children":414},{},[415],{"type":47,"value":416},"Looking up margin contract addresses",{"type":42,"tag":314,"props":418,"children":419},{},[420],{"type":47,"value":421},"contract-info",{"type":42,"tag":292,"props":423,"children":424},{},[425,430],{"type":42,"tag":314,"props":426,"children":427},{},[428],{"type":47,"value":429},"Comparing spot vs margin integration",{"type":42,"tag":314,"props":431,"children":432},{},[433],{"type":47,"value":421},{"type":42,"tag":292,"props":435,"children":436},{},[437,442],{"type":42,"tag":314,"props":438,"children":439},{},[440],{"type":47,"value":441},"Building a margin trading application",{"type":42,"tag":314,"props":443,"children":444},{},[445],{"type":42,"tag":58,"props":446,"children":447},{},[448],{"type":47,"value":449},"all reference files",{"type":42,"tag":292,"props":451,"children":452},{},[453,458],{"type":42,"tag":314,"props":454,"children":455},{},[456],{"type":47,"value":457},"Integrating margin into a protocol",{"type":42,"tag":314,"props":459,"children":460},{},[461],{"type":42,"tag":58,"props":462,"children":463},{},[464],{"type":47,"value":449},{"type":42,"tag":163,"props":466,"children":467},{},[],{"type":42,"tag":167,"props":469,"children":471},{"id":470},"skill-content",[472],{"type":47,"value":473},"Skill Content",{"type":42,"tag":174,"props":475,"children":477},{"id":476},"key-concepts",[478],{"type":47,"value":479},"Key concepts",{"type":42,"tag":481,"props":482,"children":483},"ul",{},[484,495,513,566,576],{"type":42,"tag":485,"props":486,"children":487},"li",{},[488,493],{"type":42,"tag":58,"props":489,"children":490},{},[491],{"type":47,"value":492},"MarginManager.",{"type":47,"value":494}," 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).",{"type":42,"tag":485,"props":496,"children":497},{},[498,503,505,511],{"type":42,"tag":58,"props":499,"children":500},{},[501],{"type":47,"value":502},"Risk ratio.",{"type":47,"value":504}," The central metric: ",{"type":42,"tag":66,"props":506,"children":508},{"className":507},[],[509],{"type":47,"value":510},"total_assets \u002F total_debt",{"type":47,"value":512},". This single number controls what operations are allowed. It changes with market price movements and interest accrual.",{"type":42,"tag":485,"props":514,"children":515},{},[516,521,523],{"type":42,"tag":58,"props":517,"children":518},{},[519],{"type":47,"value":520},"Four risk thresholds.",{"type":47,"value":522}," All stored per-pool in the MarginRegistry and set by governance:",{"type":42,"tag":481,"props":524,"children":525},{},[526,536,546,556],{"type":42,"tag":485,"props":527,"children":528},{},[529,534],{"type":42,"tag":58,"props":530,"children":531},{},[532],{"type":47,"value":533},"Min withdraw risk ratio",{"type":47,"value":535}," — withdrawal blocked below this (typically 2.0)",{"type":42,"tag":485,"props":537,"children":538},{},[539,544],{"type":42,"tag":58,"props":540,"children":541},{},[542],{"type":47,"value":543},"Min borrow risk ratio",{"type":47,"value":545}," — borrowing blocked below this; sets max leverage",{"type":42,"tag":485,"props":547,"children":548},{},[549,554],{"type":42,"tag":58,"props":550,"children":551},{},[552],{"type":47,"value":553},"Target liquidation risk ratio",{"type":47,"value":555}," — liquidation restores position to this level",{"type":42,"tag":485,"props":557,"children":558},{},[559,564],{"type":42,"tag":58,"props":560,"children":561},{},[562],{"type":47,"value":563},"Liquidation risk ratio",{"type":47,"value":565}," — permissionless liquidation triggered at or below this",{"type":42,"tag":485,"props":567,"children":568},{},[569,574],{"type":42,"tag":58,"props":570,"children":571},{},[572],{"type":47,"value":573},"Kinked interest model.",{"type":47,"value":575}," 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.",{"type":42,"tag":485,"props":577,"children":578},{},[579,584],{"type":42,"tag":58,"props":580,"children":581},{},[582],{"type":47,"value":583},"Permissionless liquidation.",{"type":47,"value":585}," 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%).",{"type":42,"tag":174,"props":587,"children":589},{"id":588},"rules",[590],{"type":47,"value":591},"Rules",{"type":42,"tag":593,"props":594,"children":595},"ol",{},[596,606,640,658,668,678],{"type":42,"tag":485,"props":597,"children":598},{},[599,604],{"type":42,"tag":58,"props":600,"children":601},{},[602],{"type":47,"value":603},"Read risk parameters on-chain.",{"type":47,"value":605}," All thresholds are governance-set and can change. Never hardcode them.",{"type":42,"tag":485,"props":607,"children":608},{},[609,622,624,630,632,638],{"type":42,"tag":58,"props":610,"children":611},{},[612,614,620],{"type":47,"value":613},"Use ",{"type":42,"tag":66,"props":615,"children":617},{"className":616},[],[618],{"type":47,"value":619},"_v2",{"type":47,"value":621}," functions for margin orders",{"type":47,"value":623}," (",{"type":42,"tag":66,"props":625,"children":627},{"className":626},[],[628],{"type":47,"value":629},"place_limit_order_v2",{"type":47,"value":631},", ",{"type":42,"tag":66,"props":633,"children":635},{"className":634},[],[636],{"type":47,"value":637},"place_market_order_v2",{"type":47,"value":639},"). The unsuffixed originals are deprecated.",{"type":42,"tag":485,"props":641,"children":642},{},[643,656],{"type":42,"tag":58,"props":644,"children":645},{},[646,648,654],{"type":47,"value":647},"Every margin operation requires Pyth ",{"type":42,"tag":66,"props":649,"children":651},{"className":650},[],[652],{"type":47,"value":653},"PriceInfoObject",{"type":47,"value":655}," arguments.",{"type":47,"value":657}," Unlike spot trading, margin has an oracle dependency for all operations (borrow, withdraw, risk reads, trading).",{"type":42,"tag":485,"props":659,"children":660},{},[661,666],{"type":42,"tag":58,"props":662,"children":663},{},[664],{"type":47,"value":665},"Reuse MarginManagers.",{"type":47,"value":667}," Creating a new one per session fragments collateral across orphaned shared objects. Discover existing managers via the registry.",{"type":42,"tag":485,"props":669,"children":670},{},[671,676],{"type":42,"tag":58,"props":672,"children":673},{},[674],{"type":47,"value":675},"Size borrows from risk parameters, not trial and error.",{"type":47,"value":677}," The min borrow risk ratio defines your maximum leverage per unit of collateral.",{"type":42,"tag":485,"props":679,"children":680},{},[681,692],{"type":42,"tag":58,"props":682,"children":683},{},[684,690],{"type":42,"tag":66,"props":685,"children":687},{"className":686},[],[688],{"type":47,"value":689},"clientOrderId",{"type":47,"value":691}," must be a numeric string",{"type":47,"value":693}," (encoded as u64), same as spot.",{"type":42,"tag":174,"props":695,"children":697},{"id":696},"common-mistakes",[698],{"type":47,"value":699},"Common mistakes",{"type":42,"tag":481,"props":701,"children":702},{},[703,713,723,741,751],{"type":42,"tag":485,"props":704,"children":705},{},[706,711],{"type":42,"tag":58,"props":707,"children":708},{},[709],{"type":47,"value":710},"Ignoring interest accrual.",{"type":47,"value":712}," 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.",{"type":42,"tag":485,"props":714,"children":715},{},[716,721],{"type":42,"tag":58,"props":717,"children":718},{},[719],{"type":47,"value":720},"Not monitoring risk ratio.",{"type":47,"value":722}," There is no grace period before liquidation. Integrators must surface the risk ratio and its distance to the liquidation threshold to users.",{"type":42,"tag":485,"props":724,"children":725},{},[726,731,733,739],{"type":42,"tag":58,"props":727,"children":728},{},[729],{"type":47,"value":730},"Creating new MarginManagers per run.",{"type":47,"value":732}," This fragments collateral. Use ",{"type":42,"tag":66,"props":734,"children":736},{"className":735},[],[737],{"type":47,"value":738},"findMarginManagerId",{"type":47,"value":740}," to discover existing managers before creating new ones.",{"type":42,"tag":485,"props":742,"children":743},{},[744,749],{"type":42,"tag":58,"props":745,"children":746},{},[747],{"type":47,"value":748},"Borrowing and trading in the same pool without oracle freshness checks.",{"type":47,"value":750}," If the Pyth price exceeds the pool's maximum age, the operation reverts.",{"type":42,"tag":485,"props":752,"children":753},{},[754,759],{"type":42,"tag":58,"props":755,"children":756},{},[757],{"type":47,"value":758},"Confusing margin order entry with spot.",{"type":47,"value":760}," Margin orders route through a pool proxy with risk checks, not the direct spot order entry.",{"items":762,"total":914},[763,779,790,800,817,835,847,860,867,878,889,900],{"slug":764,"name":764,"fn":765,"description":766,"org":767,"tags":768,"stars":776,"repoUrl":777,"updatedAt":778},"move-bytecode-comprehension","analyze and disassemble Move bytecode","Use when reading or reasoning about compiled Move bytecode or `sui move disassemble` output. Mental model for the binary format, what survives compilation (and what's lost), and how to read disassembly soundly. Trigger on \"what does this package do?\", \"read this .mv module\", \"interpret this disassembly\", or whenever an analysis needs to interpret bytecode faithfully.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[769,772,775],{"name":770,"slug":771,"type":15},"Code Analysis","code-analysis",{"name":773,"slug":774,"type":15},"Engineering","engineering",{"name":14,"slug":8,"type":15},7724,"https:\u002F\u002Fgithub.com\u002FMystenLabs\u002Fsui","2026-07-16T05:59:32.904886",{"slug":780,"name":780,"fn":781,"description":782,"org":783,"tags":784,"stars":776,"repoUrl":777,"updatedAt":789},"official-sui-skills","access official Sui development resources","Pointer to the official Mysten Labs skills for building on Sui — language fundamentals, object model, PTBs, SDKs, publishing, upgrades, frontend integration, accessing on-chain data. Maintained upstream at github.com\u002FMystenLabs\u002Fskills; pinned to the same ref the audit catalog derives from (see maintenance\u002FUPSTREAMS.md). Trigger on \"build a contract\", \"publish a package\", \"upgrade a module or package\", \"use the TypeScript SDK\", \"write a PTB\", \"set up a Sui client\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[785,788],{"name":786,"slug":787,"type":15},"Documentation","documentation",{"name":14,"slug":8,"type":15},"2026-07-16T06:00:59.641382",{"slug":791,"name":791,"fn":792,"description":793,"org":794,"tags":795,"stars":776,"repoUrl":777,"updatedAt":799},"sui-and-move-tools","disassemble Sui Move bytecode","Use to get bytecode for a deployed Sui package and produce a disassembled working view. One GraphQL call fetches every module's raw bytecode bytes; `sui move disassemble` (already on the system, running `sui prompt`) produces `.asm` files for analysis. Trigger on \"fetch this package's bytecode\", \"get me the .mv for package X\", \"disassemble this package\", or \"I need to read a deployed Sui package\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[796,797,798],{"name":770,"slug":771,"type":15},{"name":773,"slug":774,"type":15},{"name":14,"slug":8,"type":15},"2026-07-16T06:02:25.3633",{"slug":801,"name":801,"fn":802,"description":803,"org":804,"tags":805,"stars":776,"repoUrl":777,"updatedAt":816},"sui-move-security-review","audit Sui Move smart contracts","Use when auditing, reviewing, or hunting for vulnerabilities in Move code on Sui. Applies equally to source code (.move files) and to disassembly of compiled bytecode (on-chain packages). A checklist of invariants whose VIOLATION causes exploitable bugs: access control & capabilities, struct abilities & type safety, object lifecycle & ownership, shared-object and PTB attack surface, dynamic fields & collections, arithmetic & coins, init\u002FOTW\u002Fpackage upgrades, hot-potato composability, time & on-chain randomness, and test-only code leakage. Trigger on \"audit this Move code\", \"find vulnerabilities in this Sui contract\", \"security review\", \"is this package safe?\", \"I suspect there's a bug in X\", \"something is wrong with this contract\", or when reasoning about whether a Move function can be abused.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[806,809,812,815],{"name":807,"slug":808,"type":15},"Code Review","code-review",{"name":810,"slug":811,"type":15},"Security","security",{"name":813,"slug":814,"type":15},"Smart Contracts","smart-contracts",{"name":14,"slug":8,"type":15},"2026-07-16T06:02:55.691149",{"slug":818,"name":818,"fn":819,"description":820,"org":821,"tags":822,"stars":832,"repoUrl":833,"updatedAt":834},"memwal","integrate Walrus Memory SDK","Walrus Memory SDK — portable agent memory that works across apps, sessions, and workflows.\n\nUse when users say:\n- \"add memory to my app\"\n- \"portable agent memory\"\n- \"integrate Walrus Memory\"\n- \"AI agent memory\"\n- \"memory across agents\"\n- \"Walrus memory storage\"\n- \"setup Walrus Memory\"\n- \"recall memories\"\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[823,826,829],{"name":824,"slug":825,"type":15},"Agents","agents",{"name":827,"slug":828,"type":15},"Memory","memory",{"name":830,"slug":831,"type":15},"SDK","sdk",57,"https:\u002F\u002Fgithub.com\u002FMystenLabs\u002FMemWal","2026-08-20T03:29:22.543459",{"slug":836,"name":836,"fn":837,"description":838,"org":839,"tags":840,"stars":25,"repoUrl":26,"updatedAt":846},"accessing-data","read data from the Sui network","How to read data from the Sui network. Use when choosing or implementing a data access strategy — queries for on-chain state, indexing pipelines, historical lookups, event subscriptions, cross-chain reads, or off-chain blob storage. Covers the two live Sui APIs (gRPC and GraphQL RPC), the Archival Store, the General-Purpose Indexer, the `sui-indexer-alt` custom indexing framework, and Walrus for off-chain blobs.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[841,844,845],{"name":842,"slug":843,"type":15},"Data Analysis","data-analysis",{"name":14,"slug":8,"type":15},{"name":20,"slug":21,"type":15},"2026-08-01T05:44:32.775598",{"slug":848,"name":848,"fn":849,"description":850,"org":851,"tags":852,"stars":25,"repoUrl":26,"updatedAt":859},"composable-move-functions","design composable Sui Move functions","Use when writing Move functions on Sui, especially public APIs. Applies to function visibility (public vs entry), parameter ordering, and return patterns. Use whenever designing function signatures or deciding whether functions should transfer objects or return them.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[853,856,857,858],{"name":854,"slug":855,"type":15},"API Development","api-development",{"name":813,"slug":814,"type":15},{"name":14,"slug":8,"type":15},{"name":20,"slug":21,"type":15},"2026-07-16T06:02:49.198495",{"slug":4,"name":4,"fn":5,"description":6,"org":861,"tags":862,"stars":25,"repoUrl":26,"updatedAt":27},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[863,864,865,866],{"name":17,"slug":18,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"slug":868,"name":868,"fn":869,"description":870,"org":871,"tags":872,"stars":25,"repoUrl":26,"updatedAt":877},"deepbook-move","integrate DeepBook pools into Move contracts","DeepBook V3 Move smart contract integration. Use when writing, reviewing, or debugging Move code that integrates with DeepBook pools — placing orders from on-chain contracts, creating pools, using flash loans, accessing BalanceManager from Move, or composing DeepBook operations in programmable transaction blocks.\nFor DeepBook architecture and contract addresses, see the `deepbook-overview` skill. For TypeScript SDK usage, see the `deepbook-sdk` skill.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[873,874,875,876],{"name":813,"slug":814,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},"2026-08-24T03:57:01.149367",{"slug":879,"name":879,"fn":880,"description":881,"org":882,"tags":883,"stars":25,"repoUrl":26,"updatedAt":888},"deepbook-overview","explain DeepBook V3 architecture and concepts","High-level overview of DeepBook V3 on Sui — architecture, key concepts, integration models, contract addresses, supported coins, and pool information. Use when explaining DeepBook to someone new, comparing integration approaches (Move vs SDK vs read-only), looking up mainnet\u002Ftestnet contract addresses, or understanding the Pool\u002FBook\u002FState\u002FVault design.\nFor TypeScript SDK usage and trading, see the `deepbook-sdk` skill. For Move smart contract integration, see the `deepbook-move` skill.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[884,885,886,887],{"name":786,"slug":787,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},"2026-08-24T03:57:01.535714",{"slug":890,"name":890,"fn":891,"description":892,"org":893,"tags":894,"stars":25,"repoUrl":26,"updatedAt":899},"deepbook-predict","build prediction market applications on Sui","DeepBook Predict — expiry-based prediction market protocol on Sui. Use when building prediction market applications, minting binary or vertical range positions, understanding oracle lifecycle, working with PredictManager accounts, or integrating vault liquidity (PLP). Also use when the user asks about DeepBook binary options, range positions, DUSDC, OracleSVI, or settlement.\nNote: DeepBook Predict is currently on Testnet only. Smart contracts may change before Mainnet deployment.\nFor spot trading, see the `deepbook-sdk` skill. For margin trading, see the `deepbook-margin` skill. For DeepBook architecture, see the `deepbook-overview` skill.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[895,896,897,898],{"name":17,"slug":18,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},"2026-08-24T03:57:04.953545",{"slug":901,"name":901,"fn":902,"description":903,"org":904,"tags":905,"stars":25,"repoUrl":26,"updatedAt":913},"deepbook-sdk","build trading applications with DeepBook SDK","DeepBook V3 TypeScript SDK integration. Use when building trading applications, bots, or scripts that interact with DeepBook pools using the @mysten\u002Fdeepbook-v3 SDK. Covers client setup, BalanceManager lifecycle, placing limit and market orders, swaps, querying order books, order management, and fee handling.\nFor DeepBook architecture and contract addresses, see the `deepbook-overview` skill. For Move smart contract integration, see the `deepbook-move` skill.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[906,907,908,909,912],{"name":830,"slug":831,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":910,"slug":911,"type":15},"TypeScript","typescript",{"name":20,"slug":21,"type":15},"2026-08-24T03:57:02.735676",42,{"items":916,"total":966},[917,923,930,937,944,951,958],{"slug":836,"name":836,"fn":837,"description":838,"org":918,"tags":919,"stars":25,"repoUrl":26,"updatedAt":846},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[920,921,922],{"name":842,"slug":843,"type":15},{"name":14,"slug":8,"type":15},{"name":20,"slug":21,"type":15},{"slug":848,"name":848,"fn":849,"description":850,"org":924,"tags":925,"stars":25,"repoUrl":26,"updatedAt":859},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[926,927,928,929],{"name":854,"slug":855,"type":15},{"name":813,"slug":814,"type":15},{"name":14,"slug":8,"type":15},{"name":20,"slug":21,"type":15},{"slug":4,"name":4,"fn":5,"description":6,"org":931,"tags":932,"stars":25,"repoUrl":26,"updatedAt":27},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[933,934,935,936],{"name":17,"slug":18,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"slug":868,"name":868,"fn":869,"description":870,"org":938,"tags":939,"stars":25,"repoUrl":26,"updatedAt":877},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[940,941,942,943],{"name":813,"slug":814,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"slug":879,"name":879,"fn":880,"description":881,"org":945,"tags":946,"stars":25,"repoUrl":26,"updatedAt":888},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[947,948,949,950],{"name":786,"slug":787,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"slug":890,"name":890,"fn":891,"description":892,"org":952,"tags":953,"stars":25,"repoUrl":26,"updatedAt":899},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[954,955,956,957],{"name":17,"slug":18,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":20,"slug":21,"type":15},{"slug":901,"name":901,"fn":902,"description":903,"org":959,"tags":960,"stars":25,"repoUrl":26,"updatedAt":913},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[961,962,963,964,965],{"name":830,"slug":831,"type":15},{"name":14,"slug":8,"type":15},{"name":23,"slug":24,"type":15},{"name":910,"slug":911,"type":15},{"name":20,"slug":21,"type":15},25]