@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,26 @@
|
|
|
1
|
+
export type HexString = string;
|
|
2
|
+
export type PriceFeedRequestConfig = {
|
|
3
|
+
verbose?: boolean;
|
|
4
|
+
binary?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type PriceServiceConnectionConfig = {
|
|
7
|
+
timeout?: number;
|
|
8
|
+
httpRetries?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class PriceServiceConnection {
|
|
11
|
+
private httpClient;
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new Connection.
|
|
14
|
+
*
|
|
15
|
+
* @param endpoint endpoint URL to the price service.
|
|
16
|
+
* @param config Optional configuration for custom setups.
|
|
17
|
+
*/
|
|
18
|
+
constructor(endpoint: string, config?: PriceServiceConnectionConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Fetch latest VAAs of given price IDs.
|
|
21
|
+
*
|
|
22
|
+
* @param priceIds Array of hex-encoded price IDs.
|
|
23
|
+
* @returns Array of base64 encoded VAAs.
|
|
24
|
+
*/
|
|
25
|
+
getLatestVaas(priceIds: HexString[]): Promise<string[]>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import axiosRetry from "axios-retry";
|
|
3
|
+
class PriceServiceConnection {
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a new Connection.
|
|
6
|
+
*
|
|
7
|
+
* @param endpoint endpoint URL to the price service.
|
|
8
|
+
* @param config Optional configuration for custom setups.
|
|
9
|
+
*/
|
|
10
|
+
constructor(endpoint, config) {
|
|
11
|
+
this.httpClient = axios.create({
|
|
12
|
+
baseURL: endpoint,
|
|
13
|
+
timeout: config?.timeout || 5e3
|
|
14
|
+
});
|
|
15
|
+
axiosRetry(this.httpClient, {
|
|
16
|
+
retries: config?.httpRetries || 3,
|
|
17
|
+
retryDelay: axiosRetry.exponentialDelay
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Fetch latest VAAs of given price IDs.
|
|
22
|
+
*
|
|
23
|
+
* @param priceIds Array of hex-encoded price IDs.
|
|
24
|
+
* @returns Array of base64 encoded VAAs.
|
|
25
|
+
*/
|
|
26
|
+
async getLatestVaas(priceIds) {
|
|
27
|
+
const response = await this.httpClient.get("/api/latest_vaas", {
|
|
28
|
+
params: {
|
|
29
|
+
ids: priceIds
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return response.data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
PriceServiceConnection
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=PriceServiceConnection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/pyth/PriceServiceConnection.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport axios from 'axios';\nimport type { AxiosInstance } from 'axios';\nimport axiosRetry from 'axios-retry';\n\nexport type HexString = string;\nexport type PriceFeedRequestConfig = {\n\tverbose?: boolean;\n\tbinary?: boolean;\n};\nexport type PriceServiceConnectionConfig = {\n\ttimeout?: number;\n\thttpRetries?: number;\n};\nexport class PriceServiceConnection {\n\tprivate httpClient: AxiosInstance;\n\t/**\n\t * Constructs a new Connection.\n\t *\n\t * @param endpoint endpoint URL to the price service.\n\t * @param config Optional configuration for custom setups.\n\t */\n\tconstructor(endpoint: string, config?: PriceServiceConnectionConfig) {\n\t\tthis.httpClient = axios.create({\n\t\t\tbaseURL: endpoint,\n\t\t\ttimeout: config?.timeout || 5000,\n\t\t});\n\t\taxiosRetry(this.httpClient, {\n\t\t\tretries: config?.httpRetries || 3,\n\t\t\tretryDelay: axiosRetry.exponentialDelay,\n\t\t});\n\t}\n\t/**\n\t * Fetch latest VAAs of given price IDs.\n\t *\n\t * @param priceIds Array of hex-encoded price IDs.\n\t * @returns Array of base64 encoded VAAs.\n\t */\n\tasync getLatestVaas(priceIds: HexString[]): Promise<string[]> {\n\t\tconst response = await this.httpClient.get('/api/latest_vaas', {\n\t\t\tparams: {\n\t\t\t\tids: priceIds,\n\t\t\t},\n\t\t});\n\t\treturn response.data;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAEA,OAAO,WAAW;AAElB,OAAO,gBAAgB;AAWhB,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAY,UAAkB,QAAuC;AACpE,SAAK,aAAa,MAAM,OAAO;AAAA,MAC9B,SAAS;AAAA,MACT,SAAS,QAAQ,WAAW;AAAA,IAC7B,CAAC;AACD,eAAW,KAAK,YAAY;AAAA,MAC3B,SAAS,QAAQ,eAAe;AAAA,MAChC,YAAY,WAAW;AAAA,IACxB,CAAC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,UAA0C;AAC7D,UAAM,WAAW,MAAM,KAAK,WAAW,IAAI,oBAAoB;AAAA,MAC9D,QAAQ;AAAA,QACP,KAAK;AAAA,MACN;AAAA,IACD,CAAC;AACD,WAAO,SAAS;AAAA,EACjB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the VAA bytes embedded in an accumulator message.
|
|
3
|
+
*
|
|
4
|
+
* @param accumulatorMessage The accumulator price update message as a Uint8Array.
|
|
5
|
+
* @returns VAA bytes as a Uint8Array.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function extractVaaBytesFromAccumulatorMessage(accumulatorMessage) {
|
|
2
|
+
const dataView = new DataView(
|
|
3
|
+
accumulatorMessage.buffer,
|
|
4
|
+
accumulatorMessage.byteOffset,
|
|
5
|
+
accumulatorMessage.byteLength
|
|
6
|
+
);
|
|
7
|
+
const trailingPayloadSize = dataView.getUint8(6);
|
|
8
|
+
const vaaSizeOffset = 7 + trailingPayloadSize + 1;
|
|
9
|
+
const vaaSize = dataView.getUint16(vaaSizeOffset, false);
|
|
10
|
+
const vaaOffset = vaaSizeOffset + 2;
|
|
11
|
+
return accumulatorMessage.subarray(vaaOffset, vaaOffset + vaaSize);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
extractVaaBytesFromAccumulatorMessage
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=pyth-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/pyth/pyth-helpers.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Extracts the VAA bytes embedded in an accumulator message.\n *\n * @param accumulatorMessage The accumulator price update message as a Uint8Array.\n * @returns VAA bytes as a Uint8Array.\n */\nexport function extractVaaBytesFromAccumulatorMessage(accumulatorMessage: Uint8Array): Uint8Array {\n\tconst dataView = new DataView(\n\t\taccumulatorMessage.buffer,\n\t\taccumulatorMessage.byteOffset,\n\t\taccumulatorMessage.byteLength,\n\t);\n\n\tconst trailingPayloadSize = dataView.getUint8(6);\n\tconst vaaSizeOffset = 7 + trailingPayloadSize + 1; // Header (7 bytes), trailing payload size, proof type\n\tconst vaaSize = dataView.getUint16(vaaSizeOffset, false); // Read 2 bytes for VAA size (big-endian)\n\tconst vaaOffset = vaaSizeOffset + 2; // VAA size is 2 bytes\n\n\treturn accumulatorMessage.subarray(vaaOffset, vaaOffset + vaaSize);\n}\n"],
|
|
5
|
+
"mappings": "AASO,SAAS,sCAAsC,oBAA4C;AACjG,QAAM,WAAW,IAAI;AAAA,IACpB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,EACpB;AAEA,QAAM,sBAAsB,SAAS,SAAS,CAAC;AAC/C,QAAM,gBAAgB,IAAI,sBAAsB;AAChD,QAAM,UAAU,SAAS,UAAU,eAAe,KAAK;AACvD,QAAM,YAAY,gBAAgB;AAElC,SAAO,mBAAmB,SAAS,WAAW,YAAY,OAAO;AAClE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { HaneulClient } from '@haneullabs/haneul/client';
|
|
2
|
+
import type { Transaction } from '@haneullabs/haneul/transactions';
|
|
3
|
+
import type { HexString } from './PriceServiceConnection.js';
|
|
4
|
+
import { PriceServiceConnection } from './PriceServiceConnection.js';
|
|
5
|
+
export type ObjectId = string;
|
|
6
|
+
export declare class HaneulPriceServiceConnection extends PriceServiceConnection {
|
|
7
|
+
/**
|
|
8
|
+
* Fetch price feed update data.
|
|
9
|
+
*
|
|
10
|
+
* @param priceIds Array of hex-encoded price IDs.
|
|
11
|
+
* @returns Array of buffers containing the price update data.
|
|
12
|
+
*/
|
|
13
|
+
getPriceFeedsUpdateData(priceIds: HexString[]): Promise<Uint8Array[]>;
|
|
14
|
+
}
|
|
15
|
+
export declare class HaneulPythClient {
|
|
16
|
+
#private;
|
|
17
|
+
provider: HaneulClient;
|
|
18
|
+
pythStateId: ObjectId;
|
|
19
|
+
wormholeStateId: ObjectId;
|
|
20
|
+
constructor(provider: HaneulClient, pythStateId: ObjectId, wormholeStateId: ObjectId);
|
|
21
|
+
/**
|
|
22
|
+
* Verifies the VAAs using the Wormhole contract.
|
|
23
|
+
*
|
|
24
|
+
* @param vaas Array of VAA buffers to verify.
|
|
25
|
+
* @param tx Transaction block to add commands to.
|
|
26
|
+
* @returns Array of verified VAAs.
|
|
27
|
+
*/
|
|
28
|
+
verifyVaas(vaas: Uint8Array[], tx: Transaction): Promise<{
|
|
29
|
+
$kind: "NestedResult";
|
|
30
|
+
NestedResult: [number, number];
|
|
31
|
+
}[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Adds the necessary commands for updating the Pyth price feeds to the transaction block.
|
|
34
|
+
*
|
|
35
|
+
* @param tx Transaction block to add commands to.
|
|
36
|
+
* @param updates Array of price feed updates received from the price service.
|
|
37
|
+
* @param feedIds Array of feed IDs to update (in hex format).
|
|
38
|
+
*/
|
|
39
|
+
updatePriceFeeds(tx: Transaction, updates: Uint8Array[], feedIds: HexString[]): Promise<ObjectId[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the price feed object ID for a given feed ID, caching the promise.
|
|
42
|
+
* @param feedId
|
|
43
|
+
*/
|
|
44
|
+
getPriceFeedObjectId(feedId: HexString): Promise<ObjectId | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetches the price table object ID for the current state ID, caching the promise.
|
|
47
|
+
* @returns Price table object ID and field type
|
|
48
|
+
*/
|
|
49
|
+
getPriceTableInfo(): Promise<{
|
|
50
|
+
id: ObjectId;
|
|
51
|
+
fieldType: ObjectId;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Fetches the package ID for the Wormhole contract, with caching.
|
|
55
|
+
*/
|
|
56
|
+
getWormholePackageId(): Promise<ObjectId>;
|
|
57
|
+
/**
|
|
58
|
+
* Fetches the package ID for the Pyth contract, with caching.
|
|
59
|
+
*/
|
|
60
|
+
getPythPackageId(): Promise<ObjectId>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the cached base update fee, fetching it if necessary.
|
|
63
|
+
*/
|
|
64
|
+
getBaseUpdateFee(): Promise<number>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
+
var _pythPackageId, _wormholePackageId, _priceFeedObjectIdCache, _priceTableInfo, _baseUpdateFee, _HaneulPythClient_instances, fetchPriceFeedObjectId_fn, fetchPriceTableInfo_fn, fetchWormholePackageId_fn, fetchPythPackageId_fn, getPackageId_fn, fetchBaseUpdateFee_fn;
|
|
10
|
+
import { bcs } from "@haneullabs/haneul/bcs";
|
|
11
|
+
import { coinWithBalance } from "@haneullabs/haneul/transactions";
|
|
12
|
+
import { fromBase64, fromHex, parseStructTag } from "@haneullabs/haneul/utils";
|
|
13
|
+
import { PriceServiceConnection } from "./PriceServiceConnection.js";
|
|
14
|
+
import { extractVaaBytesFromAccumulatorMessage } from "./pyth-helpers.js";
|
|
15
|
+
const MAX_ARGUMENT_SIZE = 16 * 1024;
|
|
16
|
+
class HaneulPriceServiceConnection extends PriceServiceConnection {
|
|
17
|
+
/**
|
|
18
|
+
* Fetch price feed update data.
|
|
19
|
+
*
|
|
20
|
+
* @param priceIds Array of hex-encoded price IDs.
|
|
21
|
+
* @returns Array of buffers containing the price update data.
|
|
22
|
+
*/
|
|
23
|
+
async getPriceFeedsUpdateData(priceIds) {
|
|
24
|
+
const latestVaas = await this.getLatestVaas(priceIds);
|
|
25
|
+
return latestVaas.map((vaa) => fromBase64(vaa));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
class HaneulPythClient {
|
|
29
|
+
constructor(provider, pythStateId, wormholeStateId) {
|
|
30
|
+
__privateAdd(this, _HaneulPythClient_instances);
|
|
31
|
+
__privateAdd(this, _pythPackageId);
|
|
32
|
+
__privateAdd(this, _wormholePackageId);
|
|
33
|
+
__privateAdd(this, _priceFeedObjectIdCache, /* @__PURE__ */ new Map());
|
|
34
|
+
__privateAdd(this, _priceTableInfo);
|
|
35
|
+
__privateAdd(this, _baseUpdateFee);
|
|
36
|
+
this.provider = provider;
|
|
37
|
+
this.pythStateId = pythStateId;
|
|
38
|
+
this.wormholeStateId = wormholeStateId;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Verifies the VAAs using the Wormhole contract.
|
|
42
|
+
*
|
|
43
|
+
* @param vaas Array of VAA buffers to verify.
|
|
44
|
+
* @param tx Transaction block to add commands to.
|
|
45
|
+
* @returns Array of verified VAAs.
|
|
46
|
+
*/
|
|
47
|
+
async verifyVaas(vaas, tx) {
|
|
48
|
+
const wormholePackageId = await this.getWormholePackageId();
|
|
49
|
+
const verifiedVaas = [];
|
|
50
|
+
for (const vaa of vaas) {
|
|
51
|
+
const [verifiedVaa] = tx.moveCall({
|
|
52
|
+
target: `${wormholePackageId}::vaa::parse_and_verify`,
|
|
53
|
+
arguments: [tx.object(this.wormholeStateId), tx.pure.vector("u8", vaa), tx.object.clock()]
|
|
54
|
+
});
|
|
55
|
+
verifiedVaas.push(verifiedVaa);
|
|
56
|
+
}
|
|
57
|
+
return verifiedVaas;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Adds the necessary commands for updating the Pyth price feeds to the transaction block.
|
|
61
|
+
*
|
|
62
|
+
* @param tx Transaction block to add commands to.
|
|
63
|
+
* @param updates Array of price feed updates received from the price service.
|
|
64
|
+
* @param feedIds Array of feed IDs to update (in hex format).
|
|
65
|
+
*/
|
|
66
|
+
async updatePriceFeeds(tx, updates, feedIds) {
|
|
67
|
+
const packageId = await this.getPythPackageId();
|
|
68
|
+
let priceUpdatesHotPotato;
|
|
69
|
+
if (updates.length > 1) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
"SDK does not support sending multiple accumulator messages in a single transaction"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const vaa = extractVaaBytesFromAccumulatorMessage(updates[0]);
|
|
75
|
+
const verifiedVaas = await this.verifyVaas([vaa], tx);
|
|
76
|
+
[priceUpdatesHotPotato] = tx.moveCall({
|
|
77
|
+
target: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,
|
|
78
|
+
arguments: [
|
|
79
|
+
tx.object(this.pythStateId),
|
|
80
|
+
tx.pure(
|
|
81
|
+
bcs.vector(bcs.U8).serialize(Array.from(updates[0]), {
|
|
82
|
+
maxSize: MAX_ARGUMENT_SIZE
|
|
83
|
+
}).toBytes()
|
|
84
|
+
),
|
|
85
|
+
verifiedVaas[0],
|
|
86
|
+
tx.object.clock()
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
const priceInfoObjects = [];
|
|
90
|
+
const baseUpdateFee = await this.getBaseUpdateFee();
|
|
91
|
+
for (const feedId of feedIds) {
|
|
92
|
+
const priceInfoObjectId = await this.getPriceFeedObjectId(feedId);
|
|
93
|
+
if (!priceInfoObjectId) {
|
|
94
|
+
throw new Error(`Price feed ${feedId} not found, please create it first`);
|
|
95
|
+
}
|
|
96
|
+
priceInfoObjects.push(priceInfoObjectId);
|
|
97
|
+
[priceUpdatesHotPotato] = tx.moveCall({
|
|
98
|
+
target: `${packageId}::pyth::update_single_price_feed`,
|
|
99
|
+
arguments: [
|
|
100
|
+
tx.object(this.pythStateId),
|
|
101
|
+
priceUpdatesHotPotato,
|
|
102
|
+
tx.object(priceInfoObjectId),
|
|
103
|
+
coinWithBalance({ balance: baseUpdateFee }),
|
|
104
|
+
tx.object.clock()
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
tx.moveCall({
|
|
109
|
+
target: `${packageId}::hot_potato_vector::destroy`,
|
|
110
|
+
arguments: [priceUpdatesHotPotato],
|
|
111
|
+
typeArguments: [`${packageId}::price_info::PriceInfo`]
|
|
112
|
+
});
|
|
113
|
+
return priceInfoObjects;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the price feed object ID for a given feed ID, caching the promise.
|
|
117
|
+
* @param feedId
|
|
118
|
+
*/
|
|
119
|
+
getPriceFeedObjectId(feedId) {
|
|
120
|
+
if (!__privateGet(this, _priceFeedObjectIdCache).has(feedId)) {
|
|
121
|
+
__privateGet(this, _priceFeedObjectIdCache).set(
|
|
122
|
+
feedId,
|
|
123
|
+
__privateMethod(this, _HaneulPythClient_instances, fetchPriceFeedObjectId_fn).call(this, feedId).catch((err) => {
|
|
124
|
+
__privateGet(this, _priceFeedObjectIdCache).delete(feedId);
|
|
125
|
+
throw err;
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return __privateGet(this, _priceFeedObjectIdCache).get(feedId);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Fetches the price table object ID for the current state ID, caching the promise.
|
|
133
|
+
* @returns Price table object ID and field type
|
|
134
|
+
*/
|
|
135
|
+
getPriceTableInfo() {
|
|
136
|
+
if (!__privateGet(this, _priceTableInfo)) {
|
|
137
|
+
const promise = __privateMethod(this, _HaneulPythClient_instances, fetchPriceTableInfo_fn).call(this).catch((err) => {
|
|
138
|
+
__privateSet(this, _priceTableInfo, void 0);
|
|
139
|
+
throw err;
|
|
140
|
+
});
|
|
141
|
+
__privateSet(this, _priceTableInfo, promise);
|
|
142
|
+
}
|
|
143
|
+
return __privateGet(this, _priceTableInfo);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Fetches the package ID for the Wormhole contract, with caching.
|
|
147
|
+
*/
|
|
148
|
+
getWormholePackageId() {
|
|
149
|
+
if (!__privateGet(this, _wormholePackageId)) {
|
|
150
|
+
__privateSet(this, _wormholePackageId, __privateMethod(this, _HaneulPythClient_instances, fetchWormholePackageId_fn).call(this));
|
|
151
|
+
}
|
|
152
|
+
return __privateGet(this, _wormholePackageId);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Fetches the package ID for the Pyth contract, with caching.
|
|
156
|
+
*/
|
|
157
|
+
getPythPackageId() {
|
|
158
|
+
if (!__privateGet(this, _pythPackageId)) {
|
|
159
|
+
__privateSet(this, _pythPackageId, __privateMethod(this, _HaneulPythClient_instances, fetchPythPackageId_fn).call(this));
|
|
160
|
+
}
|
|
161
|
+
return __privateGet(this, _pythPackageId);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns the cached base update fee, fetching it if necessary.
|
|
165
|
+
*/
|
|
166
|
+
getBaseUpdateFee() {
|
|
167
|
+
if (!__privateGet(this, _baseUpdateFee)) {
|
|
168
|
+
__privateSet(this, _baseUpdateFee, __privateMethod(this, _HaneulPythClient_instances, fetchBaseUpdateFee_fn).call(this));
|
|
169
|
+
}
|
|
170
|
+
return __privateGet(this, _baseUpdateFee);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
_pythPackageId = new WeakMap();
|
|
174
|
+
_wormholePackageId = new WeakMap();
|
|
175
|
+
_priceFeedObjectIdCache = new WeakMap();
|
|
176
|
+
_priceTableInfo = new WeakMap();
|
|
177
|
+
_baseUpdateFee = new WeakMap();
|
|
178
|
+
_HaneulPythClient_instances = new WeakSet();
|
|
179
|
+
fetchPriceFeedObjectId_fn = async function(feedId) {
|
|
180
|
+
const { id: tableId, fieldType } = await this.getPriceTableInfo();
|
|
181
|
+
const result = await this.provider.getDynamicFieldObject({
|
|
182
|
+
parentId: tableId,
|
|
183
|
+
name: {
|
|
184
|
+
type: `${fieldType}::price_identifier::PriceIdentifier`,
|
|
185
|
+
value: {
|
|
186
|
+
bytes: Array.from(fromHex(feedId))
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
if (!result.data || !result.data.content) {
|
|
191
|
+
throw new Error(`Price feed object ID for feed ID ${feedId} not found.`);
|
|
192
|
+
}
|
|
193
|
+
if (result.data.content.dataType !== "moveObject") {
|
|
194
|
+
throw new Error("Price feed type mismatch");
|
|
195
|
+
}
|
|
196
|
+
const fields = result.data.content.fields;
|
|
197
|
+
return fields.value;
|
|
198
|
+
};
|
|
199
|
+
fetchPriceTableInfo_fn = async function() {
|
|
200
|
+
const result = await this.provider.getDynamicFieldObject({
|
|
201
|
+
parentId: this.pythStateId,
|
|
202
|
+
name: {
|
|
203
|
+
type: "vector<u8>",
|
|
204
|
+
value: "price_info"
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
if (!result.data || !result.data.type) {
|
|
208
|
+
throw new Error("Price Table not found, contract may not be initialized");
|
|
209
|
+
}
|
|
210
|
+
const priceIdentifier = parseStructTag(result.data.type).typeParams[0];
|
|
211
|
+
if (typeof priceIdentifier === "object" && priceIdentifier !== null && priceIdentifier.name === "PriceIdentifier" && "address" in priceIdentifier) {
|
|
212
|
+
return { id: result.data.objectId, fieldType: priceIdentifier.address };
|
|
213
|
+
} else {
|
|
214
|
+
throw new Error("fieldType not found");
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
fetchWormholePackageId_fn = async function() {
|
|
218
|
+
return await __privateMethod(this, _HaneulPythClient_instances, getPackageId_fn).call(this, this.wormholeStateId);
|
|
219
|
+
};
|
|
220
|
+
fetchPythPackageId_fn = async function() {
|
|
221
|
+
return await __privateMethod(this, _HaneulPythClient_instances, getPackageId_fn).call(this, this.pythStateId);
|
|
222
|
+
};
|
|
223
|
+
getPackageId_fn = async function(objectId) {
|
|
224
|
+
const result = await this.provider.getObject({
|
|
225
|
+
id: objectId,
|
|
226
|
+
options: { showContent: true }
|
|
227
|
+
});
|
|
228
|
+
if (result.data?.content?.dataType === "moveObject" && "upgrade_cap" in result.data.content.fields) {
|
|
229
|
+
const fields = result.data.content.fields;
|
|
230
|
+
return fields.upgrade_cap.fields.package;
|
|
231
|
+
}
|
|
232
|
+
throw new Error(`Cannot fetch package ID for object ${objectId}`);
|
|
233
|
+
};
|
|
234
|
+
fetchBaseUpdateFee_fn = async function() {
|
|
235
|
+
const result = await this.provider.getObject({
|
|
236
|
+
id: this.pythStateId,
|
|
237
|
+
options: { showContent: true }
|
|
238
|
+
});
|
|
239
|
+
if (!result.data || result.data.content?.dataType !== "moveObject") {
|
|
240
|
+
throw new Error("Unable to fetch Pyth state object");
|
|
241
|
+
}
|
|
242
|
+
const fields = result.data.content.fields;
|
|
243
|
+
return fields.base_update_fee;
|
|
244
|
+
};
|
|
245
|
+
export {
|
|
246
|
+
HaneulPriceServiceConnection,
|
|
247
|
+
HaneulPythClient
|
|
248
|
+
};
|
|
249
|
+
//# sourceMappingURL=pyth.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/pyth/pyth.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\nimport type { HaneulClient } from '@haneullabs/haneul/client';\nimport type { Transaction } from '@haneullabs/haneul/transactions';\nimport { coinWithBalance } from '@haneullabs/haneul/transactions';\nimport { fromBase64, fromHex, parseStructTag } from '@haneullabs/haneul/utils';\n\nimport type { HexString } from './PriceServiceConnection.js';\nimport { PriceServiceConnection } from './PriceServiceConnection.js';\nimport { extractVaaBytesFromAccumulatorMessage } from './pyth-helpers.js';\n\nconst MAX_ARGUMENT_SIZE = 16 * 1024;\nexport type ObjectId = string;\nexport class HaneulPriceServiceConnection extends PriceServiceConnection {\n\t/**\n\t * Fetch price feed update data.\n\t *\n\t * @param priceIds Array of hex-encoded price IDs.\n\t * @returns Array of buffers containing the price update data.\n\t */\n\tasync getPriceFeedsUpdateData(priceIds: HexString[]): Promise<Uint8Array[]> {\n\t\tconst latestVaas = await this.getLatestVaas(priceIds);\n\t\treturn latestVaas.map((vaa) => fromBase64(vaa));\n\t}\n}\nexport class HaneulPythClient {\n\t#pythPackageId?: Promise<ObjectId>;\n\t#wormholePackageId?: Promise<ObjectId>;\n\t#priceFeedObjectIdCache: Map<HexString, Promise<ObjectId>> = new Map();\n\t#priceTableInfo?: Promise<{ id: ObjectId; fieldType: ObjectId }>;\n\t#baseUpdateFee?: Promise<number>;\n\tprovider: HaneulClient;\n\tpythStateId: ObjectId;\n\twormholeStateId: ObjectId;\n\n\tconstructor(provider: HaneulClient, pythStateId: ObjectId, wormholeStateId: ObjectId) {\n\t\tthis.provider = provider;\n\t\tthis.pythStateId = pythStateId;\n\t\tthis.wormholeStateId = wormholeStateId;\n\t}\n\t/**\n\t * Verifies the VAAs using the Wormhole contract.\n\t *\n\t * @param vaas Array of VAA buffers to verify.\n\t * @param tx Transaction block to add commands to.\n\t * @returns Array of verified VAAs.\n\t */\n\tasync verifyVaas(vaas: Uint8Array[], tx: Transaction) {\n\t\tconst wormholePackageId = await this.getWormholePackageId();\n\t\tconst verifiedVaas = [];\n\t\tfor (const vaa of vaas) {\n\t\t\tconst [verifiedVaa] = tx.moveCall({\n\t\t\t\ttarget: `${wormholePackageId}::vaa::parse_and_verify`,\n\t\t\t\targuments: [tx.object(this.wormholeStateId), tx.pure.vector('u8', vaa), tx.object.clock()],\n\t\t\t});\n\t\t\tverifiedVaas.push(verifiedVaa);\n\t\t}\n\t\treturn verifiedVaas;\n\t}\n\t/**\n\t * Adds the necessary commands for updating the Pyth price feeds to the transaction block.\n\t *\n\t * @param tx Transaction block to add commands to.\n\t * @param updates Array of price feed updates received from the price service.\n\t * @param feedIds Array of feed IDs to update (in hex format).\n\t */\n\tasync updatePriceFeeds(\n\t\ttx: Transaction,\n\t\tupdates: Uint8Array[],\n\t\tfeedIds: HexString[],\n\t): Promise<ObjectId[]> {\n\t\tconst packageId = await this.getPythPackageId();\n\t\tlet priceUpdatesHotPotato;\n\t\tif (updates.length > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t'SDK does not support sending multiple accumulator messages in a single transaction',\n\t\t\t);\n\t\t}\n\t\tconst vaa = extractVaaBytesFromAccumulatorMessage(updates[0]);\n\t\tconst verifiedVaas = await this.verifyVaas([vaa], tx);\n\t\t[priceUpdatesHotPotato] = tx.moveCall({\n\t\t\ttarget: `${packageId}::pyth::create_authenticated_price_infos_using_accumulator`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.pythStateId),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.U8)\n\t\t\t\t\t\t.serialize(Array.from(updates[0]), {\n\t\t\t\t\t\t\tmaxSize: MAX_ARGUMENT_SIZE,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.toBytes(),\n\t\t\t\t),\n\t\t\t\tverifiedVaas[0],\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t});\n\t\tconst priceInfoObjects: ObjectId[] = [];\n\t\tconst baseUpdateFee = await this.getBaseUpdateFee();\n\t\tfor (const feedId of feedIds) {\n\t\t\tconst priceInfoObjectId = await this.getPriceFeedObjectId(feedId);\n\t\t\tif (!priceInfoObjectId) {\n\t\t\t\tthrow new Error(`Price feed ${feedId} not found, please create it first`);\n\t\t\t}\n\t\t\tpriceInfoObjects.push(priceInfoObjectId);\n\t\t\t[priceUpdatesHotPotato] = tx.moveCall({\n\t\t\t\ttarget: `${packageId}::pyth::update_single_price_feed`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(this.pythStateId),\n\t\t\t\t\tpriceUpdatesHotPotato,\n\t\t\t\t\ttx.object(priceInfoObjectId),\n\t\t\t\t\tcoinWithBalance({ balance: baseUpdateFee }),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\t\ttx.moveCall({\n\t\t\ttarget: `${packageId}::hot_potato_vector::destroy`,\n\t\t\targuments: [priceUpdatesHotPotato],\n\t\t\ttypeArguments: [`${packageId}::price_info::PriceInfo`],\n\t\t});\n\t\treturn priceInfoObjects;\n\t}\n\t/**\n\t * Get the price feed object ID for a given feed ID, caching the promise.\n\t * @param feedId\n\t */\n\tgetPriceFeedObjectId(feedId: HexString): Promise<ObjectId | undefined> {\n\t\tif (!this.#priceFeedObjectIdCache.has(feedId)) {\n\t\t\tthis.#priceFeedObjectIdCache.set(\n\t\t\t\tfeedId,\n\t\t\t\tthis.#fetchPriceFeedObjectId(feedId).catch((err) => {\n\t\t\t\t\t// Remove failed promises from the cache to allow retries\n\t\t\t\t\tthis.#priceFeedObjectIdCache.delete(feedId);\n\t\t\t\t\tthrow err;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn this.#priceFeedObjectIdCache.get(feedId)!;\n\t}\n\n\t/**\n\t * Fetches the price feed object ID for a given feed ID (no caching).\n\t * Throws an error if the object is not found.\n\t */\n\tasync #fetchPriceFeedObjectId(feedId: HexString): Promise<ObjectId> {\n\t\tconst { id: tableId, fieldType } = await this.getPriceTableInfo();\n\t\tconst result = await this.provider.getDynamicFieldObject({\n\t\t\tparentId: tableId,\n\t\t\tname: {\n\t\t\t\ttype: `${fieldType}::price_identifier::PriceIdentifier`,\n\t\t\t\tvalue: {\n\t\t\t\t\tbytes: Array.from(fromHex(feedId)),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tif (!result.data || !result.data.content) {\n\t\t\tthrow new Error(`Price feed object ID for feed ID ${feedId} not found.`);\n\t\t}\n\t\tif (result.data.content.dataType !== 'moveObject') {\n\t\t\tthrow new Error('Price feed type mismatch');\n\t\t}\n\n\t\tconst fields = result.data.content.fields as { value: string };\n\t\treturn fields.value;\n\t}\n\n\t/**\n\t * Fetches the price table object ID for the current state ID, caching the promise.\n\t * @returns Price table object ID and field type\n\t */\n\tgetPriceTableInfo(): Promise<{ id: ObjectId; fieldType: ObjectId }> {\n\t\tif (!this.#priceTableInfo) {\n\t\t\tconst promise = this.#fetchPriceTableInfo().catch((err) => {\n\t\t\t\t// Clear the cached promise on error\n\t\t\t\tthis.#priceTableInfo = undefined;\n\t\t\t\tthrow err;\n\t\t\t});\n\n\t\t\tthis.#priceTableInfo = promise;\n\t\t}\n\n\t\treturn this.#priceTableInfo;\n\t}\n\n\t/**\n\t * Fetches the price table object ID and field type (no caching).\n\t * @returns Price table object ID and field type\n\t */\n\tasync #fetchPriceTableInfo(): Promise<{ id: ObjectId; fieldType: ObjectId }> {\n\t\tconst result = await this.provider.getDynamicFieldObject({\n\t\t\tparentId: this.pythStateId,\n\t\t\tname: {\n\t\t\t\ttype: 'vector<u8>',\n\t\t\t\tvalue: 'price_info',\n\t\t\t},\n\t\t});\n\n\t\tif (!result.data || !result.data.type) {\n\t\t\tthrow new Error('Price Table not found, contract may not be initialized');\n\t\t}\n\n\t\tconst priceIdentifier = parseStructTag(result.data.type).typeParams[0];\n\t\tif (\n\t\t\ttypeof priceIdentifier === 'object' &&\n\t\t\tpriceIdentifier !== null &&\n\t\t\tpriceIdentifier.name === 'PriceIdentifier' &&\n\t\t\t'address' in priceIdentifier\n\t\t) {\n\t\t\treturn { id: result.data.objectId, fieldType: priceIdentifier.address };\n\t\t} else {\n\t\t\tthrow new Error('fieldType not found');\n\t\t}\n\t}\n\t/**\n\t * Fetches the package ID for the Wormhole contract, with caching.\n\t */\n\tgetWormholePackageId(): Promise<ObjectId> {\n\t\tif (!this.#wormholePackageId) {\n\t\t\tthis.#wormholePackageId = this.#fetchWormholePackageId();\n\t\t}\n\t\treturn this.#wormholePackageId;\n\t}\n\n\t/**\n\t * Fetches the package ID for the Wormhole contract (no caching).\n\t */\n\tasync #fetchWormholePackageId(): Promise<ObjectId> {\n\t\treturn await this.#getPackageId(this.wormholeStateId);\n\t}\n\n\t/**\n\t * Fetches the package ID for the Pyth contract, with caching.\n\t */\n\tgetPythPackageId(): Promise<ObjectId> {\n\t\tif (!this.#pythPackageId) {\n\t\t\tthis.#pythPackageId = this.#fetchPythPackageId();\n\t\t}\n\t\treturn this.#pythPackageId;\n\t}\n\n\t/**\n\t * Fetches the package ID for the Pyth contract (no caching).\n\t */\n\tasync #fetchPythPackageId(): Promise<ObjectId> {\n\t\treturn await this.#getPackageId(this.pythStateId);\n\t}\n\n\t/**\n\t * Fetches the package ID for a given object.\n\t *\n\t * @param objectId Object ID to fetch the package ID for.\n\t */\n\tasync #getPackageId(objectId: ObjectId): Promise<ObjectId> {\n\t\tconst result = await this.provider.getObject({\n\t\t\tid: objectId,\n\t\t\toptions: { showContent: true },\n\t\t});\n\n\t\tif (\n\t\t\tresult.data?.content?.dataType === 'moveObject' &&\n\t\t\t'upgrade_cap' in result.data.content.fields\n\t\t) {\n\t\t\tconst fields = result.data.content.fields as {\n\t\t\t\tupgrade_cap: {\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tpackage: ObjectId;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\treturn fields.upgrade_cap.fields.package;\n\t\t}\n\n\t\tthrow new Error(`Cannot fetch package ID for object ${objectId}`);\n\t}\n\t/**\n\t * Gets the base update fee from the Pyth state object.\n\t */\n\tasync #fetchBaseUpdateFee(): Promise<number> {\n\t\tconst result = await this.provider.getObject({\n\t\t\tid: this.pythStateId,\n\t\t\toptions: { showContent: true },\n\t\t});\n\n\t\tif (!result.data || result.data.content?.dataType !== 'moveObject') {\n\t\t\tthrow new Error('Unable to fetch Pyth state object');\n\t\t}\n\n\t\tconst fields = result.data.content.fields as { base_update_fee: number };\n\t\treturn fields.base_update_fee;\n\t}\n\n\t/**\n\t * Returns the cached base update fee, fetching it if necessary.\n\t */\n\tgetBaseUpdateFee(): Promise<number> {\n\t\tif (!this.#baseUpdateFee) {\n\t\t\tthis.#baseUpdateFee = this.#fetchBaseUpdateFee();\n\t\t}\n\t\treturn this.#baseUpdateFee;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { Transaction, TransactionArgument } from '@haneullabs/haneul/transactions';
|
|
2
|
+
import type { DeepBookConfig } from '../utils/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* BalanceManagerContract class for managing BalanceManager operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BalanceManagerContract {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* @param {DeepBookConfig} config Configuration for BalanceManagerContract
|
|
10
|
+
*/
|
|
11
|
+
constructor(config: DeepBookConfig);
|
|
12
|
+
/**
|
|
13
|
+
* @description Create and share a new BalanceManager
|
|
14
|
+
* @returns A function that takes a Transaction object
|
|
15
|
+
*/
|
|
16
|
+
createAndShareBalanceManager: () => (tx: Transaction) => void;
|
|
17
|
+
/**
|
|
18
|
+
* @description Create a new BalanceManager, manually set the owner. Returns the manager.
|
|
19
|
+
* @returns A function that takes a Transaction object
|
|
20
|
+
*/
|
|
21
|
+
createBalanceManagerWithOwner: (ownerAddress: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
22
|
+
/**
|
|
23
|
+
* @description Share the BalanceManager
|
|
24
|
+
* @param {TransactionArgument} manager The BalanceManager to share
|
|
25
|
+
* @returns A function that takes a Transaction object
|
|
26
|
+
*/
|
|
27
|
+
shareBalanceManager: (manager: TransactionArgument) => (tx: Transaction) => void;
|
|
28
|
+
/**
|
|
29
|
+
* @description Deposit funds into the BalanceManager
|
|
30
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
31
|
+
* @param {string} coinKey The key of the coin to deposit
|
|
32
|
+
* @param {number} amountToDeposit The amount to deposit
|
|
33
|
+
* @returns A function that takes a Transaction object
|
|
34
|
+
*/
|
|
35
|
+
depositIntoManager: (managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => void;
|
|
36
|
+
/**
|
|
37
|
+
* @description Withdraw funds from the BalanceManager
|
|
38
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
39
|
+
* @param {string} coinKey The key of the coin to withdraw
|
|
40
|
+
* @param {number} amountToWithdraw The amount to withdraw
|
|
41
|
+
* @param {string} recipient The recipient of the withdrawn funds
|
|
42
|
+
* @returns A function that takes a Transaction object
|
|
43
|
+
*/
|
|
44
|
+
withdrawFromManager: (managerKey: string, coinKey: string, amountToWithdraw: number, recipient: string) => (tx: Transaction) => void;
|
|
45
|
+
/**
|
|
46
|
+
* @description Withdraw all funds from the BalanceManager
|
|
47
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
48
|
+
* @param {string} coinKey The key of the coin to withdraw
|
|
49
|
+
* @param {string} recipient The recipient of the withdrawn funds
|
|
50
|
+
* @returns A function that takes a Transaction object
|
|
51
|
+
*/
|
|
52
|
+
withdrawAllFromManager: (managerKey: string, coinKey: string, recipient: string) => (tx: Transaction) => void;
|
|
53
|
+
/**
|
|
54
|
+
* @description Check the balance of the BalanceManager
|
|
55
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
56
|
+
* @param {string} coinKey The key of the coin to check the balance of
|
|
57
|
+
* @returns A function that takes a Transaction object
|
|
58
|
+
*/
|
|
59
|
+
checkManagerBalance: (managerKey: string, coinKey: string) => (tx: Transaction) => void;
|
|
60
|
+
/**
|
|
61
|
+
* @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.
|
|
62
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
63
|
+
* @returns A function that takes a Transaction object
|
|
64
|
+
*/
|
|
65
|
+
generateProof: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
66
|
+
/**
|
|
67
|
+
* @description Generate a trade proof as the owner
|
|
68
|
+
* @param {string} managerId The ID of the BalanceManager
|
|
69
|
+
* @returns A function that takes a Transaction object
|
|
70
|
+
*/
|
|
71
|
+
generateProofAsOwner: (managerId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
72
|
+
/**
|
|
73
|
+
* @description Generate a trade proof as a trader
|
|
74
|
+
* @param {string} managerId The ID of the BalanceManager
|
|
75
|
+
* @param {string} tradeCapId The ID of the tradeCap
|
|
76
|
+
* @returns A function that takes a Transaction object
|
|
77
|
+
*/
|
|
78
|
+
generateProofAsTrader: (managerId: string, tradeCapId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
79
|
+
/**
|
|
80
|
+
* @description Mint a TradeCap
|
|
81
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
82
|
+
* @returns A function that takes a Transaction object
|
|
83
|
+
*/
|
|
84
|
+
mintTradeCap: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
85
|
+
/**
|
|
86
|
+
* @description Mint a DepositCap
|
|
87
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
88
|
+
* @returns A function that takes a Transaction object
|
|
89
|
+
*/
|
|
90
|
+
mintDepositCap: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
91
|
+
/**
|
|
92
|
+
* @description Mint a WithdrawalCap
|
|
93
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
94
|
+
* @returns A function that takes a Transaction object
|
|
95
|
+
*/
|
|
96
|
+
mintWithdrawalCap: (managerKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
97
|
+
/**
|
|
98
|
+
* @description Deposit using the DepositCap
|
|
99
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
100
|
+
* @param {string} coinKey The name of the coin to deposit
|
|
101
|
+
* @param {number} amountToDeposit The amount to deposit
|
|
102
|
+
* @returns A function that takes a Transaction object
|
|
103
|
+
*/
|
|
104
|
+
depositWithCap: (managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => void;
|
|
105
|
+
/**
|
|
106
|
+
* @description Withdraw using the WithdrawCap
|
|
107
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
108
|
+
* @param {string} coinKey The name of the coin to withdraw
|
|
109
|
+
* @param {number} amountToWithdraw The amount to withdraw
|
|
110
|
+
* @returns A function that takes a Transaction object
|
|
111
|
+
*/
|
|
112
|
+
withdrawWithCap: (managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
113
|
+
/**
|
|
114
|
+
* @description Set the referral for the BalanceManager for a specific pool
|
|
115
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
116
|
+
* @param {string} referral The referral (DeepBookPoolReferral) to set the BalanceManager to
|
|
117
|
+
* @param {TransactionArgument} tradeCap The tradeCap for permission checking
|
|
118
|
+
* @returns A function that takes a Transaction object
|
|
119
|
+
*/
|
|
120
|
+
setBalanceManagerReferral: (managerKey: string, referral: string, tradeCap: TransactionArgument) => (tx: Transaction) => void;
|
|
121
|
+
/**
|
|
122
|
+
* @description Unset the referral for the BalanceManager for a specific pool
|
|
123
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
124
|
+
* @param {string} poolKey The key of the pool to unset the referral for
|
|
125
|
+
* @param {TransactionArgument} tradeCap The tradeCap for permission checking
|
|
126
|
+
* @returns A function that takes a Transaction object
|
|
127
|
+
*/
|
|
128
|
+
unsetBalanceManagerReferral: (managerKey: string, poolKey: string, tradeCap: TransactionArgument) => (tx: Transaction) => void;
|
|
129
|
+
registerBalanceManager: (managerKey: string) => (tx: Transaction) => void;
|
|
130
|
+
/**
|
|
131
|
+
* @description Get the owner of the BalanceManager
|
|
132
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
133
|
+
* @returns A function that takes a Transaction object
|
|
134
|
+
*/
|
|
135
|
+
owner: (managerKey: string) => (tx: Transaction) => void;
|
|
136
|
+
/**
|
|
137
|
+
* @description Get the ID of the BalanceManager
|
|
138
|
+
* @param {string} managerKey The key of the BalanceManager
|
|
139
|
+
* @returns A function that takes a Transaction object
|
|
140
|
+
*/
|
|
141
|
+
id: (managerKey: string) => (tx: Transaction) => void;
|
|
142
|
+
/**
|
|
143
|
+
* @description Get the owner of the referral (DeepBookPoolReferral)
|
|
144
|
+
* @param {string} referralId The ID of the referral to get the owner of
|
|
145
|
+
* @returns A function that takes a Transaction object
|
|
146
|
+
*/
|
|
147
|
+
balanceManagerReferralOwner: (referralId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
148
|
+
/**
|
|
149
|
+
* @description Get the pool ID associated with a referral (DeepBookPoolReferral)
|
|
150
|
+
* @param {string} referralId The ID of the referral to get the pool ID of
|
|
151
|
+
* @returns A function that takes a Transaction object
|
|
152
|
+
*/
|
|
153
|
+
balanceManagerReferralPoolId: (referralId: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
154
|
+
/**
|
|
155
|
+
* @description Get the referral ID from the balance manager for a specific pool
|
|
156
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
157
|
+
* @param {string} poolKey Key of the pool to get the referral for
|
|
158
|
+
* @returns A function that takes a Transaction object
|
|
159
|
+
*/
|
|
160
|
+
getBalanceManagerReferralId: (managerKey: string, poolKey: string) => (tx: Transaction) => import("@haneullabs/haneul/transactions").TransactionResult;
|
|
161
|
+
/**
|
|
162
|
+
* @description Revoke a TradeCap. This also revokes the associated DepositCap and WithdrawCap.
|
|
163
|
+
* @param {string} managerKey The name of the BalanceManager
|
|
164
|
+
* @param {string} tradeCapId The ID of the TradeCap to revoke
|
|
165
|
+
* @returns A function that takes a Transaction object
|
|
166
|
+
*/
|
|
167
|
+
revokeTradeCap: (managerKey: string, tradeCapId: string) => (tx: Transaction) => void;
|
|
168
|
+
}
|