@mysten/deepbook-v3 1.5.9 → 1.6.2
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 +60 -0
- package/dist/client.d.mts +5 -0
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +7 -0
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs +413 -0
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/big_vector.mjs +43 -0
- package/dist/contracts/deepbook/big_vector.mjs.map +1 -0
- package/dist/contracts/deepbook/book.mjs +29 -0
- package/dist/contracts/deepbook/book.mjs.map +1 -0
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.mjs +1 -1
- package/dist/contracts/deepbook/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook/governance.mjs +49 -0
- package/dist/contracts/deepbook/governance.mjs.map +1 -0
- package/dist/contracts/deepbook/history.mjs +56 -0
- package/dist/contracts/deepbook/history.mjs.map +1 -0
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs +1739 -0
- package/dist/contracts/deepbook/pool.mjs.map +1 -0
- package/dist/contracts/deepbook/registry.mjs +295 -0
- package/dist/contracts/deepbook/registry.mjs.map +1 -0
- package/dist/contracts/deepbook/state.mjs +89 -0
- package/dist/contracts/deepbook/state.mjs.map +1 -0
- package/dist/contracts/deepbook/trade_params.mjs +21 -0
- package/dist/contracts/deepbook/trade_params.mjs.map +1 -0
- package/dist/contracts/deepbook/vault.mjs +42 -0
- package/dist/contracts/deepbook/vault.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs +53 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs +989 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs +550 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs +786 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs +30 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/oracle.mjs +82 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +644 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs +32 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs +122 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs +58 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs +26 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs +171 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs +43 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +179 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -0
- package/dist/contracts/utils/index.d.mts +1 -1
- package/dist/contracts/utils/index.mjs +92 -3
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +13 -0
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +119 -100
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +464 -439
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +151 -135
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +29 -22
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +34 -33
- package/dist/transactions/governance.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +10 -0
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +186 -169
- 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 +53 -54
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +83 -83
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +330 -311
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +93 -89
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +22 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.mjs +101 -68
- package/dist/transactions/marginRegistry.mjs.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +27 -9
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +108 -82
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +32 -0
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +269 -189
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/utils/constants.mjs +4 -4
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +8 -0
- package/src/contracts/deepbook/balance_manager.ts +46 -5
- package/src/contracts/deepbook/constants.ts +13 -0
- package/src/contracts/deepbook/pool.ts +133 -0
- package/src/contracts/deepbook/registry.ts +136 -1
- package/src/contracts/deepbook_margin/deps/deepbook/balance_manager.ts +49 -0
- package/src/contracts/deepbook_margin/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_margin/deps/sui/bag.ts +41 -0
- package/src/contracts/deepbook_margin/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_margin/deps/sui/table.ts +36 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_margin/deps/sui/versioned.ts +13 -0
- package/src/contracts/deepbook_margin/margin_constants.ts +329 -0
- package/src/contracts/deepbook_margin/margin_manager.ts +1772 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +1129 -0
- package/src/contracts/deepbook_margin/margin_registry.ts +1207 -0
- package/src/contracts/deepbook_margin/margin_state.ts +26 -0
- package/src/contracts/deepbook_margin/oracle.ts +99 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +1298 -0
- package/src/contracts/deepbook_margin/position_manager.ts +28 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +163 -0
- package/src/contracts/deepbook_margin/protocol_fees.ts +153 -0
- package/src/contracts/deepbook_margin/rate_limiter.ts +80 -0
- package/src/contracts/deepbook_margin/tpsl.ts +559 -0
- package/src/contracts/margin_liquidation/deps/sui/bag.ts +41 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +401 -0
- package/src/queries/registryQueries.ts +15 -0
- package/src/transactions/balanceManager.ts +140 -90
- package/src/transactions/deepbook.ts +586 -494
- package/src/transactions/deepbookAdmin.ts +154 -146
- package/src/transactions/flashLoans.ts +29 -20
- package/src/transactions/governance.ts +50 -37
- package/src/transactions/marginAdmin.ts +247 -188
- package/src/transactions/marginLiquidations.ts +70 -55
- package/src/transactions/marginMaintainer.ts +106 -88
- package/src/transactions/marginManager.ts +414 -348
- package/src/transactions/marginPool.ts +140 -103
- package/src/transactions/marginRegistry.ts +103 -70
- package/src/transactions/marginTPSL.ts +151 -87
- package/src/transactions/poolProxy.ts +384 -205
- package/src/utils/constants.ts +4 -4
|
@@ -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 '@mysten/sui/transactions';\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/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,gBAAgB,iBAAiB,KAAK,O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PoolMoveCalls.withdrawReferralFees","marginPoolMoveCalls.id","marginPoolMoveCalls.deepbookPoolAllowed","marginPoolMoveCalls.totalSupply","marginPoolMoveCalls.supplyShares","marginPoolMoveCalls.totalBorrow","marginPoolMoveCalls.borrowShares","marginPoolMoveCalls.lastUpdateTimestamp","marginPoolMoveCalls.supplyCap","marginPoolMoveCalls.maxUtilizationRate","marginPoolMoveCalls.protocolSpread","marginPoolMoveCalls.minBorrow","marginPoolMoveCalls.interestRate","marginPoolMoveCalls.userSupplyShares","marginPoolMoveCalls.userSupplyAmount"],"sources":["../../src/transactions/marginPool.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { convertQuantity } from '../utils/conversion.js';\nimport * as marginPoolMoveCalls from '../contracts/deepbook_margin/margin_pool.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.add(\n\t\t\tmarginPoolMoveCalls.mintSupplierCap({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { registry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t}),\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\t// NOTE: left as a positional moveCall (not codegen). This builder's\n\t\t\t// coinWithBalance + `tx.object.option` (an on-chain option::none MoveCall\n\t\t\t// for the Option<ID> referral) interleave commands in a way that a\n\t\t\t// generated named-arg call reorders — so migrating it would change the\n\t\t\t// emitted PTB. Kept verbatim to stay byte-identical.\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.add(\n\t\t\t\tmarginPoolMoveCalls.withdraw({\n\t\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: marginPool.address,\n\t\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\t\tsupplierCap,\n\t\t\t\t\t\tamount: withdrawInput,\n\t\t\t\t\t},\n\t\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.mintSupplyReferral({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, registry: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.withdrawReferralFees({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: {\n\t\t\t\t\tself: marginPool.address,\n\t\t\t\t\tregistry: this.#config.MARGIN_REGISTRY_ID,\n\t\t\t\t\treferral: referralId,\n\t\t\t\t},\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.id({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.deepbookPoolAllowed({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, deepbookPoolId },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.totalSupply({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.supplyShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.totalBorrow({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.borrowShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.lastUpdateTimestamp({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.supplyCap({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.maxUtilizationRate({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.protocolSpread({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.minBorrow({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.interestRate({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.userSupplyShares({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: marginPool.address, supplierCapId },\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t}),\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.add(\n\t\t\tmarginPoolMoveCalls.userSupplyAmount({\n\t\t\t\tpackage: this.#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
2
|
+
import * as _mysten_sui_transactions106 from "@mysten/sui/transactions";
|
|
3
3
|
import { Transaction } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/marginRegistry.d.ts
|
|
@@ -17,83 +17,90 @@ 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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.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) => _mysten_sui_transactions106.TransactionResult;
|
|
63
|
+
/**
|
|
64
|
+
* @description Get the minimum risk ratio required to open a new position on
|
|
65
|
+
* a deepbook pool. Distinct from `minBorrowRiskRatio`, which gates borrowing.
|
|
66
|
+
* @param {string} poolKey The key to identify the pool
|
|
67
|
+
* @returns A function that takes a Transaction object
|
|
68
|
+
*/
|
|
69
|
+
minOpenRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
63
70
|
/**
|
|
64
71
|
* @description Get the liquidation risk ratio for a deepbook pool
|
|
65
72
|
* @param {string} poolKey The key to identify the pool
|
|
66
73
|
* @returns A function that takes a Transaction object
|
|
67
74
|
*/
|
|
68
|
-
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
75
|
+
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
69
76
|
/**
|
|
70
77
|
* @description Get the target liquidation risk ratio for a deepbook pool
|
|
71
78
|
* @param {string} poolKey The key to identify the pool
|
|
72
79
|
* @returns A function that takes a Transaction object
|
|
73
80
|
*/
|
|
74
|
-
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
81
|
+
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
75
82
|
/**
|
|
76
83
|
* @description Get the user liquidation reward for a deepbook pool
|
|
77
84
|
* @param {string} poolKey The key to identify the pool
|
|
78
85
|
* @returns A function that takes a Transaction object
|
|
79
86
|
*/
|
|
80
|
-
userLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
87
|
+
userLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
81
88
|
/**
|
|
82
89
|
* @description Get the pool liquidation reward for a deepbook pool
|
|
83
90
|
* @param {string} poolKey The key to identify the pool
|
|
84
91
|
* @returns A function that takes a Transaction object
|
|
85
92
|
*/
|
|
86
|
-
poolLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
93
|
+
poolLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
87
94
|
/**
|
|
88
95
|
* @description Get all allowed maintainer cap IDs
|
|
89
96
|
* @returns A function that takes a Transaction object
|
|
90
97
|
*/
|
|
91
|
-
allowedMaintainers: () => (tx: Transaction) =>
|
|
98
|
+
allowedMaintainers: () => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
92
99
|
/**
|
|
93
100
|
* @description Get all allowed pause cap IDs
|
|
94
101
|
* @returns A function that takes a Transaction object
|
|
95
102
|
*/
|
|
96
|
-
allowedPauseCaps: () => (tx: Transaction) =>
|
|
103
|
+
allowedPauseCaps: () => (tx: Transaction) => _mysten_sui_transactions106.TransactionResult;
|
|
97
104
|
}
|
|
98
105
|
//#endregion
|
|
99
106
|
export { MarginRegistryContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"marginRegistry.d.mts","names":[],"sources":["../../src/transactions/marginRegistry.ts"],"mappings":";;;;;;;;cAUa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EA2BwB;;;;;EAlB5C,WAAA,GAAe,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA+DN;;;;;EA7C7C,eAAA,GAAmB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA0FR;;;;;EA1E/C,4BAAA,GAAgC,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAwHb;;;;;EAzGvD,mBAAA,GAAuB,KAAA,cAAmB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAqJzB;;;;;EAvIhC,gBAAA,GAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;;;;;;EAexD,iBAAA,GAAqB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA9EjB;;;;;EA6FxC,oBAAA,GAAwB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA3EpB;;;;;EA0FxC,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA1EU;;;;;;EA0FpE,gBAAA,GAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA7DpC;;;;;EA4EpB,oBAAA,GAAwB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA7Dd;;;;;EA4E9C,0BAAA,GAA8B,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA7DrB;;;;;EA4E7C,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA7DH;;;;;EA4E1D,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA7C7D;;;;EA2DA,kBAAA,SAA4B,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA5C3C;;;;EAyDA,gBAAA,SAA0B,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;AAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { allowedMaintainers, allowedPauseCaps, baseMarginPoolId, getDeepbookPoolMarginPoolIds, getMarginManagerIds, getMarginPoolId, liquidationRiskRatio, minBorrowRiskRatio, minOpenRiskRatio, minWithdrawRiskRatio, poolEnabled, poolLiquidationReward, quoteMarginPoolId, targetLiquidationRiskRatio, userLiquidationReward } from "../contracts/deepbook_margin/margin_registry.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/transactions/marginRegistry.ts
|
|
2
4
|
/**
|
|
3
5
|
* MarginRegistryContract class for managing MarginRegistry read-only operations.
|
|
@@ -12,112 +14,143 @@ var MarginRegistryContract = class {
|
|
|
12
14
|
const pool = this.#config.getPool(poolKey);
|
|
13
15
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
14
16
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
15
|
-
return tx.
|
|
16
|
-
|
|
17
|
-
arguments:
|
|
17
|
+
return tx.add(poolEnabled({
|
|
18
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
19
|
+
arguments: {
|
|
20
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
21
|
+
pool: pool.address
|
|
22
|
+
},
|
|
18
23
|
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
19
|
-
});
|
|
24
|
+
}));
|
|
20
25
|
};
|
|
21
26
|
this.getMarginPoolId = (coinKey) => (tx) => {
|
|
22
27
|
const coin = this.#config.getCoin(coinKey);
|
|
23
|
-
return tx.
|
|
24
|
-
|
|
25
|
-
arguments:
|
|
28
|
+
return tx.add(getMarginPoolId({
|
|
29
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
30
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID },
|
|
26
31
|
typeArguments: [coin.type]
|
|
27
|
-
});
|
|
32
|
+
}));
|
|
28
33
|
};
|
|
29
34
|
this.getDeepbookPoolMarginPoolIds = (poolKey) => (tx) => {
|
|
30
35
|
const pool = this.#config.getPool(poolKey);
|
|
31
|
-
return tx.
|
|
32
|
-
|
|
33
|
-
arguments:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
return tx.add(getDeepbookPoolMarginPoolIds({
|
|
37
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
38
|
+
arguments: {
|
|
39
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
40
|
+
deepbookPoolId: pool.address
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
36
43
|
};
|
|
37
44
|
this.getMarginManagerIds = (owner) => (tx) => {
|
|
38
|
-
return tx.
|
|
39
|
-
|
|
40
|
-
arguments:
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
return tx.add(getMarginManagerIds({
|
|
46
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
47
|
+
arguments: {
|
|
48
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
49
|
+
owner
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
43
52
|
};
|
|
44
53
|
this.baseMarginPoolId = (poolKey) => (tx) => {
|
|
45
54
|
const pool = this.#config.getPool(poolKey);
|
|
46
|
-
return tx.
|
|
47
|
-
|
|
48
|
-
arguments:
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
return tx.add(baseMarginPoolId({
|
|
56
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
57
|
+
arguments: {
|
|
58
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
59
|
+
deepbookPoolId: pool.address
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
51
62
|
};
|
|
52
63
|
this.quoteMarginPoolId = (poolKey) => (tx) => {
|
|
53
64
|
const pool = this.#config.getPool(poolKey);
|
|
54
|
-
return tx.
|
|
55
|
-
|
|
56
|
-
arguments:
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
return tx.add(quoteMarginPoolId({
|
|
66
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
67
|
+
arguments: {
|
|
68
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
69
|
+
deepbookPoolId: pool.address
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
59
72
|
};
|
|
60
73
|
this.minWithdrawRiskRatio = (poolKey) => (tx) => {
|
|
61
74
|
const pool = this.#config.getPool(poolKey);
|
|
62
|
-
return tx.
|
|
63
|
-
|
|
64
|
-
arguments:
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
return tx.add(minWithdrawRiskRatio({
|
|
76
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
77
|
+
arguments: {
|
|
78
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
79
|
+
deepbookPoolId: pool.address
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
67
82
|
};
|
|
68
83
|
this.minBorrowRiskRatio = (poolKey) => (tx) => {
|
|
69
84
|
const pool = this.#config.getPool(poolKey);
|
|
70
|
-
return tx.
|
|
71
|
-
|
|
72
|
-
arguments:
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
return tx.add(minBorrowRiskRatio({
|
|
86
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
87
|
+
arguments: {
|
|
88
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
89
|
+
deepbookPoolId: pool.address
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
this.minOpenRiskRatio = (poolKey) => (tx) => {
|
|
94
|
+
const pool = this.#config.getPool(poolKey);
|
|
95
|
+
return tx.add(minOpenRiskRatio({
|
|
96
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
97
|
+
arguments: {
|
|
98
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
99
|
+
deepbookPoolId: pool.address
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
75
102
|
};
|
|
76
103
|
this.liquidationRiskRatio = (poolKey) => (tx) => {
|
|
77
104
|
const pool = this.#config.getPool(poolKey);
|
|
78
|
-
return tx.
|
|
79
|
-
|
|
80
|
-
arguments:
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
return tx.add(liquidationRiskRatio({
|
|
106
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
107
|
+
arguments: {
|
|
108
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
109
|
+
deepbookPoolId: pool.address
|
|
110
|
+
}
|
|
111
|
+
}));
|
|
83
112
|
};
|
|
84
113
|
this.targetLiquidationRiskRatio = (poolKey) => (tx) => {
|
|
85
114
|
const pool = this.#config.getPool(poolKey);
|
|
86
|
-
return tx.
|
|
87
|
-
|
|
88
|
-
arguments:
|
|
89
|
-
|
|
90
|
-
|
|
115
|
+
return tx.add(targetLiquidationRiskRatio({
|
|
116
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
117
|
+
arguments: {
|
|
118
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
119
|
+
deepbookPoolId: pool.address
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
91
122
|
};
|
|
92
123
|
this.userLiquidationReward = (poolKey) => (tx) => {
|
|
93
124
|
const pool = this.#config.getPool(poolKey);
|
|
94
|
-
return tx.
|
|
95
|
-
|
|
96
|
-
arguments:
|
|
97
|
-
|
|
98
|
-
|
|
125
|
+
return tx.add(userLiquidationReward({
|
|
126
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
127
|
+
arguments: {
|
|
128
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
129
|
+
deepbookPoolId: pool.address
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
99
132
|
};
|
|
100
133
|
this.poolLiquidationReward = (poolKey) => (tx) => {
|
|
101
134
|
const pool = this.#config.getPool(poolKey);
|
|
102
|
-
return tx.
|
|
103
|
-
|
|
104
|
-
arguments:
|
|
105
|
-
|
|
106
|
-
|
|
135
|
+
return tx.add(poolLiquidationReward({
|
|
136
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
137
|
+
arguments: {
|
|
138
|
+
self: this.#config.MARGIN_REGISTRY_ID,
|
|
139
|
+
deepbookPoolId: pool.address
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
107
142
|
};
|
|
108
143
|
this.allowedMaintainers = () => (tx) => {
|
|
109
|
-
return tx.
|
|
110
|
-
|
|
111
|
-
arguments:
|
|
112
|
-
|
|
113
|
-
});
|
|
144
|
+
return tx.add(allowedMaintainers({
|
|
145
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
146
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID }
|
|
147
|
+
}));
|
|
114
148
|
};
|
|
115
149
|
this.allowedPauseCaps = () => (tx) => {
|
|
116
|
-
return tx.
|
|
117
|
-
|
|
118
|
-
arguments:
|
|
119
|
-
|
|
120
|
-
});
|
|
150
|
+
return tx.add(allowedPauseCaps({
|
|
151
|
+
package: this.#config.MARGIN_PACKAGE_ID,
|
|
152
|
+
arguments: { self: this.#config.MARGIN_REGISTRY_ID }
|
|
153
|
+
}));
|
|
121
154
|
};
|
|
122
155
|
this.#config = config;
|
|
123
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginRegistry.mjs","names":["#config"],"sources":["../../src/transactions/marginRegistry.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * MarginRegistryContract class for managing MarginRegistry read-only operations.\n */\nexport class MarginRegistryContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginRegistryContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Check if a deepbook pool is enabled for margin trading\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tpoolEnabled = (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\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::pool_enabled`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the margin pool ID for a given asset\n\t * @param {string} coinKey The key to identify the coin\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetMarginPoolId = (coinKey: string) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::get_margin_pool_id`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the margin pool IDs (base and quote) for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetDeepbookPoolMarginPoolIds = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::get_deepbook_pool_margin_pool_ids`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the margin manager IDs for a given owner\n\t * @param {string} owner The owner address\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetMarginManagerIds = (owner: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::get_margin_manager_ids`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.address(owner)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the base margin pool ID for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tbaseMarginPoolId = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::base_margin_pool_id`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quote margin pool ID for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tquoteMarginPoolId = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::quote_margin_pool_id`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the minimum withdraw risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminWithdrawRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::min_withdraw_risk_ratio`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the minimum borrow risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminBorrowRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::min_borrow_risk_ratio`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the liquidation risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::liquidation_risk_ratio`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the target liquidation risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttargetLiquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::target_liquidation_risk_ratio`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the user liquidation reward for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserLiquidationReward = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::user_liquidation_reward`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the pool liquidation reward for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tpoolLiquidationReward = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::pool_liquidation_reward`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get all allowed maintainer cap IDs\n\t * @returns A function that takes a Transaction object\n\t */\n\tallowedMaintainers = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::allowed_maintainers`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get all allowed pause cap IDs\n\t * @returns A function that takes a Transaction object\n\t */\n\tallowedPauseCaps = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::allowed_pause_caps`,\n\t\t\targuments: [tx.object(this.#config.MARGIN_REGISTRY_ID)],\n\t\t\ttypeArguments: [],\n\t\t});\n\t};\n}\n"],"mappings":";;;;AASA,IAAa,yBAAb,MAAoC;CACnC;;;;CAKA,YAAY,QAAwB;sBASrB,aAAqB,OAAoB;GACvD,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB,EAAE,GAAG,OAAO,KAAK,QAAQ,CAAC;IAChF,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;0BAQgB,aAAqB,OAAoB;GAC3D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;AAC1C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB,CAAC;IACvD,eAAe,CAAC,KAAK,KAAK;IAC1B,CAAC;;uCAQ6B,aAAqB,OAAoB;GACxE,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;AAC1C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAA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AAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB,CAAC;IACvD,eAAe,EAAE;IACjB,CAAC;;iCAOuB,OAAoB;AAC7C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,kBAAkB;IAC1C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,mBAAmB,CAAC;IACvD,eAAe,EAAE;IACjB,CAAC;;AAjMF,QAAKA,SAAU"}
|
|
1
|
+
{"version":3,"file":"marginRegistry.mjs","names":["#config","marginRegistryMoveCalls.poolEnabled","marginRegistryMoveCalls.getMarginPoolId","marginRegistryMoveCalls.getDeepbookPoolMarginPoolIds","marginRegistryMoveCalls.getMarginManagerIds","marginRegistryMoveCalls.baseMarginPoolId","marginRegistryMoveCalls.quoteMarginPoolId","marginRegistryMoveCalls.minWithdrawRiskRatio","marginRegistryMoveCalls.minBorrowRiskRatio","marginRegistryMoveCalls.minOpenRiskRatio","marginRegistryMoveCalls.liquidationRiskRatio","marginRegistryMoveCalls.targetLiquidationRiskRatio","marginRegistryMoveCalls.userLiquidationReward","marginRegistryMoveCalls.poolLiquidationReward","marginRegistryMoveCalls.allowedMaintainers","marginRegistryMoveCalls.allowedPauseCaps"],"sources":["../../src/transactions/marginRegistry.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport * as marginRegistryMoveCalls from '../contracts/deepbook_margin/margin_registry.js';\n\n/**\n * MarginRegistryContract class for managing MarginRegistry read-only operations.\n */\nexport class MarginRegistryContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginRegistryContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Check if a deepbook pool is enabled for margin trading\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tpoolEnabled = (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\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.poolEnabled({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, pool: pool.address },\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the margin pool ID for a given asset\n\t * @param {string} coinKey The key to identify the coin\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetMarginPoolId = (coinKey: string) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.getMarginPoolId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the margin pool IDs (base and quote) for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetDeepbookPoolMarginPoolIds = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.getDeepbookPoolMarginPoolIds({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the margin manager IDs for a given owner\n\t * @param {string} owner The owner address\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetMarginManagerIds = (owner: string) => (tx: Transaction) => {\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.getMarginManagerIds({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, owner },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the base margin pool ID for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tbaseMarginPoolId = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.baseMarginPoolId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the quote margin pool ID for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tquoteMarginPoolId = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.quoteMarginPoolId({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the minimum withdraw risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminWithdrawRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.minWithdrawRiskRatio({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the minimum borrow risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminBorrowRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.minBorrowRiskRatio({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the minimum risk ratio required to open a new position on\n\t * a deepbook pool. Distinct from `minBorrowRiskRatio`, which gates borrowing.\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tminOpenRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.minOpenRiskRatio({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the liquidation risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.liquidationRiskRatio({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the target liquidation risk ratio for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\ttargetLiquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.targetLiquidationRiskRatio({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the user liquidation reward for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tuserLiquidationReward = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.userLiquidationReward({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get the pool liquidation reward for a deepbook pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tpoolLiquidationReward = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.poolLiquidationReward({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID, deepbookPoolId: pool.address },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get all allowed maintainer cap IDs\n\t * @returns A function that takes a Transaction object\n\t */\n\tallowedMaintainers = () => (tx: Transaction) => {\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.allowedMaintainers({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t}),\n\t\t);\n\t};\n\n\t/**\n\t * @description Get all allowed pause cap IDs\n\t * @returns A function that takes a Transaction object\n\t */\n\tallowedPauseCaps = () => (tx: Transaction) => {\n\t\treturn tx.add(\n\t\t\tmarginRegistryMoveCalls.allowedPauseCaps({\n\t\t\t\tpackage: this.#config.MARGIN_PACKAGE_ID,\n\t\t\t\targuments: { self: this.#config.MARGIN_REGISTRY_ID },\n\t\t\t}),\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;AAUA,IAAa,yBAAb,MAAoC;CACnC;;;;CAKA,YAAY,QAAwB;sBASrB,aAAqB,OAAoB;GACvD,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;GAC1C,MAAM,WAAW,MAAKA,OAAQ,QAAQ,KAAK,SAAS;GACpD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AACtD,UAAO,GAAG,IACTC,YAAoC;IACnC,SAAS,MAAKD,OAAQ;IACtB,WAAW;KAAE,MAAM,MAAKA,OAAQ;KAAoB,MAAM,KAAK;KAAS;IACxE,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC,CACF;;0BAQiB,aAAqB,OAAoB;GAC3D,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;AAC1C,UAAO,GAAG,IACTE,gBAAwC;IACvC,SAAS,MAAKF,OAAQ;IACtB,WAAW,EAAE,MAAM,MAAKA,OAAQ,oBAAoB;IACpD,eAAe,CAAC,KAAK,KAAK;IAC1B,CAAC,CACF;;uCAQ8B,aAAqB,OAAoB;GACxE,MAAM,OAAO,MAAKA,OAAQ,QAAQ,QAAQ;AAC1C,UAAO,GAAG,IACTG,6BAAqD;IACpD,SAAS,MAAKH,OAAQ;IACtB,WAAW;KAAE,MAAM,MAAKA,OAAQ;KAAoB,gBAAgB,KAAK;KAAS;IAClF,CAAC,CACF;;8BAQqB,WAAmB,OAAoB;AAC7D,UAAO,GA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
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions97 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/marginTPSL.d.ts
|
|
@@ -20,21 +20,21 @@ declare class MarginTPSLContract {
|
|
|
20
20
|
* @param {number} triggerPrice The price at which to trigger the order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
newCondition: (poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) => (tx: Transaction) =>
|
|
23
|
+
newCondition: (poolKey: string, triggerBelowPrice: boolean, triggerPrice: number | bigint) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Create a new pending limit order for use in conditional orders
|
|
26
26
|
* @param {string} poolKey The key to identify the pool
|
|
27
27
|
* @param {PendingLimitOrderParams} params Parameters for the pending limit order
|
|
28
28
|
* @returns A function that takes a Transaction object
|
|
29
29
|
*/
|
|
30
|
-
newPendingLimitOrder: (poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) =>
|
|
30
|
+
newPendingLimitOrder: (poolKey: string, params: PendingLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
31
31
|
/**
|
|
32
32
|
* @description Create a new pending market order for use in conditional orders
|
|
33
33
|
* @param {string} poolKey The key to identify the pool
|
|
34
34
|
* @param {PendingMarketOrderParams} params Parameters for the pending market order
|
|
35
35
|
* @returns A function that takes a Transaction object
|
|
36
36
|
*/
|
|
37
|
-
newPendingMarketOrder: (poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) =>
|
|
37
|
+
newPendingMarketOrder: (poolKey: string, params: PendingMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
38
38
|
/**
|
|
39
39
|
* @description Add a conditional order (take profit or stop loss)
|
|
40
40
|
* @param {AddConditionalOrderParams} params Parameters for adding the conditional order
|
|
@@ -65,14 +65,32 @@ declare class MarginTPSLContract {
|
|
|
65
65
|
* @param {number} maxOrdersToExecute Maximum number of orders to execute in this call
|
|
66
66
|
* @returns A function that takes a Transaction object
|
|
67
67
|
*/
|
|
68
|
-
executeConditionalOrders: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) =>
|
|
68
|
+
executeConditionalOrders: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
69
|
+
/**
|
|
70
|
+
* @description Execute conditional orders, deleveraging on each market-type
|
|
71
|
+
* fill. Permissionless, with the same trigger and cancellation handling as
|
|
72
|
+
* {@link executeConditionalOrders}, but the market proceeds are repaid into
|
|
73
|
+
* the loan before the risk check, and the gate is the *net* post-repay
|
|
74
|
+
* `risk_ratio` being at least the pre-fill ratio.
|
|
75
|
+
*
|
|
76
|
+
* This is what lets a stop-loss fire in the `liquidation..min_borrow` danger
|
|
77
|
+
* band: a swap alone only lowers the oracle-valued ratio (so the v2
|
|
78
|
+
* borrow-floor gate rejects it), while repaying actually improves it. If a
|
|
79
|
+
* single triggered fill would worsen net solvency the whole txn aborts — no
|
|
80
|
+
* partial-state landing.
|
|
81
|
+
* @param {string} managerAddress The address of the margin manager
|
|
82
|
+
* @param {string} poolKey The key to identify the pool (e.g., 'SUI_USDC')
|
|
83
|
+
* @param {number} maxOrdersToExecute Maximum number of orders to execute in this call
|
|
84
|
+
* @returns A function that takes a Transaction object
|
|
85
|
+
*/
|
|
86
|
+
executeConditionalOrdersV3: (managerAddress: string, poolKey: string, maxOrdersToExecute: number) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
69
87
|
/**
|
|
70
88
|
* @description Get all conditional order IDs for a margin manager
|
|
71
89
|
* @param {string} poolKey The key to identify the pool
|
|
72
90
|
* @param {string} marginManagerId The ID of the margin manager
|
|
73
91
|
* @returns A function that takes a Transaction object
|
|
74
92
|
*/
|
|
75
|
-
conditionalOrderIds: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
93
|
+
conditionalOrderIds: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
76
94
|
/**
|
|
77
95
|
* @description Get a specific conditional order by ID
|
|
78
96
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -80,7 +98,7 @@ declare class MarginTPSLContract {
|
|
|
80
98
|
* @param {string} conditionalOrderId The ID of the conditional order
|
|
81
99
|
* @returns A function that takes a Transaction object
|
|
82
100
|
*/
|
|
83
|
-
conditionalOrder: (poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) =>
|
|
101
|
+
conditionalOrder: (poolKey: string, marginManagerId: string, conditionalOrderId: string) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
84
102
|
/**
|
|
85
103
|
* @description Get the lowest trigger price for trigger_above orders
|
|
86
104
|
* Returns constants::max_u64() if there are no trigger_above orders
|
|
@@ -88,7 +106,7 @@ declare class MarginTPSLContract {
|
|
|
88
106
|
* @param {string} marginManagerId The ID of the margin manager
|
|
89
107
|
* @returns A function that takes a Transaction object
|
|
90
108
|
*/
|
|
91
|
-
lowestTriggerAbovePrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
109
|
+
lowestTriggerAbovePrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
92
110
|
/**
|
|
93
111
|
* @description Get the highest trigger price for trigger_below orders
|
|
94
112
|
* Returns 0 if there are no trigger_below orders
|
|
@@ -96,7 +114,7 @@ declare class MarginTPSLContract {
|
|
|
96
114
|
* @param {string} marginManagerId The ID of the margin manager
|
|
97
115
|
* @returns A function that takes a Transaction object
|
|
98
116
|
*/
|
|
99
|
-
highestTriggerBelowPrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) =>
|
|
117
|
+
highestTriggerBelowPrice: (poolKey: string, marginManagerId: string) => (tx: Transaction) => _mysten_sui_transactions97.TransactionResult;
|
|
100
118
|
}
|
|
101
119
|
//#endregion
|
|
102
120
|
export { MarginTPSLContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;cAmBa,kBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAwCO;;;;;;;EA3B3B,YAAA,GACE,OAAA,UAAiB,iBAAA,WAA4B,YAAA,uBAC7C,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAyI+C;;;;;;EAjHhE,oBAAA,GACE,OAAA,UAAiB,MAAA,EAAQ,uBAAA,MAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAyOa;;;;;;EAlMpF,qBAAA,GACE,OAAA,UAAiB,MAAA,EAAQ,wBAAA,MAA8B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA8PiB;;;;;EA9NzF,mBAAA,GAAuB,MAAA,EAAQ,yBAAA,MAA+B,EAAA,EAAI,WAAA;EAnGlE;;;;;EA2IA,0BAAA,GAA8B,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAzI/C;;;;;;EA6JjB,sBAAA,GACE,gBAAA,UAA0B,kBAAA,cAAgC,EAAA,EAAI,WAAA;EArIO;;;;;;;;;;;EA8JvE,wBAAA,GACE,cAAA,UAAwB,OAAA,UAAiB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAvF5B;;;;;;;;;;;;;;;;;EAgI9D,0BAAA,GACE,cAAA,UAAwB,OAAA,UAAiB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAxF;;;;;;E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