@mysten/deepbook-v3 1.6.7 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/client.d.mts +9 -6
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +3 -2
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs.map +1 -1
- package/dist/contracts/deepbook/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager.mjs +1 -319
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs +386 -0
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/oracle.mjs +9 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +1 -383
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy_upgraded.mjs +340 -0
- package/dist/contracts/deepbook_margin/pool_proxy_upgraded.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -1
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +33 -17
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +2 -2
- package/dist/pyth/PriceServiceConnection.d.mts +18 -3
- package/dist/pyth/PriceServiceConnection.d.mts.map +1 -1
- package/dist/pyth/PriceServiceConnection.mjs +35 -4
- package/dist/pyth/PriceServiceConnection.mjs.map +1 -1
- package/dist/queries/priceFeedQueries.mjs +50 -18
- package/dist/queries/priceFeedQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +2 -2
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +19 -7
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +43 -34
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +19 -10
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +34 -27
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +16 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/config.d.mts +30 -10
- package/dist/utils/config.d.mts.map +1 -1
- package/dist/utils/config.mjs +33 -4
- package/dist/utils/config.mjs.map +1 -1
- package/dist/utils/constants.d.mts +32 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +55 -24
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +10 -10
- package/src/client.ts +9 -1
- package/src/contracts/deepbook/balance_manager.ts +1 -2
- package/src/contracts/deepbook/pool.ts +12 -24
- package/src/contracts/deepbook/registry.ts +1 -2
- package/src/contracts/deepbook_margin/margin_manager.ts +149 -28
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +646 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +2 -4
- package/src/contracts/deepbook_margin/margin_registry.ts +3 -6
- package/src/contracts/deepbook_margin/oracle.ts +59 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +597 -584
- package/src/contracts/deepbook_margin/pool_proxy_upgraded.ts +614 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +1 -2
- package/src/contracts/deepbook_margin/tpsl.ts +1 -2
- package/src/contracts/margin_liquidation/liquidation_vault.ts +144 -4
- package/src/contracts/pyth/pyth.ts +2 -4
- package/src/index.ts +4 -0
- package/src/pyth/PriceServiceConnection.ts +69 -8
- package/src/queries/priceFeedQueries.ts +74 -24
- package/src/transactions/marginAdmin.ts +2 -4
- package/src/transactions/marginLiquidations.ts +20 -6
- package/src/transactions/marginManager.ts +43 -33
- package/src/transactions/marginTPSL.ts +19 -9
- package/src/transactions/poolProxy.ts +34 -30
- package/src/types/index.ts +17 -2
- package/src/utils/config.ts +69 -9
- package/src/utils/constants.ts +83 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginTPSL.mjs","names":["#config","tpslMoveCalls.newCondition","tpslMoveCalls.newPendingLimitOrder","tpslMoveCalls.newPendingMarketOrder","marginManagerMoveCalls.addConditionalOrder","marginManagerMoveCalls.cancelAllConditionalOrders","marginManagerMoveCalls.cancelConditionalOrder","marginManagerMoveCalls.executeConditionalOrdersV2","marginManagerMoveCalls.executeConditionalOrdersV3","marginManagerMoveCalls.conditionalOrderIds","marginManagerMoveCalls.conditionalOrder","marginManagerMoveCalls.lowestTriggerAbovePrice","marginManagerMoveCalls.highestTriggerBelowPrice"],"sources":["../../src/transactions/marginTPSL.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type {\n\tPendingLimitOrderParams,\n\tPendingMarketOrderParams,\n\tAddConditionalOrderParams,\n} from '../types/index.js';\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport { MAX_TIMESTAMP, FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice } from '../utils/conversion.js';\nimport * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';\nimport * as tpslMoveCalls from '../contracts/deepbook_margin/tpsl.js';\n\n/**\n * MarginTPSLContract class for managing Take Profit / Stop Loss operations.\n */\nexport class MarginTPSLContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginTPSLContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t// === Helper Functions ===\n\n\t/**\n\t * @description Create a new condition for a conditional order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} triggerBelowPrice Whether to trigger when price is below trigger price\n\t * @param {number} triggerPrice The price at which to trigger the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewCondition =\n\t\t(poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(\n\t\t\t\ttriggerPrice,\n\t\t\t\tFLOAT_SCALAR,\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tbaseCoin.scalar,\n\t\t\t);\n\t\t\treturn tx.add(\n\t\t\t\ttpslMoveCalls.newCondition({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { triggerBelowPrice, triggerPrice: inputPrice },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Create a new pending limit order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingLimitOrderParams} params Parameters for the pending limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingLimitOrder =\n\t\t(poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tprice,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t\texpireTimestamp = MAX_TIMESTAMP,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\ttpslMoveCalls.newPendingLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\torderType,\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Create a new pending market order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingMarketOrderParams} params Parameters for the pending market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingMarketOrder =\n\t\t(poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\ttpslMoveCalls.newPendingMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t// === Public Functions ===\n\n\t/**\n\t * @description Add a conditional order (take profit or stop loss)\n\t * @param {AddConditionalOrderParams} params Parameters for adding the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\taddConditionalOrder = (params: AddConditionalOrderParams) => (tx: Transaction) => {\n\t\tconst { marginManagerKey, conditionalOrderId, triggerBelowPrice, triggerPrice, pendingOrder } =\n\t\t\tparams;\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t// Create condition\n\t\tconst condition = this.newCondition(manager.poolKey, triggerBelowPrice, triggerPrice)(tx);\n\n\t\t// Create pending order based on type\n\t\tconst isLimitOrder = 'price' in pendingOrder;\n\t\tconst pending = isLimitOrder\n\t\t\t? this.newPendingLimitOrder(manager.poolKey, pendingOrder as PendingLimitOrderParams)(tx)\n\t\t\t: this.newPendingMarketOrder(manager.poolKey, pendingOrder as PendingMarketOrderParams)(tx);\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.addConditionalOrder({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tconditionalOrderId: BigInt(conditionalOrderId),\n\t\t\t\t\tcondition,\n\t\t\t\t\tpendingOrder: pending,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel all conditional orders for a margin manager\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllConditionalOrders = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.cancelAllConditionalOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel a specific conditional order\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelConditionalOrder =\n\t\t(marginManagerKey: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.add(\n\t\t\t\tmarginManagerMoveCalls.cancelConditionalOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: manager.address, conditionalOrderId: BigInt(conditionalOrderId) },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders that have been triggered.\n\t * Permissionless — anyone can call this. After the inner fill loop, the\n\t * manager's post-trade `risk_ratio` is checked against\n\t * `min_borrow_risk_ratio`; if any triggered fill breaches that floor, the\n\t * whole txn aborts (no partial-state landing).\n\t * @param {string} managerAddress The address of the margin manager\n\t * @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')\n\t * @param {number} maxOrdersToExecute Maximum number of orders to execute in this call\n\t * @returns A function that takes a Transaction object\n\t */\n\texecuteConditionalOrders =\n\t\t(managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.executeConditionalOrdersV2({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmaxOrdersToExecute,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders, deleveraging on each market-type\n\t * fill. Permissionless, with the same trigger and cancellation handling as\n\t * {@link executeConditionalOrders}, but the market proceeds are repaid into\n\t * the loan before the risk check, and the gate is the *net* post-repay\n\t * `risk_ratio` being at least the pre-fill ratio.\n\t *\n\t * This is what lets a stop-loss fire in the `liquidation..min_borrow` danger\n\t * band: a swap alone only lowers the oracle-valued ratio (so the v2\n\t * borrow-floor gate rejects it), while repaying actually improves it. If a\n\t * single triggered fill would worsen net solvency the whole txn aborts — no\n\t * partial-state landing.\n\t * @param {string} managerAddress The address of the margin manager\n\t * @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')\n\t * @param {number} maxOrdersToExecute Maximum number of orders to execute in this call\n\t * @returns A function that takes a Transaction object\n\t */\n\texecuteConditionalOrdersV3 =\n\t\t(managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.executeConditionalOrdersV3({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmaxOrdersToExecute,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get all conditional order IDs for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrderIds = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.conditionalOrderIds({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get a specific conditional order by ID\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrder =\n\t\t(poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.conditionalOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, conditionalOrderId: BigInt(conditionalOrderId) },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Get the lowest trigger price for trigger_above orders\n\t * Returns constants::max_u64() if there are no trigger_above orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tlowestTriggerAbovePrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.lowestTriggerAbovePrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the highest trigger price for trigger_below orders\n\t * Returns 0 if there are no trigger_below orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\thighestTriggerBelowPrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.highestTriggerBelowPrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;uBAclC,SAAiB,mBAA4B,kBAC7C,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAClB,cACA,cAHiB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CAI3C,QACV,SAAS,OACT;AACD,UAAO,GAAG,IACTC,aAA2B;IAC1B,SAAS,MAAKD,OAAQ;IACtB,WAAW;KAAE;KAAmB,cAAc;KAAY;IAC1D,CAAC,CACF;;+BAUD,SAAiB,YAAqC,OAAoB;GAC1E,MAAM,EACL,eACA,YAAY,UAAU,gBACtB,qBAAqB,oBAAoB,uBACzC,OACA,UACA,OACA,cAAc,MACd,kBAAkB,kBACf;GACJ,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAAa,OAAO,cADrB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CACS,QAAQ,SAAS,OAAO;GACvF,MAAM,gBAAgB,gBAAgB,UAAU,SAAS,OAAO;AAChE,UAAO,GAAG,IACTE,qBAAmC;IAClC,SAAS,MAAKF,OAAQ;IACtB,WAAW;KACV,eAAe,OAAO,cA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AAK,UAAU;AACtD,UAAO,GAAG,IACTU,iBAAwC;IACvC,SAAS,MAAKV,OAAQ;IACtB,WAAW;KAAE,MAAM;KAAiB,oBAAoB,OAAO,mBAAmB;KAAE;IACpF,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;kCAUwB,SAAiB,qBAA6B,OAAoB;GAC5F,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,IACTW,wBAA+C;IAC9C,SAAS,MAAKX,OAAQ;IACtB,WAAW,EAAE,MAAM,iBAAiB;IACpC,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;mCAU0B,SAAiB,qBAA6B,OAAoB;GAC7F,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,IACTY,yBAAgD;IAC/C,SAAS,MAAKZ,OAAQ;IACtB,WAAW,EAAE,MAAM,iBAAiB;IACpC,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;AAvVD,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginTPSL.mjs","names":["#config","tpslMoveCalls.newCondition","tpslMoveCalls.newPendingLimitOrder","tpslMoveCalls.newPendingMarketOrder","#oracleCalls","marginManagerMoveCalls.cancelAllConditionalOrders","marginManagerMoveCalls.cancelConditionalOrder","marginManagerMoveCalls.conditionalOrderIds","marginManagerMoveCalls.conditionalOrder","marginManagerMoveCalls.lowestTriggerAbovePrice","marginManagerMoveCalls.highestTriggerBelowPrice","marginManagerUpgradedMoveCalls"],"sources":["../../src/transactions/marginTPSL.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type {\n\tPendingLimitOrderParams,\n\tPendingMarketOrderParams,\n\tAddConditionalOrderParams,\n} from '../types/index.js';\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport { MAX_TIMESTAMP, FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice } from '../utils/conversion.js';\nimport * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';\nimport * as marginManagerUpgradedMoveCalls from '../contracts/deepbook_margin/margin_manager_upgraded.js';\nimport * as tpslMoveCalls from '../contracts/deepbook_margin/tpsl.js';\n\n/**\n * MarginTPSLContract class for managing Take Profit / Stop Loss operations.\n */\nexport class MarginTPSLContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginTPSLContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * Oracle-taking entrypoints live in the parallel `_upgraded` module, which takes Pyth's\n\t * upgraded-Core `PriceInfoObject`. Entrypoints with no oracle argument stay on the base\n\t * module, which is the only place they exist.\n\t */\n\tget #oracleCalls() {\n\t\treturn marginManagerUpgradedMoveCalls;\n\t}\n\n\t// === Helper Functions ===\n\n\t/**\n\t * @description Create a new condition for a conditional order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} triggerBelowPrice Whether to trigger when price is below trigger price\n\t * @param {number} triggerPrice The price at which to trigger the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewCondition =\n\t\t(poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(\n\t\t\t\ttriggerPrice,\n\t\t\t\tFLOAT_SCALAR,\n\t\t\t\tquoteCoin.scalar,\n\t\t\t\tbaseCoin.scalar,\n\t\t\t);\n\t\t\treturn tx.add(\n\t\t\t\ttpslMoveCalls.newCondition({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { triggerBelowPrice, triggerPrice: inputPrice },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Create a new pending limit order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingLimitOrderParams} params Parameters for the pending limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingLimitOrder =\n\t\t(poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tprice,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t\texpireTimestamp = MAX_TIMESTAMP,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\ttpslMoveCalls.newPendingLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\torderType,\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Create a new pending market order for use in conditional orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {PendingMarketOrderParams} params Parameters for the pending market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewPendingMarketOrder =\n\t\t(poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tclientOrderId,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\ttpslMoveCalls.newPendingMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t// === Public Functions ===\n\n\t/**\n\t * @description Add a conditional order (take profit or stop loss)\n\t * @param {AddConditionalOrderParams} params Parameters for adding the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\taddConditionalOrder = (params: AddConditionalOrderParams) => (tx: Transaction) => {\n\t\tconst { marginManagerKey, conditionalOrderId, triggerBelowPrice, triggerPrice, pendingOrder } =\n\t\t\tparams;\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t// Create condition\n\t\tconst condition = this.newCondition(manager.poolKey, triggerBelowPrice, triggerPrice)(tx);\n\n\t\t// Create pending order based on type\n\t\tconst isLimitOrder = 'price' in pendingOrder;\n\t\tconst pending = isLimitOrder\n\t\t\t? this.newPendingLimitOrder(manager.poolKey, pendingOrder as PendingLimitOrderParams)(tx)\n\t\t\t: this.newPendingMarketOrder(manager.poolKey, pendingOrder as PendingMarketOrderParams)(tx);\n\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.addConditionalOrder({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbasePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tconditionalOrderId: BigInt(conditionalOrderId),\n\t\t\t\t\tcondition,\n\t\t\t\t\tpendingOrder: pending,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel all conditional orders for a margin manager\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllConditionalOrders = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.cancelAllConditionalOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel a specific conditional order\n\t * @param {string} marginManagerKey The key to identify the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelConditionalOrder =\n\t\t(marginManagerKey: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(manager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.add(\n\t\t\t\tmarginManagerMoveCalls.cancelConditionalOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: manager.address, conditionalOrderId: BigInt(conditionalOrderId) },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders that have been triggered.\n\t * Permissionless — anyone can call this. After the inner fill loop, the\n\t * manager's post-trade `risk_ratio` is checked against\n\t * `min_borrow_risk_ratio`; if any triggered fill breaches that floor, the\n\t * whole txn aborts (no partial-state landing).\n\t * @param {string} managerAddress The address of the margin manager\n\t * @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')\n\t * @param {number} maxOrdersToExecute Maximum number of orders to execute in this call\n\t * @returns A function that takes a Transaction object\n\t */\n\texecuteConditionalOrders =\n\t\t(managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\treturn tx.add(\n\t\t\t\tthis.#oracleCalls.executeConditionalOrdersV2({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbasePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\t\tquotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmaxOrdersToExecute,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Execute conditional orders, deleveraging on each market-type\n\t * fill. Permissionless, with the same trigger and cancellation handling as\n\t * {@link executeConditionalOrders}, but the market proceeds are repaid into\n\t * the loan before the risk check, and the gate is the *net* post-repay\n\t * `risk_ratio` being at least the pre-fill ratio.\n\t *\n\t * This is what lets a stop-loss fire in the `liquidation..min_borrow` danger\n\t * band: a swap alone only lowers the oracle-valued ratio (so the v2\n\t * borrow-floor gate rejects it), while repaying actually improves it. If a\n\t * single triggered fill would worsen net solvency the whole txn aborts — no\n\t * partial-state landing.\n\t * @param {string} managerAddress The address of the margin manager\n\t * @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')\n\t * @param {number} maxOrdersToExecute Maximum number of orders to execute in this call\n\t * @returns A function that takes a Transaction object\n\t */\n\texecuteConditionalOrdersV3 =\n\t\t(managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\treturn tx.add(\n\t\t\t\tthis.#oracleCalls.executeConditionalOrdersV3({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: managerAddress,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbasePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\t\tquotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmaxOrdersToExecute,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get all conditional order IDs for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrderIds = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.conditionalOrderIds({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get a specific conditional order by ID\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @param {string} conditionalOrderId The ID of the conditional order\n\t * @returns A function that takes a Transaction object\n\t */\n\tconditionalOrder =\n\t\t(poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.conditionalOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, conditionalOrderId: BigInt(conditionalOrderId) },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Get the lowest trigger price for trigger_above orders\n\t * Returns constants::max_u64() if there are no trigger_above orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tlowestTriggerAbovePrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.lowestTriggerAbovePrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the highest trigger price for trigger_below orders\n\t * Returns 0 if there are no trigger_below orders\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\thighestTriggerBelowPrice = (poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.highestTriggerBelowPrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;;;;;;AAoBA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;uBAuBlC,SAAiB,mBAA4B,kBAC7C,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAClB,cACA,cAHiB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CAI3C,QACV,SAAS,OACT;AACD,UAAO,GAAG,IACTC,aAA2B;IAC1B,SAAS,MAAKD,OAAQ;IACtB,WAAW;KAAE;KAAmB,cAAc;KAAY;IAC1D,CAAC,CACF;;+BAUD,SAAiB,YAAqC,OAAoB;GAC1E,MAAM,EACL,eACA,YAAY,UAAU,gBACtB,qBAAqB,oBAAoB,uBACzC,OACA,UACA,OACA,cAAc,MACd,kBAAkB,kBACf;GACJ,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GAEpD,MAAM,aAAa,aAAa,OAAO,cADrB,MAAKA,OAAQ,QAAQ,KAAK,UAAU,CACS,QAAQ,SAAS,OAAO;GACvF,MAAM,gBAAgB,gBAAgB,UAAU,SAAS,OAAO;AAChE,UAAO,GAAG,IACT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|
|
|
1
1
|
import { MarginProposalParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions99 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/poolProxy.d.ts
|
|
@@ -20,7 +20,7 @@ declare class PoolProxyContract {
|
|
|
20
20
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
23
|
+
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Place a market order. Enforces a post-trade `risk_ratio >=
|
|
26
26
|
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
@@ -28,7 +28,7 @@ declare class PoolProxyContract {
|
|
|
28
28
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
29
29
|
* @returns A function that takes a Transaction object
|
|
30
30
|
*/
|
|
31
|
-
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
31
|
+
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
32
32
|
/**
|
|
33
33
|
* @description Place a reduce only limit order. Requires the manager to have
|
|
34
34
|
* debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -37,7 +37,7 @@ declare class PoolProxyContract {
|
|
|
37
37
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
38
38
|
* @returns A function that takes a Transaction object
|
|
39
39
|
*/
|
|
40
|
-
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
40
|
+
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
41
41
|
/**
|
|
42
42
|
* @description Place a reduce only market order. Requires the manager to
|
|
43
43
|
* have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -46,7 +46,7 @@ declare class PoolProxyContract {
|
|
|
46
46
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
47
47
|
* @returns A function that takes a Transaction object
|
|
48
48
|
*/
|
|
49
|
-
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
49
|
+
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
50
50
|
/**
|
|
51
51
|
* @description Place a market order and repay the loan from the fill proceeds.
|
|
52
52
|
* The taker fill settles into the manager's balance, so the proceeds (plus any
|
|
@@ -58,7 +58,7 @@ declare class PoolProxyContract {
|
|
|
58
58
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
59
59
|
* @returns A function that takes a Transaction object
|
|
60
60
|
*/
|
|
61
|
-
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
61
|
+
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
62
62
|
/**
|
|
63
63
|
* @description Place a reduce only limit order and repay the loan from the
|
|
64
64
|
* fill proceeds. Requires debt on the relevant side (a bid needs base debt; an
|
|
@@ -68,7 +68,7 @@ declare class PoolProxyContract {
|
|
|
68
68
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
69
69
|
* @returns A function that takes a Transaction object
|
|
70
70
|
*/
|
|
71
|
-
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
71
|
+
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
72
72
|
/**
|
|
73
73
|
* @description Place a reduce only market order and repay the loan from the
|
|
74
74
|
* fill proceeds. Same reduce-only direction guard as
|
|
@@ -78,7 +78,7 @@ declare class PoolProxyContract {
|
|
|
78
78
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
79
79
|
* @returns A function that takes a Transaction object
|
|
80
80
|
*/
|
|
81
|
-
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
81
|
+
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions99.TransactionResult;
|
|
82
82
|
/**
|
|
83
83
|
* @description Modify an existing order
|
|
84
84
|
* @param {string} marginManagerKey The key to identify the MarginManager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAmBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAoBuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA0JC;;;;;;;EArG5E,gBAAA,GAAoB,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAgQnE;;;;;;;;EAjNV,yBAAA,GAA6B,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAsZxC;;;;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AAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;;;;;;EAsBpD,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;AAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { convertPrice, convertQuantity, convertRate } from "../utils/conversion.mjs";
|
|
2
2
|
import { FLOAT_SCALAR, MAX_TIMESTAMP } from "../utils/config.mjs";
|
|
3
3
|
import { OrderType, SelfMatchingOptions } from "../types/index.mjs";
|
|
4
|
-
import { cancelAllOrders, cancelOrder, cancelOrders, claimRebates, modifyOrder,
|
|
4
|
+
import { cancelAllOrders, cancelOrder, cancelOrders, claimRebates, modifyOrder, stake, submitProposal, unstake, vote, withdrawSettledAmounts, withdrawSettledAmountsPermissionless } from "../contracts/deepbook_margin/pool_proxy.mjs";
|
|
5
|
+
import { pool_proxy_upgraded_exports } from "../contracts/deepbook_margin/pool_proxy_upgraded.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/transactions/poolProxy.ts
|
|
7
8
|
/**
|
|
@@ -23,7 +24,7 @@ var PoolProxyContract = class {
|
|
|
23
24
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
24
25
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
25
26
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
26
|
-
return tx.add(placeLimitOrderV2({
|
|
27
|
+
return tx.add(this.#oracleCalls.placeLimitOrderV2({
|
|
27
28
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
28
29
|
arguments: {
|
|
29
30
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -31,8 +32,8 @@ var PoolProxyContract = class {
|
|
|
31
32
|
pool: pool.address,
|
|
32
33
|
baseMarginPool: baseMarginPool.address,
|
|
33
34
|
quoteMarginPool: quoteMarginPool.address,
|
|
34
|
-
baseOracle: baseCoin
|
|
35
|
-
quoteOracle: quoteCoin
|
|
35
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
36
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
36
37
|
clientOrderId: BigInt(clientOrderId),
|
|
37
38
|
orderType,
|
|
38
39
|
selfMatchingOption,
|
|
@@ -54,7 +55,7 @@ var PoolProxyContract = class {
|
|
|
54
55
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
55
56
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
56
57
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
57
|
-
return tx.add(placeMarketOrderV2({
|
|
58
|
+
return tx.add(this.#oracleCalls.placeMarketOrderV2({
|
|
58
59
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
59
60
|
arguments: {
|
|
60
61
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -62,8 +63,8 @@ var PoolProxyContract = class {
|
|
|
62
63
|
pool: pool.address,
|
|
63
64
|
baseMarginPool: baseMarginPool.address,
|
|
64
65
|
quoteMarginPool: quoteMarginPool.address,
|
|
65
|
-
baseOracle: baseCoin
|
|
66
|
-
quoteOracle: quoteCoin
|
|
66
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
67
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
67
68
|
clientOrderId: BigInt(clientOrderId),
|
|
68
69
|
selfMatchingOption,
|
|
69
70
|
quantity: inputQuantity,
|
|
@@ -83,7 +84,7 @@ var PoolProxyContract = class {
|
|
|
83
84
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
84
85
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
85
86
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
86
|
-
return tx.add(placeReduceOnlyLimitOrderV2({
|
|
87
|
+
return tx.add(this.#oracleCalls.placeReduceOnlyLimitOrderV2({
|
|
87
88
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
88
89
|
arguments: {
|
|
89
90
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -91,8 +92,8 @@ var PoolProxyContract = class {
|
|
|
91
92
|
pool: pool.address,
|
|
92
93
|
baseMarginPool: baseMarginPool.address,
|
|
93
94
|
quoteMarginPool: quoteMarginPool.address,
|
|
94
|
-
baseOracle: baseCoin
|
|
95
|
-
quoteOracle: quoteCoin
|
|
95
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
96
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
96
97
|
clientOrderId: BigInt(clientOrderId),
|
|
97
98
|
orderType,
|
|
98
99
|
selfMatchingOption,
|
|
@@ -114,7 +115,7 @@ var PoolProxyContract = class {
|
|
|
114
115
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
115
116
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
116
117
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
117
|
-
return tx.add(placeReduceOnlyMarketOrderV2({
|
|
118
|
+
return tx.add(this.#oracleCalls.placeReduceOnlyMarketOrderV2({
|
|
118
119
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
119
120
|
arguments: {
|
|
120
121
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -122,8 +123,8 @@ var PoolProxyContract = class {
|
|
|
122
123
|
pool: pool.address,
|
|
123
124
|
baseMarginPool: baseMarginPool.address,
|
|
124
125
|
quoteMarginPool: quoteMarginPool.address,
|
|
125
|
-
baseOracle: baseCoin
|
|
126
|
-
quoteOracle: quoteCoin
|
|
126
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
127
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
127
128
|
clientOrderId: BigInt(clientOrderId),
|
|
128
129
|
selfMatchingOption,
|
|
129
130
|
quantity: inputQuantity,
|
|
@@ -142,7 +143,7 @@ var PoolProxyContract = class {
|
|
|
142
143
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
143
144
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
144
145
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
145
|
-
return tx.add(placeMarketOrderAndRepayLoan({
|
|
146
|
+
return tx.add(this.#oracleCalls.placeMarketOrderAndRepayLoan({
|
|
146
147
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
147
148
|
arguments: {
|
|
148
149
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -150,8 +151,8 @@ var PoolProxyContract = class {
|
|
|
150
151
|
pool: pool.address,
|
|
151
152
|
baseMarginPool: baseMarginPool.address,
|
|
152
153
|
quoteMarginPool: quoteMarginPool.address,
|
|
153
|
-
baseOracle: baseCoin
|
|
154
|
-
quoteOracle: quoteCoin
|
|
154
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
155
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
155
156
|
clientOrderId: BigInt(clientOrderId),
|
|
156
157
|
selfMatchingOption,
|
|
157
158
|
quantity: inputQuantity,
|
|
@@ -171,7 +172,7 @@ var PoolProxyContract = class {
|
|
|
171
172
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
172
173
|
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
173
174
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
174
|
-
return tx.add(placeReduceOnlyLimitOrderAndRepayLoan({
|
|
175
|
+
return tx.add(this.#oracleCalls.placeReduceOnlyLimitOrderAndRepayLoan({
|
|
175
176
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
176
177
|
arguments: {
|
|
177
178
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -179,8 +180,8 @@ var PoolProxyContract = class {
|
|
|
179
180
|
pool: pool.address,
|
|
180
181
|
baseMarginPool: baseMarginPool.address,
|
|
181
182
|
quoteMarginPool: quoteMarginPool.address,
|
|
182
|
-
baseOracle: baseCoin
|
|
183
|
-
quoteOracle: quoteCoin
|
|
183
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
184
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
184
185
|
clientOrderId: BigInt(clientOrderId),
|
|
185
186
|
orderType,
|
|
186
187
|
selfMatchingOption,
|
|
@@ -202,7 +203,7 @@ var PoolProxyContract = class {
|
|
|
202
203
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
203
204
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
204
205
|
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
205
|
-
return tx.add(placeReduceOnlyMarketOrderAndRepayLoan({
|
|
206
|
+
return tx.add(this.#oracleCalls.placeReduceOnlyMarketOrderAndRepayLoan({
|
|
206
207
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
207
208
|
arguments: {
|
|
208
209
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
@@ -210,8 +211,8 @@ var PoolProxyContract = class {
|
|
|
210
211
|
pool: pool.address,
|
|
211
212
|
baseMarginPool: baseMarginPool.address,
|
|
212
213
|
quoteMarginPool: quoteMarginPool.address,
|
|
213
|
-
baseOracle: baseCoin
|
|
214
|
-
quoteOracle: quoteCoin
|
|
214
|
+
baseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
215
|
+
quoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
215
216
|
clientOrderId: BigInt(clientOrderId),
|
|
216
217
|
selfMatchingOption,
|
|
217
218
|
quantity: inputQuantity,
|
|
@@ -404,21 +405,27 @@ var PoolProxyContract = class {
|
|
|
404
405
|
const pool = this.#config.getPool(poolKey);
|
|
405
406
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
406
407
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
407
|
-
|
|
408
|
-
if (!quoteCoin.priceInfoObjectId) throw new Error(`Missing priceInfoObjectId for ${pool.quoteCoin}`);
|
|
409
|
-
tx.add(updateCurrentPrice({
|
|
408
|
+
tx.add(this.#oracleCalls.updateCurrentPrice({
|
|
410
409
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
411
410
|
arguments: {
|
|
412
411
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
413
412
|
pool: pool.address,
|
|
414
|
-
basePriceInfoObject: baseCoin
|
|
415
|
-
quotePriceInfoObject: quoteCoin
|
|
413
|
+
basePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
414
|
+
quotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin)
|
|
416
415
|
},
|
|
417
416
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
418
417
|
}));
|
|
419
418
|
};
|
|
420
419
|
this.#config = config;
|
|
421
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Oracle-taking entrypoints live in the parallel `_upgraded` module, which takes Pyth's
|
|
423
|
+
* upgraded-Core `PriceInfoObject`. Entrypoints with no oracle argument stay on the base
|
|
424
|
+
* module, which is the only place they exist.
|
|
425
|
+
*/
|
|
426
|
+
get #oracleCalls() {
|
|
427
|
+
return pool_proxy_upgraded_exports;
|
|
428
|
+
}
|
|
422
429
|
};
|
|
423
430
|
|
|
424
431
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolProxy.mjs","names":["#config","poolProxyMoveCalls.placeLimitOrderV2","poolProxyMoveCalls.placeMarketOrderV2","poolProxyMoveCalls.placeReduceOnlyLimitOrderV2","poolProxyMoveCalls.placeReduceOnlyMarketOrderV2","poolProxyMoveCalls.placeMarketOrderAndRepayLoan","poolProxyMoveCalls.placeReduceOnlyLimitOrderAndRepayLoan","poolProxyMoveCalls.placeReduceOnlyMarketOrderAndRepayLoan","poolProxyMoveCalls.modifyOrder","poolProxyMoveCalls.cancelOrder","poolProxyMoveCalls.cancelOrders","poolProxyMoveCalls.cancelAllOrders","poolProxyMoveCalls.withdrawSettledAmounts","poolProxyMoveCalls.stake","poolProxyMoveCalls.unstake","poolProxyMoveCalls.submitProposal","poolProxyMoveCalls.vote","poolProxyMoveCalls.claimRebates","poolProxyMoveCalls.withdrawSettledAmountsPermissionless","poolProxyMoveCalls.updateCurrentPrice"],"sources":["../../src/transactions/poolProxy.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\nimport type {\n\tPlaceMarginLimitOrderParams,\n\tPlaceMarginMarketOrderParams,\n\tMarginProposalParams,\n} from '../types/index.js';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport { MAX_TIMESTAMP, FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';\nimport * as poolProxyMoveCalls from '../contracts/deepbook_margin/pool_proxy.js';\n\n/**\n * PoolProxyContract class for managing PoolProxy operations.\n */\nexport class PoolProxyContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for PoolProxyContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Place a limit order. Enforces a post-trade `risk_ratio >=\n\t * min_borrow_risk_ratio` invariant on the manager (skipped when the manager\n\t * has no debt).\n\t * @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceLimitOrder = (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tpoolProxyMoveCalls.placeLimitOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\torderType,\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t\texpireTimestamp: expiration,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a market order. Enforces a post-trade `risk_ratio >=\n\t * min_borrow_risk_ratio` invariant on the manager (skipped when the manager\n\t * has no debt).\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrder = (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tpoolProxyMoveCalls.placeMarketOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a reduce only limit order. Requires the manager to have\n\t * debt on the relevant side; enforces a monotonic `risk_ratio_after >=\n\t * risk_ratio_before` invariant so the fill cannot leak value to the\n\t * counterparty.\n\t * @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyLimitOrder = (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tpoolProxyMoveCalls.placeReduceOnlyLimitOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\torderType,\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t\texpireTimestamp: expiration,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a reduce only market order. Requires the manager to\n\t * have debt on the relevant side; enforces a monotonic `risk_ratio_after >=\n\t * risk_ratio_before` invariant so the fill cannot leak value to the\n\t * counterparty.\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyMarketOrder = (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tpoolProxyMoveCalls.placeReduceOnlyMarketOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a market order and repay the loan from the fill proceeds.\n\t * The taker fill settles into the manager's balance, so the proceeds (plus any\n\t * idle balance) are repaid into the debt side before the risk check; the gate\n\t * is then the *net* post-repay `risk_ratio` being at least the pre-fill ratio.\n\t * Unlike {@link placeMarketOrder}, which checks the post-trade ratio against\n\t * `min_borrow_risk_ratio`, this lets a deleveraging fill go through in the\n\t * `liquidation..min_borrow` band, where a swap alone would be rejected.\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrderAndRepayLoan = (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tpoolProxyMoveCalls.placeMarketOrderAndRepayLoan({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a reduce only limit order and repay the loan from the\n\t * fill proceeds. Requires debt on the relevant side (a bid needs base debt; an\n\t * ask needs quote debt and sells at most the gross base held); the repay\n\t * happens before the monotonic `risk_ratio` gate, so the check is on the net\n\t * post-repay ratio.\n\t * @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyLimitOrderAndRepayLoan =\n\t\t(params: PlaceMarginLimitOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tpoolKey,\n\t\t\t\tmarginManagerKey,\n\t\t\t\tclientOrderId,\n\t\t\t\tprice,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tpoolProxyMoveCalls.placeReduceOnlyLimitOrderAndRepayLoan({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\torderType,\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp: expiration,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Place a reduce only market order and repay the loan from the\n\t * fill proceeds. Same reduce-only direction guard as\n\t * {@link placeReduceOnlyMarketOrder}, but the settled proceeds are repaid into\n\t * the debt side before the monotonic `risk_ratio` gate, so the check is on the\n\t * net post-repay ratio.\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyMarketOrderAndRepayLoan =\n\t\t(params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tpoolKey,\n\t\t\t\tmarginManagerKey,\n\t\t\t\tclientOrderId,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tpoolProxyMoveCalls.placeReduceOnlyMarketOrderAndRepayLoan({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Modify an existing order\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string} orderId Order ID to modify\n\t * @param {number} newQuantity New quantity for the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tmodifyOrder =\n\t\t(marginManagerKey: string, orderId: string, newQuantity: number) => (tx: Transaction) => {\n\t\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputQuantity = convertQuantity(newQuantity, baseCoin.scalar);\n\n\t\t\ttx.add(\n\t\t\t\tpoolProxyMoveCalls.modifyOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\torderId: BigInt(orderId),\n\t\t\t\t\t\tnewQuantity: inputQuantity,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Cancel an existing order\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string} orderId Order ID to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrder = (marginManagerKey: string, orderId: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.cancelOrder({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\torderId: BigInt(orderId),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel multiple existing orders\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string[]} orderIds Order IDs to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrders = (marginManagerKey: string, orderIds: string[]) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.cancelOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\torderIds: orderIds.map(BigInt),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel all existing orders\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllOrders = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.cancelAllOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawSettledAmounts = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.withdrawSettledAmounts({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Stake in the pool\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {number} stakeAmount The amount to stake\n\t * @returns A function that takes a Transaction object\n\t */\n\tstake = (marginManagerKey: string, stakeAmount: number) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst stakeInput = convertQuantity(stakeAmount, deepCoin.scalar);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.stake({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tamount: stakeInput,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unstake from the pool\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tunstake = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.unstake({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Submit a proposal\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {MarginProposalParams} params Parameters for the proposal\n\t * @returns A function that takes a Transaction object\n\t */\n\tsubmitProposal =\n\t\t(marginManagerKey: string, params: MarginProposalParams) => (tx: Transaction) => {\n\t\t\tconst { takerFee, makerFee, stakeRequired } = params;\n\t\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst stakeInput = convertRate(stakeRequired, FLOAT_SCALAR);\n\t\t\tconst takerFeeInput = convertRate(takerFee, FLOAT_SCALAR);\n\t\t\tconst makerFeeInput = convertRate(makerFee, FLOAT_SCALAR);\n\t\t\ttx.add(\n\t\t\t\tpoolProxyMoveCalls.submitProposal({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\ttakerFee: takerFeeInput,\n\t\t\t\t\t\tmakerFee: makerFeeInput,\n\t\t\t\t\t\tstakeRequired: stakeInput,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Vote on a proposal\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string} proposalId The ID of the proposal to vote on\n\t * @returns A function that takes a Transaction object\n\t */\n\tvote = (marginManagerKey: string, proposalId: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.vote({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tproposalId,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Claim a rebate from a pool\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tclaimRebate = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.claimRebates({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts permissionlessly for a margin manager by ID\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The object ID of the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawMarginSettledAmounts =\n\t\t(poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.add(\n\t\t\t\tpoolProxyMoveCalls.withdrawSettledAmountsPermissionless({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Update the current price for a pool using Pyth oracle\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateCurrentPrice = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tif (!baseCoin.priceInfoObjectId) {\n\t\t\tthrow new Error(`Missing priceInfoObjectId for ${pool.baseCoin}`);\n\t\t}\n\t\tif (!quoteCoin.priceInfoObjectId) {\n\t\t\tthrow new Error(`Missing priceInfoObjectId for ${pool.quoteCoin}`);\n\t\t}\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.updateCurrentPrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbasePriceInfoObject: baseCoin.priceInfoObjectId,\n\t\t\t\t\tquotePriceInfoObject: quoteCoin.priceInfoObjectId,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,oBAAb,MAA+B;CAC9B;;;;CAKA,YAAY,QAAwB;0BAWjB,YAAyC,OAAoB;GAC/E,MAAM,EACL,SACA,kBACA,eACA,OACA,UACA,OACA,aAAa,eACb,YAAY,UAAU,gBACtB,qBAAqB,oBAAoB,uBACzC,cAAc,SACX;GACJ,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,UAAU,MAAKA,OAAQ,iBAAiB,iBAAiB;GAC/D,MAAM,WA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AU,MAAKA,OAAQ;KACvB,MAAM,KAAK;KACX,qBAAqB,SAAS;KAC9B,sBAAsB,UAAU;KAChC;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;AAxpBD,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"poolProxy.mjs","names":["#config","#oracleCalls","poolProxyMoveCalls.modifyOrder","poolProxyMoveCalls.cancelOrder","poolProxyMoveCalls.cancelOrders","poolProxyMoveCalls.cancelAllOrders","poolProxyMoveCalls.withdrawSettledAmounts","poolProxyMoveCalls.stake","poolProxyMoveCalls.unstake","poolProxyMoveCalls.submitProposal","poolProxyMoveCalls.vote","poolProxyMoveCalls.claimRebates","poolProxyMoveCalls.withdrawSettledAmountsPermissionless","poolProxyUpgradedMoveCalls"],"sources":["../../src/transactions/poolProxy.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\nimport type {\n\tPlaceMarginLimitOrderParams,\n\tPlaceMarginMarketOrderParams,\n\tMarginProposalParams,\n} from '../types/index.js';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport { MAX_TIMESTAMP, FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';\nimport * as poolProxyMoveCalls from '../contracts/deepbook_margin/pool_proxy.js';\nimport * as poolProxyUpgradedMoveCalls from '../contracts/deepbook_margin/pool_proxy_upgraded.js';\n\n/**\n * PoolProxyContract class for managing PoolProxy operations.\n */\nexport class PoolProxyContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for PoolProxyContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * Oracle-taking entrypoints live in the parallel `_upgraded` module, which takes Pyth's\n\t * upgraded-Core `PriceInfoObject`. Entrypoints with no oracle argument stay on the base\n\t * module, which is the only place they exist.\n\t */\n\tget #oracleCalls() {\n\t\treturn poolProxyUpgradedMoveCalls;\n\t}\n\n\t/**\n\t * @description Place a limit order. Enforces a post-trade `risk_ratio >=\n\t * min_borrow_risk_ratio` invariant on the manager (skipped when the manager\n\t * has no debt).\n\t * @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceLimitOrder = (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.placeLimitOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\torderType,\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t\texpireTimestamp: expiration,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a market order. Enforces a post-trade `risk_ratio >=\n\t * min_borrow_risk_ratio` invariant on the manager (skipped when the manager\n\t * has no debt).\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrder = (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.placeMarketOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a reduce only limit order. Requires the manager to have\n\t * debt on the relevant side; enforces a monotonic `risk_ratio_after >=\n\t * risk_ratio_before` invariant so the fill cannot leak value to the\n\t * counterparty.\n\t * @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyLimitOrder = (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.placeReduceOnlyLimitOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\torderType,\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t\texpireTimestamp: expiration,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a reduce only market order. Requires the manager to\n\t * have debt on the relevant side; enforces a monotonic `risk_ratio_after >=\n\t * risk_ratio_before` invariant so the fill cannot leak value to the\n\t * counterparty.\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyMarketOrder = (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.placeReduceOnlyMarketOrderV2({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a market order and repay the loan from the fill proceeds.\n\t * The taker fill settles into the manager's balance, so the proceeds (plus any\n\t * idle balance) are repaid into the debt side before the risk check; the gate\n\t * is then the *net* post-repay `risk_ratio` being at least the pre-fill ratio.\n\t * Unlike {@link placeMarketOrder}, which checks the post-trade ratio against\n\t * `min_borrow_risk_ratio`, this lets a deleveraging fill go through in the\n\t * `liquidation..min_borrow` band, where a swap alone would be rejected.\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrderAndRepayLoan = (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tmarginManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.placeMarketOrderAndRepayLoan({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\tisBid,\n\t\t\t\t\tpayWithDeep,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Place a reduce only limit order and repay the loan from the\n\t * fill proceeds. Requires debt on the relevant side (a bid needs base debt; an\n\t * ask needs quote debt and sells at most the gross base held); the repay\n\t * happens before the monotonic `risk_ratio` gate, so the check is on the net\n\t * post-repay ratio.\n\t * @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyLimitOrderAndRepayLoan =\n\t\t(params: PlaceMarginLimitOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tpoolKey,\n\t\t\t\tmarginManagerKey,\n\t\t\t\tclientOrderId,\n\t\t\t\tprice,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tthis.#oracleCalls.placeReduceOnlyLimitOrderAndRepayLoan({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\torderType,\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tprice: inputPrice,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t\texpireTimestamp: expiration,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Place a reduce only market order and repay the loan from the\n\t * fill proceeds. Same reduce-only direction guard as\n\t * {@link placeReduceOnlyMarketOrder}, but the settled proceeds are repaid into\n\t * the debt side before the monotonic `risk_ratio` gate, so the check is on the\n\t * net post-repay ratio.\n\t * @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceReduceOnlyMarketOrderAndRepayLoan =\n\t\t(params: PlaceMarginMarketOrderParams) => (tx: Transaction) => {\n\t\t\tconst {\n\t\t\t\tpoolKey,\n\t\t\t\tmarginManagerKey,\n\t\t\t\tclientOrderId,\n\t\t\t\tquantity,\n\t\t\t\tisBid,\n\t\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\t\tpayWithDeep = true,\n\t\t\t} = params;\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst manager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tthis.#oracleCalls.placeReduceOnlyMarketOrderAndRepayLoan({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: manager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\t\tquoteMarginPool: quoteMarginPool.address,\n\t\t\t\t\t\tbaseOracle: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\t\tquoteOracle: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t\t\tclientOrderId: BigInt(clientOrderId),\n\t\t\t\t\t\tselfMatchingOption,\n\t\t\t\t\t\tquantity: inputQuantity,\n\t\t\t\t\t\tisBid,\n\t\t\t\t\t\tpayWithDeep,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Modify an existing order\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string} orderId Order ID to modify\n\t * @param {number} newQuantity New quantity for the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tmodifyOrder =\n\t\t(marginManagerKey: string, orderId: string, newQuantity: number) => (tx: Transaction) => {\n\t\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst inputQuantity = convertQuantity(newQuantity, baseCoin.scalar);\n\n\t\t\ttx.add(\n\t\t\t\tpoolProxyMoveCalls.modifyOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\torderId: BigInt(orderId),\n\t\t\t\t\t\tnewQuantity: inputQuantity,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Cancel an existing order\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string} orderId Order ID to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrder = (marginManagerKey: string, orderId: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.cancelOrder({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\torderId: BigInt(orderId),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel multiple existing orders\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string[]} orderIds Order IDs to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrders = (marginManagerKey: string, orderIds: string[]) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.cancelOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\torderIds: orderIds.map(BigInt),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Cancel all existing orders\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllOrders = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.cancelAllOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawSettledAmounts = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.withdrawSettledAmounts({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Stake in the pool\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {number} stakeAmount The amount to stake\n\t * @returns A function that takes a Transaction object\n\t */\n\tstake = (marginManagerKey: string, stakeAmount: number) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst stakeInput = convertQuantity(stakeAmount, deepCoin.scalar);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.stake({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tamount: stakeInput,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unstake from the pool\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tunstake = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.unstake({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Submit a proposal\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {MarginProposalParams} params Parameters for the proposal\n\t * @returns A function that takes a Transaction object\n\t */\n\tsubmitProposal =\n\t\t(marginManagerKey: string, params: MarginProposalParams) => (tx: Transaction) => {\n\t\t\tconst { takerFee, makerFee, stakeRequired } = params;\n\t\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst stakeInput = convertRate(stakeRequired, FLOAT_SCALAR);\n\t\t\tconst takerFeeInput = convertRate(takerFee, FLOAT_SCALAR);\n\t\t\tconst makerFeeInput = convertRate(makerFee, FLOAT_SCALAR);\n\t\t\ttx.add(\n\t\t\t\tpoolProxyMoveCalls.submitProposal({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\ttakerFee: takerFeeInput,\n\t\t\t\t\t\tmakerFee: makerFeeInput,\n\t\t\t\t\t\tstakeRequired: stakeInput,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Vote on a proposal\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @param {string} proposalId The ID of the proposal to vote on\n\t * @returns A function that takes a Transaction object\n\t */\n\tvote = (marginManagerKey: string, proposalId: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.vote({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tproposalId,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Claim a rebate from a pool\n\t * @param {string} marginManagerKey The key to identify the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tclaimRebate = (marginManagerKey: string) => (tx: Transaction) => {\n\t\tconst marginManager = this.#config.getMarginManager(marginManagerKey);\n\t\tconst pool = this.#config.getPool(marginManager.poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tpoolProxyMoveCalls.claimRebates({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginManager: marginManager.address,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts permissionlessly for a margin manager by ID\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} marginManagerId The object ID of the MarginManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawMarginSettledAmounts =\n\t\t(poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\ttx.add(\n\t\t\t\tpoolProxyMoveCalls.withdrawSettledAmountsPermissionless({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tmarginManager: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Update the current price for a pool using Pyth oracle\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateCurrentPrice = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.updateCurrentPrice({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tbasePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),\n\t\t\t\t\tquotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quo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A,OAAQ;KACvB,eAAe,cAAc;KAC7B,MAAM,KAAK;KACX;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;uCAUA,SAAiB,qBAA6B,OAAoB;GAClE,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,MAAG,IACFY,qCAAwD;IACvD,SAAS,MAAKZ,OAAQ;IACtB,WAAW;KACV,UAAU,MAAKA,OAAQ;KACvB,eAAe;KACf,MAAM,KAAK;KACX;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;6BAQmB,aAAqB,OAAoB;GAC9D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,MAAG,IACF,MAAKC,YAAa,mBAAmB;IACpC,SAAS,MAAKD,OAAQ;IACtB,WAAW;KACV,UAAU,MAAKA,OAAQ;KACvB,MAAM,KAAK;KACX,qBAAqB,MAAKA,OAAQ,qBAAqB,KAAK,SAAS;KACrE,sBAAsB,MAAKA,OAAQ,qBAAqB,KAAK,UAAU;KACvE;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;AA3pBD,QAAKA,SAAU;;;;;;;CAQhB,KAAIC,cAAe;AAClB,SAAOY"}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -19,6 +19,21 @@ interface Coin {
|
|
|
19
19
|
currencyId?: string;
|
|
20
20
|
priceInfoObjectId?: string;
|
|
21
21
|
}
|
|
22
|
+
/** State objects identifying the Pyth deployment margin prices against. */
|
|
23
|
+
interface PythConfig {
|
|
24
|
+
pythStateId: string;
|
|
25
|
+
wormholeStateId: string;
|
|
26
|
+
/** Hermes endpoint serving update data for this deployment. */
|
|
27
|
+
hermesEndpoint?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Bearer token for the Hermes endpoint. The one serving Pyth's upgraded Core answers
|
|
30
|
+
* 401 without it, so pushing price updates needs this set.
|
|
31
|
+
*
|
|
32
|
+
* Prefer the client-level `pythAccessToken` option, which sets this without having to
|
|
33
|
+
* restate the state object ids. Supply the token at runtime — do not commit it.
|
|
34
|
+
*/
|
|
35
|
+
accessToken?: string;
|
|
36
|
+
}
|
|
22
37
|
interface Pool {
|
|
23
38
|
address: string;
|
|
24
39
|
baseCoin: string;
|
|
@@ -370,5 +385,5 @@ type DepositDuringInitParams = {
|
|
|
370
385
|
coin: TransactionArgument;
|
|
371
386
|
});
|
|
372
387
|
//#endregion
|
|
373
|
-
export { AccountBalances, AccountInfo, AddConditionalOrderParams, BalanceManager, BaseQuantityIn, BaseQuantityOut, BorrowedShares, CanPlaceLimitOrderParams, CanPlaceMarketOrderParams, Coin, Config, CreatePermissionlessPoolParams, CreatePoolAdminParams, DecodedOrderId, DepositDuringInitParams, DepositParams, InterestConfigParams, Level2Range, Level2TicksFromMid, LockedBalances, ManagerBalance, MarginManager, MarginManagerAssets, MarginManagerBalancesResult, MarginManagerDebts, MarginManagerState, MarginPool, MarginPoolConfigParams, MarginProposalParams, OrderDeepRequiredResult, OrderType, PendingLimitOrderParams, PendingMarketOrderParams, PlaceLimitOrderParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams, PlaceMarketOrderParams, Pool, PoolBookParams, PoolConfigParams, PoolDeepPrice, PoolTradeParams, ProposalParams, QuantityOut, QuoteQuantityIn, QuoteQuantityOut, ReferralBalances, SelfMatchingOptions, SetEwmaParams, SwapParams, SwapWithManagerParams, VaultBalances };
|
|
388
|
+
export { AccountBalances, AccountInfo, AddConditionalOrderParams, BalanceManager, BaseQuantityIn, BaseQuantityOut, BorrowedShares, CanPlaceLimitOrderParams, CanPlaceMarketOrderParams, Coin, Config, CreatePermissionlessPoolParams, CreatePoolAdminParams, DecodedOrderId, DepositDuringInitParams, DepositParams, InterestConfigParams, Level2Range, Level2TicksFromMid, LockedBalances, ManagerBalance, MarginManager, MarginManagerAssets, MarginManagerBalancesResult, MarginManagerDebts, MarginManagerState, MarginPool, MarginPoolConfigParams, MarginProposalParams, OrderDeepRequiredResult, OrderType, PendingLimitOrderParams, PendingMarketOrderParams, PlaceLimitOrderParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams, PlaceMarketOrderParams, Pool, PoolBookParams, PoolConfigParams, PoolDeepPrice, PoolTradeParams, ProposalParams, PythConfig, QuantityOut, QuoteQuantityIn, QuoteQuantityOut, ReferralBalances, SelfMatchingOptions, SetEwmaParams, SwapParams, SwapWithManagerParams, VaultBalances };
|
|
374
389
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;UAMiB,cAAA;EAChB,OAAA;EACA,QAAA;EACA,UAAA;EACA,WAAA;AAAA;AAAA,UAGgB,aAAA;EAChB,OAAA;EACA,OAAA;AAAA;AAAA,UAGgB,IAAA;EAChB,OAAA;EACA,IAAA;EACA,MAAA;EACA,IAAA;EACA,UAAA;EACA,iBAAA;AAAA;AAAA,UAGgB,IAAA;EAChB,OAAA;EACA,QAAA;EACA,SAAA;AAAA;AAAA,UAGgB,UAAA;EAChB,OAAA;EACA,IAAA;AAAA;AAAA,aAIW,SAAA;EACX,cAAA;EACA,mBAAA;EACA,YAAA;EACA,SAAA;AAAA;AAAA,aAIW,mBAAA;EACX,qBAAA;EACA,YAAA;EACA,YAAA;AAAA;AAAA,UAGgB,qBAAA;EAChB,OAAA;EACA,iBAAA;EACA,aAAA;EACA,KAAA;EACA,QAAA;EACA,KAAA;EACA,UAAA;EACA,SAAA,GAAY,SAAA;EACZ,kBAAA,GAAqB,mBAAA;EACrB,WAAA;AAAA;AAA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A;AAAA,UAGI,qBAAA;EAChB,OAAA;EACA,iBAAA;EACA,QAAA;EACA,UAAA;EACA,WAAA;EACA,MAAA;EACA,MAAA;EACA,QAAA,GAAW,yBAAA;EACX,SAAA,GAAY,yBAAA;AAAA;AAAA,UAoBI,qBAAA;EAChB,WAAA;EACA,YAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,WAAA;EACA,UAAA;AAAA;AAAA,UAGgB,8BAAA;EAChB,WAAA;EACA,YAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,QAAA,GAAW,yBAAA;AAAA;AAAA,UAGK,aAAA;EAChB,KAAA;EACA,eAAA;EACA,kBAAA;AAAA;AAAA,UAGgB,gBAAA;EAChB,oBAAA;EACA,kBAAA;EACA,oBAAA;EACA,0BAAA;EACA,qBAAA;EACA,qBAAA;AAAA;AAAA,UAGgB,sBAAA;EAChB,SAAA;EACA,kBAAA;EACA,cAAA;EACA,SAAA;EACA,iBAAA;EACA,wBAAA;EACA,gBAAA;AAAA;AAAA,UAGgB,oBAAA;EAChB,QAAA;EACA,SAAA;EACA,kBAAA;EACA,WAAA;AAAA;AAAA,UAGgB,MAAA;EAChB,mBAAA;EACA,WAAA;EACA,gBAAA;AAAA;AAAA,UAMgB,cAAA;EAChB,QAAA;EACA,OAAA;AAAA;AAAA,UAEgB,aAAA;EAChB,IAAA;EACA,KAAA;EACA,IAAA;AAAA;AAAA,UAEgB,cAAA;EAChB,IAAA;EACA,KAAA;EACA,IAAA;AAAA;AAAA,UAEgB,gBAAA;EAChB,IAAA;EACA,KAAA;EACA,IAAA;AAAA;AAAA,UAIgB,eAAA;EAChB,QAAA;EACA,QAAA;EACA,aAAA;AAAA;AAAA,UAEgB,cAAA;EAChB,QAAA;EACA,OAAA;EACA,OAAA;AAAA;AAAA,KAEW,aAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;UAMiB,cAAA;EAChB,OAAA;EACA,QAAA;E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