@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,668 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
var _config;
|
|
9
|
+
import { coinWithBalance } from "@haneullabs/haneul/transactions";
|
|
10
|
+
class MarginManagerContract {
|
|
11
|
+
/**
|
|
12
|
+
* @param {DeepBookConfig} config Configuration for MarginManagerContract
|
|
13
|
+
*/
|
|
14
|
+
constructor(config) {
|
|
15
|
+
__privateAdd(this, _config);
|
|
16
|
+
/**
|
|
17
|
+
* @description Create a new margin manager
|
|
18
|
+
* @param {string} poolKey The key to identify the pool
|
|
19
|
+
* @returns A function that takes a Transaction object
|
|
20
|
+
*/
|
|
21
|
+
this.newMarginManager = (poolKey) => (tx) => {
|
|
22
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
23
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
24
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
25
|
+
tx.moveCall({
|
|
26
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::new`,
|
|
27
|
+
arguments: [
|
|
28
|
+
tx.object(pool.address),
|
|
29
|
+
tx.object(__privateGet(this, _config).REGISTRY_ID),
|
|
30
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
31
|
+
tx.object.clock()
|
|
32
|
+
],
|
|
33
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @description Create a new margin manager with an initializer
|
|
38
|
+
* @param {string} poolKey The key to identify the pool
|
|
39
|
+
* @returns A function that takes a Transaction object
|
|
40
|
+
*/
|
|
41
|
+
this.newMarginManagerWithInitializer = (poolKey) => (tx) => {
|
|
42
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
43
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
44
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
45
|
+
const [manager, initializer] = tx.moveCall({
|
|
46
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::new_with_initializer`,
|
|
47
|
+
arguments: [
|
|
48
|
+
tx.object(pool.address),
|
|
49
|
+
tx.object(__privateGet(this, _config).REGISTRY_ID),
|
|
50
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
51
|
+
tx.object.clock()
|
|
52
|
+
],
|
|
53
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
54
|
+
});
|
|
55
|
+
return { manager, initializer };
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @description Share a margin manager
|
|
59
|
+
* @param {string} poolKey The key to identify the pool
|
|
60
|
+
* @param {TransactionArgument} manager The margin manager to share
|
|
61
|
+
* @param {TransactionArgument} initializer The initializer for the manager
|
|
62
|
+
* @returns A function that takes a Transaction object
|
|
63
|
+
*/
|
|
64
|
+
this.shareMarginManager = (poolKey, manager, initializer) => (tx) => {
|
|
65
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
66
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
67
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
68
|
+
tx.moveCall({
|
|
69
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::share`,
|
|
70
|
+
arguments: [manager, initializer],
|
|
71
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* @description Deposit base into a margin manager
|
|
76
|
+
* @param {string} managerKey The key to identify the manager
|
|
77
|
+
* @param {number} amount The amount to deposit
|
|
78
|
+
* @returns A function that takes a Transaction object
|
|
79
|
+
*/
|
|
80
|
+
this.depositBase = (managerKey, amount) => (tx) => {
|
|
81
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
82
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
83
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
84
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
85
|
+
const coin = coinWithBalance({
|
|
86
|
+
type: baseCoin.type,
|
|
87
|
+
balance: amount * baseCoin.scalar
|
|
88
|
+
});
|
|
89
|
+
tx.moveCall({
|
|
90
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::deposit`,
|
|
91
|
+
arguments: [
|
|
92
|
+
tx.object(manager.address),
|
|
93
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
94
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
95
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
96
|
+
coin,
|
|
97
|
+
tx.object.clock()
|
|
98
|
+
],
|
|
99
|
+
typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type]
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* @description Deposit quote into a margin manager
|
|
104
|
+
* @param {string} managerKey The key to identify the manager
|
|
105
|
+
* @param {number} amount The amount to deposit
|
|
106
|
+
* @returns A function that takes a Transaction object
|
|
107
|
+
*/
|
|
108
|
+
this.depositQuote = (managerKey, amount) => (tx) => {
|
|
109
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
110
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
111
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
112
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
113
|
+
const coin = coinWithBalance({
|
|
114
|
+
type: quoteCoin.type,
|
|
115
|
+
balance: amount * quoteCoin.scalar
|
|
116
|
+
});
|
|
117
|
+
tx.moveCall({
|
|
118
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::deposit`,
|
|
119
|
+
arguments: [
|
|
120
|
+
tx.object(manager.address),
|
|
121
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
122
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
123
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
124
|
+
coin,
|
|
125
|
+
tx.object.clock()
|
|
126
|
+
],
|
|
127
|
+
typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type]
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* @description Deposit deep into a margin manager
|
|
132
|
+
* @param {string} managerKey The key to identify the manager
|
|
133
|
+
* @param {number} amount The amount to deposit
|
|
134
|
+
* @returns A function that takes a Transaction object
|
|
135
|
+
*/
|
|
136
|
+
this.depositDeep = (managerKey, amount) => (tx) => {
|
|
137
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
138
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
139
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
140
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
141
|
+
const deepCoin = __privateGet(this, _config).getCoin("DEEP");
|
|
142
|
+
const coin = coinWithBalance({
|
|
143
|
+
type: deepCoin.type,
|
|
144
|
+
balance: amount * deepCoin.scalar
|
|
145
|
+
});
|
|
146
|
+
tx.moveCall({
|
|
147
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::deposit`,
|
|
148
|
+
arguments: [
|
|
149
|
+
tx.object(manager.address),
|
|
150
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
151
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
152
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
153
|
+
coin,
|
|
154
|
+
tx.object.clock()
|
|
155
|
+
],
|
|
156
|
+
typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type]
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* @description Withdraw base from a margin manager
|
|
161
|
+
* @param {string} managerKey The key to identify the manager
|
|
162
|
+
* @param {number} amount The amount to withdraw
|
|
163
|
+
* @returns A function that takes a Transaction object
|
|
164
|
+
*/
|
|
165
|
+
this.withdrawBase = (managerKey, amount) => (tx) => {
|
|
166
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
167
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
168
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
169
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
170
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
171
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
172
|
+
return tx.moveCall({
|
|
173
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::withdraw`,
|
|
174
|
+
arguments: [
|
|
175
|
+
tx.object(manager.address),
|
|
176
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
177
|
+
tx.object(baseMarginPool.address),
|
|
178
|
+
tx.object(quoteMarginPool.address),
|
|
179
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
180
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
181
|
+
tx.object(pool.address),
|
|
182
|
+
tx.pure.u64(amount * baseCoin.scalar),
|
|
183
|
+
tx.object.clock()
|
|
184
|
+
],
|
|
185
|
+
typeArguments: [baseCoin.type, quoteCoin.type, baseCoin.type]
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* @description Withdraw quote from a margin manager
|
|
190
|
+
* @param {string} managerKey The key to identify the manager
|
|
191
|
+
* @param {number} amount The amount to withdraw
|
|
192
|
+
* @returns A function that takes a Transaction object
|
|
193
|
+
*/
|
|
194
|
+
this.withdrawQuote = (managerKey, amount) => (tx) => {
|
|
195
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
196
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
197
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
198
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
199
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
200
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
201
|
+
return tx.moveCall({
|
|
202
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::withdraw`,
|
|
203
|
+
arguments: [
|
|
204
|
+
tx.object(manager.address),
|
|
205
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
206
|
+
tx.object(baseMarginPool.address),
|
|
207
|
+
tx.object(quoteMarginPool.address),
|
|
208
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
209
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
210
|
+
tx.object(pool.address),
|
|
211
|
+
tx.pure.u64(amount * quoteCoin.scalar),
|
|
212
|
+
tx.object.clock()
|
|
213
|
+
],
|
|
214
|
+
typeArguments: [baseCoin.type, quoteCoin.type, quoteCoin.type]
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* @description Withdraw deep from a margin manager
|
|
219
|
+
* @param {string} managerKey The key to identify the manager
|
|
220
|
+
* @param {number} amount The amount to withdraw
|
|
221
|
+
* @returns A function that takes a Transaction object
|
|
222
|
+
*/
|
|
223
|
+
this.withdrawDeep = (managerKey, amount) => (tx) => {
|
|
224
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
225
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
226
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
227
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
228
|
+
const deepCoin = __privateGet(this, _config).getCoin("DEEP");
|
|
229
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
230
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
231
|
+
return tx.moveCall({
|
|
232
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::withdraw`,
|
|
233
|
+
arguments: [
|
|
234
|
+
tx.object(manager.address),
|
|
235
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
236
|
+
tx.object(baseMarginPool.address),
|
|
237
|
+
tx.object(quoteMarginPool.address),
|
|
238
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
239
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
240
|
+
tx.object(pool.address),
|
|
241
|
+
tx.pure.u64(amount * deepCoin.scalar),
|
|
242
|
+
tx.object.clock()
|
|
243
|
+
],
|
|
244
|
+
typeArguments: [baseCoin.type, quoteCoin.type, deepCoin.type]
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* @description Borrow base from a margin manager
|
|
249
|
+
* @param {string} managerKey The key to identify the manager
|
|
250
|
+
* @param {number} amount The amount to borrow
|
|
251
|
+
* @returns A function that takes a Transaction object
|
|
252
|
+
*/
|
|
253
|
+
this.borrowBase = (managerKey, amount) => (tx) => {
|
|
254
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
255
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
256
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
257
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
258
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
259
|
+
return tx.moveCall({
|
|
260
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::borrow_base`,
|
|
261
|
+
arguments: [
|
|
262
|
+
tx.object(manager.address),
|
|
263
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
264
|
+
tx.object(baseMarginPool.address),
|
|
265
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
266
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
267
|
+
tx.object(pool.address),
|
|
268
|
+
tx.pure.u64(amount * baseCoin.scalar),
|
|
269
|
+
tx.object.clock()
|
|
270
|
+
],
|
|
271
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* @description Borrow quote from a margin manager
|
|
276
|
+
* @param {string} managerKey The key to identify the manager
|
|
277
|
+
* @param {number} amount The amount to borrow
|
|
278
|
+
* @returns A function that takes a Transaction object
|
|
279
|
+
*/
|
|
280
|
+
this.borrowQuote = (managerKey, amount) => (tx) => {
|
|
281
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
282
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
283
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
284
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
285
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
286
|
+
return tx.moveCall({
|
|
287
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::borrow_quote`,
|
|
288
|
+
arguments: [
|
|
289
|
+
tx.object(manager.address),
|
|
290
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
291
|
+
tx.object(quoteMarginPool.address),
|
|
292
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
293
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
294
|
+
tx.object(pool.address),
|
|
295
|
+
tx.pure.u64(amount * quoteCoin.scalar),
|
|
296
|
+
tx.object.clock()
|
|
297
|
+
],
|
|
298
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* @description Repay base from a margin manager
|
|
303
|
+
* @param {string} managerKey The key to identify the manager
|
|
304
|
+
* @param {number} amount The amount to repay
|
|
305
|
+
* @returns A function that takes a Transaction object
|
|
306
|
+
*/
|
|
307
|
+
this.repayBase = (managerKey, amount) => (tx) => {
|
|
308
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
309
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
310
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
311
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
312
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
313
|
+
return tx.moveCall({
|
|
314
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::repay_base`,
|
|
315
|
+
arguments: [
|
|
316
|
+
tx.object(manager.address),
|
|
317
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
318
|
+
tx.object(baseMarginPool.address),
|
|
319
|
+
tx.object.option({
|
|
320
|
+
type: "u64",
|
|
321
|
+
value: amount ? tx.pure.u64(amount * baseCoin.scalar) : null
|
|
322
|
+
}),
|
|
323
|
+
tx.object.clock()
|
|
324
|
+
],
|
|
325
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* @description Repay quote from a margin manager
|
|
330
|
+
* @param {string} managerKey The key to identify the manager
|
|
331
|
+
* @param {number} amount The amount to repay
|
|
332
|
+
* @returns A function that takes a Transaction object
|
|
333
|
+
*/
|
|
334
|
+
this.repayQuote = (managerKey, amount) => (tx) => {
|
|
335
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
336
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
337
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
338
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
339
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
340
|
+
return tx.moveCall({
|
|
341
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::repay_quote`,
|
|
342
|
+
arguments: [
|
|
343
|
+
tx.object(manager.address),
|
|
344
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
345
|
+
tx.object(quoteMarginPool.address),
|
|
346
|
+
tx.object.option({
|
|
347
|
+
type: "u64",
|
|
348
|
+
value: amount ? tx.pure.u64(amount * quoteCoin.scalar) : null
|
|
349
|
+
}),
|
|
350
|
+
tx.object.clock()
|
|
351
|
+
],
|
|
352
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* @description Liquidate a margin manager
|
|
357
|
+
* @param {string} managerAddress The address of the manager to liquidate
|
|
358
|
+
* @param {string} poolKey The key to identify the pool
|
|
359
|
+
* @param {boolean} debtIsBase Whether the debt is in base
|
|
360
|
+
* @param {TransactionArgument} repayCoin The coin to repay
|
|
361
|
+
* @returns A function that takes a Transaction object
|
|
362
|
+
*/
|
|
363
|
+
this.liquidate = (managerAddress, poolKey, debtIsBase, repayCoin) => (tx) => {
|
|
364
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
365
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
366
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
367
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
368
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
369
|
+
const marginPool = debtIsBase ? baseMarginPool : quoteMarginPool;
|
|
370
|
+
return tx.moveCall({
|
|
371
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::liquidate`,
|
|
372
|
+
arguments: [
|
|
373
|
+
tx.object(managerAddress),
|
|
374
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
375
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
376
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
377
|
+
tx.object(marginPool.address),
|
|
378
|
+
tx.object(pool.address),
|
|
379
|
+
repayCoin,
|
|
380
|
+
tx.object.clock()
|
|
381
|
+
],
|
|
382
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* @description Set the referral for a margin manager (DeepBookPoolReferral)
|
|
387
|
+
* @param {string} managerKey The key to identify the margin manager
|
|
388
|
+
* @param {string} referral The referral (DeepBookPoolReferral) to set
|
|
389
|
+
* @returns A function that takes a Transaction object
|
|
390
|
+
*/
|
|
391
|
+
this.setMarginManagerReferral = (managerKey, referral) => (tx) => {
|
|
392
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
393
|
+
const pool = __privateGet(this, _config).getPool(manager.poolKey);
|
|
394
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
395
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
396
|
+
tx.moveCall({
|
|
397
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::set_margin_manager_referral`,
|
|
398
|
+
arguments: [tx.object(manager.address), tx.object(referral)],
|
|
399
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* @description Unset the referral for a margin manager
|
|
404
|
+
* @param {string} managerKey The key to identify the margin manager
|
|
405
|
+
* @param {string} poolKey The key of the pool to unset the referral for
|
|
406
|
+
* @returns A function that takes a Transaction object
|
|
407
|
+
*/
|
|
408
|
+
this.unsetMarginManagerReferral = (managerKey, poolKey) => (tx) => {
|
|
409
|
+
const manager = __privateGet(this, _config).getMarginManager(managerKey);
|
|
410
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
411
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
412
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
413
|
+
tx.moveCall({
|
|
414
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::unset_margin_manager_referral`,
|
|
415
|
+
arguments: [tx.object(manager.address), tx.pure.id(pool.address)],
|
|
416
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
// === Read-Only Functions ===
|
|
420
|
+
/**
|
|
421
|
+
* @description Get the owner address of a margin manager
|
|
422
|
+
* @param {string} poolKey The key to identify the pool
|
|
423
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
424
|
+
* @returns A function that takes a Transaction object
|
|
425
|
+
*/
|
|
426
|
+
this.ownerByPoolKey = (poolKey, marginManagerId) => (tx) => {
|
|
427
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
428
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
429
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
430
|
+
return tx.moveCall({
|
|
431
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::owner`,
|
|
432
|
+
arguments: [tx.object(marginManagerId)],
|
|
433
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* @description Get the DeepBook pool ID associated with a margin manager
|
|
438
|
+
* @param {string} poolKey The key to identify the pool
|
|
439
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
440
|
+
* @returns A function that takes a Transaction object
|
|
441
|
+
*/
|
|
442
|
+
this.deepbookPool = (poolKey, marginManagerId) => (tx) => {
|
|
443
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
444
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
445
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
446
|
+
return tx.moveCall({
|
|
447
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::deepbook_pool`,
|
|
448
|
+
arguments: [tx.object(marginManagerId)],
|
|
449
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* @description Get the margin pool ID (if any) associated with a margin manager
|
|
454
|
+
* @param {string} poolKey The key to identify the pool
|
|
455
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
456
|
+
* @returns A function that takes a Transaction object
|
|
457
|
+
*/
|
|
458
|
+
this.marginPoolId = (poolKey, marginManagerId) => (tx) => {
|
|
459
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
460
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
461
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
462
|
+
return tx.moveCall({
|
|
463
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::margin_pool_id`,
|
|
464
|
+
arguments: [tx.object(marginManagerId)],
|
|
465
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
466
|
+
});
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* @description Get borrowed shares for both base and quote assets
|
|
470
|
+
* @param {string} poolKey The key to identify the pool
|
|
471
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
472
|
+
* @returns A function that takes a Transaction object
|
|
473
|
+
*/
|
|
474
|
+
this.borrowedShares = (poolKey, marginManagerId) => (tx) => {
|
|
475
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
476
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
477
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
478
|
+
return tx.moveCall({
|
|
479
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::borrowed_shares`,
|
|
480
|
+
arguments: [tx.object(marginManagerId)],
|
|
481
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* @description Get borrowed base shares
|
|
486
|
+
* @param {string} poolKey The key to identify the pool
|
|
487
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
488
|
+
* @returns A function that takes a Transaction object
|
|
489
|
+
*/
|
|
490
|
+
this.borrowedBaseShares = (poolKey, marginManagerId) => (tx) => {
|
|
491
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
492
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
493
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
494
|
+
return tx.moveCall({
|
|
495
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::borrowed_base_shares`,
|
|
496
|
+
arguments: [tx.object(marginManagerId)],
|
|
497
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* @description Get borrowed quote shares
|
|
502
|
+
* @param {string} poolKey The key to identify the pool
|
|
503
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
504
|
+
* @returns A function that takes a Transaction object
|
|
505
|
+
*/
|
|
506
|
+
this.borrowedQuoteShares = (poolKey, marginManagerId) => (tx) => {
|
|
507
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
508
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
509
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
510
|
+
return tx.moveCall({
|
|
511
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::borrowed_quote_shares`,
|
|
512
|
+
arguments: [tx.object(marginManagerId)],
|
|
513
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
514
|
+
});
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* @description Check if margin manager has base asset debt
|
|
518
|
+
* @param {string} poolKey The key to identify the pool
|
|
519
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
520
|
+
* @returns A function that takes a Transaction object
|
|
521
|
+
*/
|
|
522
|
+
this.hasBaseDebt = (poolKey, marginManagerId) => (tx) => {
|
|
523
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
524
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
525
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
526
|
+
return tx.moveCall({
|
|
527
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::has_base_debt`,
|
|
528
|
+
arguments: [tx.object(marginManagerId)],
|
|
529
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* @description Get the balance manager ID for a margin manager
|
|
534
|
+
* @param {string} poolKey The key to identify the pool
|
|
535
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
536
|
+
* @returns A function that takes a Transaction object
|
|
537
|
+
*/
|
|
538
|
+
this.balanceManager = (poolKey, marginManagerId) => (tx) => {
|
|
539
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
540
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
541
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
542
|
+
return tx.moveCall({
|
|
543
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::balance_manager`,
|
|
544
|
+
arguments: [tx.object(marginManagerId)],
|
|
545
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* @description Calculate assets (base and quote) for a margin manager
|
|
550
|
+
* @param {string} poolKey The key to identify the pool
|
|
551
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
552
|
+
* @returns A function that takes a Transaction object
|
|
553
|
+
*/
|
|
554
|
+
this.calculateAssets = (poolKey, marginManagerId) => (tx) => {
|
|
555
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
556
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
557
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
558
|
+
return tx.moveCall({
|
|
559
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::calculate_assets`,
|
|
560
|
+
arguments: [tx.object(marginManagerId), tx.object(pool.address)],
|
|
561
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
/**
|
|
565
|
+
* @description Calculate debts (base and quote) for a margin manager
|
|
566
|
+
* @param {string} poolKey The key to identify the pool
|
|
567
|
+
* @param {string} coinKey The key to identify the debt coin (base or quote)
|
|
568
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
569
|
+
* @returns A function that takes a Transaction object
|
|
570
|
+
*/
|
|
571
|
+
this.calculateDebts = (poolKey, coinKey, marginManagerId) => (tx) => {
|
|
572
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
573
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
574
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
575
|
+
const debtCoin = __privateGet(this, _config).getCoin(coinKey);
|
|
576
|
+
const marginPool = __privateGet(this, _config).getMarginPool(coinKey);
|
|
577
|
+
return tx.moveCall({
|
|
578
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::calculate_debts`,
|
|
579
|
+
arguments: [tx.object(marginManagerId), tx.object(marginPool.address), tx.object.clock()],
|
|
580
|
+
typeArguments: [baseCoin.type, quoteCoin.type, debtCoin.type]
|
|
581
|
+
});
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* @description Get comprehensive state information for a margin manager
|
|
585
|
+
* @param {string} poolKey The key to identify the pool
|
|
586
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
587
|
+
* @returns A function that takes a Transaction object
|
|
588
|
+
* @returns Returns (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset,
|
|
589
|
+
* base_debt, quote_debt, base_pyth_price, base_pyth_decimals,
|
|
590
|
+
* quote_pyth_price, quote_pyth_decimals)
|
|
591
|
+
*/
|
|
592
|
+
this.managerState = (poolKey, marginManagerId) => (tx) => {
|
|
593
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
594
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
595
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
596
|
+
const baseMarginPool = __privateGet(this, _config).getMarginPool(pool.baseCoin);
|
|
597
|
+
const quoteMarginPool = __privateGet(this, _config).getMarginPool(pool.quoteCoin);
|
|
598
|
+
return tx.moveCall({
|
|
599
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::manager_state`,
|
|
600
|
+
arguments: [
|
|
601
|
+
tx.object(marginManagerId),
|
|
602
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
603
|
+
tx.object(baseCoin.priceInfoObjectId),
|
|
604
|
+
tx.object(quoteCoin.priceInfoObjectId),
|
|
605
|
+
tx.object(pool.address),
|
|
606
|
+
tx.object(baseMarginPool.address),
|
|
607
|
+
tx.object(quoteMarginPool.address),
|
|
608
|
+
tx.object.clock()
|
|
609
|
+
],
|
|
610
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* @description Get the base asset balance of a margin manager
|
|
615
|
+
* @param {string} poolKey The key to identify the pool
|
|
616
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
617
|
+
* @returns A function that takes a Transaction object
|
|
618
|
+
*/
|
|
619
|
+
this.baseBalance = (poolKey, marginManagerId) => (tx) => {
|
|
620
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
621
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
622
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
623
|
+
return tx.moveCall({
|
|
624
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::base_balance`,
|
|
625
|
+
arguments: [tx.object(marginManagerId)],
|
|
626
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* @description Get the quote asset balance of a margin manager
|
|
631
|
+
* @param {string} poolKey The key to identify the pool
|
|
632
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
633
|
+
* @returns A function that takes a Transaction object
|
|
634
|
+
*/
|
|
635
|
+
this.quoteBalance = (poolKey, marginManagerId) => (tx) => {
|
|
636
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
637
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
638
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
639
|
+
return tx.moveCall({
|
|
640
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::quote_balance`,
|
|
641
|
+
arguments: [tx.object(marginManagerId)],
|
|
642
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* @description Get the DEEP token balance of a margin manager
|
|
647
|
+
* @param {string} poolKey The key to identify the pool
|
|
648
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
649
|
+
* @returns A function that takes a Transaction object
|
|
650
|
+
*/
|
|
651
|
+
this.deepBalance = (poolKey, marginManagerId) => (tx) => {
|
|
652
|
+
const pool = __privateGet(this, _config).getPool(poolKey);
|
|
653
|
+
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
|
|
654
|
+
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
|
|
655
|
+
return tx.moveCall({
|
|
656
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_manager::deep_balance`,
|
|
657
|
+
arguments: [tx.object(marginManagerId)],
|
|
658
|
+
typeArguments: [baseCoin.type, quoteCoin.type]
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
__privateSet(this, _config, config);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
_config = new WeakMap();
|
|
665
|
+
export {
|
|
666
|
+
MarginManagerContract
|
|
667
|
+
};
|
|
668
|
+
//# sourceMappingURL=marginManager.js.map
|