@haneullabs/deepbook-v3 0.1.0
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 +984 -0
- package/README.md +1 -0
- package/dist/cjs/client.d.ts +861 -0
- package/dist/cjs/client.js +1982 -0
- package/dist/cjs/client.js.map +7 -0
- package/dist/cjs/contracts/deepbook/account.d.ts +105 -0
- package/dist/cjs/contracts/deepbook/account.js +163 -0
- package/dist/cjs/contracts/deepbook/account.js.map +7 -0
- package/dist/cjs/contracts/deepbook/balance_manager.d.ts +268 -0
- package/dist/cjs/contracts/deepbook/balance_manager.js +361 -0
- package/dist/cjs/contracts/deepbook/balance_manager.js.map +7 -0
- package/dist/cjs/contracts/deepbook/balances.d.ts +10 -0
- package/dist/cjs/contracts/deepbook/balances.js +35 -0
- package/dist/cjs/contracts/deepbook/balances.js.map +7 -0
- package/dist/cjs/contracts/deepbook/big_vector.d.ts +62 -0
- package/dist/cjs/contracts/deepbook/big_vector.js +80 -0
- package/dist/cjs/contracts/deepbook/big_vector.js.map +7 -0
- package/dist/cjs/contracts/deepbook/book.d.ts +34 -0
- package/dist/cjs/contracts/deepbook/book.js +50 -0
- package/dist/cjs/contracts/deepbook/book.js.map +7 -0
- package/dist/cjs/contracts/deepbook/constants.d.ts +176 -0
- package/dist/cjs/contracts/deepbook/constants.js +338 -0
- package/dist/cjs/contracts/deepbook/constants.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deep_price.d.ts +60 -0
- package/dist/cjs/contracts/deepbook/deep_price.js +87 -0
- package/dist/cjs/contracts/deepbook/deep_price.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/std/type_name.d.ts +14 -0
- package/dist/cjs/contracts/deepbook/deps/std/type_name.js +42 -0
- package/dist/cjs/contracts/deepbook/deps/std/type_name.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/bag.d.ts +33 -0
- package/dist/cjs/contracts/deepbook/deps/sui/bag.js +47 -0
- package/dist/cjs/contracts/deepbook/deps/sui/bag.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/balance.d.ts +9 -0
- package/dist/cjs/contracts/deepbook/deps/sui/balance.js +33 -0
- package/dist/cjs/contracts/deepbook/deps/sui/balance.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/object.d.ts +5 -0
- package/dist/cjs/contracts/deepbook/deps/sui/object.js +33 -0
- package/dist/cjs/contracts/deepbook/deps/sui/object.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/table.d.ts +28 -0
- package/dist/cjs/contracts/deepbook/deps/sui/table.js +47 -0
- package/dist/cjs/contracts/deepbook/deps/sui/table.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/vec_map.d.ts +27 -0
- package/dist/cjs/contracts/deepbook/deps/sui/vec_map.js +45 -0
- package/dist/cjs/contracts/deepbook/deps/sui/vec_map.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/vec_set.d.ts +15 -0
- package/dist/cjs/contracts/deepbook/deps/sui/vec_set.js +35 -0
- package/dist/cjs/contracts/deepbook/deps/sui/vec_set.js.map +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/versioned.d.ts +7 -0
- package/dist/cjs/contracts/deepbook/deps/sui/versioned.js +45 -0
- package/dist/cjs/contracts/deepbook/deps/sui/versioned.js.map +7 -0
- package/dist/cjs/contracts/deepbook/ewma.d.ts +17 -0
- package/dist/cjs/contracts/deepbook/ewma.js +39 -0
- package/dist/cjs/contracts/deepbook/ewma.js.map +7 -0
- package/dist/cjs/contracts/deepbook/fill.d.ts +153 -0
- package/dist/cjs/contracts/deepbook/fill.js +251 -0
- package/dist/cjs/contracts/deepbook/fill.js.map +7 -0
- package/dist/cjs/contracts/deepbook/governance.d.ts +63 -0
- package/dist/cjs/contracts/deepbook/governance.js +79 -0
- package/dist/cjs/contracts/deepbook/governance.js.map +7 -0
- package/dist/cjs/contracts/deepbook/history.d.ts +60 -0
- package/dist/cjs/contracts/deepbook/history.js +78 -0
- package/dist/cjs/contracts/deepbook/history.js.map +7 -0
- package/dist/cjs/contracts/deepbook/math.d.ts +94 -0
- package/dist/cjs/contracts/deepbook/math.js +132 -0
- package/dist/cjs/contracts/deepbook/math.js.map +7 -0
- package/dist/cjs/contracts/deepbook/order.d.ts +135 -0
- package/dist/cjs/contracts/deepbook/order.js +218 -0
- package/dist/cjs/contracts/deepbook/order.js.map +7 -0
- package/dist/cjs/contracts/deepbook/order_info.d.ts +296 -0
- package/dist/cjs/contracts/deepbook/order_info.js +386 -0
- package/dist/cjs/contracts/deepbook/order_info.js.map +7 -0
- package/dist/cjs/contracts/deepbook/order_query.d.ts +85 -0
- package/dist/cjs/contracts/deepbook/order_query.js +96 -0
- package/dist/cjs/contracts/deepbook/order_query.js.map +7 -0
- package/dist/cjs/contracts/deepbook/pool.d.ts +1218 -0
- package/dist/cjs/contracts/deepbook/pool.js +1236 -0
- package/dist/cjs/contracts/deepbook/pool.js.map +7 -0
- package/dist/cjs/contracts/deepbook/registry.d.ts +134 -0
- package/dist/cjs/contracts/deepbook/registry.js +182 -0
- package/dist/cjs/contracts/deepbook/registry.js.map +7 -0
- package/dist/cjs/contracts/deepbook/state.d.ts +117 -0
- package/dist/cjs/contracts/deepbook/state.js +104 -0
- package/dist/cjs/contracts/deepbook/state.js.map +7 -0
- package/dist/cjs/contracts/deepbook/trade_params.d.ts +7 -0
- package/dist/cjs/contracts/deepbook/trade_params.js +35 -0
- package/dist/cjs/contracts/deepbook/trade_params.js.map +7 -0
- package/dist/cjs/contracts/deepbook/vault.d.ts +30 -0
- package/dist/cjs/contracts/deepbook/vault.js +65 -0
- package/dist/cjs/contracts/deepbook/vault.js.map +7 -0
- package/dist/cjs/contracts/utils/index.d.ts +25 -0
- package/dist/cjs/contracts/utils/index.js +148 -0
- package/dist/cjs/contracts/utils/index.js.map +7 -0
- package/dist/cjs/index.d.ts +23 -0
- package/dist/cjs/index.js +81 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/pyth/PriceServiceConnection.d.ts +26 -0
- package/dist/cjs/pyth/PriceServiceConnection.js +68 -0
- package/dist/cjs/pyth/PriceServiceConnection.js.map +7 -0
- package/dist/cjs/pyth/pyth-helpers.d.ts +7 -0
- package/dist/cjs/pyth/pyth-helpers.js +36 -0
- package/dist/cjs/pyth/pyth-helpers.js.map +7 -0
- package/dist/cjs/pyth/pyth.d.ts +65 -0
- package/dist/cjs/pyth/pyth.js +269 -0
- package/dist/cjs/pyth/pyth.js.map +7 -0
- package/dist/cjs/transactions/balanceManager.d.ts +168 -0
- package/dist/cjs/transactions/balanceManager.js +384 -0
- package/dist/cjs/transactions/balanceManager.js.map +7 -0
- package/dist/cjs/transactions/deepbook.d.ts +477 -0
- package/dist/cjs/transactions/deepbook.js +1335 -0
- package/dist/cjs/transactions/deepbook.js.map +7 -0
- package/dist/cjs/transactions/deepbookAdmin.d.ts +105 -0
- package/dist/cjs/transactions/deepbookAdmin.js +334 -0
- package/dist/cjs/transactions/deepbookAdmin.js.map +7 -0
- package/dist/cjs/transactions/flashLoans.d.ts +56 -0
- package/dist/cjs/transactions/flashLoans.js +124 -0
- package/dist/cjs/transactions/flashLoans.js.map +7 -0
- package/dist/cjs/transactions/governance.d.ts +42 -0
- package/dist/cjs/transactions/governance.js +135 -0
- package/dist/cjs/transactions/governance.js.map +7 -0
- package/dist/cjs/transactions/marginAdmin.d.ts +133 -0
- package/dist/cjs/transactions/marginAdmin.js +393 -0
- package/dist/cjs/transactions/marginAdmin.js.map +7 -0
- package/dist/cjs/transactions/marginLiquidations.d.ts +61 -0
- package/dist/cjs/transactions/marginLiquidations.js +173 -0
- package/dist/cjs/transactions/marginLiquidations.js.map +7 -0
- package/dist/cjs/transactions/marginMaintainer.d.ts +80 -0
- package/dist/cjs/transactions/marginMaintainer.js +251 -0
- package/dist/cjs/transactions/marginMaintainer.js.map +7 -0
- package/dist/cjs/transactions/marginManager.d.ts +236 -0
- package/dist/cjs/transactions/marginManager.js +688 -0
- package/dist/cjs/transactions/marginManager.js.map +7 -0
- package/dist/cjs/transactions/marginPool.d.ts +134 -0
- package/dist/cjs/transactions/marginPool.js +330 -0
- package/dist/cjs/transactions/marginPool.js.map +7 -0
- package/dist/cjs/transactions/marginRegistry.d.ts +94 -0
- package/dist/cjs/transactions/marginRegistry.js +221 -0
- package/dist/cjs/transactions/marginRegistry.js.map +7 -0
- package/dist/cjs/transactions/marginTPSL.d.ts +93 -0
- package/dist/cjs/transactions/marginTPSL.js +286 -0
- package/dist/cjs/transactions/marginTPSL.js.map +7 -0
- package/dist/cjs/transactions/poolProxy.d.ts +104 -0
- package/dist/cjs/transactions/poolProxy.js +435 -0
- package/dist/cjs/transactions/poolProxy.js.map +7 -0
- package/dist/cjs/types/bcs.d.ts +5 -0
- package/dist/cjs/types/bcs.js +33 -0
- package/dist/cjs/types/bcs.js.map +7 -0
- package/dist/cjs/types/index.d.ts +218 -0
- package/dist/cjs/types/index.js +38 -0
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/utils/config.d.ts +65 -0
- package/dist/cjs/utils/config.js +144 -0
- package/dist/cjs/utils/config.js.map +7 -0
- package/dist/cjs/utils/constants.d.ts +76 -0
- package/dist/cjs/utils/constants.js +382 -0
- package/dist/cjs/utils/constants.js.map +7 -0
- package/dist/cjs/utils/errors.d.ts +42 -0
- package/dist/cjs/utils/errors.js +70 -0
- package/dist/cjs/utils/errors.js.map +7 -0
- package/dist/cjs/utils/validation.d.ts +50 -0
- package/dist/cjs/utils/validation.js +67 -0
- package/dist/cjs/utils/validation.js.map +7 -0
- package/dist/esm/client.d.ts +861 -0
- package/dist/esm/client.js +1967 -0
- package/dist/esm/client.js.map +7 -0
- package/dist/esm/contracts/deepbook/account.d.ts +105 -0
- package/dist/esm/contracts/deepbook/account.js +133 -0
- package/dist/esm/contracts/deepbook/account.js.map +7 -0
- package/dist/esm/contracts/deepbook/balance_manager.d.ts +268 -0
- package/dist/esm/contracts/deepbook/balance_manager.js +331 -0
- package/dist/esm/contracts/deepbook/balance_manager.js.map +7 -0
- package/dist/esm/contracts/deepbook/balances.d.ts +10 -0
- package/dist/esm/contracts/deepbook/balances.js +15 -0
- package/dist/esm/contracts/deepbook/balances.js.map +7 -0
- package/dist/esm/contracts/deepbook/big_vector.d.ts +62 -0
- package/dist/esm/contracts/deepbook/big_vector.js +50 -0
- package/dist/esm/contracts/deepbook/big_vector.js.map +7 -0
- package/dist/esm/contracts/deepbook/book.d.ts +34 -0
- package/dist/esm/contracts/deepbook/book.js +20 -0
- package/dist/esm/contracts/deepbook/book.js.map +7 -0
- package/dist/esm/contracts/deepbook/constants.d.ts +176 -0
- package/dist/esm/contracts/deepbook/constants.js +318 -0
- package/dist/esm/contracts/deepbook/constants.js.map +7 -0
- package/dist/esm/contracts/deepbook/deep_price.d.ts +60 -0
- package/dist/esm/contracts/deepbook/deep_price.js +67 -0
- package/dist/esm/contracts/deepbook/deep_price.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/std/type_name.d.ts +14 -0
- package/dist/esm/contracts/deepbook/deps/std/type_name.js +22 -0
- package/dist/esm/contracts/deepbook/deps/std/type_name.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/bag.d.ts +33 -0
- package/dist/esm/contracts/deepbook/deps/sui/bag.js +17 -0
- package/dist/esm/contracts/deepbook/deps/sui/bag.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/balance.d.ts +9 -0
- package/dist/esm/contracts/deepbook/deps/sui/balance.js +13 -0
- package/dist/esm/contracts/deepbook/deps/sui/balance.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/object.d.ts +5 -0
- package/dist/esm/contracts/deepbook/deps/sui/object.js +13 -0
- package/dist/esm/contracts/deepbook/deps/sui/object.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/table.d.ts +28 -0
- package/dist/esm/contracts/deepbook/deps/sui/table.js +17 -0
- package/dist/esm/contracts/deepbook/deps/sui/table.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/vec_map.d.ts +27 -0
- package/dist/esm/contracts/deepbook/deps/sui/vec_map.js +25 -0
- package/dist/esm/contracts/deepbook/deps/sui/vec_map.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/vec_set.d.ts +15 -0
- package/dist/esm/contracts/deepbook/deps/sui/vec_set.js +15 -0
- package/dist/esm/contracts/deepbook/deps/sui/vec_set.js.map +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/versioned.d.ts +7 -0
- package/dist/esm/contracts/deepbook/deps/sui/versioned.js +15 -0
- package/dist/esm/contracts/deepbook/deps/sui/versioned.js.map +7 -0
- package/dist/esm/contracts/deepbook/ewma.d.ts +17 -0
- package/dist/esm/contracts/deepbook/ewma.js +19 -0
- package/dist/esm/contracts/deepbook/ewma.js.map +7 -0
- package/dist/esm/contracts/deepbook/fill.d.ts +153 -0
- package/dist/esm/contracts/deepbook/fill.js +221 -0
- package/dist/esm/contracts/deepbook/fill.js.map +7 -0
- package/dist/esm/contracts/deepbook/governance.d.ts +63 -0
- package/dist/esm/contracts/deepbook/governance.js +49 -0
- package/dist/esm/contracts/deepbook/governance.js.map +7 -0
- package/dist/esm/contracts/deepbook/history.d.ts +60 -0
- package/dist/esm/contracts/deepbook/history.js +48 -0
- package/dist/esm/contracts/deepbook/history.js.map +7 -0
- package/dist/esm/contracts/deepbook/math.d.ts +94 -0
- package/dist/esm/contracts/deepbook/math.js +112 -0
- package/dist/esm/contracts/deepbook/math.js.map +7 -0
- package/dist/esm/contracts/deepbook/order.d.ts +135 -0
- package/dist/esm/contracts/deepbook/order.js +188 -0
- package/dist/esm/contracts/deepbook/order.js.map +7 -0
- package/dist/esm/contracts/deepbook/order_info.d.ts +296 -0
- package/dist/esm/contracts/deepbook/order_info.js +356 -0
- package/dist/esm/contracts/deepbook/order_info.js.map +7 -0
- package/dist/esm/contracts/deepbook/order_query.d.ts +85 -0
- package/dist/esm/contracts/deepbook/order_query.js +66 -0
- package/dist/esm/contracts/deepbook/order_query.js.map +7 -0
- package/dist/esm/contracts/deepbook/pool.d.ts +1218 -0
- package/dist/esm/contracts/deepbook/pool.js +1206 -0
- package/dist/esm/contracts/deepbook/pool.js.map +7 -0
- package/dist/esm/contracts/deepbook/registry.d.ts +134 -0
- package/dist/esm/contracts/deepbook/registry.js +152 -0
- package/dist/esm/contracts/deepbook/registry.js.map +7 -0
- package/dist/esm/contracts/deepbook/state.d.ts +117 -0
- package/dist/esm/contracts/deepbook/state.js +74 -0
- package/dist/esm/contracts/deepbook/state.js.map +7 -0
- package/dist/esm/contracts/deepbook/trade_params.d.ts +7 -0
- package/dist/esm/contracts/deepbook/trade_params.js +15 -0
- package/dist/esm/contracts/deepbook/trade_params.js.map +7 -0
- package/dist/esm/contracts/deepbook/vault.d.ts +30 -0
- package/dist/esm/contracts/deepbook/vault.js +35 -0
- package/dist/esm/contracts/deepbook/vault.js.map +7 -0
- package/dist/esm/contracts/utils/index.d.ts +25 -0
- package/dist/esm/contracts/utils/index.js +128 -0
- package/dist/esm/contracts/utils/index.js.map +7 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/index.js +81 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/pyth/PriceServiceConnection.d.ts +26 -0
- package/dist/esm/pyth/PriceServiceConnection.js +38 -0
- package/dist/esm/pyth/PriceServiceConnection.js.map +7 -0
- package/dist/esm/pyth/pyth-helpers.d.ts +7 -0
- package/dist/esm/pyth/pyth-helpers.js +16 -0
- package/dist/esm/pyth/pyth-helpers.js.map +7 -0
- package/dist/esm/pyth/pyth.d.ts +65 -0
- package/dist/esm/pyth/pyth.js +249 -0
- package/dist/esm/pyth/pyth.js.map +7 -0
- package/dist/esm/transactions/balanceManager.d.ts +168 -0
- package/dist/esm/transactions/balanceManager.js +364 -0
- package/dist/esm/transactions/balanceManager.js.map +7 -0
- package/dist/esm/transactions/deepbook.d.ts +477 -0
- package/dist/esm/transactions/deepbook.js +1321 -0
- package/dist/esm/transactions/deepbook.js.map +7 -0
- package/dist/esm/transactions/deepbookAdmin.d.ts +105 -0
- package/dist/esm/transactions/deepbookAdmin.js +314 -0
- package/dist/esm/transactions/deepbookAdmin.js.map +7 -0
- package/dist/esm/transactions/flashLoans.d.ts +56 -0
- package/dist/esm/transactions/flashLoans.js +104 -0
- package/dist/esm/transactions/flashLoans.js.map +7 -0
- package/dist/esm/transactions/governance.d.ts +42 -0
- package/dist/esm/transactions/governance.js +115 -0
- package/dist/esm/transactions/governance.js.map +7 -0
- package/dist/esm/transactions/marginAdmin.d.ts +133 -0
- package/dist/esm/transactions/marginAdmin.js +373 -0
- package/dist/esm/transactions/marginAdmin.js.map +7 -0
- package/dist/esm/transactions/marginLiquidations.d.ts +61 -0
- package/dist/esm/transactions/marginLiquidations.js +153 -0
- package/dist/esm/transactions/marginLiquidations.js.map +7 -0
- package/dist/esm/transactions/marginMaintainer.d.ts +80 -0
- package/dist/esm/transactions/marginMaintainer.js +231 -0
- package/dist/esm/transactions/marginMaintainer.js.map +7 -0
- package/dist/esm/transactions/marginManager.d.ts +236 -0
- package/dist/esm/transactions/marginManager.js +668 -0
- package/dist/esm/transactions/marginManager.js.map +7 -0
- package/dist/esm/transactions/marginPool.d.ts +134 -0
- package/dist/esm/transactions/marginPool.js +310 -0
- package/dist/esm/transactions/marginPool.js.map +7 -0
- package/dist/esm/transactions/marginRegistry.d.ts +94 -0
- package/dist/esm/transactions/marginRegistry.js +201 -0
- package/dist/esm/transactions/marginRegistry.js.map +7 -0
- package/dist/esm/transactions/marginTPSL.d.ts +93 -0
- package/dist/esm/transactions/marginTPSL.js +266 -0
- package/dist/esm/transactions/marginTPSL.js.map +7 -0
- package/dist/esm/transactions/poolProxy.d.ts +104 -0
- package/dist/esm/transactions/poolProxy.js +415 -0
- package/dist/esm/transactions/poolProxy.js.map +7 -0
- package/dist/esm/types/bcs.d.ts +5 -0
- package/dist/esm/types/bcs.js +13 -0
- package/dist/esm/types/bcs.js.map +7 -0
- package/dist/esm/types/index.d.ts +218 -0
- package/dist/esm/types/index.js +18 -0
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/utils/config.d.ts +65 -0
- package/dist/esm/utils/config.js +135 -0
- package/dist/esm/utils/config.js.map +7 -0
- package/dist/esm/utils/constants.d.ts +76 -0
- package/dist/esm/utils/constants.js +362 -0
- package/dist/esm/utils/constants.js.map +7 -0
- package/dist/esm/utils/errors.d.ts +42 -0
- package/dist/esm/utils/errors.js +50 -0
- package/dist/esm/utils/errors.js.map +7 -0
- package/dist/esm/utils/validation.d.ts +50 -0
- package/dist/esm/utils/validation.js +47 -0
- package/dist/esm/utils/validation.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +63 -0
- package/src/client.ts +2451 -0
- package/src/contracts/deepbook/account.ts +199 -0
- package/src/contracts/deepbook/balance_manager.ts +532 -0
- package/src/contracts/deepbook/balances.ts +19 -0
- package/src/contracts/deepbook/big_vector.ts +74 -0
- package/src/contracts/deepbook/book.ts +24 -0
- package/src/contracts/deepbook/constants.ts +458 -0
- package/src/contracts/deepbook/deep_price.ts +84 -0
- package/src/contracts/deepbook/deps/std/type_name.ts +23 -0
- package/src/contracts/deepbook/deps/sui/bag.ts +41 -0
- package/src/contracts/deepbook/deps/sui/balance.ts +18 -0
- package/src/contracts/deepbook/deps/sui/object.ts +14 -0
- package/src/contracts/deepbook/deps/sui/table.ts +36 -0
- package/src/contracts/deepbook/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook/deps/sui/versioned.ts +13 -0
- package/src/contracts/deepbook/ewma.ts +26 -0
- package/src/contracts/deepbook/fill.ts +336 -0
- package/src/contracts/deepbook/governance.ts +52 -0
- package/src/contracts/deepbook/history.ts +51 -0
- package/src/contracts/deepbook/math.ts +210 -0
- package/src/contracts/deepbook/order.ts +269 -0
- package/src/contracts/deepbook/order_info.ts +513 -0
- package/src/contracts/deepbook/order_query.ts +115 -0
- package/src/contracts/deepbook/pool.ts +2269 -0
- package/src/contracts/deepbook/registry.ts +242 -0
- package/src/contracts/deepbook/state.ts +74 -0
- package/src/contracts/deepbook/trade_params.ts +16 -0
- package/src/contracts/deepbook/vault.ts +37 -0
- package/src/contracts/utils/index.ts +184 -0
- package/src/index.ts +95 -0
- package/src/pyth/PriceServiceConnection.ts +48 -0
- package/src/pyth/pyth-helpers.ts +23 -0
- package/src/pyth/pyth.ts +305 -0
- package/src/transactions/balanceManager.ts +399 -0
- package/src/transactions/deepbook.ts +1519 -0
- package/src/transactions/deepbookAdmin.ts +332 -0
- package/src/transactions/flashLoans.ts +123 -0
- package/src/transactions/governance.ts +123 -0
- package/src/transactions/marginAdmin.ts +396 -0
- package/src/transactions/marginLiquidations.ts +175 -0
- package/src/transactions/marginMaintainer.ts +280 -0
- package/src/transactions/marginManager.ts +708 -0
- package/src/transactions/marginPool.ts +339 -0
- package/src/transactions/marginRegistry.ts +212 -0
- package/src/transactions/marginTPSL.ts +296 -0
- package/src/transactions/poolProxy.ts +438 -0
- package/src/types/bcs.ts +8 -0
- package/src/types/index.ts +255 -0
- package/src/utils/config.ts +177 -0
- package/src/utils/constants.ts +374 -0
- package/src/utils/errors.ts +67 -0
- package/src/utils/validation.ts +91 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { coinWithBalance } from '@haneullabs/haneul/transactions';
|
|
4
|
+
import type { Transaction, TransactionObjectArgument } from '@haneullabs/haneul/transactions';
|
|
5
|
+
|
|
6
|
+
import type { DeepBookConfig } from '../utils/config.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* MarginPoolContract class for managing MarginPool operations.
|
|
10
|
+
*/
|
|
11
|
+
export class MarginPoolContract {
|
|
12
|
+
#config: DeepBookConfig;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {DeepBookConfig} config Configuration for MarginPoolContract
|
|
16
|
+
*/
|
|
17
|
+
constructor(config: DeepBookConfig) {
|
|
18
|
+
this.#config = config;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @description Mint a supplier cap for margin pool
|
|
23
|
+
* @returns A function that takes a Transaction object
|
|
24
|
+
*/
|
|
25
|
+
mintSupplierCap = () => (tx: Transaction) => {
|
|
26
|
+
return tx.moveCall({
|
|
27
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supplier_cap`,
|
|
28
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object.clock()],
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @description Supply to a margin pool
|
|
34
|
+
* @param {string} coinKey The key to identify the pool
|
|
35
|
+
* @param {TransactionObjectArgument} supplierCap The supplier cap object
|
|
36
|
+
* @param {number} amountToDeposit The amount to deposit
|
|
37
|
+
* @param {string} referralId The ID of the referral
|
|
38
|
+
* @returns A function that takes a Transaction object
|
|
39
|
+
*/
|
|
40
|
+
supplyToMarginPool =
|
|
41
|
+
(
|
|
42
|
+
coinKey: string,
|
|
43
|
+
supplierCap: TransactionObjectArgument,
|
|
44
|
+
amountToDeposit: number,
|
|
45
|
+
referralId?: string,
|
|
46
|
+
) =>
|
|
47
|
+
(tx: Transaction) => {
|
|
48
|
+
tx.setSenderIfNotSet(this.#config.address);
|
|
49
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
50
|
+
const coin = this.#config.getCoin(coinKey);
|
|
51
|
+
const depositInput = Math.round(amountToDeposit * coin.scalar);
|
|
52
|
+
const supply = coinWithBalance({
|
|
53
|
+
type: coin.type,
|
|
54
|
+
balance: depositInput,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
tx.moveCall({
|
|
58
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply`,
|
|
59
|
+
arguments: [
|
|
60
|
+
tx.object(marginPool.address),
|
|
61
|
+
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
62
|
+
supplierCap,
|
|
63
|
+
supply,
|
|
64
|
+
tx.object.option({
|
|
65
|
+
type: '0x2::object::ID',
|
|
66
|
+
value: referralId ? tx.pure.id(referralId) : null,
|
|
67
|
+
}),
|
|
68
|
+
tx.object.clock(),
|
|
69
|
+
],
|
|
70
|
+
typeArguments: [marginPool.type],
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @description Withdraw from a margin pool
|
|
76
|
+
* @param {string} coinKey The key to identify the pool
|
|
77
|
+
* @param {TransactionObjectArgument} supplierCap The supplier cap object
|
|
78
|
+
* @param {number} amountToWithdraw The amount to withdraw
|
|
79
|
+
* @returns A function that takes a Transaction object
|
|
80
|
+
*/
|
|
81
|
+
withdrawFromMarginPool =
|
|
82
|
+
(coinKey: string, supplierCap: TransactionObjectArgument, amountToWithdraw?: number) =>
|
|
83
|
+
(tx: Transaction) => {
|
|
84
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
85
|
+
const coin = this.#config.getCoin(coinKey);
|
|
86
|
+
const withdrawInput = amountToWithdraw
|
|
87
|
+
? tx.pure.u64(Math.round(amountToWithdraw * coin.scalar))
|
|
88
|
+
: null;
|
|
89
|
+
return tx.moveCall({
|
|
90
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw`,
|
|
91
|
+
arguments: [
|
|
92
|
+
tx.object(marginPool.address),
|
|
93
|
+
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
94
|
+
supplierCap,
|
|
95
|
+
tx.object.option({ type: 'u64', value: withdrawInput }),
|
|
96
|
+
tx.object.clock(),
|
|
97
|
+
],
|
|
98
|
+
typeArguments: [marginPool.type],
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @description Mint a referral for a margin pool
|
|
104
|
+
* @param {string} coinKey The key to identify the pool
|
|
105
|
+
* @returns A function that takes a Transaction object
|
|
106
|
+
*/
|
|
107
|
+
mintSupplyReferral = (coinKey: string) => (tx: Transaction) => {
|
|
108
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
109
|
+
tx.moveCall({
|
|
110
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::mint_supply_referral`,
|
|
111
|
+
arguments: [
|
|
112
|
+
tx.object(marginPool.address),
|
|
113
|
+
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
114
|
+
tx.object.clock(),
|
|
115
|
+
],
|
|
116
|
+
typeArguments: [marginPool.type],
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @description Withdraw referral fees from a margin pool
|
|
122
|
+
* @param {string} coinKey The key to identify the pool
|
|
123
|
+
* @param {string} referralId The ID of the referral
|
|
124
|
+
* @returns A function that takes a Transaction object
|
|
125
|
+
*/
|
|
126
|
+
withdrawReferralFees = (coinKey: string, referralId: string) => (tx: Transaction) => {
|
|
127
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
128
|
+
return tx.moveCall({
|
|
129
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::withdraw_referral_fees`,
|
|
130
|
+
arguments: [
|
|
131
|
+
tx.object(marginPool.address),
|
|
132
|
+
tx.object(this.#config.MARGIN_REGISTRY_ID),
|
|
133
|
+
tx.object(referralId),
|
|
134
|
+
],
|
|
135
|
+
typeArguments: [marginPool.type],
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// === Read-only/View Functions ===
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @description Get the margin pool ID
|
|
143
|
+
* @param {string} coinKey The key to identify the pool
|
|
144
|
+
* @returns A function that takes a Transaction object
|
|
145
|
+
*/
|
|
146
|
+
getId = (coinKey: string) => (tx: Transaction) => {
|
|
147
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
148
|
+
return tx.moveCall({
|
|
149
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::id`,
|
|
150
|
+
arguments: [tx.object(marginPool.address)],
|
|
151
|
+
typeArguments: [marginPool.type],
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @description Check if a deepbook pool is allowed for borrowing
|
|
157
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
158
|
+
* @param {string} deepbookPoolId The ID of the deepbook pool
|
|
159
|
+
* @returns A function that takes a Transaction object
|
|
160
|
+
*/
|
|
161
|
+
deepbookPoolAllowed = (coinKey: string, deepbookPoolId: string) => (tx: Transaction) => {
|
|
162
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
163
|
+
return tx.moveCall({
|
|
164
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::deepbook_pool_allowed`,
|
|
165
|
+
arguments: [tx.object(marginPool.address), tx.pure.id(deepbookPoolId)],
|
|
166
|
+
typeArguments: [marginPool.type],
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @description Get the total supply amount
|
|
172
|
+
* @param {string} coinKey The key to identify the pool
|
|
173
|
+
* @returns A function that takes a Transaction object
|
|
174
|
+
*/
|
|
175
|
+
totalSupply = (coinKey: string) => (tx: Transaction) => {
|
|
176
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
177
|
+
return tx.moveCall({
|
|
178
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_supply`,
|
|
179
|
+
arguments: [tx.object(marginPool.address)],
|
|
180
|
+
typeArguments: [marginPool.type],
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @description Get the total supply shares
|
|
186
|
+
* @param {string} coinKey The key to identify the pool
|
|
187
|
+
* @returns A function that takes a Transaction object
|
|
188
|
+
*/
|
|
189
|
+
supplyShares = (coinKey: string) => (tx: Transaction) => {
|
|
190
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
191
|
+
return tx.moveCall({
|
|
192
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_shares`,
|
|
193
|
+
arguments: [tx.object(marginPool.address)],
|
|
194
|
+
typeArguments: [marginPool.type],
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @description Get the total borrow amount
|
|
200
|
+
* @param {string} coinKey The key to identify the pool
|
|
201
|
+
* @returns A function that takes a Transaction object
|
|
202
|
+
*/
|
|
203
|
+
totalBorrow = (coinKey: string) => (tx: Transaction) => {
|
|
204
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
205
|
+
return tx.moveCall({
|
|
206
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::total_borrow`,
|
|
207
|
+
arguments: [tx.object(marginPool.address)],
|
|
208
|
+
typeArguments: [marginPool.type],
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @description Get the total borrow shares
|
|
214
|
+
* @param {string} coinKey The key to identify the pool
|
|
215
|
+
* @returns A function that takes a Transaction object
|
|
216
|
+
*/
|
|
217
|
+
borrowShares = (coinKey: string) => (tx: Transaction) => {
|
|
218
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
219
|
+
return tx.moveCall({
|
|
220
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::borrow_shares`,
|
|
221
|
+
arguments: [tx.object(marginPool.address)],
|
|
222
|
+
typeArguments: [marginPool.type],
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @description Get the last update timestamp
|
|
228
|
+
* @param {string} coinKey The key to identify the pool
|
|
229
|
+
* @returns A function that takes a Transaction object
|
|
230
|
+
*/
|
|
231
|
+
lastUpdateTimestamp = (coinKey: string) => (tx: Transaction) => {
|
|
232
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
233
|
+
return tx.moveCall({
|
|
234
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::last_update_timestamp`,
|
|
235
|
+
arguments: [tx.object(marginPool.address)],
|
|
236
|
+
typeArguments: [marginPool.type],
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @description Get the supply cap
|
|
242
|
+
* @param {string} coinKey The key to identify the pool
|
|
243
|
+
* @returns A function that takes a Transaction object
|
|
244
|
+
*/
|
|
245
|
+
supplyCap = (coinKey: string) => (tx: Transaction) => {
|
|
246
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
247
|
+
return tx.moveCall({
|
|
248
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::supply_cap`,
|
|
249
|
+
arguments: [tx.object(marginPool.address)],
|
|
250
|
+
typeArguments: [marginPool.type],
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @description Get the max utilization rate
|
|
256
|
+
* @param {string} coinKey The key to identify the pool
|
|
257
|
+
* @returns A function that takes a Transaction object
|
|
258
|
+
*/
|
|
259
|
+
maxUtilizationRate = (coinKey: string) => (tx: Transaction) => {
|
|
260
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
261
|
+
return tx.moveCall({
|
|
262
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::max_utilization_rate`,
|
|
263
|
+
arguments: [tx.object(marginPool.address)],
|
|
264
|
+
typeArguments: [marginPool.type],
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @description Get the protocol spread
|
|
270
|
+
* @param {string} coinKey The key to identify the pool
|
|
271
|
+
* @returns A function that takes a Transaction object
|
|
272
|
+
*/
|
|
273
|
+
protocolSpread = (coinKey: string) => (tx: Transaction) => {
|
|
274
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
275
|
+
return tx.moveCall({
|
|
276
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::protocol_spread`,
|
|
277
|
+
arguments: [tx.object(marginPool.address)],
|
|
278
|
+
typeArguments: [marginPool.type],
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @description Get the minimum borrow amount
|
|
284
|
+
* @param {string} coinKey The key to identify the pool
|
|
285
|
+
* @returns A function that takes a Transaction object
|
|
286
|
+
*/
|
|
287
|
+
minBorrow = (coinKey: string) => (tx: Transaction) => {
|
|
288
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
289
|
+
return tx.moveCall({
|
|
290
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::min_borrow`,
|
|
291
|
+
arguments: [tx.object(marginPool.address)],
|
|
292
|
+
typeArguments: [marginPool.type],
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @description Get the current interest rate
|
|
298
|
+
* @param {string} coinKey The key to identify the pool
|
|
299
|
+
* @returns A function that takes a Transaction object
|
|
300
|
+
*/
|
|
301
|
+
interestRate = (coinKey: string) => (tx: Transaction) => {
|
|
302
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
303
|
+
return tx.moveCall({
|
|
304
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::interest_rate`,
|
|
305
|
+
arguments: [tx.object(marginPool.address)],
|
|
306
|
+
typeArguments: [marginPool.type],
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @description Get user supply shares for a supplier cap
|
|
312
|
+
* @param {string} coinKey The key to identify the pool
|
|
313
|
+
* @param {string} supplierCapId The ID of the supplier cap
|
|
314
|
+
* @returns A function that takes a Transaction object
|
|
315
|
+
*/
|
|
316
|
+
userSupplyShares = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {
|
|
317
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
318
|
+
return tx.moveCall({
|
|
319
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_shares`,
|
|
320
|
+
arguments: [tx.object(marginPool.address), tx.pure.id(supplierCapId)],
|
|
321
|
+
typeArguments: [marginPool.type],
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @description Get user supply amount for a supplier cap
|
|
327
|
+
* @param {string} coinKey The key to identify the pool
|
|
328
|
+
* @param {string} supplierCapId The ID of the supplier cap
|
|
329
|
+
* @returns A function that takes a Transaction object
|
|
330
|
+
*/
|
|
331
|
+
userSupplyAmount = (coinKey: string, supplierCapId: string) => (tx: Transaction) => {
|
|
332
|
+
const marginPool = this.#config.getMarginPool(coinKey);
|
|
333
|
+
return tx.moveCall({
|
|
334
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::user_supply_amount`,
|
|
335
|
+
arguments: [tx.object(marginPool.address), tx.pure.id(supplierCapId), tx.object.clock()],
|
|
336
|
+
typeArguments: [marginPool.type],
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import type { Transaction } from '@haneullabs/haneul/transactions';
|
|
4
|
+
|
|
5
|
+
import type { DeepBookConfig } from '../utils/config.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* MarginRegistryContract class for managing MarginRegistry read-only operations.
|
|
9
|
+
*/
|
|
10
|
+
export class MarginRegistryContract {
|
|
11
|
+
#config: DeepBookConfig;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {DeepBookConfig} config Configuration for MarginRegistryContract
|
|
15
|
+
*/
|
|
16
|
+
constructor(config: DeepBookConfig) {
|
|
17
|
+
this.#config = config;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @description Check if a deepbook pool is enabled for margin trading
|
|
22
|
+
* @param {string} poolKey The key to identify the pool
|
|
23
|
+
* @returns A function that takes a Transaction object
|
|
24
|
+
*/
|
|
25
|
+
poolEnabled = (poolKey: string) => (tx: Transaction) => {
|
|
26
|
+
const pool = this.#config.getPool(poolKey);
|
|
27
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
28
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
29
|
+
return tx.moveCall({
|
|
30
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::pool_enabled`,
|
|
31
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.object(pool.address)],
|
|
32
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @description Get the margin pool ID for a given asset
|
|
38
|
+
* @param {string} coinKey The key to identify the coin
|
|
39
|
+
* @returns A function that takes a Transaction object
|
|
40
|
+
*/
|
|
41
|
+
getMarginPoolId = (coinKey: string) => (tx: Transaction) => {
|
|
42
|
+
const coin = this.#config.getCoin(coinKey);
|
|
43
|
+
return tx.moveCall({
|
|
44
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::get_margin_pool_id`,
|
|
45
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID)],
|
|
46
|
+
typeArguments: [coin.type],
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @description Get the margin pool IDs (base and quote) for a deepbook pool
|
|
52
|
+
* @param {string} poolKey The key to identify the pool
|
|
53
|
+
* @returns A function that takes a Transaction object
|
|
54
|
+
*/
|
|
55
|
+
getDeepbookPoolMarginPoolIds = (poolKey: string) => (tx: Transaction) => {
|
|
56
|
+
const pool = this.#config.getPool(poolKey);
|
|
57
|
+
return tx.moveCall({
|
|
58
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::get_deepbook_pool_margin_pool_ids`,
|
|
59
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
60
|
+
typeArguments: [],
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @description Get the margin manager IDs for a given owner
|
|
66
|
+
* @param {string} owner The owner address
|
|
67
|
+
* @returns A function that takes a Transaction object
|
|
68
|
+
*/
|
|
69
|
+
getMarginManagerIds = (owner: string) => (tx: Transaction) => {
|
|
70
|
+
return tx.moveCall({
|
|
71
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::get_margin_manager_ids`,
|
|
72
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.address(owner)],
|
|
73
|
+
typeArguments: [],
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @description Get the base margin pool ID for a deepbook pool
|
|
79
|
+
* @param {string} poolKey The key to identify the pool
|
|
80
|
+
* @returns A function that takes a Transaction object
|
|
81
|
+
*/
|
|
82
|
+
baseMarginPoolId = (poolKey: string) => (tx: Transaction) => {
|
|
83
|
+
const pool = this.#config.getPool(poolKey);
|
|
84
|
+
return tx.moveCall({
|
|
85
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::base_margin_pool_id`,
|
|
86
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
87
|
+
typeArguments: [],
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @description Get the quote margin pool ID for a deepbook pool
|
|
93
|
+
* @param {string} poolKey The key to identify the pool
|
|
94
|
+
* @returns A function that takes a Transaction object
|
|
95
|
+
*/
|
|
96
|
+
quoteMarginPoolId = (poolKey: string) => (tx: Transaction) => {
|
|
97
|
+
const pool = this.#config.getPool(poolKey);
|
|
98
|
+
return tx.moveCall({
|
|
99
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::quote_margin_pool_id`,
|
|
100
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
101
|
+
typeArguments: [],
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @description Get the minimum withdraw risk ratio for a deepbook pool
|
|
107
|
+
* @param {string} poolKey The key to identify the pool
|
|
108
|
+
* @returns A function that takes a Transaction object
|
|
109
|
+
*/
|
|
110
|
+
minWithdrawRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
111
|
+
const pool = this.#config.getPool(poolKey);
|
|
112
|
+
return tx.moveCall({
|
|
113
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::min_withdraw_risk_ratio`,
|
|
114
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
115
|
+
typeArguments: [],
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @description Get the minimum borrow risk ratio for a deepbook pool
|
|
121
|
+
* @param {string} poolKey The key to identify the pool
|
|
122
|
+
* @returns A function that takes a Transaction object
|
|
123
|
+
*/
|
|
124
|
+
minBorrowRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
125
|
+
const pool = this.#config.getPool(poolKey);
|
|
126
|
+
return tx.moveCall({
|
|
127
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::min_borrow_risk_ratio`,
|
|
128
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
129
|
+
typeArguments: [],
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @description Get the liquidation risk ratio for a deepbook pool
|
|
135
|
+
* @param {string} poolKey The key to identify the pool
|
|
136
|
+
* @returns A function that takes a Transaction object
|
|
137
|
+
*/
|
|
138
|
+
liquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
139
|
+
const pool = this.#config.getPool(poolKey);
|
|
140
|
+
return tx.moveCall({
|
|
141
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::liquidation_risk_ratio`,
|
|
142
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
143
|
+
typeArguments: [],
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @description Get the target liquidation risk ratio for a deepbook pool
|
|
149
|
+
* @param {string} poolKey The key to identify the pool
|
|
150
|
+
* @returns A function that takes a Transaction object
|
|
151
|
+
*/
|
|
152
|
+
targetLiquidationRiskRatio = (poolKey: string) => (tx: Transaction) => {
|
|
153
|
+
const pool = this.#config.getPool(poolKey);
|
|
154
|
+
return tx.moveCall({
|
|
155
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::target_liquidation_risk_ratio`,
|
|
156
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
157
|
+
typeArguments: [],
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @description Get the user liquidation reward for a deepbook pool
|
|
163
|
+
* @param {string} poolKey The key to identify the pool
|
|
164
|
+
* @returns A function that takes a Transaction object
|
|
165
|
+
*/
|
|
166
|
+
userLiquidationReward = (poolKey: string) => (tx: Transaction) => {
|
|
167
|
+
const pool = this.#config.getPool(poolKey);
|
|
168
|
+
return tx.moveCall({
|
|
169
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::user_liquidation_reward`,
|
|
170
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
171
|
+
typeArguments: [],
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @description Get the pool liquidation reward for a deepbook pool
|
|
177
|
+
* @param {string} poolKey The key to identify the pool
|
|
178
|
+
* @returns A function that takes a Transaction object
|
|
179
|
+
*/
|
|
180
|
+
poolLiquidationReward = (poolKey: string) => (tx: Transaction) => {
|
|
181
|
+
const pool = this.#config.getPool(poolKey);
|
|
182
|
+
return tx.moveCall({
|
|
183
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::pool_liquidation_reward`,
|
|
184
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID), tx.pure.id(pool.address)],
|
|
185
|
+
typeArguments: [],
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @description Get all allowed maintainer cap IDs
|
|
191
|
+
* @returns A function that takes a Transaction object
|
|
192
|
+
*/
|
|
193
|
+
allowedMaintainers = () => (tx: Transaction) => {
|
|
194
|
+
return tx.moveCall({
|
|
195
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::allowed_maintainers`,
|
|
196
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID)],
|
|
197
|
+
typeArguments: [],
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @description Get all allowed pause cap IDs
|
|
203
|
+
* @returns A function that takes a Transaction object
|
|
204
|
+
*/
|
|
205
|
+
allowedPauseCaps = () => (tx: Transaction) => {
|
|
206
|
+
return tx.moveCall({
|
|
207
|
+
target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::allowed_pause_caps`,
|
|
208
|
+
arguments: [tx.object(this.#config.MARGIN_REGISTRY_ID)],
|
|
209
|
+
typeArguments: [],
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
}
|