@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,2269 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/** Public-facing interface for the package. */
|
|
5
|
+
|
|
6
|
+
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
7
|
+
import type { RawTransactionArgument } from '../utils/index.js';
|
|
8
|
+
import { bcs } from '@haneullabs/haneul/bcs';
|
|
9
|
+
import type { BcsType } from '@haneullabs/haneul/bcs';
|
|
10
|
+
import type { Transaction } from '@haneullabs/haneul/transactions';
|
|
11
|
+
import * as object from './deps/sui/object.js';
|
|
12
|
+
import * as versioned from './deps/sui/versioned.js';
|
|
13
|
+
import * as vec_set from './deps/sui/vec_set.js';
|
|
14
|
+
import * as book from './book.js';
|
|
15
|
+
import * as state from './state.js';
|
|
16
|
+
import * as vault from './vault.js';
|
|
17
|
+
import * as deep_price from './deep_price.js';
|
|
18
|
+
const $moduleName = '@deepbook/core::pool';
|
|
19
|
+
export const Pool = new MoveStruct({
|
|
20
|
+
name: `${$moduleName}::Pool`,
|
|
21
|
+
fields: {
|
|
22
|
+
id: object.UID,
|
|
23
|
+
inner: versioned.Versioned,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
export const PoolInner = new MoveStruct({
|
|
27
|
+
name: `${$moduleName}::PoolInner`,
|
|
28
|
+
fields: {
|
|
29
|
+
allowed_versions: vec_set.VecSet(bcs.u64()),
|
|
30
|
+
pool_id: bcs.Address,
|
|
31
|
+
book: book.Book,
|
|
32
|
+
state: state.State,
|
|
33
|
+
vault: vault.Vault,
|
|
34
|
+
deep_price: deep_price.DeepPrice,
|
|
35
|
+
registered_pool: bcs.bool(),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export const PoolCreated = new MoveStruct({
|
|
39
|
+
name: `${$moduleName}::PoolCreated`,
|
|
40
|
+
fields: {
|
|
41
|
+
pool_id: bcs.Address,
|
|
42
|
+
taker_fee: bcs.u64(),
|
|
43
|
+
maker_fee: bcs.u64(),
|
|
44
|
+
tick_size: bcs.u64(),
|
|
45
|
+
lot_size: bcs.u64(),
|
|
46
|
+
min_size: bcs.u64(),
|
|
47
|
+
whitelisted_pool: bcs.bool(),
|
|
48
|
+
treasury_address: bcs.Address,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
export const BookParamsUpdated = new MoveStruct({
|
|
52
|
+
name: `${$moduleName}::BookParamsUpdated`,
|
|
53
|
+
fields: {
|
|
54
|
+
pool_id: bcs.Address,
|
|
55
|
+
tick_size: bcs.u64(),
|
|
56
|
+
lot_size: bcs.u64(),
|
|
57
|
+
min_size: bcs.u64(),
|
|
58
|
+
timestamp: bcs.u64(),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export const DeepBurned = new MoveStruct({
|
|
62
|
+
name: `${$moduleName}::DeepBurned`,
|
|
63
|
+
fields: {
|
|
64
|
+
pool_id: bcs.Address,
|
|
65
|
+
deep_burned: bcs.u64(),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
export const AppKey = new MoveStruct({
|
|
69
|
+
name: `${$moduleName}::AppKey`,
|
|
70
|
+
fields: {
|
|
71
|
+
dummy_field: bcs.bool(),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
export const MarginTradingKey = new MoveStruct({
|
|
75
|
+
name: `${$moduleName}::MarginTradingKey`,
|
|
76
|
+
fields: {
|
|
77
|
+
dummy_field: bcs.bool(),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
export interface CreatePermissionlessPoolArguments {
|
|
81
|
+
registry: RawTransactionArgument<string>;
|
|
82
|
+
tickSize: RawTransactionArgument<number | bigint>;
|
|
83
|
+
lotSize: RawTransactionArgument<number | bigint>;
|
|
84
|
+
minSize: RawTransactionArgument<number | bigint>;
|
|
85
|
+
creationFee: RawTransactionArgument<string>;
|
|
86
|
+
}
|
|
87
|
+
export interface CreatePermissionlessPoolOptions {
|
|
88
|
+
package?: string;
|
|
89
|
+
arguments:
|
|
90
|
+
| CreatePermissionlessPoolArguments
|
|
91
|
+
| [
|
|
92
|
+
registry: RawTransactionArgument<string>,
|
|
93
|
+
tickSize: RawTransactionArgument<number | bigint>,
|
|
94
|
+
lotSize: RawTransactionArgument<number | bigint>,
|
|
95
|
+
minSize: RawTransactionArgument<number | bigint>,
|
|
96
|
+
creationFee: RawTransactionArgument<string>,
|
|
97
|
+
];
|
|
98
|
+
typeArguments: [string, string];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new pool. The pool is registered in the registry. Checks are performed
|
|
102
|
+
* to ensure the tick size, lot size, and min size are valid. The creation fee is
|
|
103
|
+
* transferred to the treasury address. Returns the id of the pool created
|
|
104
|
+
*/
|
|
105
|
+
export function createPermissionlessPool(options: CreatePermissionlessPoolOptions) {
|
|
106
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
107
|
+
const argumentsTypes = [
|
|
108
|
+
`${packageAddress}::registry::Registry`,
|
|
109
|
+
'u64',
|
|
110
|
+
'u64',
|
|
111
|
+
'u64',
|
|
112
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::deep::DEEP>`,
|
|
113
|
+
] satisfies string[];
|
|
114
|
+
const parameterNames = ['registry', 'tickSize', 'lotSize', 'minSize', 'creationFee'];
|
|
115
|
+
return (tx: Transaction) =>
|
|
116
|
+
tx.moveCall({
|
|
117
|
+
package: packageAddress,
|
|
118
|
+
module: 'pool',
|
|
119
|
+
function: 'create_permissionless_pool',
|
|
120
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
121
|
+
typeArguments: options.typeArguments,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export interface PlaceLimitOrderArguments {
|
|
125
|
+
self: RawTransactionArgument<string>;
|
|
126
|
+
balanceManager: RawTransactionArgument<string>;
|
|
127
|
+
tradeProof: RawTransactionArgument<string>;
|
|
128
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
129
|
+
orderType: RawTransactionArgument<number>;
|
|
130
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
131
|
+
price: RawTransactionArgument<number | bigint>;
|
|
132
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
133
|
+
isBid: RawTransactionArgument<boolean>;
|
|
134
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
135
|
+
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
136
|
+
}
|
|
137
|
+
export interface PlaceLimitOrderOptions {
|
|
138
|
+
package?: string;
|
|
139
|
+
arguments:
|
|
140
|
+
| PlaceLimitOrderArguments
|
|
141
|
+
| [
|
|
142
|
+
self: RawTransactionArgument<string>,
|
|
143
|
+
balanceManager: RawTransactionArgument<string>,
|
|
144
|
+
tradeProof: RawTransactionArgument<string>,
|
|
145
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
146
|
+
orderType: RawTransactionArgument<number>,
|
|
147
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
148
|
+
price: RawTransactionArgument<number | bigint>,
|
|
149
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
150
|
+
isBid: RawTransactionArgument<boolean>,
|
|
151
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
152
|
+
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
153
|
+
];
|
|
154
|
+
typeArguments: [string, string];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Place a limit order. Quantity is in base asset terms. For current version
|
|
158
|
+
* pay_with_deep must be true, so the fee will be paid with DEEP tokens.
|
|
159
|
+
*/
|
|
160
|
+
export function placeLimitOrder(options: PlaceLimitOrderOptions) {
|
|
161
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
162
|
+
const argumentsTypes = [
|
|
163
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
164
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
165
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
166
|
+
'u64',
|
|
167
|
+
'u8',
|
|
168
|
+
'u8',
|
|
169
|
+
'u64',
|
|
170
|
+
'u64',
|
|
171
|
+
'bool',
|
|
172
|
+
'bool',
|
|
173
|
+
'u64',
|
|
174
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
175
|
+
] satisfies string[];
|
|
176
|
+
const parameterNames = [
|
|
177
|
+
'self',
|
|
178
|
+
'balanceManager',
|
|
179
|
+
'tradeProof',
|
|
180
|
+
'clientOrderId',
|
|
181
|
+
'orderType',
|
|
182
|
+
'selfMatchingOption',
|
|
183
|
+
'price',
|
|
184
|
+
'quantity',
|
|
185
|
+
'isBid',
|
|
186
|
+
'payWithDeep',
|
|
187
|
+
'expireTimestamp',
|
|
188
|
+
'clock',
|
|
189
|
+
];
|
|
190
|
+
return (tx: Transaction) =>
|
|
191
|
+
tx.moveCall({
|
|
192
|
+
package: packageAddress,
|
|
193
|
+
module: 'pool',
|
|
194
|
+
function: 'place_limit_order',
|
|
195
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
196
|
+
typeArguments: options.typeArguments,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
export interface PlaceMarketOrderArguments {
|
|
200
|
+
self: RawTransactionArgument<string>;
|
|
201
|
+
balanceManager: RawTransactionArgument<string>;
|
|
202
|
+
tradeProof: RawTransactionArgument<string>;
|
|
203
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
204
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
205
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
206
|
+
isBid: RawTransactionArgument<boolean>;
|
|
207
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
208
|
+
}
|
|
209
|
+
export interface PlaceMarketOrderOptions {
|
|
210
|
+
package?: string;
|
|
211
|
+
arguments:
|
|
212
|
+
| PlaceMarketOrderArguments
|
|
213
|
+
| [
|
|
214
|
+
self: RawTransactionArgument<string>,
|
|
215
|
+
balanceManager: RawTransactionArgument<string>,
|
|
216
|
+
tradeProof: RawTransactionArgument<string>,
|
|
217
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
218
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
219
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
220
|
+
isBid: RawTransactionArgument<boolean>,
|
|
221
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
222
|
+
];
|
|
223
|
+
typeArguments: [string, string];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Place a market order. Quantity is in base asset terms. Calls place_limit_order
|
|
227
|
+
* with a price of MAX_PRICE for bids and MIN_PRICE for asks. Any quantity not
|
|
228
|
+
* filled is cancelled.
|
|
229
|
+
*/
|
|
230
|
+
export function placeMarketOrder(options: PlaceMarketOrderOptions) {
|
|
231
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
232
|
+
const argumentsTypes = [
|
|
233
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
234
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
235
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
236
|
+
'u64',
|
|
237
|
+
'u8',
|
|
238
|
+
'u64',
|
|
239
|
+
'bool',
|
|
240
|
+
'bool',
|
|
241
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
242
|
+
] satisfies string[];
|
|
243
|
+
const parameterNames = [
|
|
244
|
+
'self',
|
|
245
|
+
'balanceManager',
|
|
246
|
+
'tradeProof',
|
|
247
|
+
'clientOrderId',
|
|
248
|
+
'selfMatchingOption',
|
|
249
|
+
'quantity',
|
|
250
|
+
'isBid',
|
|
251
|
+
'payWithDeep',
|
|
252
|
+
'clock',
|
|
253
|
+
];
|
|
254
|
+
return (tx: Transaction) =>
|
|
255
|
+
tx.moveCall({
|
|
256
|
+
package: packageAddress,
|
|
257
|
+
module: 'pool',
|
|
258
|
+
function: 'place_market_order',
|
|
259
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
260
|
+
typeArguments: options.typeArguments,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
export interface SwapExactBaseForQuoteArguments {
|
|
264
|
+
self: RawTransactionArgument<string>;
|
|
265
|
+
baseIn: RawTransactionArgument<string>;
|
|
266
|
+
deepIn: RawTransactionArgument<string>;
|
|
267
|
+
minQuoteOut: RawTransactionArgument<number | bigint>;
|
|
268
|
+
}
|
|
269
|
+
export interface SwapExactBaseForQuoteOptions {
|
|
270
|
+
package?: string;
|
|
271
|
+
arguments:
|
|
272
|
+
| SwapExactBaseForQuoteArguments
|
|
273
|
+
| [
|
|
274
|
+
self: RawTransactionArgument<string>,
|
|
275
|
+
baseIn: RawTransactionArgument<string>,
|
|
276
|
+
deepIn: RawTransactionArgument<string>,
|
|
277
|
+
minQuoteOut: RawTransactionArgument<number | bigint>,
|
|
278
|
+
];
|
|
279
|
+
typeArguments: [string, string];
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Swap exact base quantity without needing a `balance_manager`. DEEP quantity can
|
|
283
|
+
* be overestimated. Returns three `Coin` objects: base, quote, and deep. Some base
|
|
284
|
+
* quantity may be left over, if the input quantity is not divisible by lot size.
|
|
285
|
+
*/
|
|
286
|
+
export function swapExactBaseForQuote(options: SwapExactBaseForQuoteOptions) {
|
|
287
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
288
|
+
const argumentsTypes = [
|
|
289
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
290
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[0]}>`,
|
|
291
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::deep::DEEP>`,
|
|
292
|
+
'u64',
|
|
293
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
294
|
+
] satisfies string[];
|
|
295
|
+
const parameterNames = ['self', 'baseIn', 'deepIn', 'minQuoteOut', 'clock'];
|
|
296
|
+
return (tx: Transaction) =>
|
|
297
|
+
tx.moveCall({
|
|
298
|
+
package: packageAddress,
|
|
299
|
+
module: 'pool',
|
|
300
|
+
function: 'swap_exact_base_for_quote',
|
|
301
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
302
|
+
typeArguments: options.typeArguments,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
export interface SwapExactQuoteForBaseArguments {
|
|
306
|
+
self: RawTransactionArgument<string>;
|
|
307
|
+
quoteIn: RawTransactionArgument<string>;
|
|
308
|
+
deepIn: RawTransactionArgument<string>;
|
|
309
|
+
minBaseOut: RawTransactionArgument<number | bigint>;
|
|
310
|
+
}
|
|
311
|
+
export interface SwapExactQuoteForBaseOptions {
|
|
312
|
+
package?: string;
|
|
313
|
+
arguments:
|
|
314
|
+
| SwapExactQuoteForBaseArguments
|
|
315
|
+
| [
|
|
316
|
+
self: RawTransactionArgument<string>,
|
|
317
|
+
quoteIn: RawTransactionArgument<string>,
|
|
318
|
+
deepIn: RawTransactionArgument<string>,
|
|
319
|
+
minBaseOut: RawTransactionArgument<number | bigint>,
|
|
320
|
+
];
|
|
321
|
+
typeArguments: [string, string];
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Swap exact quote quantity without needing a `balance_manager`. DEEP quantity can
|
|
325
|
+
* be overestimated. Returns three `Coin` objects: base, quote, and deep. Some
|
|
326
|
+
* quote quantity may be left over if the input quantity is not divisible by lot
|
|
327
|
+
* size.
|
|
328
|
+
*/
|
|
329
|
+
export function swapExactQuoteForBase(options: SwapExactQuoteForBaseOptions) {
|
|
330
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
331
|
+
const argumentsTypes = [
|
|
332
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
333
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`,
|
|
334
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::deep::DEEP>`,
|
|
335
|
+
'u64',
|
|
336
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
337
|
+
] satisfies string[];
|
|
338
|
+
const parameterNames = ['self', 'quoteIn', 'deepIn', 'minBaseOut', 'clock'];
|
|
339
|
+
return (tx: Transaction) =>
|
|
340
|
+
tx.moveCall({
|
|
341
|
+
package: packageAddress,
|
|
342
|
+
module: 'pool',
|
|
343
|
+
function: 'swap_exact_quote_for_base',
|
|
344
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
345
|
+
typeArguments: options.typeArguments,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
export interface SwapExactQuantityArguments {
|
|
349
|
+
self: RawTransactionArgument<string>;
|
|
350
|
+
baseIn: RawTransactionArgument<string>;
|
|
351
|
+
quoteIn: RawTransactionArgument<string>;
|
|
352
|
+
deepIn: RawTransactionArgument<string>;
|
|
353
|
+
minOut: RawTransactionArgument<number | bigint>;
|
|
354
|
+
}
|
|
355
|
+
export interface SwapExactQuantityOptions {
|
|
356
|
+
package?: string;
|
|
357
|
+
arguments:
|
|
358
|
+
| SwapExactQuantityArguments
|
|
359
|
+
| [
|
|
360
|
+
self: RawTransactionArgument<string>,
|
|
361
|
+
baseIn: RawTransactionArgument<string>,
|
|
362
|
+
quoteIn: RawTransactionArgument<string>,
|
|
363
|
+
deepIn: RawTransactionArgument<string>,
|
|
364
|
+
minOut: RawTransactionArgument<number | bigint>,
|
|
365
|
+
];
|
|
366
|
+
typeArguments: [string, string];
|
|
367
|
+
}
|
|
368
|
+
/** Swap exact quantity without needing a balance_manager. */
|
|
369
|
+
export function swapExactQuantity(options: SwapExactQuantityOptions) {
|
|
370
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
371
|
+
const argumentsTypes = [
|
|
372
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
373
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[0]}>`,
|
|
374
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`,
|
|
375
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::deep::DEEP>`,
|
|
376
|
+
'u64',
|
|
377
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
378
|
+
] satisfies string[];
|
|
379
|
+
const parameterNames = ['self', 'baseIn', 'quoteIn', 'deepIn', 'minOut', 'clock'];
|
|
380
|
+
return (tx: Transaction) =>
|
|
381
|
+
tx.moveCall({
|
|
382
|
+
package: packageAddress,
|
|
383
|
+
module: 'pool',
|
|
384
|
+
function: 'swap_exact_quantity',
|
|
385
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
386
|
+
typeArguments: options.typeArguments,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
export interface ModifyOrderArguments {
|
|
390
|
+
self: RawTransactionArgument<string>;
|
|
391
|
+
balanceManager: RawTransactionArgument<string>;
|
|
392
|
+
tradeProof: RawTransactionArgument<string>;
|
|
393
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
394
|
+
newQuantity: RawTransactionArgument<number | bigint>;
|
|
395
|
+
}
|
|
396
|
+
export interface ModifyOrderOptions {
|
|
397
|
+
package?: string;
|
|
398
|
+
arguments:
|
|
399
|
+
| ModifyOrderArguments
|
|
400
|
+
| [
|
|
401
|
+
self: RawTransactionArgument<string>,
|
|
402
|
+
balanceManager: RawTransactionArgument<string>,
|
|
403
|
+
tradeProof: RawTransactionArgument<string>,
|
|
404
|
+
orderId: RawTransactionArgument<number | bigint>,
|
|
405
|
+
newQuantity: RawTransactionArgument<number | bigint>,
|
|
406
|
+
];
|
|
407
|
+
typeArguments: [string, string];
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Modifies an order given order_id and new_quantity. New quantity must be less
|
|
411
|
+
* than the original quantity and more than the filled quantity. Order must not
|
|
412
|
+
* have already expired.
|
|
413
|
+
*/
|
|
414
|
+
export function modifyOrder(options: ModifyOrderOptions) {
|
|
415
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
416
|
+
const argumentsTypes = [
|
|
417
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
418
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
419
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
420
|
+
'u128',
|
|
421
|
+
'u64',
|
|
422
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
423
|
+
] satisfies string[];
|
|
424
|
+
const parameterNames = [
|
|
425
|
+
'self',
|
|
426
|
+
'balanceManager',
|
|
427
|
+
'tradeProof',
|
|
428
|
+
'orderId',
|
|
429
|
+
'newQuantity',
|
|
430
|
+
'clock',
|
|
431
|
+
];
|
|
432
|
+
return (tx: Transaction) =>
|
|
433
|
+
tx.moveCall({
|
|
434
|
+
package: packageAddress,
|
|
435
|
+
module: 'pool',
|
|
436
|
+
function: 'modify_order',
|
|
437
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
438
|
+
typeArguments: options.typeArguments,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
export interface CancelOrderArguments {
|
|
442
|
+
self: RawTransactionArgument<string>;
|
|
443
|
+
balanceManager: RawTransactionArgument<string>;
|
|
444
|
+
tradeProof: RawTransactionArgument<string>;
|
|
445
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
446
|
+
}
|
|
447
|
+
export interface CancelOrderOptions {
|
|
448
|
+
package?: string;
|
|
449
|
+
arguments:
|
|
450
|
+
| CancelOrderArguments
|
|
451
|
+
| [
|
|
452
|
+
self: RawTransactionArgument<string>,
|
|
453
|
+
balanceManager: RawTransactionArgument<string>,
|
|
454
|
+
tradeProof: RawTransactionArgument<string>,
|
|
455
|
+
orderId: RawTransactionArgument<number | bigint>,
|
|
456
|
+
];
|
|
457
|
+
typeArguments: [string, string];
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Cancel an order. The order must be owned by the balance_manager. The order is
|
|
461
|
+
* removed from the book and the balance_manager's open orders. The
|
|
462
|
+
* balance_manager's balance is updated with the order's remaining quantity. Order
|
|
463
|
+
* canceled event is emitted.
|
|
464
|
+
*/
|
|
465
|
+
export function cancelOrder(options: CancelOrderOptions) {
|
|
466
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
467
|
+
const argumentsTypes = [
|
|
468
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
469
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
470
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
471
|
+
'u128',
|
|
472
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
473
|
+
] satisfies string[];
|
|
474
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId', 'clock'];
|
|
475
|
+
return (tx: Transaction) =>
|
|
476
|
+
tx.moveCall({
|
|
477
|
+
package: packageAddress,
|
|
478
|
+
module: 'pool',
|
|
479
|
+
function: 'cancel_order',
|
|
480
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
481
|
+
typeArguments: options.typeArguments,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
export interface CancelOrdersArguments {
|
|
485
|
+
self: RawTransactionArgument<string>;
|
|
486
|
+
balanceManager: RawTransactionArgument<string>;
|
|
487
|
+
tradeProof: RawTransactionArgument<string>;
|
|
488
|
+
orderIds: RawTransactionArgument<number | bigint[]>;
|
|
489
|
+
}
|
|
490
|
+
export interface CancelOrdersOptions {
|
|
491
|
+
package?: string;
|
|
492
|
+
arguments:
|
|
493
|
+
| CancelOrdersArguments
|
|
494
|
+
| [
|
|
495
|
+
self: RawTransactionArgument<string>,
|
|
496
|
+
balanceManager: RawTransactionArgument<string>,
|
|
497
|
+
tradeProof: RawTransactionArgument<string>,
|
|
498
|
+
orderIds: RawTransactionArgument<number | bigint[]>,
|
|
499
|
+
];
|
|
500
|
+
typeArguments: [string, string];
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Cancel multiple orders within a vector. The orders must be owned by the
|
|
504
|
+
* balance_manager. The orders are removed from the book and the balance_manager's
|
|
505
|
+
* open orders. Order canceled events are emitted. If any order fails to cancel, no
|
|
506
|
+
* orders will be cancelled.
|
|
507
|
+
*/
|
|
508
|
+
export function cancelOrders(options: CancelOrdersOptions) {
|
|
509
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
510
|
+
const argumentsTypes = [
|
|
511
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
512
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
513
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
514
|
+
'vector<u128>',
|
|
515
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
516
|
+
] satisfies string[];
|
|
517
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderIds', 'clock'];
|
|
518
|
+
return (tx: Transaction) =>
|
|
519
|
+
tx.moveCall({
|
|
520
|
+
package: packageAddress,
|
|
521
|
+
module: 'pool',
|
|
522
|
+
function: 'cancel_orders',
|
|
523
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
524
|
+
typeArguments: options.typeArguments,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
export interface CancelAllOrdersArguments {
|
|
528
|
+
self: RawTransactionArgument<string>;
|
|
529
|
+
balanceManager: RawTransactionArgument<string>;
|
|
530
|
+
tradeProof: RawTransactionArgument<string>;
|
|
531
|
+
}
|
|
532
|
+
export interface CancelAllOrdersOptions {
|
|
533
|
+
package?: string;
|
|
534
|
+
arguments:
|
|
535
|
+
| CancelAllOrdersArguments
|
|
536
|
+
| [
|
|
537
|
+
self: RawTransactionArgument<string>,
|
|
538
|
+
balanceManager: RawTransactionArgument<string>,
|
|
539
|
+
tradeProof: RawTransactionArgument<string>,
|
|
540
|
+
];
|
|
541
|
+
typeArguments: [string, string];
|
|
542
|
+
}
|
|
543
|
+
/** Cancel all open orders placed by the balance manager in the pool. */
|
|
544
|
+
export function cancelAllOrders(options: CancelAllOrdersOptions) {
|
|
545
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
546
|
+
const argumentsTypes = [
|
|
547
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
548
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
549
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
550
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
551
|
+
] satisfies string[];
|
|
552
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'clock'];
|
|
553
|
+
return (tx: Transaction) =>
|
|
554
|
+
tx.moveCall({
|
|
555
|
+
package: packageAddress,
|
|
556
|
+
module: 'pool',
|
|
557
|
+
function: 'cancel_all_orders',
|
|
558
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
559
|
+
typeArguments: options.typeArguments,
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
export interface WithdrawSettledAmountsArguments {
|
|
563
|
+
self: RawTransactionArgument<string>;
|
|
564
|
+
balanceManager: RawTransactionArgument<string>;
|
|
565
|
+
tradeProof: RawTransactionArgument<string>;
|
|
566
|
+
}
|
|
567
|
+
export interface WithdrawSettledAmountsOptions {
|
|
568
|
+
package?: string;
|
|
569
|
+
arguments:
|
|
570
|
+
| WithdrawSettledAmountsArguments
|
|
571
|
+
| [
|
|
572
|
+
self: RawTransactionArgument<string>,
|
|
573
|
+
balanceManager: RawTransactionArgument<string>,
|
|
574
|
+
tradeProof: RawTransactionArgument<string>,
|
|
575
|
+
];
|
|
576
|
+
typeArguments: [string, string];
|
|
577
|
+
}
|
|
578
|
+
/** Withdraw settled amounts to the `balance_manager`. */
|
|
579
|
+
export function withdrawSettledAmounts(options: WithdrawSettledAmountsOptions) {
|
|
580
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
581
|
+
const argumentsTypes = [
|
|
582
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
583
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
584
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
585
|
+
] satisfies string[];
|
|
586
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof'];
|
|
587
|
+
return (tx: Transaction) =>
|
|
588
|
+
tx.moveCall({
|
|
589
|
+
package: packageAddress,
|
|
590
|
+
module: 'pool',
|
|
591
|
+
function: 'withdraw_settled_amounts',
|
|
592
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
593
|
+
typeArguments: options.typeArguments,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
export interface StakeArguments {
|
|
597
|
+
self: RawTransactionArgument<string>;
|
|
598
|
+
balanceManager: RawTransactionArgument<string>;
|
|
599
|
+
tradeProof: RawTransactionArgument<string>;
|
|
600
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
601
|
+
}
|
|
602
|
+
export interface StakeOptions {
|
|
603
|
+
package?: string;
|
|
604
|
+
arguments:
|
|
605
|
+
| StakeArguments
|
|
606
|
+
| [
|
|
607
|
+
self: RawTransactionArgument<string>,
|
|
608
|
+
balanceManager: RawTransactionArgument<string>,
|
|
609
|
+
tradeProof: RawTransactionArgument<string>,
|
|
610
|
+
amount: RawTransactionArgument<number | bigint>,
|
|
611
|
+
];
|
|
612
|
+
typeArguments: [string, string];
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Stake DEEP tokens to the pool. The balance_manager must have enough DEEP tokens.
|
|
616
|
+
* The balance_manager's data is updated with the staked amount.
|
|
617
|
+
*/
|
|
618
|
+
export function stake(options: StakeOptions) {
|
|
619
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
620
|
+
const argumentsTypes = [
|
|
621
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
622
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
623
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
624
|
+
'u64',
|
|
625
|
+
] satisfies string[];
|
|
626
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'amount'];
|
|
627
|
+
return (tx: Transaction) =>
|
|
628
|
+
tx.moveCall({
|
|
629
|
+
package: packageAddress,
|
|
630
|
+
module: 'pool',
|
|
631
|
+
function: 'stake',
|
|
632
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
633
|
+
typeArguments: options.typeArguments,
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
export interface UnstakeArguments {
|
|
637
|
+
self: RawTransactionArgument<string>;
|
|
638
|
+
balanceManager: RawTransactionArgument<string>;
|
|
639
|
+
tradeProof: RawTransactionArgument<string>;
|
|
640
|
+
}
|
|
641
|
+
export interface UnstakeOptions {
|
|
642
|
+
package?: string;
|
|
643
|
+
arguments:
|
|
644
|
+
| UnstakeArguments
|
|
645
|
+
| [
|
|
646
|
+
self: RawTransactionArgument<string>,
|
|
647
|
+
balanceManager: RawTransactionArgument<string>,
|
|
648
|
+
tradeProof: RawTransactionArgument<string>,
|
|
649
|
+
];
|
|
650
|
+
typeArguments: [string, string];
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Unstake DEEP tokens from the pool. The balance_manager must have enough staked
|
|
654
|
+
* DEEP tokens. The balance_manager's data is updated with the unstaked amount.
|
|
655
|
+
* Balance is transferred to the balance_manager immediately.
|
|
656
|
+
*/
|
|
657
|
+
export function unstake(options: UnstakeOptions) {
|
|
658
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
659
|
+
const argumentsTypes = [
|
|
660
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
661
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
662
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
663
|
+
] satisfies string[];
|
|
664
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof'];
|
|
665
|
+
return (tx: Transaction) =>
|
|
666
|
+
tx.moveCall({
|
|
667
|
+
package: packageAddress,
|
|
668
|
+
module: 'pool',
|
|
669
|
+
function: 'unstake',
|
|
670
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
671
|
+
typeArguments: options.typeArguments,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
export interface SubmitProposalArguments {
|
|
675
|
+
self: RawTransactionArgument<string>;
|
|
676
|
+
balanceManager: RawTransactionArgument<string>;
|
|
677
|
+
tradeProof: RawTransactionArgument<string>;
|
|
678
|
+
takerFee: RawTransactionArgument<number | bigint>;
|
|
679
|
+
makerFee: RawTransactionArgument<number | bigint>;
|
|
680
|
+
stakeRequired: RawTransactionArgument<number | bigint>;
|
|
681
|
+
}
|
|
682
|
+
export interface SubmitProposalOptions {
|
|
683
|
+
package?: string;
|
|
684
|
+
arguments:
|
|
685
|
+
| SubmitProposalArguments
|
|
686
|
+
| [
|
|
687
|
+
self: RawTransactionArgument<string>,
|
|
688
|
+
balanceManager: RawTransactionArgument<string>,
|
|
689
|
+
tradeProof: RawTransactionArgument<string>,
|
|
690
|
+
takerFee: RawTransactionArgument<number | bigint>,
|
|
691
|
+
makerFee: RawTransactionArgument<number | bigint>,
|
|
692
|
+
stakeRequired: RawTransactionArgument<number | bigint>,
|
|
693
|
+
];
|
|
694
|
+
typeArguments: [string, string];
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Submit a proposal to change the taker fee, maker fee, and stake required. The
|
|
698
|
+
* balance_manager must have enough staked DEEP tokens to participate. Each
|
|
699
|
+
* balance_manager can only submit one proposal per epoch. If the maximum proposal
|
|
700
|
+
* is reached, the proposal with the lowest vote is removed. If the balance_manager
|
|
701
|
+
* has less voting power than the lowest voted proposal, the proposal is not added.
|
|
702
|
+
*/
|
|
703
|
+
export function submitProposal(options: SubmitProposalOptions) {
|
|
704
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
705
|
+
const argumentsTypes = [
|
|
706
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
707
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
708
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
709
|
+
'u64',
|
|
710
|
+
'u64',
|
|
711
|
+
'u64',
|
|
712
|
+
] satisfies string[];
|
|
713
|
+
const parameterNames = [
|
|
714
|
+
'self',
|
|
715
|
+
'balanceManager',
|
|
716
|
+
'tradeProof',
|
|
717
|
+
'takerFee',
|
|
718
|
+
'makerFee',
|
|
719
|
+
'stakeRequired',
|
|
720
|
+
];
|
|
721
|
+
return (tx: Transaction) =>
|
|
722
|
+
tx.moveCall({
|
|
723
|
+
package: packageAddress,
|
|
724
|
+
module: 'pool',
|
|
725
|
+
function: 'submit_proposal',
|
|
726
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
727
|
+
typeArguments: options.typeArguments,
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
export interface VoteArguments {
|
|
731
|
+
self: RawTransactionArgument<string>;
|
|
732
|
+
balanceManager: RawTransactionArgument<string>;
|
|
733
|
+
tradeProof: RawTransactionArgument<string>;
|
|
734
|
+
proposalId: RawTransactionArgument<string>;
|
|
735
|
+
}
|
|
736
|
+
export interface VoteOptions {
|
|
737
|
+
package?: string;
|
|
738
|
+
arguments:
|
|
739
|
+
| VoteArguments
|
|
740
|
+
| [
|
|
741
|
+
self: RawTransactionArgument<string>,
|
|
742
|
+
balanceManager: RawTransactionArgument<string>,
|
|
743
|
+
tradeProof: RawTransactionArgument<string>,
|
|
744
|
+
proposalId: RawTransactionArgument<string>,
|
|
745
|
+
];
|
|
746
|
+
typeArguments: [string, string];
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Vote on a proposal. The balance_manager must have enough staked DEEP tokens to
|
|
750
|
+
* participate. Full voting power of the balance_manager is used. Voting for a new
|
|
751
|
+
* proposal will remove the vote from the previous proposal.
|
|
752
|
+
*/
|
|
753
|
+
export function vote(options: VoteOptions) {
|
|
754
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
755
|
+
const argumentsTypes = [
|
|
756
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
757
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
758
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
759
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::object::ID',
|
|
760
|
+
] satisfies string[];
|
|
761
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'proposalId'];
|
|
762
|
+
return (tx: Transaction) =>
|
|
763
|
+
tx.moveCall({
|
|
764
|
+
package: packageAddress,
|
|
765
|
+
module: 'pool',
|
|
766
|
+
function: 'vote',
|
|
767
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
768
|
+
typeArguments: options.typeArguments,
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
export interface ClaimRebatesArguments {
|
|
772
|
+
self: RawTransactionArgument<string>;
|
|
773
|
+
balanceManager: RawTransactionArgument<string>;
|
|
774
|
+
tradeProof: RawTransactionArgument<string>;
|
|
775
|
+
}
|
|
776
|
+
export interface ClaimRebatesOptions {
|
|
777
|
+
package?: string;
|
|
778
|
+
arguments:
|
|
779
|
+
| ClaimRebatesArguments
|
|
780
|
+
| [
|
|
781
|
+
self: RawTransactionArgument<string>,
|
|
782
|
+
balanceManager: RawTransactionArgument<string>,
|
|
783
|
+
tradeProof: RawTransactionArgument<string>,
|
|
784
|
+
];
|
|
785
|
+
typeArguments: [string, string];
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Claim the rewards for the balance_manager. The balance_manager must have rewards
|
|
789
|
+
* to claim. The balance_manager's data is updated with the claimed rewards.
|
|
790
|
+
*/
|
|
791
|
+
export function claimRebates(options: ClaimRebatesOptions) {
|
|
792
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
793
|
+
const argumentsTypes = [
|
|
794
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
795
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
796
|
+
`${packageAddress}::balance_manager::TradeProof`,
|
|
797
|
+
] satisfies string[];
|
|
798
|
+
const parameterNames = ['self', 'balanceManager', 'tradeProof'];
|
|
799
|
+
return (tx: Transaction) =>
|
|
800
|
+
tx.moveCall({
|
|
801
|
+
package: packageAddress,
|
|
802
|
+
module: 'pool',
|
|
803
|
+
function: 'claim_rebates',
|
|
804
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
805
|
+
typeArguments: options.typeArguments,
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
export interface BorrowFlashloanBaseArguments {
|
|
809
|
+
self: RawTransactionArgument<string>;
|
|
810
|
+
baseAmount: RawTransactionArgument<number | bigint>;
|
|
811
|
+
}
|
|
812
|
+
export interface BorrowFlashloanBaseOptions {
|
|
813
|
+
package?: string;
|
|
814
|
+
arguments:
|
|
815
|
+
| BorrowFlashloanBaseArguments
|
|
816
|
+
| [self: RawTransactionArgument<string>, baseAmount: RawTransactionArgument<number | bigint>];
|
|
817
|
+
typeArguments: [string, string];
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Borrow base assets from the Pool. A hot potato is returned, forcing the borrower
|
|
821
|
+
* to return the assets within the same transaction.
|
|
822
|
+
*/
|
|
823
|
+
export function borrowFlashloanBase(options: BorrowFlashloanBaseOptions) {
|
|
824
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
825
|
+
const argumentsTypes = [
|
|
826
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
827
|
+
'u64',
|
|
828
|
+
] satisfies string[];
|
|
829
|
+
const parameterNames = ['self', 'baseAmount'];
|
|
830
|
+
return (tx: Transaction) =>
|
|
831
|
+
tx.moveCall({
|
|
832
|
+
package: packageAddress,
|
|
833
|
+
module: 'pool',
|
|
834
|
+
function: 'borrow_flashloan_base',
|
|
835
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
836
|
+
typeArguments: options.typeArguments,
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
export interface BorrowFlashloanQuoteArguments {
|
|
840
|
+
self: RawTransactionArgument<string>;
|
|
841
|
+
quoteAmount: RawTransactionArgument<number | bigint>;
|
|
842
|
+
}
|
|
843
|
+
export interface BorrowFlashloanQuoteOptions {
|
|
844
|
+
package?: string;
|
|
845
|
+
arguments:
|
|
846
|
+
| BorrowFlashloanQuoteArguments
|
|
847
|
+
| [self: RawTransactionArgument<string>, quoteAmount: RawTransactionArgument<number | bigint>];
|
|
848
|
+
typeArguments: [string, string];
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Borrow quote assets from the Pool. A hot potato is returned, forcing the
|
|
852
|
+
* borrower to return the assets within the same transaction.
|
|
853
|
+
*/
|
|
854
|
+
export function borrowFlashloanQuote(options: BorrowFlashloanQuoteOptions) {
|
|
855
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
856
|
+
const argumentsTypes = [
|
|
857
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
858
|
+
'u64',
|
|
859
|
+
] satisfies string[];
|
|
860
|
+
const parameterNames = ['self', 'quoteAmount'];
|
|
861
|
+
return (tx: Transaction) =>
|
|
862
|
+
tx.moveCall({
|
|
863
|
+
package: packageAddress,
|
|
864
|
+
module: 'pool',
|
|
865
|
+
function: 'borrow_flashloan_quote',
|
|
866
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
867
|
+
typeArguments: options.typeArguments,
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
export interface ReturnFlashloanBaseArguments {
|
|
871
|
+
self: RawTransactionArgument<string>;
|
|
872
|
+
coin: RawTransactionArgument<string>;
|
|
873
|
+
flashLoan: RawTransactionArgument<string>;
|
|
874
|
+
}
|
|
875
|
+
export interface ReturnFlashloanBaseOptions {
|
|
876
|
+
package?: string;
|
|
877
|
+
arguments:
|
|
878
|
+
| ReturnFlashloanBaseArguments
|
|
879
|
+
| [
|
|
880
|
+
self: RawTransactionArgument<string>,
|
|
881
|
+
coin: RawTransactionArgument<string>,
|
|
882
|
+
flashLoan: RawTransactionArgument<string>,
|
|
883
|
+
];
|
|
884
|
+
typeArguments: [string, string];
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Return the flashloaned base assets to the Pool. FlashLoan object will only be
|
|
888
|
+
* unwrapped if the assets are returned, otherwise the transaction will fail.
|
|
889
|
+
*/
|
|
890
|
+
export function returnFlashloanBase(options: ReturnFlashloanBaseOptions) {
|
|
891
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
892
|
+
const argumentsTypes = [
|
|
893
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
894
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[0]}>`,
|
|
895
|
+
`${packageAddress}::vault::FlashLoan`,
|
|
896
|
+
] satisfies string[];
|
|
897
|
+
const parameterNames = ['self', 'coin', 'flashLoan'];
|
|
898
|
+
return (tx: Transaction) =>
|
|
899
|
+
tx.moveCall({
|
|
900
|
+
package: packageAddress,
|
|
901
|
+
module: 'pool',
|
|
902
|
+
function: 'return_flashloan_base',
|
|
903
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
904
|
+
typeArguments: options.typeArguments,
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
export interface ReturnFlashloanQuoteArguments {
|
|
908
|
+
self: RawTransactionArgument<string>;
|
|
909
|
+
coin: RawTransactionArgument<string>;
|
|
910
|
+
flashLoan: RawTransactionArgument<string>;
|
|
911
|
+
}
|
|
912
|
+
export interface ReturnFlashloanQuoteOptions {
|
|
913
|
+
package?: string;
|
|
914
|
+
arguments:
|
|
915
|
+
| ReturnFlashloanQuoteArguments
|
|
916
|
+
| [
|
|
917
|
+
self: RawTransactionArgument<string>,
|
|
918
|
+
coin: RawTransactionArgument<string>,
|
|
919
|
+
flashLoan: RawTransactionArgument<string>,
|
|
920
|
+
];
|
|
921
|
+
typeArguments: [string, string];
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Return the flashloaned quote assets to the Pool. FlashLoan object will only be
|
|
925
|
+
* unwrapped if the assets are returned, otherwise the transaction will fail.
|
|
926
|
+
*/
|
|
927
|
+
export function returnFlashloanQuote(options: ReturnFlashloanQuoteOptions) {
|
|
928
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
929
|
+
const argumentsTypes = [
|
|
930
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
931
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[1]}>`,
|
|
932
|
+
`${packageAddress}::vault::FlashLoan`,
|
|
933
|
+
] satisfies string[];
|
|
934
|
+
const parameterNames = ['self', 'coin', 'flashLoan'];
|
|
935
|
+
return (tx: Transaction) =>
|
|
936
|
+
tx.moveCall({
|
|
937
|
+
package: packageAddress,
|
|
938
|
+
module: 'pool',
|
|
939
|
+
function: 'return_flashloan_quote',
|
|
940
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
941
|
+
typeArguments: options.typeArguments,
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
export interface AddDeepPricePointArguments {
|
|
945
|
+
targetPool: RawTransactionArgument<string>;
|
|
946
|
+
referencePool: RawTransactionArgument<string>;
|
|
947
|
+
}
|
|
948
|
+
export interface AddDeepPricePointOptions {
|
|
949
|
+
package?: string;
|
|
950
|
+
arguments:
|
|
951
|
+
| AddDeepPricePointArguments
|
|
952
|
+
| [targetPool: RawTransactionArgument<string>, referencePool: RawTransactionArgument<string>];
|
|
953
|
+
typeArguments: [string, string, string, string];
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Adds a price point along with a timestamp to the deep price. Allows for the
|
|
957
|
+
* calculation of deep price per base asset.
|
|
958
|
+
*/
|
|
959
|
+
export function addDeepPricePoint(options: AddDeepPricePointOptions) {
|
|
960
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
961
|
+
const argumentsTypes = [
|
|
962
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
963
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[2]}, ${options.typeArguments[3]}>`,
|
|
964
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
965
|
+
] satisfies string[];
|
|
966
|
+
const parameterNames = ['targetPool', 'referencePool', 'clock'];
|
|
967
|
+
return (tx: Transaction) =>
|
|
968
|
+
tx.moveCall({
|
|
969
|
+
package: packageAddress,
|
|
970
|
+
module: 'pool',
|
|
971
|
+
function: 'add_deep_price_point',
|
|
972
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
973
|
+
typeArguments: options.typeArguments,
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
export interface BurnDeepArguments {
|
|
977
|
+
self: RawTransactionArgument<string>;
|
|
978
|
+
treasuryCap: RawTransactionArgument<string>;
|
|
979
|
+
}
|
|
980
|
+
export interface BurnDeepOptions {
|
|
981
|
+
package?: string;
|
|
982
|
+
arguments:
|
|
983
|
+
| BurnDeepArguments
|
|
984
|
+
| [self: RawTransactionArgument<string>, treasuryCap: RawTransactionArgument<string>];
|
|
985
|
+
typeArguments: [string, string];
|
|
986
|
+
}
|
|
987
|
+
/** Burns DEEP tokens from the pool. Amount to burn is within history */
|
|
988
|
+
export function burnDeep(options: BurnDeepOptions) {
|
|
989
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
990
|
+
const argumentsTypes = [
|
|
991
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
992
|
+
`${packageAddress}::deep::ProtectedTreasury`,
|
|
993
|
+
] satisfies string[];
|
|
994
|
+
const parameterNames = ['self', 'treasuryCap'];
|
|
995
|
+
return (tx: Transaction) =>
|
|
996
|
+
tx.moveCall({
|
|
997
|
+
package: packageAddress,
|
|
998
|
+
module: 'pool',
|
|
999
|
+
function: 'burn_deep',
|
|
1000
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1001
|
+
typeArguments: options.typeArguments,
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
export interface CreatePoolAdminArguments {
|
|
1005
|
+
registry: RawTransactionArgument<string>;
|
|
1006
|
+
tickSize: RawTransactionArgument<number | bigint>;
|
|
1007
|
+
lotSize: RawTransactionArgument<number | bigint>;
|
|
1008
|
+
minSize: RawTransactionArgument<number | bigint>;
|
|
1009
|
+
whitelistedPool: RawTransactionArgument<boolean>;
|
|
1010
|
+
stablePool: RawTransactionArgument<boolean>;
|
|
1011
|
+
Cap: RawTransactionArgument<string>;
|
|
1012
|
+
}
|
|
1013
|
+
export interface CreatePoolAdminOptions {
|
|
1014
|
+
package?: string;
|
|
1015
|
+
arguments:
|
|
1016
|
+
| CreatePoolAdminArguments
|
|
1017
|
+
| [
|
|
1018
|
+
registry: RawTransactionArgument<string>,
|
|
1019
|
+
tickSize: RawTransactionArgument<number | bigint>,
|
|
1020
|
+
lotSize: RawTransactionArgument<number | bigint>,
|
|
1021
|
+
minSize: RawTransactionArgument<number | bigint>,
|
|
1022
|
+
whitelistedPool: RawTransactionArgument<boolean>,
|
|
1023
|
+
stablePool: RawTransactionArgument<boolean>,
|
|
1024
|
+
Cap: RawTransactionArgument<string>,
|
|
1025
|
+
];
|
|
1026
|
+
typeArguments: [string, string];
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Create a new pool. The pool is registered in the registry. Checks are performed
|
|
1030
|
+
* to ensure the tick size, lot size, and min size are valid. Returns the id of the
|
|
1031
|
+
* pool created
|
|
1032
|
+
*/
|
|
1033
|
+
export function createPoolAdmin(options: CreatePoolAdminOptions) {
|
|
1034
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1035
|
+
const argumentsTypes = [
|
|
1036
|
+
`${packageAddress}::registry::Registry`,
|
|
1037
|
+
'u64',
|
|
1038
|
+
'u64',
|
|
1039
|
+
'u64',
|
|
1040
|
+
'bool',
|
|
1041
|
+
'bool',
|
|
1042
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1043
|
+
] satisfies string[];
|
|
1044
|
+
const parameterNames = [
|
|
1045
|
+
'registry',
|
|
1046
|
+
'tickSize',
|
|
1047
|
+
'lotSize',
|
|
1048
|
+
'minSize',
|
|
1049
|
+
'whitelistedPool',
|
|
1050
|
+
'stablePool',
|
|
1051
|
+
'Cap',
|
|
1052
|
+
];
|
|
1053
|
+
return (tx: Transaction) =>
|
|
1054
|
+
tx.moveCall({
|
|
1055
|
+
package: packageAddress,
|
|
1056
|
+
module: 'pool',
|
|
1057
|
+
function: 'create_pool_admin',
|
|
1058
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1059
|
+
typeArguments: options.typeArguments,
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
export interface UnregisterPoolAdminArguments {
|
|
1063
|
+
self: RawTransactionArgument<string>;
|
|
1064
|
+
registry: RawTransactionArgument<string>;
|
|
1065
|
+
Cap: RawTransactionArgument<string>;
|
|
1066
|
+
}
|
|
1067
|
+
export interface UnregisterPoolAdminOptions {
|
|
1068
|
+
package?: string;
|
|
1069
|
+
arguments:
|
|
1070
|
+
| UnregisterPoolAdminArguments
|
|
1071
|
+
| [
|
|
1072
|
+
self: RawTransactionArgument<string>,
|
|
1073
|
+
registry: RawTransactionArgument<string>,
|
|
1074
|
+
Cap: RawTransactionArgument<string>,
|
|
1075
|
+
];
|
|
1076
|
+
typeArguments: [string, string];
|
|
1077
|
+
}
|
|
1078
|
+
/** Unregister a pool in case it needs to be redeployed. */
|
|
1079
|
+
export function unregisterPoolAdmin(options: UnregisterPoolAdminOptions) {
|
|
1080
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1081
|
+
const argumentsTypes = [
|
|
1082
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1083
|
+
`${packageAddress}::registry::Registry`,
|
|
1084
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1085
|
+
] satisfies string[];
|
|
1086
|
+
const parameterNames = ['self', 'registry', 'Cap'];
|
|
1087
|
+
return (tx: Transaction) =>
|
|
1088
|
+
tx.moveCall({
|
|
1089
|
+
package: packageAddress,
|
|
1090
|
+
module: 'pool',
|
|
1091
|
+
function: 'unregister_pool_admin',
|
|
1092
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1093
|
+
typeArguments: options.typeArguments,
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
export interface UpdateAllowedVersionsArguments {
|
|
1097
|
+
self: RawTransactionArgument<string>;
|
|
1098
|
+
registry: RawTransactionArgument<string>;
|
|
1099
|
+
Cap: RawTransactionArgument<string>;
|
|
1100
|
+
}
|
|
1101
|
+
export interface UpdateAllowedVersionsOptions {
|
|
1102
|
+
package?: string;
|
|
1103
|
+
arguments:
|
|
1104
|
+
| UpdateAllowedVersionsArguments
|
|
1105
|
+
| [
|
|
1106
|
+
self: RawTransactionArgument<string>,
|
|
1107
|
+
registry: RawTransactionArgument<string>,
|
|
1108
|
+
Cap: RawTransactionArgument<string>,
|
|
1109
|
+
];
|
|
1110
|
+
typeArguments: [string, string];
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Takes the registry and updates the allowed version within pool Only admin can
|
|
1114
|
+
* update the allowed versions This function does not have version restrictions
|
|
1115
|
+
*/
|
|
1116
|
+
export function updateAllowedVersions(options: UpdateAllowedVersionsOptions) {
|
|
1117
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1118
|
+
const argumentsTypes = [
|
|
1119
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1120
|
+
`${packageAddress}::registry::Registry`,
|
|
1121
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1122
|
+
] satisfies string[];
|
|
1123
|
+
const parameterNames = ['self', 'registry', 'Cap'];
|
|
1124
|
+
return (tx: Transaction) =>
|
|
1125
|
+
tx.moveCall({
|
|
1126
|
+
package: packageAddress,
|
|
1127
|
+
module: 'pool',
|
|
1128
|
+
function: 'update_allowed_versions',
|
|
1129
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1130
|
+
typeArguments: options.typeArguments,
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
export interface UpdatePoolAllowedVersionsArguments {
|
|
1134
|
+
self: RawTransactionArgument<string>;
|
|
1135
|
+
registry: RawTransactionArgument<string>;
|
|
1136
|
+
}
|
|
1137
|
+
export interface UpdatePoolAllowedVersionsOptions {
|
|
1138
|
+
package?: string;
|
|
1139
|
+
arguments:
|
|
1140
|
+
| UpdatePoolAllowedVersionsArguments
|
|
1141
|
+
| [self: RawTransactionArgument<string>, registry: RawTransactionArgument<string>];
|
|
1142
|
+
typeArguments: [string, string];
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Takes the registry and updates the allowed version within pool Permissionless
|
|
1146
|
+
* equivalent of `update_allowed_versions` This function does not have version
|
|
1147
|
+
* restrictions
|
|
1148
|
+
*/
|
|
1149
|
+
export function updatePoolAllowedVersions(options: UpdatePoolAllowedVersionsOptions) {
|
|
1150
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1151
|
+
const argumentsTypes = [
|
|
1152
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1153
|
+
`${packageAddress}::registry::Registry`,
|
|
1154
|
+
] satisfies string[];
|
|
1155
|
+
const parameterNames = ['self', 'registry'];
|
|
1156
|
+
return (tx: Transaction) =>
|
|
1157
|
+
tx.moveCall({
|
|
1158
|
+
package: packageAddress,
|
|
1159
|
+
module: 'pool',
|
|
1160
|
+
function: 'update_pool_allowed_versions',
|
|
1161
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1162
|
+
typeArguments: options.typeArguments,
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
export interface AdjustTickSizeAdminArguments {
|
|
1166
|
+
self: RawTransactionArgument<string>;
|
|
1167
|
+
newTickSize: RawTransactionArgument<number | bigint>;
|
|
1168
|
+
Cap: RawTransactionArgument<string>;
|
|
1169
|
+
}
|
|
1170
|
+
export interface AdjustTickSizeAdminOptions {
|
|
1171
|
+
package?: string;
|
|
1172
|
+
arguments:
|
|
1173
|
+
| AdjustTickSizeAdminArguments
|
|
1174
|
+
| [
|
|
1175
|
+
self: RawTransactionArgument<string>,
|
|
1176
|
+
newTickSize: RawTransactionArgument<number | bigint>,
|
|
1177
|
+
Cap: RawTransactionArgument<string>,
|
|
1178
|
+
];
|
|
1179
|
+
typeArguments: [string, string];
|
|
1180
|
+
}
|
|
1181
|
+
/** Adjust the tick size of the pool. Only admin can adjust the tick size. */
|
|
1182
|
+
export function adjustTickSizeAdmin(options: AdjustTickSizeAdminOptions) {
|
|
1183
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1184
|
+
const argumentsTypes = [
|
|
1185
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1186
|
+
'u64',
|
|
1187
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1188
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1189
|
+
] satisfies string[];
|
|
1190
|
+
const parameterNames = ['self', 'newTickSize', 'Cap', 'clock'];
|
|
1191
|
+
return (tx: Transaction) =>
|
|
1192
|
+
tx.moveCall({
|
|
1193
|
+
package: packageAddress,
|
|
1194
|
+
module: 'pool',
|
|
1195
|
+
function: 'adjust_tick_size_admin',
|
|
1196
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1197
|
+
typeArguments: options.typeArguments,
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
export interface AdjustMinLotSizeAdminArguments {
|
|
1201
|
+
self: RawTransactionArgument<string>;
|
|
1202
|
+
newLotSize: RawTransactionArgument<number | bigint>;
|
|
1203
|
+
newMinSize: RawTransactionArgument<number | bigint>;
|
|
1204
|
+
Cap: RawTransactionArgument<string>;
|
|
1205
|
+
}
|
|
1206
|
+
export interface AdjustMinLotSizeAdminOptions {
|
|
1207
|
+
package?: string;
|
|
1208
|
+
arguments:
|
|
1209
|
+
| AdjustMinLotSizeAdminArguments
|
|
1210
|
+
| [
|
|
1211
|
+
self: RawTransactionArgument<string>,
|
|
1212
|
+
newLotSize: RawTransactionArgument<number | bigint>,
|
|
1213
|
+
newMinSize: RawTransactionArgument<number | bigint>,
|
|
1214
|
+
Cap: RawTransactionArgument<string>,
|
|
1215
|
+
];
|
|
1216
|
+
typeArguments: [string, string];
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Adjust and lot size and min size of the pool. New lot size must be smaller than
|
|
1220
|
+
* current lot size. Only admin can adjust the min size and lot size.
|
|
1221
|
+
*/
|
|
1222
|
+
export function adjustMinLotSizeAdmin(options: AdjustMinLotSizeAdminOptions) {
|
|
1223
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1224
|
+
const argumentsTypes = [
|
|
1225
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1226
|
+
'u64',
|
|
1227
|
+
'u64',
|
|
1228
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1229
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1230
|
+
] satisfies string[];
|
|
1231
|
+
const parameterNames = ['self', 'newLotSize', 'newMinSize', 'Cap', 'clock'];
|
|
1232
|
+
return (tx: Transaction) =>
|
|
1233
|
+
tx.moveCall({
|
|
1234
|
+
package: packageAddress,
|
|
1235
|
+
module: 'pool',
|
|
1236
|
+
function: 'adjust_min_lot_size_admin',
|
|
1237
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1238
|
+
typeArguments: options.typeArguments,
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
export interface AuthorizeAppArguments {
|
|
1242
|
+
self: RawTransactionArgument<string>;
|
|
1243
|
+
Cap: RawTransactionArgument<string>;
|
|
1244
|
+
}
|
|
1245
|
+
export interface AuthorizeAppOptions {
|
|
1246
|
+
package?: string;
|
|
1247
|
+
arguments:
|
|
1248
|
+
| AuthorizeAppArguments
|
|
1249
|
+
| [self: RawTransactionArgument<string>, Cap: RawTransactionArgument<string>];
|
|
1250
|
+
typeArguments: [string, string, string];
|
|
1251
|
+
}
|
|
1252
|
+
/** Authorize an application to access protected features of Deepbook core. */
|
|
1253
|
+
export function authorizeApp(options: AuthorizeAppOptions) {
|
|
1254
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1255
|
+
const argumentsTypes = [
|
|
1256
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}, ${options.typeArguments[2]}>`,
|
|
1257
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1258
|
+
] satisfies string[];
|
|
1259
|
+
const parameterNames = ['self', 'Cap'];
|
|
1260
|
+
return (tx: Transaction) =>
|
|
1261
|
+
tx.moveCall({
|
|
1262
|
+
package: packageAddress,
|
|
1263
|
+
module: 'pool',
|
|
1264
|
+
function: 'authorize_app',
|
|
1265
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1266
|
+
typeArguments: options.typeArguments,
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
export interface DeauthorizeAppArguments {
|
|
1270
|
+
self: RawTransactionArgument<string>;
|
|
1271
|
+
Cap: RawTransactionArgument<string>;
|
|
1272
|
+
}
|
|
1273
|
+
export interface DeauthorizeAppOptions {
|
|
1274
|
+
package?: string;
|
|
1275
|
+
arguments:
|
|
1276
|
+
| DeauthorizeAppArguments
|
|
1277
|
+
| [self: RawTransactionArgument<string>, Cap: RawTransactionArgument<string>];
|
|
1278
|
+
typeArguments: [string, string, string];
|
|
1279
|
+
}
|
|
1280
|
+
/** Deauthorize an application by removing its authorization key. */
|
|
1281
|
+
export function deauthorizeApp(options: DeauthorizeAppOptions) {
|
|
1282
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1283
|
+
const argumentsTypes = [
|
|
1284
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}, ${options.typeArguments[2]}>`,
|
|
1285
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1286
|
+
] satisfies string[];
|
|
1287
|
+
const parameterNames = ['self', 'Cap'];
|
|
1288
|
+
return (tx: Transaction) =>
|
|
1289
|
+
tx.moveCall({
|
|
1290
|
+
package: packageAddress,
|
|
1291
|
+
module: 'pool',
|
|
1292
|
+
function: 'deauthorize_app',
|
|
1293
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1294
|
+
typeArguments: options.typeArguments,
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
export interface EnableEwmaStateArguments {
|
|
1298
|
+
self: RawTransactionArgument<string>;
|
|
1299
|
+
Cap: RawTransactionArgument<string>;
|
|
1300
|
+
enable: RawTransactionArgument<boolean>;
|
|
1301
|
+
}
|
|
1302
|
+
export interface EnableEwmaStateOptions {
|
|
1303
|
+
package?: string;
|
|
1304
|
+
arguments:
|
|
1305
|
+
| EnableEwmaStateArguments
|
|
1306
|
+
| [
|
|
1307
|
+
self: RawTransactionArgument<string>,
|
|
1308
|
+
Cap: RawTransactionArgument<string>,
|
|
1309
|
+
enable: RawTransactionArgument<boolean>,
|
|
1310
|
+
];
|
|
1311
|
+
typeArguments: [string, string];
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Enable the EWMA state for the pool. This allows the pool to use the EWMA state
|
|
1315
|
+
* for volatility calculations and additional taker fees.
|
|
1316
|
+
*/
|
|
1317
|
+
export function enableEwmaState(options: EnableEwmaStateOptions) {
|
|
1318
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1319
|
+
const argumentsTypes = [
|
|
1320
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1321
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1322
|
+
'bool',
|
|
1323
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1324
|
+
] satisfies string[];
|
|
1325
|
+
const parameterNames = ['self', 'Cap', 'enable', 'clock'];
|
|
1326
|
+
return (tx: Transaction) =>
|
|
1327
|
+
tx.moveCall({
|
|
1328
|
+
package: packageAddress,
|
|
1329
|
+
module: 'pool',
|
|
1330
|
+
function: 'enable_ewma_state',
|
|
1331
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1332
|
+
typeArguments: options.typeArguments,
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
export interface SetEwmaParamsArguments {
|
|
1336
|
+
self: RawTransactionArgument<string>;
|
|
1337
|
+
Cap: RawTransactionArgument<string>;
|
|
1338
|
+
alpha: RawTransactionArgument<number | bigint>;
|
|
1339
|
+
zScoreThreshold: RawTransactionArgument<number | bigint>;
|
|
1340
|
+
additionalTakerFee: RawTransactionArgument<number | bigint>;
|
|
1341
|
+
}
|
|
1342
|
+
export interface SetEwmaParamsOptions {
|
|
1343
|
+
package?: string;
|
|
1344
|
+
arguments:
|
|
1345
|
+
| SetEwmaParamsArguments
|
|
1346
|
+
| [
|
|
1347
|
+
self: RawTransactionArgument<string>,
|
|
1348
|
+
Cap: RawTransactionArgument<string>,
|
|
1349
|
+
alpha: RawTransactionArgument<number | bigint>,
|
|
1350
|
+
zScoreThreshold: RawTransactionArgument<number | bigint>,
|
|
1351
|
+
additionalTakerFee: RawTransactionArgument<number | bigint>,
|
|
1352
|
+
];
|
|
1353
|
+
typeArguments: [string, string];
|
|
1354
|
+
}
|
|
1355
|
+
/** Set the EWMA parameters for the pool. Only admin can set the parameters. */
|
|
1356
|
+
export function setEwmaParams(options: SetEwmaParamsOptions) {
|
|
1357
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1358
|
+
const argumentsTypes = [
|
|
1359
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1360
|
+
`${packageAddress}::registry::DeepbookAdminCap`,
|
|
1361
|
+
'u64',
|
|
1362
|
+
'u64',
|
|
1363
|
+
'u64',
|
|
1364
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1365
|
+
] satisfies string[];
|
|
1366
|
+
const parameterNames = ['self', 'Cap', 'alpha', 'zScoreThreshold', 'additionalTakerFee', 'clock'];
|
|
1367
|
+
return (tx: Transaction) =>
|
|
1368
|
+
tx.moveCall({
|
|
1369
|
+
package: packageAddress,
|
|
1370
|
+
module: 'pool',
|
|
1371
|
+
function: 'set_ewma_params',
|
|
1372
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1373
|
+
typeArguments: options.typeArguments,
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
export interface UpdateMarginStatusArguments<A extends BcsType<any>> {
|
|
1377
|
+
self: RawTransactionArgument<string>;
|
|
1378
|
+
_: RawTransactionArgument<A>;
|
|
1379
|
+
enable: RawTransactionArgument<boolean>;
|
|
1380
|
+
}
|
|
1381
|
+
export interface UpdateMarginStatusOptions<A extends BcsType<any>> {
|
|
1382
|
+
package?: string;
|
|
1383
|
+
arguments:
|
|
1384
|
+
| UpdateMarginStatusArguments<A>
|
|
1385
|
+
| [
|
|
1386
|
+
self: RawTransactionArgument<string>,
|
|
1387
|
+
_: RawTransactionArgument<A>,
|
|
1388
|
+
enable: RawTransactionArgument<boolean>,
|
|
1389
|
+
];
|
|
1390
|
+
typeArguments: [string, string, string];
|
|
1391
|
+
}
|
|
1392
|
+
export function updateMarginStatus<A extends BcsType<any>>(options: UpdateMarginStatusOptions<A>) {
|
|
1393
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1394
|
+
const argumentsTypes = [
|
|
1395
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}, ${options.typeArguments[2]}>`,
|
|
1396
|
+
`${options.typeArguments[0]}`,
|
|
1397
|
+
'bool',
|
|
1398
|
+
] satisfies string[];
|
|
1399
|
+
const parameterNames = ['self', '_', 'enable'];
|
|
1400
|
+
return (tx: Transaction) =>
|
|
1401
|
+
tx.moveCall({
|
|
1402
|
+
package: packageAddress,
|
|
1403
|
+
module: 'pool',
|
|
1404
|
+
function: 'update_margin_status',
|
|
1405
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1406
|
+
typeArguments: options.typeArguments,
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
export interface WhitelistedArguments {
|
|
1410
|
+
self: RawTransactionArgument<string>;
|
|
1411
|
+
}
|
|
1412
|
+
export interface WhitelistedOptions {
|
|
1413
|
+
package?: string;
|
|
1414
|
+
arguments: WhitelistedArguments | [self: RawTransactionArgument<string>];
|
|
1415
|
+
typeArguments: [string, string];
|
|
1416
|
+
}
|
|
1417
|
+
/** Accessor to check if the pool is whitelisted. */
|
|
1418
|
+
export function whitelisted(options: WhitelistedOptions) {
|
|
1419
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1420
|
+
const argumentsTypes = [
|
|
1421
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1422
|
+
] satisfies string[];
|
|
1423
|
+
const parameterNames = ['self'];
|
|
1424
|
+
return (tx: Transaction) =>
|
|
1425
|
+
tx.moveCall({
|
|
1426
|
+
package: packageAddress,
|
|
1427
|
+
module: 'pool',
|
|
1428
|
+
function: 'whitelisted',
|
|
1429
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1430
|
+
typeArguments: options.typeArguments,
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
export interface StablePoolArguments {
|
|
1434
|
+
self: RawTransactionArgument<string>;
|
|
1435
|
+
}
|
|
1436
|
+
export interface StablePoolOptions {
|
|
1437
|
+
package?: string;
|
|
1438
|
+
arguments: StablePoolArguments | [self: RawTransactionArgument<string>];
|
|
1439
|
+
typeArguments: [string, string];
|
|
1440
|
+
}
|
|
1441
|
+
/** Accessor to check if the pool is a stablecoin pool. */
|
|
1442
|
+
export function stablePool(options: StablePoolOptions) {
|
|
1443
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1444
|
+
const argumentsTypes = [
|
|
1445
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1446
|
+
] satisfies string[];
|
|
1447
|
+
const parameterNames = ['self'];
|
|
1448
|
+
return (tx: Transaction) =>
|
|
1449
|
+
tx.moveCall({
|
|
1450
|
+
package: packageAddress,
|
|
1451
|
+
module: 'pool',
|
|
1452
|
+
function: 'stable_pool',
|
|
1453
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1454
|
+
typeArguments: options.typeArguments,
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
export interface RegisteredPoolArguments {
|
|
1458
|
+
self: RawTransactionArgument<string>;
|
|
1459
|
+
}
|
|
1460
|
+
export interface RegisteredPoolOptions {
|
|
1461
|
+
package?: string;
|
|
1462
|
+
arguments: RegisteredPoolArguments | [self: RawTransactionArgument<string>];
|
|
1463
|
+
typeArguments: [string, string];
|
|
1464
|
+
}
|
|
1465
|
+
export function registeredPool(options: RegisteredPoolOptions) {
|
|
1466
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1467
|
+
const argumentsTypes = [
|
|
1468
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1469
|
+
] satisfies string[];
|
|
1470
|
+
const parameterNames = ['self'];
|
|
1471
|
+
return (tx: Transaction) =>
|
|
1472
|
+
tx.moveCall({
|
|
1473
|
+
package: packageAddress,
|
|
1474
|
+
module: 'pool',
|
|
1475
|
+
function: 'registered_pool',
|
|
1476
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1477
|
+
typeArguments: options.typeArguments,
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
export interface GetQuoteQuantityOutArguments {
|
|
1481
|
+
self: RawTransactionArgument<string>;
|
|
1482
|
+
baseQuantity: RawTransactionArgument<number | bigint>;
|
|
1483
|
+
}
|
|
1484
|
+
export interface GetQuoteQuantityOutOptions {
|
|
1485
|
+
package?: string;
|
|
1486
|
+
arguments:
|
|
1487
|
+
| GetQuoteQuantityOutArguments
|
|
1488
|
+
| [self: RawTransactionArgument<string>, baseQuantity: RawTransactionArgument<number | bigint>];
|
|
1489
|
+
typeArguments: [string, string];
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Dry run to determine the quote quantity out for a given base quantity. Uses DEEP
|
|
1493
|
+
* token as fee.
|
|
1494
|
+
*/
|
|
1495
|
+
export function getQuoteQuantityOut(options: GetQuoteQuantityOutOptions) {
|
|
1496
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1497
|
+
const argumentsTypes = [
|
|
1498
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1499
|
+
'u64',
|
|
1500
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1501
|
+
] satisfies string[];
|
|
1502
|
+
const parameterNames = ['self', 'baseQuantity', 'clock'];
|
|
1503
|
+
return (tx: Transaction) =>
|
|
1504
|
+
tx.moveCall({
|
|
1505
|
+
package: packageAddress,
|
|
1506
|
+
module: 'pool',
|
|
1507
|
+
function: 'get_quote_quantity_out',
|
|
1508
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1509
|
+
typeArguments: options.typeArguments,
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
export interface GetBaseQuantityOutArguments {
|
|
1513
|
+
self: RawTransactionArgument<string>;
|
|
1514
|
+
quoteQuantity: RawTransactionArgument<number | bigint>;
|
|
1515
|
+
}
|
|
1516
|
+
export interface GetBaseQuantityOutOptions {
|
|
1517
|
+
package?: string;
|
|
1518
|
+
arguments:
|
|
1519
|
+
| GetBaseQuantityOutArguments
|
|
1520
|
+
| [
|
|
1521
|
+
self: RawTransactionArgument<string>,
|
|
1522
|
+
quoteQuantity: RawTransactionArgument<number | bigint>,
|
|
1523
|
+
];
|
|
1524
|
+
typeArguments: [string, string];
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Dry run to determine the base quantity out for a given quote quantity. Uses DEEP
|
|
1528
|
+
* token as fee.
|
|
1529
|
+
*/
|
|
1530
|
+
export function getBaseQuantityOut(options: GetBaseQuantityOutOptions) {
|
|
1531
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1532
|
+
const argumentsTypes = [
|
|
1533
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1534
|
+
'u64',
|
|
1535
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1536
|
+
] satisfies string[];
|
|
1537
|
+
const parameterNames = ['self', 'quoteQuantity', 'clock'];
|
|
1538
|
+
return (tx: Transaction) =>
|
|
1539
|
+
tx.moveCall({
|
|
1540
|
+
package: packageAddress,
|
|
1541
|
+
module: 'pool',
|
|
1542
|
+
function: 'get_base_quantity_out',
|
|
1543
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1544
|
+
typeArguments: options.typeArguments,
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
export interface GetQuoteQuantityOutInputFeeArguments {
|
|
1548
|
+
self: RawTransactionArgument<string>;
|
|
1549
|
+
baseQuantity: RawTransactionArgument<number | bigint>;
|
|
1550
|
+
}
|
|
1551
|
+
export interface GetQuoteQuantityOutInputFeeOptions {
|
|
1552
|
+
package?: string;
|
|
1553
|
+
arguments:
|
|
1554
|
+
| GetQuoteQuantityOutInputFeeArguments
|
|
1555
|
+
| [self: RawTransactionArgument<string>, baseQuantity: RawTransactionArgument<number | bigint>];
|
|
1556
|
+
typeArguments: [string, string];
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Dry run to determine the quote quantity out for a given base quantity. Uses
|
|
1560
|
+
* input token as fee.
|
|
1561
|
+
*/
|
|
1562
|
+
export function getQuoteQuantityOutInputFee(options: GetQuoteQuantityOutInputFeeOptions) {
|
|
1563
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1564
|
+
const argumentsTypes = [
|
|
1565
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1566
|
+
'u64',
|
|
1567
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1568
|
+
] satisfies string[];
|
|
1569
|
+
const parameterNames = ['self', 'baseQuantity', 'clock'];
|
|
1570
|
+
return (tx: Transaction) =>
|
|
1571
|
+
tx.moveCall({
|
|
1572
|
+
package: packageAddress,
|
|
1573
|
+
module: 'pool',
|
|
1574
|
+
function: 'get_quote_quantity_out_input_fee',
|
|
1575
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1576
|
+
typeArguments: options.typeArguments,
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
export interface GetBaseQuantityOutInputFeeArguments {
|
|
1580
|
+
self: RawTransactionArgument<string>;
|
|
1581
|
+
quoteQuantity: RawTransactionArgument<number | bigint>;
|
|
1582
|
+
}
|
|
1583
|
+
export interface GetBaseQuantityOutInputFeeOptions {
|
|
1584
|
+
package?: string;
|
|
1585
|
+
arguments:
|
|
1586
|
+
| GetBaseQuantityOutInputFeeArguments
|
|
1587
|
+
| [
|
|
1588
|
+
self: RawTransactionArgument<string>,
|
|
1589
|
+
quoteQuantity: RawTransactionArgument<number | bigint>,
|
|
1590
|
+
];
|
|
1591
|
+
typeArguments: [string, string];
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Dry run to determine the base quantity out for a given quote quantity. Uses
|
|
1595
|
+
* input token as fee.
|
|
1596
|
+
*/
|
|
1597
|
+
export function getBaseQuantityOutInputFee(options: GetBaseQuantityOutInputFeeOptions) {
|
|
1598
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1599
|
+
const argumentsTypes = [
|
|
1600
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1601
|
+
'u64',
|
|
1602
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1603
|
+
] satisfies string[];
|
|
1604
|
+
const parameterNames = ['self', 'quoteQuantity', 'clock'];
|
|
1605
|
+
return (tx: Transaction) =>
|
|
1606
|
+
tx.moveCall({
|
|
1607
|
+
package: packageAddress,
|
|
1608
|
+
module: 'pool',
|
|
1609
|
+
function: 'get_base_quantity_out_input_fee',
|
|
1610
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1611
|
+
typeArguments: options.typeArguments,
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
export interface GetQuantityOutArguments {
|
|
1615
|
+
self: RawTransactionArgument<string>;
|
|
1616
|
+
baseQuantity: RawTransactionArgument<number | bigint>;
|
|
1617
|
+
quoteQuantity: RawTransactionArgument<number | bigint>;
|
|
1618
|
+
}
|
|
1619
|
+
export interface GetQuantityOutOptions {
|
|
1620
|
+
package?: string;
|
|
1621
|
+
arguments:
|
|
1622
|
+
| GetQuantityOutArguments
|
|
1623
|
+
| [
|
|
1624
|
+
self: RawTransactionArgument<string>,
|
|
1625
|
+
baseQuantity: RawTransactionArgument<number | bigint>,
|
|
1626
|
+
quoteQuantity: RawTransactionArgument<number | bigint>,
|
|
1627
|
+
];
|
|
1628
|
+
typeArguments: [string, string];
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Dry run to determine the quantity out for a given base or quote quantity. Only
|
|
1632
|
+
* one out of base or quote quantity should be non-zero. Returns the
|
|
1633
|
+
* (base_quantity_out, quote_quantity_out, deep_quantity_required) Uses DEEP token
|
|
1634
|
+
* as fee.
|
|
1635
|
+
*/
|
|
1636
|
+
export function getQuantityOut(options: GetQuantityOutOptions) {
|
|
1637
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1638
|
+
const argumentsTypes = [
|
|
1639
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1640
|
+
'u64',
|
|
1641
|
+
'u64',
|
|
1642
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1643
|
+
] satisfies string[];
|
|
1644
|
+
const parameterNames = ['self', 'baseQuantity', 'quoteQuantity', 'clock'];
|
|
1645
|
+
return (tx: Transaction) =>
|
|
1646
|
+
tx.moveCall({
|
|
1647
|
+
package: packageAddress,
|
|
1648
|
+
module: 'pool',
|
|
1649
|
+
function: 'get_quantity_out',
|
|
1650
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1651
|
+
typeArguments: options.typeArguments,
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
export interface GetQuantityOutInputFeeArguments {
|
|
1655
|
+
self: RawTransactionArgument<string>;
|
|
1656
|
+
baseQuantity: RawTransactionArgument<number | bigint>;
|
|
1657
|
+
quoteQuantity: RawTransactionArgument<number | bigint>;
|
|
1658
|
+
}
|
|
1659
|
+
export interface GetQuantityOutInputFeeOptions {
|
|
1660
|
+
package?: string;
|
|
1661
|
+
arguments:
|
|
1662
|
+
| GetQuantityOutInputFeeArguments
|
|
1663
|
+
| [
|
|
1664
|
+
self: RawTransactionArgument<string>,
|
|
1665
|
+
baseQuantity: RawTransactionArgument<number | bigint>,
|
|
1666
|
+
quoteQuantity: RawTransactionArgument<number | bigint>,
|
|
1667
|
+
];
|
|
1668
|
+
typeArguments: [string, string];
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Dry run to determine the quantity out for a given base or quote quantity. Only
|
|
1672
|
+
* one out of base or quote quantity should be non-zero. Returns the
|
|
1673
|
+
* (base_quantity_out, quote_quantity_out, deep_quantity_required) Uses input token
|
|
1674
|
+
* as fee.
|
|
1675
|
+
*/
|
|
1676
|
+
export function getQuantityOutInputFee(options: GetQuantityOutInputFeeOptions) {
|
|
1677
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1678
|
+
const argumentsTypes = [
|
|
1679
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1680
|
+
'u64',
|
|
1681
|
+
'u64',
|
|
1682
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1683
|
+
] satisfies string[];
|
|
1684
|
+
const parameterNames = ['self', 'baseQuantity', 'quoteQuantity', 'clock'];
|
|
1685
|
+
return (tx: Transaction) =>
|
|
1686
|
+
tx.moveCall({
|
|
1687
|
+
package: packageAddress,
|
|
1688
|
+
module: 'pool',
|
|
1689
|
+
function: 'get_quantity_out_input_fee',
|
|
1690
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1691
|
+
typeArguments: options.typeArguments,
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
export interface MidPriceArguments {
|
|
1695
|
+
self: RawTransactionArgument<string>;
|
|
1696
|
+
}
|
|
1697
|
+
export interface MidPriceOptions {
|
|
1698
|
+
package?: string;
|
|
1699
|
+
arguments: MidPriceArguments | [self: RawTransactionArgument<string>];
|
|
1700
|
+
typeArguments: [string, string];
|
|
1701
|
+
}
|
|
1702
|
+
/** Returns the mid price of the pool. */
|
|
1703
|
+
export function midPrice(options: MidPriceOptions) {
|
|
1704
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1705
|
+
const argumentsTypes = [
|
|
1706
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1707
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1708
|
+
] satisfies string[];
|
|
1709
|
+
const parameterNames = ['self', 'clock'];
|
|
1710
|
+
return (tx: Transaction) =>
|
|
1711
|
+
tx.moveCall({
|
|
1712
|
+
package: packageAddress,
|
|
1713
|
+
module: 'pool',
|
|
1714
|
+
function: 'mid_price',
|
|
1715
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1716
|
+
typeArguments: options.typeArguments,
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
export interface AccountOpenOrdersArguments {
|
|
1720
|
+
self: RawTransactionArgument<string>;
|
|
1721
|
+
balanceManager: RawTransactionArgument<string>;
|
|
1722
|
+
}
|
|
1723
|
+
export interface AccountOpenOrdersOptions {
|
|
1724
|
+
package?: string;
|
|
1725
|
+
arguments:
|
|
1726
|
+
| AccountOpenOrdersArguments
|
|
1727
|
+
| [self: RawTransactionArgument<string>, balanceManager: RawTransactionArgument<string>];
|
|
1728
|
+
typeArguments: [string, string];
|
|
1729
|
+
}
|
|
1730
|
+
/** Returns the order_id for all open order for the balance_manager in the pool. */
|
|
1731
|
+
export function accountOpenOrders(options: AccountOpenOrdersOptions) {
|
|
1732
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1733
|
+
const argumentsTypes = [
|
|
1734
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1735
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
1736
|
+
] satisfies string[];
|
|
1737
|
+
const parameterNames = ['self', 'balanceManager'];
|
|
1738
|
+
return (tx: Transaction) =>
|
|
1739
|
+
tx.moveCall({
|
|
1740
|
+
package: packageAddress,
|
|
1741
|
+
module: 'pool',
|
|
1742
|
+
function: 'account_open_orders',
|
|
1743
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1744
|
+
typeArguments: options.typeArguments,
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
export interface GetLevel2RangeArguments {
|
|
1748
|
+
self: RawTransactionArgument<string>;
|
|
1749
|
+
priceLow: RawTransactionArgument<number | bigint>;
|
|
1750
|
+
priceHigh: RawTransactionArgument<number | bigint>;
|
|
1751
|
+
isBid: RawTransactionArgument<boolean>;
|
|
1752
|
+
}
|
|
1753
|
+
export interface GetLevel2RangeOptions {
|
|
1754
|
+
package?: string;
|
|
1755
|
+
arguments:
|
|
1756
|
+
| GetLevel2RangeArguments
|
|
1757
|
+
| [
|
|
1758
|
+
self: RawTransactionArgument<string>,
|
|
1759
|
+
priceLow: RawTransactionArgument<number | bigint>,
|
|
1760
|
+
priceHigh: RawTransactionArgument<number | bigint>,
|
|
1761
|
+
isBid: RawTransactionArgument<boolean>,
|
|
1762
|
+
];
|
|
1763
|
+
typeArguments: [string, string];
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Returns the (price_vec, quantity_vec) for the level2 order book. The price_low
|
|
1767
|
+
* and price_high are inclusive, all orders within the range are returned. is_bid
|
|
1768
|
+
* is true for bids and false for asks.
|
|
1769
|
+
*/
|
|
1770
|
+
export function getLevel2Range(options: GetLevel2RangeOptions) {
|
|
1771
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1772
|
+
const argumentsTypes = [
|
|
1773
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1774
|
+
'u64',
|
|
1775
|
+
'u64',
|
|
1776
|
+
'bool',
|
|
1777
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1778
|
+
] satisfies string[];
|
|
1779
|
+
const parameterNames = ['self', 'priceLow', 'priceHigh', 'isBid', 'clock'];
|
|
1780
|
+
return (tx: Transaction) =>
|
|
1781
|
+
tx.moveCall({
|
|
1782
|
+
package: packageAddress,
|
|
1783
|
+
module: 'pool',
|
|
1784
|
+
function: 'get_level2_range',
|
|
1785
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1786
|
+
typeArguments: options.typeArguments,
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
export interface GetLevel2TicksFromMidArguments {
|
|
1790
|
+
self: RawTransactionArgument<string>;
|
|
1791
|
+
ticks: RawTransactionArgument<number | bigint>;
|
|
1792
|
+
}
|
|
1793
|
+
export interface GetLevel2TicksFromMidOptions {
|
|
1794
|
+
package?: string;
|
|
1795
|
+
arguments:
|
|
1796
|
+
| GetLevel2TicksFromMidArguments
|
|
1797
|
+
| [self: RawTransactionArgument<string>, ticks: RawTransactionArgument<number | bigint>];
|
|
1798
|
+
typeArguments: [string, string];
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Returns the (price_vec, quantity_vec) for the level2 order book. Ticks are the
|
|
1802
|
+
* maximum number of ticks to return starting from best bid and best ask.
|
|
1803
|
+
* (bid_price, bid_quantity, ask_price, ask_quantity) are returned as 4 vectors.
|
|
1804
|
+
* The price vectors are sorted in descending order for bids and ascending order
|
|
1805
|
+
* for asks.
|
|
1806
|
+
*/
|
|
1807
|
+
export function getLevel2TicksFromMid(options: GetLevel2TicksFromMidOptions) {
|
|
1808
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1809
|
+
const argumentsTypes = [
|
|
1810
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1811
|
+
'u64',
|
|
1812
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002::clock::Clock',
|
|
1813
|
+
] satisfies string[];
|
|
1814
|
+
const parameterNames = ['self', 'ticks', 'clock'];
|
|
1815
|
+
return (tx: Transaction) =>
|
|
1816
|
+
tx.moveCall({
|
|
1817
|
+
package: packageAddress,
|
|
1818
|
+
module: 'pool',
|
|
1819
|
+
function: 'get_level2_ticks_from_mid',
|
|
1820
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1821
|
+
typeArguments: options.typeArguments,
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
export interface VaultBalancesArguments {
|
|
1825
|
+
self: RawTransactionArgument<string>;
|
|
1826
|
+
}
|
|
1827
|
+
export interface VaultBalancesOptions {
|
|
1828
|
+
package?: string;
|
|
1829
|
+
arguments: VaultBalancesArguments | [self: RawTransactionArgument<string>];
|
|
1830
|
+
typeArguments: [string, string];
|
|
1831
|
+
}
|
|
1832
|
+
/** Get all balances held in this pool. */
|
|
1833
|
+
export function vaultBalances(options: VaultBalancesOptions) {
|
|
1834
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1835
|
+
const argumentsTypes = [
|
|
1836
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1837
|
+
] satisfies string[];
|
|
1838
|
+
const parameterNames = ['self'];
|
|
1839
|
+
return (tx: Transaction) =>
|
|
1840
|
+
tx.moveCall({
|
|
1841
|
+
package: packageAddress,
|
|
1842
|
+
module: 'pool',
|
|
1843
|
+
function: 'vault_balances',
|
|
1844
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1845
|
+
typeArguments: options.typeArguments,
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
export interface GetPoolIdByAssetArguments {
|
|
1849
|
+
registry: RawTransactionArgument<string>;
|
|
1850
|
+
}
|
|
1851
|
+
export interface GetPoolIdByAssetOptions {
|
|
1852
|
+
package?: string;
|
|
1853
|
+
arguments: GetPoolIdByAssetArguments | [registry: RawTransactionArgument<string>];
|
|
1854
|
+
typeArguments: [string, string];
|
|
1855
|
+
}
|
|
1856
|
+
/** Get the ID of the pool given the asset types. */
|
|
1857
|
+
export function getPoolIdByAsset(options: GetPoolIdByAssetOptions) {
|
|
1858
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1859
|
+
const argumentsTypes = [`${packageAddress}::registry::Registry`] satisfies string[];
|
|
1860
|
+
const parameterNames = ['registry'];
|
|
1861
|
+
return (tx: Transaction) =>
|
|
1862
|
+
tx.moveCall({
|
|
1863
|
+
package: packageAddress,
|
|
1864
|
+
module: 'pool',
|
|
1865
|
+
function: 'get_pool_id_by_asset',
|
|
1866
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1867
|
+
typeArguments: options.typeArguments,
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
export interface GetOrderArguments {
|
|
1871
|
+
self: RawTransactionArgument<string>;
|
|
1872
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
1873
|
+
}
|
|
1874
|
+
export interface GetOrderOptions {
|
|
1875
|
+
package?: string;
|
|
1876
|
+
arguments:
|
|
1877
|
+
| GetOrderArguments
|
|
1878
|
+
| [self: RawTransactionArgument<string>, orderId: RawTransactionArgument<number | bigint>];
|
|
1879
|
+
typeArguments: [string, string];
|
|
1880
|
+
}
|
|
1881
|
+
/** Get the Order struct */
|
|
1882
|
+
export function getOrder(options: GetOrderOptions) {
|
|
1883
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1884
|
+
const argumentsTypes = [
|
|
1885
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1886
|
+
'u128',
|
|
1887
|
+
] satisfies string[];
|
|
1888
|
+
const parameterNames = ['self', 'orderId'];
|
|
1889
|
+
return (tx: Transaction) =>
|
|
1890
|
+
tx.moveCall({
|
|
1891
|
+
package: packageAddress,
|
|
1892
|
+
module: 'pool',
|
|
1893
|
+
function: 'get_order',
|
|
1894
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1895
|
+
typeArguments: options.typeArguments,
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
export interface GetOrdersArguments {
|
|
1899
|
+
self: RawTransactionArgument<string>;
|
|
1900
|
+
orderIds: RawTransactionArgument<number | bigint[]>;
|
|
1901
|
+
}
|
|
1902
|
+
export interface GetOrdersOptions {
|
|
1903
|
+
package?: string;
|
|
1904
|
+
arguments:
|
|
1905
|
+
| GetOrdersArguments
|
|
1906
|
+
| [self: RawTransactionArgument<string>, orderIds: RawTransactionArgument<number | bigint[]>];
|
|
1907
|
+
typeArguments: [string, string];
|
|
1908
|
+
}
|
|
1909
|
+
/** Get multiple orders given a vector of order_ids. */
|
|
1910
|
+
export function getOrders(options: GetOrdersOptions) {
|
|
1911
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1912
|
+
const argumentsTypes = [
|
|
1913
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1914
|
+
'vector<u128>',
|
|
1915
|
+
] satisfies string[];
|
|
1916
|
+
const parameterNames = ['self', 'orderIds'];
|
|
1917
|
+
return (tx: Transaction) =>
|
|
1918
|
+
tx.moveCall({
|
|
1919
|
+
package: packageAddress,
|
|
1920
|
+
module: 'pool',
|
|
1921
|
+
function: 'get_orders',
|
|
1922
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1923
|
+
typeArguments: options.typeArguments,
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
export interface GetAccountOrderDetailsArguments {
|
|
1927
|
+
self: RawTransactionArgument<string>;
|
|
1928
|
+
balanceManager: RawTransactionArgument<string>;
|
|
1929
|
+
}
|
|
1930
|
+
export interface GetAccountOrderDetailsOptions {
|
|
1931
|
+
package?: string;
|
|
1932
|
+
arguments:
|
|
1933
|
+
| GetAccountOrderDetailsArguments
|
|
1934
|
+
| [self: RawTransactionArgument<string>, balanceManager: RawTransactionArgument<string>];
|
|
1935
|
+
typeArguments: [string, string];
|
|
1936
|
+
}
|
|
1937
|
+
/** Return a copy of all orders that are in the book for this account. */
|
|
1938
|
+
export function getAccountOrderDetails(options: GetAccountOrderDetailsOptions) {
|
|
1939
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1940
|
+
const argumentsTypes = [
|
|
1941
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1942
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
1943
|
+
] satisfies string[];
|
|
1944
|
+
const parameterNames = ['self', 'balanceManager'];
|
|
1945
|
+
return (tx: Transaction) =>
|
|
1946
|
+
tx.moveCall({
|
|
1947
|
+
package: packageAddress,
|
|
1948
|
+
module: 'pool',
|
|
1949
|
+
function: 'get_account_order_details',
|
|
1950
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1951
|
+
typeArguments: options.typeArguments,
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
export interface GetOrderDeepPriceArguments {
|
|
1955
|
+
self: RawTransactionArgument<string>;
|
|
1956
|
+
}
|
|
1957
|
+
export interface GetOrderDeepPriceOptions {
|
|
1958
|
+
package?: string;
|
|
1959
|
+
arguments: GetOrderDeepPriceArguments | [self: RawTransactionArgument<string>];
|
|
1960
|
+
typeArguments: [string, string];
|
|
1961
|
+
}
|
|
1962
|
+
/** Return the DEEP price for the pool. */
|
|
1963
|
+
export function getOrderDeepPrice(options: GetOrderDeepPriceOptions) {
|
|
1964
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
1965
|
+
const argumentsTypes = [
|
|
1966
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
1967
|
+
] satisfies string[];
|
|
1968
|
+
const parameterNames = ['self'];
|
|
1969
|
+
return (tx: Transaction) =>
|
|
1970
|
+
tx.moveCall({
|
|
1971
|
+
package: packageAddress,
|
|
1972
|
+
module: 'pool',
|
|
1973
|
+
function: 'get_order_deep_price',
|
|
1974
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1975
|
+
typeArguments: options.typeArguments,
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
export interface GetOrderDeepRequiredArguments {
|
|
1979
|
+
self: RawTransactionArgument<string>;
|
|
1980
|
+
baseQuantity: RawTransactionArgument<number | bigint>;
|
|
1981
|
+
price: RawTransactionArgument<number | bigint>;
|
|
1982
|
+
}
|
|
1983
|
+
export interface GetOrderDeepRequiredOptions {
|
|
1984
|
+
package?: string;
|
|
1985
|
+
arguments:
|
|
1986
|
+
| GetOrderDeepRequiredArguments
|
|
1987
|
+
| [
|
|
1988
|
+
self: RawTransactionArgument<string>,
|
|
1989
|
+
baseQuantity: RawTransactionArgument<number | bigint>,
|
|
1990
|
+
price: RawTransactionArgument<number | bigint>,
|
|
1991
|
+
];
|
|
1992
|
+
typeArguments: [string, string];
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* Returns the deep required for an order if it's taker or maker given quantity and
|
|
1996
|
+
* price Does not account for discounted taker fees Returns (deep_required_taker,
|
|
1997
|
+
* deep_required_maker)
|
|
1998
|
+
*/
|
|
1999
|
+
export function getOrderDeepRequired(options: GetOrderDeepRequiredOptions) {
|
|
2000
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2001
|
+
const argumentsTypes = [
|
|
2002
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2003
|
+
'u64',
|
|
2004
|
+
'u64',
|
|
2005
|
+
] satisfies string[];
|
|
2006
|
+
const parameterNames = ['self', 'baseQuantity', 'price'];
|
|
2007
|
+
return (tx: Transaction) =>
|
|
2008
|
+
tx.moveCall({
|
|
2009
|
+
package: packageAddress,
|
|
2010
|
+
module: 'pool',
|
|
2011
|
+
function: 'get_order_deep_required',
|
|
2012
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2013
|
+
typeArguments: options.typeArguments,
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
export interface LockedBalanceArguments {
|
|
2017
|
+
self: RawTransactionArgument<string>;
|
|
2018
|
+
balanceManager: RawTransactionArgument<string>;
|
|
2019
|
+
}
|
|
2020
|
+
export interface LockedBalanceOptions {
|
|
2021
|
+
package?: string;
|
|
2022
|
+
arguments:
|
|
2023
|
+
| LockedBalanceArguments
|
|
2024
|
+
| [self: RawTransactionArgument<string>, balanceManager: RawTransactionArgument<string>];
|
|
2025
|
+
typeArguments: [string, string];
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Returns the locked balance for the balance_manager in the pool Returns
|
|
2029
|
+
* (base_quantity, quote_quantity, deep_quantity)
|
|
2030
|
+
*/
|
|
2031
|
+
export function lockedBalance(options: LockedBalanceOptions) {
|
|
2032
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2033
|
+
const argumentsTypes = [
|
|
2034
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2035
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
2036
|
+
] satisfies string[];
|
|
2037
|
+
const parameterNames = ['self', 'balanceManager'];
|
|
2038
|
+
return (tx: Transaction) =>
|
|
2039
|
+
tx.moveCall({
|
|
2040
|
+
package: packageAddress,
|
|
2041
|
+
module: 'pool',
|
|
2042
|
+
function: 'locked_balance',
|
|
2043
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2044
|
+
typeArguments: options.typeArguments,
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
export interface PoolTradeParamsArguments {
|
|
2048
|
+
self: RawTransactionArgument<string>;
|
|
2049
|
+
}
|
|
2050
|
+
export interface PoolTradeParamsOptions {
|
|
2051
|
+
package?: string;
|
|
2052
|
+
arguments: PoolTradeParamsArguments | [self: RawTransactionArgument<string>];
|
|
2053
|
+
typeArguments: [string, string];
|
|
2054
|
+
}
|
|
2055
|
+
/** Returns the trade params for the pool. */
|
|
2056
|
+
export function poolTradeParams(options: PoolTradeParamsOptions) {
|
|
2057
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2058
|
+
const argumentsTypes = [
|
|
2059
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2060
|
+
] satisfies string[];
|
|
2061
|
+
const parameterNames = ['self'];
|
|
2062
|
+
return (tx: Transaction) =>
|
|
2063
|
+
tx.moveCall({
|
|
2064
|
+
package: packageAddress,
|
|
2065
|
+
module: 'pool',
|
|
2066
|
+
function: 'pool_trade_params',
|
|
2067
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2068
|
+
typeArguments: options.typeArguments,
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
export interface PoolTradeParamsNextArguments {
|
|
2072
|
+
self: RawTransactionArgument<string>;
|
|
2073
|
+
}
|
|
2074
|
+
export interface PoolTradeParamsNextOptions {
|
|
2075
|
+
package?: string;
|
|
2076
|
+
arguments: PoolTradeParamsNextArguments | [self: RawTransactionArgument<string>];
|
|
2077
|
+
typeArguments: [string, string];
|
|
2078
|
+
}
|
|
2079
|
+
/** Returns the currently leading trade params for the next epoch for the pool */
|
|
2080
|
+
export function poolTradeParamsNext(options: PoolTradeParamsNextOptions) {
|
|
2081
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2082
|
+
const argumentsTypes = [
|
|
2083
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2084
|
+
] satisfies string[];
|
|
2085
|
+
const parameterNames = ['self'];
|
|
2086
|
+
return (tx: Transaction) =>
|
|
2087
|
+
tx.moveCall({
|
|
2088
|
+
package: packageAddress,
|
|
2089
|
+
module: 'pool',
|
|
2090
|
+
function: 'pool_trade_params_next',
|
|
2091
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2092
|
+
typeArguments: options.typeArguments,
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
export interface PoolBookParamsArguments {
|
|
2096
|
+
self: RawTransactionArgument<string>;
|
|
2097
|
+
}
|
|
2098
|
+
export interface PoolBookParamsOptions {
|
|
2099
|
+
package?: string;
|
|
2100
|
+
arguments: PoolBookParamsArguments | [self: RawTransactionArgument<string>];
|
|
2101
|
+
typeArguments: [string, string];
|
|
2102
|
+
}
|
|
2103
|
+
/** Returns the tick size, lot size, and min size for the pool. */
|
|
2104
|
+
export function poolBookParams(options: PoolBookParamsOptions) {
|
|
2105
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2106
|
+
const argumentsTypes = [
|
|
2107
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2108
|
+
] satisfies string[];
|
|
2109
|
+
const parameterNames = ['self'];
|
|
2110
|
+
return (tx: Transaction) =>
|
|
2111
|
+
tx.moveCall({
|
|
2112
|
+
package: packageAddress,
|
|
2113
|
+
module: 'pool',
|
|
2114
|
+
function: 'pool_book_params',
|
|
2115
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2116
|
+
typeArguments: options.typeArguments,
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
export interface AccountArguments {
|
|
2120
|
+
self: RawTransactionArgument<string>;
|
|
2121
|
+
balanceManager: RawTransactionArgument<string>;
|
|
2122
|
+
}
|
|
2123
|
+
export interface AccountOptions {
|
|
2124
|
+
package?: string;
|
|
2125
|
+
arguments:
|
|
2126
|
+
| AccountArguments
|
|
2127
|
+
| [self: RawTransactionArgument<string>, balanceManager: RawTransactionArgument<string>];
|
|
2128
|
+
typeArguments: [string, string];
|
|
2129
|
+
}
|
|
2130
|
+
export function account(options: AccountOptions) {
|
|
2131
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2132
|
+
const argumentsTypes = [
|
|
2133
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2134
|
+
`${packageAddress}::balance_manager::BalanceManager`,
|
|
2135
|
+
] satisfies string[];
|
|
2136
|
+
const parameterNames = ['self', 'balanceManager'];
|
|
2137
|
+
return (tx: Transaction) =>
|
|
2138
|
+
tx.moveCall({
|
|
2139
|
+
package: packageAddress,
|
|
2140
|
+
module: 'pool',
|
|
2141
|
+
function: 'account',
|
|
2142
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2143
|
+
typeArguments: options.typeArguments,
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
export interface QuorumArguments {
|
|
2147
|
+
self: RawTransactionArgument<string>;
|
|
2148
|
+
}
|
|
2149
|
+
export interface QuorumOptions {
|
|
2150
|
+
package?: string;
|
|
2151
|
+
arguments: QuorumArguments | [self: RawTransactionArgument<string>];
|
|
2152
|
+
typeArguments: [string, string];
|
|
2153
|
+
}
|
|
2154
|
+
/** Returns the quorum needed to pass proposal in the current epoch */
|
|
2155
|
+
export function quorum(options: QuorumOptions) {
|
|
2156
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2157
|
+
const argumentsTypes = [
|
|
2158
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2159
|
+
] satisfies string[];
|
|
2160
|
+
const parameterNames = ['self'];
|
|
2161
|
+
return (tx: Transaction) =>
|
|
2162
|
+
tx.moveCall({
|
|
2163
|
+
package: packageAddress,
|
|
2164
|
+
module: 'pool',
|
|
2165
|
+
function: 'quorum',
|
|
2166
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2167
|
+
typeArguments: options.typeArguments,
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
export interface IdArguments {
|
|
2171
|
+
self: RawTransactionArgument<string>;
|
|
2172
|
+
}
|
|
2173
|
+
export interface IdOptions {
|
|
2174
|
+
package?: string;
|
|
2175
|
+
arguments: IdArguments | [self: RawTransactionArgument<string>];
|
|
2176
|
+
typeArguments: [string, string];
|
|
2177
|
+
}
|
|
2178
|
+
export function id(options: IdOptions) {
|
|
2179
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2180
|
+
const argumentsTypes = [
|
|
2181
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2182
|
+
] satisfies string[];
|
|
2183
|
+
const parameterNames = ['self'];
|
|
2184
|
+
return (tx: Transaction) =>
|
|
2185
|
+
tx.moveCall({
|
|
2186
|
+
package: packageAddress,
|
|
2187
|
+
module: 'pool',
|
|
2188
|
+
function: 'id',
|
|
2189
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2190
|
+
typeArguments: options.typeArguments,
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
export interface MarginTradingEnabledArguments {
|
|
2194
|
+
self: RawTransactionArgument<string>;
|
|
2195
|
+
}
|
|
2196
|
+
export interface MarginTradingEnabledOptions {
|
|
2197
|
+
package?: string;
|
|
2198
|
+
arguments: MarginTradingEnabledArguments | [self: RawTransactionArgument<string>];
|
|
2199
|
+
typeArguments: [string, string];
|
|
2200
|
+
}
|
|
2201
|
+
export function marginTradingEnabled(options: MarginTradingEnabledOptions) {
|
|
2202
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2203
|
+
const argumentsTypes = [
|
|
2204
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[0]}, ${options.typeArguments[1]}>`,
|
|
2205
|
+
] satisfies string[];
|
|
2206
|
+
const parameterNames = ['self'];
|
|
2207
|
+
return (tx: Transaction) =>
|
|
2208
|
+
tx.moveCall({
|
|
2209
|
+
package: packageAddress,
|
|
2210
|
+
module: 'pool',
|
|
2211
|
+
function: 'margin_trading_enabled',
|
|
2212
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2213
|
+
typeArguments: options.typeArguments,
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
export interface IsAppAuthorizedArguments {
|
|
2217
|
+
self: RawTransactionArgument<string>;
|
|
2218
|
+
}
|
|
2219
|
+
export interface IsAppAuthorizedOptions {
|
|
2220
|
+
package?: string;
|
|
2221
|
+
arguments: IsAppAuthorizedArguments | [self: RawTransactionArgument<string>];
|
|
2222
|
+
typeArguments: [string, string, string];
|
|
2223
|
+
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Check if an application is authorized to access protected features of DeepBook
|
|
2226
|
+
* core.
|
|
2227
|
+
*/
|
|
2228
|
+
export function isAppAuthorized(options: IsAppAuthorizedOptions) {
|
|
2229
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2230
|
+
const argumentsTypes = [
|
|
2231
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}, ${options.typeArguments[2]}>`,
|
|
2232
|
+
] satisfies string[];
|
|
2233
|
+
const parameterNames = ['self'];
|
|
2234
|
+
return (tx: Transaction) =>
|
|
2235
|
+
tx.moveCall({
|
|
2236
|
+
package: packageAddress,
|
|
2237
|
+
module: 'pool',
|
|
2238
|
+
function: 'is_app_authorized',
|
|
2239
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2240
|
+
typeArguments: options.typeArguments,
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
export interface AssertAppIsAuthorizedArguments {
|
|
2244
|
+
self: RawTransactionArgument<string>;
|
|
2245
|
+
}
|
|
2246
|
+
export interface AssertAppIsAuthorizedOptions {
|
|
2247
|
+
package?: string;
|
|
2248
|
+
arguments: AssertAppIsAuthorizedArguments | [self: RawTransactionArgument<string>];
|
|
2249
|
+
typeArguments: [string, string, string];
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Assert that an application is authorized to access protected features of
|
|
2253
|
+
* DeepBook core. Aborts with `EAppNotAuthorized` if not.
|
|
2254
|
+
*/
|
|
2255
|
+
export function assertAppIsAuthorized(options: AssertAppIsAuthorizedOptions) {
|
|
2256
|
+
const packageAddress = options.package ?? '@deepbook/core';
|
|
2257
|
+
const argumentsTypes = [
|
|
2258
|
+
`${packageAddress}::pool::Pool<${options.typeArguments[1]}, ${options.typeArguments[2]}>`,
|
|
2259
|
+
] satisfies string[];
|
|
2260
|
+
const parameterNames = ['self'];
|
|
2261
|
+
return (tx: Transaction) =>
|
|
2262
|
+
tx.moveCall({
|
|
2263
|
+
package: packageAddress,
|
|
2264
|
+
module: 'pool',
|
|
2265
|
+
function: 'assert_app_is_authorized',
|
|
2266
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
2267
|
+
typeArguments: options.typeArguments,
|
|
2268
|
+
});
|
|
2269
|
+
}
|