@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":"marginManager.mjs","names":["#config","marginManagerMoveCalls._new","marginManagerMoveCalls.newWithInitializer","marginManagerMoveCalls.share","marginManagerMoveCalls.registerMarginManager","marginManagerMoveCalls.unregisterMarginManager","marginManagerMoveCalls.deposit","marginManagerMoveCalls.withdraw","marginManagerMoveCalls.borrowBase","marginManagerMoveCalls.borrowQuote","marginManagerMoveCalls.repayBase","marginManagerMoveCalls.repayQuote","marginManagerMoveCalls.liquidate","marginManagerMoveCalls.setMarginManagerReferral","marginManagerMoveCalls.unsetMarginManagerReferral","marginManagerMoveCalls.owner","marginManagerMoveCalls.deepbookPool","marginManagerMoveCalls.marginPoolId","marginManagerMoveCalls.borrowedShares","marginManagerMoveCalls.borrowedBaseShares","marginManagerMoveCalls.borrowedQuoteShares","marginManagerMoveCalls.hasBaseDebt","marginManagerMoveCalls.balanceManager","marginManagerMoveCalls.calculateAssets","marginManagerMoveCalls.calculateDebts","marginManagerMoveCalls.managerState","marginManagerMoveCalls.baseBalance","marginManagerMoveCalls.quoteBalance","marginManagerMoveCalls.deepBalance","marginManagerMoveCalls.balanceManagerId","marginManagerMoveCalls.getBalanceManagerReferralId","marginManagerMoveCalls.accountExists","marginManagerMoveCalls.account","marginManagerMoveCalls.accountOpenOrders","marginManagerMoveCalls.getAccountOrderDetails","marginManagerMoveCalls.lockedBalance","marginManagerMoveCalls.canPlaceLimitOrder","marginManagerMoveCalls.canPlaceMarketOrder"],"sources":["../../src/transactions/marginManager.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionArgument } from '@mysten/sui/transactions';\nimport { coinWithBalance } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { DepositParams, DepositDuringInitParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertPrice, convertQuantity } from '../utils/conversion.js';\nimport * as marginManagerMoveCalls from '../contracts/deepbook_margin/margin_manager.js';\n\n/**\n * MarginManagerContract class for managing MarginManager operations.\n */\nexport class MarginManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create a new margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManager = (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\tmarginManagerMoveCalls._new({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\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 Create a new margin manager with an initializer\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManagerWithInitializer = (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\tconst [manager, initializer] = tx.add(\n\t\t\tmarginManagerMoveCalls.newWithInitializer({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t\treturn { manager, initializer };\n\t};\n\n\t/**\n\t * @description Share a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {TransactionArgument} manager The margin manager to share\n\t * @param {TransactionArgument} initializer The initializer for the manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tshareMarginManager =\n\t\t(poolKey: string, manager: TransactionArgument, initializer: TransactionArgument) =>\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\ttx.add(\n\t\t\t\tmarginManagerMoveCalls.share({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { manager, initializer },\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 Register a margin manager back to the margin registry. Lets\n\t * owners restore visibility of a manager that was unregistered by another\n\t * platform.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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.registerMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unregister a margin manager from the margin registry. Aborts\n\t * if the manager holds any outstanding debt or base/quote/DEEP balance.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tunregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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.unregisterMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit into a margin manager during initialization (before sharing).\n\t * Use this when you need to deposit funds into a newly created manager in the same transaction.\n\t * @param {DepositDuringInitParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDuringInitialization = (params: DepositDuringInitParams) => (tx: Transaction) => {\n\t\tconst { manager, poolKey, coinType } = params;\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\n\t\t// Get the deposit coin from config using the coinType key (e.g., 'SUI', 'DBUSDC', 'DEEP')\n\t\tconst depositCoin = this.#config.getCoin(coinType);\n\n\t\t// If amount is provided, create a coin with balance; otherwise use the provided coin\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: depositCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, depositCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit base into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositBase = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: baseCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, baseCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit quote into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositQuote = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: quoteCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, quoteCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit deep into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDeep = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: deepCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, deepCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.deposit({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.withdraw({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, baseCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.withdraw({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, quoteCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw deep from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawDeep = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.withdraw({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, deepCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Borrow base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowBase({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, baseCoin.scalar),\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 Borrow quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.borrowQuote({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, quoteCoin.scalar),\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 Repay base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayBase = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayBase({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: baseMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, baseCoin.scalar) : null,\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 Repay quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayQuote = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayQuote({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: quoteMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, quoteCoin.scalar) : null,\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 Liquidate a margin manager\n\t * @param {string} managerAddress The address of the manager to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} debtIsBase Whether the debt is in base\n\t * @param {TransactionArgument} repayCoin The coin to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidate =\n\t\t(\n\t\t\tmanagerAddress: string,\n\t\t\tpoolKey: string,\n\t\t\tdebtIsBase: boolean,\n\t\t\trepayCoin: TransactionArgument,\n\t\t) =>\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 baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.liquidate({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\n\t\t\t\t\t\tmarginPool: marginPool.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\trepayCoin,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [\n\t\t\t\t\t\tbaseCoin.type,\n\t\t\t\t\t\tquoteCoin.type,\n\t\t\t\t\t\tdebtIsBase ? baseCoin.type : quoteCoin.type,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Set the referral for a margin manager (DeepBookPoolReferral)\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} referral The referral (DeepBookPoolReferral) to set\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetMarginManagerReferral = (managerKey: string, referral: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\ttx.add(\n\t\t\tmarginManagerMoveCalls.setMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, referralCap: referral },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unset the referral for a margin manager\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} poolKey The key of the pool to unset the referral for\n\t * @returns A function that takes a Transaction object\n\t */\n\tunsetMarginManagerReferral = (managerKey: string, poolKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.unsetMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, poolId: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get the owner address of 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\townerByPoolKey = (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.owner({\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 DeepBook pool ID associated with 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\tdeepbookPool = (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.deepbookPool({\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 margin pool ID (if any) associated with 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\tmarginPoolId = (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.marginPoolId({\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 borrowed shares for both base and quote assets\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\tborrowedShares = (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.borrowedShares({\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 borrowed base shares\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\tborrowedBaseShares = (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.borrowedBaseShares({\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 borrowed quote shares\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\tborrowedQuoteShares = (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.borrowedQuoteShares({\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 Check if margin manager has base asset debt\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\thasBaseDebt = (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.hasBaseDebt({\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 balance manager ID 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\tbalanceManager = (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.balanceManager({\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 Calculate assets (base and quote) 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\tcalculateAssets = (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.calculateAssets({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Calculate debts (base and quote) for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} coinKey The key to identify the debt coin (base or quote)\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcalculateDebts =\n\t\t(poolKey: string, coinKey: 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\tconst debtCoin = this.#config.getCoin(coinKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.calculateDebts({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, marginPool: marginPool.address },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Get comprehensive state information 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 * @returns Returns (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset,\n\t * base_debt, quote_debt, base_pyth_price, base_pyth_decimals,\n\t * quote_pyth_price, quote_pyth_decimals)\n\t */\n\tmanagerState = (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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.managerState({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseOracle: baseCoin.priceInfoObjectId!,\n\t\t\t\t\tquoteOracle: quoteCoin.priceInfoObjectId!,\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},\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 base asset balance of 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\tbaseBalance = (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.baseBalance({\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 quote asset balance of 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\tquoteBalance = (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.quoteBalance({\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 DEEP token balance of 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\tdeepBalance = (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.deepBalance({\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 underlying BalanceManager ID for a margin manager.\n\t * Returns an ID (not a `&BalanceManager`), so it composes in PTBs unlike\n\t * `balanceManager`.\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\tbalanceManagerId = (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.balanceManagerId({\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 BalanceManager referral ID for a pool (Option<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 * @returns A function that takes a Transaction object\n\t */\n\tgetBalanceManagerReferralId = (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.getBalanceManagerReferralId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, poolId: pool.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 Check if the margin manager's account exists in the pool.\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\taccountExists = (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.accountExists({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get the pool account data for the 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\taccount = (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.account({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get the open order IDs for the margin manager's account in\n\t * the pool.\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\taccountOpenOrders = (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.accountOpenOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get full order details for the margin manager's account in\n\t * the pool.\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\tgetAccountOrderDetails = (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.getAccountOrderDetails({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get locked balances (base, quote, deep) for the margin\n\t * manager's account in the pool.\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\tlockedBalance = (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.lockedBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Check whether a limit order can be placed given the\n\t * manager's current state.\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 {number | bigint} price Limit price\n\t * @param {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @param {number | bigint} expireTimestamp Order expiration timestamp (ms)\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceLimitOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tprice: number | bigint,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t\texpireTimestamp: number | bigint,\n\t\t) =>\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(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\tmarginManagerMoveCalls.canPlaceLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\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\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Check whether a market order can be placed given the\n\t * manager's current state.\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 {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceMarketOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t) =>\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 inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.canPlaceMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\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}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GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;GACtD,MAAM,gBAAgB,gBAAgB,UAAU,SAAS,OAAO;AAChE,UAAO,GAAG,IACTqC,oBAA2C;IAC1C,SAAS,MAAKrC,OAAQ;IACtB,WAAW;KACV,MAAM;KACN,MAAM,KAAK;KACX,UAAU;KACV;KACA;KACA;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;AAlhCF,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginManager.mjs","names":["#config","marginManagerMoveCalls._new","marginManagerMoveCalls.newWithInitializer","marginManagerMoveCalls.share","marginManagerMoveCalls.registerMarginManager","marginManagerMoveCalls.unregisterMarginManager","#oracleCalls","marginManagerMoveCalls.repayBase","marginManagerMoveCalls.repayQuote","marginManagerMoveCalls.setMarginManagerReferral","marginManagerMoveCalls.unsetMarginManagerReferral","marginManagerMoveCalls.owner","marginManagerMoveCalls.deepbookPool","marginManagerMoveCalls.marginPoolId","marginManagerMoveCalls.borrowedShares","marginManagerMoveCalls.borrowedBaseShares","marginManagerMoveCalls.borrowedQuoteShares","marginManagerMoveCalls.hasBaseDebt","marginManagerMoveCalls.balanceManager","marginManagerMoveCalls.calculateAssets","marginManagerMoveCalls.calculateDebts","marginManagerMoveCalls.baseBalance","marginManagerMoveCalls.quoteBalance","marginManagerMoveCalls.deepBalance","marginManagerMoveCalls.balanceManagerId","marginManagerMoveCalls.getBalanceManagerReferralId","marginManagerMoveCalls.accountExists","marginManagerMoveCalls.account","marginManagerMoveCalls.accountOpenOrders","marginManagerMoveCalls.getAccountOrderDetails","marginManagerMoveCalls.lockedBalance","marginManagerMoveCalls.canPlaceLimitOrder","marginManagerMoveCalls.canPlaceMarketOrder","marginManagerUpgradedMoveCalls"],"sources":["../../src/transactions/marginManager.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionArgument } from '@mysten/sui/transactions';\nimport { coinWithBalance } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { DepositParams, DepositDuringInitParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertPrice, convertQuantity } 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';\n\n/**\n * MarginManagerContract class for managing MarginManager operations.\n */\nexport class MarginManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginManagerContract\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/**\n\t * @description Create a new margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManager = (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\tmarginManagerMoveCalls._new({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\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 Create a new margin manager with an initializer\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginManagerWithInitializer = (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\tconst [manager, initializer] = tx.add(\n\t\t\tmarginManagerMoveCalls.newWithInitializer({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tpool: pool.address,\n\t\t\t\t\tdeepbookRegistry: this.#config.REGISTRY_ID,\n\t\t\t\t\tmarginRegistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t\treturn { manager, initializer };\n\t};\n\n\t/**\n\t * @description Share a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {TransactionArgument} manager The margin manager to share\n\t * @param {TransactionArgument} initializer The initializer for the manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tshareMarginManager =\n\t\t(poolKey: string, manager: TransactionArgument, initializer: TransactionArgument) =>\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\ttx.add(\n\t\t\t\tmarginManagerMoveCalls.share({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { manager, initializer },\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 Register a margin manager back to the margin registry. Lets\n\t * owners restore visibility of a manager that was unregistered by another\n\t * platform.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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.registerMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unregister a margin manager from the margin registry. Aborts\n\t * if the manager holds any outstanding debt or base/quote/DEEP balance.\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tunregisterMarginManager = (managerKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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.unregisterMarginManager({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, marginRegistry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit into a margin manager during initialization (before sharing).\n\t * Use this when you need to deposit funds into a newly created manager in the same transaction.\n\t * @param {DepositDuringInitParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDuringInitialization = (params: DepositDuringInitParams) => (tx: Transaction) => {\n\t\tconst { manager, poolKey, coinType } = params;\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\n\t\t// Get the deposit coin from config using the coinType key (e.g., 'SUI', 'DBUSDC', 'DEEP')\n\t\tconst depositCoin = this.#config.getCoin(coinType);\n\n\t\t// If amount is provided, create a coin with balance; otherwise use the provided coin\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: depositCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, depositCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: manager,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit base into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositBase = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: baseCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, baseCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit quote into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositQuote = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: quoteCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, quoteCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Deposit deep into a margin manager\n\t * @param {DepositParams} params The deposit parameters\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositDeep = (params: DepositParams) => (tx: Transaction) => {\n\t\tconst { managerKey } = params;\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst coin =\n\t\t\t'amount' in params && params.amount !== undefined\n\t\t\t\t? coinWithBalance({\n\t\t\t\t\t\ttype: deepCoin.type,\n\t\t\t\t\t\tbalance: convertQuantity(params.amount, deepCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.add(\n\t\t\tthis.#oracleCalls.deposit({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tcoin,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.withdraw({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, baseCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.withdraw({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, quoteCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Withdraw deep from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawDeep = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst deepCoin = this.#config.getCoin('DEEP');\n\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.withdraw({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\twithdrawAmount: convertQuantity(amount, deepCoin.scalar),\n\t\t\t\t},\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Borrow base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowBase = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.borrowBase({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.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\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, baseCoin.scalar),\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 Borrow quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowQuote = (managerKey: string, amount: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.borrowQuote({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\tloanAmount: convertQuantity(amount, quoteCoin.scalar),\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 Repay base from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayBase = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayBase({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: baseMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, baseCoin.scalar) : null,\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 Repay quote from a margin manager\n\t * @param {string} managerKey The key to identify the manager\n\t * @param {number} amount The amount to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\trepayQuote = (managerKey: string, amount?: number) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tmarginManagerMoveCalls.repayQuote({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\tmarginPool: quoteMarginPool.address,\n\t\t\t\t\tamount: amount !== undefined ? convertQuantity(amount, quoteCoin.scalar) : null,\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 Liquidate a margin manager\n\t * @param {string} managerAddress The address of the manager to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} debtIsBase Whether the debt is in base\n\t * @param {TransactionArgument} repayCoin The coin to repay\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidate =\n\t\t(\n\t\t\tmanagerAddress: string,\n\t\t\tpoolKey: string,\n\t\t\tdebtIsBase: boolean,\n\t\t\trepayCoin: TransactionArgument,\n\t\t) =>\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 baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\t\tconst marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;\n\t\t\treturn tx.add(\n\t\t\t\tthis.#oracleCalls.liquidate({\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\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tmarginPool: marginPool.address,\n\t\t\t\t\t\tpool: pool.address,\n\t\t\t\t\t\trepayCoin,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [\n\t\t\t\t\t\tbaseCoin.type,\n\t\t\t\t\t\tquoteCoin.type,\n\t\t\t\t\t\tdebtIsBase ? baseCoin.type : quoteCoin.type,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Set the referral for a margin manager (DeepBookPoolReferral)\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} referral The referral (DeepBookPoolReferral) to set\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetMarginManagerReferral = (managerKey: string, referral: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\ttx.add(\n\t\t\tmarginManagerMoveCalls.setMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, referralCap: referral },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Unset the referral for a margin manager\n\t * @param {string} managerKey The key to identify the margin manager\n\t * @param {string} poolKey The key of the pool to unset the referral for\n\t * @returns A function that takes a Transaction object\n\t */\n\tunsetMarginManagerReferral = (managerKey: string, poolKey: string) => (tx: Transaction) => {\n\t\tconst manager = this.#config.getMarginManager(managerKey);\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\n\t\ttx.add(\n\t\t\tmarginManagerMoveCalls.unsetMarginManagerReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: manager.address, poolId: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get the owner address of 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\townerByPoolKey = (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.owner({\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 DeepBook pool ID associated with 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\tdeepbookPool = (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.deepbookPool({\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 margin pool ID (if any) associated with 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\tmarginPoolId = (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.marginPoolId({\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 borrowed shares for both base and quote assets\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\tborrowedShares = (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.borrowedShares({\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 borrowed base shares\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\tborrowedBaseShares = (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.borrowedBaseShares({\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 borrowed quote shares\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\tborrowedQuoteShares = (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.borrowedQuoteShares({\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 Check if margin manager has base asset debt\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\thasBaseDebt = (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.hasBaseDebt({\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 balance manager ID 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\tbalanceManager = (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.balanceManager({\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 Calculate assets (base and quote) 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\tcalculateAssets = (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.calculateAssets({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Calculate debts (base and quote) for a margin manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} coinKey The key to identify the debt coin (base or quote)\n\t * @param {string} marginManagerId The ID of the margin manager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcalculateDebts =\n\t\t(poolKey: string, coinKey: 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\tconst debtCoin = this.#config.getCoin(coinKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.calculateDebts({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: { self: marginManagerId, marginPool: marginPool.address },\n\t\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Get comprehensive state information 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 * @returns Returns (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset,\n\t * base_debt, quote_debt, base_pyth_price, base_pyth_decimals,\n\t * quote_pyth_price, quote_pyth_decimals)\n\t */\n\tmanagerState = (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\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\t\treturn tx.add(\n\t\t\tthis.#oracleCalls.managerState({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\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\tpool: pool.address,\n\t\t\t\t\tbaseMarginPool: baseMarginPool.address,\n\t\t\t\t\tquoteMarginPool: quoteMarginPool.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 Get the base asset balance of 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\tbaseBalance = (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.baseBalance({\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 quote asset balance of 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\tquoteBalance = (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.quoteBalance({\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 DEEP token balance of 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\tdeepBalance = (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.deepBalance({\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 underlying BalanceManager ID for a margin manager.\n\t * Returns an ID (not a `&BalanceManager`), so it composes in PTBs unlike\n\t * `balanceManager`.\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\tbalanceManagerId = (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.balanceManagerId({\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 BalanceManager referral ID for a pool (Option<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 * @returns A function that takes a Transaction object\n\t */\n\tgetBalanceManagerReferralId = (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.getBalanceManagerReferralId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, poolId: pool.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 Check if the margin manager's account exists in the pool.\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\taccountExists = (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.accountExists({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get the pool account data for the 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\taccount = (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.account({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get the open order IDs for the margin manager's account in\n\t * the pool.\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\taccountOpenOrders = (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.accountOpenOrders({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get full order details for the margin manager's account in\n\t * the pool.\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\tgetAccountOrderDetails = (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.getAccountOrderDetails({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Get locked balances (base, quote, deep) for the margin\n\t * manager's account in the pool.\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\tlockedBalance = (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.lockedBalance({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginManagerId, pool: pool.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 Check whether a limit order can be placed given the\n\t * manager's current state.\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 {number | bigint} price Limit price\n\t * @param {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @param {number | bigint} expireTimestamp Order expiration timestamp (ms)\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceLimitOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tprice: number | bigint,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t\texpireTimestamp: number | bigint,\n\t\t) =>\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(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\tmarginManagerMoveCalls.canPlaceLimitOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\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\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\n\t/**\n\t * @description Check whether a market order can be placed given the\n\t * manager's current state.\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 {number | bigint} quantity Order quantity (base units)\n\t * @param {boolean} isBid True for bid, false for ask\n\t * @param {boolean} payWithDeep Whether to pay fees in DEEP\n\t * @returns A function that takes a Transaction object\n\t */\n\tcanPlaceMarketOrder =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tmarginManagerId: string,\n\t\t\tquantity: number | bigint,\n\t\t\tisBid: boolean,\n\t\t\tpayWithDeep: boolean,\n\t\t) =>\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 inputQuantity = convertQuantity(quantity, baseCoin.scalar);\n\t\t\treturn tx.add(\n\t\t\t\tmarginManagerMoveCalls.canPlaceMarketOrder({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginManagerId,\n\t\t\t\t\t\tpool: pool.address,\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"],"mappings":";;;;;;;;;;AAeA,IAAa,wBAAb,MAAmC;CAClC;;;;CAKA,YAAY,QAAwB;2BAkBhB,aAAqB,OAAoB;GAC5D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,MAAG,IACFC,KAA4B;IAC3B,SAAS,MAAKD,OAAQ;IACtB,WAAW;KACV,MAAM,KAAK;KACX,kBAAkB,MAAKA,OAAQ;KAC/B,gBAAgB,MAAKA,OAAQ;KAC7B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BAAgB,gBAAgB,UAAU,SAAS,OAAO;AAChE,UAAO,GAAG,IACT+B,mBAA0C;IACzC,SAAS,MAAK/B,OAAQ;IACtB,WAAW;KACV,MAAM;KACN,MAAM,KAAK;KACX,OAAO;KACP,UAAU;KACV;KACA;KACA;KACA;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;8BAeD,SACA,iBACA,UACA,OACA,iBAEA,OAAoB;GACpB,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;GACtD,MAAM,gBAAgB,gBAAgB,UAAU,SAAS,OAAO;AAChE,UAAO,GAAG,IACTgC,oBAA2C;IAC1C,SAAS,MAAKhC,OAAQ;IACtB,WAAW;KACV,MAAM;KACN,MAAM,KAAK;KACX,UAAU;KACV;KACA;KACA;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;AA3hCF,QAAKA,SAAU;;;;;;;CAQhB,KAAIM,cAAe;AAClB,SAAO2B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_transactions76 from "@mysten/sui/transactions";
|
|
3
3
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/marginPool.d.ts
|
|
@@ -16,7 +16,7 @@ declare class MarginPoolContract {
|
|
|
16
16
|
* @description Mint a supplier cap for margin pool
|
|
17
17
|
* @returns A function that takes a Transaction object
|
|
18
18
|
*/
|
|
19
|
-
mintSupplierCap: () => (tx: Transaction) =>
|
|
19
|
+
mintSupplierCap: () => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
20
20
|
/**
|
|
21
21
|
* @description Supply to a margin pool
|
|
22
22
|
* @param {string} coinKey The key to identify the pool
|
|
@@ -33,7 +33,7 @@ declare class MarginPoolContract {
|
|
|
33
33
|
* @param {number} [amountToWithdraw] The amount to withdraw. If omitted, withdraws all.
|
|
34
34
|
* @returns A function that takes a Transaction object
|
|
35
35
|
*/
|
|
36
|
-
withdrawFromMarginPool: (coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) => (tx: Transaction) =>
|
|
36
|
+
withdrawFromMarginPool: (coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
37
37
|
/**
|
|
38
38
|
* @description Mint a referral for a margin pool
|
|
39
39
|
* @param {string} coinKey The key to identify the pool
|
|
@@ -46,94 +46,94 @@ declare class MarginPoolContract {
|
|
|
46
46
|
* @param {string} referralId The ID of the referral
|
|
47
47
|
* @returns A function that takes a Transaction object
|
|
48
48
|
*/
|
|
49
|
-
withdrawReferralFees: (coinKey: string, referralId: string) => (tx: Transaction) =>
|
|
49
|
+
withdrawReferralFees: (coinKey: string, referralId: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
50
50
|
/**
|
|
51
51
|
* @description Get the margin pool ID
|
|
52
52
|
* @param {string} coinKey The key to identify the pool
|
|
53
53
|
* @returns A function that takes a Transaction object
|
|
54
54
|
*/
|
|
55
|
-
getId: (coinKey: string) => (tx: Transaction) =>
|
|
55
|
+
getId: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
56
56
|
/**
|
|
57
57
|
* @description Check if a deepbook pool is allowed for borrowing
|
|
58
58
|
* @param {string} coinKey The key to identify the margin pool
|
|
59
59
|
* @param {string} deepbookPoolId The ID of the deepbook pool
|
|
60
60
|
* @returns A function that takes a Transaction object
|
|
61
61
|
*/
|
|
62
|
-
deepbookPoolAllowed: (coinKey: string, deepbookPoolId: string) => (tx: Transaction) =>
|
|
62
|
+
deepbookPoolAllowed: (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
63
63
|
/**
|
|
64
64
|
* @description Get the total supply amount
|
|
65
65
|
* @param {string} coinKey The key to identify the pool
|
|
66
66
|
* @returns A function that takes a Transaction object
|
|
67
67
|
*/
|
|
68
|
-
totalSupply: (coinKey: string) => (tx: Transaction) =>
|
|
68
|
+
totalSupply: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
69
69
|
/**
|
|
70
70
|
* @description Get the total supply shares
|
|
71
71
|
* @param {string} coinKey The key to identify the pool
|
|
72
72
|
* @returns A function that takes a Transaction object
|
|
73
73
|
*/
|
|
74
|
-
supplyShares: (coinKey: string) => (tx: Transaction) =>
|
|
74
|
+
supplyShares: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
75
75
|
/**
|
|
76
76
|
* @description Get the total borrow amount
|
|
77
77
|
* @param {string} coinKey The key to identify the pool
|
|
78
78
|
* @returns A function that takes a Transaction object
|
|
79
79
|
*/
|
|
80
|
-
totalBorrow: (coinKey: string) => (tx: Transaction) =>
|
|
80
|
+
totalBorrow: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
81
81
|
/**
|
|
82
82
|
* @description Get the total borrow shares
|
|
83
83
|
* @param {string} coinKey The key to identify the pool
|
|
84
84
|
* @returns A function that takes a Transaction object
|
|
85
85
|
*/
|
|
86
|
-
borrowShares: (coinKey: string) => (tx: Transaction) =>
|
|
86
|
+
borrowShares: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
87
87
|
/**
|
|
88
88
|
* @description Get the last update timestamp
|
|
89
89
|
* @param {string} coinKey The key to identify the pool
|
|
90
90
|
* @returns A function that takes a Transaction object
|
|
91
91
|
*/
|
|
92
|
-
lastUpdateTimestamp: (coinKey: string) => (tx: Transaction) =>
|
|
92
|
+
lastUpdateTimestamp: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
93
93
|
/**
|
|
94
94
|
* @description Get the supply cap
|
|
95
95
|
* @param {string} coinKey The key to identify the pool
|
|
96
96
|
* @returns A function that takes a Transaction object
|
|
97
97
|
*/
|
|
98
|
-
supplyCap: (coinKey: string) => (tx: Transaction) =>
|
|
98
|
+
supplyCap: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
99
99
|
/**
|
|
100
100
|
* @description Get the max utilization rate
|
|
101
101
|
* @param {string} coinKey The key to identify the pool
|
|
102
102
|
* @returns A function that takes a Transaction object
|
|
103
103
|
*/
|
|
104
|
-
maxUtilizationRate: (coinKey: string) => (tx: Transaction) =>
|
|
104
|
+
maxUtilizationRate: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
105
105
|
/**
|
|
106
106
|
* @description Get the protocol spread
|
|
107
107
|
* @param {string} coinKey The key to identify the pool
|
|
108
108
|
* @returns A function that takes a Transaction object
|
|
109
109
|
*/
|
|
110
|
-
protocolSpread: (coinKey: string) => (tx: Transaction) =>
|
|
110
|
+
protocolSpread: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
111
111
|
/**
|
|
112
112
|
* @description Get the minimum borrow amount
|
|
113
113
|
* @param {string} coinKey The key to identify the pool
|
|
114
114
|
* @returns A function that takes a Transaction object
|
|
115
115
|
*/
|
|
116
|
-
minBorrow: (coinKey: string) => (tx: Transaction) =>
|
|
116
|
+
minBorrow: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
117
117
|
/**
|
|
118
118
|
* @description Get the current interest rate
|
|
119
119
|
* @param {string} coinKey The key to identify the pool
|
|
120
120
|
* @returns A function that takes a Transaction object
|
|
121
121
|
*/
|
|
122
|
-
interestRate: (coinKey: string) => (tx: Transaction) =>
|
|
122
|
+
interestRate: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
123
123
|
/**
|
|
124
124
|
* @description Get user supply shares for a supplier cap
|
|
125
125
|
* @param {string} coinKey The key to identify the pool
|
|
126
126
|
* @param {string} supplierCapId The ID of the supplier cap
|
|
127
127
|
* @returns A function that takes a Transaction object
|
|
128
128
|
*/
|
|
129
|
-
userSupplyShares: (coinKey: string, supplierCapId: string) => (tx: Transaction) =>
|
|
129
|
+
userSupplyShares: (coinKey: string, supplierCapId: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
130
130
|
/**
|
|
131
131
|
* @description Get user supply amount for a supplier cap
|
|
132
132
|
* @param {string} coinKey The key to identify the pool
|
|
133
133
|
* @param {string} supplierCapId The ID of the supplier cap
|
|
134
134
|
* @returns A function that takes a Transaction object
|
|
135
135
|
*/
|
|
136
|
-
userSupplyAmount: (coinKey: string, supplierCapId: string) => (tx: Transaction) =>
|
|
136
|
+
userSupplyAmount: (coinKey: string, supplierCapId: string) => (tx: Transaction) => _mysten_sui_transactions76.TransactionResult;
|
|
137
137
|
}
|
|
138
138
|
//#endregion
|
|
139
139
|
export { MarginPoolContract };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AddConditionalOrderParams, PendingLimitOrderParams, PendingMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions33 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/marginTPSL.d.ts
|
|
@@ -20,21 +20,21 @@ declare class MarginTPSLContract {
|
|
|
20
20
|
* @param {number} triggerPrice The price at which to trigger the order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
newCondition: (poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) => (tx: Transaction) =>
|
|
23
|
+
newCondition: (poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Create a new pending limit order for use in conditional orders
|
|
26
26
|
* @param {string} poolKey The key to identify the pool
|
|
27
27
|
* @param {PendingLimitOrderParams} params Parameters for the pending limit order
|
|
28
28
|
* @returns A function that takes a Transaction object
|
|
29
29
|
*/
|
|
30
|
-
newPendingLimitOrder: (poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) =>
|
|
30
|
+
newPendingLimitOrder: (poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
31
31
|
/**
|
|
32
32
|
* @description Create a new pending market order for use in conditional orders
|
|
33
33
|
* @param {string} poolKey The key to identify the pool
|
|
34
34
|
* @param {PendingMarketOrderParams} params Parameters for the pending market order
|
|
35
35
|
* @returns A function that takes a Transaction object
|
|
36
36
|
*/
|
|
37
|
-
newPendingMarketOrder: (poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) =>
|
|
37
|
+
newPendingMarketOrder: (poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
38
38
|
/**
|
|
39
39
|
* @description Add a conditional order (take profit or stop loss)
|
|
40
40
|
* @param {AddConditionalOrderParams} params Parameters for adding the conditional order
|
|
@@ -65,7 +65,7 @@ declare class MarginTPSLContract {
|
|
|
65
65
|
* @param {number} maxOrdersToExecute Maximum number of orders to execute in this call
|
|
66
66
|
* @returns A function that takes a Transaction object
|
|
67
67
|
*/
|
|
68
|
-
executeConditionalOrders: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) =>
|
|
68
|
+
executeConditionalOrders: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
69
69
|
/**
|
|
70
70
|
* @description Execute conditional orders, deleveraging on each market-type
|
|
71
71
|
* fill. Permissionless, with the same trigger and cancellation handling as
|
|
@@ -83,14 +83,14 @@ declare class MarginTPSLContract {
|
|
|
83
83
|
* @param {number} maxOrdersToExecute Maximum number of orders to execute in this call
|
|
84
84
|
* @returns A function that takes a Transaction object
|
|
85
85
|
*/
|
|
86
|
-
executeConditionalOrdersV3: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) =>
|
|
86
|
+
executeConditionalOrdersV3: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
87
87
|
/**
|
|
88
88
|
* @description Get all conditional order IDs for a margin manager
|
|
89
89
|
* @param {string} poolKey The key to identify the pool
|
|
90
90
|
* @param {string} marginManagerId The ID of the margin manager
|
|
91
91
|
* @returns A function that takes a Transaction object
|
|
92
92
|
*/
|
|
93
|
-
conditionalOrderIds: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
93
|
+
conditionalOrderIds: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
94
94
|
/**
|
|
95
95
|
* @description Get a specific conditional order by ID
|
|
96
96
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -98,7 +98,7 @@ declare class MarginTPSLContract {
|
|
|
98
98
|
* @param {string} conditionalOrderId The ID of the conditional order
|
|
99
99
|
* @returns A function that takes a Transaction object
|
|
100
100
|
*/
|
|
101
|
-
conditionalOrder: (poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) =>
|
|
101
|
+
conditionalOrder: (poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
102
102
|
/**
|
|
103
103
|
* @description Get the lowest trigger price for trigger_above orders
|
|
104
104
|
* Returns constants::max_u64() if there are no trigger_above orders
|
|
@@ -106,7 +106,7 @@ declare class MarginTPSLContract {
|
|
|
106
106
|
* @param {string} marginManagerId The ID of the margin manager
|
|
107
107
|
* @returns A function that takes a Transaction object
|
|
108
108
|
*/
|
|
109
|
-
lowestTriggerAbovePrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
109
|
+
lowestTriggerAbovePrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
110
110
|
/**
|
|
111
111
|
* @description Get the highest trigger price for trigger_below orders
|
|
112
112
|
* Returns 0 if there are no trigger_below orders
|
|
@@ -114,7 +114,7 @@ declare class MarginTPSLContract {
|
|
|
114
114
|
* @param {string} marginManagerId The ID of the margin manager
|
|
115
115
|
* @returns A function that takes a Transaction object
|
|
116
116
|
*/
|
|
117
|
-
highestTriggerBelowPrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
117
|
+
highestTriggerBelowPrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions33.TransactionResult;
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
export { MarginTPSLContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;cAoBa,kBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAiDO;;;;;;;EA3B3B,YAAA,GACE,OAAA,UAAiB,iBAAA,WAA4B,YAAA,uBAC7C,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAyI+C;;;;;;EAjHhE,oBAAA,GACE,OAAA,UAAiB,MAAA,EAAQ,uBAAA,MAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAyOa;;;;;;EAlMpF,qBAAA,GACE,OAAA,UAAiB,MAAA,EAAQ,wBAAA,MAA8B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA8PiB;;;;;EA9NzF,mBAAA,GAAuB,MAAA,EAAQ,yBAAA,MAA+B,EAAA,EAAI,WAAA;EAnGlE;;;;;EA2IA,0BAAA,GAA8B,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAzI/C;;;;;;EA6JjB,sBAAA,GACE,gBAAA,UAA0B,kBAAA,cAAgC,EAAA,EAAI,WAAA;EArIO;;;;;;;;;;;EA8JvE,wBAAA,GACE,cAAA,UAAwB,OAAA,UAAiB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAvF5B;;;;;;;;;;;;;;;;;EAgI9D,0BAAA,GACE,cAAA,UAAwB,OAAA,UAAiB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAxF;;;;;;EAgCF,mBAAA,GAAuB,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAA7D;;;;;;;EAoBvB,gBAAA,GACE,OAAA,UAAiB,eAAA,UAAyB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAA/C;;;;;;;EAoB5C,uBAAA,GAA2B,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAf;;;;;;;EAoBzE,wBAAA,GAA4B,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;AAAA"}
|
|
@@ -2,7 +2,8 @@ import { convertPrice, convertQuantity } 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
4
|
import { newCondition, newPendingLimitOrder, newPendingMarketOrder } from "../contracts/deepbook_margin/tpsl.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { cancelAllConditionalOrders, cancelConditionalOrder, conditionalOrder, conditionalOrderIds, highestTriggerBelowPrice, lowestTriggerAbovePrice } from "../contracts/deepbook_margin/margin_manager.mjs";
|
|
6
|
+
import { margin_manager_upgraded_exports } from "../contracts/deepbook_margin/margin_manager_upgraded.mjs";
|
|
6
7
|
|
|
7
8
|
//#region src/transactions/marginTPSL.ts
|
|
8
9
|
/**
|
|
@@ -69,13 +70,13 @@ var MarginTPSLContract = class {
|
|
|
69
70
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
70
71
|
const condition = this.newCondition(manager.poolKey, triggerBelowPrice, triggerPrice)(tx);
|
|
71
72
|
const pending = "price" in pendingOrder ? this.newPendingLimitOrder(manager.poolKey, pendingOrder)(tx) : this.newPendingMarketOrder(manager.poolKey, pendingOrder)(tx);
|
|
72
|
-
tx.add(addConditionalOrder({
|
|
73
|
+
tx.add(this.#oracleCalls.addConditionalOrder({
|
|
73
74
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
74
75
|
arguments: {
|
|
75
76
|
self: manager.address,
|
|
76
77
|
pool: pool.address,
|
|
77
|
-
basePriceInfoObject: baseCoin
|
|
78
|
-
quotePriceInfoObject: quoteCoin
|
|
78
|
+
basePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
79
|
+
quotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
79
80
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
80
81
|
conditionalOrderId: BigInt(conditionalOrderId),
|
|
81
82
|
condition,
|
|
@@ -115,15 +116,15 @@ var MarginTPSLContract = class {
|
|
|
115
116
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
116
117
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
117
118
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
118
|
-
return tx.add(executeConditionalOrdersV2({
|
|
119
|
+
return tx.add(this.#oracleCalls.executeConditionalOrdersV2({
|
|
119
120
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
120
121
|
arguments: {
|
|
121
122
|
self: managerAddress,
|
|
122
123
|
pool: pool.address,
|
|
123
124
|
baseMarginPool: baseMarginPool.address,
|
|
124
125
|
quoteMarginPool: quoteMarginPool.address,
|
|
125
|
-
basePriceInfoObject: baseCoin
|
|
126
|
-
quotePriceInfoObject: quoteCoin
|
|
126
|
+
basePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
127
|
+
quotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
127
128
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
128
129
|
maxOrdersToExecute
|
|
129
130
|
},
|
|
@@ -136,15 +137,15 @@ var MarginTPSLContract = class {
|
|
|
136
137
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
137
138
|
const baseMarginPool = this.#config.getMarginPool(pool.baseCoin);
|
|
138
139
|
const quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);
|
|
139
|
-
return tx.add(executeConditionalOrdersV3({
|
|
140
|
+
return tx.add(this.#oracleCalls.executeConditionalOrdersV3({
|
|
140
141
|
package: this.#config.MARGIN_PACKAGE_ID,
|
|
141
142
|
arguments: {
|
|
142
143
|
self: managerAddress,
|
|
143
144
|
pool: pool.address,
|
|
144
145
|
baseMarginPool: baseMarginPool.address,
|
|
145
146
|
quoteMarginPool: quoteMarginPool.address,
|
|
146
|
-
basePriceInfoObject: baseCoin
|
|
147
|
-
quotePriceInfoObject: quoteCoin
|
|
147
|
+
basePriceInfoObject: this.#config.getPriceInfoObjectId(pool.baseCoin),
|
|
148
|
+
quotePriceInfoObject: this.#config.getPriceInfoObjectId(pool.quoteCoin),
|
|
148
149
|
registry: this.#config.MARGIN_REGISTRY_ID,
|
|
149
150
|
maxOrdersToExecute
|
|
150
151
|
},
|
|
@@ -196,6 +197,14 @@ var MarginTPSLContract = class {
|
|
|
196
197
|
};
|
|
197
198
|
this.#config = config;
|
|
198
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Oracle-taking entrypoints live in the parallel `_upgraded` module, which takes Pyth's
|
|
202
|
+
* upgraded-Core `PriceInfoObject`. Entrypoints with no oracle argument stay on the base
|
|
203
|
+
* module, which is the only place they exist.
|
|
204
|
+
*/
|
|
205
|
+
get #oracleCalls() {
|
|
206
|
+
return margin_manager_upgraded_exports;
|
|
207
|
+
}
|
|
199
208
|
};
|
|
200
209
|
|
|
201
210
|
//#endregion
|