@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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/transactions/marginLiquidations.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction } from '@haneullabs/haneul/transactions';\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * MarginLiquidationsContract class for managing LiquidationVault operations.\n */\nexport class MarginLiquidationsContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginLiquidationsContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create a new liquidation vault\n\t * @param {string} liquidationAdminCap The liquidation admin cap object ID\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateLiquidationVault = (liquidationAdminCap: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::create_liquidation_vault`,\n\t\t\targuments: [tx.object(liquidationAdminCap)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit coins into a liquidation vault\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} liquidationAdminCap The liquidation admin cap object ID\n\t * @param {string} coinKey The key to identify the coin type\n\t * @param {number} amount The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdeposit =\n\t\t(vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositCoin = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: amount * coin.scalar,\n\t\t\t});\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::deposit`,\n\t\t\t\targuments: [tx.object(vaultId), tx.object(liquidationAdminCap), depositCoin],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw coins from a liquidation vault\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} liquidationAdminCap The liquidation admin cap object ID\n\t * @param {string} coinKey The key to identify the coin type\n\t * @param {number} amount The amount to withdraw\n\t * @returns A function that takes a Transaction object and returns the withdrawn coin\n\t */\n\twithdraw =\n\t\t(vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::withdraw`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(vaultId),\n\t\t\t\t\ttx.object(liquidationAdminCap),\n\t\t\t\t\ttx.pure.u64(amount * coin.scalar),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Liquidate a margin manager by repaying base debt\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} managerAddress The margin manager address to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} [repayAmount] The amount to repay (in base asset units), or undefined for full liquidation\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidateBase =\n\t\t(vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\n\t\t\tconst repayAmountArg =\n\t\t\t\trepayAmount !== undefined\n\t\t\t\t\t? tx.pure.option('u64', BigInt(Math.floor(repayAmount * baseCoin.scalar)))\n\t\t\t\t\t: tx.pure.option('u64', null);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_base`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(vaultId),\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\trepayAmountArg,\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Liquidate a margin manager by repaying quote debt\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} managerAddress The margin manager address to liquidate\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} [repayAmount] The amount to repay (in quote asset units), or undefined for full liquidation\n\t * @returns A function that takes a Transaction object\n\t */\n\tliquidateQuote =\n\t\t(vaultId: string, managerAddress: string, poolKey: string, repayAmount?: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst baseMarginPool = this.#config.getMarginPool(pool.baseCoin);\n\t\t\tconst quoteMarginPool = this.#config.getMarginPool(pool.quoteCoin);\n\n\t\t\tconst repayAmountArg =\n\t\t\t\trepayAmount !== undefined\n\t\t\t\t\t? tx.pure.option('u64', BigInt(Math.floor(repayAmount * quoteCoin.scalar)))\n\t\t\t\t\t: tx.pure.option('u64', null);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::liquidate_quote`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(vaultId),\n\t\t\t\t\ttx.object(managerAddress),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.object(baseCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(quoteCoin.priceInfoObjectId!),\n\t\t\t\t\ttx.object(baseMarginPool.address),\n\t\t\t\t\ttx.object(quoteMarginPool.address),\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\trepayAmountArg,\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t// === Read-Only Functions ===\n\n\t/**\n\t * @description Get the balance of a specific coin type in the liquidation vault\n\t * @param {string} vaultId The liquidation vault object ID\n\t * @param {string} coinKey The key to identify the coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalance = (vaultId: string, coinKey: string) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.LIQUIDATION_PACKAGE_ID}::liquidation_vault::balance`,\n\t\t\targuments: [tx.object(vaultId)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA;AAGA,SAAS,uBAAuB;AAOzB,MAAM,2BAA2B;AAAA;AAAA;AAAA;AAAA,EAMvC,YAAY,QAAwB;AALpC;AAcA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAyB,CAAC,wBAAgC,CAAC,OAAoB;AAC9E,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,sBAAsB;AAAA,QAC9C,WAAW,CAAC,GAAG,OAAO,mBAAmB,CAAC;AAAA,MAC3C,CAAC;AAAA,IACF;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACC,CAAC,SAAiB,qBAA6B,SAAiB,WAChE,CAAC,OAAoB;AACpB,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,YAAM,cAAc,gBAAgB;AAAA,QACnC,MAAM,KAAK;AAAA,QACX,SAAS,SAAS,KAAK;AAAA,MACxB,CAAC;AACD,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,sBAAsB;AAAA,QAC9C,WAAW,CAAC,GAAG,OAAO,OAAO,GAAG,GAAG,OAAO,mBAAmB,GAA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QACjB;AAAA,QACA,eAAe,CAAC,SAAS,MAAM,UAAU,IAAI;AAAA,MAC9C,CAAC;AAAA,IACF;AAUD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAU,CAAC,SAAiB,YAAoB,CAAC,OAAoB;AACpE,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,aAAO,GAAG,SAAS;AAAA,QAClB,QAAQ,GAAG,mBAAK,SAAQ,sBAAsB;AAAA,QAC9C,WAAW,CAAC,GAAG,OAAO,OAAO,CAAC;AAAA,QAC9B,eAAe,CAAC,KAAK,IAAI;AAAA,MAC1B,CAAC;AAAA,IACF;AA5JC,uBAAK,SAAU;AAAA,EAChB;AA4JD;AAnKC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Transaction, TransactionArgument, TransactionObjectArgument } from '@haneullabs/haneul/transactions';
|
|
2
|
+
import type { DeepBookConfig } from '../utils/config.js';
|
|
3
|
+
import type { MarginPoolConfigParams, InterestConfigParams } from '../types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* DeepBookMaintainerContract class for managing maintainer actions.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MarginMaintainerContract {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* @param {DeepBookConfig} config Configuration for MarginMaintainerContract
|
|
11
|
+
*/
|
|
12
|
+
constructor(config: DeepBookConfig);
|
|
13
|
+
/**
|
|
14
|
+
* @description Create a new margin pool
|
|
15
|
+
* @param {string} coinKey The key to identify the coin
|
|
16
|
+
* @param {TransactionArgument} poolConfig The configuration for the pool
|
|
17
|
+
* @returns A function that takes a Transaction object
|
|
18
|
+
*/
|
|
19
|
+
createMarginPool: (coinKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => void;
|
|
20
|
+
/**
|
|
21
|
+
* @description Create a new protocol config
|
|
22
|
+
* @param {string} coinKey The key to identify the coin
|
|
23
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)
|
|
24
|
+
* @param {InterestConfigParams} interestConfig The configuration for the interest
|
|
25
|
+
* @returns A function that takes a Transaction object
|
|
26
|
+
*/
|
|
27
|
+
newProtocolConfig: (coinKey: string, marginPoolConfig: MarginPoolConfigParams, interestConfig: InterestConfigParams) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
28
|
+
/**
|
|
29
|
+
* @description Create a new margin pool config
|
|
30
|
+
* @param {string} coinKey The key to identify the coin
|
|
31
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool
|
|
32
|
+
* @returns A function that takes a Transaction object
|
|
33
|
+
*/
|
|
34
|
+
newMarginPoolConfig: (coinKey: string, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
35
|
+
/**
|
|
36
|
+
* @description Create a new margin pool config with rate limit
|
|
37
|
+
* @param {string} coinKey The key to identify the coin
|
|
38
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool with rate limit
|
|
39
|
+
* @returns A function that takes a Transaction object
|
|
40
|
+
*/
|
|
41
|
+
newMarginPoolConfigWithRateLimit: (coinKey: string, marginPoolConfig: Required<Pick<MarginPoolConfigParams, "rateLimitCapacity" | "rateLimitRefillRatePerMs" | "rateLimitEnabled">> & MarginPoolConfigParams) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
42
|
+
/**
|
|
43
|
+
* @description Create a new interest config
|
|
44
|
+
* @param {InterestConfigParams} interestConfig The configuration for the interest
|
|
45
|
+
* @returns A function that takes a Transaction object
|
|
46
|
+
*/
|
|
47
|
+
newInterestConfig: (interestConfig: InterestConfigParams) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
48
|
+
/**
|
|
49
|
+
* @description Enable a deepbook pool for loan
|
|
50
|
+
* @param {string} deepbookPoolKey The key to identify the deepbook pool
|
|
51
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
52
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
53
|
+
* @returns A function that takes a Transaction object
|
|
54
|
+
*/
|
|
55
|
+
enableDeepbookPoolForLoan: (deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) => (tx: Transaction) => void;
|
|
56
|
+
/**
|
|
57
|
+
* @description Disable a deepbook pool for loan
|
|
58
|
+
* @param {string} deepbookPoolKey The key to identify the deepbook pool
|
|
59
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
60
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
61
|
+
* @returns A function that takes a Transaction object
|
|
62
|
+
*/
|
|
63
|
+
disableDeepbookPoolForLoan: (deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) => (tx: Transaction) => void;
|
|
64
|
+
/**
|
|
65
|
+
* @description Update the interest params
|
|
66
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
67
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
68
|
+
* @param {InterestConfigParams} interestConfig The configuration for the interest
|
|
69
|
+
* @returns A function that takes a Transaction object
|
|
70
|
+
*/
|
|
71
|
+
updateInterestParams: (coinKey: string, marginPoolCap: TransactionObjectArgument, interestConfig: InterestConfigParams) => (tx: Transaction) => void;
|
|
72
|
+
/**
|
|
73
|
+
* @description Update the margin pool config
|
|
74
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
75
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
76
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool
|
|
77
|
+
* @returns A function that takes a Transaction object
|
|
78
|
+
*/
|
|
79
|
+
updateMarginPoolConfig: (coinKey: string, marginPoolCap: TransactionObjectArgument, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => void;
|
|
80
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
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 __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
+
var _config, _MarginMaintainerContract_instances, marginMaintainerCap_fn;
|
|
10
|
+
import { FLOAT_SCALAR } from "../utils/config.js";
|
|
11
|
+
class MarginMaintainerContract {
|
|
12
|
+
/**
|
|
13
|
+
* @param {DeepBookConfig} config Configuration for MarginMaintainerContract
|
|
14
|
+
*/
|
|
15
|
+
constructor(config) {
|
|
16
|
+
__privateAdd(this, _MarginMaintainerContract_instances);
|
|
17
|
+
__privateAdd(this, _config);
|
|
18
|
+
/**
|
|
19
|
+
* @description Create a new margin pool
|
|
20
|
+
* @param {string} coinKey The key to identify the coin
|
|
21
|
+
* @param {TransactionArgument} poolConfig The configuration for the pool
|
|
22
|
+
* @returns A function that takes a Transaction object
|
|
23
|
+
*/
|
|
24
|
+
this.createMarginPool = (coinKey, poolConfig) => (tx) => {
|
|
25
|
+
const coin = __privateGet(this, _config).getCoin(coinKey);
|
|
26
|
+
tx.moveCall({
|
|
27
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_pool::create_margin_pool`,
|
|
28
|
+
arguments: [
|
|
29
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
30
|
+
poolConfig,
|
|
31
|
+
tx.object(__privateMethod(this, _MarginMaintainerContract_instances, marginMaintainerCap_fn).call(this)),
|
|
32
|
+
tx.object.clock()
|
|
33
|
+
],
|
|
34
|
+
typeArguments: [coin.type]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @description Create a new protocol config
|
|
39
|
+
* @param {string} coinKey The key to identify the coin
|
|
40
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)
|
|
41
|
+
* @param {InterestConfigParams} interestConfig The configuration for the interest
|
|
42
|
+
* @returns A function that takes a Transaction object
|
|
43
|
+
*/
|
|
44
|
+
this.newProtocolConfig = (coinKey, marginPoolConfig, interestConfig) => (tx) => {
|
|
45
|
+
const hasRateLimit = marginPoolConfig.rateLimitCapacity !== void 0 && marginPoolConfig.rateLimitRefillRatePerMs !== void 0 && marginPoolConfig.rateLimitEnabled !== void 0;
|
|
46
|
+
const marginPoolConfigObject = hasRateLimit ? this.newMarginPoolConfigWithRateLimit(coinKey, {
|
|
47
|
+
...marginPoolConfig,
|
|
48
|
+
rateLimitCapacity: marginPoolConfig.rateLimitCapacity,
|
|
49
|
+
rateLimitRefillRatePerMs: marginPoolConfig.rateLimitRefillRatePerMs,
|
|
50
|
+
rateLimitEnabled: marginPoolConfig.rateLimitEnabled
|
|
51
|
+
})(tx) : this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
|
|
52
|
+
const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
|
|
53
|
+
return tx.moveCall({
|
|
54
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::protocol_config::new_protocol_config`,
|
|
55
|
+
arguments: [marginPoolConfigObject, interestConfigObject]
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @description Create a new margin pool config
|
|
60
|
+
* @param {string} coinKey The key to identify the coin
|
|
61
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool
|
|
62
|
+
* @returns A function that takes a Transaction object
|
|
63
|
+
*/
|
|
64
|
+
this.newMarginPoolConfig = (coinKey, marginPoolConfig) => (tx) => {
|
|
65
|
+
const coin = __privateGet(this, _config).getCoin(coinKey);
|
|
66
|
+
const { supplyCap, maxUtilizationRate, referralSpread, minBorrow } = marginPoolConfig;
|
|
67
|
+
return tx.moveCall({
|
|
68
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config`,
|
|
69
|
+
arguments: [
|
|
70
|
+
tx.pure.u64(supplyCap * coin.scalar),
|
|
71
|
+
tx.pure.u64(maxUtilizationRate * FLOAT_SCALAR),
|
|
72
|
+
tx.pure.u64(referralSpread * FLOAT_SCALAR),
|
|
73
|
+
tx.pure.u64(Math.round(minBorrow * coin.scalar))
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @description Create a new margin pool config with rate limit
|
|
79
|
+
* @param {string} coinKey The key to identify the coin
|
|
80
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool with rate limit
|
|
81
|
+
* @returns A function that takes a Transaction object
|
|
82
|
+
*/
|
|
83
|
+
this.newMarginPoolConfigWithRateLimit = (coinKey, marginPoolConfig) => (tx) => {
|
|
84
|
+
const coin = __privateGet(this, _config).getCoin(coinKey);
|
|
85
|
+
const {
|
|
86
|
+
supplyCap,
|
|
87
|
+
maxUtilizationRate,
|
|
88
|
+
referralSpread,
|
|
89
|
+
minBorrow,
|
|
90
|
+
rateLimitCapacity,
|
|
91
|
+
rateLimitRefillRatePerMs,
|
|
92
|
+
rateLimitEnabled
|
|
93
|
+
} = marginPoolConfig;
|
|
94
|
+
return tx.moveCall({
|
|
95
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config_with_rate_limit`,
|
|
96
|
+
arguments: [
|
|
97
|
+
tx.pure.u64(supplyCap * coin.scalar),
|
|
98
|
+
tx.pure.u64(maxUtilizationRate * FLOAT_SCALAR),
|
|
99
|
+
tx.pure.u64(referralSpread * FLOAT_SCALAR),
|
|
100
|
+
tx.pure.u64(Math.round(minBorrow * coin.scalar)),
|
|
101
|
+
tx.pure.u64(Math.round(rateLimitCapacity * coin.scalar)),
|
|
102
|
+
tx.pure.u64(Math.round(rateLimitRefillRatePerMs * coin.scalar)),
|
|
103
|
+
tx.pure.bool(rateLimitEnabled)
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* @description Create a new interest config
|
|
109
|
+
* @param {InterestConfigParams} interestConfig The configuration for the interest
|
|
110
|
+
* @returns A function that takes a Transaction object
|
|
111
|
+
*/
|
|
112
|
+
this.newInterestConfig = (interestConfig) => (tx) => {
|
|
113
|
+
const { baseRate, baseSlope, optimalUtilization, excessSlope } = interestConfig;
|
|
114
|
+
return tx.moveCall({
|
|
115
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::protocol_config::new_interest_config`,
|
|
116
|
+
arguments: [
|
|
117
|
+
tx.pure.u64(baseRate * FLOAT_SCALAR),
|
|
118
|
+
tx.pure.u64(baseSlope * FLOAT_SCALAR),
|
|
119
|
+
tx.pure.u64(optimalUtilization * FLOAT_SCALAR),
|
|
120
|
+
tx.pure.u64(excessSlope * FLOAT_SCALAR)
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* @description Enable a deepbook pool for loan
|
|
126
|
+
* @param {string} deepbookPoolKey The key to identify the deepbook pool
|
|
127
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
128
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
129
|
+
* @returns A function that takes a Transaction object
|
|
130
|
+
*/
|
|
131
|
+
this.enableDeepbookPoolForLoan = (deepbookPoolKey, coinKey, marginPoolCap) => (tx) => {
|
|
132
|
+
const deepbookPool = __privateGet(this, _config).getPool(deepbookPoolKey);
|
|
133
|
+
const marginPool = __privateGet(this, _config).getMarginPool(coinKey);
|
|
134
|
+
tx.moveCall({
|
|
135
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_pool::enable_deepbook_pool_for_loan`,
|
|
136
|
+
arguments: [
|
|
137
|
+
tx.object(marginPool.address),
|
|
138
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
139
|
+
tx.pure.id(deepbookPool.address),
|
|
140
|
+
tx.object(marginPoolCap),
|
|
141
|
+
tx.object.clock()
|
|
142
|
+
],
|
|
143
|
+
typeArguments: [marginPool.type]
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* @description Disable a deepbook pool for loan
|
|
148
|
+
* @param {string} deepbookPoolKey The key to identify the deepbook pool
|
|
149
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
150
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
151
|
+
* @returns A function that takes a Transaction object
|
|
152
|
+
*/
|
|
153
|
+
this.disableDeepbookPoolForLoan = (deepbookPoolKey, coinKey, marginPoolCap) => (tx) => {
|
|
154
|
+
const deepbookPool = __privateGet(this, _config).getPool(deepbookPoolKey);
|
|
155
|
+
const marginPool = __privateGet(this, _config).getMarginPool(coinKey);
|
|
156
|
+
tx.moveCall({
|
|
157
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_pool::disable_deepbook_pool_for_loan`,
|
|
158
|
+
arguments: [
|
|
159
|
+
tx.object(marginPool.address),
|
|
160
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
161
|
+
tx.pure.id(deepbookPool.address),
|
|
162
|
+
tx.object(marginPoolCap),
|
|
163
|
+
tx.object.clock()
|
|
164
|
+
],
|
|
165
|
+
typeArguments: [marginPool.type]
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* @description Update the interest params
|
|
170
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
171
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
172
|
+
* @param {InterestConfigParams} interestConfig The configuration for the interest
|
|
173
|
+
* @returns A function that takes a Transaction object
|
|
174
|
+
*/
|
|
175
|
+
this.updateInterestParams = (coinKey, marginPoolCap, interestConfig) => (tx) => {
|
|
176
|
+
const marginPool = __privateGet(this, _config).getMarginPool(coinKey);
|
|
177
|
+
const interestConfigObject = this.newInterestConfig(interestConfig)(tx);
|
|
178
|
+
tx.moveCall({
|
|
179
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_pool::update_interest_params`,
|
|
180
|
+
arguments: [
|
|
181
|
+
tx.object(marginPool.address),
|
|
182
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
183
|
+
interestConfigObject,
|
|
184
|
+
tx.object(marginPoolCap),
|
|
185
|
+
tx.object.clock()
|
|
186
|
+
],
|
|
187
|
+
typeArguments: [marginPool.type]
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* @description Update the margin pool config
|
|
192
|
+
* @param {string} coinKey The key to identify the margin pool
|
|
193
|
+
* @param {TransactionObjectArgument} marginPoolCap The margin pool cap
|
|
194
|
+
* @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool
|
|
195
|
+
* @returns A function that takes a Transaction object
|
|
196
|
+
*/
|
|
197
|
+
this.updateMarginPoolConfig = (coinKey, marginPoolCap, marginPoolConfig) => (tx) => {
|
|
198
|
+
const marginPool = __privateGet(this, _config).getMarginPool(coinKey);
|
|
199
|
+
const marginPoolConfigObject = this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);
|
|
200
|
+
tx.moveCall({
|
|
201
|
+
target: `${__privateGet(this, _config).MARGIN_PACKAGE_ID}::margin_pool::update_margin_pool_config`,
|
|
202
|
+
arguments: [
|
|
203
|
+
tx.object(marginPool.address),
|
|
204
|
+
tx.object(__privateGet(this, _config).MARGIN_REGISTRY_ID),
|
|
205
|
+
marginPoolConfigObject,
|
|
206
|
+
tx.object(marginPoolCap),
|
|
207
|
+
tx.object.clock()
|
|
208
|
+
],
|
|
209
|
+
typeArguments: [marginPool.type]
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
__privateSet(this, _config, config);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
_config = new WeakMap();
|
|
216
|
+
_MarginMaintainerContract_instances = new WeakSet();
|
|
217
|
+
/**
|
|
218
|
+
* @returns The admin capability required for admin operations
|
|
219
|
+
* @throws Error if the admin capability is not set
|
|
220
|
+
*/
|
|
221
|
+
marginMaintainerCap_fn = function() {
|
|
222
|
+
const marginMaintainerCap = __privateGet(this, _config).marginMaintainerCap;
|
|
223
|
+
if (!marginMaintainerCap) {
|
|
224
|
+
throw new Error("MARGIN_ADMIN_CAP environment variable not set");
|
|
225
|
+
}
|
|
226
|
+
return marginMaintainerCap;
|
|
227
|
+
};
|
|
228
|
+
export {
|
|
229
|
+
MarginMaintainerContract
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=marginMaintainer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/transactions/marginMaintainer.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tTransaction,\n\tTransactionArgument,\n\tTransactionObjectArgument,\n} from '@haneullabs/haneul/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\nimport type { MarginPoolConfigParams, InterestConfigParams } from '../types/index.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\n\n/**\n * DeepBookMaintainerContract class for managing maintainer actions.\n */\nexport class MarginMaintainerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for MarginMaintainerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @returns The admin capability required for admin operations\n\t * @throws Error if the admin capability is not set\n\t */\n\t#marginMaintainerCap() {\n\t\tconst marginMaintainerCap = this.#config.marginMaintainerCap;\n\t\tif (!marginMaintainerCap) {\n\t\t\tthrow new Error('MARGIN_ADMIN_CAP environment variable not set');\n\t\t}\n\t\treturn marginMaintainerCap;\n\t}\n\n\t/**\n\t * @description Create a new margin pool\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {TransactionArgument} poolConfig The configuration for the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateMarginPool = (coinKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => {\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::create_margin_pool`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\tpoolConfig,\n\t\t\t\ttx.object(this.#marginMaintainerCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Create a new protocol config\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool (with optional rate limit)\n\t * @param {InterestConfigParams} interestConfig The configuration for the interest\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewProtocolConfig =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolConfig: MarginPoolConfigParams,\n\t\t\tinterestConfig: InterestConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst hasRateLimit =\n\t\t\t\tmarginPoolConfig.rateLimitCapacity !== undefined &&\n\t\t\t\tmarginPoolConfig.rateLimitRefillRatePerMs !== undefined &&\n\t\t\t\tmarginPoolConfig.rateLimitEnabled !== undefined;\n\t\t\tconst marginPoolConfigObject = hasRateLimit\n\t\t\t\t? this.newMarginPoolConfigWithRateLimit(coinKey, {\n\t\t\t\t\t\t...marginPoolConfig,\n\t\t\t\t\t\trateLimitCapacity: marginPoolConfig.rateLimitCapacity!,\n\t\t\t\t\t\trateLimitRefillRatePerMs: marginPoolConfig.rateLimitRefillRatePerMs!,\n\t\t\t\t\t\trateLimitEnabled: marginPoolConfig.rateLimitEnabled!,\n\t\t\t\t\t})(tx)\n\t\t\t\t: this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);\n\t\t\tconst interestConfigObject = this.newInterestConfig(interestConfig)(tx);\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_protocol_config`,\n\t\t\t\targuments: [marginPoolConfigObject, interestConfigObject],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new margin pool config\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginPoolConfig =\n\t\t(coinKey: string, marginPoolConfig: MarginPoolConfigParams) => (tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst { supplyCap, maxUtilizationRate, referralSpread, minBorrow } = marginPoolConfig;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(supplyCap * coin.scalar),\n\t\t\t\t\ttx.pure.u64(maxUtilizationRate * FLOAT_SCALAR),\n\t\t\t\t\ttx.pure.u64(referralSpread * FLOAT_SCALAR),\n\t\t\t\t\ttx.pure.u64(Math.round(minBorrow * coin.scalar)),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new margin pool config with rate limit\n\t * @param {string} coinKey The key to identify the coin\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool with rate limit\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewMarginPoolConfigWithRateLimit =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolConfig: Required<\n\t\t\t\tPick<\n\t\t\t\t\tMarginPoolConfigParams,\n\t\t\t\t\t'rateLimitCapacity' | 'rateLimitRefillRatePerMs' | 'rateLimitEnabled'\n\t\t\t\t>\n\t\t\t> &\n\t\t\t\tMarginPoolConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst {\n\t\t\t\tsupplyCap,\n\t\t\t\tmaxUtilizationRate,\n\t\t\t\treferralSpread,\n\t\t\t\tminBorrow,\n\t\t\t\trateLimitCapacity,\n\t\t\t\trateLimitRefillRatePerMs,\n\t\t\t\trateLimitEnabled,\n\t\t\t} = marginPoolConfig;\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_margin_pool_config_with_rate_limit`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.pure.u64(supplyCap * coin.scalar),\n\t\t\t\t\ttx.pure.u64(maxUtilizationRate * FLOAT_SCALAR),\n\t\t\t\t\ttx.pure.u64(referralSpread * FLOAT_SCALAR),\n\t\t\t\t\ttx.pure.u64(Math.round(minBorrow * coin.scalar)),\n\t\t\t\t\ttx.pure.u64(Math.round(rateLimitCapacity * coin.scalar)),\n\t\t\t\t\ttx.pure.u64(Math.round(rateLimitRefillRatePerMs * coin.scalar)),\n\t\t\t\t\ttx.pure.bool(rateLimitEnabled),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Create a new interest config\n\t * @param {InterestConfigParams} interestConfig The configuration for the interest\n\t * @returns A function that takes a Transaction object\n\t */\n\tnewInterestConfig = (interestConfig: InterestConfigParams) => (tx: Transaction) => {\n\t\tconst { baseRate, baseSlope, optimalUtilization, excessSlope } = interestConfig;\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::protocol_config::new_interest_config`,\n\t\t\targuments: [\n\t\t\t\ttx.pure.u64(baseRate * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(baseSlope * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(optimalUtilization * FLOAT_SCALAR),\n\t\t\t\ttx.pure.u64(excessSlope * FLOAT_SCALAR),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable a deepbook pool for loan\n\t * @param {string} deepbookPoolKey The key to identify the deepbook pool\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableDeepbookPoolForLoan =\n\t\t(deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst deepbookPool = this.#config.getPool(deepbookPoolKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::enable_deepbook_pool_for_loan`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.pure.id(deepbookPool.address),\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Disable a deepbook pool for loan\n\t * @param {string} deepbookPoolKey The key to identify the deepbook pool\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableDeepbookPoolForLoan =\n\t\t(deepbookPoolKey: string, coinKey: string, marginPoolCap: TransactionObjectArgument) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst deepbookPool = this.#config.getPool(deepbookPoolKey);\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::disable_deepbook_pool_for_loan`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\ttx.pure.id(deepbookPool.address),\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Update the interest params\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @param {InterestConfigParams} interestConfig The configuration for the interest\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateInterestParams =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolCap: TransactionObjectArgument,\n\t\t\tinterestConfig: InterestConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst interestConfigObject = this.newInterestConfig(interestConfig)(tx);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_interest_params`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tinterestConfigObject,\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Update the margin pool config\n\t * @param {string} coinKey The key to identify the margin pool\n\t * @param {TransactionObjectArgument} marginPoolCap The margin pool cap\n\t * @param {MarginPoolConfigParams} marginPoolConfig The configuration for the margin pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateMarginPoolConfig =\n\t\t(\n\t\t\tcoinKey: string,\n\t\t\tmarginPoolCap: TransactionObjectArgument,\n\t\t\tmarginPoolConfig: MarginPoolConfigParams,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst marginPool = this.#config.getMarginPool(coinKey);\n\t\t\tconst marginPoolConfigObject = this.newMarginPoolConfig(coinKey, marginPoolConfig)(tx);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.MARGIN_PACKAGE_ID}::margin_pool::update_margin_pool_config`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(marginPool.address),\n\t\t\t\t\ttx.object(this.#config.MARGIN_REGISTRY_ID),\n\t\t\t\t\tmarginPoolConfigObject,\n\t\t\t\t\ttx.object(marginPoolCap),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [marginPool.type],\n\t\t\t});\n\t\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;AAWA,SAAS,oBAAoB;AAKtB,MAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA,EAMrC,YAAY,QAAwB;AAN9B;AACN;AA2BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAmB,CAAC,SAAiB,eAAoC,CAAC,OAAoB;AAC7F,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,iBAAiB;AAAA,QACzC,WAAW;AAAA,UACV,GAAG,OAAO,mBAAK,SAAQ,kBAAkB;AAAA,UACzC;AAAA,UACA,GAAG,OAAO,sBAAK,6DAAL,UAA2B;AAAA,UACrC,GAAG,OAAO,MAAM;AAAA,QACjB;AAAA,QACA,eAAe,CAAC,KAAK,IAAI;AAAA,MAC1B,CAAC;AAAA,IACF;AASA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BACC,CACC,SACA,kBACA,mBAED,CAAC,OAAoB;AACpB,YAAM,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AW,IAAI;AAAA,MAChC,CAAC;AAAA,IACF;AASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCACC,CACC,SACA,eACA,qBAED,CAAC,OAAoB;AACpB,YAAM,aAAa,mBAAK,SAAQ,cAAc,OAAO;AACrD,YAAM,yBAAyB,KAAK,oBAAoB,SAAS,gBAAgB,EAAE,EAAE;AACrF,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,iBAAiB;AAAA,QACzC,WAAW;AAAA,UACV,GAAG,OAAO,WAAW,OAAO;AAAA,UAC5B,GAAG,OAAO,mBAAK,SAAQ,kBAAkB;AAAA,UACzC;AAAA,UACA,GAAG,OAAO,aAAa;AAAA,UACvB,GAAG,OAAO,MAAM;AAAA,QACjB;AAAA,QACA,eAAe,CAAC,WAAW,IAAI;AAAA,MAChC,CAAC;AAAA,IACF;AA/PA,uBAAK,SAAU;AAAA,EAChB;AA+PD;AAtQC;AADM;AAAA;AAAA;AAAA;AAAA;AAcN,yBAAoB,WAAG;AACtB,QAAM,sBAAsB,mBAAK,SAAQ;AACzC,MAAI,CAAC,qBAAqB;AACzB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { Transaction, TransactionArgument } from '@haneullabs/haneul/transactions';
|
|
2
|
+
import type { DeepBookConfig } from '../utils/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* MarginManagerContract class for managing MarginManager operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MarginManagerContract {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* @param {DeepBookConfig} config Configuration for MarginManagerContract
|
|
10
|
+
*/
|
|
11
|
+
constructor(config: DeepBookConfig);
|
|
12
|
+
/**
|
|
13
|
+
* @description Create a new margin manager
|
|
14
|
+
* @param {string} poolKey The key to identify the pool
|
|
15
|
+
* @returns A function that takes a Transaction object
|
|
16
|
+
*/
|
|
17
|
+
newMarginManager: (poolKey: string) => (tx: Transaction) => void;
|
|
18
|
+
/**
|
|
19
|
+
* @description Create a new margin manager with an initializer
|
|
20
|
+
* @param {string} poolKey The key to identify the pool
|
|
21
|
+
* @returns A function that takes a Transaction object
|
|
22
|
+
*/
|
|
23
|
+
newMarginManagerWithInitializer: (poolKey: string) => (tx: Transaction) => {
|
|
24
|
+
manager: {
|
|
25
|
+
$kind: "NestedResult";
|
|
26
|
+
NestedResult: [number, number];
|
|
27
|
+
};
|
|
28
|
+
initializer: {
|
|
29
|
+
$kind: "NestedResult";
|
|
30
|
+
NestedResult: [number, number];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @description Share a margin manager
|
|
35
|
+
* @param {string} poolKey The key to identify the pool
|
|
36
|
+
* @param {TransactionArgument} manager The margin manager to share
|
|
37
|
+
* @param {TransactionArgument} initializer The initializer for the manager
|
|
38
|
+
* @returns A function that takes a Transaction object
|
|
39
|
+
*/
|
|
40
|
+
shareMarginManager: (poolKey: string, manager: TransactionArgument, initializer: TransactionArgument) => (tx: Transaction) => void;
|
|
41
|
+
/**
|
|
42
|
+
* @description Deposit base into a margin manager
|
|
43
|
+
* @param {string} managerKey The key to identify the manager
|
|
44
|
+
* @param {number} amount The amount to deposit
|
|
45
|
+
* @returns A function that takes a Transaction object
|
|
46
|
+
*/
|
|
47
|
+
depositBase: (managerKey: string, amount: number) => (tx: Transaction) => void;
|
|
48
|
+
/**
|
|
49
|
+
* @description Deposit quote into a margin manager
|
|
50
|
+
* @param {string} managerKey The key to identify the manager
|
|
51
|
+
* @param {number} amount The amount to deposit
|
|
52
|
+
* @returns A function that takes a Transaction object
|
|
53
|
+
*/
|
|
54
|
+
depositQuote: (managerKey: string, amount: number) => (tx: Transaction) => void;
|
|
55
|
+
/**
|
|
56
|
+
* @description Deposit deep into a margin manager
|
|
57
|
+
* @param {string} managerKey The key to identify the manager
|
|
58
|
+
* @param {number} amount The amount to deposit
|
|
59
|
+
* @returns A function that takes a Transaction object
|
|
60
|
+
*/
|
|
61
|
+
depositDeep: (managerKey: string, amount: number) => (tx: Transaction) => void;
|
|
62
|
+
/**
|
|
63
|
+
* @description Withdraw base from a margin manager
|
|
64
|
+
* @param {string} managerKey The key to identify the manager
|
|
65
|
+
* @param {number} amount The amount to withdraw
|
|
66
|
+
* @returns A function that takes a Transaction object
|
|
67
|
+
*/
|
|
68
|
+
withdrawBase: (managerKey: string, amount: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
69
|
+
/**
|
|
70
|
+
* @description Withdraw quote from a margin manager
|
|
71
|
+
* @param {string} managerKey The key to identify the manager
|
|
72
|
+
* @param {number} amount The amount to withdraw
|
|
73
|
+
* @returns A function that takes a Transaction object
|
|
74
|
+
*/
|
|
75
|
+
withdrawQuote: (managerKey: string, amount: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
76
|
+
/**
|
|
77
|
+
* @description Withdraw deep from a margin manager
|
|
78
|
+
* @param {string} managerKey The key to identify the manager
|
|
79
|
+
* @param {number} amount The amount to withdraw
|
|
80
|
+
* @returns A function that takes a Transaction object
|
|
81
|
+
*/
|
|
82
|
+
withdrawDeep: (managerKey: string, amount: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
83
|
+
/**
|
|
84
|
+
* @description Borrow base from a margin manager
|
|
85
|
+
* @param {string} managerKey The key to identify the manager
|
|
86
|
+
* @param {number} amount The amount to borrow
|
|
87
|
+
* @returns A function that takes a Transaction object
|
|
88
|
+
*/
|
|
89
|
+
borrowBase: (managerKey: string, amount: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
90
|
+
/**
|
|
91
|
+
* @description Borrow quote from a margin manager
|
|
92
|
+
* @param {string} managerKey The key to identify the manager
|
|
93
|
+
* @param {number} amount The amount to borrow
|
|
94
|
+
* @returns A function that takes a Transaction object
|
|
95
|
+
*/
|
|
96
|
+
borrowQuote: (managerKey: string, amount: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
97
|
+
/**
|
|
98
|
+
* @description Repay base from a margin manager
|
|
99
|
+
* @param {string} managerKey The key to identify the manager
|
|
100
|
+
* @param {number} amount The amount to repay
|
|
101
|
+
* @returns A function that takes a Transaction object
|
|
102
|
+
*/
|
|
103
|
+
repayBase: (managerKey: string, amount?: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
104
|
+
/**
|
|
105
|
+
* @description Repay quote from a margin manager
|
|
106
|
+
* @param {string} managerKey The key to identify the manager
|
|
107
|
+
* @param {number} amount The amount to repay
|
|
108
|
+
* @returns A function that takes a Transaction object
|
|
109
|
+
*/
|
|
110
|
+
repayQuote: (managerKey: string, amount?: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
111
|
+
/**
|
|
112
|
+
* @description Liquidate a margin manager
|
|
113
|
+
* @param {string} managerAddress The address of the manager to liquidate
|
|
114
|
+
* @param {string} poolKey The key to identify the pool
|
|
115
|
+
* @param {boolean} debtIsBase Whether the debt is in base
|
|
116
|
+
* @param {TransactionArgument} repayCoin The coin to repay
|
|
117
|
+
* @returns A function that takes a Transaction object
|
|
118
|
+
*/
|
|
119
|
+
liquidate: (managerAddress: string, poolKey: string, debtIsBase: boolean, repayCoin: TransactionArgument) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
120
|
+
/**
|
|
121
|
+
* @description Set the referral for a margin manager (DeepBookPoolReferral)
|
|
122
|
+
* @param {string} managerKey The key to identify the margin manager
|
|
123
|
+
* @param {string} referral The referral (DeepBookPoolReferral) to set
|
|
124
|
+
* @returns A function that takes a Transaction object
|
|
125
|
+
*/
|
|
126
|
+
setMarginManagerReferral: (managerKey: string, referral: string) => (tx: Transaction) => void;
|
|
127
|
+
/**
|
|
128
|
+
* @description Unset the referral for a margin manager
|
|
129
|
+
* @param {string} managerKey The key to identify the margin manager
|
|
130
|
+
* @param {string} poolKey The key of the pool to unset the referral for
|
|
131
|
+
* @returns A function that takes a Transaction object
|
|
132
|
+
*/
|
|
133
|
+
unsetMarginManagerReferral: (managerKey: string, poolKey: string) => (tx: Transaction) => void;
|
|
134
|
+
/**
|
|
135
|
+
* @description Get the owner address of a margin manager
|
|
136
|
+
* @param {string} poolKey The key to identify the pool
|
|
137
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
138
|
+
* @returns A function that takes a Transaction object
|
|
139
|
+
*/
|
|
140
|
+
ownerByPoolKey: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
141
|
+
/**
|
|
142
|
+
* @description Get the DeepBook pool ID associated with a margin manager
|
|
143
|
+
* @param {string} poolKey The key to identify the pool
|
|
144
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
145
|
+
* @returns A function that takes a Transaction object
|
|
146
|
+
*/
|
|
147
|
+
deepbookPool: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
148
|
+
/**
|
|
149
|
+
* @description Get the margin pool ID (if any) associated with a margin manager
|
|
150
|
+
* @param {string} poolKey The key to identify the pool
|
|
151
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
152
|
+
* @returns A function that takes a Transaction object
|
|
153
|
+
*/
|
|
154
|
+
marginPoolId: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
155
|
+
/**
|
|
156
|
+
* @description Get borrowed shares for both base and quote assets
|
|
157
|
+
* @param {string} poolKey The key to identify the pool
|
|
158
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
159
|
+
* @returns A function that takes a Transaction object
|
|
160
|
+
*/
|
|
161
|
+
borrowedShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
162
|
+
/**
|
|
163
|
+
* @description Get borrowed base shares
|
|
164
|
+
* @param {string} poolKey The key to identify the pool
|
|
165
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
166
|
+
* @returns A function that takes a Transaction object
|
|
167
|
+
*/
|
|
168
|
+
borrowedBaseShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
169
|
+
/**
|
|
170
|
+
* @description Get borrowed quote shares
|
|
171
|
+
* @param {string} poolKey The key to identify the pool
|
|
172
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
173
|
+
* @returns A function that takes a Transaction object
|
|
174
|
+
*/
|
|
175
|
+
borrowedQuoteShares: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
176
|
+
/**
|
|
177
|
+
* @description Check if margin manager has base asset debt
|
|
178
|
+
* @param {string} poolKey The key to identify the pool
|
|
179
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
180
|
+
* @returns A function that takes a Transaction object
|
|
181
|
+
*/
|
|
182
|
+
hasBaseDebt: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
183
|
+
/**
|
|
184
|
+
* @description Get the balance manager ID for a margin manager
|
|
185
|
+
* @param {string} poolKey The key to identify the pool
|
|
186
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
187
|
+
* @returns A function that takes a Transaction object
|
|
188
|
+
*/
|
|
189
|
+
balanceManager: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
190
|
+
/**
|
|
191
|
+
* @description Calculate assets (base and quote) for a margin manager
|
|
192
|
+
* @param {string} poolKey The key to identify the pool
|
|
193
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
194
|
+
* @returns A function that takes a Transaction object
|
|
195
|
+
*/
|
|
196
|
+
calculateAssets: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
197
|
+
/**
|
|
198
|
+
* @description Calculate debts (base and quote) for a margin manager
|
|
199
|
+
* @param {string} poolKey The key to identify the pool
|
|
200
|
+
* @param {string} coinKey The key to identify the debt coin (base or quote)
|
|
201
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
202
|
+
* @returns A function that takes a Transaction object
|
|
203
|
+
*/
|
|
204
|
+
calculateDebts: (poolKey: string, coinKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
205
|
+
/**
|
|
206
|
+
* @description Get comprehensive state information for a margin manager
|
|
207
|
+
* @param {string} poolKey The key to identify the pool
|
|
208
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
209
|
+
* @returns A function that takes a Transaction object
|
|
210
|
+
* @returns Returns (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset,
|
|
211
|
+
* base_debt, quote_debt, base_pyth_price, base_pyth_decimals,
|
|
212
|
+
* quote_pyth_price, quote_pyth_decimals)
|
|
213
|
+
*/
|
|
214
|
+
managerState: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
215
|
+
/**
|
|
216
|
+
* @description Get the base asset balance of a margin manager
|
|
217
|
+
* @param {string} poolKey The key to identify the pool
|
|
218
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
219
|
+
* @returns A function that takes a Transaction object
|
|
220
|
+
*/
|
|
221
|
+
baseBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
222
|
+
/**
|
|
223
|
+
* @description Get the quote asset balance of a margin manager
|
|
224
|
+
* @param {string} poolKey The key to identify the pool
|
|
225
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
226
|
+
* @returns A function that takes a Transaction object
|
|
227
|
+
*/
|
|
228
|
+
quoteBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
229
|
+
/**
|
|
230
|
+
* @description Get the DEEP token balance of a margin manager
|
|
231
|
+
* @param {string} poolKey The key to identify the pool
|
|
232
|
+
* @param {string} marginManagerId The ID of the margin manager
|
|
233
|
+
* @returns A function that takes a Transaction object
|
|
234
|
+
*/
|
|
235
|
+
deepBalance: (poolKey: string, marginManagerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
236
|
+
}
|