import type { SuiClient } from '@onelabs/sui/client'; import { BalanceManagerContract } from './transactions/balanceManager.js'; import { DeepBookContract } from './transactions/deepbook.js'; import { DeepBookAdminContract } from './transactions/deepbookAdmin.js'; import { FlashLoanContract } from './transactions/flashLoans.js'; import { GovernanceContract } from './transactions/governance.js'; import type { BalanceManager, Environment } from './types/index.js'; import type { CoinMap, PoolMap } from './utils/constants.js'; /** * DeepBookClient class for managing DeepBook operations. */ export declare class DeepBookClient { #private; client: SuiClient; balanceManager: BalanceManagerContract; deepBook: DeepBookContract; deepBookAdmin: DeepBookAdminContract; flashLoans: FlashLoanContract; governance: GovernanceContract; /** * @param {SuiClient} client SuiClient instance * @param {string} address Address of the client * @param {Environment} env Environment configuration * @param {Object.} [balanceManagers] Optional initial BalanceManager map * @param {CoinMap} [coins] Optional initial CoinMap * @param {PoolMap} [pools] Optional initial PoolMap * @param {string} [adminCap] Optional admin capability */ constructor({ client, address, env, balanceManagers, coins, pools, adminCap, }: { client: SuiClient; address: string; env: Environment; balanceManagers?: { [key: string]: BalanceManager; }; coins?: CoinMap; pools?: PoolMap; adminCap?: string; }); /** * @description Check the balance of a balance manager for a specific coin * @param {string} managerKey Key of the balance manager * @param {string} coinKey Key of the coin * @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance */ checkManagerBalance(managerKey: string, coinKey: string): Promise<{ coinType: string; balance: number; }>; /** * @description Check if a pool is whitelisted * @param {string} poolKey Key of the pool * @returns {Promise} Boolean indicating if the pool is whitelisted */ whitelisted(poolKey: string): Promise; /** * @description Get the quote quantity out for a given base quantity * @param {string} poolKey Key of the pool * @param {number} baseQuantity Base quantity to convert * @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>} * An object with base quantity, base out, quote out, and deep required for the dry run */ getQuoteQuantityOut(poolKey: string, baseQuantity: number): Promise<{ baseQuantity: number; baseOut: number; quoteOut: number; deepRequired: number; }>; /** * @description Get the base quantity out for a given quote quantity * @param {string} poolKey Key of the pool * @param {number} quoteQuantity Quote quantity to convert * @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>} * An object with quote quantity, base out, quote out, and deep required for the dry run */ getBaseQuantityOut(poolKey: string, quoteQuantity: number): Promise<{ quoteQuantity: number; baseOut: number; quoteOut: number; deepRequired: number; }>; /** * @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero * @param {string} poolKey Key of the pool * @param {number} baseQuantity Base quantity to convert * @param {number} quoteQuantity Quote quantity to convert * @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>} * An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run */ getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number): Promise<{ baseQuantity: number; quoteQuantity: number; baseOut: number; quoteOut: number; deepRequired: number; }>; /** * @description Get open orders for a balance manager in a pool * @param {string} poolKey Key of the pool * @param {string} managerKey Key of the balance manager * @returns {Promise} An array of open order IDs */ accountOpenOrders(poolKey: string, managerKey: string): Promise; /** * @description Get the order information for a specific order in a pool * @param {string} poolKey Key of the pool * @param {string} orderId Order ID * @returns {Promise} A promise that resolves to an object containing the order information */ getOrder(poolKey: string, orderId: string): Promise<{ balance_manager_id: { bytes: string; }; order_id: string; client_order_id: string; quantity: string; filled_quantity: string; fee_is_deep: boolean; order_deep_price: { asset_is_base: boolean; deep_per_asset: string; }; epoch: string; status: number; expire_timestamp: string; } | null>; /** * @description Get the order information for a specific order in a pool, with normalized price * @param {string} poolKey Key of the pool * @param {string} orderId Order ID * @returns {Promise} A promise that resolves to an object containing the order information with normalized price */ getOrderNormalized(poolKey: string, orderId: string): Promise<{ quantity: string; filled_quantity: string; order_deep_price: { deep_per_asset: string; asset_is_base: boolean; }; isBid: boolean; normalized_price: string; balance_manager_id: { bytes: string; }; order_id: string; client_order_id: string; fee_is_deep: boolean; epoch: string; status: number; expire_timestamp: string; } | null>; /** * @description Retrieves information for multiple specific orders in a pool. * @param {string} poolKey - The key identifying the pool from which to retrieve order information. * @param {string[]} orderIds - List of order IDs to retrieve information for. * @returns {Promise} A promise that resolves to an array of order objects, each containing details such as * balance manager ID, order ID, client order ID, quantity, filled quantity, fee information, order price, epoch, status, * and expiration timestamp. Returns `null` if the retrieval fails. */ getOrders(poolKey: string, orderIds: string[]): Promise<{ balance_manager_id: { bytes: string; }; order_id: string; client_order_id: string; quantity: string; filled_quantity: string; fee_is_deep: boolean; order_deep_price: { asset_is_base: boolean; deep_per_asset: string; }; epoch: string; status: number; expire_timestamp: string; }[] | null>; /** * @description Get level 2 order book specifying range of price * @param {string} poolKey Key of the pool * @param {number} priceLow Lower bound of the price range * @param {number} priceHigh Upper bound of the price range * @param {boolean} isBid Whether to get bid or ask orders * @returns {Promise<{ prices: Array, quantities: Array }>} * An object with arrays of prices and quantities */ getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean): Promise<{ prices: number[]; quantities: number[]; }>; /** * @description Get level 2 order book ticks from mid-price for a pool * @param {string} poolKey Key of the pool * @param {number} ticks Number of ticks from mid-price * @returns {Promise<{ bid_prices: Array, bid_quantities: Array, ask_prices: Array, ask_quantities: Array }>} * An object with arrays of prices and quantities */ getLevel2TicksFromMid(poolKey: string, ticks: number): Promise<{ bid_prices: number[]; bid_quantities: number[]; ask_prices: number[]; ask_quantities: number[]; }>; /** * @description Get the vault balances for a pool * @param {string} poolKey Key of the pool * @returns {Promise<{ base: number, quote: number, deep: number }>} * An object with base, quote, and deep balances in the vault */ vaultBalances(poolKey: string): Promise<{ base: number; quote: number; deep: number; }>; /** * @description Get the pool ID by asset types * @param {string} baseType Type of the base asset * @param {string} quoteType Type of the quote asset * @returns {Promise} The address of the pool */ getPoolIdByAssets(baseType: string, quoteType: string): Promise; /** * @description Get the mid price for a pool * @param {string} poolKey Key of the pool * @returns {Promise} The mid price */ midPrice(poolKey: string): Promise; /** * @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. * @param {string} poolKey Key of the pool * @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>} */ poolTradeParams(poolKey: string): Promise<{ takerFee: number; makerFee: number; stakeRequired: number; }>; /** * @description Get the trade parameters for a given pool, including tick size, lot size, and min size. * @param {string} poolKey Key of the pool * @returns {Promise<{ tickSize: number, lotSize: number, minSize: number }>} */ poolBookParams(poolKey: string): Promise<{ tickSize: number; lotSize: number; minSize: number; }>; /** * @description Get the account information for a given pool and balance manager * @param {string} poolKey Key of the pool * @param {string} managerKey The key of the BalanceManager * @returns {Promise} A promise that resolves to an object containing the account information */ account(poolKey: string, managerKey: string): Promise<{ epoch: string; open_orders: { constants: string[]; }; taker_volume: number; maker_volume: number; active_stake: number; inactive_stake: number; created_proposal: boolean; voted_proposal: { bytes: string; } | null; unclaimed_rebates: { base: number; quote: number; deep: number; }; settled_balances: { base: number; quote: number; deep: number; }; owed_balances: { base: number; quote: number; deep: number; }; }>; /** * @description Get the locked balances for a pool and balance manager * @param {string} poolKey Key of the pool * @param {string} managerKey The key of the BalanceManager * @returns {Promise<{ base: number, quote: number, deep: number }>} * An object with base, quote, and deep locked for the balance manager in the pool */ lockedBalance(poolKey: string, balanceManagerKey: string): Promise<{ base: number; quote: number; deep: number; }>; /** * @description Get the DEEP price conversion for a pool * @param {string} poolKey Key of the pool * @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion */ getPoolDeepPrice(poolKey: string): Promise<{ asset_is_base: true; deep_per_base: number; deep_per_quote?: undefined; } | { asset_is_base: false; deep_per_quote: number; deep_per_base?: undefined; }>; /** * @description Decode the order ID to get bid/ask status, price, and orderId * @param {bigint} encodedOrderId Encoded order ID * @returns {Object} Object containing isBid, price, and orderId */ decodeOrderId(encodedOrderId: bigint): { isBid: boolean; price: number; orderId: number; }; }