@waterx/sdk 2.4.0 → 3.0.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 +25 -21
- package/dist/src/{utils → account}/account-request.d.ts +2 -2
- package/dist/src/{user → account}/account.d.ts +23 -21
- package/dist/src/{user → account}/account.js +5 -5
- package/dist/src/account/client.d.ts +42 -0
- package/dist/src/account/client.js +17 -0
- package/dist/src/account/config.d.ts +151 -0
- package/dist/src/account/config.js +8 -0
- package/dist/src/account/constants.d.ts +5 -0
- package/dist/src/account/constants.js +5 -0
- package/dist/src/account/fetch/referral.d.ts +15 -0
- package/dist/src/account/fetch/referral.js +51 -0
- package/dist/src/account/fetch/simulate.d.ts +34 -0
- package/dist/src/account/fetch/simulate.js +43 -0
- package/dist/src/{utils/consolidate-balance.d.ts → account/funding/balance.d.ts} +3 -8
- package/dist/src/{utils/consolidate-balance.js → account/funding/balance.js} +6 -1
- package/dist/src/account/funding/consolidate.d.ts +46 -0
- package/dist/src/account/funding/consolidate.js +137 -0
- package/dist/src/{user → account/funding}/credit.d.ts +10 -10
- package/dist/src/{user → account/funding}/credit.js +6 -6
- package/dist/src/{user → account/funding}/custody.d.ts +4 -4
- package/dist/src/{user → account/funding}/custody.js +2 -2
- package/dist/src/{utils → account/funding}/wormhole.d.ts +4 -4
- package/dist/src/{utils → account/funding}/wormhole.js +1 -1
- package/dist/src/account/index.d.ts +29 -0
- package/dist/src/account/index.js +29 -0
- package/dist/src/{user → account}/referral.d.ts +3 -3
- package/dist/src/{user → account}/referral.js +1 -1
- package/dist/src/base-client.d.ts +74 -0
- package/dist/src/base-client.js +97 -0
- package/dist/src/constants.d.ts +4 -42
- package/dist/src/constants.js +8 -47
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +0 -26
- package/dist/src/generated/bucket_v2_framework/liability.js +0 -28
- package/dist/src/generated/waterx_account/account.d.ts +50 -15
- package/dist/src/generated/waterx_account/account.js +51 -15
- package/dist/src/generated/waterx_oracle/oracle.d.ts +7 -1
- package/dist/src/generated/waterx_oracle/oracle.js +7 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.d.ts +19 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.d.ts +3 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/sui/balance.d.ts +3 -1
- package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.d.ts +6 -1
- package/dist/src/generated/waterx_prediction/events.d.ts +288 -0
- package/dist/src/{prediction/generated → generated}/waterx_prediction/events.js +39 -0
- package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.d.ts +6 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/order.d.ts +34 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/position.d.ts +16 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/view.d.ts +69 -4
- package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.d.ts +162 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.js +99 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +102 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +99 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +5 -5
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +1 -2
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +23 -23
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +3 -6
- package/dist/src/oracle/aggregate.d.ts +74 -0
- package/dist/src/oracle/aggregate.js +112 -0
- package/dist/src/oracle/config.d.ts +99 -0
- package/dist/src/oracle/config.js +23 -0
- package/dist/src/oracle/host.d.ts +32 -0
- package/dist/src/oracle/host.js +10 -0
- package/dist/src/oracle/index.d.ts +16 -0
- package/dist/src/oracle/index.js +18 -0
- package/dist/src/oracle/pyth.d.ts +52 -0
- package/dist/src/oracle/pyth.js +220 -0
- package/dist/src/oracle/rules/constant-rule.d.ts +9 -0
- package/dist/src/oracle/rules/constant-rule.js +14 -0
- package/dist/src/oracle/rules/pyth-rule.d.ts +11 -0
- package/dist/src/oracle/rules/pyth-rule.js +20 -0
- package/dist/src/oracle/rules/sponsor.d.ts +28 -0
- package/dist/src/oracle/rules/sponsor.js +48 -0
- package/dist/src/oracle/rules/supra-rule.d.ts +11 -0
- package/dist/src/oracle/rules/supra-rule.js +22 -0
- package/dist/src/perp/client.d.ts +78 -0
- package/dist/src/perp/client.js +108 -0
- package/dist/src/{client.d.ts → perp/config-view.d.ts} +15 -60
- package/dist/src/{client.js → perp/config-view.js} +23 -95
- package/dist/src/perp/config.d.ts +126 -0
- package/dist/src/{config.js → perp/config.js} +11 -12
- package/dist/src/perp/constants.d.ts +49 -0
- package/dist/src/perp/constants.js +61 -0
- package/dist/src/perp/fetch/account.d.ts +43 -0
- package/dist/src/perp/fetch/account.js +64 -0
- package/dist/src/perp/fetch/bridge.d.ts +90 -0
- package/dist/src/perp/fetch/bridge.js +127 -0
- package/dist/src/perp/fetch/custody.d.ts +32 -0
- package/dist/src/perp/fetch/custody.js +62 -0
- package/dist/src/perp/fetch/market.d.ts +30 -0
- package/dist/src/perp/fetch/market.js +68 -0
- package/dist/src/perp/fetch/positions.d.ts +70 -0
- package/dist/src/perp/fetch/positions.js +185 -0
- package/dist/src/perp/fetch/simulate.d.ts +12 -0
- package/dist/src/perp/fetch/simulate.js +13 -0
- package/dist/src/perp/fetch.d.ts +23 -0
- package/dist/src/perp/fetch.js +23 -0
- package/dist/src/{index.d.ts → perp/index.d.ts} +22 -22
- package/dist/src/{index.js → perp/index.js} +22 -22
- package/dist/src/perp/tx-builders/common.d.ts +83 -0
- package/dist/src/perp/tx-builders/common.js +70 -0
- package/dist/src/perp/tx-builders/credit.d.ts +65 -0
- package/dist/src/perp/tx-builders/credit.js +62 -0
- package/dist/src/perp/tx-builders/rewards.d.ts +30 -0
- package/dist/src/perp/tx-builders/rewards.js +34 -0
- package/dist/src/perp/tx-builders/trading.d.ts +51 -0
- package/dist/src/perp/tx-builders/trading.js +59 -0
- package/dist/src/perp/tx-builders/wlp.d.ts +90 -0
- package/dist/src/perp/tx-builders/wlp.js +120 -0
- package/dist/src/perp/tx-builders.d.ts +23 -0
- package/dist/src/perp/tx-builders.js +23 -0
- package/dist/src/perp/user/index.d.ts +8 -0
- package/dist/src/perp/user/index.js +8 -0
- package/dist/src/{user → perp/user}/order.d.ts +7 -7
- package/dist/src/{user → perp/user}/order.js +3 -3
- package/dist/src/{user → perp/user}/staking.d.ts +4 -4
- package/dist/src/{user → perp/user}/staking.js +2 -2
- package/dist/src/{user → perp/user}/trading.d.ts +13 -13
- package/dist/src/{user → perp/user}/trading.js +2 -2
- package/dist/src/{user → perp/user}/wlp.d.ts +7 -7
- package/dist/src/{user → perp/user}/wlp.js +3 -3
- package/dist/src/prediction/account.js +40 -76
- package/dist/src/prediction/client.d.ts +8 -38
- package/dist/src/prediction/client.js +11 -67
- package/dist/src/prediction/config.d.ts +16 -2
- package/dist/src/prediction/config.js +10 -4
- package/dist/src/prediction/index.d.ts +11 -11
- package/dist/src/prediction/index.js +10 -10
- package/dist/src/prediction/prediction.d.ts +45 -0
- package/dist/src/prediction/prediction.js +71 -0
- package/dist/src/prediction/tx-builders.d.ts +4 -4
- package/dist/src/prediction/tx-builders.js +2 -2
- package/dist/src/prediction/user/index.d.ts +2 -2
- package/dist/src/prediction/user/index.js +1 -1
- package/dist/src/prediction/user/position.d.ts +2 -2
- package/dist/src/prediction/user/position.js +1 -1
- package/dist/src/prediction/utils/bcs.d.ts +5 -0
- package/dist/src/prediction/utils/bcs.js +5 -0
- package/dist/src/prediction/utils/index.d.ts +7 -0
- package/dist/src/prediction/utils/index.js +7 -0
- package/dist/src/sdk.d.ts +10 -6
- package/dist/src/sdk.js +9 -5
- package/dist/src/unified-client.d.ts +140 -145
- package/dist/src/unified-client.js +98 -40
- package/dist/src/utils/config.d.ts +1 -1
- package/package.json +22 -5
- package/dist/src/config.d.ts +0 -292
- package/dist/src/fetch.d.ts +0 -254
- package/dist/src/fetch.js +0 -564
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +0 -100
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +0 -129
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +0 -6
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +0 -19
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +0 -10
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +0 -27
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +0 -382
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +0 -466
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +0 -362
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +0 -440
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +0 -193
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +0 -205
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +0 -384
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +0 -382
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +0 -344
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +0 -338
- package/dist/src/prediction/generated/utils/index.d.ts +0 -30
- package/dist/src/prediction/generated/utils/index.js +0 -160
- package/dist/src/prediction/generated/waterx_account/account.d.ts +0 -1589
- package/dist/src/prediction/generated/waterx_account/account.js +0 -1758
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +0 -7
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +0 -13
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +0 -7
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +0 -16
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +0 -6
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +0 -19
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +0 -10
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +0 -14
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +0 -12
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +0 -19
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +0 -27
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +0 -16
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +0 -19
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +0 -75
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +0 -78
- package/dist/src/prediction/generated/waterx_account/events.d.ts +0 -33
- package/dist/src/prediction/generated/waterx_account/events.js +0 -137
- package/dist/src/prediction/generated/waterx_account/version.js +0 -8
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +0 -60
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +0 -83
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +0 -14
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +0 -24
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +0 -31
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +0 -16
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +0 -19
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +0 -22
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +0 -10
- package/dist/src/tx-builders.d.ts +0 -296
- package/dist/src/tx-builders.js +0 -461
- package/dist/src/user/index.d.ts +0 -8
- package/dist/src/user/index.js +0 -8
- package/dist/src/utils/pyth.d.ts +0 -124
- package/dist/src/utils/pyth.js +0 -392
- /package/dist/src/{utils → account}/account-request.js +0 -0
- /package/dist/src/{core → account}/waterx-account.d.ts +0 -0
- /package/dist/src/{core → account}/waterx-account.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.js +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/balance.js +0 -0
- /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.js +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.d.ts +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/order.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/position.js +0 -0
- /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/version.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/version.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/view.js +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
3
|
**************************************************************/
|
|
4
4
|
import { MoveStruct, type RawTransactionArgument } from '../utils/index.ts';
|
|
5
|
-
import { type Transaction } from '@mysten/sui/transactions';
|
|
5
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
6
6
|
export declare const WithdrawQueue: MoveStruct<{
|
|
7
7
|
dummy_field: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
8
8
|
}, "@waterx/withdrawal-queue::withdrawal_queue::WithdrawQueue">;
|
|
@@ -163,15 +163,15 @@ export interface PackageVersionOptions {
|
|
|
163
163
|
export declare function packageVersion(options?: PackageVersionOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
164
164
|
export interface RouteWormholeArguments {
|
|
165
165
|
evmDestinationChain: RawTransactionArgument<number>;
|
|
166
|
-
evmRecipient: RawTransactionArgument<number
|
|
167
|
-
evmToken: RawTransactionArgument<number
|
|
166
|
+
evmRecipient: RawTransactionArgument<Array<number>>;
|
|
167
|
+
evmToken: RawTransactionArgument<Array<number>>;
|
|
168
168
|
}
|
|
169
169
|
export interface RouteWormholeOptions {
|
|
170
170
|
package?: string;
|
|
171
171
|
arguments: RouteWormholeArguments | [
|
|
172
172
|
evmDestinationChain: RawTransactionArgument<number>,
|
|
173
|
-
evmRecipient: RawTransactionArgument<number
|
|
174
|
-
evmToken: RawTransactionArgument<number
|
|
173
|
+
evmRecipient: RawTransactionArgument<Array<number>>,
|
|
174
|
+
evmToken: RawTransactionArgument<Array<number>>
|
|
175
175
|
];
|
|
176
176
|
}
|
|
177
177
|
/** User helper: encode a Wormhole-bound route as `extra_data` bytes. */
|
|
@@ -466,7 +466,7 @@ export declare function unsetChainBridgeMinFee(options: UnsetChainBridgeMinFeeOp
|
|
|
466
466
|
export interface CancelEntryArguments {
|
|
467
467
|
queue: RawTransactionArgument<string>;
|
|
468
468
|
accountRegistry: RawTransactionArgument<string>;
|
|
469
|
-
request:
|
|
469
|
+
request: TransactionArgument;
|
|
470
470
|
key: RawTransactionArgument<number | bigint>;
|
|
471
471
|
}
|
|
472
472
|
export interface CancelEntryOptions {
|
|
@@ -474,7 +474,7 @@ export interface CancelEntryOptions {
|
|
|
474
474
|
arguments: CancelEntryArguments | [
|
|
475
475
|
queue: RawTransactionArgument<string>,
|
|
476
476
|
accountRegistry: RawTransactionArgument<string>,
|
|
477
|
-
request:
|
|
477
|
+
request: TransactionArgument,
|
|
478
478
|
key: RawTransactionArgument<number | bigint>
|
|
479
479
|
];
|
|
480
480
|
typeArguments: [
|
|
@@ -505,14 +505,14 @@ export declare function cancelEntry(options: CancelEntryOptions): (tx: Transacti
|
|
|
505
505
|
export interface EnqueueArguments {
|
|
506
506
|
queue: RawTransactionArgument<string>;
|
|
507
507
|
registry: RawTransactionArgument<string>;
|
|
508
|
-
req:
|
|
508
|
+
req: TransactionArgument;
|
|
509
509
|
}
|
|
510
510
|
export interface EnqueueOptions {
|
|
511
511
|
package?: string;
|
|
512
512
|
arguments: EnqueueArguments | [
|
|
513
513
|
queue: RawTransactionArgument<string>,
|
|
514
514
|
registry: RawTransactionArgument<string>,
|
|
515
|
-
req:
|
|
515
|
+
req: TransactionArgument
|
|
516
516
|
];
|
|
517
517
|
typeArguments: [
|
|
518
518
|
string
|
|
@@ -527,7 +527,7 @@ export declare function enqueue(options: EnqueueOptions): (tx: Transaction) => i
|
|
|
527
527
|
export interface ExecuteWormholeArguments {
|
|
528
528
|
queue: RawTransactionArgument<string>;
|
|
529
529
|
key: RawTransactionArgument<number | bigint>;
|
|
530
|
-
request:
|
|
530
|
+
request: TransactionArgument;
|
|
531
531
|
bridge: RawTransactionArgument<string>;
|
|
532
532
|
creditRegistry: RawTransactionArgument<string>;
|
|
533
533
|
wormholeState: RawTransactionArgument<string>;
|
|
@@ -538,7 +538,7 @@ export interface ExecuteWormholeOptions {
|
|
|
538
538
|
arguments: ExecuteWormholeArguments | [
|
|
539
539
|
queue: RawTransactionArgument<string>,
|
|
540
540
|
key: RawTransactionArgument<number | bigint>,
|
|
541
|
-
request:
|
|
541
|
+
request: TransactionArgument,
|
|
542
542
|
bridge: RawTransactionArgument<string>,
|
|
543
543
|
creditRegistry: RawTransactionArgument<string>,
|
|
544
544
|
wormholeState: RawTransactionArgument<string>,
|
|
@@ -559,7 +559,7 @@ export declare function executeWormhole(options: ExecuteWormholeOptions): (tx: T
|
|
|
559
559
|
export interface ExecuteNativeArguments {
|
|
560
560
|
queue: RawTransactionArgument<string>;
|
|
561
561
|
key: RawTransactionArgument<number | bigint>;
|
|
562
|
-
request:
|
|
562
|
+
request: TransactionArgument;
|
|
563
563
|
vault: RawTransactionArgument<string>;
|
|
564
564
|
creditRegistry: RawTransactionArgument<string>;
|
|
565
565
|
}
|
|
@@ -568,7 +568,7 @@ export interface ExecuteNativeOptions {
|
|
|
568
568
|
arguments: ExecuteNativeArguments | [
|
|
569
569
|
queue: RawTransactionArgument<string>,
|
|
570
570
|
key: RawTransactionArgument<number | bigint>,
|
|
571
|
-
request:
|
|
571
|
+
request: TransactionArgument,
|
|
572
572
|
vault: RawTransactionArgument<string>,
|
|
573
573
|
creditRegistry: RawTransactionArgument<string>
|
|
574
574
|
];
|
|
@@ -653,12 +653,12 @@ export interface EntryOptions {
|
|
|
653
653
|
}
|
|
654
654
|
export declare function entry(options: EntryOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
655
655
|
export interface EntryAmountArguments {
|
|
656
|
-
entry:
|
|
656
|
+
entry: TransactionArgument;
|
|
657
657
|
}
|
|
658
658
|
export interface EntryAmountOptions {
|
|
659
659
|
package?: string;
|
|
660
660
|
arguments: EntryAmountArguments | [
|
|
661
|
-
entry:
|
|
661
|
+
entry: TransactionArgument
|
|
662
662
|
];
|
|
663
663
|
typeArguments: [
|
|
664
664
|
string
|
|
@@ -666,12 +666,12 @@ export interface EntryAmountOptions {
|
|
|
666
666
|
}
|
|
667
667
|
export declare function entryAmount(options: EntryAmountOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
668
668
|
export interface EntryAccountIdArguments {
|
|
669
|
-
entry:
|
|
669
|
+
entry: TransactionArgument;
|
|
670
670
|
}
|
|
671
671
|
export interface EntryAccountIdOptions {
|
|
672
672
|
package?: string;
|
|
673
673
|
arguments: EntryAccountIdArguments | [
|
|
674
|
-
entry:
|
|
674
|
+
entry: TransactionArgument
|
|
675
675
|
];
|
|
676
676
|
typeArguments: [
|
|
677
677
|
string
|
|
@@ -679,12 +679,12 @@ export interface EntryAccountIdOptions {
|
|
|
679
679
|
}
|
|
680
680
|
export declare function entryAccountId(options: EntryAccountIdOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
681
681
|
export interface EntryRecipientArguments {
|
|
682
|
-
entry:
|
|
682
|
+
entry: TransactionArgument;
|
|
683
683
|
}
|
|
684
684
|
export interface EntryRecipientOptions {
|
|
685
685
|
package?: string;
|
|
686
686
|
arguments: EntryRecipientArguments | [
|
|
687
|
-
entry:
|
|
687
|
+
entry: TransactionArgument
|
|
688
688
|
];
|
|
689
689
|
typeArguments: [
|
|
690
690
|
string
|
|
@@ -692,12 +692,12 @@ export interface EntryRecipientOptions {
|
|
|
692
692
|
}
|
|
693
693
|
export declare function entryRecipient(options: EntryRecipientOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
694
694
|
export interface EntryExtraDataArguments {
|
|
695
|
-
entry:
|
|
695
|
+
entry: TransactionArgument;
|
|
696
696
|
}
|
|
697
697
|
export interface EntryExtraDataOptions {
|
|
698
698
|
package?: string;
|
|
699
699
|
arguments: EntryExtraDataArguments | [
|
|
700
|
-
entry:
|
|
700
|
+
entry: TransactionArgument
|
|
701
701
|
];
|
|
702
702
|
typeArguments: [
|
|
703
703
|
string
|
|
@@ -705,12 +705,12 @@ export interface EntryExtraDataOptions {
|
|
|
705
705
|
}
|
|
706
706
|
export declare function entryExtraData(options: EntryExtraDataOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
707
707
|
export interface RouteTagArguments {
|
|
708
|
-
extraData: RawTransactionArgument<number
|
|
708
|
+
extraData: RawTransactionArgument<Array<number>>;
|
|
709
709
|
}
|
|
710
710
|
export interface RouteTagOptions {
|
|
711
711
|
package?: string;
|
|
712
712
|
arguments: RouteTagArguments | [
|
|
713
|
-
extraData: RawTransactionArgument<number
|
|
713
|
+
extraData: RawTransactionArgument<Array<number>>
|
|
714
714
|
];
|
|
715
715
|
}
|
|
716
716
|
/**
|
|
@@ -7,11 +7,8 @@ import * as type_name from "./deps/std/type_name.js";
|
|
|
7
7
|
import * as balance from "./deps/sui/balance.js";
|
|
8
8
|
import * as linked_table from "./deps/bucket_v2_framework/linked_table.js";
|
|
9
9
|
import * as vec_set from "./deps/sui/vec_set.js";
|
|
10
|
-
import * as vec_set_1 from "./deps/sui/vec_set.js";
|
|
11
10
|
import * as float from "./deps/bucket_v2_framework/float.js";
|
|
12
11
|
import * as vec_map from "./deps/sui/vec_map.js";
|
|
13
|
-
import * as float_1 from "./deps/bucket_v2_framework/float.js";
|
|
14
|
-
import * as vec_map_1 from "./deps/sui/vec_map.js";
|
|
15
12
|
const $moduleName = '@waterx/withdrawal-queue::withdrawal_queue';
|
|
16
13
|
export const WithdrawQueue = new MoveStruct({ name: `${$moduleName}::WithdrawQueue`, fields: {
|
|
17
14
|
dummy_field: bcs.bool()
|
|
@@ -63,21 +60,21 @@ export const Queue = new MoveStruct({ name: `${$moduleName}::Queue<phantom CREDI
|
|
|
63
60
|
* `PACKAGE_VERSION ∈ allowed_versions`; admin uses `add_version` /
|
|
64
61
|
* `remove_version` to kill-switch a deprecated package after a contract upgrade.
|
|
65
62
|
*/
|
|
66
|
-
allowed_versions:
|
|
63
|
+
allowed_versions: vec_set.VecSet(bcs.u16())
|
|
67
64
|
} });
|
|
68
65
|
export const BridgeFeeKey = new MoveStruct({ name: `${$moduleName}::BridgeFeeKey`, fields: {
|
|
69
66
|
dummy_field: bcs.bool()
|
|
70
67
|
} });
|
|
71
68
|
export const BridgeFeeConfig = new MoveStruct({ name: `${$moduleName}::BridgeFeeConfig`, fields: {
|
|
72
69
|
default_rate: float.Float,
|
|
73
|
-
chain_rates: vec_map.VecMap(bcs.u16(),
|
|
70
|
+
chain_rates: vec_map.VecMap(bcs.u16(), float.Float)
|
|
74
71
|
} });
|
|
75
72
|
export const BridgeMinFeeKey = new MoveStruct({ name: `${$moduleName}::BridgeMinFeeKey`, fields: {
|
|
76
73
|
dummy_field: bcs.bool()
|
|
77
74
|
} });
|
|
78
75
|
export const BridgeMinFeeConfig = new MoveStruct({ name: `${$moduleName}::BridgeMinFeeConfig`, fields: {
|
|
79
76
|
default_min_fee: bcs.u64(),
|
|
80
|
-
chain_min_fees:
|
|
77
|
+
chain_min_fees: vec_map.VecMap(bcs.u16(), bcs.u64())
|
|
81
78
|
} });
|
|
82
79
|
export const BridgeFeeUpdated = new MoveStruct({ name: `${$moduleName}::BridgeFeeUpdated<phantom CREDIT>`, fields: {
|
|
83
80
|
/** 1e9-scaled default fee rate now in effect. */
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle aggregation — the orchestrator that composes rules into the shared
|
|
3
|
+
* `Oracle`. This is the ONE file that knows about every rule: it builds a
|
|
4
|
+
* `PriceCollector`, feeds whichever rules a ticker is configured for
|
|
5
|
+
* (Pyth / Supra / Constant), then `aggregate`s.
|
|
6
|
+
*
|
|
7
|
+
* Per ticker:
|
|
8
|
+
* collector = oracle::new_collector(ticker)
|
|
9
|
+
* [pyth_rule::feed] when the ticker has a pyth_rule.feeds entry
|
|
10
|
+
* [supra_rule::feed] when supra is enabled + wired
|
|
11
|
+
* [constant_rule::feed] when the ticker is a constant ticker
|
|
12
|
+
* oracle::aggregate(oracle, collector)
|
|
13
|
+
*
|
|
14
|
+
* The fed rule set must match the on-chain weighted set for the ticker —
|
|
15
|
+
* `aggregator::remove_outliers` aborts `EMissingPriceSource` if a weighted rule
|
|
16
|
+
* is missing from the collector.
|
|
17
|
+
*/
|
|
18
|
+
import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
19
|
+
import type { OracleHost } from "./host.ts";
|
|
20
|
+
import { type PythCache } from "./pyth.ts";
|
|
21
|
+
/**
|
|
22
|
+
* Aggregate one ticker's price into the shared `Oracle`: build a collector, feed
|
|
23
|
+
* every rule the ticker is configured for, then `aggregate`.
|
|
24
|
+
*
|
|
25
|
+
* - **Pyth** — fed when `priceInfoObjectId` is supplied (i.e. the ticker has a
|
|
26
|
+
* `pyth_rule.feeds` entry). Caller must run the Pyth update first so the
|
|
27
|
+
* `PriceInfoObject` is fresh.
|
|
28
|
+
* - **Supra** — fed alongside Pyth when supra is enabled + wired (abstains
|
|
29
|
+
* on-chain for symbols it has no pair for).
|
|
30
|
+
* - **Constant** — fed when the ticker is a constant ticker
|
|
31
|
+
* ({@link OracleHost.isConstantTicker}).
|
|
32
|
+
*
|
|
33
|
+
* "Dual-feed" (Pyth + Constant) and "constant-only" are not special cases — they
|
|
34
|
+
* fall out of which rules the ticker is in. Throws if no rule applies.
|
|
35
|
+
*/
|
|
36
|
+
export declare function aggregateTicker(tx: Transaction, host: OracleHost, args: {
|
|
37
|
+
ticker: string;
|
|
38
|
+
priceInfoObjectId?: string;
|
|
39
|
+
}): void;
|
|
40
|
+
/**
|
|
41
|
+
* Thin wrapper over {@link aggregateTicker} for a Pyth-fed ticker. Kept for
|
|
42
|
+
* back-compat (e.g. WLP mint builds). Caller must run the Pyth update first.
|
|
43
|
+
*/
|
|
44
|
+
export declare function aggregateTickerWithPyth(tx: Transaction, host: OracleHost, args: {
|
|
45
|
+
ticker: string;
|
|
46
|
+
priceInfoObjectId: string;
|
|
47
|
+
}): void;
|
|
48
|
+
/**
|
|
49
|
+
* {@link aggregateTicker} for a **constant-only** ticker (no Pyth update needed —
|
|
50
|
+
* the price comes from the on-chain `constant_rule::Config`).
|
|
51
|
+
*
|
|
52
|
+
* Throws if the ticker ALSO has a `pyth_rule.feeds` entry (a dual-feed transition
|
|
53
|
+
* ticker): feeding only the constant leg would leave the still-weighted Pyth rule
|
|
54
|
+
* absent from the collector and abort `aggregate` with `EMissingPriceSource`. Such
|
|
55
|
+
* tickers must go through {@link aggregateTicker} with a `priceInfoObjectId` (or
|
|
56
|
+
* {@link refreshOraclePrices}), which feeds both.
|
|
57
|
+
*/
|
|
58
|
+
export declare function aggregateTickerWithConstant(tx: Transaction, host: OracleHost, args: {
|
|
59
|
+
ticker: string;
|
|
60
|
+
}): void;
|
|
61
|
+
/**
|
|
62
|
+
* Refresh multiple tickers in one PTB. For each ticker {@link aggregateTicker}
|
|
63
|
+
* feeds whichever rules it is configured for (Pyth if it has a `pyth_rule.feeds`
|
|
64
|
+
* entry, Supra when enabled, Constant when it's a constant ticker). Tickers with a
|
|
65
|
+
* Pyth feed are updated on-chain via one shared Pyth accumulator first; the rest
|
|
66
|
+
* (constant-only) skip Pyth entirely.
|
|
67
|
+
*/
|
|
68
|
+
export declare function refreshOraclePrices(tx: Transaction, host: OracleHost, tickers: string[], opts?: {
|
|
69
|
+
cache?: PythCache;
|
|
70
|
+
sponsorFund?: {
|
|
71
|
+
fund: TransactionArgument;
|
|
72
|
+
packageId: string;
|
|
73
|
+
};
|
|
74
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle aggregation — the orchestrator that composes rules into the shared
|
|
3
|
+
* `Oracle`. This is the ONE file that knows about every rule: it builds a
|
|
4
|
+
* `PriceCollector`, feeds whichever rules a ticker is configured for
|
|
5
|
+
* (Pyth / Supra / Constant), then `aggregate`s.
|
|
6
|
+
*
|
|
7
|
+
* Per ticker:
|
|
8
|
+
* collector = oracle::new_collector(ticker)
|
|
9
|
+
* [pyth_rule::feed] when the ticker has a pyth_rule.feeds entry
|
|
10
|
+
* [supra_rule::feed] when supra is enabled + wired
|
|
11
|
+
* [constant_rule::feed] when the ticker is a constant ticker
|
|
12
|
+
* oracle::aggregate(oracle, collector)
|
|
13
|
+
*
|
|
14
|
+
* The fed rule set must match the on-chain weighted set for the ticker —
|
|
15
|
+
* `aggregator::remove_outliers` aborts `EMissingPriceSource` if a weighted rule
|
|
16
|
+
* is missing from the collector.
|
|
17
|
+
*/
|
|
18
|
+
import { aggregate as aggregateCall, newCollector } from "../generated/waterx_oracle/oracle.js";
|
|
19
|
+
import { updatePythPrices } from "./pyth.js";
|
|
20
|
+
import { feedConstantRule } from "./rules/constant-rule.js";
|
|
21
|
+
import { feedPythRule } from "./rules/pyth-rule.js";
|
|
22
|
+
import { maybeFeedSupra } from "./rules/supra-rule.js";
|
|
23
|
+
/**
|
|
24
|
+
* Aggregate one ticker's price into the shared `Oracle`: build a collector, feed
|
|
25
|
+
* every rule the ticker is configured for, then `aggregate`.
|
|
26
|
+
*
|
|
27
|
+
* - **Pyth** — fed when `priceInfoObjectId` is supplied (i.e. the ticker has a
|
|
28
|
+
* `pyth_rule.feeds` entry). Caller must run the Pyth update first so the
|
|
29
|
+
* `PriceInfoObject` is fresh.
|
|
30
|
+
* - **Supra** — fed alongside Pyth when supra is enabled + wired (abstains
|
|
31
|
+
* on-chain for symbols it has no pair for).
|
|
32
|
+
* - **Constant** — fed when the ticker is a constant ticker
|
|
33
|
+
* ({@link OracleHost.isConstantTicker}).
|
|
34
|
+
*
|
|
35
|
+
* "Dual-feed" (Pyth + Constant) and "constant-only" are not special cases — they
|
|
36
|
+
* fall out of which rules the ticker is in. Throws if no rule applies.
|
|
37
|
+
*/
|
|
38
|
+
export function aggregateTicker(tx, host, args) {
|
|
39
|
+
const oraclePkg = host.config.packages.waterx_oracle.published_at;
|
|
40
|
+
const collector = newCollector({
|
|
41
|
+
package: oraclePkg,
|
|
42
|
+
arguments: { symbol: args.ticker },
|
|
43
|
+
})(tx);
|
|
44
|
+
let fed = false;
|
|
45
|
+
if (args.priceInfoObjectId) {
|
|
46
|
+
feedPythRule(tx, host, collector, args.priceInfoObjectId);
|
|
47
|
+
// Supra rides on the same collector when enabled (abstains on-chain otherwise).
|
|
48
|
+
maybeFeedSupra(tx, host, collector);
|
|
49
|
+
fed = true;
|
|
50
|
+
}
|
|
51
|
+
if (host.isConstantTicker(args.ticker)) {
|
|
52
|
+
feedConstantRule(tx, host, collector);
|
|
53
|
+
fed = true;
|
|
54
|
+
}
|
|
55
|
+
if (!fed) {
|
|
56
|
+
throw new Error(`no oracle rule configured for ticker '${args.ticker}' (no pyth feed, not a constant ticker)`);
|
|
57
|
+
}
|
|
58
|
+
aggregateCall({
|
|
59
|
+
package: oraclePkg,
|
|
60
|
+
arguments: {
|
|
61
|
+
oracle: tx.object(host.config.packages.waterx_oracle.oracle),
|
|
62
|
+
collector,
|
|
63
|
+
},
|
|
64
|
+
})(tx);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Thin wrapper over {@link aggregateTicker} for a Pyth-fed ticker. Kept for
|
|
68
|
+
* back-compat (e.g. WLP mint builds). Caller must run the Pyth update first.
|
|
69
|
+
*/
|
|
70
|
+
export function aggregateTickerWithPyth(tx, host, args) {
|
|
71
|
+
aggregateTicker(tx, host, args);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* {@link aggregateTicker} for a **constant-only** ticker (no Pyth update needed —
|
|
75
|
+
* the price comes from the on-chain `constant_rule::Config`).
|
|
76
|
+
*
|
|
77
|
+
* Throws if the ticker ALSO has a `pyth_rule.feeds` entry (a dual-feed transition
|
|
78
|
+
* ticker): feeding only the constant leg would leave the still-weighted Pyth rule
|
|
79
|
+
* absent from the collector and abort `aggregate` with `EMissingPriceSource`. Such
|
|
80
|
+
* tickers must go through {@link aggregateTicker} with a `priceInfoObjectId` (or
|
|
81
|
+
* {@link refreshOraclePrices}), which feeds both.
|
|
82
|
+
*/
|
|
83
|
+
export function aggregateTickerWithConstant(tx, host, args) {
|
|
84
|
+
if (host.config.packages.pyth_rule?.feeds?.[args.ticker] !== undefined) {
|
|
85
|
+
throw new Error(`'${args.ticker}' is in pyth_rule.feeds (dual-feed) — feed both via aggregateTicker({ priceInfoObjectId }) / refreshOraclePrices, not aggregateTickerWithConstant`);
|
|
86
|
+
}
|
|
87
|
+
aggregateTicker(tx, host, { ticker: args.ticker });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Refresh multiple tickers in one PTB. For each ticker {@link aggregateTicker}
|
|
91
|
+
* feeds whichever rules it is configured for (Pyth if it has a `pyth_rule.feeds`
|
|
92
|
+
* entry, Supra when enabled, Constant when it's a constant ticker). Tickers with a
|
|
93
|
+
* Pyth feed are updated on-chain via one shared Pyth accumulator first; the rest
|
|
94
|
+
* (constant-only) skip Pyth entirely.
|
|
95
|
+
*/
|
|
96
|
+
export async function refreshOraclePrices(tx, host, tickers, opts = {}) {
|
|
97
|
+
if (tickers.length === 0)
|
|
98
|
+
return;
|
|
99
|
+
// Every ticker with a pyth_rule.feeds entry needs the on-chain Pyth update
|
|
100
|
+
// first (one shared accumulator). Constant-only tickers (no pyth feed) skip it.
|
|
101
|
+
const pythTickers = tickers.filter((t) => host.config.packages.pyth_rule?.feeds?.[t] !== undefined);
|
|
102
|
+
const priceInfoByTicker = new Map();
|
|
103
|
+
if (pythTickers.length > 0) {
|
|
104
|
+
const entries = pythTickers.map((t) => host.getPythFeed(t));
|
|
105
|
+
await updatePythPrices(tx, host, entries.map((e) => e.feed_id), opts.cache, opts.sponsorFund);
|
|
106
|
+
pythTickers.forEach((t, i) => priceInfoByTicker.set(t, entries[i].price_info_object));
|
|
107
|
+
}
|
|
108
|
+
// Aggregate each ticker, feeding whichever rules it is configured for.
|
|
109
|
+
for (const ticker of tickers) {
|
|
110
|
+
aggregateTicker(tx, host, { ticker, priceInfoObjectId: priceInfoByTicker.get(ticker) });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle-layer config schema — the package entries + config slice the shared
|
|
3
|
+
* oracle layer (Pyth source + oracle rules + aggregate) reads. This is shared
|
|
4
|
+
* infra, **not** the perp line: `perp/config.ts` imports these and
|
|
5
|
+
* `WaterXPackages extends OraclePackages`; nothing here imports `perp/` or
|
|
6
|
+
* `prediction/`. Snake_case mirrors the canonical `waterx-config` JSON 1:1.
|
|
7
|
+
*
|
|
8
|
+
* Hoisted out of `perp/config.ts` so {@link import("./host.ts").OracleHost}
|
|
9
|
+
* depends on this shared schema instead of the perp line's full config —
|
|
10
|
+
* mirrors the earlier account-config hoist.
|
|
11
|
+
*/
|
|
12
|
+
import type { BasePackageEntry } from "../account/config.ts";
|
|
13
|
+
import type { BaseLineConfig } from "../base-client.ts";
|
|
14
|
+
import type { Network } from "../constants.ts";
|
|
15
|
+
export interface PythRulePackage extends BasePackageEntry {
|
|
16
|
+
config: string;
|
|
17
|
+
feeds: Record<string, {
|
|
18
|
+
feed_id: string;
|
|
19
|
+
price_info_object: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
export interface PythSponsorRulePackage extends BasePackageEntry {
|
|
23
|
+
pyth_sponsor: string;
|
|
24
|
+
}
|
|
25
|
+
/** Per-ticker `constant_rule` feed entry (mirrors the `pyth_rule.feeds` shape). */
|
|
26
|
+
export interface ConstantFeedEntry {
|
|
27
|
+
/**
|
|
28
|
+
* Constant 1e9-scaled price (decimal string), mirroring the on-chain
|
|
29
|
+
* `Config.prices` value (e.g. `"1000000000"` for $1). Informational off-chain —
|
|
30
|
+
* the on-chain `constant_rule::feed` reads the price from `Config`; the SDK only
|
|
31
|
+
* keys routing off the presence of the entry.
|
|
32
|
+
*/
|
|
33
|
+
price: string;
|
|
34
|
+
}
|
|
35
|
+
export interface WaterxConstantRulePackage extends BasePackageEntry {
|
|
36
|
+
/** Shared `constant_rule::Config` holding the per-ticker constant prices. */
|
|
37
|
+
config: string;
|
|
38
|
+
/**
|
|
39
|
+
* Oracle ticker → constant feed entry, mirroring `pyth_rule.feeds`. A ticker
|
|
40
|
+
* present here is fed via `constant_rule::feed` instead of (steady state) or
|
|
41
|
+
* alongside (dual-feed) `pyth_rule::feed` (e.g. `USDCUSD → { price: "1000000000" }`).
|
|
42
|
+
*/
|
|
43
|
+
feeds?: Record<string, ConstantFeedEntry>;
|
|
44
|
+
}
|
|
45
|
+
/** Per-ticker `supra_rule` feed entry (mirrors the `pyth_rule.feeds` shape). */
|
|
46
|
+
export interface SupraFeedEntry {
|
|
47
|
+
/** Supra pair id (mirrors the on-chain `Config`; informational off-chain). */
|
|
48
|
+
pair_id: number;
|
|
49
|
+
/** Optional per-ticker freshness tolerance override (ms). */
|
|
50
|
+
tolerance_ms?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SupraRulePackage extends BasePackageEntry {
|
|
53
|
+
/** Shared `supra_rule::Config` (per-symbol Supra pair_id + freshness tolerance). */
|
|
54
|
+
config: string;
|
|
55
|
+
/** Supra `OracleHolder` shared object id (network-specific). Required to feed. */
|
|
56
|
+
oracle_holder?: string;
|
|
57
|
+
/** Oracle ticker → Supra feed entry (mirrors the on-chain `Config`; informational). */
|
|
58
|
+
feeds?: Record<string, SupraFeedEntry>;
|
|
59
|
+
/**
|
|
60
|
+
* When true AND `config` + `oracle_holder` are set, `refreshOraclePrices`
|
|
61
|
+
* feeds `supra_rule` on the same `PriceCollector` as Pyth before `aggregate`
|
|
62
|
+
* (a second weighted rule). Defaults to **false** so a Pyth-only deployment
|
|
63
|
+
* is unaffected — flip on only after `weight_threshold`/feeders are ready.
|
|
64
|
+
*/
|
|
65
|
+
enabled?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface WaterxOraclePackage extends BasePackageEntry {
|
|
68
|
+
listing_cap: string;
|
|
69
|
+
oracle: string;
|
|
70
|
+
aggregators: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The package subset the shared oracle layer reads. A line config
|
|
74
|
+
* (`WaterXPackages`) **extends** this, so any line client's config is
|
|
75
|
+
* structurally an oracle config.
|
|
76
|
+
*/
|
|
77
|
+
export interface OraclePackages {
|
|
78
|
+
pyth_rule: PythRulePackage;
|
|
79
|
+
pyth_sponsor_rule?: PythSponsorRulePackage;
|
|
80
|
+
constant_rule?: WaterxConstantRulePackage;
|
|
81
|
+
supra_rule?: SupraRulePackage;
|
|
82
|
+
waterx_oracle: WaterxOraclePackage;
|
|
83
|
+
}
|
|
84
|
+
export interface PythInfraConfig {
|
|
85
|
+
state_id: string;
|
|
86
|
+
wormhole_state_id: string;
|
|
87
|
+
hermes_endpoint: string;
|
|
88
|
+
}
|
|
89
|
+
export declare const PYTH_DEFAULTS: Record<Network, PythInfraConfig>;
|
|
90
|
+
/**
|
|
91
|
+
* The narrow config shape the oracle/refresh code needs. `WaterXConfig`
|
|
92
|
+
* (the perp line's full config) is assignable to this, so `PerpClient` satisfies
|
|
93
|
+
* {@link import("./host.ts").OracleHost} without the oracle layer importing `perp/`.
|
|
94
|
+
*/
|
|
95
|
+
export interface OracleConfig extends BaseLineConfig {
|
|
96
|
+
packages: OraclePackages;
|
|
97
|
+
/** Pyth infra override (defaults from {@link PYTH_DEFAULTS}). */
|
|
98
|
+
pyth?: PythInfraConfig;
|
|
99
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle-layer config schema — the package entries + config slice the shared
|
|
3
|
+
* oracle layer (Pyth source + oracle rules + aggregate) reads. This is shared
|
|
4
|
+
* infra, **not** the perp line: `perp/config.ts` imports these and
|
|
5
|
+
* `WaterXPackages extends OraclePackages`; nothing here imports `perp/` or
|
|
6
|
+
* `prediction/`. Snake_case mirrors the canonical `waterx-config` JSON 1:1.
|
|
7
|
+
*
|
|
8
|
+
* Hoisted out of `perp/config.ts` so {@link import("./host.ts").OracleHost}
|
|
9
|
+
* depends on this shared schema instead of the perp line's full config —
|
|
10
|
+
* mirrors the earlier account-config hoist.
|
|
11
|
+
*/
|
|
12
|
+
export const PYTH_DEFAULTS = {
|
|
13
|
+
MAINNET: {
|
|
14
|
+
state_id: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
15
|
+
wormhole_state_id: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
|
|
16
|
+
hermes_endpoint: "https://hermes.pyth.network",
|
|
17
|
+
},
|
|
18
|
+
TESTNET: {
|
|
19
|
+
state_id: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c",
|
|
20
|
+
wormhole_state_id: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
|
|
21
|
+
hermes_endpoint: "https://hermes-beta.pyth.network",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `OracleHost` — the narrow slice of a line client the oracle module reads.
|
|
3
|
+
*
|
|
4
|
+
* The oracle/refresh code used to take a concrete `PerpClient`, which fused the
|
|
5
|
+
* shared oracle layer to the perp line. It only ever needs config-schema
|
|
6
|
+
* lookups, the Pyth infra block, and a gRPC client — so it depends on this
|
|
7
|
+
* structural interface instead. `PerpClient` satisfies it without any `implements`
|
|
8
|
+
* clause, and a future `PredictClient` (or a test double) can too.
|
|
9
|
+
*/
|
|
10
|
+
import type { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
11
|
+
import type { OracleConfig, PythInfraConfig } from "./config.ts";
|
|
12
|
+
export interface OracleHost {
|
|
13
|
+
/** Oracle slice of the canonical `waterx-config` JSON (rule packages + per-ticker feeds). */
|
|
14
|
+
readonly config: OracleConfig;
|
|
15
|
+
/** External Pyth/Wormhole/Hermes infra (network default, overridable via config). */
|
|
16
|
+
readonly pyth: PythInfraConfig;
|
|
17
|
+
/** gRPC client for the on-chain reads the Pyth update path needs. */
|
|
18
|
+
readonly grpcClient: SuiGrpcClient;
|
|
19
|
+
/** True when `ticker` is priced by `constant_rule`. */
|
|
20
|
+
isConstantTicker(ticker: string): boolean;
|
|
21
|
+
/** The `supra_rule` config when deployed, enabled, and fully wired; else `undefined`. */
|
|
22
|
+
getSupraRule(): {
|
|
23
|
+
published_at: string;
|
|
24
|
+
config: string;
|
|
25
|
+
oracle_holder: string;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/** The `pyth_rule.feeds` entry for `ticker` (`{ feed_id, price_info_object }`); throws if absent. */
|
|
28
|
+
getPythFeed(ticker: string): {
|
|
29
|
+
feed_id: string;
|
|
30
|
+
price_info_object: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `OracleHost` — the narrow slice of a line client the oracle module reads.
|
|
3
|
+
*
|
|
4
|
+
* The oracle/refresh code used to take a concrete `PerpClient`, which fused the
|
|
5
|
+
* shared oracle layer to the perp line. It only ever needs config-schema
|
|
6
|
+
* lookups, the Pyth infra block, and a gRPC client — so it depends on this
|
|
7
|
+
* structural interface instead. `PerpClient` satisfies it without any `implements`
|
|
8
|
+
* clause, and a future `PredictClient` (or a test double) can too.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle module — the single source of truth for price freshness.
|
|
3
|
+
*
|
|
4
|
+
* Layering (no cross-imports between siblings except via `aggregate.ts`):
|
|
5
|
+
* - `host.ts` — `OracleHost`, the narrow client slice this module reads.
|
|
6
|
+
* - `pyth.ts` — Pyth as a price source: Hermes REST + on-chain update PTB.
|
|
7
|
+
* - `rules/*` — one file per oracle rule (pyth / supra / constant / sponsor).
|
|
8
|
+
* - `aggregate.ts`— the orchestrator that feeds rules into a collector + aggregates.
|
|
9
|
+
*
|
|
10
|
+
* `pyth.ts` deliberately imports NO rule package — Pyth-the-source and the
|
|
11
|
+
* rules that consume it are separate concerns.
|
|
12
|
+
*/
|
|
13
|
+
export type { OracleHost } from "./host.ts";
|
|
14
|
+
export { PythCache, fetchPriceFeedsUpdateData, buildPythPriceUpdateCalls, updatePythPrices, } from "./pyth.ts";
|
|
15
|
+
export { aggregateTicker, aggregateTickerWithPyth, aggregateTickerWithConstant, refreshOraclePrices, } from "./aggregate.ts";
|
|
16
|
+
export { openPythSponsorFund, reimbursePythSponsor } from "./rules/sponsor.ts";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oracle module — the single source of truth for price freshness.
|
|
3
|
+
*
|
|
4
|
+
* Layering (no cross-imports between siblings except via `aggregate.ts`):
|
|
5
|
+
* - `host.ts` — `OracleHost`, the narrow client slice this module reads.
|
|
6
|
+
* - `pyth.ts` — Pyth as a price source: Hermes REST + on-chain update PTB.
|
|
7
|
+
* - `rules/*` — one file per oracle rule (pyth / supra / constant / sponsor).
|
|
8
|
+
* - `aggregate.ts`— the orchestrator that feeds rules into a collector + aggregates.
|
|
9
|
+
*
|
|
10
|
+
* `pyth.ts` deliberately imports NO rule package — Pyth-the-source and the
|
|
11
|
+
* rules that consume it are separate concerns.
|
|
12
|
+
*/
|
|
13
|
+
// Pyth source
|
|
14
|
+
export { PythCache, fetchPriceFeedsUpdateData, buildPythPriceUpdateCalls, updatePythPrices, } from "./pyth.js";
|
|
15
|
+
// Aggregation orchestrator
|
|
16
|
+
export { aggregateTicker, aggregateTickerWithPyth, aggregateTickerWithConstant, refreshOraclePrices, } from "./aggregate.js";
|
|
17
|
+
// Sponsor rule (fund open / reimburse + witness attach)
|
|
18
|
+
export { openPythSponsorFund, reimbursePythSponsor } from "./rules/sponsor.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pyth as a price *source*: Hermes REST + the on-chain Pyth update PTB.
|
|
3
|
+
*
|
|
4
|
+
* This file knows nothing about oracle *rules* (pyth_rule / supra_rule /
|
|
5
|
+
* constant_rule / sponsor) — it only fetches price update VAAs from Hermes and
|
|
6
|
+
* appends the Pyth on-chain update block, returning the refreshed
|
|
7
|
+
* `PriceInfoObject` IDs. Feeding rules into a collector and aggregating lives in
|
|
8
|
+
* `aggregate.ts`; the rule wrappers live in `rules/`.
|
|
9
|
+
*
|
|
10
|
+
* On-chain a single PTB:
|
|
11
|
+
* 1. wormhole::vaa::parse_and_verify
|
|
12
|
+
* 2. pyth::create_authenticated_price_infos_using_accumulator
|
|
13
|
+
* 3. pyth::update_single_price_feed (one per feed)
|
|
14
|
+
* 4. hot_potato_vector::destroy
|
|
15
|
+
*/
|
|
16
|
+
import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
17
|
+
import type { OracleHost } from "./host.ts";
|
|
18
|
+
type PriceTableInfo = {
|
|
19
|
+
id: string;
|
|
20
|
+
fieldType: string;
|
|
21
|
+
};
|
|
22
|
+
type PythStateInfo = {
|
|
23
|
+
packageId: string;
|
|
24
|
+
baseUpdateFee: bigint;
|
|
25
|
+
};
|
|
26
|
+
export declare class PythCache {
|
|
27
|
+
pythStateInfo?: PythStateInfo;
|
|
28
|
+
wormholePackageId?: string;
|
|
29
|
+
priceTableInfo?: PriceTableInfo;
|
|
30
|
+
priceFeedObjectIdCache: Map<string, string | undefined>;
|
|
31
|
+
}
|
|
32
|
+
export declare function fetchPriceFeedsUpdateData(endpoint: string, priceIds: string[]): Promise<Uint8Array[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Append the on-chain Pyth update PTB block. Returns `PriceInfoObject` IDs
|
|
35
|
+
* (one per `feedIds`, same order). After this you can feed `pyth_rule` per
|
|
36
|
+
* ticker against the matching `PriceInfoObject` (see `rules/pyth-rule.ts`).
|
|
37
|
+
*
|
|
38
|
+
* If `sponsorFund` is provided, the per-feed update fee comes from the
|
|
39
|
+
* sponsor pool (`pyth_sponsor_rule::split`) instead of `tx.gas`. Opening and
|
|
40
|
+
* reimbursing that fund is the sponsor rule's job (`rules/sponsor.ts`); here we
|
|
41
|
+
* only draw a fee coin from the already-open `fund` hot potato.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildPythPriceUpdateCalls(tx: Transaction, host: OracleHost, updates: Uint8Array[], feedIds: string[], cache?: PythCache, sponsorFund?: {
|
|
44
|
+
fund: TransactionArgument;
|
|
45
|
+
packageId: string;
|
|
46
|
+
}): Promise<string[]>;
|
|
47
|
+
/** All-in-one: fetch from Hermes, append update calls. Returns PriceInfoObject IDs. */
|
|
48
|
+
export declare function updatePythPrices(tx: Transaction, host: OracleHost, feedIds: string[], cache?: PythCache, sponsorFund?: {
|
|
49
|
+
fund: TransactionArgument;
|
|
50
|
+
packageId: string;
|
|
51
|
+
}): Promise<string[]>;
|
|
52
|
+
export {};
|