@haneullabs/deepbook-v3 1.0.11 → 1.2.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 +74 -0
- package/dist/client.d.mts +68 -787
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +258 -2154
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +0 -1
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -5
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -4
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/deps/haneul/vec_set.d.mts +0 -1
- package/dist/contracts/deepbook/deps/haneul/vec_set.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -13
- package/dist/contracts/deepbook/order.d.mts.map +1 -1
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/contracts/utils/index.mjs +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/pyth/PriceServiceConnection.d.mts.map +1 -1
- package/dist/pyth/pyth.d.mts.map +1 -1
- package/dist/pyth/pyth.mjs +1 -1
- package/dist/queries/accountQueries.mjs +104 -0
- package/dist/queries/accountQueries.mjs.map +1 -0
- package/dist/queries/balanceManagerQueries.mjs +113 -0
- package/dist/queries/balanceManagerQueries.mjs.map +1 -0
- package/dist/queries/context.mjs +15 -0
- package/dist/queries/context.mjs.map +1 -0
- package/dist/queries/marginManagerQueries.mjs +365 -0
- package/dist/queries/marginManagerQueries.mjs.map +1 -0
- package/dist/queries/marginPoolQueries.mjs +184 -0
- package/dist/queries/marginPoolQueries.mjs.map +1 -0
- package/dist/queries/orderQueries.mjs +165 -0
- package/dist/queries/orderQueries.mjs.map +1 -0
- package/dist/queries/poolQueries.mjs +234 -0
- package/dist/queries/poolQueries.mjs.map +1 -0
- package/dist/queries/priceFeedQueries.mjs +83 -0
- package/dist/queries/priceFeedQueries.mjs.map +1 -0
- package/dist/queries/quantityQueries.mjs +216 -0
- package/dist/queries/quantityQueries.mjs.map +1 -0
- package/dist/queries/referralQueries.mjs +96 -0
- package/dist/queries/referralQueries.mjs.map +1 -0
- package/dist/queries/registryQueries.mjs +162 -0
- package/dist/queries/registryQueries.mjs.map +1 -0
- package/dist/queries/tpslQueries.mjs +62 -0
- package/dist/queries/tpslQueries.mjs.map +1 -0
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +5 -4
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +48 -47
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +2 -2
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +10 -9
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts +0 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +6 -4
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts +0 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +5 -4
- package/dist/transactions/governance.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -8
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +8 -7
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +5 -4
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +15 -14
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +23 -31
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +17 -27
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +3 -2
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +15 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +6 -8
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +5 -5
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +13 -13
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +191 -54
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/config.d.mts +10 -2
- package/dist/utils/config.d.mts.map +1 -1
- package/dist/utils/config.mjs +22 -6
- package/dist/utils/config.mjs.map +1 -1
- package/dist/utils/constants.d.mts +15 -7
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +54 -30
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/conversion.mjs +26 -0
- package/dist/utils/conversion.mjs.map +1 -0
- package/dist/utils/errors.d.mts.map +1 -1
- package/dist/utils/validation.d.mts.map +1 -1
- package/package.json +6 -5
- package/src/client.ts +429 -2688
- package/src/index.ts +27 -0
- package/src/queries/accountQueries.ts +117 -0
- package/src/queries/balanceManagerQueries.ts +156 -0
- package/src/queries/context.ts +44 -0
- package/src/queries/index.ts +16 -0
- package/src/queries/marginManagerQueries.ts +575 -0
- package/src/queries/marginPoolQueries.ts +226 -0
- package/src/queries/orderQueries.ts +202 -0
- package/src/queries/poolQueries.ts +266 -0
- package/src/queries/priceFeedQueries.ts +141 -0
- package/src/queries/quantityQueries.ts +266 -0
- package/src/queries/referralQueries.ts +112 -0
- package/src/queries/registryQueries.ts +185 -0
- package/src/queries/tpslQueries.ts +88 -0
- package/src/transactions/balanceManager.ts +5 -4
- package/src/transactions/deepbook.ts +98 -84
- package/src/transactions/deepbookAdmin.ts +10 -9
- package/src/transactions/flashLoans.ts +5 -4
- package/src/transactions/governance.ts +5 -4
- package/src/transactions/marginAdmin.ts +8 -7
- package/src/transactions/marginLiquidations.ts +5 -4
- package/src/transactions/marginMaintainer.ts +15 -14
- package/src/transactions/marginManager.ts +13 -40
- package/src/transactions/marginPool.ts +3 -2
- package/src/transactions/marginTPSL.ts +12 -7
- package/src/transactions/poolProxy.ts +12 -11
- package/src/types/index.ts +200 -53
- package/src/utils/config.ts +31 -8
- package/src/utils/constants.ts +60 -37
- package/src/utils/conversion.ts +33 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginManager.mjs","names":["#config"],"sources":["../../src/transactions/marginManager.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionArgument } from '@haneullabs/haneul/transactions';\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { DepositParams, DepositDuringInitParams } from '../types/index.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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::new`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::new_with_initializer`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::share`,\n\t\t\t\targuments: [manager, initializer],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\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., 'HANEUL', '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: Math.round(params.amount * depositCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\tmanager,\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],\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: Math.round(params.amount * baseCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\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: Math.round(params.amount * quoteCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\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: Math.round(params.amount * deepCoin.scalar),\n\t\t\t\t\t})\n\t\t\t\t: params.coin;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(Math.round(amount * baseCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(Math.round(amount * quoteCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(Math.round(amount * deepCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrow_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(Math.round(amount * baseCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrow_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(Math.round(amount * quoteCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::repay_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object.option({\n\t\t\t\t\ttype: 'u64',\n\t\t\t\t\tvalue: amount ? tx.pure.u64(Math.round(amount * baseCoin.scalar)) : null,\n\t\t\t\t}),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::repay_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object.option({\n\t\t\t\t\ttype: 'u64',\n\t\t\t\t\tvalue: amount ? tx.pure.u64(Math.round(amount * quoteCoin.scalar)) : null,\n\t\t\t\t}),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::liquidate`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\trepayCoin,\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::set_margin_manager_referral`,\n\t\t\targuments: [tx.object(manager.address), tx.object(referral)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::unset_margin_manager_referral`,\n\t\t\targuments: [tx.object(manager.address), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::owner`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deepbook_pool`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::margin_pool_id`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_shares`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_base_shares`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_quote_shares`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::has_base_debt`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::balance_manager`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::calculate_assets`,\n\t\t\targuments: [tx.object(marginManagerId), tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::calculate_debts`,\n\t\t\t\targuments: [tx.object(marginManagerId), tx.object(marginPool.address), tx.object.clock()],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::manager_state`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginManagerId),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::base_balance`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::quote_balance`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deep_balance`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get account order details for a margin manager.\n\t * This retrieves the balance manager from the margin manager and calls get_account_order_details.\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\tgetMarginAccountOrderDetails =\n\t\t(poolKey: string, marginManagerId: string) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t\t// Get the balance manager from the margin manager\n\t\t\tconst balanceManager = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::balance_manager`,\n\t\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\n\t\t\t// Call get_account_order_details with the balance manager\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_account_order_details`,\n\t\t\t\targuments: [tx.object(pool.address), balanceManager],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n}\n"],"mappings":";;;;;;AAWA,IAAa,wBAAb,MAAmC;CAClC;;;;CAKA,YAAY,QAAwB;2BAShB,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,SAAS;IACX,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW;KACV,GAAG,OAAO,KAAK,QAAQ;KACvB,GAAG,OAAO,MAAKA,OAAQ,YAAY;KACnC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB;KAC1C,GAAG,OAAO,OAAO;KACjB;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;0CAQgC,aAAqB,OAAoB;G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MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;GAGtD,MAAM,iBAAiB,GAAG,SAAS;IAClC,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,gBAAgB,CAAC;IACvC,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;AAGF,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,oBAAoB;IAC5C,WAAW,CAAC,GAAG,OAAO,KAAK,QAAQ,EAAE,eAAe;IACpD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;AA3vBH,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginManager.mjs","names":["#config"],"sources":["../../src/transactions/marginManager.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionArgument } from '@haneullabs/haneul/transactions';\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { DepositParams, DepositDuringInitParams } from '../types/index.js';\nimport { convertQuantity } from '../utils/conversion.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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::new`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::new_with_initializer`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::share`,\n\t\t\t\targuments: [manager, initializer],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\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., 'HANEUL', '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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\tmanager,\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, depositCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deposit`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\tcoin,\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(convertQuantity(amount, baseCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(convertQuantity(amount, quoteCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::withdraw`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(convertQuantity(amount, deepCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrow_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(convertQuantity(amount, baseCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrow_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(convertQuantity(amount, quoteCoin.scalar)),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::repay_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object.option({\n\t\t\t\t\ttype: 'u64',\n\t\t\t\t\tvalue: amount ? tx.pure.u64(convertQuantity(amount, baseCoin.scalar)) : null,\n\t\t\t\t}),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::repay_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(manager.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object.option({\n\t\t\t\t\ttype: 'u64',\n\t\t\t\t\tvalue: amount ? tx.pure.u64(convertQuantity(amount, quoteCoin.scalar)) : null,\n\t\t\t\t}),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::liquidate`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\trepayCoin,\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtIsBase ? baseCoin.type : quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::set_margin_manager_referral`,\n\t\t\targuments: [tx.object(manager.address), tx.object(referral)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::unset_margin_manager_referral`,\n\t\t\targuments: [tx.object(manager.address), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::owner`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deepbook_pool`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::margin_pool_id`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_shares`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_base_shares`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::borrowed_quote_shares`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::has_base_debt`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::balance_manager`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::calculate_assets`,\n\t\t\targuments: [tx.object(marginManagerId), tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::calculate_debts`,\n\t\t\t\targuments: [tx.object(marginManagerId), tx.object(marginPool.address), tx.object.clock()],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::manager_state`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginManagerId),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::base_balance`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::quote_balance`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\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.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_manager::deep_balance`,\n\t\t\targuments: [tx.object(marginManagerId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;AAYA,IAAa,wBAAb,MAAmC;CAClC;;;;CAKA,YAAY,QAAwB;2BAShB,aAAqB,OAAoB;GAC5D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,Q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ACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,gBAAgB,CAAC;IACvC,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;AA/tBF,QAAKA,SAAU"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _haneullabs_haneul_transactions29 from "@haneullabs/haneul/transactions";
|
|
3
3
|
import { Transaction, TransactionObjectArgument } from "@haneullabs/haneul/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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.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) => _haneullabs_haneul_transactions29.TransactionResult;
|
|
137
137
|
}
|
|
138
138
|
//#endregion
|
|
139
139
|
export { MarginPoolContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginPool.d.mts","names":[],"sources":["../../src/transactions/marginPool.ts"],"
|
|
1
|
+
{"version":3,"file":"marginPool.d.mts","names":[],"sources":["../../src/transactions/marginPool.ts"],"mappings":";;;;;;;;cAWa,kBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EA0BL;;;;EAlBf,eAAA,SAAyB,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EAiFO;;;;;;;;EAlE/C,kBAAA,GAEE,OAAA,UACA,WAAA,EAAa,yBAAA,EACb,eAAA,UACA,UAAA,eAEA,EAAA,EAAI,WAAA;EA6ImC;;;;;;;EA3GzC,sBAAA,GACE,OAAA,UAAiB,WAAA,EAAa,yBAAA,EAA2B,gBAAA,eACzD,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EAiKqB;;;;;EA1ItC,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAoLT;;;;;;EAjKtC,oBAAA,GAAwB,OAAA,UAAiB,UAAA,cAAwB,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EA6MD;;;;;EAzL/E,KAAA,GAAS,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EAhIjC;;;;;;EA+IZ,mBAAA,GAAuB,OAAA,UAAiB,cAAA,cAA4B,EAAA,EAAI,WAAA,KAAW,iCAAA,CAAA,iBAAA;EArHpE;;;;;EAmIf,WAAA,GAAe,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,iCA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,7 +21,7 @@ var MarginPoolContract = class {
|
|
|
20
21
|
tx.setSenderIfNotSet(this.#config.address);
|
|
21
22
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
22
23
|
const coin = this.#config.getCoin(coinKey);
|
|
23
|
-
const depositInput =
|
|
24
|
+
const depositInput = convertQuantity(amountToDeposit, coin.scalar);
|
|
24
25
|
const supply = coinWithBalance({
|
|
25
26
|
type: coin.type,
|
|
26
27
|
balance: depositInput
|
|
@@ -44,7 +45,7 @@ var MarginPoolContract = class {
|
|
|
44
45
|
this.withdrawFromMarginPool = (coinKey, supplierCap, amountToWithdraw) => (tx) => {
|
|
45
46
|
const marginPool = this.#config.getMarginPool(coinKey);
|
|
46
47
|
const coin = this.#config.getCoin(coinKey);
|
|
47
|
-
const withdrawInput = amountToWithdraw !== void 0 ?
|
|
48
|
+
const withdrawInput = amountToWithdraw !== void 0 ? convertQuantity(amountToWithdraw, coin.scalar) : null;
|
|
48
49
|
return tx.moveCall({
|
|
49
50
|
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw`,
|
|
50
51
|
arguments: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginPool.mjs","names":["#config"],"sources":["../../src/transactions/marginPool.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\nimport type { Transaction, TransactionObjectArgument } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * MarginPoolContract class for managing MarginPool operations.\n */\nexport class MarginPoolContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginPoolContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Mint a supplier cap for margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplierCap = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supplier_cap`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object.clock()],\n\t\t});\n\t};\n\n\t/**\n\t * @description Supply to a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyToMarginPool =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tsupplierCap: TransactionObjectArgument,\n\t\t\tamountToDeposit: number,\n\t\t\treferralId?: string,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = Math.round(amountToDeposit * coin.scalar);\n\t\t\tconst supply = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\tsupply,\n\t\t\t\t\ttx.object.option({\n\t\t\t\t\t\ttype: '0x2::object::ID',\n\t\t\t\t\t\tvalue: referralId ? tx.pure.id(referralId) : null,\n\t\t\t\t\t}),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw from a margin pool. If amountToWithdraw is not provided, withdraws all.\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} [amountToWithdraw] The amount to withdraw. If omitted, withdraws all.\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromMarginPool =\n\t\t(coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawInput =\n\t\t\t\tamountToWithdraw !== undefined ? Math.round(amountToWithdraw * coin.scalar) : null;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\ttx.pure.option('u64', withdrawInput),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Mint a referral for a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplyReferral = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supply_referral`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw referral fees from a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawReferralFees = (coinKey: string, referralId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw_referral_fees`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(referralId),\n\t\t\t],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t// === Read-only/View Functions ===\n\n\t/**\n\t * @description Get the margin pool ID\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetId = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::id`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Check if a deepbook pool is allowed for borrowing\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {string} deepbookPoolId The ID of the deepbook pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepbookPoolAllowed = (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::deepbook_pool_allowed`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(deepbookPoolId)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total supply amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalSupply = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_supply`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total supply shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_shares`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_borrow`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total borrow shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::borrow_shares`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the last update timestamp\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tlastUpdateTimestamp = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::last_update_timestamp`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the supply cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyCap = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_cap`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the max utilization rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmaxUtilizationRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::max_utilization_rate`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the protocol spread\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tprotocolSpread = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::protocol_spread`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the minimum borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::min_borrow`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the current interest rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tinterestRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::interest_rate`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get user supply shares for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyShares = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_shares`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(supplierCapId)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get user supply amount for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyAmount = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_amount`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(supplierCapId), tx.object.clock()],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;AAUA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QA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A2B,OAAoB;GACnF,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW;KAAC,GAAG,OAAO,WAAW,QAAQ;KAAE,GAAG,KAAK,GAAG,cAAc;KAAE,GAAG,OAAO,OAAO;KAAC;IACxF,eAAe,CAAC,WAAW,KAAK;IAChC,CAAC;;AA9TF,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginPool.mjs","names":["#config"],"sources":["../../src/transactions/marginPool.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\nimport type { Transaction, TransactionObjectArgument } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { convertQuantity } from '../utils/conversion.js';\n\n/**\n * MarginPoolContract class for managing MarginPool operations.\n */\nexport class MarginPoolContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginPoolContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Mint a supplier cap for margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplierCap = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supplier_cap`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object.clock()],\n\t\t});\n\t};\n\n\t/**\n\t * @description Supply to a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyToMarginPool =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tsupplierCap: TransactionObjectArgument,\n\t\t\tamountToDeposit: number,\n\t\t\treferralId?: string,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = convertQuantity(amountToDeposit, coin.scalar);\n\t\t\tconst supply = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\tsupply,\n\t\t\t\t\ttx.object.option({\n\t\t\t\t\t\ttype: '0x2::object::ID',\n\t\t\t\t\t\tvalue: referralId ? tx.pure.id(referralId) : null,\n\t\t\t\t\t}),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw from a margin pool. If amountToWithdraw is not provided, withdraws all.\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {TransactionObjectArgument} supplierCap The supplier cap object\n\t * @param {number} [amountToWithdraw] The amount to withdraw. If omitted, withdraws all.\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromMarginPool =\n\t\t(coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawInput =\n\t\t\t\tamountToWithdraw !== undefined ? convertQuantity(amountToWithdraw, coin.scalar) : null;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tsupplierCap,\n\t\t\t\t\ttx.pure.option('u64', withdrawInput),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Mint a referral for a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmintSupplyReferral = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supply_referral`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw referral fees from a margin pool\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} referralId The ID of the referral\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawReferralFees = (coinKey: string, referralId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw_referral_fees`,\n\t\t\targuments: [\n\t\t\t\ttx.object(marginPool.address),\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\ttx.object(referralId),\n\t\t\t],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t// === Read-only/View Functions ===\n\n\t/**\n\t * @description Get the margin pool ID\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetId = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::id`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Check if a deepbook pool is allowed for borrowing\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {string} deepbookPoolId The ID of the deepbook pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeepbookPoolAllowed = (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::deepbook_pool_allowed`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(deepbookPoolId)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total supply amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalSupply = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_supply`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total supply shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_shares`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttotalBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_borrow`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the total borrow shares\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowShares = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::borrow_shares`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the last update timestamp\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tlastUpdateTimestamp = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::last_update_timestamp`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the supply cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tsupplyCap = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_cap`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the max utilization rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmaxUtilizationRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::max_utilization_rate`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the protocol spread\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tprotocolSpread = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::protocol_spread`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the minimum borrow amount\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminBorrow = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::min_borrow`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the current interest rate\n\t * @param {string} coinKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tinterestRate = (coinKey: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::interest_rate`,\n\t\t\targuments: [tx.object(marginPool.address)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get user supply shares for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyShares = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_shares`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(supplierCapId)],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get user supply amount for a supplier cap\n\t * @param {string} coinKey The key to identify the pool\n\t * @param {string} supplierCapId The ID of the supplier cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserSupplyAmount = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {\n\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_amount`,\n\t\t\targuments: [tx.object(marginPool.address), tx.pure.id(supplierCapId), tx.object.clock()],\n\t\t\ttypeArguments: [marginPool.type],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;AAWA,IAAa,qBAAb,MAAgC;CAC/B;;;;CAKA,YAAY,QAAwB;gCAQX,OAAoB;AAC5C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB,EAAE,GAAG,OAAO,OAAO,CAAC;IAC1E,CAAC;;6BAaD,SACA,aACA,iBACA,gBAEA,OAAoB;AACpB,MAAG,kBAAkB,MAAKA,OAAQ,QAAQ;GAC1C,MAAM,aAAa,MAAKA,OAAQ,cAAc,QAAQ;GACtD,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,eAAe,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
+
import * as _haneullabs_haneul_transactions115 from "@haneullabs/haneul/transactions";
|
|
3
3
|
import { Transaction } from "@haneullabs/haneul/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/marginRegistry.d.ts
|
|
@@ -17,83 +17,83 @@ declare class MarginRegistryContract {
|
|
|
17
17
|
* @param {string} poolKey The key to identify the pool
|
|
18
18
|
* @returns A function that takes a Transaction object
|
|
19
19
|
*/
|
|
20
|
-
poolEnabled: (poolKey: string) => (tx: Transaction) =>
|
|
20
|
+
poolEnabled: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
21
21
|
/**
|
|
22
22
|
* @description Get the margin pool ID for a given asset
|
|
23
23
|
* @param {string} coinKey The key to identify the coin
|
|
24
24
|
* @returns A function that takes a Transaction object
|
|
25
25
|
*/
|
|
26
|
-
getMarginPoolId: (coinKey: string) => (tx: Transaction) =>
|
|
26
|
+
getMarginPoolId: (coinKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
27
27
|
/**
|
|
28
28
|
* @description Get the margin pool IDs (base and quote) for a deepbook pool
|
|
29
29
|
* @param {string} poolKey The key to identify the pool
|
|
30
30
|
* @returns A function that takes a Transaction object
|
|
31
31
|
*/
|
|
32
|
-
getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) =>
|
|
32
|
+
getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
33
33
|
/**
|
|
34
34
|
* @description Get the margin manager IDs for a given owner
|
|
35
35
|
* @param {string} owner The owner address
|
|
36
36
|
* @returns A function that takes a Transaction object
|
|
37
37
|
*/
|
|
38
|
-
getMarginManagerIds: (owner: string) => (tx: Transaction) =>
|
|
38
|
+
getMarginManagerIds: (owner: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
39
39
|
/**
|
|
40
40
|
* @description Get the base margin pool ID for a deepbook pool
|
|
41
41
|
* @param {string} poolKey The key to identify the pool
|
|
42
42
|
* @returns A function that takes a Transaction object
|
|
43
43
|
*/
|
|
44
|
-
baseMarginPoolId: (poolKey: string) => (tx: Transaction) =>
|
|
44
|
+
baseMarginPoolId: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
45
45
|
/**
|
|
46
46
|
* @description Get the quote margin pool ID for a deepbook pool
|
|
47
47
|
* @param {string} poolKey The key to identify the pool
|
|
48
48
|
* @returns A function that takes a Transaction object
|
|
49
49
|
*/
|
|
50
|
-
quoteMarginPoolId: (poolKey: string) => (tx: Transaction) =>
|
|
50
|
+
quoteMarginPoolId: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
51
51
|
/**
|
|
52
52
|
* @description Get the minimum withdraw risk ratio for a deepbook pool
|
|
53
53
|
* @param {string} poolKey The key to identify the pool
|
|
54
54
|
* @returns A function that takes a Transaction object
|
|
55
55
|
*/
|
|
56
|
-
minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
56
|
+
minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
57
57
|
/**
|
|
58
58
|
* @description Get the minimum borrow risk ratio for a deepbook pool
|
|
59
59
|
* @param {string} poolKey The key to identify the pool
|
|
60
60
|
* @returns A function that takes a Transaction object
|
|
61
61
|
*/
|
|
62
|
-
minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
62
|
+
minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
63
63
|
/**
|
|
64
64
|
* @description Get the liquidation risk ratio for a deepbook pool
|
|
65
65
|
* @param {string} poolKey The key to identify the pool
|
|
66
66
|
* @returns A function that takes a Transaction object
|
|
67
67
|
*/
|
|
68
|
-
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
68
|
+
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
69
69
|
/**
|
|
70
70
|
* @description Get the target liquidation risk ratio for a deepbook pool
|
|
71
71
|
* @param {string} poolKey The key to identify the pool
|
|
72
72
|
* @returns A function that takes a Transaction object
|
|
73
73
|
*/
|
|
74
|
-
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
74
|
+
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
75
75
|
/**
|
|
76
76
|
* @description Get the user liquidation reward for a deepbook pool
|
|
77
77
|
* @param {string} poolKey The key to identify the pool
|
|
78
78
|
* @returns A function that takes a Transaction object
|
|
79
79
|
*/
|
|
80
|
-
userLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
80
|
+
userLiquidationReward: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
81
81
|
/**
|
|
82
82
|
* @description Get the pool liquidation reward for a deepbook pool
|
|
83
83
|
* @param {string} poolKey The key to identify the pool
|
|
84
84
|
* @returns A function that takes a Transaction object
|
|
85
85
|
*/
|
|
86
|
-
poolLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
86
|
+
poolLiquidationReward: (poolKey: string) => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
87
87
|
/**
|
|
88
88
|
* @description Get all allowed maintainer cap IDs
|
|
89
89
|
* @returns A function that takes a Transaction object
|
|
90
90
|
*/
|
|
91
|
-
allowedMaintainers: () => (tx: Transaction) =>
|
|
91
|
+
allowedMaintainers: () => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
92
92
|
/**
|
|
93
93
|
* @description Get all allowed pause cap IDs
|
|
94
94
|
* @returns A function that takes a Transaction object
|
|
95
95
|
*/
|
|
96
|
-
allowedPauseCaps: () => (tx: Transaction) =>
|
|
96
|
+
allowedPauseCaps: () => (tx: Transaction) => _haneullabs_haneul_transactions115.TransactionResult;
|
|
97
97
|
}
|
|
98
98
|
//#endregion
|
|
99
99
|
export { MarginRegistryContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"
|
|
1
|
+
{"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"mappings":";;;;;;;;cASa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAyBwB;;;;;EAhB5C,WAAA,GAAe,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAyDN;;;;;EAzC7C,eAAA,GAAmB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAmFR;;;;;EArE/C,4BAAA,GAAgC,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EA+GlB;;;;;EAjGlD,mBAAA,GAAuB,KAAA,cAAmB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAwI3B;;;;;EA3H9B,gBAAA,GAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAlEpC;;;;;EAgFpB,iBAAA,GAAqB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAvEN;;;;;EAqFnD,oBAAA,GAAwB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAvD5D;;;;;EAqEA,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAvDnC;;;;;EAqEvB,oBAAA,GAAwB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;EAxDf;;;;;EAsE7C,0BAAA,GAA8B,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,kCAAA,CAAA,iBAAA;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