@mysten/deepbook-v3 1.5.8 → 1.6.2
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 +73 -0
- package/dist/client.d.mts +5 -0
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +7 -0
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs +413 -0
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook/big_vector.mjs +43 -0
- package/dist/contracts/deepbook/big_vector.mjs.map +1 -0
- package/dist/contracts/deepbook/book.mjs +29 -0
- package/dist/contracts/deepbook/book.mjs.map +1 -0
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.mjs +1 -1
- package/dist/contracts/deepbook/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook/governance.mjs +49 -0
- package/dist/contracts/deepbook/governance.mjs.map +1 -0
- package/dist/contracts/deepbook/history.mjs +56 -0
- package/dist/contracts/deepbook/history.mjs.map +1 -0
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs +1739 -0
- package/dist/contracts/deepbook/pool.mjs.map +1 -0
- package/dist/contracts/deepbook/registry.mjs +295 -0
- package/dist/contracts/deepbook/registry.mjs.map +1 -0
- package/dist/contracts/deepbook/state.mjs +89 -0
- package/dist/contracts/deepbook/state.mjs.map +1 -0
- package/dist/contracts/deepbook/trade_params.mjs +21 -0
- package/dist/contracts/deepbook/trade_params.mjs.map +1 -0
- package/dist/contracts/deepbook/vault.mjs +42 -0
- package/dist/contracts/deepbook/vault.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs +53 -0
- package/dist/contracts/deepbook_margin/deps/deepbook/balance_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_margin/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs +43 -0
- package/dist/contracts/deepbook_margin/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_margin/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs +38 -0
- package/dist/contracts/deepbook_margin/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_margin/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs +19 -0
- package/dist/contracts/deepbook_margin/deps/sui/versioned.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs +989 -0
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs +550 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs +786 -0
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs +30 -0
- package/dist/contracts/deepbook_margin/margin_state.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/oracle.mjs +82 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +644 -0
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs +32 -0
- package/dist/contracts/deepbook_margin/position_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs +122 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs +58 -0
- package/dist/contracts/deepbook_margin/protocol_fees.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs +26 -0
- package/dist/contracts/deepbook_margin/rate_limiter.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs +171 -0
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs +43 -0
- package/dist/contracts/margin_liquidation/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +179 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -0
- package/dist/contracts/utils/index.d.mts +1 -1
- package/dist/contracts/utils/index.mjs +92 -3
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +13 -0
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +119 -100
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +464 -439
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +151 -135
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +29 -22
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +34 -33
- package/dist/transactions/governance.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +17 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +186 -169
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +53 -54
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +83 -83
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +330 -317
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +93 -89
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +22 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.mjs +101 -68
- package/dist/transactions/marginRegistry.mjs.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +27 -9
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +108 -82
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +37 -5
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +269 -189
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/utils/constants.mjs +4 -4
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +8 -0
- package/src/contracts/deepbook/balance_manager.ts +46 -5
- package/src/contracts/deepbook/constants.ts +13 -0
- package/src/contracts/deepbook/pool.ts +133 -0
- package/src/contracts/deepbook/registry.ts +136 -1
- package/src/contracts/deepbook_margin/deps/deepbook/balance_manager.ts +49 -0
- package/src/contracts/deepbook_margin/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_margin/deps/sui/bag.ts +41 -0
- package/src/contracts/deepbook_margin/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_margin/deps/sui/table.ts +36 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_margin/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_margin/deps/sui/versioned.ts +13 -0
- package/src/contracts/deepbook_margin/margin_constants.ts +329 -0
- package/src/contracts/deepbook_margin/margin_manager.ts +1772 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +1129 -0
- package/src/contracts/deepbook_margin/margin_registry.ts +1207 -0
- package/src/contracts/deepbook_margin/margin_state.ts +26 -0
- package/src/contracts/deepbook_margin/oracle.ts +99 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +1298 -0
- package/src/contracts/deepbook_margin/position_manager.ts +28 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +163 -0
- package/src/contracts/deepbook_margin/protocol_fees.ts +153 -0
- package/src/contracts/deepbook_margin/rate_limiter.ts +80 -0
- package/src/contracts/deepbook_margin/tpsl.ts +559 -0
- package/src/contracts/margin_liquidation/deps/sui/bag.ts +41 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +401 -0
- package/src/queries/registryQueries.ts +15 -0
- package/src/transactions/balanceManager.ts +140 -90
- package/src/transactions/deepbook.ts +586 -494
- package/src/transactions/deepbookAdmin.ts +154 -146
- package/src/transactions/flashLoans.ts +29 -20
- package/src/transactions/governance.ts +50 -37
- package/src/transactions/marginAdmin.ts +247 -188
- package/src/transactions/marginLiquidations.ts +70 -55
- package/src/transactions/marginMaintainer.ts +106 -88
- package/src/transactions/marginManager.ts +414 -348
- package/src/transactions/marginPool.ts +140 -103
- package/src/transactions/marginRegistry.ts +103 -70
- package/src/transactions/marginTPSL.ts +151 -87
- package/src/transactions/poolProxy.ts +384 -205
- package/src/utils/constants.ts +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tpsl.mjs","names":[],"sources":["../../../src/contracts/deepbook_margin/tpsl.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nconst $moduleName = '@deepbook/margin::tpsl';\nexport const Condition = new MoveStruct({\n\tname: `${$moduleName}::Condition`,\n\tfields: {\n\t\ttrigger_below_price: bcs.bool(),\n\t\ttrigger_price: bcs.u64(),\n\t},\n});\nexport const PendingOrder = new MoveStruct({\n\tname: `${$moduleName}::PendingOrder`,\n\tfields: {\n\t\tis_limit_order: bcs.bool(),\n\t\tclient_order_id: bcs.u64(),\n\t\torder_type: bcs.option(bcs.u8()),\n\t\tself_matching_option: bcs.u8(),\n\t\tprice: bcs.option(bcs.u64()),\n\t\tquantity: bcs.u64(),\n\t\tis_bid: bcs.bool(),\n\t\tpay_with_deep: bcs.bool(),\n\t\texpire_timestamp: bcs.option(bcs.u64()),\n\t},\n});\nexport const ConditionalOrder = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrder`,\n\tfields: {\n\t\tconditional_order_id: bcs.u64(),\n\t\tcondition: Condition,\n\t\tpending_order: PendingOrder,\n\t},\n});\nexport const TakeProfitStopLoss = new MoveStruct({\n\tname: `${$moduleName}::TakeProfitStopLoss`,\n\tfields: {\n\t\ttrigger_below: bcs.vector(ConditionalOrder),\n\t\ttrigger_above: bcs.vector(ConditionalOrder),\n\t},\n});\nexport const ConditionalOrderAdded = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrderAdded`,\n\tfields: {\n\t\tmanager_id: bcs.Address,\n\t\tconditional_order_id: bcs.u64(),\n\t\tconditional_order: ConditionalOrder,\n\t\ttimestamp: bcs.u64(),\n\t},\n});\nexport const ConditionalOrderCancelled = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrderCancelled`,\n\tfields: {\n\t\tmanager_id: bcs.Address,\n\t\tconditional_order_id: bcs.u64(),\n\t\tconditional_order: ConditionalOrder,\n\t\ttimestamp: bcs.u64(),\n\t},\n});\nexport const ConditionalOrderExecuted = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrderExecuted`,\n\tfields: {\n\t\tmanager_id: bcs.Address,\n\t\tpool_id: bcs.Address,\n\t\tconditional_order_id: bcs.u64(),\n\t\tconditional_order: ConditionalOrder,\n\t\ttimestamp: bcs.u64(),\n\t},\n});\nexport const ConditionalOrderInsufficientFunds = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrderInsufficientFunds`,\n\tfields: {\n\t\tmanager_id: bcs.Address,\n\t\tconditional_order_id: bcs.u64(),\n\t\tconditional_order: ConditionalOrder,\n\t\ttimestamp: bcs.u64(),\n\t},\n});\nexport const ConditionalOrderPriceOutOfBounds = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrderPriceOutOfBounds`,\n\tfields: {\n\t\tmanager_id: bcs.Address,\n\t\tconditional_order_id: bcs.u64(),\n\t\tconditional_order: ConditionalOrder,\n\t\ttimestamp: bcs.u64(),\n\t},\n});\nexport const ConditionalOrderBelowLiquidation = new MoveStruct({\n\tname: `${$moduleName}::ConditionalOrderBelowLiquidation`,\n\tfields: {\n\t\tmanager_id: bcs.Address,\n\t\tconditional_order_id: bcs.u64(),\n\t\tconditional_order: ConditionalOrder,\n\t\ttimestamp: bcs.u64(),\n\t},\n});\nexport interface NewConditionArguments {\n\ttriggerBelowPrice: RawTransactionArgument<boolean>;\n\ttriggerPrice: RawTransactionArgument<number | bigint>;\n}\nexport interface NewConditionOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewConditionArguments\n\t\t| [\n\t\t\t\ttriggerBelowPrice: RawTransactionArgument<boolean>,\n\t\t\t\ttriggerPrice: RawTransactionArgument<number | bigint>,\n\t\t ];\n}\nexport function newCondition(options: NewConditionOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = ['bool', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['triggerBelowPrice', 'triggerPrice'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'new_condition',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NewPendingLimitOrderArguments {\n\tclientOrderId: RawTransactionArgument<number | bigint>;\n\torderType: RawTransactionArgument<number>;\n\tselfMatchingOption: RawTransactionArgument<number>;\n\tprice: RawTransactionArgument<number | bigint>;\n\tquantity: RawTransactionArgument<number | bigint>;\n\tisBid: RawTransactionArgument<boolean>;\n\tpayWithDeep: RawTransactionArgument<boolean>;\n\texpireTimestamp: RawTransactionArgument<number | bigint>;\n}\nexport interface NewPendingLimitOrderOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewPendingLimitOrderArguments\n\t\t| [\n\t\t\t\tclientOrderId: RawTransactionArgument<number | bigint>,\n\t\t\t\torderType: RawTransactionArgument<number>,\n\t\t\t\tselfMatchingOption: RawTransactionArgument<number>,\n\t\t\t\tprice: RawTransactionArgument<number | bigint>,\n\t\t\t\tquantity: RawTransactionArgument<number | bigint>,\n\t\t\t\tisBid: RawTransactionArgument<boolean>,\n\t\t\t\tpayWithDeep: RawTransactionArgument<boolean>,\n\t\t\t\texpireTimestamp: RawTransactionArgument<number | bigint>,\n\t\t ];\n}\n/**\n * Creates a new pending limit order. Order type must be no restriction or\n * immediate or cancel.\n */\nexport function newPendingLimitOrder(options: NewPendingLimitOrderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = ['u64', 'u8', 'u8', 'u64', 'u64', 'bool', 'bool', 'u64'] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\tconst parameterNames = [\n\t\t'clientOrderId',\n\t\t'orderType',\n\t\t'selfMatchingOption',\n\t\t'price',\n\t\t'quantity',\n\t\t'isBid',\n\t\t'payWithDeep',\n\t\t'expireTimestamp',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'new_pending_limit_order',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NewPendingMarketOrderArguments {\n\tclientOrderId: RawTransactionArgument<number | bigint>;\n\tselfMatchingOption: RawTransactionArgument<number>;\n\tquantity: RawTransactionArgument<number | bigint>;\n\tisBid: RawTransactionArgument<boolean>;\n\tpayWithDeep: RawTransactionArgument<boolean>;\n}\nexport interface NewPendingMarketOrderOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewPendingMarketOrderArguments\n\t\t| [\n\t\t\t\tclientOrderId: RawTransactionArgument<number | bigint>,\n\t\t\t\tselfMatchingOption: RawTransactionArgument<number>,\n\t\t\t\tquantity: RawTransactionArgument<number | bigint>,\n\t\t\t\tisBid: RawTransactionArgument<boolean>,\n\t\t\t\tpayWithDeep: RawTransactionArgument<boolean>,\n\t\t ];\n}\n/** Creates a new pending market order. */\nexport function newPendingMarketOrder(options: NewPendingMarketOrderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = ['u64', 'u8', 'u64', 'bool', 'bool'] satisfies (string | null)[];\n\tconst parameterNames = [\n\t\t'clientOrderId',\n\t\t'selfMatchingOption',\n\t\t'quantity',\n\t\t'isBid',\n\t\t'payWithDeep',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'new_pending_market_order',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TriggerBelowOrdersArguments {\n\tself: TransactionArgument;\n}\nexport interface TriggerBelowOrdersOptions {\n\tpackage?: string;\n\targuments: TriggerBelowOrdersArguments | [self: TransactionArgument];\n}\nexport function triggerBelowOrders(options: TriggerBelowOrdersOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'trigger_below_orders',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TriggerAboveOrdersArguments {\n\tself: TransactionArgument;\n}\nexport interface TriggerAboveOrdersOptions {\n\tpackage?: string;\n\targuments: TriggerAboveOrdersArguments | [self: TransactionArgument];\n}\nexport function triggerAboveOrders(options: TriggerAboveOrdersOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'trigger_above_orders',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NumConditionalOrdersArguments {\n\tself: TransactionArgument;\n}\nexport interface NumConditionalOrdersOptions {\n\tpackage?: string;\n\targuments: NumConditionalOrdersArguments | [self: TransactionArgument];\n}\nexport function numConditionalOrders(options: NumConditionalOrdersOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'num_conditional_orders',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ConditionalOrderIdArguments {\n\tconditionalOrder: TransactionArgument;\n}\nexport interface ConditionalOrderIdOptions {\n\tpackage?: string;\n\targuments: ConditionalOrderIdArguments | [conditionalOrder: TransactionArgument];\n}\nexport function conditionalOrderId(options: ConditionalOrderIdOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['conditionalOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'conditional_order_id',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface GetConditionalOrderArguments {\n\tself: TransactionArgument;\n\tconditionalOrderId: RawTransactionArgument<number | bigint>;\n}\nexport interface GetConditionalOrderOptions {\n\tpackage?: string;\n\targuments:\n\t\t| GetConditionalOrderArguments\n\t\t| [self: TransactionArgument, conditionalOrderId: RawTransactionArgument<number | bigint>];\n}\nexport function getConditionalOrder(options: GetConditionalOrderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'conditionalOrderId'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'get_conditional_order',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ConditionArguments {\n\tconditionalOrder: TransactionArgument;\n}\nexport interface ConditionOptions {\n\tpackage?: string;\n\targuments: ConditionArguments | [conditionalOrder: TransactionArgument];\n}\nexport function condition(options: ConditionOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['conditionalOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'condition',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface PendingOrderArguments {\n\tconditionalOrder: TransactionArgument;\n}\nexport interface PendingOrderOptions {\n\tpackage?: string;\n\targuments: PendingOrderArguments | [conditionalOrder: TransactionArgument];\n}\nexport function pendingOrder(options: PendingOrderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['conditionalOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'pending_order',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TriggerBelowPriceArguments {\n\tcondition: TransactionArgument;\n}\nexport interface TriggerBelowPriceOptions {\n\tpackage?: string;\n\targuments: TriggerBelowPriceArguments | [condition: TransactionArgument];\n}\nexport function triggerBelowPrice(options: TriggerBelowPriceOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['condition'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'trigger_below_price',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TriggerPriceArguments {\n\tcondition: TransactionArgument;\n}\nexport interface TriggerPriceOptions {\n\tpackage?: string;\n\targuments: TriggerPriceArguments | [condition: TransactionArgument];\n}\nexport function triggerPrice(options: TriggerPriceOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['condition'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'trigger_price',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ClientOrderIdArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface ClientOrderIdOptions {\n\tpackage?: string;\n\targuments: ClientOrderIdArguments | [pendingOrder: TransactionArgument];\n}\nexport function clientOrderId(options: ClientOrderIdOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'client_order_id',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface OrderTypeArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface OrderTypeOptions {\n\tpackage?: string;\n\targuments: OrderTypeArguments | [pendingOrder: TransactionArgument];\n}\nexport function orderType(options: OrderTypeOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'order_type',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SelfMatchingOptionArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface SelfMatchingOptionOptions {\n\tpackage?: string;\n\targuments: SelfMatchingOptionArguments | [pendingOrder: TransactionArgument];\n}\nexport function selfMatchingOption(options: SelfMatchingOptionOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'self_matching_option',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface PriceArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface PriceOptions {\n\tpackage?: string;\n\targuments: PriceArguments | [pendingOrder: TransactionArgument];\n}\nexport function price(options: PriceOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'price',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface QuantityArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface QuantityOptions {\n\tpackage?: string;\n\targuments: QuantityArguments | [pendingOrder: TransactionArgument];\n}\nexport function quantity(options: QuantityOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'quantity',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface IsBidArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface IsBidOptions {\n\tpackage?: string;\n\targuments: IsBidArguments | [pendingOrder: TransactionArgument];\n}\nexport function isBid(options: IsBidOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'is_bid',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface PayWithDeepArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface PayWithDeepOptions {\n\tpackage?: string;\n\targuments: PayWithDeepArguments | [pendingOrder: TransactionArgument];\n}\nexport function payWithDeep(options: PayWithDeepOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'pay_with_deep',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ExpireTimestampArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface ExpireTimestampOptions {\n\tpackage?: string;\n\targuments: ExpireTimestampArguments | [pendingOrder: TransactionArgument];\n}\nexport function expireTimestamp(options: ExpireTimestampOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'expire_timestamp',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface IsLimitOrderArguments {\n\tpendingOrder: TransactionArgument;\n}\nexport interface IsLimitOrderOptions {\n\tpackage?: string;\n\targuments: IsLimitOrderArguments | [pendingOrder: TransactionArgument];\n}\nexport function isLimitOrder(options: IsLimitOrderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['pendingOrder'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'tpsl',\n\t\t\tfunction: 'is_limit_order',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;AAMA,MAAM,cAAc;AACpB,MAAa,YAAY,IAAI,WAAW;CACvC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,qBAAqB,IAAI,MAAM;EAC/B,eAAe,IAAI,KAAK;EACxB;CACD,CAAC;AACF,MAAa,eAAe,IAAI,WAAW;CAC1C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,gBAAgB,IAAI,MAAM;EAC1B,iBAAiB,IAAI,KAAK;EAC1B,YAAY,IAAI,OAAO,IAAI,IAAI,CAAC;EAChC,sBAAsB,IAAI,IAAI;EAC9B,OAAO,IAAI,OAAO,IAAI,KAAK,CAAC;EAC5B,UAAU,IAAI,KAAK;EACnB,QAAQ,IAAI,MAAM;EAClB,eAAe,IAAI,MAAM;EACzB,kBAAkB,IAAI,OAAO,IAAI,KAAK,CAAC;EACvC;CACD,CAAC;AACF,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,sBAAsB,IAAI,KAA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AAgB,aAAa,SAA8B;CAC1D,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,QAAQ,MAAM;CACtC,MAAM,iBAAiB,CAAC,qBAAqB,eAAe;AAC5D,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC;;;;;;AA+BJ,SAAgB,qBAAqB,SAAsC;CAC1E,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAO;EAAM;EAAM;EAAO;EAAO;EAAQ;EAAQ;EAAM;CAI/E,MAAM,iBAAiB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACD,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC;;;AAsBJ,SAAgB,sBAAsB,SAAuC;CAC5E,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAO;EAAM;EAAO;EAAQ;EAAO;CAC3D,MAAM,iBAAiB;EACtB;EACA;EACA;EACA;EACA;EACA;AACD,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/margin_liquidation/deps/sui/bag.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
/**
|
|
9
|
+
* A bag is a heterogeneous map-like collection. The collection is similar to
|
|
10
|
+
* `sui::table` in that its keys and values are not stored within the `Bag` value,
|
|
11
|
+
* but instead are stored using Sui's object system. The `Bag` struct acts only as
|
|
12
|
+
* a handle into the object system to retrieve those keys and values. Note that
|
|
13
|
+
* this means that `Bag` values with exactly the same key-value mapping will not be
|
|
14
|
+
* equal, with `==`, at runtime. For example
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* let bag1 = bag::new();
|
|
18
|
+
* let bag2 = bag::new();
|
|
19
|
+
* bag::add(&mut bag1, 0, false);
|
|
20
|
+
* bag::add(&mut bag1, 1, true);
|
|
21
|
+
* bag::add(&mut bag2, 0, false);
|
|
22
|
+
* bag::add(&mut bag2, 1, true);
|
|
23
|
+
* // bag1 does not equal bag2, despite having the same entries
|
|
24
|
+
* assert!(&bag1 != &bag2);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* At it's core, `sui::bag` is a wrapper around `UID` that allows for access to
|
|
28
|
+
* `sui::dynamic_field` while preventing accidentally stranding field values. A
|
|
29
|
+
* `UID` can be deleted, even if it has dynamic fields associated with it, but a
|
|
30
|
+
* bag, on the other hand, must be empty to be destroyed.
|
|
31
|
+
*/
|
|
32
|
+
const $moduleName = "0x2::bag";
|
|
33
|
+
const Bag = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::Bag`,
|
|
35
|
+
fields: {
|
|
36
|
+
id: bcs.Address,
|
|
37
|
+
size: bcs.u64()
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Bag };
|
|
43
|
+
//# sourceMappingURL=bag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bag.mjs","names":[],"sources":["../../../../../src/contracts/margin_liquidation/deps/sui/bag.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * A bag is a heterogeneous map-like collection. The collection is similar to\n * `sui::table` in that its keys and values are not stored within the `Bag` value,\n * but instead are stored using Sui's object system. The `Bag` struct acts only as\n * a handle into the object system to retrieve those keys and values. Note that\n * this means that `Bag` values with exactly the same key-value mapping will not be\n * equal, with `==`, at runtime. For example\n *\n * ```\n * let bag1 = bag::new();\n * let bag2 = bag::new();\n * bag::add(&mut bag1, 0, false);\n * bag::add(&mut bag1, 1, true);\n * bag::add(&mut bag2, 0, false);\n * bag::add(&mut bag2, 1, true);\n * // bag1 does not equal bag2, despite having the same entries\n * assert!(&bag1 != &bag2);\n * ```\n *\n * At it's core, `sui::bag` is a wrapper around `UID` that allows for access to\n * `sui::dynamic_field` while preventing accidentally stranding field values. A\n * `UID` can be deleted, even if it has dynamic fields associated with it, but a\n * bag, on the other hand, must be empty to be destroyed.\n */\n\nimport { MoveStruct } from '../../../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nconst $moduleName = '0x2::bag';\nexport const Bag = new MoveStruct({\n\tname: `${$moduleName}::Bag`,\n\tfields: {\n\t\t/** the ID of this bag */\n\t\tid: bcs.Address,\n\t\t/** the number of key-value pairs in the bag */\n\t\tsize: bcs.u64(),\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AACpB,MAAa,MAAM,IAAI,WAAW;CACjC,MAAM,GAAG,YAAY;CACrB,QAAQ;EAEP,IAAI,IAAI;EAER,MAAM,IAAI,KAAK;EACf;CACD,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
|
|
2
|
+
import { Bag } from "./deps/sui/bag.mjs";
|
|
3
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
4
|
+
|
|
5
|
+
//#region src/contracts/margin_liquidation/liquidation_vault.ts
|
|
6
|
+
/**************************************************************
|
|
7
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
8
|
+
**************************************************************/
|
|
9
|
+
const $moduleName = "@deepbook/margin-liquidation::liquidation_vault";
|
|
10
|
+
const LIQUIDATION_VAULT = new MoveStruct({
|
|
11
|
+
name: `${$moduleName}::LIQUIDATION_VAULT`,
|
|
12
|
+
fields: { dummy_field: bcs.bool() }
|
|
13
|
+
});
|
|
14
|
+
const LiquidationVault = new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::LiquidationVault`,
|
|
16
|
+
fields: {
|
|
17
|
+
id: bcs.Address,
|
|
18
|
+
vault: Bag
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const BalanceKey = new MoveStruct({
|
|
22
|
+
name: `${$moduleName}::BalanceKey<phantom T>`,
|
|
23
|
+
fields: { dummy_field: bcs.bool() }
|
|
24
|
+
});
|
|
25
|
+
const AuthorizedTradersKey = new MoveStruct({
|
|
26
|
+
name: `${$moduleName}::AuthorizedTradersKey`,
|
|
27
|
+
fields: { dummy_field: bcs.bool() }
|
|
28
|
+
});
|
|
29
|
+
const LiquidationAdminCap = new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::LiquidationAdminCap`,
|
|
31
|
+
fields: { id: bcs.Address }
|
|
32
|
+
});
|
|
33
|
+
const LiquidationByVault = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::LiquidationByVault`,
|
|
35
|
+
fields: {
|
|
36
|
+
vault_id: bcs.Address,
|
|
37
|
+
margin_manager_id: bcs.Address,
|
|
38
|
+
margin_pool_id: bcs.Address,
|
|
39
|
+
base_in: bcs.u64(),
|
|
40
|
+
base_out: bcs.u64(),
|
|
41
|
+
quote_in: bcs.u64(),
|
|
42
|
+
quote_out: bcs.u64(),
|
|
43
|
+
repay_balance_remaining: bcs.u64(),
|
|
44
|
+
base_liquidation: bcs.bool()
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
function deposit(options) {
|
|
48
|
+
const packageAddress = options.package ?? "@deepbook/margin-liquidation";
|
|
49
|
+
const argumentsTypes = [
|
|
50
|
+
null,
|
|
51
|
+
null,
|
|
52
|
+
null
|
|
53
|
+
];
|
|
54
|
+
const parameterNames = [
|
|
55
|
+
"self",
|
|
56
|
+
"LiquidationCap",
|
|
57
|
+
"coin"
|
|
58
|
+
];
|
|
59
|
+
return (tx) => tx.moveCall({
|
|
60
|
+
package: packageAddress,
|
|
61
|
+
module: "liquidation_vault",
|
|
62
|
+
function: "deposit",
|
|
63
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
64
|
+
typeArguments: options.typeArguments
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function withdraw(options) {
|
|
68
|
+
const packageAddress = options.package ?? "@deepbook/margin-liquidation";
|
|
69
|
+
const argumentsTypes = [
|
|
70
|
+
null,
|
|
71
|
+
null,
|
|
72
|
+
"u64"
|
|
73
|
+
];
|
|
74
|
+
const parameterNames = [
|
|
75
|
+
"self",
|
|
76
|
+
"LiquidationCap",
|
|
77
|
+
"amount"
|
|
78
|
+
];
|
|
79
|
+
return (tx) => tx.moveCall({
|
|
80
|
+
package: packageAddress,
|
|
81
|
+
module: "liquidation_vault",
|
|
82
|
+
function: "withdraw",
|
|
83
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
84
|
+
typeArguments: options.typeArguments
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function createLiquidationVault(options) {
|
|
88
|
+
const packageAddress = options.package ?? "@deepbook/margin-liquidation";
|
|
89
|
+
const argumentsTypes = [null];
|
|
90
|
+
const parameterNames = ["LiquidationCap"];
|
|
91
|
+
return (tx) => tx.moveCall({
|
|
92
|
+
package: packageAddress,
|
|
93
|
+
module: "liquidation_vault",
|
|
94
|
+
function: "create_liquidation_vault",
|
|
95
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function liquidateBase(options) {
|
|
99
|
+
const packageAddress = options.package ?? "@deepbook/margin-liquidation";
|
|
100
|
+
const argumentsTypes = [
|
|
101
|
+
null,
|
|
102
|
+
null,
|
|
103
|
+
null,
|
|
104
|
+
null,
|
|
105
|
+
null,
|
|
106
|
+
null,
|
|
107
|
+
null,
|
|
108
|
+
null,
|
|
109
|
+
"0x1::option::Option<u64>",
|
|
110
|
+
"0x2::clock::Clock"
|
|
111
|
+
];
|
|
112
|
+
const parameterNames = [
|
|
113
|
+
"self",
|
|
114
|
+
"marginManager",
|
|
115
|
+
"registry",
|
|
116
|
+
"baseOracle",
|
|
117
|
+
"quoteOracle",
|
|
118
|
+
"baseMarginPool",
|
|
119
|
+
"quoteMarginPool",
|
|
120
|
+
"pool",
|
|
121
|
+
"repayAmount"
|
|
122
|
+
];
|
|
123
|
+
return (tx) => tx.moveCall({
|
|
124
|
+
package: packageAddress,
|
|
125
|
+
module: "liquidation_vault",
|
|
126
|
+
function: "liquidate_base",
|
|
127
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
128
|
+
typeArguments: options.typeArguments
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function liquidateQuote(options) {
|
|
132
|
+
const packageAddress = options.package ?? "@deepbook/margin-liquidation";
|
|
133
|
+
const argumentsTypes = [
|
|
134
|
+
null,
|
|
135
|
+
null,
|
|
136
|
+
null,
|
|
137
|
+
null,
|
|
138
|
+
null,
|
|
139
|
+
null,
|
|
140
|
+
null,
|
|
141
|
+
null,
|
|
142
|
+
"0x1::option::Option<u64>",
|
|
143
|
+
"0x2::clock::Clock"
|
|
144
|
+
];
|
|
145
|
+
const parameterNames = [
|
|
146
|
+
"self",
|
|
147
|
+
"marginManager",
|
|
148
|
+
"registry",
|
|
149
|
+
"baseOracle",
|
|
150
|
+
"quoteOracle",
|
|
151
|
+
"baseMarginPool",
|
|
152
|
+
"quoteMarginPool",
|
|
153
|
+
"pool",
|
|
154
|
+
"repayAmount"
|
|
155
|
+
];
|
|
156
|
+
return (tx) => tx.moveCall({
|
|
157
|
+
package: packageAddress,
|
|
158
|
+
module: "liquidation_vault",
|
|
159
|
+
function: "liquidate_quote",
|
|
160
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
161
|
+
typeArguments: options.typeArguments
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function balance(options) {
|
|
165
|
+
const packageAddress = options.package ?? "@deepbook/margin-liquidation";
|
|
166
|
+
const argumentsTypes = [null];
|
|
167
|
+
const parameterNames = ["self"];
|
|
168
|
+
return (tx) => tx.moveCall({
|
|
169
|
+
package: packageAddress,
|
|
170
|
+
module: "liquidation_vault",
|
|
171
|
+
function: "balance",
|
|
172
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
173
|
+
typeArguments: options.typeArguments
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
export { balance, createLiquidationVault, deposit, liquidateBase, liquidateQuote, withdraw };
|
|
179
|
+
//# sourceMappingURL=liquidation_vault.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquidation_vault.mjs","names":["bag.Bag"],"sources":["../../../src/contracts/margin_liquidation/liquidation_vault.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport * as bag from './deps/sui/bag.js';\nconst $moduleName = '@deepbook/margin-liquidation::liquidation_vault';\nexport const LIQUIDATION_VAULT = new MoveStruct({\n\tname: `${$moduleName}::LIQUIDATION_VAULT`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const LiquidationVault = new MoveStruct({\n\tname: `${$moduleName}::LiquidationVault`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tvault: bag.Bag,\n\t},\n});\nexport const BalanceKey = new MoveStruct({\n\tname: `${$moduleName}::BalanceKey<phantom T>`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const AuthorizedTradersKey = new MoveStruct({\n\tname: `${$moduleName}::AuthorizedTradersKey`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const LiquidationAdminCap = new MoveStruct({\n\tname: `${$moduleName}::LiquidationAdminCap`,\n\tfields: {\n\t\tid: bcs.Address,\n\t},\n});\nexport const LiquidationByVault = new MoveStruct({\n\tname: `${$moduleName}::LiquidationByVault`,\n\tfields: {\n\t\tvault_id: bcs.Address,\n\t\tmargin_manager_id: bcs.Address,\n\t\tmargin_pool_id: bcs.Address,\n\t\tbase_in: bcs.u64(),\n\t\tbase_out: bcs.u64(),\n\t\tquote_in: bcs.u64(),\n\t\tquote_out: bcs.u64(),\n\t\trepay_balance_remaining: bcs.u64(),\n\t\tbase_liquidation: bcs.bool(),\n\t},\n});\nexport interface DepositArguments {\n\tself: RawTransactionArgument<string>;\n\tLiquidationCap: RawTransactionArgument<string>;\n\tcoin: RawTransactionArgument<string>;\n}\nexport interface DepositOptions {\n\tpackage?: string;\n\targuments:\n\t\t| DepositArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tLiquidationCap: RawTransactionArgument<string>,\n\t\t\t\tcoin: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string];\n}\nexport function deposit(options: DepositOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null, null, null] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'LiquidationCap', 'coin'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'deposit',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface WithdrawArguments {\n\tself: RawTransactionArgument<string>;\n\tLiquidationCap: RawTransactionArgument<string>;\n\tamount: RawTransactionArgument<number | bigint>;\n}\nexport interface WithdrawOptions {\n\tpackage?: string;\n\targuments:\n\t\t| WithdrawArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tLiquidationCap: RawTransactionArgument<string>,\n\t\t\t\tamount: RawTransactionArgument<number | bigint>,\n\t\t ];\n\ttypeArguments: [string];\n}\nexport function withdraw(options: WithdrawOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null, null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'LiquidationCap', 'amount'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'withdraw',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface CreateLiquidationVaultArguments {\n\tLiquidationCap: RawTransactionArgument<string>;\n}\nexport interface CreateLiquidationVaultOptions {\n\tpackage?: string;\n\targuments: CreateLiquidationVaultArguments | [LiquidationCap: RawTransactionArgument<string>];\n}\nexport function createLiquidationVault(options: CreateLiquidationVaultOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['LiquidationCap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'create_liquidation_vault',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface AuthorizeTraderArguments {\n\tself: RawTransactionArgument<string>;\n\tLiquidationCap: RawTransactionArgument<string>;\n\tauthorizedAddress: RawTransactionArgument<string>;\n}\nexport interface AuthorizeTraderOptions {\n\tpackage?: string;\n\targuments:\n\t\t| AuthorizeTraderArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tLiquidationCap: RawTransactionArgument<string>,\n\t\t\t\tauthorizedAddress: RawTransactionArgument<string>,\n\t\t ];\n}\nexport function authorizeTrader(options: AuthorizeTraderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null, null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'LiquidationCap', 'authorizedAddress'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'authorize_trader',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface DeauthorizeTraderArguments {\n\tself: RawTransactionArgument<string>;\n\tLiquidationCap: RawTransactionArgument<string>;\n\tauthorizedAddress: RawTransactionArgument<string>;\n}\nexport interface DeauthorizeTraderOptions {\n\tpackage?: string;\n\targuments:\n\t\t| DeauthorizeTraderArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tLiquidationCap: RawTransactionArgument<string>,\n\t\t\t\tauthorizedAddress: RawTransactionArgument<string>,\n\t\t ];\n}\nexport function deauthorizeTrader(options: DeauthorizeTraderOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null, null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'LiquidationCap', 'authorizedAddress'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'deauthorize_trader',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface SwapBaseToQuoteArguments {\n\tself: RawTransactionArgument<string>;\n\tpool: RawTransactionArgument<string>;\n\tbaseIn: RawTransactionArgument<number | bigint>;\n\tdeepIn: RawTransactionArgument<number | bigint>;\n\tminQuoteOut: RawTransactionArgument<number | bigint>;\n}\nexport interface SwapBaseToQuoteOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SwapBaseToQuoteArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tpool: RawTransactionArgument<string>,\n\t\t\t\tbaseIn: RawTransactionArgument<number | bigint>,\n\t\t\t\tdeepIn: RawTransactionArgument<number | bigint>,\n\t\t\t\tminQuoteOut: RawTransactionArgument<number | bigint>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\nexport function swapBaseToQuote(options: SwapBaseToQuoteOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null, null, 'u64', 'u64', 'u64', '0x2::clock::Clock'] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\tconst parameterNames = ['self', 'pool', 'baseIn', 'deepIn', 'minQuoteOut'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'swap_base_to_quote',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface SwapQuoteToBaseArguments {\n\tself: RawTransactionArgument<string>;\n\tpool: RawTransactionArgument<string>;\n\tquoteIn: RawTransactionArgument<number | bigint>;\n\tdeepIn: RawTransactionArgument<number | bigint>;\n\tminBaseOut: RawTransactionArgument<number | bigint>;\n}\nexport interface SwapQuoteToBaseOptions {\n\tpackage?: string;\n\targuments:\n\t\t| SwapQuoteToBaseArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tpool: RawTransactionArgument<string>,\n\t\t\t\tquoteIn: RawTransactionArgument<number | bigint>,\n\t\t\t\tdeepIn: RawTransactionArgument<number | bigint>,\n\t\t\t\tminBaseOut: RawTransactionArgument<number | bigint>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\nexport function swapQuoteToBase(options: SwapQuoteToBaseOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null, null, 'u64', 'u64', 'u64', '0x2::clock::Clock'] satisfies (\n\t\t| string\n\t\t| null\n\t)[];\n\tconst parameterNames = ['self', 'pool', 'quoteIn', 'deepIn', 'minBaseOut'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'swap_quote_to_base',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface LiquidateBaseArguments {\n\tself: RawTransactionArgument<string>;\n\tmarginManager: RawTransactionArgument<string>;\n\tregistry: RawTransactionArgument<string>;\n\tbaseOracle: RawTransactionArgument<string>;\n\tquoteOracle: RawTransactionArgument<string>;\n\tbaseMarginPool: RawTransactionArgument<string>;\n\tquoteMarginPool: RawTransactionArgument<string>;\n\tpool: RawTransactionArgument<string>;\n\trepayAmount: RawTransactionArgument<number | bigint | null>;\n}\nexport interface LiquidateBaseOptions {\n\tpackage?: string;\n\targuments:\n\t\t| LiquidateBaseArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tmarginManager: RawTransactionArgument<string>,\n\t\t\t\tregistry: RawTransactionArgument<string>,\n\t\t\t\tbaseOracle: RawTransactionArgument<string>,\n\t\t\t\tquoteOracle: RawTransactionArgument<string>,\n\t\t\t\tbaseMarginPool: RawTransactionArgument<string>,\n\t\t\t\tquoteMarginPool: RawTransactionArgument<string>,\n\t\t\t\tpool: RawTransactionArgument<string>,\n\t\t\t\trepayAmount: RawTransactionArgument<number | bigint | null>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\nexport function liquidateBase(options: LiquidateBaseOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\t'0x1::option::Option<u64>',\n\t\t'0x2::clock::Clock',\n\t] satisfies (string | null)[];\n\tconst parameterNames = [\n\t\t'self',\n\t\t'marginManager',\n\t\t'registry',\n\t\t'baseOracle',\n\t\t'quoteOracle',\n\t\t'baseMarginPool',\n\t\t'quoteMarginPool',\n\t\t'pool',\n\t\t'repayAmount',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'liquidate_base',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface LiquidateQuoteArguments {\n\tself: RawTransactionArgument<string>;\n\tmarginManager: RawTransactionArgument<string>;\n\tregistry: RawTransactionArgument<string>;\n\tbaseOracle: RawTransactionArgument<string>;\n\tquoteOracle: RawTransactionArgument<string>;\n\tbaseMarginPool: RawTransactionArgument<string>;\n\tquoteMarginPool: RawTransactionArgument<string>;\n\tpool: RawTransactionArgument<string>;\n\trepayAmount: RawTransactionArgument<number | bigint | null>;\n}\nexport interface LiquidateQuoteOptions {\n\tpackage?: string;\n\targuments:\n\t\t| LiquidateQuoteArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tmarginManager: RawTransactionArgument<string>,\n\t\t\t\tregistry: RawTransactionArgument<string>,\n\t\t\t\tbaseOracle: RawTransactionArgument<string>,\n\t\t\t\tquoteOracle: RawTransactionArgument<string>,\n\t\t\t\tbaseMarginPool: RawTransactionArgument<string>,\n\t\t\t\tquoteMarginPool: RawTransactionArgument<string>,\n\t\t\t\tpool: RawTransactionArgument<string>,\n\t\t\t\trepayAmount: RawTransactionArgument<number | bigint | null>,\n\t\t ];\n\ttypeArguments: [string, string];\n}\nexport function liquidateQuote(options: LiquidateQuoteOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\t'0x1::option::Option<u64>',\n\t\t'0x2::clock::Clock',\n\t] satisfies (string | null)[];\n\tconst parameterNames = [\n\t\t'self',\n\t\t'marginManager',\n\t\t'registry',\n\t\t'baseOracle',\n\t\t'quoteOracle',\n\t\t'baseMarginPool',\n\t\t'quoteMarginPool',\n\t\t'pool',\n\t\t'repayAmount',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'liquidate_quote',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface BalanceArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface BalanceOptions {\n\tpackage?: string;\n\targuments: BalanceArguments | [self: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\nexport function balance(options: BalanceOptions) {\n\tconst packageAddress = options.package ?? '@deepbook/margin-liquidation';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'liquidation_vault',\n\t\t\tfunction: 'balance',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,cAAc;AACpB,MAAa,oBAAoB,IAAI,WAAW;CAC/C,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,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AAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC"}
|
|
@@ -1,10 +1,89 @@
|
|
|
1
|
-
import { BcsStruct, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
|
|
2
|
-
import "@mysten/sui/transactions";
|
|
1
|
+
import { BcsStruct, BcsTuple, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
|
|
2
|
+
import { isArgument } from "@mysten/sui/transactions";
|
|
3
3
|
import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/contracts/utils/index.ts
|
|
6
6
|
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
|
|
7
7
|
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
|
|
8
|
+
function getPureBcsSchema(typeTag) {
|
|
9
|
+
const parsedTag = typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
10
|
+
if ("u8" in parsedTag) return bcs.U8;
|
|
11
|
+
else if ("u16" in parsedTag) return bcs.U16;
|
|
12
|
+
else if ("u32" in parsedTag) return bcs.U32;
|
|
13
|
+
else if ("u64" in parsedTag) return bcs.U64;
|
|
14
|
+
else if ("u128" in parsedTag) return bcs.U128;
|
|
15
|
+
else if ("u256" in parsedTag) return bcs.U256;
|
|
16
|
+
else if ("address" in parsedTag) return bcs.Address;
|
|
17
|
+
else if ("bool" in parsedTag) return bcs.Bool;
|
|
18
|
+
else if ("vector" in parsedTag) {
|
|
19
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
20
|
+
return type ? bcs.vector(type) : null;
|
|
21
|
+
} else if ("struct" in parsedTag) {
|
|
22
|
+
const structTag = parsedTag.struct;
|
|
23
|
+
const pkg = normalizeSuiAddress(structTag.address);
|
|
24
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
25
|
+
if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") return bcs.String;
|
|
26
|
+
if (structTag.module === "option" && structTag.name === "Option") {
|
|
27
|
+
const inner = structTag.typeParams[0];
|
|
28
|
+
const type = inner ? getPureBcsSchema(inner) : null;
|
|
29
|
+
return type ? bcs.option(type) : null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === "object" && (structTag.name === "ID" || structTag.name === "UID")) return bcs.Address;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
37
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
38
|
+
if (parameterNames && argLen !== parameterNames.length) throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
|
|
39
|
+
const normalizedArgs = [];
|
|
40
|
+
let index = 0;
|
|
41
|
+
for (const argType of argTypes) {
|
|
42
|
+
if (argType === "0x2::clock::Clock") {
|
|
43
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (argType === "0x2::random::Random") {
|
|
47
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (argType === "0x2::deny_list::DenyList") {
|
|
51
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (argType === "0x3::sui_system::SuiSystemState") {
|
|
55
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let arg;
|
|
59
|
+
if (Array.isArray(args)) {
|
|
60
|
+
if (index >= args.length) throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
61
|
+
arg = args[index];
|
|
62
|
+
} else {
|
|
63
|
+
if (!parameterNames) throw new Error(`Expected arguments to be passed as an array`);
|
|
64
|
+
const name = parameterNames[index];
|
|
65
|
+
arg = args[name];
|
|
66
|
+
if (arg === void 0) throw new Error(`Parameter ${name} is required`);
|
|
67
|
+
}
|
|
68
|
+
index += 1;
|
|
69
|
+
if (typeof arg === "function" || isArgument(arg)) {
|
|
70
|
+
normalizedArgs.push(arg);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const bcsType = argType === null ? null : getPureBcsSchema(argType);
|
|
74
|
+
if (bcsType) {
|
|
75
|
+
const bytes = bcsType.serialize(arg);
|
|
76
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (typeof arg === "string") {
|
|
80
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);
|
|
84
|
+
}
|
|
85
|
+
return normalizedArgs;
|
|
86
|
+
}
|
|
8
87
|
const HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;
|
|
9
88
|
function splitTopLevelTypeArgs(inner) {
|
|
10
89
|
const parts = [];
|
|
@@ -96,6 +175,16 @@ var MoveStruct = class extends BcsStruct {
|
|
|
96
175
|
});
|
|
97
176
|
}
|
|
98
177
|
};
|
|
178
|
+
var MoveTuple = class extends BcsTuple {
|
|
179
|
+
/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */
|
|
180
|
+
typeTag(...args) {
|
|
181
|
+
return buildTypeTag(this.name, args[0]);
|
|
182
|
+
}
|
|
183
|
+
/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */
|
|
184
|
+
async resolveTypeTag(options) {
|
|
185
|
+
return resolveBuiltTypeTag(this.name, options);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
99
188
|
function stringify(val) {
|
|
100
189
|
if (typeof val === "object") return JSON.stringify(val, (_key, value) => typeof value === "bigint" ? value.toString() : value);
|
|
101
190
|
if (typeof val === "bigint") return val.toString();
|
|
@@ -103,5 +192,5 @@ function stringify(val) {
|
|
|
103
192
|
}
|
|
104
193
|
|
|
105
194
|
//#endregion
|
|
106
|
-
export { MoveStruct };
|
|
195
|
+
export { MoveStruct, MoveTuple, normalizeMoveArguments };
|
|
107
196
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\n/* -------------------------- Move type tags -------------------------- */\n\n/** A type argument: a type tag string, or a BCS type whose name is a Move type. */\nexport type TypeArgument = string | BcsType<any>;\n\nexport interface TypeTagOptions {\n\tpackage?: string;\n\ttypeArguments?: readonly TypeArgument[];\n}\n\n/**\n * `typeArguments` is required when the type's name contains unfilled\n * `phantom X` parameters (at any depth). Everything else — argument arity,\n * position contents, and tag validity — is validated at runtime.\n */\ntype TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}`\n\t? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]\n\t: [options?: TypeTagOptions];\n\ntype ResolveTypeTagOptions<Name extends string> = {\n\tclient: ClientWithCoreApi;\n} & (Name extends `${string}phantom ${string}`\n\t? TypeTagOptions & { typeArguments: readonly TypeArgument[] }\n\t: TypeTagOptions);\n\nconst HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;\n\nfunction splitTopLevelTypeArgs(inner: string): string[] {\n\tconst parts: string[] = [];\n\tlet depth = 0;\n\tlet current = '';\n\tfor (const char of inner) {\n\t\tif (char === ',' && depth === 0) {\n\t\t\tparts.push(current.trim());\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '<') depth++;\n\t\tif (char === '>') depth--;\n\t\tcurrent += char;\n\t}\n\tif (current) parts.push(current.trim());\n\treturn parts;\n}\n\nfunction buildTypeTag(name: string, options: TypeTagOptions | undefined): string {\n\tconst lt = name.indexOf('<');\n\tconst base = lt === -1 ? name : name.slice(0, lt);\n\n\tif (base.split('::').length !== 3) {\n\t\tthrow new Error(`${name} is not a top-level Move type`);\n\t}\n\n\tlet result = name;\n\n\tif (options?.typeArguments) {\n\t\tconst baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));\n\t\tconst supplied = options.typeArguments.map((arg) => {\n\t\t\tif (typeof arg === 'string') {\n\t\t\t\treturn arg;\n\t\t\t}\n\t\t\tif (arg && typeof arg.serialize === 'function' && typeof arg.name === 'string') {\n\t\t\t\treturn arg.name;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid type argument ${stringify(arg)}`);\n\t\t});\n\n\t\tif (supplied.length !== baked.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,\n\t\t\t);\n\t\t}\n\n\t\tresult = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;\n\t}\n\n\tif (HAS_PHANTOM_REGEX.test(result)) {\n\t\tthrow new Error(\n\t\t\toptions?.typeArguments\n\t\t\t\t? `A type argument contains an unfilled phantom parameter in ${result}`\n\t\t\t\t: `Missing type arguments for ${result}`,\n\t\t);\n\t}\n\n\tif (options?.package) {\n\t\tconst [, ...rest] = result.split('::');\n\t\tresult = [options.package, ...rest].join('::');\n\t}\n\n\t// fully validate address-only tags (MVR names can't be parsed as type tags)\n\tif (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {\n\t\tTypeTagSerializer.parseFromStr(result);\n\t}\n\n\treturn result;\n}\n\nasync function resolveBuiltTypeTag(\n\tname: string,\n\toptions: { client: ClientWithCoreApi } & TypeTagOptions,\n): Promise<string> {\n\tconst { client, ...rest } = options;\n\tconst { type } = await client.core.mvr.resolveType({\n\t\ttype: buildTypeTag(name, rest),\n\t});\n\treturn normalizeStructTag(type);\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\t/**\n\t * Build the type tag for this struct.\n\t *\n\t * `typeArguments` is the full positional list, in Move declaration order, and\n\t * is required when the struct has unfilled phantom parameters. The result may\n\t * contain MVR names: those are valid in transaction `typeArguments`, but for\n\t * queries or comparisons against on-chain data use `resolveTypeTag` instead.\n\t */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/**\n\t * Build the type tag for this struct, then resolve any MVR names through the\n\t * client (using its configured overrides and the MVR API) and return the\n\t * normalized, address-only form suitable for queries and comparisons against\n\t * on-chain data.\n\t */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {\n\t/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {\n\t/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (_key, value) =>\n\t\t\ttypeof value === 'bigint' ? value.toString() : value,\n\t\t);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AA0KxD,MAAM,oBAAoB;AAE1B,SAAS,sBAAsB,OAAyB;CACvD,MAAM,QAAkB,EAAE;CAC1B,IAAI,QAAQ;CACZ,IAAI,UAAU;AACd,MAAK,MAAM,QAAQ,OAAO;AACzB,MAAI,SAAS,OAAO,UAAU,GAAG;AAChC,SAAM,KAAK,QAAQ,MAAM,CAAC;AAC1B,aAAU;AACV;;AAED,MAAI,SAAS,IAAK;AAClB,MAAI,SAAS,IAAK;AAClB,aAAW;;AAEZ,KAAI,QAAS,OAAM,KAAK,QAAQ,MAAM,CAAC;AACvC,QAAO;;AAGR,SAAS,aAAa,MAAc,SAA6C;CAChF,MAA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AO,mBAAmB,KAAK;;AAGhC,IAAa,aAAb,cAGU,UAAmB;;;;;;;;;CAS5B,QAAQ,GAAG,MAAmC;AAC7C,SAAO,aAAa,KAAK,MAAM,KAAK,GAAiC;;;;;;;;CAStE,MAAM,eAAe,SAAuD;AAC3E,SAAO,oBACN,KAAK,MACL,QACA;;CAGF,MAAM,IAAiF,EACtF,UACA,GAAG,WAKF;EACD,MAAM,CAAC,OAAO,MAAM,KAAK,QAAiB;GACzC,GAAG;GACH,WAAW,CAAC,SAAS;GACrB,CAAC;AAEF,MAAI,CAAC,IACJ,OAAM,IAAI,MAAM,0BAA0B,WAAW;AAGtD,SAAO;;CAGR,MAAM,QAAqF,EAC1F,QACA,GAAG,WAOF;AASD,UARkB,MAAM,OAAO,KAAK,WAAW;GAC9C,GAAG;GACH,SAAS;IACR,GAAG,QAAQ;IACX,SAAS;IACT;GACD,CAAC,EAEc,QAAQ,KAAK,QAAQ;AACpC,OAAI,eAAe,MAClB,OAAM;AAGP,UAAO;IACN,GAAG;IACH,MAAM,KAAK,MAAM,IAAI,QAAQ;IAC7B;IACA;;;AAwCJ,SAAS,UAAU,KAAc;AAChC,KAAI,OAAO,QAAQ,SAClB,QAAO,KAAK,UAAU,MAAM,MAAM,UACjC,OAAO,UAAU,WAAW,MAAM,UAAU,GAAG,MAC/C;AAEF,KAAI,OAAO,QAAQ,SAClB,QAAO,IAAI,UAAU;AAGtB,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\ttype BcsType,\n\ttype TypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport { type TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { type ClientWithCoreApi, type SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> =\n\tSuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\n/* -------------------------- Move type tags -------------------------- */\n\n/** A type argument: a type tag string, or a BCS type whose name is a Move type. */\nexport type TypeArgument = string | BcsType<any>;\n\nexport interface TypeTagOptions {\n\tpackage?: string;\n\ttypeArguments?: readonly TypeArgument[];\n}\n\n/**\n * `typeArguments` is required when the type's name contains unfilled\n * `phantom X` parameters (at any depth). Everything else — argument arity,\n * position contents, and tag validity — is validated at runtime.\n */\ntype TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}`\n\t? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]\n\t: [options?: TypeTagOptions];\n\ntype ResolveTypeTagOptions<Name extends string> = {\n\tclient: ClientWithCoreApi;\n} & (Name extends `${string}phantom ${string}`\n\t? TypeTagOptions & { typeArguments: readonly TypeArgument[] }\n\t: TypeTagOptions);\n\nconst HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;\n\nfunction splitTopLevelTypeArgs(inner: string): string[] {\n\tconst parts: string[] = [];\n\tlet depth = 0;\n\tlet current = '';\n\tfor (const char of inner) {\n\t\tif (char === ',' && depth === 0) {\n\t\t\tparts.push(current.trim());\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '<') depth++;\n\t\tif (char === '>') depth--;\n\t\tcurrent += char;\n\t}\n\tif (current) parts.push(current.trim());\n\treturn parts;\n}\n\nfunction buildTypeTag(name: string, options: TypeTagOptions | undefined): string {\n\tconst lt = name.indexOf('<');\n\tconst base = lt === -1 ? name : name.slice(0, lt);\n\n\tif (base.split('::').length !== 3) {\n\t\tthrow new Error(`${name} is not a top-level Move type`);\n\t}\n\n\tlet result = name;\n\n\tif (options?.typeArguments) {\n\t\tconst baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));\n\t\tconst supplied = options.typeArguments.map((arg) => {\n\t\t\tif (typeof arg === 'string') {\n\t\t\t\treturn arg;\n\t\t\t}\n\t\t\tif (arg && typeof arg.serialize === 'function' && typeof arg.name === 'string') {\n\t\t\t\treturn arg.name;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid type argument ${stringify(arg)}`);\n\t\t});\n\n\t\tif (supplied.length !== baked.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,\n\t\t\t);\n\t\t}\n\n\t\tresult = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;\n\t}\n\n\tif (HAS_PHANTOM_REGEX.test(result)) {\n\t\tthrow new Error(\n\t\t\toptions?.typeArguments\n\t\t\t\t? `A type argument contains an unfilled phantom parameter in ${result}`\n\t\t\t\t: `Missing type arguments for ${result}`,\n\t\t);\n\t}\n\n\tif (options?.package) {\n\t\tconst [, ...rest] = result.split('::');\n\t\tresult = [options.package, ...rest].join('::');\n\t}\n\n\t// fully validate address-only tags (MVR names can't be parsed as type tags)\n\tif (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {\n\t\tTypeTagSerializer.parseFromStr(result);\n\t}\n\n\treturn result;\n}\n\nasync function resolveBuiltTypeTag(\n\tname: string,\n\toptions: { client: ClientWithCoreApi } & TypeTagOptions,\n): Promise<string> {\n\tconst { client, ...rest } = options;\n\tconst { type } = await client.core.mvr.resolveType({\n\t\ttype: buildTypeTag(name, rest),\n\t});\n\treturn normalizeStructTag(type);\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\t/**\n\t * Build the type tag for this struct.\n\t *\n\t * `typeArguments` is the full positional list, in Move declaration order, and\n\t * is required when the struct has unfilled phantom parameters. The result may\n\t * contain MVR names: those are valid in transaction `typeArguments`, but for\n\t * queries or comparisons against on-chain data use `resolveTypeTag` instead.\n\t */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/**\n\t * Build the type tag for this struct, then resolve any MVR names through the\n\t * client (using its configured overrides and the MVR API) and return the\n\t * normalized, address-only form suitable for queries and comparisons against\n\t * on-chain data.\n\t */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {\n\t/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {\n\t/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (_key, value) =>\n\t\t\ttypeof value === 'bigint' ? value.toString() : value,\n\t\t);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AAUxD,SAAgB,iBAAiB,SAAgD;CAChF,MAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,QAAQ,GAAG;AAE1F,KAAI,QAAQ,UACX,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,aAAa,UACvB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,YAAY,WAAW;EACjC,MAAM,OAAO,iBAAiB,UAAU,OAAO;AAC/C,SAAO,OAAO,IAAI,OAAO,KAAK,GAAG;YACvB,YAAY,WAAW;EACjC,MAAM,YAAY,UAAU;EAC5B,MAAM,MAAM,oBAAoB,UAAU,QAAQ;AAElD,MAAI,QAAQ,qBAAqB;AAChC,QACE,UAAU,WAAW,WAAW,UAAU,WAAW,aACtD,UAAU,SAAS,SAEnB,QAAO,IAAI;AAGZ,OAAI,UAAU,WAAW,YAAY,UAAU,SAAS,UAAU;IACjE,MAAM,QAAQ,UAAU,WAAW;IACnC,MAAM,OAAO,QAAQ,iBAAiB,MAAM,GAAG;AAC/C,WAAO,OAAO,IAAI,OAAO,KAAK,GAAG;;;AAInC,MACC,QAAQ,yBACR,UAAU,WAAW,aACpB,UAAU,SAAS,QAAQ,UAAU,SAAS,OAE/C,QAAO,IAAI;;AAIb,QAAO;;AAGR,SAAgB,uBACf,MACA,UACA,gBACC;CACD,MAAM,SAAS,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,OAAO,KAAK,KAAK,CAAC;AACr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SAAuD;AAC3E,SAAO,oBACN,KAAK,MACL,QACA;;;AAIH,SAAS,UAAU,KAAc;AAChC,KAAI,OAAO,QAAQ,SAClB,QAAO,KAAK,UAAU,MAAM,MAAM,UACjC,OAAO,UAAU,WAAW,MAAM,UAAU,GAAG,MAC/C;AAEF,KAAI,OAAO,QAAQ,SAClB,QAAO,IAAI,UAAU;AAGtB,QAAO"}
|
|
@@ -89,6 +89,19 @@ var RegistryQueries = class {
|
|
|
89
89
|
})).commandResults[0].returnValues[0].bcs;
|
|
90
90
|
return Number(bcs.U64.parse(bytes)) / FLOAT_SCALAR;
|
|
91
91
|
}
|
|
92
|
+
async getMinOpenRiskRatio(poolKey) {
|
|
93
|
+
const tx = new Transaction();
|
|
94
|
+
tx.setSender(this.#ctx.address);
|
|
95
|
+
tx.add(this.#ctx.marginRegistry.minOpenRiskRatio(poolKey));
|
|
96
|
+
const bytes = (await this.#ctx.client.core.simulateTransaction({
|
|
97
|
+
transaction: tx,
|
|
98
|
+
include: {
|
|
99
|
+
commandResults: true,
|
|
100
|
+
effects: true
|
|
101
|
+
}
|
|
102
|
+
})).commandResults[0].returnValues[0].bcs;
|
|
103
|
+
return Number(bcs.U64.parse(bytes)) / FLOAT_SCALAR;
|
|
104
|
+
}
|
|
92
105
|
async getLiquidationRiskRatio(poolKey) {
|
|
93
106
|
const tx = new Transaction();
|
|
94
107
|
tx.setSender(this.#ctx.address);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registryQueries.mjs","names":["#ctx"],"sources":["../../src/queries/registryQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { VecSet } from '../types/bcs.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport type { QueryContext } from './context.js';\n\nexport class RegistryQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync isPoolEnabledForMargin(poolKey: string): Promise<boolean> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.poolEnabled(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.Bool.parse(bytes);\n\t}\n\n\tasync getMarginManagerIdsForOwner(owner: string): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.getMarginManagerIds(owner));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst vecSet = VecSet(bcs.Address).parse(bytes);\n\t\treturn vecSet.contents.map((id) => normalizeSuiAddress(id));\n\t}\n\n\tasync getBaseMarginPoolId(poolKey: string): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.baseMarginPoolId(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst id = bcs.Address.parse(bytes);\n\t\treturn '0x' + id;\n\t}\n\n\tasync getQuoteMarginPoolId(poolKey: string): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.quoteMarginPoolId(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst id = bcs.Address.parse(bytes);\n\t\treturn '0x' + id;\n\t}\n\n\tasync getMinWithdrawRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.minWithdrawRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getMinBorrowRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.minBorrowRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getLiquidationRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.liquidationRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getTargetLiquidationRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.targetLiquidationRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getUserLiquidationReward(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.userLiquidationReward(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst reward = Number(bcs.U64.parse(bytes));\n\t\treturn reward / FLOAT_SCALAR;\n\t}\n\n\tasync getPoolLiquidationReward(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.poolLiquidationReward(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst reward = Number(bcs.U64.parse(bytes));\n\t\treturn reward / FLOAT_SCALAR;\n\t}\n\n\tasync getAllowedMaintainers(): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.allowedMaintainers());\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst vecSet = VecSet(bcs.Address).parse(bytes);\n\t\treturn vecSet.contents.map((id) => normalizeSuiAddress(id));\n\t}\n\n\tasync getAllowedPauseCaps(): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.allowedPauseCaps());\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst vecSet = VecSet(bcs.Address).parse(bytes);\n\t\treturn vecSet.contents.map((id) => normalizeSuiAddress(id));\n\t}\n}\n"],"mappings":";;;;;;;;AAWA,IAAa,kBAAb,MAA6B;CAC5B;CAEA,YAAY,KAAmB;AAC9B,QAAKA,MAAO;;CAGb,MAAM,uBAAuB,SAAmC;EAC/D,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,UAAU,MAAKA,IAAK,QAAQ;AAC/B,KAAG,IAAI,MAAKA,IAAK,eAAe,YAAY,QAAQ,CAAC;EAOrD,MAAM,SALM,MAAM,MAAKA,IAAK,OAAO,KAAK,oBAAoB;GAC3D,aAAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC,EAEgB,eAAgB,GAAG,aAAa,GAAG;AACrD,SAAO,IAAI,KAAK,MAAM,MAAM;;CAG7B,MAAM,4BAA4B,OAAkC;EACnE,MAAM,KAAK,IAAI,aAAa;AAC5B,KAAG,UAAU,MAAKA,IAAK,QAAQ;AAC/B,KAAG,IAAI,MAAKA,IAAK,eAAe,oBAAoB,MAAM,CAAC;EAO3D,MAAM,SALM,MAAM,MAAKA,IAAK,OAAO,KAAK,oBAAoB;GAC3D,aAAa;GACb,SAAS;IAAE,gBAAgB;IAAM,SAAS;IAAM;GAChD,CAAC,EAEgB,eAAgB,GAAG,aAAa,GAAG;AAErD,S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,SAAS;IAAM;GAChD,CAAC,EAEgB,eAAgB,GAAG,aAAa,GAAG;AAErD,SADe,OAAO,IAAI,QAAQ,CAAC,MAAM,MAAM,CACjC,SAAS,KAAK,OAAO,oBAAoB,GAAG,CAAC"}
|
|
1
|
+
{"version":3,"file":"registryQueries.mjs","names":["#ctx"],"sources":["../../src/queries/registryQueries.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { VecSet } from '../types/bcs.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport type { QueryContext } from './context.js';\n\nexport class RegistryQueries {\n\t#ctx: QueryContext;\n\n\tconstructor(ctx: QueryContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\tasync isPoolEnabledForMargin(poolKey: string): Promise<boolean> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.poolEnabled(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\treturn bcs.Bool.parse(bytes);\n\t}\n\n\tasync getMarginManagerIdsForOwner(owner: string): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.getMarginManagerIds(owner));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst vecSet = VecSet(bcs.Address).parse(bytes);\n\t\treturn vecSet.contents.map((id) => normalizeSuiAddress(id));\n\t}\n\n\tasync getBaseMarginPoolId(poolKey: string): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.baseMarginPoolId(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst id = bcs.Address.parse(bytes);\n\t\treturn '0x' + id;\n\t}\n\n\tasync getQuoteMarginPoolId(poolKey: string): Promise<string> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.quoteMarginPoolId(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst id = bcs.Address.parse(bytes);\n\t\treturn '0x' + id;\n\t}\n\n\tasync getMinWithdrawRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.minWithdrawRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getMinBorrowRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.minBorrowRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getMinOpenRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.minOpenRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getLiquidationRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.liquidationRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getTargetLiquidationRiskRatio(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.targetLiquidationRiskRatio(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst ratio = Number(bcs.U64.parse(bytes));\n\t\treturn ratio / FLOAT_SCALAR;\n\t}\n\n\tasync getUserLiquidationReward(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.userLiquidationReward(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst reward = Number(bcs.U64.parse(bytes));\n\t\treturn reward / FLOAT_SCALAR;\n\t}\n\n\tasync getPoolLiquidationReward(poolKey: string): Promise<number> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.poolLiquidationReward(poolKey));\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst reward = Number(bcs.U64.parse(bytes));\n\t\treturn reward / FLOAT_SCALAR;\n\t}\n\n\tasync getAllowedMaintainers(): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.allowedMaintainers());\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst vecSet = VecSet(bcs.Address).parse(bytes);\n\t\treturn vecSet.contents.map((id) => normalizeSuiAddress(id));\n\t}\n\n\tasync getAllowedPauseCaps(): Promise<string[]> {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(this.#ctx.address);\n\t\ttx.add(this.#ctx.marginRegistry.allowedPauseCaps());\n\n\t\tconst res = await this.#ctx.client.core.simulateTransaction({\n\t\t\ttransaction: tx,\n\t\t\tinclude: { commandResults: true, effects: true },\n\t\t});\n\n\t\tconst bytes = res.commandResults![0].returnValues[0].bcs;\n\t\tconst vecSet = VecSet(bcs.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,EAEgB,eAAgB,GAAG,aAAa,GAAG;AAErD,SADe,OAAO,IAAI,QAAQ,CAAC,MAAM,MAAM,CACjC,SAAS,KAAK,OAAO,oBAAoB,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balanceManager.d.mts","names":[],"sources":["../../src/transactions/balanceManager.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"balanceManager.d.mts","names":[],"sources":["../../src/transactions/balanceManager.ts"],"mappings":";;;;;;;;cAYa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EA6BsD;;;;EArB1E,4BAAA,SAAsC,EAAA,EAAI,WAAA;EAyGwB;;;;EApFlE,6BAAA,GAAiC,YAAA,cAA0B,EAAA,EAAI,WAAA,KAAW,yBAAA,CAAA,iBAAA;EAuIZ;;;;;EAzH9D,mBAAA,GAAuB,OAAA,EAAS,mBAAA,MAAyB,EAAA,EAAI,WAAA;EAsKJ;;;;;;;EArJzD,kBAAA,GACE,UAAA,UAAoB,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;EAmQvB;;;;;;;;EAxOjD,mBAAA,GACE,UAAA,UAAoB,OAAA,UAAiB,gBAAA,UAA0B,SAAA,cAC/D,EAAA,EAAI,WAAA;EA2TsE;;;;;;;EArS5E,sBAAA,GACE,UAAA,UAAoB,OAAA,UAAiB,SAAA,cAAuB,EAAA,EAAI,WAAA;EAjHtD;;;;;;EAqIZ,mBAAA,GAAuB,UAAA,UAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAxGT;;;;;EAyH3D,aAAA,GAAiB,UAAA,cAAwB,EAAA,EAAI,WAAA,KAAW,yBAAA,CAAA,iBAAA;EA3GC;;;;;EAyHzD,oBAAA,GAAwB,SAAA,cAAuB,EAAA,EAAI,WAAA,KAAW,yBAAA,CAAA,iBAAA;EAvGM;;;;;;EAsHpE,qBAAA,GAAyB,SAAA,UAAmB,UAAA,cAAwB,EAAA,EAAI,WA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