deepbook-move
БесплатноБез исполняемых скриптовНе проверенGuides writing, reviewing, and debugging Move smart contracts that call DeepBook V3: placing limit or market orders on-chain, creating pools, swapping without…
от MystenLabs★ 25 звёзд на GitHubОб этом скилле
DeepBook V3 Move Integration
Setup
Move.toml:
[dependencies]
deepbook = { mvr = "@deepbook/core" }
use deepbook::pool::{Self, Pool};
use deepbook::balance_manager::{Self, BalanceManager, TradeProof, TradeCap};
Every Pool function is generic over <BaseAsset, QuoteAsset> and the type arguments must match the pool's creation order exactly: Pool<SUI, USDC> is a different type from Pool<USDC, SUI>.
Orders (require a BalanceManager + TradeProof)
public fun place_limit_order<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>,
balance_manager: &mut BalanceManager,
trade_proof: &TradeProof,
client_order_id: u64,
order_type: u8,
self_matching_option: u8,
price: u64,
quantity: u64,
is_bid: bool,
pay_with_deep: bool,
expire_timestamp: u64,
clock: &Clock,
ctx: &mut TxContext,
): OrderInfo
place_market_order takes the same arguments minus price and expire_timestamp.
cancel_order<BaseAsset, QuoteAsset>(pool, balance_manager, trade_proof, order_id, clock, ctx).
order_type constants: 0 = NO_RESTRICTION, 1 = IMMEDIATE_OR_CANCEL (IOC), 2 = FILL_OR_KILL (FOK), 3 = POST_ONLY.
Every order placement and cancellation needs a TradeProof, created in the same transaction:
// owner of the BalanceManager
public fun generate_proof_as_owner(bm: &mut BalanceManager, ctx: &TxContext): TradeProof
// delegated trader holding a TradeCap
public fun generate_proof_as_trader(bm: &mut BalanceManager, trade_cap: &TradeCap, ctx: &TxContext): TradeProof
Swaps (no BalanceManager, no TradeProof)
public fun swap_exact_base_for_quote<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>,
base_in: Coin<BaseAsset>,
deep_in: Coin<DEEP>,
min_quote_out: u64,
clock: &Clock,
ctx: &mut TxContext,
): (Coin<BaseAsset>, Coin<QuoteAsset>, Coin<DEEP>)
public fun swap_exact_quote_for_base<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>,
quote_in: Coin<QuoteAsset>,
deep_in: Coin<DEEP>,
min_base_out: u64,
clock: &Clock,
ctx: &mut TxContext,
): (Coin<BaseAsset>, Coin<QuoteAsset>, Coin<DEEP>)
Both return three coins: leftover base, leftover quote, and unused DEEP. deep_in pays the taker fee — overestimating is safe because the unused DEEP is returned; underestimating aborts.
Simulate first:
public fun get_quantity_out<BaseAsset, QuoteAsset>(
self: &Pool<BaseAsset, QuoteAsset>,
base_quantity: u64,
quote_quantity: u64,
clock: &Clock,
): (u64, u64, u64) // (base_out, quote_out, deep_required)
Exactly one of base_quantity or quote_quantity must be non-zero; passing both or neither is invalid.
Flash loans
public fun borrow_flashloan_base<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>, base_amount: u64, ctx: &mut TxContext,
): (Coin<BaseAsset>, FlashLoan)
public fun borrow_flashloan_quote<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>, quote_amount: u64, ctx: &mut TxContext,
): (Coin<QuoteAsset>, FlashLoan)
public fun return_flashloan_base<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>, coin: Coin<BaseAsset>, flash_loan: FlashLoan,
)
public fun return_flashloan_quote<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>, coin: Coin<QuoteAsset>, flash_loan: FlashLoan,
)
FlashLoan has no abilities — it cannot be stored, copied, or dropped, so it must be consumed by the matching return_flashloan_* call in the same transaction. If it is not repaid the whole transaction reverts and no state change persists. The maximum borrowable amount is the pool's current holdings of that asset. There is no borrow fee; repay the exact borrowed amount.
BalanceManager and delegation
A BalanceManager is a shared object that holds a user's balances and is reused across all pools — deposit once, trade everywhere. Two-tier authorization:
- Owner — full control: deposit, withdraw, mint and revoke caps,
generate_proof_as_owner. - Cap holders —
TradeCapcan only trade (generate_proof_as_trader); it cannot deposit or withdraw.DepositCapcan only deposit,WithdrawCapcan only withdraw.
public fun new(ctx: &mut TxContext): BalanceManager
public fun mint_trade_cap(bm: &mut BalanceManager, ctx: &mut TxContext): TradeCap
public fun deposit<T>(bm: &mut BalanceManager, coin: Coin<T>, ctx: &mut TxContext)
public fun withdraw<T>(bm: &mut BalanceManager, amount: u64, ctx: &mut TxContext): Coin<T>
Limit: 1,000 total capabilities per BalanceManager across TradeCap, DepositCap, and WithdrawCap combined. Beyond that, shard across multiple BalanceManagers.
Rules and common mistakes
- Type parameter order.
<USDC, SUI>against aPool<SUI, USDC>is a type mismatch; match the pool's base/quote order. - Return the hot potato. Forgetting
return_flashloan_*compiles but
Установить deepbook-move в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл deepbook-move?
Guides writing, reviewing, and debugging Move smart contracts that call DeepBook V3: placing limit or market orders on-chain, creating pools, swapping without a BalanceManager, flash loans, BalanceManager/TradeCap authorization, and composing DeepBook calls in programmable transaction blocks. Use when the user asks about deepbook::pool, place_limit_order, swap_exact_base_for_quote, borrow_flashloan_base, FlashLoan hot potato, TradeProof, TradeCap/DepositCap/WithdrawCap, or adding `deepbook = { mvr = "@deepbook/core" }` to Move.toml.
Как установить скилл deepbook-move?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл deepbook-move запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic