@waterx/sdk 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/src/account/account-request.d.ts +9 -0
- package/dist/cjs/src/account/account-request.js +20 -0
- package/dist/cjs/src/account/account.d.ts +158 -0
- package/dist/cjs/src/account/account.js +238 -0
- package/dist/cjs/src/account/client.d.ts +42 -0
- package/dist/cjs/src/account/client.js +18 -0
- package/dist/cjs/src/account/config.d.ts +151 -0
- package/dist/cjs/src/account/config.js +9 -0
- package/dist/cjs/src/account/constants.d.ts +5 -0
- package/dist/cjs/src/account/constants.js +8 -0
- package/dist/cjs/src/account/fetch/referral.d.ts +15 -0
- package/dist/cjs/src/account/fetch/referral.js +56 -0
- package/dist/cjs/src/account/fetch/simulate.d.ts +34 -0
- package/dist/cjs/src/account/fetch/simulate.js +49 -0
- package/dist/cjs/src/account/funding/balance.d.ts +32 -0
- package/dist/cjs/src/account/funding/balance.js +100 -0
- package/dist/cjs/src/account/funding/consolidate.d.ts +46 -0
- package/dist/cjs/src/account/funding/consolidate.js +143 -0
- package/dist/cjs/src/account/funding/credit.d.ts +129 -0
- package/dist/cjs/src/account/funding/credit.js +252 -0
- package/dist/cjs/src/account/funding/custody.d.ts +57 -0
- package/dist/cjs/src/account/funding/custody.js +139 -0
- package/dist/cjs/src/account/funding/wormhole.d.ts +86 -0
- package/dist/cjs/src/account/funding/wormhole.js +166 -0
- package/dist/cjs/src/account/index.d.ts +29 -0
- package/dist/cjs/src/account/index.js +45 -0
- package/dist/cjs/src/account/referral.d.ts +21 -0
- package/dist/cjs/src/account/referral.js +78 -0
- package/dist/cjs/src/account/waterx-account.d.ts +31 -0
- package/dist/cjs/src/account/waterx-account.js +29 -0
- package/dist/cjs/src/base-client.d.ts +74 -0
- package/dist/cjs/src/base-client.js +101 -0
- package/dist/cjs/src/constants.d.ts +32 -0
- package/dist/cjs/src/constants.js +41 -0
- package/dist/cjs/src/generated/bucket_v2_framework/account.d.ts +107 -0
- package/dist/cjs/src/generated/bucket_v2_framework/account.js +141 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/bucket_v2_framework/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/bucket_v2_framework/double.d.ts +384 -0
- package/dist/cjs/src/generated/bucket_v2_framework/double.js +504 -0
- package/dist/cjs/src/generated/bucket_v2_framework/float.d.ts +364 -0
- package/dist/cjs/src/generated/bucket_v2_framework/float.js +476 -0
- package/dist/cjs/src/generated/bucket_v2_framework/liability.d.ts +171 -0
- package/dist/cjs/src/generated/bucket_v2_framework/liability.js +192 -0
- package/dist/cjs/src/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/cjs/src/generated/bucket_v2_framework/linked_table.js +405 -0
- package/dist/cjs/src/generated/bucket_v2_framework/sheet.d.ts +424 -0
- package/dist/cjs/src/generated/bucket_v2_framework/sheet.js +395 -0
- package/dist/cjs/src/generated/native_custody/custody_vault.d.ts +586 -0
- package/dist/cjs/src/generated/native_custody/custody_vault.js +555 -0
- package/dist/cjs/src/generated/native_custody/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/cjs/src/generated/native_custody/deps/bucket_v2_framework/float.js +13 -0
- package/dist/cjs/src/generated/native_custody/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/cjs/src/generated/native_custody/deps/bucket_v2_framework/liability.js +16 -0
- package/dist/cjs/src/generated/native_custody/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/cjs/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +52 -0
- package/dist/cjs/src/generated/native_custody/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/native_custody/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/native_custody/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/native_custody/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/native_custody/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/native_custody/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/native_custody/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/native_custody/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/native_custody/events.d.ts +36 -0
- package/dist/cjs/src/generated/native_custody/events.js +71 -0
- package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +68 -0
- package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +113 -0
- package/dist/cjs/src/generated/utils/index.d.ts +30 -0
- package/dist/cjs/src/generated/utils/index.js +168 -0
- package/dist/cjs/src/generated/waterx_account/account.d.ts +1906 -0
- package/dist/cjs/src/generated/waterx_account/account.js +1929 -0
- package/dist/cjs/src/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/cjs/src/generated/waterx_account/deps/bucket_v2_framework/liability.js +16 -0
- package/dist/cjs/src/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/cjs/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +52 -0
- package/dist/cjs/src/generated/waterx_account/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/waterx_account/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/object_table.d.ts +17 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/object_table.js +22 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/table.d.ts +29 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/table.js +34 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_account/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_account/direct_rule.d.ts +77 -0
- package/dist/cjs/src/generated/waterx_account/direct_rule.js +83 -0
- package/dist/cjs/src/generated/waterx_account/events.d.ts +190 -0
- package/dist/cjs/src/generated/waterx_account/events.js +173 -0
- package/dist/cjs/src/generated/waterx_account/version.d.ts +10 -0
- package/dist/cjs/src/generated/waterx_account/version.js +11 -0
- package/dist/cjs/src/generated/waterx_constant_rule/constant_rule.d.ts +68 -0
- package/dist/cjs/src/generated/waterx_constant_rule/constant_rule.js +97 -0
- package/dist/cjs/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.js +13 -0
- package/dist/cjs/src/generated/waterx_constant_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_constant_rule/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_credit/credit_registry.d.ts +708 -0
- package/dist/cjs/src/generated/waterx_credit/credit_registry.js +728 -0
- package/dist/cjs/src/generated/waterx_credit/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/waterx_credit/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/waterx_credit/deps/sui/table.d.ts +29 -0
- package/dist/cjs/src/generated/waterx_credit/deps/sui/table.js +34 -0
- package/dist/cjs/src/generated/waterx_credit/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_credit/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_credit/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_credit/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_credit/limited_supply.d.ts +107 -0
- package/dist/cjs/src/generated/waterx_credit/limited_supply.js +143 -0
- package/dist/cjs/src/generated/waterx_oracle/aggregator.d.ts +211 -0
- package/dist/cjs/src/generated/waterx_oracle/aggregator.js +258 -0
- package/dist/cjs/src/generated/waterx_oracle/collector.d.ts +119 -0
- package/dist/cjs/src/generated/waterx_oracle/collector.js +147 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/bucket_v2_framework/float.js +13 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_oracle/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_oracle/oracle.d.ts +304 -0
- package/dist/cjs/src/generated/waterx_oracle/oracle.js +381 -0
- package/dist/cjs/src/generated/waterx_oracle/version.d.ts +10 -0
- package/dist/cjs/src/generated/waterx_oracle/version.js +11 -0
- package/dist/cjs/src/generated/waterx_perp/account_data.d.ts +269 -0
- package/dist/cjs/src/generated/waterx_perp/account_data.js +340 -0
- package/dist/cjs/src/generated/waterx_perp/admin.d.ts +19 -0
- package/dist/cjs/src/generated/waterx_perp/admin.js +26 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/double.js +13 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/float.js +13 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/liability.js +16 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/linked_table.js +21 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/cjs/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +52 -0
- package/dist/cjs/src/generated/waterx_perp/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/waterx_perp/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/balance.d.ts +15 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/balance.js +20 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/coin.d.ts +14 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/coin.js +51 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_perp/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_perp/events.d.ts +1283 -0
- package/dist/cjs/src/generated/waterx_perp/events.js +990 -0
- package/dist/cjs/src/generated/waterx_perp/global_config.d.ts +775 -0
- package/dist/cjs/src/generated/waterx_perp/global_config.js +918 -0
- package/dist/cjs/src/generated/waterx_perp/keyed_big_vector.d.ts +553 -0
- package/dist/cjs/src/generated/waterx_perp/keyed_big_vector.js +626 -0
- package/dist/cjs/src/generated/waterx_perp/lp_pool.d.ts +1648 -0
- package/dist/cjs/src/generated/waterx_perp/lp_pool.js +1630 -0
- package/dist/cjs/src/generated/waterx_perp/market_config.d.ts +733 -0
- package/dist/cjs/src/generated/waterx_perp/market_config.js +871 -0
- package/dist/cjs/src/generated/waterx_perp/math.d.ts +63 -0
- package/dist/cjs/src/generated/waterx_perp/math.js +70 -0
- package/dist/cjs/src/generated/waterx_perp/memo.d.ts +251 -0
- package/dist/cjs/src/generated/waterx_perp/memo.js +360 -0
- package/dist/cjs/src/generated/waterx_perp/order_book.d.ts +290 -0
- package/dist/cjs/src/generated/waterx_perp/order_book.js +388 -0
- package/dist/cjs/src/generated/waterx_perp/position.d.ts +1005 -0
- package/dist/cjs/src/generated/waterx_perp/position.js +1200 -0
- package/dist/cjs/src/generated/waterx_perp/request.d.ts +544 -0
- package/dist/cjs/src/generated/waterx_perp/request.js +609 -0
- package/dist/cjs/src/generated/waterx_perp/response.d.ts +247 -0
- package/dist/cjs/src/generated/waterx_perp/response.js +331 -0
- package/dist/cjs/src/generated/waterx_perp/trading.d.ts +2945 -0
- package/dist/cjs/src/generated/waterx_perp/trading.js +2616 -0
- package/dist/cjs/src/generated/waterx_perp/version.d.ts +10 -0
- package/dist/cjs/src/generated/waterx_perp/version.js +11 -0
- package/dist/cjs/src/generated/waterx_perp/witness.d.ts +18 -0
- package/dist/cjs/src/generated/waterx_perp/witness.js +25 -0
- package/dist/cjs/src/generated/waterx_perp_view/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/waterx_perp_view/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/waterx_perp_view/view.d.ts +447 -0
- package/dist/cjs/src/generated/waterx_perp_view/view.js +459 -0
- package/dist/cjs/src/generated/waterx_prediction/account_data.d.ts +344 -0
- package/dist/cjs/src/generated/waterx_prediction/account_data.js +470 -0
- package/dist/cjs/src/generated/waterx_prediction/admin.d.ts +7 -0
- package/dist/cjs/src/generated/waterx_prediction/admin.js +12 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +21 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/sui/table.d.ts +29 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/sui/table.js +34 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_prediction/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_prediction/events.d.ts +288 -0
- package/dist/cjs/src/generated/waterx_prediction/events.js +254 -0
- package/dist/cjs/src/generated/waterx_prediction/global_config.d.ts +121 -0
- package/dist/cjs/src/generated/waterx_prediction/global_config.js +186 -0
- package/dist/cjs/src/generated/waterx_prediction/order.d.ts +233 -0
- package/dist/cjs/src/generated/waterx_prediction/order.js +339 -0
- package/dist/cjs/src/generated/waterx_prediction/outcome.d.ts +58 -0
- package/dist/cjs/src/generated/waterx_prediction/outcome.js +82 -0
- package/dist/cjs/src/generated/waterx_prediction/position.d.ts +175 -0
- package/dist/cjs/src/generated/waterx_prediction/position.js +232 -0
- package/dist/cjs/src/generated/waterx_prediction/version.d.ts +10 -0
- package/dist/cjs/src/generated/waterx_prediction/version.js +11 -0
- package/dist/cjs/src/generated/waterx_prediction/view.d.ts +418 -0
- package/dist/cjs/src/generated/waterx_prediction/view.js +492 -0
- package/dist/cjs/src/generated/waterx_prediction/waterx_prediction.d.ts +1858 -0
- package/dist/cjs/src/generated/waterx_prediction/waterx_prediction.js +1972 -0
- package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.d.ts +192 -0
- package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.js +214 -0
- package/dist/cjs/src/generated/waterx_referral/deps/sui/table.d.ts +29 -0
- package/dist/cjs/src/generated/waterx_referral/deps/sui/table.js +34 -0
- package/dist/cjs/src/generated/waterx_referral/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_referral/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_referral/referral_table.d.ts +171 -0
- package/dist/cjs/src/generated/waterx_referral/referral_table.js +239 -0
- package/dist/cjs/src/generated/waterx_staking/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_staking/deps/bucket_v2_framework/double.js +13 -0
- package/dist/cjs/src/generated/waterx_staking/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/waterx_staking/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/waterx_staking/deps/sui/table.d.ts +29 -0
- package/dist/cjs/src/generated/waterx_staking/deps/sui/table.js +34 -0
- package/dist/cjs/src/generated/waterx_staking/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_staking/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/waterx_staking/waterx_staking.d.ts +746 -0
- package/dist/cjs/src/generated/waterx_staking/waterx_staking.js +797 -0
- package/dist/cjs/src/generated/waterx_staking/witness.d.ts +16 -0
- package/dist/cjs/src/generated/waterx_staking/witness.js +21 -0
- package/dist/cjs/src/generated/waterx_supra_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_supra_rule/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_supra_rule/supra_rule.d.ts +158 -0
- package/dist/cjs/src/generated/waterx_supra_rule/supra_rule.js +189 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.js +13 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/bucket_v2_framework/linked_table.js +21 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/std/type_name.d.ts +17 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/std/type_name.js +22 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/sui/balance.d.ts +12 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/sui/balance.js +17 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/withdrawal_queue/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/withdrawal_queue/withdrawal_queue.d.ts +923 -0
- package/dist/cjs/src/generated/withdrawal_queue/withdrawal_queue.js +965 -0
- package/dist/cjs/src/generated/wlp/wlp.d.ts +28 -0
- package/dist/cjs/src/generated/wlp/wlp.js +37 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/sui/table.d.ts +29 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/sui/table.js +34 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/sui/vec_set.d.ts +16 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/sui/vec_set.js +22 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/wormhole_sdk/consumed_vaas.d.ts +12 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/wormhole_sdk/consumed_vaas.js +45 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/wormhole_sdk/emitter.d.ts +14 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/wormhole_sdk/emitter.js +19 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/wormhole_sdk/set.d.ts +16 -0
- package/dist/cjs/src/generated/wormhole_bridge/deps/wormhole_sdk/set.js +51 -0
- package/dist/cjs/src/generated/wormhole_bridge/events.d.ts +32 -0
- package/dist/cjs/src/generated/wormhole_bridge/events.js +31 -0
- package/dist/cjs/src/generated/wormhole_bridge/wormhole_bridge.d.ts +638 -0
- package/dist/cjs/src/generated/wormhole_bridge/wormhole_bridge.js +692 -0
- package/dist/cjs/src/oracle/aggregate.d.ts +74 -0
- package/dist/cjs/src/oracle/aggregate.js +118 -0
- package/dist/cjs/src/oracle/config.d.ts +99 -0
- package/dist/cjs/src/oracle/config.js +26 -0
- package/dist/cjs/src/oracle/host.d.ts +32 -0
- package/dist/cjs/src/oracle/host.js +11 -0
- package/dist/cjs/src/oracle/index.d.ts +16 -0
- package/dist/cjs/src/oracle/index.js +31 -0
- package/dist/cjs/src/oracle/pyth.d.ts +52 -0
- package/dist/cjs/src/oracle/pyth.js +227 -0
- package/dist/cjs/src/oracle/rules/constant-rule.d.ts +9 -0
- package/dist/cjs/src/oracle/rules/constant-rule.js +17 -0
- package/dist/cjs/src/oracle/rules/pyth-rule.d.ts +11 -0
- package/dist/cjs/src/oracle/rules/pyth-rule.js +23 -0
- package/dist/cjs/src/oracle/rules/sponsor.d.ts +28 -0
- package/dist/cjs/src/oracle/rules/sponsor.js +52 -0
- package/dist/cjs/src/oracle/rules/supra-rule.d.ts +11 -0
- package/dist/cjs/src/oracle/rules/supra-rule.js +25 -0
- package/dist/cjs/src/perp/client.d.ts +78 -0
- package/dist/cjs/src/perp/client.js +112 -0
- package/dist/cjs/src/perp/config-view.d.ts +102 -0
- package/dist/cjs/src/perp/config-view.js +178 -0
- package/dist/cjs/src/perp/config.d.ts +126 -0
- package/dist/cjs/src/perp/config.js +119 -0
- package/dist/cjs/src/perp/constants.d.ts +49 -0
- package/dist/cjs/src/perp/constants.js +79 -0
- package/dist/cjs/src/perp/fetch/account.d.ts +43 -0
- package/dist/cjs/src/perp/fetch/account.js +69 -0
- package/dist/cjs/src/perp/fetch/bridge.d.ts +90 -0
- package/dist/cjs/src/perp/fetch/bridge.js +131 -0
- package/dist/cjs/src/perp/fetch/custody.d.ts +32 -0
- package/dist/cjs/src/perp/fetch/custody.js +66 -0
- package/dist/cjs/src/perp/fetch/market.d.ts +30 -0
- package/dist/cjs/src/perp/fetch/market.js +75 -0
- package/dist/cjs/src/perp/fetch/positions.d.ts +70 -0
- package/dist/cjs/src/perp/fetch/positions.js +195 -0
- package/dist/cjs/src/perp/fetch/simulate.d.ts +12 -0
- package/dist/cjs/src/perp/fetch/simulate.js +21 -0
- package/dist/cjs/src/perp/fetch.d.ts +23 -0
- package/dist/cjs/src/perp/fetch.js +39 -0
- package/dist/cjs/src/perp/index.d.ts +29 -0
- package/dist/cjs/src/perp/index.js +183 -0
- package/dist/cjs/src/perp/tx-builders/common.d.ts +83 -0
- package/dist/cjs/src/perp/tx-builders/common.js +76 -0
- package/dist/cjs/src/perp/tx-builders/credit.d.ts +65 -0
- package/dist/cjs/src/perp/tx-builders/credit.js +67 -0
- package/dist/cjs/src/perp/tx-builders/rewards.d.ts +30 -0
- package/dist/cjs/src/perp/tx-builders/rewards.js +37 -0
- package/dist/cjs/src/perp/tx-builders/trading.d.ts +51 -0
- package/dist/cjs/src/perp/tx-builders/trading.js +71 -0
- package/dist/cjs/src/perp/tx-builders/wlp.d.ts +90 -0
- package/dist/cjs/src/perp/tx-builders/wlp.js +126 -0
- package/dist/cjs/src/perp/tx-builders.d.ts +23 -0
- package/dist/cjs/src/perp/tx-builders.js +45 -0
- package/dist/cjs/src/perp/user/index.d.ts +8 -0
- package/dist/cjs/src/perp/user/index.js +24 -0
- package/dist/cjs/src/perp/user/order.d.ts +89 -0
- package/dist/cjs/src/perp/user/order.js +175 -0
- package/dist/cjs/src/perp/user/staking.d.ts +54 -0
- package/dist/cjs/src/perp/user/staking.js +147 -0
- package/dist/cjs/src/perp/user/trading.d.ts +119 -0
- package/dist/cjs/src/perp/user/trading.js +310 -0
- package/dist/cjs/src/perp/user/wlp.d.ts +58 -0
- package/dist/cjs/src/perp/user/wlp.js +139 -0
- package/dist/cjs/src/prediction/account.d.ts +96 -0
- package/dist/cjs/src/prediction/account.js +212 -0
- package/dist/cjs/src/prediction/admin.d.ts +47 -0
- package/dist/cjs/src/prediction/admin.js +116 -0
- package/dist/cjs/src/prediction/bcs.d.ts +28 -0
- package/dist/cjs/src/prediction/bcs.js +189 -0
- package/dist/cjs/src/prediction/client.d.ts +56 -0
- package/dist/cjs/src/prediction/client.js +128 -0
- package/dist/cjs/src/prediction/config.d.ts +74 -0
- package/dist/cjs/src/prediction/config.js +86 -0
- package/dist/cjs/src/prediction/constants.d.ts +44 -0
- package/dist/cjs/src/prediction/constants.js +49 -0
- package/dist/cjs/src/prediction/fetch.d.ts +82 -0
- package/dist/cjs/src/prediction/fetch.js +294 -0
- package/dist/cjs/src/prediction/gift-link.d.ts +6 -0
- package/dist/cjs/src/prediction/gift-link.js +16 -0
- package/dist/cjs/src/prediction/gift.d.ts +242 -0
- package/dist/cjs/src/prediction/gift.js +490 -0
- package/dist/cjs/src/prediction/index.d.ts +29 -0
- package/dist/cjs/src/prediction/index.js +154 -0
- package/dist/cjs/src/prediction/prediction.d.ts +149 -0
- package/dist/cjs/src/prediction/prediction.js +410 -0
- package/dist/cjs/src/prediction/tx-builders.d.ts +44 -0
- package/dist/cjs/src/prediction/tx-builders.js +56 -0
- package/dist/cjs/src/prediction/types.d.ts +95 -0
- package/dist/cjs/src/prediction/types.js +2 -0
- package/dist/cjs/src/prediction/user/account.d.ts +2 -0
- package/dist/cjs/src/prediction/user/account.js +17 -0
- package/dist/cjs/src/prediction/user/admin.d.ts +6 -0
- package/dist/cjs/src/prediction/user/admin.js +19 -0
- package/dist/cjs/src/prediction/user/gift.d.ts +2 -0
- package/dist/cjs/src/prediction/user/gift.js +24 -0
- package/dist/cjs/src/prediction/user/index.d.ts +5 -0
- package/dist/cjs/src/prediction/user/index.js +60 -0
- package/dist/cjs/src/prediction/user/keeper.d.ts +2 -0
- package/dist/cjs/src/prediction/user/keeper.js +13 -0
- package/dist/cjs/src/prediction/user/order.d.ts +2 -0
- package/dist/cjs/src/prediction/user/order.js +6 -0
- package/dist/cjs/src/prediction/user/position.d.ts +2 -0
- package/dist/cjs/src/prediction/user/position.js +11 -0
- package/dist/cjs/src/prediction/utils/bcs.d.ts +6 -0
- package/dist/cjs/src/prediction/utils/bcs.js +29 -0
- package/dist/cjs/src/prediction/utils/index.d.ts +8 -0
- package/dist/cjs/src/prediction/utils/index.js +31 -0
- package/dist/cjs/src/prediction/utils.d.ts +30 -0
- package/dist/cjs/src/prediction/utils.js +200 -0
- package/dist/cjs/src/sdk.d.ts +22 -0
- package/dist/cjs/src/sdk.js +62 -0
- package/dist/cjs/src/unified-client.d.ts +402 -0
- package/dist/cjs/src/unified-client.js +218 -0
- package/dist/cjs/src/utils/config.d.ts +11 -0
- package/dist/cjs/src/utils/config.js +19 -0
- package/dist/cjs/src/utils/math.d.ts +287 -0
- package/dist/cjs/src/utils/math.js +469 -0
- package/dist/src/prediction/client.d.ts +11 -0
- package/dist/src/prediction/client.js +16 -0
- package/dist/src/prediction/gift.d.ts +19 -0
- package/dist/src/prediction/gift.js +26 -1
- package/package.json +119 -31
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wormhole / Wormholescan integration for the cross-chain credit bridge.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for VAA discovery + (de)serialization — mirrors
|
|
6
|
+
* `oracle/pyth.ts`'s role for Pyth's Hermes endpoint. Two directions:
|
|
7
|
+
*
|
|
8
|
+
* - Mint (EVM → Sui): fetch the signed VAA for an EVM `Deposit` by
|
|
9
|
+
* (emitter chain, emitter address, sequence); the raw bytes feed
|
|
10
|
+
* `wormhole_bridge::redeem_vaa`.
|
|
11
|
+
* - Withdraw (Sui → EVM): list recent VAAs emitted by the bridge's
|
|
12
|
+
* `EmitterCap` to submit on the EVM side.
|
|
13
|
+
*
|
|
14
|
+
* Endpoints / chain ids come from `client.wormhole` (network defaults in
|
|
15
|
+
* `WORMHOLE_DEFAULTS`, overridable via `WaterXConfig.wormhole`).
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.padEvmEmitter = void 0;
|
|
19
|
+
exports.toWormholescanEmitter = toWormholescanEmitter;
|
|
20
|
+
exports.fetchVaa = fetchVaa;
|
|
21
|
+
exports.listVaasByEmitter = listVaasByEmitter;
|
|
22
|
+
exports.waitForVaa = waitForVaa;
|
|
23
|
+
exports.vaaBase64ToBytes = vaaBase64ToBytes;
|
|
24
|
+
exports.vaaBytesToBase64 = vaaBytesToBase64;
|
|
25
|
+
exports.vaaBase64ToHex = vaaBase64ToHex;
|
|
26
|
+
exports.fetchDepositVaa = fetchDepositVaa;
|
|
27
|
+
exports.listBridgeWithdrawalVaas = listBridgeWithdrawalVaas;
|
|
28
|
+
const bcs_1 = require("@mysten/bcs");
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Emitter address formatting
|
|
31
|
+
// ============================================================================
|
|
32
|
+
/**
|
|
33
|
+
* Normalize an emitter id to Wormholescan's `emitter` path segment:
|
|
34
|
+
* 64-char lowercase hex, no `0x`. Accepts a 0x EVM address (left-padded to
|
|
35
|
+
* 32 bytes) or a 32-byte Sui object id (the bridge `EmitterCap` id).
|
|
36
|
+
*/
|
|
37
|
+
function toWormholescanEmitter(idOrAddress) {
|
|
38
|
+
const raw = idOrAddress.startsWith("0x") ? idOrAddress.slice(2) : idOrAddress;
|
|
39
|
+
return raw.toLowerCase().padStart(64, "0");
|
|
40
|
+
}
|
|
41
|
+
/** EVM-side naming alias of {@link toWormholescanEmitter}. */
|
|
42
|
+
exports.padEvmEmitter = toWormholescanEmitter;
|
|
43
|
+
async function doFetch(url, opts) {
|
|
44
|
+
const fetchImpl = opts?.fetchImpl ?? globalThis.fetch;
|
|
45
|
+
if (!fetchImpl) {
|
|
46
|
+
throw new Error("wormhole: no global `fetch` available; pass opts.fetchImpl");
|
|
47
|
+
}
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
const timer = setTimeout(() => controller.abort(), opts?.timeoutMs ?? 10_000);
|
|
50
|
+
const onOuterAbort = () => controller.abort();
|
|
51
|
+
opts?.signal?.addEventListener("abort", onOuterAbort, { once: true });
|
|
52
|
+
try {
|
|
53
|
+
return await fetchImpl(url, { cache: "no-store", signal: controller.signal });
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
opts?.signal?.removeEventListener("abort", onOuterAbort);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetch a single signed VAA. Returns `null` while guardians haven't signed
|
|
62
|
+
* it yet (HTTP 404 or no `vaa` field) so callers can retry on the next tick.
|
|
63
|
+
*/
|
|
64
|
+
async function fetchVaa(apiBase, chainId, emitter, sequence, opts) {
|
|
65
|
+
const url = `${apiBase}/vaas/${chainId}/${emitter}/${sequence}`;
|
|
66
|
+
const res = await doFetch(url, opts);
|
|
67
|
+
if (res.status === 404)
|
|
68
|
+
return null;
|
|
69
|
+
if (!res.ok) {
|
|
70
|
+
throw new Error(`Wormholescan ${res.status}: ${await res.text()}`);
|
|
71
|
+
}
|
|
72
|
+
const json = (await res.json());
|
|
73
|
+
if (!json?.data?.vaa)
|
|
74
|
+
return null;
|
|
75
|
+
return json.data;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* List recent VAAs emitted by `emitter` on `chainId`, newest first. Used by
|
|
79
|
+
* the burn relayer to discover Sui→EVM `WithdrawalInitiated` messages
|
|
80
|
+
* (Wormholescan only returns guardian-signed VAAs, so the await is implicit).
|
|
81
|
+
*/
|
|
82
|
+
async function listVaasByEmitter(apiBase, chainId, emitter, opts) {
|
|
83
|
+
const page = opts?.page ?? 0;
|
|
84
|
+
const pageSize = opts?.pageSize ?? 20;
|
|
85
|
+
const url = `${apiBase}/vaas/${chainId}/${emitter}?page=${page}&pageSize=${pageSize}`;
|
|
86
|
+
const res = await doFetch(url, opts);
|
|
87
|
+
if (!res.ok) {
|
|
88
|
+
throw new Error(`Wormholescan list ${res.status}: ${await res.text()}`);
|
|
89
|
+
}
|
|
90
|
+
const json = (await res.json());
|
|
91
|
+
return json.data ?? [];
|
|
92
|
+
}
|
|
93
|
+
/** Poll {@link fetchVaa} until the VAA is signed or `timeoutMs` elapses. */
|
|
94
|
+
async function waitForVaa(apiBase, chainId, emitter, sequence, opts = {}) {
|
|
95
|
+
const intervalMs = opts.intervalMs ?? 30_000;
|
|
96
|
+
const timeoutMs = opts.timeoutMs ?? 25 * 60_000;
|
|
97
|
+
const start = Date.now();
|
|
98
|
+
let attempt = 0;
|
|
99
|
+
while (Date.now() - start < timeoutMs) {
|
|
100
|
+
if (opts.signal?.aborted)
|
|
101
|
+
throw new Error("waitForVaa: aborted");
|
|
102
|
+
attempt++;
|
|
103
|
+
opts.onTick?.(attempt);
|
|
104
|
+
const vaa = await fetchVaa(apiBase, chainId, emitter, sequence, opts);
|
|
105
|
+
if (vaa)
|
|
106
|
+
return vaa;
|
|
107
|
+
await abortableSleep(intervalMs, opts.signal);
|
|
108
|
+
}
|
|
109
|
+
throw new Error("waitForVaa: timeout");
|
|
110
|
+
}
|
|
111
|
+
function abortableSleep(ms, signal) {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
const timer = setTimeout(() => {
|
|
114
|
+
signal?.removeEventListener("abort", onAbort);
|
|
115
|
+
resolve();
|
|
116
|
+
}, ms);
|
|
117
|
+
const onAbort = () => {
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
reject(new Error("waitForVaa: aborted"));
|
|
120
|
+
};
|
|
121
|
+
if (signal?.aborted) {
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
reject(new Error("waitForVaa: aborted"));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// ============================================================================
|
|
130
|
+
// VAA (de)serialization — portable (Node + edge/browser)
|
|
131
|
+
// ============================================================================
|
|
132
|
+
/** Base64 VAA → raw bytes (the form Sui `redeem_vaa(vector<u8>)` expects). */
|
|
133
|
+
function vaaBase64ToBytes(b64) {
|
|
134
|
+
return (0, bcs_1.fromBase64)(b64);
|
|
135
|
+
}
|
|
136
|
+
/** Raw bytes → base64 (round-trips a VAA pulled off-chain). */
|
|
137
|
+
function vaaBytesToBase64(bytes) {
|
|
138
|
+
return (0, bcs_1.toBase64)(bytes);
|
|
139
|
+
}
|
|
140
|
+
/** Base64 VAA → `0x`-prefixed hex (the form EVM `submitWithdrawalVAA(bytes)` expects). */
|
|
141
|
+
function vaaBase64ToHex(b64) {
|
|
142
|
+
return `0x${(0, bcs_1.toHex)((0, bcs_1.fromBase64)(b64))}`;
|
|
143
|
+
}
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// Client-aware convenience
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/**
|
|
148
|
+
* Fetch the signed VAA for an inbound EVM `Deposit` using the client's
|
|
149
|
+
* configured Wormholescan endpoint. `emitter` is the EVM-side bridge
|
|
150
|
+
* address (0x form accepted — left-padded automatically); `chainId` is the
|
|
151
|
+
* source EVM chain's Wormhole chain id.
|
|
152
|
+
*/
|
|
153
|
+
function fetchDepositVaa(client, evmWormholeChainId, evmEmitter, sequence, opts) {
|
|
154
|
+
return fetchVaa(client.wormhole.wormholescan_api, evmWormholeChainId, toWormholescanEmitter(evmEmitter), sequence, opts);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* List recent Sui→EVM VAAs from the configured bridge `EmitterCap` (burn
|
|
158
|
+
* relayer). Requires `packages.wormhole_bridge.emitter_cap` in config.
|
|
159
|
+
*/
|
|
160
|
+
function listBridgeWithdrawalVaas(client, opts) {
|
|
161
|
+
const emitterCap = client.config.packages.wormhole_bridge?.emitter_cap;
|
|
162
|
+
if (!emitterCap) {
|
|
163
|
+
throw new Error("wormhole_bridge.emitter_cap missing from config");
|
|
164
|
+
}
|
|
165
|
+
return listVaasByEmitter(client.wormhole.wormholescan_api, client.wormhole.sui_chain_id, toWormholescanEmitter(emitterCap), opts);
|
|
166
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified WaterX account namespace — exposed as `client.account`.
|
|
3
|
+
*
|
|
4
|
+
* Aggregates the generic `waterx_account` framework builders with the funding
|
|
5
|
+
* (credit + custody) builders into one surface. This is the contract's **base**
|
|
6
|
+
* layer: it lives under `account/` and depends only **down** (base-client /
|
|
7
|
+
* constants / generated) — it must never import `perp/` or `prediction/`. Builders
|
|
8
|
+
* are typed to the {@link AccountClientLike} capability interface (in `./client.ts`),
|
|
9
|
+
* which `PerpClient` satisfies structurally; `bindClient` passes the perp-line
|
|
10
|
+
* client (which carries the shared `waterx_account` + `AccountRegistry`, bridge /
|
|
11
|
+
* native_custody / withdrawal_queue / credit_registry) as arg 0. Because
|
|
12
|
+
* `waterx_account` is a single shared object across both product lines, an account
|
|
13
|
+
* created here is usable by perp and prediction alike (see the cross-network caveat
|
|
14
|
+
* on the umbrella `WaterXClient`).
|
|
15
|
+
*
|
|
16
|
+
* The prediction-specific account operations (delegate prediction permission,
|
|
17
|
+
* prediction protocol whitelist / asset allowlist) are NOT generic and stay on
|
|
18
|
+
* `client.predict`.
|
|
19
|
+
*
|
|
20
|
+
* INVARIANT: every export below must be **client-first** — `bindClient` (in
|
|
21
|
+
* `unified-client.ts`) blindly binds the client as arg 0 to each function here, so
|
|
22
|
+
* a non-client-first helper (e.g. a local crypto/URL util) leaking out of these
|
|
23
|
+
* modules would be mis-bound silently. Keep such helpers unexported, or add them to
|
|
24
|
+
* `NON_CLIENT_FIRST` in `unified-client.ts` (the coverage guard in
|
|
25
|
+
* `test/perp/unit/unified-client.test.ts` only excuses names on that list).
|
|
26
|
+
*/
|
|
27
|
+
export * from "./account.ts";
|
|
28
|
+
export * from "./funding/credit.ts";
|
|
29
|
+
export * from "./funding/custody.ts";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Unified WaterX account namespace — exposed as `client.account`.
|
|
4
|
+
*
|
|
5
|
+
* Aggregates the generic `waterx_account` framework builders with the funding
|
|
6
|
+
* (credit + custody) builders into one surface. This is the contract's **base**
|
|
7
|
+
* layer: it lives under `account/` and depends only **down** (base-client /
|
|
8
|
+
* constants / generated) — it must never import `perp/` or `prediction/`. Builders
|
|
9
|
+
* are typed to the {@link AccountClientLike} capability interface (in `./client.ts`),
|
|
10
|
+
* which `PerpClient` satisfies structurally; `bindClient` passes the perp-line
|
|
11
|
+
* client (which carries the shared `waterx_account` + `AccountRegistry`, bridge /
|
|
12
|
+
* native_custody / withdrawal_queue / credit_registry) as arg 0. Because
|
|
13
|
+
* `waterx_account` is a single shared object across both product lines, an account
|
|
14
|
+
* created here is usable by perp and prediction alike (see the cross-network caveat
|
|
15
|
+
* on the umbrella `WaterXClient`).
|
|
16
|
+
*
|
|
17
|
+
* The prediction-specific account operations (delegate prediction permission,
|
|
18
|
+
* prediction protocol whitelist / asset allowlist) are NOT generic and stay on
|
|
19
|
+
* `client.predict`.
|
|
20
|
+
*
|
|
21
|
+
* INVARIANT: every export below must be **client-first** — `bindClient` (in
|
|
22
|
+
* `unified-client.ts`) blindly binds the client as arg 0 to each function here, so
|
|
23
|
+
* a non-client-first helper (e.g. a local crypto/URL util) leaking out of these
|
|
24
|
+
* modules would be mis-bound silently. Keep such helpers unexported, or add them to
|
|
25
|
+
* `NON_CLIENT_FIRST` in `unified-client.ts` (the coverage guard in
|
|
26
|
+
* `test/perp/unit/unified-client.test.ts` only excuses names on that list).
|
|
27
|
+
*/
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
40
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
__exportStar(require("./account.js"), exports); // generic waterx_account framework builders
|
|
44
|
+
__exportStar(require("./funding/credit.js"), exports); // cross-chain CREDIT / bridge builders
|
|
45
|
+
__exportStar(require("./funding/custody.js"), exports); // native_custody PSM mint builders
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Referral builders — backed by the standalone `waterx_referral` package.
|
|
3
|
+
* Requires
|
|
4
|
+
* `config.packages.waterx_referral.{published_at,referral_table}` to be
|
|
5
|
+
* populated; otherwise the builder throws so misconfigured deployments fail
|
|
6
|
+
* loudly instead of silently aborting on-chain.
|
|
7
|
+
*/
|
|
8
|
+
import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
9
|
+
import type { WxaClientLike } from "./client.ts";
|
|
10
|
+
export interface SetReferralCodeParams {
|
|
11
|
+
/** Referral code string the caller wants to claim. */
|
|
12
|
+
code: string;
|
|
13
|
+
bucketAccount?: string | TransactionArgument;
|
|
14
|
+
}
|
|
15
|
+
export declare function setReferralCode(client: WxaClientLike, tx: Transaction, params: SetReferralCodeParams): void;
|
|
16
|
+
export interface UseReferralCodeParams {
|
|
17
|
+
/** Referral code to bind to the caller's address. */
|
|
18
|
+
code: string;
|
|
19
|
+
bucketAccount?: string | TransactionArgument;
|
|
20
|
+
}
|
|
21
|
+
export declare function useReferralCode(client: WxaClientLike, tx: Transaction, params: UseReferralCodeParams): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Referral builders — backed by the standalone `waterx_referral` package.
|
|
4
|
+
* Requires
|
|
5
|
+
* `config.packages.waterx_referral.{published_at,referral_table}` to be
|
|
6
|
+
* populated; otherwise the builder throws so misconfigured deployments fail
|
|
7
|
+
* loudly instead of silently aborting on-chain.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.setReferralCode = setReferralCode;
|
|
44
|
+
exports.useReferralCode = useReferralCode;
|
|
45
|
+
const referral = __importStar(require("../generated/waterx_referral/referral_table.js"));
|
|
46
|
+
const account_request_ts_1 = require("./account-request.js");
|
|
47
|
+
function requireReferralConfig(client) {
|
|
48
|
+
const pkg = client.config.packages.waterx_referral?.published_at;
|
|
49
|
+
const table = client.config.packages.waterx_referral?.referral_table;
|
|
50
|
+
if (!pkg || !table) {
|
|
51
|
+
throw new Error("referral package not configured: set config.packages.waterx_referral.{published_at,referral_table}");
|
|
52
|
+
}
|
|
53
|
+
return { pkg, table };
|
|
54
|
+
}
|
|
55
|
+
function setReferralCode(client, tx, params) {
|
|
56
|
+
const { pkg, table } = requireReferralConfig(client);
|
|
57
|
+
const req = (0, account_request_ts_1.makeSenderRequest)(client, tx, params.bucketAccount);
|
|
58
|
+
referral.setReferralCode({
|
|
59
|
+
package: pkg,
|
|
60
|
+
arguments: {
|
|
61
|
+
table: tx.object(table),
|
|
62
|
+
req: req,
|
|
63
|
+
code: params.code,
|
|
64
|
+
},
|
|
65
|
+
})(tx);
|
|
66
|
+
}
|
|
67
|
+
function useReferralCode(client, tx, params) {
|
|
68
|
+
const { pkg, table } = requireReferralConfig(client);
|
|
69
|
+
const req = (0, account_request_ts_1.makeSenderRequest)(client, tx, params.bucketAccount);
|
|
70
|
+
referral.useReferralCode({
|
|
71
|
+
package: pkg,
|
|
72
|
+
arguments: {
|
|
73
|
+
table: tx.object(table),
|
|
74
|
+
req: req,
|
|
75
|
+
code: params.code,
|
|
76
|
+
},
|
|
77
|
+
})(tx);
|
|
78
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `waterx_account` PTB builders.
|
|
3
|
+
*
|
|
4
|
+
* Perp and prediction both create/operate accounts through the **same** on-chain
|
|
5
|
+
* `waterx_account` system (same package + `AccountRegistry`), so the actual PTB
|
|
6
|
+
* calls are assembled here once. Each product line resolves the deployment
|
|
7
|
+
* coordinates (`WxaAccountRef`) and builds its own `senderRequest` (via its own
|
|
8
|
+
* account-request helper), then delegates the moveCall to these functions.
|
|
9
|
+
*
|
|
10
|
+
* These builders are raw `tx.moveCall(...)` (no generated-bindings dependency),
|
|
11
|
+
* so the module is shared by both `src/user/account.ts` (perp) and
|
|
12
|
+
* `src/prediction/account.ts` (prediction) without coupling to either line's
|
|
13
|
+
* generated code.
|
|
14
|
+
*/
|
|
15
|
+
import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
16
|
+
/** Resolved `waterx_account` deployment coordinates (each line resolves these from its own client). */
|
|
17
|
+
export interface WxaAccountRef {
|
|
18
|
+
/** `waterx_account` package id (`published_at`). */
|
|
19
|
+
packageId: string;
|
|
20
|
+
/** `AccountRegistry` shared-object id. */
|
|
21
|
+
registry: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `waterx_account::account::create_account`. Returns the new account id
|
|
25
|
+
* (Move return value). `senderRequest` is the `account::request` hot-potato the
|
|
26
|
+
* caller built with its own account-request helper.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createAccountCall(tx: Transaction, ref: WxaAccountRef, params: {
|
|
29
|
+
senderRequest: TransactionArgument;
|
|
30
|
+
alias: string;
|
|
31
|
+
}): TransactionArgument;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared `waterx_account` PTB builders.
|
|
4
|
+
*
|
|
5
|
+
* Perp and prediction both create/operate accounts through the **same** on-chain
|
|
6
|
+
* `waterx_account` system (same package + `AccountRegistry`), so the actual PTB
|
|
7
|
+
* calls are assembled here once. Each product line resolves the deployment
|
|
8
|
+
* coordinates (`WxaAccountRef`) and builds its own `senderRequest` (via its own
|
|
9
|
+
* account-request helper), then delegates the moveCall to these functions.
|
|
10
|
+
*
|
|
11
|
+
* These builders are raw `tx.moveCall(...)` (no generated-bindings dependency),
|
|
12
|
+
* so the module is shared by both `src/user/account.ts` (perp) and
|
|
13
|
+
* `src/prediction/account.ts` (prediction) without coupling to either line's
|
|
14
|
+
* generated code.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.createAccountCall = createAccountCall;
|
|
18
|
+
/**
|
|
19
|
+
* `waterx_account::account::create_account`. Returns the new account id
|
|
20
|
+
* (Move return value). `senderRequest` is the `account::request` hot-potato the
|
|
21
|
+
* caller built with its own account-request helper.
|
|
22
|
+
*/
|
|
23
|
+
function createAccountCall(tx, ref, params) {
|
|
24
|
+
const [accountId] = tx.moveCall({
|
|
25
|
+
target: `${ref.packageId}::account::create_account`,
|
|
26
|
+
arguments: [tx.object(ref.registry), params.senderRequest, tx.pure.string(params.alias)],
|
|
27
|
+
});
|
|
28
|
+
return accountId;
|
|
29
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared transport base for the two product-line clients (`PerpClient`,
|
|
3
|
+
* `PredictClient`).
|
|
4
|
+
*
|
|
5
|
+
* Holds the half that is identical across both lines: the gRPC client
|
|
6
|
+
* construction (network + URL resolution), the read-only gRPC convenience
|
|
7
|
+
* wrappers, `simulate` / `signAndExecuteTransaction`, and the `packageIds()`
|
|
8
|
+
* lookup. The config-schema half (per-line typed lookups like `getMarket` /
|
|
9
|
+
* `marketRegistry`) legitimately differs and lives on each subclass.
|
|
10
|
+
*
|
|
11
|
+
* `Cfg` is the line's parsed `waterx-config` JSON type. Only the fields needed
|
|
12
|
+
* here are constrained ({@link BaseLineConfig}); each subclass narrows `Cfg` to
|
|
13
|
+
* its full config type so `this.config` stays precisely typed.
|
|
14
|
+
*/
|
|
15
|
+
import type { SuiClientTypes } from "@mysten/sui/client";
|
|
16
|
+
import type { Signer } from "@mysten/sui/cryptography";
|
|
17
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
18
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
19
|
+
import type { Network } from "./constants.ts";
|
|
20
|
+
/** Default Sui gRPC base URLs by network (public Mysten fullnodes). */
|
|
21
|
+
export declare const DEFAULT_GRPC_URLS: Record<Network, string>;
|
|
22
|
+
/** Minimal shape of a line config that {@link BaseLineClient} reads directly. */
|
|
23
|
+
export interface BaseLineConfig {
|
|
24
|
+
/** Sui gRPC base URL override (default: public Mysten fullnode for the network). */
|
|
25
|
+
grpcUrl?: string;
|
|
26
|
+
/** Package map — iterated by {@link BaseLineClient.packageIds}. */
|
|
27
|
+
packages: object;
|
|
28
|
+
}
|
|
29
|
+
export declare abstract class BaseLineClient<Cfg extends BaseLineConfig = BaseLineConfig> {
|
|
30
|
+
/** gRPC client — all RPC including `simulateTransaction`. */
|
|
31
|
+
grpcClient: SuiGrpcClient;
|
|
32
|
+
/** Network identifier in upper case (`MAINNET` / `TESTNET`). */
|
|
33
|
+
network: Network;
|
|
34
|
+
/** Parsed canonical `waterx-config` JSON for this line. */
|
|
35
|
+
config: Cfg;
|
|
36
|
+
protected constructor(network: Network, config: Cfg, opts?: {
|
|
37
|
+
grpcUrl?: string;
|
|
38
|
+
});
|
|
39
|
+
getObject(objectId: string): Promise<SuiClientTypes.GetObjectResponse<{}>>;
|
|
40
|
+
getObjects(objectIds: string[]): Promise<SuiClientTypes.GetObjectsResponse<{}>>;
|
|
41
|
+
listOwnedObjects(owner: string): Promise<SuiClientTypes.ListOwnedObjectsResponse<{}>>;
|
|
42
|
+
listCoins(params: {
|
|
43
|
+
owner: string;
|
|
44
|
+
coinType?: string;
|
|
45
|
+
}): Promise<SuiClientTypes.ListCoinsResponse>;
|
|
46
|
+
getBalance(params: {
|
|
47
|
+
owner: string;
|
|
48
|
+
coinType?: string;
|
|
49
|
+
}): Promise<SuiClientTypes.GetBalanceResponse>;
|
|
50
|
+
listDynamicFields(parentId: string): ReturnType<SuiGrpcClient["listDynamicFields"]>;
|
|
51
|
+
getDynamicField(parentId: string, name: {
|
|
52
|
+
type: string;
|
|
53
|
+
bcs: Uint8Array;
|
|
54
|
+
}): Promise<SuiClientTypes.GetDynamicFieldResponse>;
|
|
55
|
+
waitForTransaction(digest: string): Promise<SuiClientTypes.TransactionResult<{}>>;
|
|
56
|
+
/**
|
|
57
|
+
* Simulate a transaction (no signing). Subclasses may override to add
|
|
58
|
+
* transport policy (e.g. the prediction line wraps this with rate-limit
|
|
59
|
+
* retry against the public testnet RPC).
|
|
60
|
+
*/
|
|
61
|
+
simulate(tx: Transaction): Promise<SuiClientTypes.SimulateTransactionResult<{
|
|
62
|
+
commandResults: true;
|
|
63
|
+
}>>;
|
|
64
|
+
signAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = object>(params: {
|
|
65
|
+
signer: {
|
|
66
|
+
toSuiAddress: () => string;
|
|
67
|
+
} & Signer;
|
|
68
|
+
transaction: Transaction | Uint8Array;
|
|
69
|
+
additionalSignatures?: string[];
|
|
70
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
71
|
+
}): Promise<SuiClientTypes.TransactionResult<Include & SuiClientTypes.TransactionInclude>>;
|
|
72
|
+
/** All package IDs (`published_at`) keyed by package name. */
|
|
73
|
+
packageIds(): Record<string, string>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared transport base for the two product-line clients (`PerpClient`,
|
|
4
|
+
* `PredictClient`).
|
|
5
|
+
*
|
|
6
|
+
* Holds the half that is identical across both lines: the gRPC client
|
|
7
|
+
* construction (network + URL resolution), the read-only gRPC convenience
|
|
8
|
+
* wrappers, `simulate` / `signAndExecuteTransaction`, and the `packageIds()`
|
|
9
|
+
* lookup. The config-schema half (per-line typed lookups like `getMarket` /
|
|
10
|
+
* `marketRegistry`) legitimately differs and lives on each subclass.
|
|
11
|
+
*
|
|
12
|
+
* `Cfg` is the line's parsed `waterx-config` JSON type. Only the fields needed
|
|
13
|
+
* here are constrained ({@link BaseLineConfig}); each subclass narrows `Cfg` to
|
|
14
|
+
* its full config type so `this.config` stays precisely typed.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BaseLineClient = exports.DEFAULT_GRPC_URLS = void 0;
|
|
18
|
+
const grpc_1 = require("@mysten/sui/grpc");
|
|
19
|
+
/** Default Sui gRPC base URLs by network (public Mysten fullnodes). */
|
|
20
|
+
exports.DEFAULT_GRPC_URLS = {
|
|
21
|
+
MAINNET: "https://fullnode.mainnet.sui.io:443",
|
|
22
|
+
TESTNET: "https://fullnode.testnet.sui.io:443",
|
|
23
|
+
};
|
|
24
|
+
function isPublishedPackage(value) {
|
|
25
|
+
return (!!value &&
|
|
26
|
+
typeof value === "object" &&
|
|
27
|
+
"published_at" in value &&
|
|
28
|
+
typeof value.published_at === "string" &&
|
|
29
|
+
value.published_at.length > 0);
|
|
30
|
+
}
|
|
31
|
+
class BaseLineClient {
|
|
32
|
+
/** gRPC client — all RPC including `simulateTransaction`. */
|
|
33
|
+
grpcClient;
|
|
34
|
+
/** Network identifier in upper case (`MAINNET` / `TESTNET`). */
|
|
35
|
+
network;
|
|
36
|
+
/** Parsed canonical `waterx-config` JSON for this line. */
|
|
37
|
+
config;
|
|
38
|
+
constructor(network, config, opts = {}) {
|
|
39
|
+
this.network = network;
|
|
40
|
+
this.config = config;
|
|
41
|
+
const grpcUrl = opts.grpcUrl ?? config.grpcUrl ?? exports.DEFAULT_GRPC_URLS[network];
|
|
42
|
+
this.grpcClient = new grpc_1.SuiGrpcClient({
|
|
43
|
+
baseUrl: grpcUrl,
|
|
44
|
+
network: network.toLowerCase(),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// ========================================================
|
|
48
|
+
// gRPC convenience wrappers
|
|
49
|
+
// ========================================================
|
|
50
|
+
getObject(objectId) {
|
|
51
|
+
return this.grpcClient.getObject({ objectId });
|
|
52
|
+
}
|
|
53
|
+
getObjects(objectIds) {
|
|
54
|
+
return this.grpcClient.getObjects({ objectIds });
|
|
55
|
+
}
|
|
56
|
+
listOwnedObjects(owner) {
|
|
57
|
+
return this.grpcClient.listOwnedObjects({ owner });
|
|
58
|
+
}
|
|
59
|
+
listCoins(params) {
|
|
60
|
+
return this.grpcClient.listCoins(params);
|
|
61
|
+
}
|
|
62
|
+
getBalance(params) {
|
|
63
|
+
return this.grpcClient.getBalance(params);
|
|
64
|
+
}
|
|
65
|
+
listDynamicFields(parentId) {
|
|
66
|
+
return this.grpcClient.listDynamicFields({ parentId });
|
|
67
|
+
}
|
|
68
|
+
getDynamicField(parentId, name) {
|
|
69
|
+
return this.grpcClient.getDynamicField({ parentId, name });
|
|
70
|
+
}
|
|
71
|
+
waitForTransaction(digest) {
|
|
72
|
+
return this.grpcClient.waitForTransaction({ digest });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Simulate a transaction (no signing). Subclasses may override to add
|
|
76
|
+
* transport policy (e.g. the prediction line wraps this with rate-limit
|
|
77
|
+
* retry against the public testnet RPC).
|
|
78
|
+
*/
|
|
79
|
+
async simulate(tx) {
|
|
80
|
+
return this.grpcClient.simulateTransaction({
|
|
81
|
+
transaction: tx,
|
|
82
|
+
include: { commandResults: true },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async signAndExecuteTransaction(params) {
|
|
86
|
+
return this.grpcClient.signAndExecuteTransaction(params);
|
|
87
|
+
}
|
|
88
|
+
// ========================================================
|
|
89
|
+
// Shared config lookup
|
|
90
|
+
// ========================================================
|
|
91
|
+
/** All package IDs (`published_at`) keyed by package name. */
|
|
92
|
+
packageIds() {
|
|
93
|
+
const out = {};
|
|
94
|
+
for (const [name, pkg] of Object.entries(this.config.packages)) {
|
|
95
|
+
if (isPublishedPackage(pkg))
|
|
96
|
+
out[name] = pkg.published_at;
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.BaseLineClient = BaseLineClient;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Network = "MAINNET" | "TESTNET";
|
|
2
|
+
/** Basis-point denominator (10_000). Matches BP_SCALE in the Move contracts. */
|
|
3
|
+
export declare const BPS_SCALE = 10000n;
|
|
4
|
+
/** Float scaling factor (1e9). All `Float` values from `bucket_v2_framework` are 1e9-scaled. */
|
|
5
|
+
export declare const FLOAT_SCALE = 1000000000n;
|
|
6
|
+
/** Double scaling factor (1e18). Used for high-precision intermediate values (e.g. u256 fields). */
|
|
7
|
+
export declare const DOUBLE_SCALE = 1000000000000000000n;
|
|
8
|
+
/** SUI coin decimals (gas + staking rewards). */
|
|
9
|
+
export declare const SUI_DECIMALS = 9;
|
|
10
|
+
/** WLP LP-token decimals. */
|
|
11
|
+
export declare const WLP_DECIMALS = 6;
|
|
12
|
+
/** Shared decimals for trading collateral / WLP backing assets (USDC, USDSUI). */
|
|
13
|
+
export declare const COLLATERAL_DECIMALS = 6;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Import the individual `SUI_DECIMALS` / `WLP_DECIMALS` /
|
|
16
|
+
* `COLLATERAL_DECIMALS` constants instead. Kept as a back-compat shim so
|
|
17
|
+
* downstream code that still does `import { TOKEN_DECIMALS }` keeps working;
|
|
18
|
+
* removed in a future major.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TOKEN_DECIMALS: {
|
|
21
|
+
readonly SUI: 9;
|
|
22
|
+
readonly USDC: 6;
|
|
23
|
+
readonly USDSUI: 6;
|
|
24
|
+
readonly WLP: 6;
|
|
25
|
+
};
|
|
26
|
+
export declare const MS_PER_YEAR: number;
|
|
27
|
+
/**
|
|
28
|
+
* Zero-address placeholder used as the sender in dry-run / simulate calls.
|
|
29
|
+
* Line-agnostic (every read path simulates with it); re-exported from
|
|
30
|
+
* `perp/constants.ts` for back-compat.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DRY_RUN_SENDER = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Shared, line-agnostic primitives (network id, scaling, decimals, time).
|
|
3
|
+
// Perp-domain enums (permissions / order tags / action codes / fee rates) live
|
|
4
|
+
// in `perp/constants.ts`; prediction has its own `prediction/constants.ts`.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DRY_RUN_SENDER = exports.MS_PER_YEAR = exports.TOKEN_DECIMALS = exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.DOUBLE_SCALE = exports.FLOAT_SCALE = exports.BPS_SCALE = void 0;
|
|
7
|
+
// ======== Scaling ========
|
|
8
|
+
/** Basis-point denominator (10_000). Matches BP_SCALE in the Move contracts. */
|
|
9
|
+
exports.BPS_SCALE = 10000n;
|
|
10
|
+
/** Float scaling factor (1e9). All `Float` values from `bucket_v2_framework` are 1e9-scaled. */
|
|
11
|
+
exports.FLOAT_SCALE = 1000000000n;
|
|
12
|
+
/** Double scaling factor (1e18). Used for high-precision intermediate values (e.g. u256 fields). */
|
|
13
|
+
exports.DOUBLE_SCALE = 1000000000000000000n;
|
|
14
|
+
// ======== Token decimals ========
|
|
15
|
+
/** SUI coin decimals (gas + staking rewards). */
|
|
16
|
+
exports.SUI_DECIMALS = 9;
|
|
17
|
+
/** WLP LP-token decimals. */
|
|
18
|
+
exports.WLP_DECIMALS = 6;
|
|
19
|
+
/** Shared decimals for trading collateral / WLP backing assets (USDC, USDSUI). */
|
|
20
|
+
exports.COLLATERAL_DECIMALS = 6;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Import the individual `SUI_DECIMALS` / `WLP_DECIMALS` /
|
|
23
|
+
* `COLLATERAL_DECIMALS` constants instead. Kept as a back-compat shim so
|
|
24
|
+
* downstream code that still does `import { TOKEN_DECIMALS }` keeps working;
|
|
25
|
+
* removed in a future major.
|
|
26
|
+
*/
|
|
27
|
+
exports.TOKEN_DECIMALS = {
|
|
28
|
+
SUI: exports.SUI_DECIMALS,
|
|
29
|
+
USDC: exports.COLLATERAL_DECIMALS,
|
|
30
|
+
USDSUI: exports.COLLATERAL_DECIMALS,
|
|
31
|
+
WLP: exports.WLP_DECIMALS,
|
|
32
|
+
};
|
|
33
|
+
// ======== Time ========
|
|
34
|
+
exports.MS_PER_YEAR = 365 * 24 * 60 * 60 * 1000;
|
|
35
|
+
// ======== Well-known addresses ========
|
|
36
|
+
/**
|
|
37
|
+
* Zero-address placeholder used as the sender in dry-run / simulate calls.
|
|
38
|
+
* Line-agnostic (every read path simulates with it); re-exported from
|
|
39
|
+
* `perp/constants.ts` for back-compat.
|
|
40
|
+
*/
|
|
41
|
+
exports.DRY_RUN_SENDER = "0x0000000000000000000000000000000000000000000000000000000000000000";
|