/************************************************************** * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * **************************************************************/ /** Public-facing interface for the package. */ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; import { bcs } from '@mysten/sui/bcs'; import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions'; import * as versioned from './deps/sui/versioned.js'; import * as vec_set from './deps/sui/vec_set.js'; import * as book from './book.js'; import * as state from './state.js'; import * as vault from './vault.js'; import * as deep_price from './deep_price.js'; import * as balance from './deps/sui/balance.js'; const $moduleName = '@deepbook/core::pool'; export const Pool = new MoveStruct({ name: `${$moduleName}::Pool`, fields: { id: bcs.Address, inner: versioned.Versioned, }, }); export const PoolInner = new MoveStruct({ name: `${$moduleName}::PoolInner`, fields: { allowed_versions: vec_set.VecSet(bcs.u64()), pool_id: bcs.Address, book: book.Book, state: state.State, vault: vault.Vault, deep_price: deep_price.DeepPrice, registered_pool: bcs.bool(), }, }); export const PoolCreated = new MoveStruct({ name: `${$moduleName}::PoolCreated`, fields: { pool_id: bcs.Address, taker_fee: bcs.u64(), maker_fee: bcs.u64(), tick_size: bcs.u64(), lot_size: bcs.u64(), min_size: bcs.u64(), whitelisted_pool: bcs.bool(), treasury_address: bcs.Address, }, }); export const BookParamsUpdated = new MoveStruct({ name: `${$moduleName}::BookParamsUpdated`, fields: { pool_id: bcs.Address, tick_size: bcs.u64(), lot_size: bcs.u64(), min_size: bcs.u64(), timestamp: bcs.u64(), }, }); export const DeepBurned = new MoveStruct({ name: `${$moduleName}::DeepBurned`, fields: { pool_id: bcs.Address, deep_burned: bcs.u64(), }, }); export const ReferralRewards = new MoveStruct({ name: `${$moduleName}::ReferralRewards`, fields: { multiplier: bcs.u64(), base: balance.Balance, quote: balance.Balance, deep: balance.Balance, }, }); export const ReferralClaimedEvent = new MoveStruct({ name: `${$moduleName}::ReferralClaimedEvent`, fields: { referral_id: bcs.Address, owner: bcs.Address, base_amount: bcs.u64(), quote_amount: bcs.u64(), deep_amount: bcs.u64(), }, }); export const ReferralClaimed = new MoveStruct({ name: `${$moduleName}::ReferralClaimed`, fields: { pool_id: bcs.Address, referral_id: bcs.Address, owner: bcs.Address, base_amount: bcs.u64(), quote_amount: bcs.u64(), deep_amount: bcs.u64(), }, }); export const ReferralFeeEvent = new MoveStruct({ name: `${$moduleName}::ReferralFeeEvent`, fields: { pool_id: bcs.Address, referral_id: bcs.Address, base_fee: bcs.u64(), quote_fee: bcs.u64(), deep_fee: bcs.u64(), }, }); export interface CreatePermissionlessPoolArguments { registry: RawTransactionArgument; tickSize: RawTransactionArgument; lotSize: RawTransactionArgument; minSize: RawTransactionArgument; creationFee: RawTransactionArgument; } export interface CreatePermissionlessPoolOptions { package?: string; arguments: | CreatePermissionlessPoolArguments | [ registry: RawTransactionArgument, tickSize: RawTransactionArgument, lotSize: RawTransactionArgument, minSize: RawTransactionArgument, creationFee: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Create a new pool. The pool is registered in the registry. Checks are performed * to ensure the tick size, lot size, and min size are valid. The creation fee is * transferred to the treasury address. Returns the id of the pool created */ export function createPermissionlessPool(options: CreatePermissionlessPoolOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', 'u64', null] satisfies (string | null)[]; const parameterNames = ['registry', 'tickSize', 'lotSize', 'minSize', 'creationFee']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'create_permissionless_pool', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PlaceLimitOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; clientOrderId: RawTransactionArgument; orderType: RawTransactionArgument; selfMatchingOption: RawTransactionArgument; price: RawTransactionArgument; quantity: RawTransactionArgument; isBid: RawTransactionArgument; payWithDeep: RawTransactionArgument; expireTimestamp: RawTransactionArgument; } export interface PlaceLimitOrderOptions { package?: string; arguments: | PlaceLimitOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, clientOrderId: RawTransactionArgument, orderType: RawTransactionArgument, selfMatchingOption: RawTransactionArgument, price: RawTransactionArgument, quantity: RawTransactionArgument, isBid: RawTransactionArgument, payWithDeep: RawTransactionArgument, expireTimestamp: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Place a limit order. Quantity is in base asset terms. For current version * pay_with_deep must be true, so the fee will be paid with DEEP tokens. */ export function placeLimitOrder(options: PlaceLimitOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, null, 'u64', 'u8', 'u8', 'u64', 'u64', 'bool', 'bool', 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeProof', 'clientOrderId', 'orderType', 'selfMatchingOption', 'price', 'quantity', 'isBid', 'payWithDeep', 'expireTimestamp', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'place_limit_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PlacePostOnlyLimitOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; clientOrderId: RawTransactionArgument; price: RawTransactionArgument; quantity: RawTransactionArgument; isBid: RawTransactionArgument; payWithDeep: RawTransactionArgument; expireTimestamp: RawTransactionArgument; } export interface PlacePostOnlyLimitOrderOptions { package?: string; arguments: | PlacePostOnlyLimitOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, clientOrderId: RawTransactionArgument, price: RawTransactionArgument, quantity: RawTransactionArgument, isBid: RawTransactionArgument, payWithDeep: RawTransactionArgument, expireTimestamp: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Graceful post-only limit order. Checks the relevant side of the book first and * only forwards to `place_limit_order` with `POST_ONLY` when the order is * guaranteed not to cross a live order the matcher can reach. Returns `none` * instead of aborting `EPOSTOrderCrossesOrderbook` when it would cross — and also * `none` when the forwarded placement rests nothing (a large expired backlog at a * crossing price makes `place_limit_order` hit its fill limit and inject no * order), so `some` always means the order is resting on the book. An empty * opposite side always allows placement. * * Self-matching is fixed to `SELF_MATCHING_ALLOWED` and is not a parameter: the * wrapper only ever forwards a non-crossing order, and self-matching governs how a * _crossing_ fill treats the taker's own maker orders, so it has no effect on the * forwarded placement. Exposing it would also be a footgun — `CANCEL_TAKER` aborts * (`ESelfMatchingCancelTaker`) against the caller's own expired order sitting at a * crossing price, which the pre-check skips as non-live, re-introducing the very * abort this wrapper exists to avoid. A caller that wants to cross and cancel its * own resting orders should call `place_limit_order` directly. */ export function placePostOnlyLimitOrder(options: PlacePostOnlyLimitOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, null, 'u64', 'u64', 'u64', 'bool', 'bool', 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeProof', 'clientOrderId', 'price', 'quantity', 'isBid', 'payWithDeep', 'expireTimestamp', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'place_post_only_limit_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PlaceMarketOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; clientOrderId: RawTransactionArgument; selfMatchingOption: RawTransactionArgument; quantity: RawTransactionArgument; isBid: RawTransactionArgument; payWithDeep: RawTransactionArgument; } export interface PlaceMarketOrderOptions { package?: string; arguments: | PlaceMarketOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, clientOrderId: RawTransactionArgument, selfMatchingOption: RawTransactionArgument, quantity: RawTransactionArgument, isBid: RawTransactionArgument, payWithDeep: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Place a market order. Quantity is in base asset terms. Calls place_limit_order * with a price of MAX_PRICE for bids and MIN_PRICE for asks. Any quantity not * filled is cancelled. */ export function placeMarketOrder(options: PlaceMarketOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, null, 'u64', 'u8', 'u64', 'bool', 'bool', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeProof', 'clientOrderId', 'selfMatchingOption', 'quantity', 'isBid', 'payWithDeep', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'place_market_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SwapExactBaseForQuoteArguments { self: RawTransactionArgument; baseIn: RawTransactionArgument; deepIn: RawTransactionArgument; minQuoteOut: RawTransactionArgument; } export interface SwapExactBaseForQuoteOptions { package?: string; arguments: | SwapExactBaseForQuoteArguments | [ self: RawTransactionArgument, baseIn: RawTransactionArgument, deepIn: RawTransactionArgument, minQuoteOut: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Swap exact base quantity without needing a `balance_manager`. DEEP quantity can * be overestimated. Returns three `Coin` objects: base, quote, and deep. Some base * quantity may be left over, if the input quantity is not divisible by lot size. */ export function swapExactBaseForQuote(options: SwapExactBaseForQuoteOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'baseIn', 'deepIn', 'minQuoteOut']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'swap_exact_base_for_quote', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SwapExactBaseForQuoteWithManagerArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeCap: RawTransactionArgument; depositCap: RawTransactionArgument; withdrawCap: RawTransactionArgument; baseIn: RawTransactionArgument; minQuoteOut: RawTransactionArgument; } export interface SwapExactBaseForQuoteWithManagerOptions { package?: string; arguments: | SwapExactBaseForQuoteWithManagerArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeCap: RawTransactionArgument, depositCap: RawTransactionArgument, withdrawCap: RawTransactionArgument, baseIn: RawTransactionArgument, minQuoteOut: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Swap exact base for quote with a `balance_manager`. Assumes fees are paid in * DEEP. Assumes balance manager has enough DEEP for fees. */ export function swapExactBaseForQuoteWithManager(options: SwapExactBaseForQuoteWithManagerOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, null, null, null, null, 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeCap', 'depositCap', 'withdrawCap', 'baseIn', 'minQuoteOut', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'swap_exact_base_for_quote_with_manager', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SwapExactQuoteForBaseArguments { self: RawTransactionArgument; quoteIn: RawTransactionArgument; deepIn: RawTransactionArgument; minBaseOut: RawTransactionArgument; } export interface SwapExactQuoteForBaseOptions { package?: string; arguments: | SwapExactQuoteForBaseArguments | [ self: RawTransactionArgument, quoteIn: RawTransactionArgument, deepIn: RawTransactionArgument, minBaseOut: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Swap exact quote quantity without needing a `balance_manager`. DEEP quantity can * be overestimated. Returns three `Coin` objects: base, quote, and deep. Some * quote quantity may be left over if the input quantity is not divisible by lot * size. */ export function swapExactQuoteForBase(options: SwapExactQuoteForBaseOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'quoteIn', 'deepIn', 'minBaseOut']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'swap_exact_quote_for_base', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SwapExactQuoteForBaseWithManagerArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeCap: RawTransactionArgument; depositCap: RawTransactionArgument; withdrawCap: RawTransactionArgument; quoteIn: RawTransactionArgument; minBaseOut: RawTransactionArgument; } export interface SwapExactQuoteForBaseWithManagerOptions { package?: string; arguments: | SwapExactQuoteForBaseWithManagerArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeCap: RawTransactionArgument, depositCap: RawTransactionArgument, withdrawCap: RawTransactionArgument, quoteIn: RawTransactionArgument, minBaseOut: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Swap exact quote for base with a `balance_manager`. Assumes fees are paid in * DEEP. Assumes balance manager has enough DEEP for fees. */ export function swapExactQuoteForBaseWithManager(options: SwapExactQuoteForBaseWithManagerOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, null, null, null, null, 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeCap', 'depositCap', 'withdrawCap', 'quoteIn', 'minBaseOut', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'swap_exact_quote_for_base_with_manager', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SwapExactQuantityArguments { self: RawTransactionArgument; baseIn: RawTransactionArgument; quoteIn: RawTransactionArgument; deepIn: RawTransactionArgument; minOut: RawTransactionArgument; } export interface SwapExactQuantityOptions { package?: string; arguments: | SwapExactQuantityArguments | [ self: RawTransactionArgument, baseIn: RawTransactionArgument, quoteIn: RawTransactionArgument, deepIn: RawTransactionArgument, minOut: RawTransactionArgument, ]; typeArguments: [string, string]; } /** Swap exact quantity without needing a balance_manager. */ export function swapExactQuantity(options: SwapExactQuantityOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, null, 'u64', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'baseIn', 'quoteIn', 'deepIn', 'minOut']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'swap_exact_quantity', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SwapExactQuantityWithManagerArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeCap: RawTransactionArgument; depositCap: RawTransactionArgument; withdrawCap: RawTransactionArgument; baseIn: RawTransactionArgument; quoteIn: RawTransactionArgument; minOut: RawTransactionArgument; } export interface SwapExactQuantityWithManagerOptions { package?: string; arguments: | SwapExactQuantityWithManagerArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeCap: RawTransactionArgument, depositCap: RawTransactionArgument, withdrawCap: RawTransactionArgument, baseIn: RawTransactionArgument, quoteIn: RawTransactionArgument, minOut: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Swap exact quantity with a `balance_manager`. Assumes fees are paid in DEEP. * Assumes balance manager has enough DEEP for fees. */ export function swapExactQuantityWithManager(options: SwapExactQuantityWithManagerOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, null, null, null, null, null, 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeCap', 'depositCap', 'withdrawCap', 'baseIn', 'quoteIn', 'minOut', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'swap_exact_quantity_with_manager', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface ModifyOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; orderId: RawTransactionArgument; newQuantity: RawTransactionArgument; } export interface ModifyOrderOptions { package?: string; arguments: | ModifyOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, orderId: RawTransactionArgument, newQuantity: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Modifies an order given order_id and new_quantity. New quantity must be less * than the original quantity and more than the filled quantity. Order must not * have already expired. */ export function modifyOrder(options: ModifyOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u128', 'u64', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId', 'newQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'modify_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CancelOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; orderId: RawTransactionArgument; } export interface CancelOrderOptions { package?: string; arguments: | CancelOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, orderId: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Cancel an order. The order must be owned by the balance_manager. The order is * removed from the book and the balance_manager's open orders. The * balance_manager's balance is updated with the order's remaining quantity. Order * canceled event is emitted. */ export function cancelOrder(options: CancelOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u128', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'cancel_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CancelOrdersArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; orderIds: RawTransactionArgument>; } export interface CancelOrdersOptions { package?: string; arguments: | CancelOrdersArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, orderIds: RawTransactionArgument>, ]; typeArguments: [string, string]; } /** * Cancel multiple orders within a vector. The orders must be owned by the * balance_manager. The orders are removed from the book and the balance_manager's * open orders. Order canceled events are emitted. If any order fails to cancel, no * orders will be cancelled. */ export function cancelOrders(options: CancelOrdersOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'vector', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderIds']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'cancel_orders', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CancelLiveOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; orderId: RawTransactionArgument; } export interface CancelLiveOrderOptions { package?: string; arguments: | CancelLiveOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, orderId: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Cancel a single order, no-op if the order_id is not currently in the * balance_manager's open orders (e.g. already filled, cancelled, or not owned by * this balance_manager). If the order is present, it must be owned by the * balance_manager. On a successful cancel the order is removed from the book and * the balance_manager's open orders, and an order canceled event is emitted. */ export function cancelLiveOrder(options: CancelLiveOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u128', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'cancel_live_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CancelLiveOrdersArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; orderIds: RawTransactionArgument>; } export interface CancelLiveOrdersOptions { package?: string; arguments: | CancelLiveOrdersArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, orderIds: RawTransactionArgument>, ]; typeArguments: [string, string]; } /** * Cancel multiple orders within a vector, skipping any order_id that is not * currently in the balance_manager's open orders (e.g. already filled, cancelled, * or not owned by this balance_manager). Orders that are present must be owned by * the balance_manager. The live orders are removed from the book and the * balance_manager's open orders. Order canceled events are emitted for each * cancelled order. */ export function cancelLiveOrders(options: CancelLiveOrdersOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'vector', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderIds']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'cancel_live_orders', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CancelAllOrdersArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; } export interface CancelAllOrdersOptions { package?: string; arguments: | CancelAllOrdersArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, ]; typeArguments: [string, string]; } /** Cancel all open orders placed by the balance manager in the pool. */ export function cancelAllOrders(options: CancelAllOrdersOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager', 'tradeProof']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'cancel_all_orders', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface WithdrawSettledAmountsArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; } export interface WithdrawSettledAmountsOptions { package?: string; arguments: | WithdrawSettledAmountsArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, ]; typeArguments: [string, string]; } /** Withdraw settled amounts to the `balance_manager`. */ export function withdrawSettledAmounts(options: WithdrawSettledAmountsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager', 'tradeProof']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'withdraw_settled_amounts', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface WithdrawSettledAmountsPermissionlessArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; } export interface WithdrawSettledAmountsPermissionlessOptions { package?: string; arguments: | WithdrawSettledAmountsPermissionlessArguments | [self: RawTransactionArgument, balanceManager: RawTransactionArgument]; typeArguments: [string, string]; } /** Withdraw settled amounts permissionlessly to the `balance_manager`. */ export function withdrawSettledAmountsPermissionless( options: WithdrawSettledAmountsPermissionlessOptions, ) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'withdraw_settled_amounts_permissionless', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface StakeArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; amount: RawTransactionArgument; } export interface StakeOptions { package?: string; arguments: | StakeArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, amount: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Stake DEEP tokens to the pool. The balance_manager must have enough DEEP tokens. * The balance_manager's data is updated with the staked amount. */ export function stake(options: StakeOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'amount']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'stake', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UnstakeArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; } export interface UnstakeOptions { package?: string; arguments: | UnstakeArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, ]; typeArguments: [string, string]; } /** * Unstake DEEP tokens from the pool. The balance_manager must have enough staked * DEEP tokens. The balance_manager's data is updated with the unstaked amount. * Balance is transferred to the balance_manager immediately. */ export function unstake(options: UnstakeOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager', 'tradeProof']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'unstake', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SubmitProposalArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; takerFee: RawTransactionArgument; makerFee: RawTransactionArgument; stakeRequired: RawTransactionArgument; } export interface SubmitProposalOptions { package?: string; arguments: | SubmitProposalArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, takerFee: RawTransactionArgument, makerFee: RawTransactionArgument, stakeRequired: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Submit a proposal to change the taker fee, maker fee, and stake required. The * balance_manager must have enough staked DEEP tokens to participate. Each * balance_manager can only submit one proposal per epoch. If the maximum proposal * is reached, the proposal with the lowest vote is removed. If the balance_manager * has less voting power than the lowest voted proposal, the proposal is not added. */ export function submitProposal(options: SubmitProposalOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, 'u64', 'u64', 'u64'] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'tradeProof', 'takerFee', 'makerFee', 'stakeRequired', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'submit_proposal', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface VoteArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; proposalId: RawTransactionArgument; } export interface VoteOptions { package?: string; arguments: | VoteArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, proposalId: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Vote on a proposal. The balance_manager must have enough staked DEEP tokens to * participate. Full voting power of the balance_manager is used. Voting for a new * proposal will remove the vote from the previous proposal. */ export function vote(options: VoteOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null, '0x2::object::ID'] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager', 'tradeProof', 'proposalId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'vote', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface ClaimRebatesArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; tradeProof: TransactionArgument; } export interface ClaimRebatesOptions { package?: string; arguments: | ClaimRebatesArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, tradeProof: TransactionArgument, ]; typeArguments: [string, string]; } /** * Claim the rewards for the balance_manager. The balance_manager must have rewards * to claim. The balance_manager's data is updated with the claimed rewards. */ export function claimRebates(options: ClaimRebatesOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager', 'tradeProof']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'claim_rebates', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface BorrowFlashloanBaseArguments { self: RawTransactionArgument; baseAmount: RawTransactionArgument; } export interface BorrowFlashloanBaseOptions { package?: string; arguments: | BorrowFlashloanBaseArguments | [self: RawTransactionArgument, baseAmount: RawTransactionArgument]; typeArguments: [string, string]; } /** * Borrow base assets from the Pool. A hot potato is returned, forcing the borrower * to return the assets within the same transaction. */ export function borrowFlashloanBase(options: BorrowFlashloanBaseOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'baseAmount']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'borrow_flashloan_base', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface BorrowFlashloanQuoteArguments { self: RawTransactionArgument; quoteAmount: RawTransactionArgument; } export interface BorrowFlashloanQuoteOptions { package?: string; arguments: | BorrowFlashloanQuoteArguments | [self: RawTransactionArgument, quoteAmount: RawTransactionArgument]; typeArguments: [string, string]; } /** * Borrow quote assets from the Pool. A hot potato is returned, forcing the * borrower to return the assets within the same transaction. */ export function borrowFlashloanQuote(options: BorrowFlashloanQuoteOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'quoteAmount']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'borrow_flashloan_quote', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface ReturnFlashloanBaseArguments { self: RawTransactionArgument; coin: RawTransactionArgument; flashLoan: TransactionArgument; } export interface ReturnFlashloanBaseOptions { package?: string; arguments: | ReturnFlashloanBaseArguments | [ self: RawTransactionArgument, coin: RawTransactionArgument, flashLoan: TransactionArgument, ]; typeArguments: [string, string]; } /** * Return the flashloaned base assets to the Pool. FlashLoan object will only be * unwrapped if the assets are returned, otherwise the transaction will fail. */ export function returnFlashloanBase(options: ReturnFlashloanBaseOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'coin', 'flashLoan']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'return_flashloan_base', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface ReturnFlashloanQuoteArguments { self: RawTransactionArgument; coin: RawTransactionArgument; flashLoan: TransactionArgument; } export interface ReturnFlashloanQuoteOptions { package?: string; arguments: | ReturnFlashloanQuoteArguments | [ self: RawTransactionArgument, coin: RawTransactionArgument, flashLoan: TransactionArgument, ]; typeArguments: [string, string]; } /** * Return the flashloaned quote assets to the Pool. FlashLoan object will only be * unwrapped if the assets are returned, otherwise the transaction will fail. */ export function returnFlashloanQuote(options: ReturnFlashloanQuoteOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'coin', 'flashLoan']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'return_flashloan_quote', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface AddDeepPricePointArguments { targetPool: RawTransactionArgument; referencePool: RawTransactionArgument; } export interface AddDeepPricePointOptions { package?: string; arguments: | AddDeepPricePointArguments | [targetPool: RawTransactionArgument, referencePool: RawTransactionArgument]; typeArguments: [string, string, string, string]; } /** * Adds a price point along with a timestamp to the deep price. Allows for the * calculation of deep price per base asset. */ export function addDeepPricePoint(options: AddDeepPricePointOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['targetPool', 'referencePool']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'add_deep_price_point', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface BurnDeepArguments { self: RawTransactionArgument; treasuryCap: RawTransactionArgument; } export interface BurnDeepOptions { package?: string; arguments: | BurnDeepArguments | [self: RawTransactionArgument, treasuryCap: RawTransactionArgument]; typeArguments: [string, string]; } /** Burns DEEP tokens from the pool. Amount to burn is within history */ export function burnDeep(options: BurnDeepOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'treasuryCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'burn_deep', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface MintReferralArguments { self: RawTransactionArgument; multiplier: RawTransactionArgument; } export interface MintReferralOptions { package?: string; arguments: | MintReferralArguments | [self: RawTransactionArgument, multiplier: RawTransactionArgument]; typeArguments: [string, string]; } /** Mint a DeepBookReferral and set the additional bps for the referral. */ export function mintReferral(options: MintReferralOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'multiplier']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'mint_referral', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UpdateReferralMultiplierArguments { Self: RawTransactionArgument; Referral: RawTransactionArgument; Multiplier: RawTransactionArgument; } export interface UpdateReferralMultiplierOptions { package?: string; arguments: | UpdateReferralMultiplierArguments | [ Self: RawTransactionArgument, Referral: RawTransactionArgument, Multiplier: RawTransactionArgument, ]; typeArguments: [string, string]; } export function updateReferralMultiplier(options: UpdateReferralMultiplierOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[]; const parameterNames = ['Self', 'Referral', 'Multiplier']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'update_referral_multiplier', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UpdateDeepbookReferralMultiplierArguments { Self: RawTransactionArgument; Referral: RawTransactionArgument; Multiplier: RawTransactionArgument; } export interface UpdateDeepbookReferralMultiplierOptions { package?: string; arguments: | UpdateDeepbookReferralMultiplierArguments | [ Self: RawTransactionArgument, Referral: RawTransactionArgument, Multiplier: RawTransactionArgument, ]; typeArguments: [string, string]; } export function updateDeepbookReferralMultiplier(options: UpdateDeepbookReferralMultiplierOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[]; const parameterNames = ['Self', 'Referral', 'Multiplier']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'update_deepbook_referral_multiplier', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UpdatePoolReferralMultiplierArguments { self: RawTransactionArgument; referral: RawTransactionArgument; multiplier: RawTransactionArgument; } export interface UpdatePoolReferralMultiplierOptions { package?: string; arguments: | UpdatePoolReferralMultiplierArguments | [ self: RawTransactionArgument, referral: RawTransactionArgument, multiplier: RawTransactionArgument, ]; typeArguments: [string, string]; } /** Update the multiplier for the referral. */ export function updatePoolReferralMultiplier(options: UpdatePoolReferralMultiplierOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'referral', 'multiplier']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'update_pool_referral_multiplier', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface ClaimReferralRewardsArguments { Self: RawTransactionArgument; Referral: RawTransactionArgument; } export interface ClaimReferralRewardsOptions { package?: string; arguments: | ClaimReferralRewardsArguments | [Self: RawTransactionArgument, Referral: RawTransactionArgument]; typeArguments: [string, string]; } export function claimReferralRewards(options: ClaimReferralRewardsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['Self', 'Referral']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'claim_referral_rewards', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface ClaimPoolReferralRewardsArguments { self: RawTransactionArgument; referral: RawTransactionArgument; } export interface ClaimPoolReferralRewardsOptions { package?: string; arguments: | ClaimPoolReferralRewardsArguments | [self: RawTransactionArgument, referral: RawTransactionArgument]; typeArguments: [string, string]; } /** Claim the rewards for the referral. */ export function claimPoolReferralRewards(options: ClaimPoolReferralRewardsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'referral']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'claim_pool_referral_rewards', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CreatePoolAdminArguments { registry: RawTransactionArgument; tickSize: RawTransactionArgument; lotSize: RawTransactionArgument; minSize: RawTransactionArgument; whitelistedPool: RawTransactionArgument; stablePool: RawTransactionArgument; Cap: RawTransactionArgument; } export interface CreatePoolAdminOptions { package?: string; arguments: | CreatePoolAdminArguments | [ registry: RawTransactionArgument, tickSize: RawTransactionArgument, lotSize: RawTransactionArgument, minSize: RawTransactionArgument, whitelistedPool: RawTransactionArgument, stablePool: RawTransactionArgument, Cap: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Create a new pool. The pool is registered in the registry. Checks are performed * to ensure the tick size, lot size, and min size are valid. Returns the id of the * pool created */ export function createPoolAdmin(options: CreatePoolAdminOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', 'u64', 'bool', 'bool', null] satisfies ( string | null )[]; const parameterNames = [ 'registry', 'tickSize', 'lotSize', 'minSize', 'whitelistedPool', 'stablePool', 'Cap', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'create_pool_admin', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UnregisterPoolAdminArguments { self: RawTransactionArgument; registry: RawTransactionArgument; Cap: RawTransactionArgument; } export interface UnregisterPoolAdminOptions { package?: string; arguments: | UnregisterPoolAdminArguments | [ self: RawTransactionArgument, registry: RawTransactionArgument, Cap: RawTransactionArgument, ]; typeArguments: [string, string]; } /** Unregister a pool in case it needs to be redeployed. */ export function unregisterPoolAdmin(options: UnregisterPoolAdminOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'registry', 'Cap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'unregister_pool_admin', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UpdateAllowedVersionsArguments { self: RawTransactionArgument; registry: RawTransactionArgument; Cap: RawTransactionArgument; } export interface UpdateAllowedVersionsOptions { package?: string; arguments: | UpdateAllowedVersionsArguments | [ self: RawTransactionArgument, registry: RawTransactionArgument, Cap: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Takes the registry and updates the allowed version within pool Only admin can * update the allowed versions This function does not have version restrictions */ export function updateAllowedVersions(options: UpdateAllowedVersionsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['self', 'registry', 'Cap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'update_allowed_versions', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface UpdatePoolAllowedVersionsArguments { self: RawTransactionArgument; registry: RawTransactionArgument; } export interface UpdatePoolAllowedVersionsOptions { package?: string; arguments: | UpdatePoolAllowedVersionsArguments | [self: RawTransactionArgument, registry: RawTransactionArgument]; typeArguments: [string, string]; } /** * Takes the registry and updates the allowed version within pool Permissionless * equivalent of `update_allowed_versions` This function does not have version * restrictions */ export function updatePoolAllowedVersions(options: UpdatePoolAllowedVersionsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'registry']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'update_pool_allowed_versions', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface AdjustTickSizeAdminArguments { self: RawTransactionArgument; newTickSize: RawTransactionArgument; Cap: RawTransactionArgument; } export interface AdjustTickSizeAdminOptions { package?: string; arguments: | AdjustTickSizeAdminArguments | [ self: RawTransactionArgument, newTickSize: RawTransactionArgument, Cap: RawTransactionArgument, ]; typeArguments: [string, string]; } /** Adjust the tick size of the pool. Only admin can adjust the tick size. */ export function adjustTickSizeAdmin(options: AdjustTickSizeAdminOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', null, '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'newTickSize', 'Cap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'adjust_tick_size_admin', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface AdjustMinLotSizeAdminArguments { self: RawTransactionArgument; newLotSize: RawTransactionArgument; newMinSize: RawTransactionArgument; Cap: RawTransactionArgument; } export interface AdjustMinLotSizeAdminOptions { package?: string; arguments: | AdjustMinLotSizeAdminArguments | [ self: RawTransactionArgument, newLotSize: RawTransactionArgument, newMinSize: RawTransactionArgument, Cap: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Adjust and lot size and min size of the pool. New lot size must be smaller than * current lot size. Only admin can adjust the min size and lot size. */ export function adjustMinLotSizeAdmin(options: AdjustMinLotSizeAdminOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', null, '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'newLotSize', 'newMinSize', 'Cap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'adjust_min_lot_size_admin', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface EnableEwmaStateArguments { self: RawTransactionArgument; Cap: RawTransactionArgument; enable: RawTransactionArgument; } export interface EnableEwmaStateOptions { package?: string; arguments: | EnableEwmaStateArguments | [ self: RawTransactionArgument, Cap: RawTransactionArgument, enable: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Enable the EWMA state for the pool. This allows the pool to use the EWMA state * for volatility calculations and additional taker fees. */ export function enableEwmaState(options: EnableEwmaStateOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, 'bool', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'Cap', 'enable']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'enable_ewma_state', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface SetEwmaParamsArguments { self: RawTransactionArgument; Cap: RawTransactionArgument; alpha: RawTransactionArgument; zScoreThreshold: RawTransactionArgument; additionalTakerFee: RawTransactionArgument; } export interface SetEwmaParamsOptions { package?: string; arguments: | SetEwmaParamsArguments | [ self: RawTransactionArgument, Cap: RawTransactionArgument, alpha: RawTransactionArgument, zScoreThreshold: RawTransactionArgument, additionalTakerFee: RawTransactionArgument, ]; typeArguments: [string, string]; } /** Set the EWMA parameters for the pool. Only admin can set the parameters. */ export function setEwmaParams(options: SetEwmaParamsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, 'u64', 'u64', 'u64', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'Cap', 'alpha', 'zScoreThreshold', 'additionalTakerFee']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'set_ewma_params', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface WhitelistedArguments { self: RawTransactionArgument; } export interface WhitelistedOptions { package?: string; arguments: WhitelistedArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Accessor to check if the pool is whitelisted. */ export function whitelisted(options: WhitelistedOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'whitelisted', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface StablePoolArguments { self: RawTransactionArgument; } export interface StablePoolOptions { package?: string; arguments: StablePoolArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Accessor to check if the pool is a stablecoin pool. */ export function stablePool(options: StablePoolOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'stable_pool', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface RegisteredPoolArguments { self: RawTransactionArgument; } export interface RegisteredPoolOptions { package?: string; arguments: RegisteredPoolArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } export function registeredPool(options: RegisteredPoolOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'registered_pool', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetQuoteQuantityOutArguments { self: RawTransactionArgument; baseQuantity: RawTransactionArgument; } export interface GetQuoteQuantityOutOptions { package?: string; arguments: | GetQuoteQuantityOutArguments | [self: RawTransactionArgument, baseQuantity: RawTransactionArgument]; typeArguments: [string, string]; } /** * Dry run to determine the quote quantity out for a given base quantity. Uses DEEP * token as fee. */ export function getQuoteQuantityOut(options: GetQuoteQuantityOutOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'baseQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_quote_quantity_out', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetBaseQuantityOutArguments { self: RawTransactionArgument; quoteQuantity: RawTransactionArgument; } export interface GetBaseQuantityOutOptions { package?: string; arguments: | GetBaseQuantityOutArguments | [ self: RawTransactionArgument, quoteQuantity: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Dry run to determine the base quantity out for a given quote quantity. Uses DEEP * token as fee. */ export function getBaseQuantityOut(options: GetBaseQuantityOutOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'quoteQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_base_quantity_out', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetQuoteQuantityOutInputFeeArguments { self: RawTransactionArgument; baseQuantity: RawTransactionArgument; } export interface GetQuoteQuantityOutInputFeeOptions { package?: string; arguments: | GetQuoteQuantityOutInputFeeArguments | [self: RawTransactionArgument, baseQuantity: RawTransactionArgument]; typeArguments: [string, string]; } /** * Dry run to determine the quote quantity out for a given base quantity. Uses * input token as fee. */ export function getQuoteQuantityOutInputFee(options: GetQuoteQuantityOutInputFeeOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'baseQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_quote_quantity_out_input_fee', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetBaseQuantityOutInputFeeArguments { self: RawTransactionArgument; quoteQuantity: RawTransactionArgument; } export interface GetBaseQuantityOutInputFeeOptions { package?: string; arguments: | GetBaseQuantityOutInputFeeArguments | [ self: RawTransactionArgument, quoteQuantity: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Dry run to determine the base quantity out for a given quote quantity. Uses * input token as fee. */ export function getBaseQuantityOutInputFee(options: GetBaseQuantityOutInputFeeOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'quoteQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_base_quantity_out_input_fee', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetQuantityOutArguments { self: RawTransactionArgument; baseQuantity: RawTransactionArgument; quoteQuantity: RawTransactionArgument; } export interface GetQuantityOutOptions { package?: string; arguments: | GetQuantityOutArguments | [ self: RawTransactionArgument, baseQuantity: RawTransactionArgument, quoteQuantity: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Dry run to determine the quantity out for a given base or quote quantity. Only * one out of base or quote quantity should be non-zero. Returns the * (base_quantity_out, quote_quantity_out, deep_quantity_required) Uses DEEP token * as fee. */ export function getQuantityOut(options: GetQuantityOutOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'baseQuantity', 'quoteQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_quantity_out', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetQuantityOutInputFeeArguments { self: RawTransactionArgument; baseQuantity: RawTransactionArgument; quoteQuantity: RawTransactionArgument; } export interface GetQuantityOutInputFeeOptions { package?: string; arguments: | GetQuantityOutInputFeeArguments | [ self: RawTransactionArgument, baseQuantity: RawTransactionArgument, quoteQuantity: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Dry run to determine the quantity out for a given base or quote quantity. Only * one out of base or quote quantity should be non-zero. Returns the * (base_quantity_out, quote_quantity_out, deep_quantity_required) Uses input token * as fee. */ export function getQuantityOutInputFee(options: GetQuantityOutInputFeeOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'baseQuantity', 'quoteQuantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_quantity_out_input_fee', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetBaseQuantityInArguments { self: RawTransactionArgument; targetQuoteQuantity: RawTransactionArgument; payWithDeep: RawTransactionArgument; } export interface GetBaseQuantityInOptions { package?: string; arguments: | GetBaseQuantityInArguments | [ self: RawTransactionArgument, targetQuoteQuantity: RawTransactionArgument, payWithDeep: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Dry run to determine the base quantity needed to sell to receive a target quote * quantity. Returns (base_quantity_in, actual_quote_quantity_out, * deep_quantity_required) Returns (0, 0, 0) if insufficient liquidity or if result * would be below min_size. */ export function getBaseQuantityIn(options: GetBaseQuantityInOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'bool', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'targetQuoteQuantity', 'payWithDeep']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_base_quantity_in', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetQuoteQuantityInArguments { self: RawTransactionArgument; targetBaseQuantity: RawTransactionArgument; payWithDeep: RawTransactionArgument; } export interface GetQuoteQuantityInOptions { package?: string; arguments: | GetQuoteQuantityInArguments | [ self: RawTransactionArgument, targetBaseQuantity: RawTransactionArgument, payWithDeep: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Dry run to determine the quote quantity needed to buy a target base quantity. * Returns (actual_base_quantity_out, quote_quantity_in, deep_quantity_required) * Returns (0, 0, 0) if insufficient liquidity or if result would be below * min_size. */ export function getQuoteQuantityIn(options: GetQuoteQuantityInOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'bool', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'targetBaseQuantity', 'payWithDeep']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_quote_quantity_in', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface MidPriceArguments { self: RawTransactionArgument; } export interface MidPriceOptions { package?: string; arguments: MidPriceArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Returns the mid price of the pool. */ export function midPrice(options: MidPriceOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'mid_price', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface BestAskPriceArguments { self: RawTransactionArgument; } export interface BestAskPriceOptions { package?: string; arguments: BestAskPriceArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** * Top-of-book read for PTB construction / devInspect (SDK, UI). Returns the best * (lowest) ask price, skipping expired orders. Returns `none` if the ask side has * no live order. */ export function bestAskPrice(options: BestAskPriceOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'best_ask_price', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface BestBidPriceArguments { self: RawTransactionArgument; } export interface BestBidPriceOptions { package?: string; arguments: BestBidPriceArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** * Top-of-book read for PTB construction / devInspect (SDK, UI). Returns the best * (highest) bid price, skipping expired orders. Returns `none` if the bid side has * no live order. */ export function bestBidPrice(options: BestBidPriceOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'best_bid_price', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface AccountOpenOrdersArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; } export interface AccountOpenOrdersOptions { package?: string; arguments: | AccountOpenOrdersArguments | [self: RawTransactionArgument, balanceManager: RawTransactionArgument]; typeArguments: [string, string]; } /** Returns the order_id for all open order for the balance_manager in the pool. */ export function accountOpenOrders(options: AccountOpenOrdersOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'account_open_orders', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetLevel2RangeArguments { self: RawTransactionArgument; priceLow: RawTransactionArgument; priceHigh: RawTransactionArgument; isBid: RawTransactionArgument; } export interface GetLevel2RangeOptions { package?: string; arguments: | GetLevel2RangeArguments | [ self: RawTransactionArgument, priceLow: RawTransactionArgument, priceHigh: RawTransactionArgument, isBid: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Returns the (price_vec, quantity_vec) for the level2 order book. The price_low * and price_high are inclusive, all orders within the range are returned. is_bid * is true for bids and false for asks. */ export function getLevel2Range(options: GetLevel2RangeOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', 'bool', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'priceLow', 'priceHigh', 'isBid']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_level2_range', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetLevel2TicksFromMidArguments { self: RawTransactionArgument; ticks: RawTransactionArgument; } export interface GetLevel2TicksFromMidOptions { package?: string; arguments: | GetLevel2TicksFromMidArguments | [self: RawTransactionArgument, ticks: RawTransactionArgument]; typeArguments: [string, string]; } /** * Returns the (price_vec, quantity_vec) for the level2 order book. Ticks are the * maximum number of ticks to return starting from best bid and best ask. * (bid_price, bid_quantity, ask_price, ask_quantity) are returned as 4 vectors. * The price vectors are sorted in descending order for bids and ascending order * for asks. */ export function getLevel2TicksFromMid(options: GetLevel2TicksFromMidOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[]; const parameterNames = ['self', 'ticks']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_level2_ticks_from_mid', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface VaultBalancesArguments { self: RawTransactionArgument; } export interface VaultBalancesOptions { package?: string; arguments: VaultBalancesArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Get all balances held in this pool. */ export function vaultBalances(options: VaultBalancesOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'vault_balances', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetPoolIdByAssetArguments { registry: RawTransactionArgument; } export interface GetPoolIdByAssetOptions { package?: string; arguments: GetPoolIdByAssetArguments | [registry: RawTransactionArgument]; typeArguments: [string, string]; } /** Get the ID of the pool given the asset types. */ export function getPoolIdByAsset(options: GetPoolIdByAssetOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['registry']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_pool_id_by_asset', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetOrderArguments { self: RawTransactionArgument; orderId: RawTransactionArgument; } export interface GetOrderOptions { package?: string; arguments: | GetOrderArguments | [self: RawTransactionArgument, orderId: RawTransactionArgument]; typeArguments: [string, string]; } /** Get the Order struct */ export function getOrder(options: GetOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u128'] satisfies (string | null)[]; const parameterNames = ['self', 'orderId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetOrdersArguments { self: RawTransactionArgument; orderIds: RawTransactionArgument>; } export interface GetOrdersOptions { package?: string; arguments: | GetOrdersArguments | [ self: RawTransactionArgument, orderIds: RawTransactionArgument>, ]; typeArguments: [string, string]; } /** Get multiple orders given a vector of order_ids. */ export function getOrders(options: GetOrdersOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'vector'] satisfies (string | null)[]; const parameterNames = ['self', 'orderIds']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_orders', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetAccountOrderDetailsArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; } export interface GetAccountOrderDetailsOptions { package?: string; arguments: | GetAccountOrderDetailsArguments | [self: RawTransactionArgument, balanceManager: RawTransactionArgument]; typeArguments: [string, string]; } /** Return a copy of all orders that are in the book for this account. */ export function getAccountOrderDetails(options: GetAccountOrderDetailsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_account_order_details', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetOrderDeepPriceArguments { self: RawTransactionArgument; } export interface GetOrderDeepPriceOptions { package?: string; arguments: GetOrderDeepPriceArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Return the DEEP price for the pool. */ export function getOrderDeepPrice(options: GetOrderDeepPriceOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_order_deep_price', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetOrderDeepRequiredArguments { self: RawTransactionArgument; baseQuantity: RawTransactionArgument; price: RawTransactionArgument; } export interface GetOrderDeepRequiredOptions { package?: string; arguments: | GetOrderDeepRequiredArguments | [ self: RawTransactionArgument, baseQuantity: RawTransactionArgument, price: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Returns the deep required for an order if it's taker or maker given quantity and * price Does not account for discounted taker fees Returns (deep_required_taker, * deep_required_maker) */ export function getOrderDeepRequired(options: GetOrderDeepRequiredOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'baseQuantity', 'price']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_order_deep_required', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface LockedBalanceArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; } export interface LockedBalanceOptions { package?: string; arguments: | LockedBalanceArguments | [self: RawTransactionArgument, balanceManager: RawTransactionArgument]; typeArguments: [string, string]; } /** * Returns the locked balance for the balance_manager in the pool Returns * (base_quantity, quote_quantity, deep_quantity) */ export function lockedBalance(options: LockedBalanceOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'locked_balance', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CanPlaceLimitOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; price: RawTransactionArgument; quantity: RawTransactionArgument; isBid: RawTransactionArgument; payWithDeep: RawTransactionArgument; expireTimestamp: RawTransactionArgument; } export interface CanPlaceLimitOrderOptions { package?: string; arguments: | CanPlaceLimitOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, price: RawTransactionArgument, quantity: RawTransactionArgument, isBid: RawTransactionArgument, payWithDeep: RawTransactionArgument, expireTimestamp: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Check if a limit order can be placed based on balance manager balances. Returns * true if the balance manager has sufficient balance (accounting for fees) to * place the order, false otherwise. Assumes the limit order is a taker order as a * worst case scenario. */ export function canPlaceLimitOrder(options: CanPlaceLimitOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [ null, null, 'u64', 'u64', 'bool', 'bool', 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'self', 'balanceManager', 'price', 'quantity', 'isBid', 'payWithDeep', 'expireTimestamp', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'can_place_limit_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CanPlaceMarketOrderArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; quantity: RawTransactionArgument; isBid: RawTransactionArgument; payWithDeep: RawTransactionArgument; } export interface CanPlaceMarketOrderOptions { package?: string; arguments: | CanPlaceMarketOrderArguments | [ self: RawTransactionArgument, balanceManager: RawTransactionArgument, quantity: RawTransactionArgument, isBid: RawTransactionArgument, payWithDeep: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Check if a market order can be placed based on balance manager balances. Returns * true if the balance manager has sufficient balance (accounting for fees) to * place the order, false otherwise. Does not account for discounted taker fees */ export function canPlaceMarketOrder(options: CanPlaceMarketOrderOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null, 'u64', 'bool', 'bool', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'balanceManager', 'quantity', 'isBid', 'payWithDeep']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'can_place_market_order', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CheckMarketOrderParamsArguments { self: RawTransactionArgument; quantity: RawTransactionArgument; } export interface CheckMarketOrderParamsOptions { package?: string; arguments: | CheckMarketOrderParamsArguments | [self: RawTransactionArgument, quantity: RawTransactionArgument]; typeArguments: [string, string]; } /** * Check if a market order can be placed based on pool book params. Returns true if * the order parameters are valid, false otherwise. */ export function checkMarketOrderParams(options: CheckMarketOrderParamsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64'] satisfies (string | null)[]; const parameterNames = ['self', 'quantity']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'check_market_order_params', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface CheckLimitOrderParamsArguments { self: RawTransactionArgument; price: RawTransactionArgument; quantity: RawTransactionArgument; expireTimestamp: RawTransactionArgument; } export interface CheckLimitOrderParamsOptions { package?: string; arguments: | CheckLimitOrderParamsArguments | [ self: RawTransactionArgument, price: RawTransactionArgument, quantity: RawTransactionArgument, expireTimestamp: RawTransactionArgument, ]; typeArguments: [string, string]; } /** * Check if a limit order can be placed based on pool book params. Returns true if * the order parameters are valid, false otherwise. */ export function checkLimitOrderParams(options: CheckLimitOrderParamsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, 'u64', 'u64', 'u64', '0x2::clock::Clock'] satisfies ( string | null )[]; const parameterNames = ['self', 'price', 'quantity', 'expireTimestamp']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'check_limit_order_params', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PoolTradeParamsArguments { self: RawTransactionArgument; } export interface PoolTradeParamsOptions { package?: string; arguments: PoolTradeParamsArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** * Returns the trade params for the pool. Returns (taker_fee, maker_fee, * stake_required) */ export function poolTradeParams(options: PoolTradeParamsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'pool_trade_params', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PoolTradeParamsNextArguments { self: RawTransactionArgument; } export interface PoolTradeParamsNextOptions { package?: string; arguments: PoolTradeParamsNextArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Returns the currently leading trade params for the next epoch for the pool */ export function poolTradeParamsNext(options: PoolTradeParamsNextOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'pool_trade_params_next', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PoolBookParamsArguments { self: RawTransactionArgument; } export interface PoolBookParamsOptions { package?: string; arguments: PoolBookParamsArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Returns the tick size, lot size, and min size for the pool. */ export function poolBookParams(options: PoolBookParamsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'pool_book_params', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface AccountExistsArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; } export interface AccountExistsOptions { package?: string; arguments: | AccountExistsArguments | [self: RawTransactionArgument, balanceManager: RawTransactionArgument]; typeArguments: [string, string]; } export function accountExists(options: AccountExistsOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'account_exists', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface AccountArguments { self: RawTransactionArgument; balanceManager: RawTransactionArgument; } export interface AccountOptions { package?: string; arguments: | AccountArguments | [self: RawTransactionArgument, balanceManager: RawTransactionArgument]; typeArguments: [string, string]; } export function account(options: AccountOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'balanceManager']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'account', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface QuorumArguments { self: RawTransactionArgument; } export interface QuorumOptions { package?: string; arguments: QuorumArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } /** Returns the quorum needed to pass proposal in the current epoch */ export function quorum(options: QuorumOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'quorum', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface IdArguments { self: RawTransactionArgument; } export interface IdOptions { package?: string; arguments: IdArguments | [self: RawTransactionArgument]; typeArguments: [string, string]; } export function id(options: IdOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['self']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'id', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetReferralBalancesArguments { Self: RawTransactionArgument; Referral: RawTransactionArgument; } export interface GetReferralBalancesOptions { package?: string; arguments: | GetReferralBalancesArguments | [Self: RawTransactionArgument, Referral: RawTransactionArgument]; typeArguments: [string, string]; } export function getReferralBalances(options: GetReferralBalancesOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['Self', 'Referral']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_referral_balances', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface GetPoolReferralBalancesArguments { self: RawTransactionArgument; referral: RawTransactionArgument; } export interface GetPoolReferralBalancesOptions { package?: string; arguments: | GetPoolReferralBalancesArguments | [self: RawTransactionArgument, referral: RawTransactionArgument]; typeArguments: [string, string]; } export function getPoolReferralBalances(options: GetPoolReferralBalancesOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'referral']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'get_pool_referral_balances', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); } export interface PoolReferralMultiplierArguments { self: RawTransactionArgument; referral: RawTransactionArgument; } export interface PoolReferralMultiplierOptions { package?: string; arguments: | PoolReferralMultiplierArguments | [self: RawTransactionArgument, referral: RawTransactionArgument]; typeArguments: [string, string]; } export function poolReferralMultiplier(options: PoolReferralMultiplierOptions) { const packageAddress = options.package ?? '@deepbook/core'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['self', 'referral']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'pool', function: 'pool_referral_multiplier', arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), typeArguments: options.typeArguments, }); }