@waterx/sdk 4.3.3 → 5.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/.claude/skills/waterx-sdk-integration/SKILL.md +41 -35
- package/README.md +81 -77
- package/dist/cjs/src/account/config.d.ts +3 -5
- package/dist/cjs/src/account/funding/wormhole.d.ts +1 -2
- package/dist/cjs/src/account/funding/wormhole.js +1 -2
- package/dist/cjs/src/oracle/aggregate.d.ts +45 -61
- package/dist/cjs/src/oracle/aggregate.js +138 -138
- package/dist/cjs/src/oracle/config.d.ts +35 -49
- package/dist/cjs/src/oracle/config.js +1 -1
- package/dist/cjs/src/oracle/host.d.ts +14 -19
- package/dist/cjs/src/oracle/host.js +3 -3
- package/dist/cjs/src/oracle/index.d.ts +25 -16
- package/dist/cjs/src/oracle/index.js +79 -66
- package/dist/cjs/src/oracle/price-update-rule.d.ts +104 -66
- package/dist/cjs/src/oracle/price-update-rule.js +24 -16
- package/dist/cjs/src/oracle/pyth-pro-history.d.ts +36 -0
- package/dist/cjs/src/oracle/pyth-pro-history.js +41 -0
- package/dist/cjs/src/oracle/read-plane.d.ts +35 -53
- package/dist/cjs/src/oracle/read-plane.js +26 -48
- package/dist/cjs/src/oracle/read-prices.d.ts +105 -0
- package/dist/cjs/src/oracle/read-prices.js +162 -0
- package/dist/cjs/src/oracle/rule-registry.d.ts +12 -12
- package/dist/cjs/src/oracle/rule-registry.js +12 -14
- package/dist/cjs/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
- package/dist/cjs/src/oracle/rules/pyth-lazer-rule.js +40 -20
- package/dist/cjs/src/oracle/rules/waterx-rule.d.ts +137 -12
- package/dist/cjs/src/oracle/rules/waterx-rule.js +318 -55
- package/dist/cjs/src/oracle/schedule.d.ts +109 -0
- package/dist/cjs/src/oracle/schedule.js +991 -0
- package/dist/cjs/src/oracle/source-list.d.ts +31 -27
- package/dist/cjs/src/oracle/source-list.js +43 -45
- package/dist/cjs/src/oracle/symbol-catalog.d.ts +54 -0
- package/dist/cjs/src/oracle/symbol-catalog.js +69 -0
- package/dist/cjs/src/oracle/update-fetch.d.ts +11 -15
- package/dist/cjs/src/oracle/update-fetch.js +12 -19
- package/dist/cjs/src/oracle/validate.d.ts +105 -0
- package/dist/cjs/src/oracle/validate.js +185 -0
- package/dist/cjs/src/oracle/weight-coverage.d.ts +79 -0
- package/dist/cjs/src/oracle/weight-coverage.js +173 -0
- package/dist/cjs/src/perp/client.d.ts +35 -52
- package/dist/cjs/src/perp/client.js +44 -17
- package/dist/cjs/src/perp/config-view.d.ts +5 -14
- package/dist/cjs/src/perp/config-view.js +5 -16
- package/dist/cjs/src/perp/config.d.ts +3 -3
- package/dist/cjs/src/perp/config.js +11 -13
- package/dist/cjs/src/perp/index.d.ts +4 -6
- package/dist/cjs/src/perp/index.js +35 -18
- package/dist/cjs/src/perp/tx-builders/common.d.ts +86 -48
- package/dist/cjs/src/perp/tx-builders/common.js +115 -47
- package/dist/cjs/src/perp/tx-builders/wlp.d.ts +3 -14
- package/dist/cjs/src/perp/tx-builders/wlp.js +6 -35
- package/dist/cjs/src/perp/tx-builders.d.ts +6 -5
- package/dist/cjs/src/perp/tx-builders.js +16 -10
- package/dist/cjs/src/unified-client.d.ts +8 -34
- package/dist/cjs/src/unified-client.js +3 -4
- package/dist/cjs/src/utils/config.d.ts +0 -8
- package/dist/cjs/src/utils/config.js +5 -13
- package/dist/src/account/config.d.ts +3 -5
- package/dist/src/account/funding/wormhole.d.ts +1 -2
- package/dist/src/account/funding/wormhole.js +1 -2
- package/dist/src/oracle/aggregate.d.ts +45 -61
- package/dist/src/oracle/aggregate.js +138 -137
- package/dist/src/oracle/config.d.ts +35 -49
- package/dist/src/oracle/config.js +1 -1
- package/dist/src/oracle/host.d.ts +14 -19
- package/dist/src/oracle/host.js +3 -3
- package/dist/src/oracle/index.d.ts +25 -16
- package/dist/src/oracle/index.js +55 -50
- package/dist/src/oracle/price-update-rule.d.ts +104 -66
- package/dist/src/oracle/price-update-rule.js +23 -16
- package/dist/src/oracle/pyth-pro-history.d.ts +36 -0
- package/dist/src/oracle/pyth-pro-history.js +38 -0
- package/dist/src/oracle/read-plane.d.ts +35 -53
- package/dist/src/oracle/read-plane.js +25 -47
- package/dist/src/oracle/read-prices.d.ts +105 -0
- package/dist/src/oracle/read-prices.js +156 -0
- package/dist/src/oracle/rule-registry.d.ts +12 -12
- package/dist/src/oracle/rule-registry.js +12 -14
- package/dist/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
- package/dist/src/oracle/rules/pyth-lazer-rule.js +39 -20
- package/dist/src/oracle/rules/waterx-rule.d.ts +137 -12
- package/dist/src/oracle/rules/waterx-rule.js +314 -56
- package/dist/src/oracle/schedule.d.ts +109 -0
- package/dist/src/oracle/schedule.js +985 -0
- package/dist/src/oracle/source-list.d.ts +31 -27
- package/dist/src/oracle/source-list.js +42 -43
- package/dist/src/oracle/symbol-catalog.d.ts +54 -0
- package/dist/src/oracle/symbol-catalog.js +65 -0
- package/dist/src/oracle/update-fetch.d.ts +11 -15
- package/dist/src/oracle/update-fetch.js +12 -18
- package/dist/src/oracle/validate.d.ts +105 -0
- package/dist/src/oracle/validate.js +177 -0
- package/dist/src/oracle/weight-coverage.d.ts +79 -0
- package/dist/src/oracle/weight-coverage.js +166 -0
- package/dist/src/perp/client.d.ts +35 -52
- package/dist/src/perp/client.js +45 -18
- package/dist/src/perp/config-view.d.ts +5 -14
- package/dist/src/perp/config-view.js +5 -16
- package/dist/src/perp/config.d.ts +3 -3
- package/dist/src/perp/config.js +11 -13
- package/dist/src/perp/index.d.ts +4 -6
- package/dist/src/perp/index.js +11 -5
- package/dist/src/perp/tx-builders/common.d.ts +86 -48
- package/dist/src/perp/tx-builders/common.js +114 -48
- package/dist/src/perp/tx-builders/wlp.d.ts +3 -14
- package/dist/src/perp/tx-builders/wlp.js +6 -35
- package/dist/src/perp/tx-builders.d.ts +6 -5
- package/dist/src/perp/tx-builders.js +15 -6
- package/dist/src/unified-client.d.ts +8 -34
- package/dist/src/unified-client.js +3 -4
- package/dist/src/utils/config.d.ts +0 -8
- package/dist/src/utils/config.js +5 -12
- package/package.json +1 -1
- package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
- package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -17
- package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
- package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -113
- package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
- package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -31
- package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
- package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.js +0 -214
- package/dist/cjs/src/oracle/pyth.d.ts +0 -227
- package/dist/cjs/src/oracle/pyth.js +0 -652
- package/dist/cjs/src/oracle/rules/pyth-core-rule.d.ts +0 -15
- package/dist/cjs/src/oracle/rules/pyth-core-rule.js +0 -100
- package/dist/cjs/src/oracle/rules/pyth-rule.d.ts +0 -11
- package/dist/cjs/src/oracle/rules/pyth-rule.js +0 -29
- package/dist/cjs/src/oracle/rules/sponsor.d.ts +0 -32
- package/dist/cjs/src/oracle/rules/sponsor.js +0 -56
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -14
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -73
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -27
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +0 -170
- package/dist/src/oracle/pyth.d.ts +0 -227
- package/dist/src/oracle/pyth.js +0 -638
- package/dist/src/oracle/rules/pyth-core-rule.d.ts +0 -15
- package/dist/src/oracle/rules/pyth-core-rule.js +0 -97
- package/dist/src/oracle/rules/pyth-rule.d.ts +0 -11
- package/dist/src/oracle/rules/pyth-rule.js +0 -26
- package/dist/src/oracle/rules/sponsor.d.ts +0 -32
- package/dist/src/oracle/rules/sponsor.js +0 -52
|
@@ -19,27 +19,18 @@ export declare class PerpConfigView {
|
|
|
19
19
|
getMarket(ticker: string): import("./config.ts").WaterxPerpMarketEntry;
|
|
20
20
|
/** `waterx_oracle.aggregators[ticker]`, throws if unknown. */
|
|
21
21
|
getAggregator(ticker: string): string;
|
|
22
|
-
/** `pyth_rule.feeds[ticker]`, throws if unknown. */
|
|
23
|
-
getPythFeed(ticker: string): {
|
|
24
|
-
feed_id: string;
|
|
25
|
-
price_info_object: string;
|
|
26
|
-
};
|
|
27
22
|
/**
|
|
28
23
|
* True when `ticker` is priced by `constant_rule` (a constant pin,
|
|
29
|
-
* e.g. `USDCUSD → $1`) rather than
|
|
30
|
-
* `constant_rule::feed` and need no
|
|
24
|
+
* e.g. `USDCUSD → $1`) rather than a live source. Such tickers are fed via
|
|
25
|
+
* `constant_rule::feed` and need no source update leg; see
|
|
26
|
+
* {@link refreshOraclePrices}.
|
|
31
27
|
*
|
|
32
28
|
* All-or-nothing, mirroring {@link getSupraRule} and the keeper: only routes a
|
|
33
29
|
* ticker to the constant rule when the rule is FULLY wired (`published_at` +
|
|
34
30
|
* `config` present). A half-populated block — a `feeds` entry listed before the
|
|
35
31
|
* rule is deployed, a realistic mid-rollout state — would otherwise make this
|
|
36
|
-
* true while {@link aggregateTicker} throws, aborting the whole price-refresh
|
|
37
|
-
* instead of
|
|
38
|
-
*
|
|
39
|
-
* Whether a constant ticker is *also* Pyth-fed (the dual-feed transition state)
|
|
40
|
-
* or constant-only is not a separate flag — it falls out of whether the ticker
|
|
41
|
-
* still has a `pyth_rule.feeds` entry. {@link aggregateTicker} feeds each rule the
|
|
42
|
-
* ticker is configured for, so no `isDualFeed` / `isConstantOnly` predicate is needed.
|
|
32
|
+
* true while {@link aggregateTicker} throws, aborting the whole price-refresh
|
|
33
|
+
* PTB instead of leaving the ticker to its live sources.
|
|
43
34
|
*/
|
|
44
35
|
isConstantTicker(ticker: string): boolean;
|
|
45
36
|
/**
|
|
@@ -42,29 +42,18 @@ class PerpConfigView {
|
|
|
42
42
|
throw new Error(`No aggregator listed for ticker: ${ticker}`);
|
|
43
43
|
return a;
|
|
44
44
|
}
|
|
45
|
-
/** `pyth_rule.feeds[ticker]`, throws if unknown. */
|
|
46
|
-
getPythFeed(ticker) {
|
|
47
|
-
const f = (0, record_ts_1.ownEntry)(this.config.packages.pyth_rule?.feeds, ticker);
|
|
48
|
-
if (!f)
|
|
49
|
-
throw new Error(`No pyth feed listed for ticker: ${ticker}`);
|
|
50
|
-
return f;
|
|
51
|
-
}
|
|
52
45
|
/**
|
|
53
46
|
* True when `ticker` is priced by `constant_rule` (a constant pin,
|
|
54
|
-
* e.g. `USDCUSD → $1`) rather than
|
|
55
|
-
* `constant_rule::feed` and need no
|
|
47
|
+
* e.g. `USDCUSD → $1`) rather than a live source. Such tickers are fed via
|
|
48
|
+
* `constant_rule::feed` and need no source update leg; see
|
|
49
|
+
* {@link refreshOraclePrices}.
|
|
56
50
|
*
|
|
57
51
|
* All-or-nothing, mirroring {@link getSupraRule} and the keeper: only routes a
|
|
58
52
|
* ticker to the constant rule when the rule is FULLY wired (`published_at` +
|
|
59
53
|
* `config` present). A half-populated block — a `feeds` entry listed before the
|
|
60
54
|
* rule is deployed, a realistic mid-rollout state — would otherwise make this
|
|
61
|
-
* true while {@link aggregateTicker} throws, aborting the whole price-refresh
|
|
62
|
-
* instead of
|
|
63
|
-
*
|
|
64
|
-
* Whether a constant ticker is *also* Pyth-fed (the dual-feed transition state)
|
|
65
|
-
* or constant-only is not a separate flag — it falls out of whether the ticker
|
|
66
|
-
* still has a `pyth_rule.feeds` entry. {@link aggregateTicker} feeds each rule the
|
|
67
|
-
* ticker is configured for, so no `isDualFeed` / `isConstantOnly` predicate is needed.
|
|
55
|
+
* true while {@link aggregateTicker} throws, aborting the whole price-refresh
|
|
56
|
+
* PTB instead of leaving the ticker to its live sources.
|
|
68
57
|
*/
|
|
69
58
|
isConstantTicker(ticker) {
|
|
70
59
|
const c = this.config.packages.constant_rule;
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* The schema mirrors the canonical JSON layout one-to-one (each package
|
|
6
6
|
* groups its own object IDs + per-ticker maps). External chain infra is
|
|
7
7
|
* **not** in the JSON — each oracle source owns its own per-network table
|
|
8
|
-
* (`
|
|
9
|
-
* `oracle/rules/
|
|
8
|
+
* (`LAZER_INFRA` in `oracle/rules/pyth-lazer-rule.ts`, `WATERX_INFRA` in
|
|
9
|
+
* `oracle/rules/waterx-rule.ts`); Wormhole bridge infra lives in
|
|
10
10
|
* `WORMHOLE_DEFAULTS` below.
|
|
11
11
|
*/
|
|
12
12
|
import type { AccountPackages, BasePackageEntry, WormholeInfraConfig } from "../account/config.ts";
|
|
13
13
|
import type { OraclePackages } from "../oracle/config.ts";
|
|
14
14
|
import type { Network } from "./constants.ts";
|
|
15
15
|
export type { AccountConfig, AccountPackages, BasePackageEntry, NativeCustodyAsset, NativeCustodyPackage, WaterxCreditPackage, WaterxReferralPackage, WithdrawalQueuePackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "../account/config.ts";
|
|
16
|
-
export type { ConstantFeedEntry, OracleConfig, OraclePackages, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage,
|
|
16
|
+
export type { ConstantFeedEntry, OracleConfig, OraclePackages, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, SupraFeedEntry, SupraRulePackage, WaterxConstantRulePackage, WaterxAccessConfig, WaterxOraclePackage, WaterxRulePackage, } from "../oracle/config.ts";
|
|
17
17
|
export interface WaterxPerpMarketEntry {
|
|
18
18
|
market: string;
|
|
19
19
|
config: string;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* The schema mirrors the canonical JSON layout one-to-one (each package
|
|
7
7
|
* groups its own object IDs + per-ticker maps). External chain infra is
|
|
8
8
|
* **not** in the JSON — each oracle source owns its own per-network table
|
|
9
|
-
* (`
|
|
10
|
-
* `oracle/rules/
|
|
9
|
+
* (`LAZER_INFRA` in `oracle/rules/pyth-lazer-rule.ts`, `WATERX_INFRA` in
|
|
10
|
+
* `oracle/rules/waterx-rule.ts`); Wormhole bridge infra lives in
|
|
11
11
|
* `WORMHOLE_DEFAULTS` below.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -19,14 +19,12 @@ const update_fetch_ts_1 = require("../oracle/update-fetch.js");
|
|
|
19
19
|
// Wormhole — external chain infra, defaults by network
|
|
20
20
|
// ============================================================================
|
|
21
21
|
//
|
|
22
|
-
// Oracle-source infra lives with each source (`
|
|
23
|
-
// `oracle/
|
|
24
|
-
// `client.pyth` is the caller-supplied access
|
|
25
|
-
// re-exported at the top of this file).
|
|
22
|
+
// Oracle-source infra lives with each source (`LAZER_INFRA` in
|
|
23
|
+
// `oracle/rules/pyth-lazer-rule.ts`, `WATERX_INFRA` in
|
|
24
|
+
// `oracle/rules/waterx-rule.ts`); `client.pyth` is the caller-supplied access
|
|
25
|
+
// slice only (`PythAccessConfig`, re-exported at the top of this file).
|
|
26
26
|
// `WormholeInfraConfig` is defined in `account/config.ts` (funding base) and
|
|
27
|
-
// re-exported at the top of this file.
|
|
28
|
-
// Wormhole `State` object Pyth uses (kept in sync with
|
|
29
|
-
// `PYTH_CORE_INFRA[*].wormhole_state_id`).
|
|
27
|
+
// re-exported at the top of this file.
|
|
30
28
|
exports.WORMHOLE_DEFAULTS = {
|
|
31
29
|
MAINNET: {
|
|
32
30
|
state_id: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
|
|
@@ -146,15 +144,15 @@ function validateConfig(cfg, expected, url) {
|
|
|
146
144
|
};
|
|
147
145
|
// Validate by deployment kind. A perp config must carry the perp set; a
|
|
148
146
|
// credit config the credit set. `waterx_account` is common to both.
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
147
|
+
// NO oracle-rule package is required by presence — which rules run is the
|
|
148
|
+
// client's derived fed set, never a hand-declared list (and
|
|
149
|
+
// `pyth_rule`, once required here, was retired in 5.0.0 — a config may
|
|
150
|
+
// carry or omit its block freely).
|
|
152
151
|
const isPerp = "waterx_perp" in cfg.packages;
|
|
153
152
|
const isCredit = "waterx_credit" in cfg.packages || "wormhole_bridge" in cfg.packages;
|
|
154
153
|
const required = isPerp
|
|
155
154
|
? [
|
|
156
155
|
"bucket_framework",
|
|
157
|
-
"pyth_rule",
|
|
158
156
|
"waterx_account",
|
|
159
157
|
"waterx_oracle",
|
|
160
158
|
"waterx_perp",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { PerpClient } from "./client.ts";
|
|
2
2
|
export type { CreateClientOptions } from "./client.ts";
|
|
3
3
|
export { WORMHOLE_DEFAULTS, clearConfigCache, loadConfig } from "./config.ts";
|
|
4
|
-
export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage,
|
|
4
|
+
export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, SupraFeedEntry, SupraRulePackage, TestnetFaucetPackage, WaterXConfig, WaterXPackages, WaterxCreditPackage, WaterxOraclePackage, WaterxPerpMarketEntry, WaterxPerpPackage, WaterxStakingPackage, WithdrawalQueuePackage, WlpPackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "./config.ts";
|
|
5
5
|
export { ACTION_ADD_PRE_ORDER, ACTION_CANCEL_ORDER, ACTION_CANCEL_PRE_ORDER, ACTION_CLOSE_POSITION, ACTION_DECREASE_POSITION, ACTION_DEPOSIT_COLLATERAL, ACTION_INCREASE_POSITION, ACTION_LIQUIDATE, ACTION_OPEN_POSITION, ACTION_PLACE_ORDER, ACTION_UPDATE_ORDER, ACTION_WITHDRAW_COLLATERAL, BPS_SCALE, DOUBLE_SCALE, DRY_RUN_SENDER, FLOAT_SCALE, ORDER_LIMIT_BUY, ORDER_LIMIT_SELL, ORDER_STOP_BUY, ORDER_STOP_SELL, ORDER_TAG_WILDCARD, PERM_ALL, PERM_ALL_TRADING, PERM_CANCEL_ORDER, PERM_CLOSE_POSITION, PERM_DECREASE_POSITION, PERM_DEPOSIT_COLLATERAL, PERM_INCREASE_POSITION, PERM_MINT_WLP, PERM_OPEN_POSITION, PERM_PLACE_ORDER, PERM_REDEEM_WLP, PERM_WITHDRAW_COLLATERAL, STAKING_PERM_DEPOSIT_STAKE, STAKING_PERM_REDEEM_STAKE, STAKING_PERM_CLAIM_REWARD, STAKING_PERM_ALL, MS_PER_MINUTE, MS_PER_HOUR, MS_PER_YEAR, SUI_DECIMALS, WLP_DECIMALS, COLLATERAL_DECIMALS, TOKEN_DECIMALS, } from "./constants.ts";
|
|
6
6
|
export type { Network } from "./constants.ts";
|
|
7
|
-
export { getMarketTickers
|
|
7
|
+
export { getMarketTickers } from "../utils/config.ts";
|
|
8
8
|
export { annualizedApyFromRatio, annualizeFundingRate, calcBorrowRate, calcBorrowRateAccrual, calcDynamicFeeBps, calcEffectiveCollateralUsd, calcEstLiqPrice, calcEstLiqPriceRaw, calcFee, calcFundingFeeUsd, calcFundingRate, calcImpactFeeRate, calcLeverage, calcMaxReducibleCollateralUsd, calcNotional, calcPositionBorrowFee, calcRealLiqNetCostUsd, calcTokenUtilizationBps, calcTotalTradingFeeRate, calcUnrealizedPnl, calcViewEstLiqFeesUsd, calcWlpIncentiveApy, calcWlpMintOut, calcWlpPrice, calcWlpRedeemOut, decodeFundingIndexDelta, rawPrice, } from "../utils/math.ts";
|
|
9
9
|
export type { ExactDecimalUsd, LiqFeeBundle, RawPriceInput } from "../utils/math.ts";
|
|
10
10
|
export { formatFundingInterval } from "../utils/format.ts";
|
|
@@ -13,8 +13,8 @@ export type { EstLiqPriceViewOpts } from "./liq-view.ts";
|
|
|
13
13
|
export * from "./user/index.ts";
|
|
14
14
|
export * from "./tx-builders.ts";
|
|
15
15
|
export * from "./fetch.ts";
|
|
16
|
-
export { FetchPolicyError, LazerApiKeyMissingError,
|
|
17
|
-
export type { FetchPolicy,
|
|
16
|
+
export { FetchPolicyError, LazerApiKeyMissingError, LazerNotEntitledError, OracleTickerUnservedError, OracleWeightCoverageError, OracleWeightUnreadableError, OracleSourceNotImplementedError, aggregateTicker, aggregateTickerWithConstant, ORACLE_SOURCES, assertOracleWeightCoverage, assertOracleWriteCoverage, fetchPythProHistory, fetchPythSymbolCatalog, fetchWaterxSignedLeaves, fetchWaterxSignedUpdate, fetchWaterxUpdateData, getMarketStatus, isFreshWaterxEntry, deriveOracleSources, missingOracleCredentials, parsePythSchedule, PythScheduleParseError, pullWaterxQuotes, readLazerPrices, readPlanTickers, readQuoteCenterPrices, refreshOraclePrices, resolveOracleReadPlan, resolveOracleRule, servableTickers, WATERX_MAX_PRICE_AGE_MS, waterxEnvelopeOf, waterxLeavesOf, parseSignedLeaves, MERKLE_ROOT_INTENT, waterxQuoteCenterEndpoint, } from "../oracle/index.ts";
|
|
17
|
+
export type { FetchPolicy, HolidayDate, MarketStatusResult, OracleCredentialKind, OraclePriceEntry, OracleRefreshSummary, OracleReadPlan, OracleSource, ParsedPythSchedule, PythSymbolRecord, TradingHours, TradingSession, UpdateDataProvider, WaterxBatchItem, WaterxEnvelopePayload, WaterxLeafPayload, WaterxSignedEnvelope, WaterxSignedLeaf, WaterxUpdatePayload, } from "../oracle/index.ts";
|
|
18
18
|
export { fetchDepositVaa, fetchVaa, listBridgeWithdrawalVaas, listVaasByEmitter, padEvmEmitter, toWormholescanEmitter, vaaBase64ToBytes, vaaBase64ToHex, vaaBytesToBase64, waitForVaa, } from "../account/funding/wormhole.ts";
|
|
19
19
|
export type { VaaListItem, VaaResponse, WormholescanOptions } from "../account/funding/wormhole.ts";
|
|
20
20
|
export { AccountData as AccountDataBcs, GlobalConfigData as GlobalConfigDataBcs, MarketData as MarketDataBcs, OrderData as OrderDataBcs, PoolData as PoolDataBcs, PositionData as PositionDataBcs, RedeemRequestData as RedeemRequestDataBcs, TokenPoolData as TokenPoolDataBcs, } from "../generated/waterx_perp_view/view.ts";
|
|
@@ -27,8 +27,6 @@ export * as viewCalls from "../generated/waterx_perp_view/view.ts";
|
|
|
27
27
|
export * as wxaAccountCalls from "../generated/waterx_account/account.ts";
|
|
28
28
|
export * as stakingCalls from "../generated/waterx_staking/waterx_staking.ts";
|
|
29
29
|
export * as oracleCalls from "../generated/waterx_oracle/oracle.ts";
|
|
30
|
-
export * as pythRuleCalls from "../generated/waterx_pyth_rule/pyth_rule.ts";
|
|
31
|
-
export * as pythSponsorRuleCalls from "../generated/pyth_sponsor_rule/pyth_sponsor_rule.ts";
|
|
32
30
|
export * as referralCalls from "../generated/waterx_referral/referral_table.ts";
|
|
33
31
|
export * as nativeCustodyCalls from "../generated/native_custody/custody_vault.ts";
|
|
34
32
|
export * as withdrawalQueueCalls from "../generated/withdrawal_queue/withdrawal_queue.ts";
|
|
@@ -36,9 +36,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
exports.
|
|
41
|
-
exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.
|
|
39
|
+
exports.annualizedApyFromRatio = exports.getMarketTickers = exports.TOKEN_DECIMALS = exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.MS_PER_YEAR = exports.MS_PER_HOUR = exports.MS_PER_MINUTE = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_REDEEM_WLP = exports.PERM_PLACE_ORDER = exports.PERM_OPEN_POSITION = exports.PERM_MINT_WLP = exports.PERM_INCREASE_POSITION = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_DECREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_CANCEL_ORDER = exports.PERM_ALL_TRADING = exports.PERM_ALL = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.FLOAT_SCALE = exports.DRY_RUN_SENDER = exports.DOUBLE_SCALE = exports.BPS_SCALE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_UPDATE_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_OPEN_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_INCREASE_POSITION = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_DECREASE_POSITION = exports.ACTION_CLOSE_POSITION = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_CANCEL_ORDER = exports.ACTION_ADD_PRE_ORDER = exports.loadConfig = exports.clearConfigCache = exports.WORMHOLE_DEFAULTS = exports.PerpClient = void 0;
|
|
40
|
+
exports.parsePythSchedule = exports.missingOracleCredentials = exports.deriveOracleSources = exports.isFreshWaterxEntry = exports.getMarketStatus = exports.fetchWaterxUpdateData = exports.fetchWaterxSignedUpdate = exports.fetchWaterxSignedLeaves = exports.fetchPythSymbolCatalog = exports.fetchPythProHistory = exports.assertOracleWriteCoverage = exports.assertOracleWeightCoverage = exports.ORACLE_SOURCES = exports.aggregateTickerWithConstant = exports.aggregateTicker = exports.OracleSourceNotImplementedError = exports.OracleWeightUnreadableError = exports.OracleWeightCoverageError = exports.OracleTickerUnservedError = exports.LazerNotEntitledError = exports.LazerApiKeyMissingError = exports.FetchPolicyError = exports.calcEstLiqPriceRawFromView = exports.formatFundingInterval = exports.rawPrice = exports.decodeFundingIndexDelta = exports.calcWlpRedeemOut = exports.calcWlpPrice = exports.calcWlpMintOut = exports.calcWlpIncentiveApy = exports.calcViewEstLiqFeesUsd = exports.calcUnrealizedPnl = exports.calcTotalTradingFeeRate = exports.calcTokenUtilizationBps = exports.calcRealLiqNetCostUsd = exports.calcPositionBorrowFee = exports.calcNotional = exports.calcMaxReducibleCollateralUsd = exports.calcLeverage = exports.calcImpactFeeRate = exports.calcFundingRate = exports.calcFundingFeeUsd = exports.calcFee = exports.calcEstLiqPriceRaw = exports.calcEstLiqPrice = exports.calcEffectiveCollateralUsd = exports.calcDynamicFeeBps = exports.calcBorrowRateAccrual = exports.calcBorrowRate = exports.annualizeFundingRate = void 0;
|
|
41
|
+
exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.oracleCalls = exports.stakingCalls = exports.wxaAccountCalls = exports.viewCalls = exports.lpPoolCalls = exports.tradingCalls = exports.MarketConfigBcs = exports.MarketBcs = exports.OrderBcs = exports.PositionBcs = exports.TokenPoolDataBcs = exports.RedeemRequestDataBcs = exports.PositionDataBcs = exports.PoolDataBcs = exports.OrderDataBcs = exports.MarketDataBcs = exports.GlobalConfigDataBcs = exports.AccountDataBcs = exports.waitForVaa = exports.vaaBytesToBase64 = exports.vaaBase64ToHex = exports.vaaBase64ToBytes = exports.toWormholescanEmitter = exports.padEvmEmitter = exports.listVaasByEmitter = exports.listBridgeWithdrawalVaas = exports.fetchVaa = exports.fetchDepositVaa = exports.waterxQuoteCenterEndpoint = exports.MERKLE_ROOT_INTENT = exports.parseSignedLeaves = exports.waterxLeavesOf = exports.waterxEnvelopeOf = exports.WATERX_MAX_PRICE_AGE_MS = exports.servableTickers = exports.resolveOracleRule = exports.resolveOracleReadPlan = exports.refreshOraclePrices = exports.readQuoteCenterPrices = exports.readPlanTickers = exports.readLazerPrices = exports.pullWaterxQuotes = exports.PythScheduleParseError = void 0;
|
|
42
42
|
// ======== Core ========
|
|
43
43
|
var client_ts_1 = require("./client.js");
|
|
44
44
|
Object.defineProperty(exports, "PerpClient", { enumerable: true, get: function () { return client_ts_1.PerpClient; } });
|
|
@@ -95,7 +95,6 @@ Object.defineProperty(exports, "TOKEN_DECIMALS", { enumerable: true, get: functi
|
|
|
95
95
|
// ======== Utilities ========
|
|
96
96
|
var config_ts_2 = require("../utils/config.js");
|
|
97
97
|
Object.defineProperty(exports, "getMarketTickers", { enumerable: true, get: function () { return config_ts_2.getMarketTickers; } });
|
|
98
|
-
Object.defineProperty(exports, "getCollateralAssets", { enumerable: true, get: function () { return config_ts_2.getCollateralAssets; } });
|
|
99
98
|
var math_ts_1 = require("../utils/math.js");
|
|
100
99
|
Object.defineProperty(exports, "annualizedApyFromRatio", { enumerable: true, get: function () { return math_ts_1.annualizedApyFromRatio; } });
|
|
101
100
|
Object.defineProperty(exports, "annualizeFundingRate", { enumerable: true, get: function () { return math_ts_1.annualizeFundingRate; } });
|
|
@@ -134,26 +133,46 @@ __exportStar(require("./user/index.js"), exports);
|
|
|
134
133
|
__exportStar(require("./tx-builders.js"), exports);
|
|
135
134
|
// ======== Read-only queries ========
|
|
136
135
|
__exportStar(require("./fetch.js"), exports);
|
|
137
|
-
// ======== Oracle utilities (
|
|
136
|
+
// ======== Oracle utilities (sources + rule aggregation + read planes) ========
|
|
138
137
|
var index_ts_1 = require("../oracle/index.js");
|
|
139
138
|
Object.defineProperty(exports, "FetchPolicyError", { enumerable: true, get: function () { return index_ts_1.FetchPolicyError; } });
|
|
140
139
|
Object.defineProperty(exports, "LazerApiKeyMissingError", { enumerable: true, get: function () { return index_ts_1.LazerApiKeyMissingError; } });
|
|
141
|
-
Object.defineProperty(exports, "
|
|
140
|
+
Object.defineProperty(exports, "LazerNotEntitledError", { enumerable: true, get: function () { return index_ts_1.LazerNotEntitledError; } });
|
|
141
|
+
Object.defineProperty(exports, "OracleTickerUnservedError", { enumerable: true, get: function () { return index_ts_1.OracleTickerUnservedError; } });
|
|
142
|
+
Object.defineProperty(exports, "OracleWeightCoverageError", { enumerable: true, get: function () { return index_ts_1.OracleWeightCoverageError; } });
|
|
143
|
+
Object.defineProperty(exports, "OracleWeightUnreadableError", { enumerable: true, get: function () { return index_ts_1.OracleWeightUnreadableError; } });
|
|
142
144
|
Object.defineProperty(exports, "OracleSourceNotImplementedError", { enumerable: true, get: function () { return index_ts_1.OracleSourceNotImplementedError; } });
|
|
143
|
-
Object.defineProperty(exports, "PythCache", { enumerable: true, get: function () { return index_ts_1.PythCache; } });
|
|
144
145
|
Object.defineProperty(exports, "aggregateTicker", { enumerable: true, get: function () { return index_ts_1.aggregateTicker; } });
|
|
145
146
|
Object.defineProperty(exports, "aggregateTickerWithConstant", { enumerable: true, get: function () { return index_ts_1.aggregateTickerWithConstant; } });
|
|
146
|
-
Object.defineProperty(exports, "aggregateTickerWithPyth", { enumerable: true, get: function () { return index_ts_1.aggregateTickerWithPyth; } });
|
|
147
147
|
Object.defineProperty(exports, "ORACLE_SOURCES", { enumerable: true, get: function () { return index_ts_1.ORACLE_SOURCES; } });
|
|
148
|
-
Object.defineProperty(exports, "
|
|
149
|
-
Object.defineProperty(exports, "
|
|
150
|
-
Object.defineProperty(exports, "
|
|
151
|
-
Object.defineProperty(exports, "
|
|
152
|
-
Object.defineProperty(exports, "
|
|
153
|
-
Object.defineProperty(exports, "
|
|
148
|
+
Object.defineProperty(exports, "assertOracleWeightCoverage", { enumerable: true, get: function () { return index_ts_1.assertOracleWeightCoverage; } });
|
|
149
|
+
Object.defineProperty(exports, "assertOracleWriteCoverage", { enumerable: true, get: function () { return index_ts_1.assertOracleWriteCoverage; } });
|
|
150
|
+
Object.defineProperty(exports, "fetchPythProHistory", { enumerable: true, get: function () { return index_ts_1.fetchPythProHistory; } });
|
|
151
|
+
Object.defineProperty(exports, "fetchPythSymbolCatalog", { enumerable: true, get: function () { return index_ts_1.fetchPythSymbolCatalog; } });
|
|
152
|
+
Object.defineProperty(exports, "fetchWaterxSignedLeaves", { enumerable: true, get: function () { return index_ts_1.fetchWaterxSignedLeaves; } });
|
|
153
|
+
Object.defineProperty(exports, "fetchWaterxSignedUpdate", { enumerable: true, get: function () { return index_ts_1.fetchWaterxSignedUpdate; } });
|
|
154
|
+
Object.defineProperty(exports, "fetchWaterxUpdateData", { enumerable: true, get: function () { return index_ts_1.fetchWaterxUpdateData; } });
|
|
155
|
+
Object.defineProperty(exports, "getMarketStatus", { enumerable: true, get: function () { return index_ts_1.getMarketStatus; } });
|
|
156
|
+
Object.defineProperty(exports, "isFreshWaterxEntry", { enumerable: true, get: function () { return index_ts_1.isFreshWaterxEntry; } });
|
|
157
|
+
Object.defineProperty(exports, "deriveOracleSources", { enumerable: true, get: function () { return index_ts_1.deriveOracleSources; } });
|
|
158
|
+
Object.defineProperty(exports, "missingOracleCredentials", { enumerable: true, get: function () { return index_ts_1.missingOracleCredentials; } });
|
|
159
|
+
Object.defineProperty(exports, "parsePythSchedule", { enumerable: true, get: function () { return index_ts_1.parsePythSchedule; } });
|
|
160
|
+
Object.defineProperty(exports, "PythScheduleParseError", { enumerable: true, get: function () { return index_ts_1.PythScheduleParseError; } });
|
|
161
|
+
// THE quote-center route ladder (leaves-first, envelope only where there is
|
|
162
|
+
// no leaf route). Both SDK planes go through it, so a consumer running its
|
|
163
|
+
// own prefetch reaches for the same one rather than re-deriving the ladder.
|
|
164
|
+
Object.defineProperty(exports, "pullWaterxQuotes", { enumerable: true, get: function () { return index_ts_1.pullWaterxQuotes; } });
|
|
165
|
+
Object.defineProperty(exports, "readLazerPrices", { enumerable: true, get: function () { return index_ts_1.readLazerPrices; } });
|
|
166
|
+
Object.defineProperty(exports, "readPlanTickers", { enumerable: true, get: function () { return index_ts_1.readPlanTickers; } });
|
|
167
|
+
Object.defineProperty(exports, "readQuoteCenterPrices", { enumerable: true, get: function () { return index_ts_1.readQuoteCenterPrices; } });
|
|
154
168
|
Object.defineProperty(exports, "refreshOraclePrices", { enumerable: true, get: function () { return index_ts_1.refreshOraclePrices; } });
|
|
155
|
-
Object.defineProperty(exports, "
|
|
156
|
-
Object.defineProperty(exports, "
|
|
169
|
+
Object.defineProperty(exports, "resolveOracleReadPlan", { enumerable: true, get: function () { return index_ts_1.resolveOracleReadPlan; } });
|
|
170
|
+
Object.defineProperty(exports, "resolveOracleRule", { enumerable: true, get: function () { return index_ts_1.resolveOracleRule; } });
|
|
171
|
+
// `refreshOraclePrices`' OWN acceptance predicate. Consumers filtering a
|
|
172
|
+
// ticker list before a build must use this rather than re-deriving "some
|
|
173
|
+
// listed source carries it", or they drift from what the build accepts.
|
|
174
|
+
Object.defineProperty(exports, "servableTickers", { enumerable: true, get: function () { return index_ts_1.servableTickers; } });
|
|
175
|
+
Object.defineProperty(exports, "WATERX_MAX_PRICE_AGE_MS", { enumerable: true, get: function () { return index_ts_1.WATERX_MAX_PRICE_AGE_MS; } });
|
|
157
176
|
Object.defineProperty(exports, "waterxEnvelopeOf", { enumerable: true, get: function () { return index_ts_1.waterxEnvelopeOf; } });
|
|
158
177
|
// Leaves are the DEFAULT waterx wire shape, so their accessor + parser belong
|
|
159
178
|
// on the same surface as `waterxEnvelopeOf` (and on the root, which re-exports
|
|
@@ -200,8 +219,6 @@ exports.viewCalls = __importStar(require("../generated/waterx_perp_view/view.js"
|
|
|
200
219
|
exports.wxaAccountCalls = __importStar(require("../generated/waterx_account/account.js"));
|
|
201
220
|
exports.stakingCalls = __importStar(require("../generated/waterx_staking/waterx_staking.js"));
|
|
202
221
|
exports.oracleCalls = __importStar(require("../generated/waterx_oracle/oracle.js"));
|
|
203
|
-
exports.pythRuleCalls = __importStar(require("../generated/waterx_pyth_rule/pyth_rule.js"));
|
|
204
|
-
exports.pythSponsorRuleCalls = __importStar(require("../generated/pyth_sponsor_rule/pyth_sponsor_rule.js"));
|
|
205
222
|
exports.referralCalls = __importStar(require("../generated/waterx_referral/referral_table.js"));
|
|
206
223
|
exports.nativeCustodyCalls = __importStar(require("../generated/native_custody/custody_vault.js"));
|
|
207
224
|
exports.withdrawalQueueCalls = __importStar(require("../generated/withdrawal_queue/withdrawal_queue.js"));
|
|
@@ -1,44 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared scaffolding for the high-level perp `build*Tx` composers:
|
|
3
3
|
* `CommonBuildOpts`, the new-or-reuse PTB helper, the WLP pool-oracle refresh,
|
|
4
|
-
* and the request+execute envelope (optional
|
|
4
|
+
* and the request+execute envelope (optional pre-sweep).
|
|
5
5
|
*/
|
|
6
6
|
import { Transaction, type TransactionArgument } from "@mysten/sui/transactions";
|
|
7
|
-
import {
|
|
7
|
+
import { type OracleRefreshSummary, type UpdateDataProvider } from "../../oracle/index.ts";
|
|
8
8
|
import type { PerpClient } from "../client.ts";
|
|
9
9
|
export interface CommonBuildOpts {
|
|
10
10
|
/** Append to an existing PTB instead of creating a new one. */
|
|
11
11
|
tx?: Transaction;
|
|
12
|
-
/** Skip oracle refresh entirely (caller manages freshness). Default: false. */
|
|
13
|
-
skipOraclePriceRefresh?: boolean;
|
|
14
|
-
/** Share a `PythCache` across builders to avoid redundant pyth_state reads. */
|
|
15
|
-
pythCache?: PythCache;
|
|
16
12
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
13
|
+
* Skip oracle refresh entirely (caller manages freshness). Default: false.
|
|
14
|
+
*
|
|
15
|
+
* This is the SHARED-REFRESH composition lever: a caller batching several
|
|
16
|
+
* builders into one PTB refreshes once, up front, then passes the same `tx`
|
|
17
|
+
* to each builder with this flag set —
|
|
18
|
+
*
|
|
19
|
+
* const tx = new Transaction();
|
|
20
|
+
* await refreshOraclePrices(tx, client.perp, allTickers);
|
|
21
|
+
* await buildIncreasePositionTx(client.perp, { ...a, tx, skipOraclePriceRefresh: true });
|
|
22
|
+
* await buildPlaceOrderTx(client.perp, { ...b, tx, skipOraclePriceRefresh: true });
|
|
23
|
+
*
|
|
24
|
+
* — one refresh covering `allTickers` (every builder's market + collateral
|
|
25
|
+
* tickers + the WLP pool tokens) instead of N. This is not just a gas
|
|
26
|
+
* saving: under `waterx_rule` a repeated per-builder refresh would submit
|
|
27
|
+
* the same signed timestamp twice per symbol in one PTB, paying full
|
|
28
|
+
* verification for an on-chain abstain (the F-014 per-symbol replay
|
|
29
|
+
* high-water mark).
|
|
30
|
+
*
|
|
31
|
+
* Sharing one fetched waterx snapshot across CONCURRENT builds is safe on
|
|
32
|
+
* these paths: every builder here feeds through `collect_*`, where a
|
|
33
|
+
* replayed per-symbol timestamp ABSTAINS rather than aborting — the chain
|
|
34
|
+
* already holds a price at least that fresh. `EReplayedSignature` is raised
|
|
35
|
+
* only by the single-rule `feed_*` entries, which no `build*Tx` uses. The
|
|
36
|
+
* cost of sharing is a contribution that does not count, not a failed
|
|
37
|
+
* transaction.
|
|
27
38
|
*/
|
|
28
|
-
|
|
39
|
+
skipOraclePriceRefresh?: boolean;
|
|
29
40
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* `
|
|
41
|
+
* Build even when a ticker this action depends on could not be refreshed.
|
|
42
|
+
*
|
|
43
|
+
* `refreshOraclePrices` SKIPS tickers no listed source serves (it is a broad
|
|
44
|
+
* primitive — losing 29 tickers because the 30th is unconfigured is the wrong
|
|
45
|
+
* trade). The composers then fail closed on the subset their specific action
|
|
46
|
+
* actually depends on. This opts out of that check, building against whatever
|
|
47
|
+
* price the chain already holds.
|
|
48
|
+
*
|
|
49
|
+
* Rarely correct. The on-chain guards do NOT cover for it: `mint_wlp` sizes
|
|
50
|
+
* the payout off `pool.tvl_usd`, and `assert_prices_fresh` only compares each
|
|
51
|
+
* token's `last_price_refresh_timestamp` against
|
|
52
|
+
* `price_refresh_threshold_ms` — so a pool asset last refreshed by SOMEONE
|
|
53
|
+
* ELSE minutes ago passes, and the mint is valued off that stale price.
|
|
40
54
|
*/
|
|
41
|
-
|
|
55
|
+
allowUnrefreshedPrices?: boolean;
|
|
42
56
|
/**
|
|
43
57
|
* Pre-sweep parked backing assets (USDC, USDsui, …) at the wxa account's
|
|
44
58
|
* address into USD credit, plus any CREDIT coins/funds at the address into
|
|
@@ -73,36 +87,63 @@ interface RequestParams {
|
|
|
73
87
|
lpType?: string;
|
|
74
88
|
}
|
|
75
89
|
export declare function newTx(opts?: CommonBuildOpts): Transaction;
|
|
90
|
+
/**
|
|
91
|
+
* Fail the build when a ticker THIS action depends on went unrefreshed.
|
|
92
|
+
*
|
|
93
|
+
* The split of responsibility: `refreshOraclePrices` skips (it cannot know
|
|
94
|
+
* which of its tickers were load-bearing), the composer asserts (it does).
|
|
95
|
+
*/
|
|
96
|
+
export declare function assertTickersRefreshed(client: PerpClient, summary: OracleRefreshSummary, required: string[], opts: CommonBuildOpts | undefined,
|
|
97
|
+
/** Appended to the error, to say why THESE tickers were load-bearing. */
|
|
98
|
+
why?: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Fail the build when ANY WLP pool asset went unpriced — stricter than
|
|
101
|
+
* {@link assertTickersRefreshed}, and deliberately so.
|
|
102
|
+
*
|
|
103
|
+
* `mint_wlp` / `settle_redeem` take `&WlpAum` and size the payout against the
|
|
104
|
+
* pool's WHOLE `tvl_usd`, so a stale price on any pool asset mis-values the
|
|
105
|
+
* trade — not just a stale price on the deposit ticker.
|
|
106
|
+
*
|
|
107
|
+
* Nothing on chain catches the gap. Two paths, neither of which fails:
|
|
108
|
+
* - the asset IS bumped: `update_token_value` calls `oracle::get_price`,
|
|
109
|
+
* which aborts `EStalePrice` unless this PTB aggregated it — loud, safe;
|
|
110
|
+
* - the asset is NOT bumped (it was skipped, so no leg was emitted): its
|
|
111
|
+
* `last_price_refresh_timestamp` keeps whatever a previous transaction
|
|
112
|
+
* left, and `assert_prices_fresh` only asks that it be within
|
|
113
|
+
* `price_refresh_threshold_ms`. A recent-enough stale price PASSES.
|
|
114
|
+
*
|
|
115
|
+
* So the silent case is exactly the skipped one, and the build is the only
|
|
116
|
+
* place it can be caught.
|
|
117
|
+
*/
|
|
118
|
+
export declare function assertWlpPoolRefreshed(client: PerpClient, summary: OracleRefreshSummary, opts: CommonBuildOpts | undefined): void;
|
|
76
119
|
/**
|
|
77
120
|
* Refresh every WLP pool-token oracle (+ caller-supplied extra tickers) and
|
|
78
121
|
* bump each pool token's `last_price_refresh_timestamp` so the pool's
|
|
79
122
|
* `assert_prices_fresh` passes when the next `mint_wlp` / `request_redeem` /
|
|
80
123
|
* trading `execute` runs in the same PTB.
|
|
124
|
+
*
|
|
125
|
+
* Fails closed via {@link assertWlpPoolRefreshed} — see there for why a gap is
|
|
126
|
+
* otherwise silent rather than an on-chain abort.
|
|
81
127
|
*/
|
|
82
|
-
export declare function refreshWlpPoolOracles(tx: Transaction, client: PerpClient, extraTickers: string[],
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
feeSource?: OracleFeeSource;
|
|
128
|
+
export declare function refreshWlpPoolOracles(tx: Transaction, client: PerpClient, extraTickers: string[],
|
|
129
|
+
/** The build's options — `lpType`, plus `allowUnrefreshedPrices` / `updateDataProvider`. */
|
|
130
|
+
opts: CommonBuildOpts & {
|
|
86
131
|
lpType?: string;
|
|
87
|
-
|
|
88
|
-
}): Promise<void>;
|
|
132
|
+
}): Promise<OracleRefreshSummary>;
|
|
89
133
|
/**
|
|
90
|
-
* Build the *Request + execute envelope
|
|
134
|
+
* Build the *Request + execute envelope:
|
|
91
135
|
*
|
|
92
136
|
* [maybeConsolidate(tx)]
|
|
93
|
-
*
|
|
94
|
-
* refreshOraclePrices(..., feeSource?)
|
|
137
|
+
* refreshOraclePrices(...)
|
|
95
138
|
* req = buildRequest()
|
|
96
|
-
* [sponsor.reimburse(fund, req)]
|
|
97
139
|
* trading::execute(req)
|
|
98
140
|
*
|
|
99
141
|
* Accepted ordering caveat: `maybeConsolidate` runs FIRST and can itself
|
|
100
|
-
* append PTB commands (the consolidation sweep) before the
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* `
|
|
104
|
-
*
|
|
105
|
-
* discard-tx-on-throw contract every `build*Tx` composer already has for
|
|
142
|
+
* append PTB commands (the consolidation sweep) before the refresh's own
|
|
143
|
+
* pre-checks run — so a throw out of `refreshOraclePrices` here is NOT the
|
|
144
|
+
* "zero commands appended" guarantee it gives its own callers (see its
|
|
145
|
+
* docblock in `aggregate.ts`); `tx` can already carry the sweep. This is the
|
|
146
|
+
* same discard-tx-on-throw contract every `build*Tx` composer already has for
|
|
106
147
|
* mid-build on-chain-read failures — not a new hole. It matters only for a
|
|
107
148
|
* caller that passed in their OWN `opts.tx` (reusing one `Transaction`
|
|
108
149
|
* across builder calls, e.g. to compose several actions in one PTB); such a
|
|
@@ -111,10 +152,7 @@ export declare function refreshWlpPoolOracles(tx: Transaction, client: PerpClien
|
|
|
111
152
|
*/
|
|
112
153
|
export declare function wrapRequestAndExecute(client: PerpClient, tx: Transaction, req: RequestParams & {
|
|
113
154
|
accountId: string;
|
|
114
|
-
}, collateralTicker: string, opts: CommonBuildOpts | undefined, buildRequest: (
|
|
115
|
-
fund: TransactionArgument;
|
|
116
|
-
packageId: string;
|
|
117
|
-
}) => TransactionArgument): Promise<void>;
|
|
155
|
+
}, collateralTicker: string, opts: CommonBuildOpts | undefined, buildRequest: () => TransactionArgument): Promise<void>;
|
|
118
156
|
/** Run the async sweep iff `consolidateToUsd !== false`. */
|
|
119
157
|
export declare function maybeConsolidate(client: PerpClient, tx: Transaction, accountId: string, opts: CommonBuildOpts | undefined): Promise<void>;
|
|
120
158
|
export {};
|