@waterx/sdk 2.1.0 → 2.3.1-dev.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/README.md +75 -169
- package/dist/src/client.d.ts +52 -2
- package/dist/src/client.js +76 -6
- package/dist/src/config.d.ts +57 -3
- package/dist/src/config.js +10 -4
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/constants.js +6 -0
- package/dist/src/core/waterx-account.d.ts +31 -0
- package/dist/src/core/waterx-account.js +26 -0
- package/dist/src/fetch.d.ts +110 -0
- package/dist/src/fetch.js +149 -4
- package/dist/src/generated/bucket_v2_framework/account.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/double.d.ts +77 -77
- package/dist/src/generated/bucket_v2_framework/float.d.ts +73 -73
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +33 -33
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/linked_table.js +2 -2
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +57 -57
- package/dist/src/generated/bucket_v2_framework/sheet.js +5 -11
- package/dist/src/generated/native_custody/custody_vault.d.ts +46 -32
- package/dist/src/generated/native_custody/custody_vault.js +19 -10
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/native_custody/events.js +1 -2
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +7 -7
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +1 -2
- package/dist/src/generated/utils/index.d.ts +7 -7
- package/dist/src/generated/utils/index.js +9 -6
- package/dist/src/generated/waterx_account/account.d.ts +124 -71
- package/dist/src/generated/waterx_account/account.js +64 -29
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_account/direct_rule.d.ts +5 -5
- package/dist/src/generated/waterx_account/events.d.ts +10 -0
- package/dist/src/generated/waterx_account/events.js +31 -50
- package/dist/src/generated/waterx_constant_rule/constant_rule.d.ts +68 -0
- package/dist/src/generated/waterx_constant_rule/constant_rule.js +59 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_credit/credit_registry.d.ts +9 -9
- package/dist/src/generated/waterx_credit/credit_registry.js +1 -2
- package/dist/src/generated/waterx_credit/limited_supply.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/aggregator.js +1 -2
- package/dist/src/generated/waterx_oracle/collector.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/collector.js +1 -1
- package/dist/src/generated/waterx_oracle/oracle.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.js +1 -2
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_perp/events.d.ts +181 -181
- package/dist/src/generated/waterx_perp/events.js +87 -173
- package/dist/src/generated/waterx_perp/global_config.d.ts +3 -3
- package/dist/src/generated/waterx_perp/global_config.js +6 -12
- package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +9 -9
- package/dist/src/generated/waterx_perp/keyed_big_vector.js +1 -2
- package/dist/src/generated/waterx_perp/lp_pool.d.ts +115 -115
- package/dist/src/generated/waterx_perp/lp_pool.js +11 -22
- package/dist/src/generated/waterx_perp/market_config.d.ts +61 -43
- package/dist/src/generated/waterx_perp/market_config.js +29 -22
- package/dist/src/generated/waterx_perp/math.d.ts +7 -7
- package/dist/src/generated/waterx_perp/order_book.d.ts +47 -47
- package/dist/src/generated/waterx_perp/position.d.ts +99 -99
- package/dist/src/generated/waterx_perp/position.js +6 -12
- package/dist/src/generated/waterx_perp/request.d.ts +67 -67
- package/dist/src/generated/waterx_perp/request.js +2 -3
- package/dist/src/generated/waterx_perp/response.d.ts +35 -35
- package/dist/src/generated/waterx_perp/response.js +1 -2
- package/dist/src/generated/waterx_perp/trading.d.ts +303 -179
- package/dist/src/generated/waterx_perp/trading.js +99 -14
- package/dist/src/generated/waterx_perp_view/view.js +5 -10
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +5 -5
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +1 -2
- package/dist/src/generated/waterx_referral/referral_table.d.ts +5 -5
- package/dist/src/generated/waterx_referral/referral_table.js +1 -2
- package/dist/src/generated/waterx_staking/waterx_staking.d.ts +19 -19
- package/dist/src/generated/waterx_staking/waterx_staking.js +10 -20
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +158 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +148 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +444 -4
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +417 -4
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +214 -74
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +158 -29
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.js +3 -2
- package/dist/src/prediction/account.d.ts +96 -0
- package/dist/src/prediction/account.js +230 -0
- package/dist/src/prediction/admin.d.ts +47 -0
- package/dist/src/prediction/admin.js +105 -0
- package/dist/src/prediction/bcs.d.ts +22 -0
- package/dist/src/prediction/bcs.js +240 -0
- package/dist/src/prediction/client.d.ts +75 -0
- package/dist/src/prediction/client.js +164 -0
- package/dist/src/prediction/config.d.ts +60 -0
- package/dist/src/prediction/config.js +75 -0
- package/dist/src/prediction/constants.d.ts +44 -0
- package/dist/src/prediction/constants.js +46 -0
- package/dist/src/prediction/fetch.d.ts +82 -0
- package/dist/src/prediction/fetch.js +270 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +100 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +362 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +193 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +344 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +338 -0
- package/dist/src/prediction/generated/utils/index.d.ts +30 -0
- package/dist/src/prediction/generated/utils/index.js +160 -0
- package/dist/src/prediction/generated/waterx_account/account.d.ts +1589 -0
- package/dist/src/prediction/generated/waterx_account/account.js +1758 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +12 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +75 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +78 -0
- package/dist/src/prediction/generated/waterx_account/events.d.ts +33 -0
- package/dist/src/prediction/generated/waterx_account/events.js +137 -0
- package/dist/src/prediction/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.d.ts +327 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.js +405 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.d.ts +5 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.js +9 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +60 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +83 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +22 -0
- package/dist/src/prediction/generated/waterx_prediction/events.js +179 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.d.ts +116 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.js +141 -0
- package/dist/src/prediction/generated/waterx_prediction/order.d.ts +200 -0
- package/dist/src/prediction/generated/waterx_prediction/order.js +284 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.d.ts +58 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.js +73 -0
- package/dist/src/prediction/generated/waterx_prediction/position.d.ts +160 -0
- package/dist/src/prediction/generated/waterx_prediction/position.js +214 -0
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/view.d.ts +353 -0
- package/dist/src/prediction/generated/waterx_prediction/view.js +432 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.d.ts +1698 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.js +1733 -0
- package/dist/src/prediction/gift-link.d.ts +6 -0
- package/dist/src/prediction/gift-link.js +5 -0
- package/dist/src/prediction/gift.d.ts +223 -0
- package/dist/src/prediction/gift.js +451 -0
- package/dist/src/prediction/index.d.ts +29 -0
- package/dist/src/prediction/index.js +21 -0
- package/dist/src/prediction/prediction.d.ts +104 -0
- package/dist/src/prediction/prediction.js +317 -0
- package/dist/src/prediction/tx-builders.d.ts +44 -0
- package/dist/src/prediction/tx-builders.js +52 -0
- package/dist/src/prediction/types.d.ts +93 -0
- package/dist/src/prediction/types.js +1 -0
- package/dist/src/prediction/user/account.d.ts +2 -0
- package/dist/src/prediction/user/account.js +1 -0
- package/dist/src/prediction/user/admin.d.ts +6 -0
- package/dist/src/prediction/user/admin.js +3 -0
- package/dist/src/prediction/user/gift.d.ts +2 -0
- package/dist/src/prediction/user/gift.js +1 -0
- package/dist/src/prediction/user/index.d.ts +5 -0
- package/dist/src/prediction/user/index.js +3 -0
- package/dist/src/prediction/user/keeper.d.ts +2 -0
- package/dist/src/prediction/user/keeper.js +1 -0
- package/dist/src/prediction/user/order.d.ts +2 -0
- package/dist/src/prediction/user/order.js +1 -0
- package/dist/src/prediction/user/position.d.ts +2 -0
- package/dist/src/prediction/user/position.js +1 -0
- package/dist/src/prediction/utils/bcs.d.ts +1 -0
- package/dist/src/prediction/utils/bcs.js +1 -0
- package/dist/src/prediction/utils/index.d.ts +1 -0
- package/dist/src/prediction/utils/index.js +1 -0
- package/dist/src/prediction/utils.d.ts +30 -0
- package/dist/src/prediction/utils.js +177 -0
- package/dist/src/sdk.d.ts +18 -0
- package/dist/src/sdk.js +17 -0
- package/dist/src/tx-builders.d.ts +54 -0
- package/dist/src/tx-builders.js +141 -0
- package/dist/src/unified-client.d.ts +407 -0
- package/dist/src/unified-client.js +123 -0
- package/dist/src/user/account.d.ts +27 -0
- package/dist/src/user/account.js +34 -8
- package/dist/src/user/credit.d.ts +8 -14
- package/dist/src/user/credit.js +9 -23
- package/dist/src/user/custody.d.ts +4 -18
- package/dist/src/user/custody.js +14 -25
- package/dist/src/utils/consolidate-balance.d.ts +37 -0
- package/dist/src/utils/consolidate-balance.js +89 -0
- package/dist/src/utils/math.d.ts +86 -0
- package/dist/src/utils/math.js +100 -0
- package/dist/src/utils/pyth.d.ts +35 -3
- package/dist/src/utils/pyth.js +145 -14
- package/package.json +129 -34
package/dist/src/utils/pyth.js
CHANGED
|
@@ -19,8 +19,10 @@ import { bcs } from "@mysten/sui/bcs";
|
|
|
19
19
|
// the market's `request_checklist` contains `PythSponsorRule`.
|
|
20
20
|
// ============================================================================
|
|
21
21
|
import { reimburse as sponsorReimburse, request as sponsorRequest, } from "../generated/pyth_sponsor_rule/pyth_sponsor_rule.js";
|
|
22
|
+
import { feed as constantRuleFeed } from "../generated/waterx_constant_rule/constant_rule.js";
|
|
22
23
|
import { aggregate as aggregateCall, newCollector } from "../generated/waterx_oracle/oracle.js";
|
|
23
24
|
import { feed as pythRuleFeed } from "../generated/waterx_pyth_rule/pyth_rule.js";
|
|
25
|
+
import { feed as supraRuleFeed } from "../generated/waterx_supra_rule/supra_rule.js";
|
|
24
26
|
export class PythCache {
|
|
25
27
|
pythStateInfo;
|
|
26
28
|
wormholePackageId;
|
|
@@ -246,6 +248,11 @@ export function aggregateTickerWithPyth(tx, client, args) {
|
|
|
246
248
|
pythPriceInfo: tx.object(args.priceInfoObjectId),
|
|
247
249
|
},
|
|
248
250
|
})(tx);
|
|
251
|
+
// Second weighted rule: when supra_rule is deployed + enabled, feed it on the
|
|
252
|
+
// SAME collector before aggregate. Supra reads the symbol from the collector
|
|
253
|
+
// and abstains on-chain if it has no pair id for it, so this is safe to add
|
|
254
|
+
// unconditionally for every Pyth ticker once enabled.
|
|
255
|
+
maybeFeedSupra(tx, client, collector);
|
|
249
256
|
aggregateCall({
|
|
250
257
|
package: client.config.packages.waterx_oracle.published_at,
|
|
251
258
|
arguments: {
|
|
@@ -255,25 +262,149 @@ export function aggregateTickerWithPyth(tx, client, args) {
|
|
|
255
262
|
})(tx);
|
|
256
263
|
}
|
|
257
264
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
265
|
+
* Append a `supra_rule::feed` on `collector` when the deployment has supra
|
|
266
|
+
* enabled + wired (see {@link WaterXClient.getSupraRule}). No-op otherwise, so
|
|
267
|
+
* Pyth-only deployments are unchanged.
|
|
268
|
+
*/
|
|
269
|
+
function maybeFeedSupra(tx, client, collector) {
|
|
270
|
+
const supra = client.getSupraRule();
|
|
271
|
+
if (!supra)
|
|
272
|
+
return;
|
|
273
|
+
supraRuleFeed({
|
|
274
|
+
package: supra.published_at,
|
|
275
|
+
arguments: {
|
|
276
|
+
collector,
|
|
277
|
+
config: tx.object(supra.config),
|
|
278
|
+
oracleHolder: tx.object(supra.oracle_holder),
|
|
279
|
+
},
|
|
280
|
+
})(tx);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* For a constant-priced ticker (e.g. `USDCUSD → $1`), build the
|
|
284
|
+
* collector → constant_rule::feed → aggregate chain. No Pyth update is
|
|
285
|
+
* needed — the price comes from the on-chain `constant_rule::Config`.
|
|
286
|
+
*/
|
|
287
|
+
export function aggregateTickerWithConstant(tx, client, args) {
|
|
288
|
+
const constant = client.config.packages.waterx_constant_rule;
|
|
289
|
+
if (!constant?.published_at || !constant.config) {
|
|
290
|
+
throw new Error(`waterx_constant_rule.{published_at,config} missing — cannot feed constant ticker '${args.ticker}'`);
|
|
291
|
+
}
|
|
292
|
+
const collector = newCollector({
|
|
293
|
+
package: client.config.packages.waterx_oracle.published_at,
|
|
294
|
+
arguments: { symbol: args.ticker },
|
|
295
|
+
})(tx);
|
|
296
|
+
constantRuleFeed({
|
|
297
|
+
package: constant.published_at,
|
|
298
|
+
arguments: {
|
|
299
|
+
collector: collector,
|
|
300
|
+
config: tx.object(constant.config),
|
|
301
|
+
},
|
|
302
|
+
})(tx);
|
|
303
|
+
aggregateCall({
|
|
304
|
+
package: client.config.packages.waterx_oracle.published_at,
|
|
305
|
+
arguments: {
|
|
306
|
+
oracle: tx.object(client.config.packages.waterx_oracle.oracle),
|
|
307
|
+
collector: collector,
|
|
308
|
+
},
|
|
309
|
+
})(tx);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* For a dual-feed ticker mid-migration (e.g. `USDCUSD`), build one collector
|
|
313
|
+
* fed by *both* `pyth_rule::feed` (+ `supra_rule::feed` when enabled) *and*
|
|
314
|
+
* `constant_rule::feed`, then `aggregate`. Used while the aggregator carries the
|
|
315
|
+
* `{Pyth, Constant}` weight set so neither weighted rule is missing from the
|
|
316
|
+
* collector (`aggregator::remove_outliers` aborts `EMissingPriceSource`
|
|
317
|
+
* otherwise). Still needs a fresh Pyth `PriceInfoObject`, so the caller must
|
|
318
|
+
* have run the Pyth update for this ticker first.
|
|
319
|
+
*
|
|
320
|
+
* Stays correct once weights are flipped to `{Constant}` only — the extra Pyth
|
|
321
|
+
* observation is dropped as a non-weighted rule — so a dual-feed ticker is safe
|
|
322
|
+
* across the whole transition; drop it from `dual_feed` (→ constant-only) once
|
|
323
|
+
* `PythRule` weight is 0.
|
|
324
|
+
*/
|
|
325
|
+
export function aggregateTickerWithDual(tx, client, args) {
|
|
326
|
+
const constant = client.config.packages.waterx_constant_rule;
|
|
327
|
+
if (!constant?.published_at || !constant.config) {
|
|
328
|
+
throw new Error(`waterx_constant_rule.{published_at,config} missing — cannot dual-feed ticker '${args.ticker}'`);
|
|
329
|
+
}
|
|
330
|
+
const collector = newCollector({
|
|
331
|
+
package: client.config.packages.waterx_oracle.published_at,
|
|
332
|
+
arguments: { symbol: args.ticker },
|
|
333
|
+
})(tx);
|
|
334
|
+
pythRuleFeed({
|
|
335
|
+
package: client.config.packages.pyth_rule.published_at,
|
|
336
|
+
arguments: {
|
|
337
|
+
collector: collector,
|
|
338
|
+
config: tx.object(client.config.packages.pyth_rule.config),
|
|
339
|
+
pythState: tx.object(client.pyth.state_id),
|
|
340
|
+
pythPriceInfo: tx.object(args.priceInfoObjectId),
|
|
341
|
+
},
|
|
342
|
+
})(tx);
|
|
343
|
+
// Second weighted rule (when enabled) on the same collector, matching the
|
|
344
|
+
// pure-Pyth path.
|
|
345
|
+
maybeFeedSupra(tx, client, collector);
|
|
346
|
+
// The constant rule — the leg that lets the aggregator carry a Constant weight.
|
|
347
|
+
constantRuleFeed({
|
|
348
|
+
package: constant.published_at,
|
|
349
|
+
arguments: {
|
|
350
|
+
collector: collector,
|
|
351
|
+
config: tx.object(constant.config),
|
|
352
|
+
},
|
|
353
|
+
})(tx);
|
|
354
|
+
aggregateCall({
|
|
355
|
+
package: client.config.packages.waterx_oracle.published_at,
|
|
356
|
+
arguments: {
|
|
357
|
+
oracle: tx.object(client.config.packages.waterx_oracle.oracle),
|
|
358
|
+
collector: collector,
|
|
359
|
+
},
|
|
360
|
+
})(tx);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Refresh multiple tickers in one PTB. Routing per ticker:
|
|
364
|
+
* - **constant-only** (see {@link WaterXClient.isConstantOnlyTicker}) — fed from
|
|
365
|
+
* `constant_rule`, skips Pyth entirely;
|
|
366
|
+
* - **dual-feed** ({@link WaterXClient.isDualFeedTicker}) — fed by both Pyth and
|
|
367
|
+
* `constant_rule` (needs the Pyth update);
|
|
368
|
+
* - **Pyth** — the rest.
|
|
369
|
+
*
|
|
370
|
+
* Pyth-priced tickers (Pyth-only + dual) are updated on-chain via Pyth first
|
|
371
|
+
* (one accumulator), then each ticker runs its collector → feed → aggregate.
|
|
261
372
|
*/
|
|
262
373
|
export async function refreshOraclePrices(tx, client, tickers, opts = {}) {
|
|
263
374
|
if (tickers.length === 0)
|
|
264
375
|
return;
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
376
|
+
// Route each ticker to its rule. Dual-feed tickers are constant *and* Pyth, so
|
|
377
|
+
// they go through the Pyth update with the Pyth-only tickers but aggregate via
|
|
378
|
+
// the dual leg; only constant-*only* tickers skip Pyth entirely.
|
|
379
|
+
const constantOnlyTickers = tickers.filter((t) => client.isConstantOnlyTicker(t));
|
|
380
|
+
const pythTickers = tickers.filter((t) => !client.isConstantTicker(t));
|
|
381
|
+
const dualTickers = tickers.filter((t) => client.isDualFeedTicker(t));
|
|
382
|
+
// Pyth update covers both Pyth-only and dual-feed tickers.
|
|
383
|
+
const pythUpdateTickers = [...pythTickers, ...dualTickers];
|
|
384
|
+
if (pythUpdateTickers.length > 0) {
|
|
385
|
+
// Oracle tickers (e.g. "BTCUSD") → each one's pyth feed entry: feed_id
|
|
386
|
+
// (off-chain) drives the accumulator; price_info_object (on-chain) is
|
|
387
|
+
// consumed by the per-ticker aggregate cycle.
|
|
388
|
+
const entries = pythUpdateTickers.map((t) => client.getPythFeed(t));
|
|
389
|
+
const feedIds = entries.map((e) => e.feed_id);
|
|
390
|
+
await updatePythPrices(tx, client, feedIds, opts.cache, opts.sponsorFund);
|
|
391
|
+
pythTickers.forEach((ticker, i) => {
|
|
392
|
+
aggregateTickerWithPyth(tx, client, {
|
|
393
|
+
ticker,
|
|
394
|
+
priceInfoObjectId: entries[i].price_info_object,
|
|
395
|
+
});
|
|
275
396
|
});
|
|
276
|
-
|
|
397
|
+
dualTickers.forEach((ticker, i) => {
|
|
398
|
+
// dual entries are appended after the pyth-only ones.
|
|
399
|
+
aggregateTickerWithDual(tx, client, {
|
|
400
|
+
ticker,
|
|
401
|
+
priceInfoObjectId: entries[pythTickers.length + i].price_info_object,
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
for (const ticker of constantOnlyTickers) {
|
|
406
|
+
aggregateTickerWithConstant(tx, client, { ticker });
|
|
407
|
+
}
|
|
277
408
|
}
|
|
278
409
|
/**
|
|
279
410
|
* Opens a `Fund` hot potato from the shared PythSponsor pool. Pass the
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waterx/sdk",
|
|
3
|
-
"version": "2.1.0",
|
|
4
|
-
"description": "WaterX
|
|
3
|
+
"version": "2.3.1-dev.0",
|
|
4
|
+
"description": "WaterX SDK — perpetuals and prediction markets on Sui",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "WaterX",
|
|
7
7
|
"repository": {
|
|
@@ -9,8 +9,51 @@
|
|
|
9
9
|
"url": "https://github.com/WaterXProtocol/waterx-sdk.git"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
|
-
"main": "dist/src/
|
|
13
|
-
"types": "dist/src/
|
|
12
|
+
"main": "dist/src/sdk.js",
|
|
13
|
+
"types": "dist/src/sdk.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/src/sdk.d.ts",
|
|
17
|
+
"import": "./dist/src/sdk.js"
|
|
18
|
+
},
|
|
19
|
+
"./perp": {
|
|
20
|
+
"types": "./dist/src/index.d.ts",
|
|
21
|
+
"import": "./dist/src/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./perp/*": {
|
|
24
|
+
"types": "./dist/src/*.d.ts",
|
|
25
|
+
"import": "./dist/src/*.js"
|
|
26
|
+
},
|
|
27
|
+
"./prediction": {
|
|
28
|
+
"types": "./dist/src/prediction/index.d.ts",
|
|
29
|
+
"import": "./dist/src/prediction/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./prediction/user": {
|
|
32
|
+
"types": "./dist/src/prediction/user/index.d.ts",
|
|
33
|
+
"import": "./dist/src/prediction/user/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./prediction/user/*": {
|
|
36
|
+
"types": "./dist/src/prediction/user/*.d.ts",
|
|
37
|
+
"import": "./dist/src/prediction/user/*.js"
|
|
38
|
+
},
|
|
39
|
+
"./prediction/utils": {
|
|
40
|
+
"types": "./dist/src/prediction/utils/index.d.ts",
|
|
41
|
+
"import": "./dist/src/prediction/utils/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./prediction/utils/*": {
|
|
44
|
+
"types": "./dist/src/prediction/utils/*.d.ts",
|
|
45
|
+
"import": "./dist/src/prediction/utils/*.js"
|
|
46
|
+
},
|
|
47
|
+
"./prediction/*": {
|
|
48
|
+
"types": "./dist/src/prediction/*.d.ts",
|
|
49
|
+
"import": "./dist/src/prediction/*.js"
|
|
50
|
+
},
|
|
51
|
+
"./generated/*": {
|
|
52
|
+
"types": "./dist/src/generated/*.d.ts",
|
|
53
|
+
"import": "./dist/src/generated/*.js"
|
|
54
|
+
},
|
|
55
|
+
"./package.json": "./package.json"
|
|
56
|
+
},
|
|
14
57
|
"files": [
|
|
15
58
|
"dist",
|
|
16
59
|
"LICENSE",
|
|
@@ -21,46 +64,98 @@
|
|
|
21
64
|
"codegen": "tsx scripts/codegen-summaries.ts && npx sui-ts-codegen generate && tsx scripts/fix-generated-imports.ts",
|
|
22
65
|
"lint": "pnpm lint:eslint && pnpm lint:prettier",
|
|
23
66
|
"lint:eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.ts\" \"examples/**/*.ts\" \"vitest.config.ts\"",
|
|
24
|
-
"lint:prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.ts\" \"examples/**/*.ts\" \"vitest.config.ts\" \"eslint.config.mjs\" \"sui-codegen.config.mjs\"",
|
|
67
|
+
"lint:prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.ts\" \"examples/**/*.ts\" \"vitest.config.ts\" \"eslint.config.mjs\" \"sui-codegen.config.mjs\" \"packages/predict-stress/**/*.{ts,mjs,json,md}\"",
|
|
25
68
|
"lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.ts\" \"examples/**/*.ts\" \"vitest.config.ts\" --fix",
|
|
26
|
-
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.ts\" \"examples/**/*.ts\" \"vitest.config.ts\" \"eslint.config.mjs\" \"sui-codegen.config.mjs\"",
|
|
69
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.ts\" \"examples/**/*.ts\" \"vitest.config.ts\" \"eslint.config.mjs\" \"sui-codegen.config.mjs\" \"packages/predict-stress/**/*.{ts,mjs,json,md}\"",
|
|
27
70
|
"env:init": "tsx scripts/init-local-env.ts",
|
|
28
71
|
"typecheck": "tsc --noEmit",
|
|
29
|
-
"
|
|
30
|
-
"test
|
|
31
|
-
"test:
|
|
32
|
-
"test:
|
|
33
|
-
"test:
|
|
34
|
-
"test:
|
|
35
|
-
"test:
|
|
72
|
+
"check": "pnpm lint && pnpm typecheck && pnpm test:unit",
|
|
73
|
+
"test": "vitest run --project unit --project predict-unit",
|
|
74
|
+
"test:unit": "vitest run --project unit --project predict-unit",
|
|
75
|
+
"test:unit:perp": "vitest run --project unit",
|
|
76
|
+
"test:unit:predict": "vitest run --project predict-unit",
|
|
77
|
+
"test:post-build": "vitest run --project post-build",
|
|
78
|
+
"test:e2e": "tsx scripts/run-e2e.ts --testnet --predict",
|
|
79
|
+
"test:e2e:perp": "tsx scripts/run-e2e.ts --testnet",
|
|
80
|
+
"test:e2e:predict": "tsx scripts/run-e2e.ts --testnet --predict-only",
|
|
81
|
+
"test:e2e:testnet": "tsx scripts/run-e2e.ts --testnet --predict",
|
|
82
|
+
"test:e2e:mainnet": "tsx scripts/run-e2e.ts --mainnet --predict",
|
|
83
|
+
"test:integration": "pnpm test:integration:perp && pnpm test:integration:predict",
|
|
84
|
+
"test:integration:perp": "tsx scripts/run-integration.ts --testnet",
|
|
85
|
+
"test:integration:predict": "vitest run --project predict-integration",
|
|
86
|
+
"test:integration:predict:keeper": "vitest run --project predict-integration-keeper",
|
|
87
|
+
"test:integration:predict:admin": "vitest run --project predict-integration-admin",
|
|
88
|
+
"test:integration:predict:all": "vitest run --project predict-integration --project predict-integration-keeper --project predict-integration-admin",
|
|
89
|
+
"test:api": "node test/prediction/scripts/run-api-tests.mjs",
|
|
90
|
+
"test:api:local": "node test/prediction/scripts/run-api-tests.mjs --env local",
|
|
91
|
+
"test:api:staging": "node test/prediction/scripts/run-api-tests.mjs --env staging",
|
|
92
|
+
"test:integration:predict:crosscheck": "E2E_API_ENV=staging E2E_API_CROSSCHECK=1 vitest run --project predict-integration-crosscheck",
|
|
93
|
+
"test:integration:predict:settlement-crosscheck": "E2E_API_ENV=staging E2E_SETTLEMENT_CROSSCHECK=1 vitest run --project predict-integration-settlement-crosscheck",
|
|
94
|
+
"test:integration:predict:headless": "E2E_API_ENV=staging E2E_HEADLESS_BET=1 vitest run --project predict-integration-headless",
|
|
95
|
+
"test:integration:predict:journey": "vitest run --project predict-integration test/prediction/integration/user-betting-journey.test.ts",
|
|
96
|
+
"test:integration:perp:mainnet": "tsx scripts/run-integration.ts --mainnet",
|
|
97
|
+
"test:integration:perp:lifecycle": "tsx scripts/run-integration.ts --testnet test/perp/integration/user/trader-position-lifecycle.test.ts",
|
|
98
|
+
"test:integration:perp:market-config": "tsx scripts/run-integration.ts --testnet test/perp/integration/user/trader-market-onchain-config.test.ts",
|
|
99
|
+
"test:integration:perp:persistent-state": "tsx scripts/run-integration.ts --testnet test/perp/integration/user/trader-e2e-persistent-state.test.ts",
|
|
100
|
+
"test:integration:perp:gap": "tsx scripts/run-integration.ts --testnet test/perp/integration/user/trader-wlp-redeem.test.ts test/perp/integration/user/trader-staking.test.ts test/perp/integration/user/trader-keeper-roundtrip.test.ts test/perp/integration/user/trader-custody.test.ts test/perp/integration/user/trader-credit-pipeline.test.ts",
|
|
101
|
+
"test:integration:perp:onboarding": "tsx scripts/run-integration.ts --testnet test/perp/integration/user/trader-full-onboarding.test.ts",
|
|
36
102
|
"smoke:chain": "tsx scripts/run-smoke-chain.ts",
|
|
37
|
-
"smoke:chain:dry": "tsx scripts/run-smoke-chain.ts --dry-run"
|
|
103
|
+
"smoke:chain:dry": "tsx scripts/run-smoke-chain.ts --dry-run",
|
|
104
|
+
"seed:testnet": "tsx test/prediction/scripts/seed-testnet.ts",
|
|
105
|
+
"predict:list-accounts": "tsx test/prediction/scripts/list-accounts.ts",
|
|
106
|
+
"predict:bootstrap-stress-accounts": "tsx test/prediction/scripts/bootstrap-stress-accounts.ts",
|
|
107
|
+
"predict:bootstrap-stress-deposits": "tsx test/prediction/scripts/bootstrap-stress-deposits.ts",
|
|
108
|
+
"mint:api-jwt": "node test/prediction/scripts/mint-api-jwt.mjs",
|
|
109
|
+
"mint:api-jwt:staging": "node test/prediction/scripts/fetch-staging-api-jwt.mjs",
|
|
110
|
+
"diagnose:bets-api": "tsx test/prediction/scripts/diagnose-bets-chain-api.ts",
|
|
111
|
+
"predict:scan-claimable": "E2E_API_ENV=staging tsx test/prediction/scripts/scan-claimable-crosscheck.ts",
|
|
112
|
+
"predict:place-all-markets": "E2E_API_ENV=staging tsx test/prediction/scripts/place-all-catalog-markets.ts",
|
|
113
|
+
"predict:place-dry-run": "E2E_API_ENV=staging E2E_PLACE_ALL_DRY_RUN=1 tsx test/prediction/scripts/place-all-catalog-markets.ts",
|
|
114
|
+
"predict:place-broker-only": "E2E_API_ENV=staging E2E_PLACE_ALL_BROKER_ONLY=1 E2E_PLACE_ALL_ONE_SIDE=1 E2E_PLACE_ALL_LIMIT=1 tsx test/prediction/scripts/place-all-catalog-markets.ts",
|
|
115
|
+
"predict:place-and-watch": "E2E_API_ENV=staging E2E_STAGING_BET_USD=1.12 E2E_PLACE_ALL_PLACE_ONLY=1 E2E_PLACE_ALL_ONE_SIDE=1 E2E_PLACE_ALL_LIMIT=1 tsx test/prediction/scripts/place-all-catalog-markets.ts",
|
|
116
|
+
"predict:place-stress": "E2E_API_ENV=staging tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
117
|
+
"predict:place-stress-dry-run": "E2E_API_ENV=staging E2E_STRESS_DRY_RUN=1 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
118
|
+
"predict:place-stress-smoke": "E2E_API_ENV=staging E2E_STRESS_PHASES=1 E2E_STRESS_PLACE_ONLY=1 E2E_STRESS_COOLDOWN_MS=0 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
119
|
+
"predict:place-stress-smoke-fill": "E2E_API_ENV=staging E2E_STRESS_PHASES=1 E2E_STRESS_COOLDOWN_MS=0 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
120
|
+
"predict:place-stress-ramp": "E2E_API_ENV=staging tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
121
|
+
"predict:place-stress-timing": "E2E_API_ENV=staging E2E_STRESS_PHASES=1,2,4,8 E2E_STRESS_COOLDOWN_MS=30000 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
122
|
+
"predict:place-stress-timing-max": "E2E_API_ENV=staging E2E_STRESS_PHASES=8 E2E_STRESS_COOLDOWN_MS=0 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
123
|
+
"predict:place-stress-hammer": "E2E_API_ENV=staging E2E_STRESS_HAMMER=1 E2E_STRESS_PLACE_ONLY=1 E2E_STRESS_COOLDOWN_MS=0 E2E_STRESS_ROUNDS=10 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
124
|
+
"predict:place-stress-hammer-smoke": "E2E_API_ENV=staging E2E_STRESS_HAMMER=1 E2E_STRESS_PLACE_ONLY=1 E2E_STRESS_COOLDOWN_MS=0 E2E_STRESS_ROUNDS=1 tsx test/prediction/scripts/place-stress-multi-wallet.ts",
|
|
125
|
+
"predict-stress": "pnpm --dir packages/predict-stress",
|
|
126
|
+
"predict:refund-probe": "E2E_API_ENV=staging tsx test/prediction/scripts/probe-catalog-refund.ts",
|
|
127
|
+
"predict:broker-matrix": "E2E_API_ENV=staging tsx test/prediction/scripts/probe-broker-matrix.ts",
|
|
128
|
+
"test:integration:predict:refund": "E2E_API_ENV=staging E2E_CATALOG_REFUND=1 vitest run --project predict-integration-refund",
|
|
129
|
+
"test:integration:predict:broker-matrix": "E2E_API_ENV=staging E2E_BROKER_MATRIX=1 vitest run --project predict-integration-broker-matrix"
|
|
130
|
+
},
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"@noble/hashes": "^2.2.0"
|
|
38
133
|
},
|
|
39
134
|
"peerDependencies": {
|
|
40
135
|
"@mysten/bcs": "^1.9.0",
|
|
41
136
|
"@mysten/sui": "^2.9.0"
|
|
42
137
|
},
|
|
43
138
|
"devDependencies": {
|
|
44
|
-
"@eslint/js": "
|
|
45
|
-
"@ianvs/prettier-plugin-sort-imports": "
|
|
46
|
-
"@mysten/bcs": "
|
|
47
|
-
"@mysten/
|
|
48
|
-
"@mysten/
|
|
49
|
-
"@types/node": "
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "
|
|
51
|
-
"@typescript-eslint/parser": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"prettier": "
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"vitest": "
|
|
139
|
+
"@eslint/js": "10.0.1",
|
|
140
|
+
"@ianvs/prettier-plugin-sort-imports": "4.7.1",
|
|
141
|
+
"@mysten/bcs": "1.9.2",
|
|
142
|
+
"@mysten/codegen": "0.10.6",
|
|
143
|
+
"@mysten/sui": "2.17.0",
|
|
144
|
+
"@types/node": "25.9.1",
|
|
145
|
+
"@typescript-eslint/eslint-plugin": "8.60.0",
|
|
146
|
+
"@typescript-eslint/parser": "8.60.0",
|
|
147
|
+
"@vitest/coverage-v8": "4.1.8",
|
|
148
|
+
"dotenv": "17.4.2",
|
|
149
|
+
"eslint": "10.4.1",
|
|
150
|
+
"eslint-config-prettier": "10.1.8",
|
|
151
|
+
"globals": "17.6.0",
|
|
152
|
+
"prettier": "3.8.3",
|
|
153
|
+
"tsc-alias": "1.8.17",
|
|
154
|
+
"tsconfig-paths": "4.2.0",
|
|
155
|
+
"tsx": "4.22.4",
|
|
156
|
+
"typescript": "6.0.3",
|
|
157
|
+
"typescript-eslint": "8.60.0",
|
|
158
|
+
"vitest": "4.1.8"
|
|
64
159
|
},
|
|
65
160
|
"packageManager": "pnpm@9.15.0"
|
|
66
161
|
}
|