@waterx/sdk 4.0.1 → 4.3.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 +37 -17
- package/dist/cjs/src/account/account.js +2 -1
- package/dist/cjs/src/account/config.d.ts +3 -2
- package/dist/cjs/src/account/funding/balance.d.ts +25 -2
- package/dist/cjs/src/account/funding/balance.js +36 -24
- package/dist/cjs/src/account/funding/credit.js +6 -10
- package/dist/cjs/src/constants.d.ts +15 -1
- package/dist/cjs/src/constants.js +18 -4
- package/dist/cjs/src/generated/waterx_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/cjs/src/generated/waterx_rule/deps/bucket_v2_framework/float.js +13 -0
- package/dist/cjs/src/generated/waterx_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/cjs/src/generated/waterx_rule/deps/sui/vec_map.js +31 -0
- package/dist/cjs/src/generated/waterx_rule/waterx_rule.d.ts +813 -0
- package/dist/cjs/src/generated/waterx_rule/waterx_rule.js +946 -0
- package/dist/cjs/src/oracle/aggregate.d.ts +23 -21
- package/dist/cjs/src/oracle/aggregate.js +133 -59
- package/dist/cjs/src/oracle/config.d.ts +82 -41
- package/dist/cjs/src/oracle/config.js +0 -42
- package/dist/cjs/src/oracle/host.d.ts +26 -11
- package/dist/cjs/src/oracle/index.d.ts +6 -2
- package/dist/cjs/src/oracle/index.js +36 -8
- package/dist/cjs/src/oracle/price-update-rule.d.ts +16 -10
- package/dist/cjs/src/oracle/price-update-rule.js +3 -3
- package/dist/cjs/src/oracle/pyth.d.ts +44 -0
- package/dist/cjs/src/oracle/pyth.js +48 -6
- package/dist/cjs/src/oracle/read-plane.d.ts +70 -0
- package/dist/cjs/src/oracle/read-plane.js +78 -0
- package/dist/cjs/src/oracle/rule-registry.d.ts +14 -11
- package/dist/cjs/src/oracle/rule-registry.js +16 -11
- package/dist/cjs/src/oracle/rules/pyth-core-rule.js +4 -4
- package/dist/cjs/src/oracle/rules/pyth-lazer-rule.d.ts +21 -0
- package/dist/cjs/src/oracle/rules/pyth-lazer-rule.js +29 -4
- package/dist/cjs/src/oracle/rules/pyth-rule.js +5 -4
- package/dist/cjs/src/oracle/rules/waterx-rule.d.ts +126 -0
- package/dist/cjs/src/oracle/rules/waterx-rule.js +312 -0
- package/dist/cjs/src/perp/client.d.ts +71 -20
- package/dist/cjs/src/perp/client.js +35 -13
- package/dist/cjs/src/perp/config.d.ts +6 -7
- package/dist/cjs/src/perp/config.js +12 -11
- package/dist/cjs/src/perp/constants.d.ts +0 -6
- package/dist/cjs/src/perp/constants.js +11 -9
- package/dist/cjs/src/perp/fetch/account.js +3 -0
- package/dist/cjs/src/perp/fetch/bridge.js +2 -1
- package/dist/cjs/src/perp/fetch/market.js +2 -1
- package/dist/cjs/src/perp/fetch/positions.d.ts +16 -10
- package/dist/cjs/src/perp/fetch/positions.js +23 -20
- package/dist/cjs/src/perp/index.d.ts +9 -5
- package/dist/cjs/src/perp/index.js +16 -7
- package/dist/cjs/src/perp/liq-view.d.ts +64 -0
- package/dist/cjs/src/perp/liq-view.js +74 -0
- package/dist/cjs/src/perp/user/order.d.ts +13 -0
- package/dist/cjs/src/perp/user/order.js +30 -16
- package/dist/cjs/src/perp/user/staking.js +3 -2
- package/dist/cjs/src/perp/user/trading.js +25 -24
- package/dist/cjs/src/perp/user/wlp.js +6 -5
- package/dist/cjs/src/prediction/utils.d.ts +11 -2
- package/dist/cjs/src/prediction/utils.js +22 -22
- package/dist/cjs/src/unified-client.d.ts +41 -15
- package/dist/cjs/src/unified-client.js +4 -2
- package/dist/cjs/src/utils/format.d.ts +14 -0
- package/dist/cjs/src/utils/format.js +24 -0
- package/dist/cjs/src/utils/math.d.ts +304 -12
- package/dist/cjs/src/utils/math.js +397 -17
- package/dist/cjs/src/utils/validate.d.ts +69 -0
- package/dist/cjs/src/utils/validate.js +183 -0
- package/dist/src/account/account.js +2 -1
- package/dist/src/account/config.d.ts +3 -2
- package/dist/src/account/funding/balance.d.ts +25 -2
- package/dist/src/account/funding/balance.js +36 -24
- package/dist/src/account/funding/credit.js +6 -10
- package/dist/src/constants.d.ts +15 -1
- package/dist/src/constants.js +17 -3
- package/dist/src/generated/waterx_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_rule/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_rule/waterx_rule.d.ts +813 -0
- package/dist/src/generated/waterx_rule/waterx_rule.js +855 -0
- package/dist/src/oracle/aggregate.d.ts +23 -21
- package/dist/src/oracle/aggregate.js +133 -59
- package/dist/src/oracle/config.d.ts +82 -41
- package/dist/src/oracle/config.js +1 -41
- package/dist/src/oracle/host.d.ts +26 -11
- package/dist/src/oracle/index.d.ts +6 -2
- package/dist/src/oracle/index.js +27 -9
- package/dist/src/oracle/price-update-rule.d.ts +16 -10
- package/dist/src/oracle/price-update-rule.js +3 -3
- package/dist/src/oracle/pyth.d.ts +44 -0
- package/dist/src/oracle/pyth.js +45 -5
- package/dist/src/oracle/read-plane.d.ts +70 -0
- package/dist/src/oracle/read-plane.js +74 -0
- package/dist/src/oracle/rule-registry.d.ts +14 -11
- package/dist/src/oracle/rule-registry.js +16 -11
- package/dist/src/oracle/rules/pyth-core-rule.js +5 -5
- package/dist/src/oracle/rules/pyth-lazer-rule.d.ts +21 -0
- package/dist/src/oracle/rules/pyth-lazer-rule.js +28 -3
- package/dist/src/oracle/rules/pyth-rule.js +5 -4
- package/dist/src/oracle/rules/waterx-rule.d.ts +126 -0
- package/dist/src/oracle/rules/waterx-rule.js +305 -0
- package/dist/src/perp/client.d.ts +71 -20
- package/dist/src/perp/client.js +36 -14
- package/dist/src/perp/config.d.ts +6 -7
- package/dist/src/perp/config.js +11 -9
- package/dist/src/perp/constants.d.ts +0 -6
- package/dist/src/perp/constants.js +10 -8
- package/dist/src/perp/fetch/account.js +3 -0
- package/dist/src/perp/fetch/bridge.js +2 -1
- package/dist/src/perp/fetch/market.js +2 -1
- package/dist/src/perp/fetch/positions.d.ts +16 -10
- package/dist/src/perp/fetch/positions.js +28 -20
- package/dist/src/perp/index.d.ts +9 -5
- package/dist/src/perp/index.js +6 -4
- package/dist/src/perp/liq-view.d.ts +64 -0
- package/dist/src/perp/liq-view.js +71 -0
- package/dist/src/perp/user/order.d.ts +13 -0
- package/dist/src/perp/user/order.js +30 -16
- package/dist/src/perp/user/staking.js +3 -2
- package/dist/src/perp/user/trading.js +25 -24
- package/dist/src/perp/user/wlp.js +6 -5
- package/dist/src/prediction/utils.d.ts +11 -2
- package/dist/src/prediction/utils.js +22 -22
- package/dist/src/unified-client.d.ts +41 -15
- package/dist/src/unified-client.js +4 -2
- package/dist/src/utils/format.d.ts +14 -0
- package/dist/src/utils/format.js +21 -0
- package/dist/src/utils/math.d.ts +304 -12
- package/dist/src/utils/math.js +394 -17
- package/dist/src/utils/validate.d.ts +69 -0
- package/dist/src/utils/validate.js +167 -0
- package/package.json +4 -1
|
@@ -17,27 +17,49 @@ const base_client_ts_1 = require("../base-client.js");
|
|
|
17
17
|
const config_view_ts_1 = require("./config-view.js");
|
|
18
18
|
const config_ts_1 = require("./config.js");
|
|
19
19
|
class PerpClient extends base_client_ts_1.BaseLineClient {
|
|
20
|
-
/** Pyth
|
|
20
|
+
/** Caller-supplied Pyth credential + fetch policy — NO infra; each source owns its own tables. */
|
|
21
21
|
pyth;
|
|
22
|
+
/**
|
|
23
|
+
* Caller-supplied quote-center overrides for `oracleSource: 'waterx_rule'`
|
|
24
|
+
* (`waterxEndpoint` / `waterxFetch` create options) — access-only, mirroring
|
|
25
|
+
* `pyth` above; unset fields resolve against the rule's own `WATERX_INFRA`.
|
|
26
|
+
*/
|
|
27
|
+
waterx;
|
|
22
28
|
/** Wormhole infra for the credit bridge (network defaults unless overridden). */
|
|
23
29
|
wormhole;
|
|
24
|
-
/**
|
|
25
|
-
|
|
30
|
+
/** The fed set: `oracleSource` create option normalized to a non-empty, deduped list. */
|
|
31
|
+
oracleSources;
|
|
26
32
|
/** Canonical-schema lookups (delegated to below); no transport. */
|
|
27
33
|
view;
|
|
28
|
-
constructor(network, config, opts
|
|
34
|
+
constructor(network, config, opts) {
|
|
29
35
|
super(network, config, opts);
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
36
|
+
// Access-only slice: the api_key + fetch policy are caller-supplied at
|
|
37
|
+
// init (a secret has no place in the canonical waterx-config JSON). All
|
|
38
|
+
// endpoint/object-id infra is per-source, owned by the rule modules —
|
|
39
|
+
// nothing infra-shaped lives on the client.
|
|
34
40
|
this.pyth = {
|
|
35
|
-
...config_ts_1.PYTH_DEFAULTS[network],
|
|
36
41
|
...(opts.pythApiKey !== undefined ? { api_key: opts.pythApiKey } : {}),
|
|
37
42
|
...(opts.pythFetch !== undefined ? { fetch: opts.pythFetch } : {}),
|
|
38
43
|
};
|
|
39
44
|
this.wormhole = config.wormhole ?? config_ts_1.WORMHOLE_DEFAULTS[network];
|
|
40
|
-
|
|
45
|
+
// Quote-center access slice: overrides only — a browser blocked by the
|
|
46
|
+
// quote-center's CORS allowlist swaps `endpoint` for a same-origin proxy;
|
|
47
|
+
// unset fields resolve inside the rule against WATERX_INFRA[network].
|
|
48
|
+
this.waterx = {
|
|
49
|
+
...(opts.waterxEndpoint !== undefined ? { endpoint: opts.waterxEndpoint } : {}),
|
|
50
|
+
...(opts.waterxFetch !== undefined ? { fetch: opts.waterxFetch } : {}),
|
|
51
|
+
};
|
|
52
|
+
// Normalize single-or-list to a deduped, order-preserving list. An empty
|
|
53
|
+
// list — or a nullish/empty entry, the shape an untyped caller produces
|
|
54
|
+
// by omitting the REQUIRED option — is a caller bug, not "no oracle":
|
|
55
|
+
// fail construction loudly instead of booting green and surfacing as
|
|
56
|
+
// `OracleSourceNotImplemented: undefined` at the first tx-build.
|
|
57
|
+
const sources = Array.isArray(opts.oracleSource) ? opts.oracleSource : [opts.oracleSource];
|
|
58
|
+
this.oracleSources = [...new Set(sources)];
|
|
59
|
+
if (this.oracleSources.length === 0 ||
|
|
60
|
+
this.oracleSources.some((source) => typeof source !== "string" || source.length === 0)) {
|
|
61
|
+
throw new Error(`oracleSource is REQUIRED and must name at least one source (got ${JSON.stringify(sources)})`);
|
|
62
|
+
}
|
|
41
63
|
this.view = new config_view_ts_1.PerpConfigView(() => this.config, () => this.wormhole);
|
|
42
64
|
}
|
|
43
65
|
/**
|
|
@@ -48,14 +70,14 @@ class PerpClient extends base_client_ts_1.BaseLineClient {
|
|
|
48
70
|
* not an error at init — it surfaces at tx-build time for the specific
|
|
49
71
|
* tickers that source can't serve (see `refreshOraclePrices`).
|
|
50
72
|
*/
|
|
51
|
-
static async create(network, opts
|
|
73
|
+
static async create(network, opts) {
|
|
52
74
|
const config = await (0, config_ts_1.loadConfig)(network, opts);
|
|
53
75
|
return new PerpClient(network, config, opts);
|
|
54
76
|
}
|
|
55
|
-
static mainnet(opts
|
|
77
|
+
static mainnet(opts) {
|
|
56
78
|
return PerpClient.create("MAINNET", opts);
|
|
57
79
|
}
|
|
58
|
-
static testnet(opts
|
|
80
|
+
static testnet(opts) {
|
|
59
81
|
return PerpClient.create("TESTNET", opts);
|
|
60
82
|
}
|
|
61
83
|
// ========================================================
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* `waterx-config` repo (default: GitHub raw).
|
|
4
4
|
*
|
|
5
5
|
* The schema mirrors the canonical JSON layout one-to-one (each package
|
|
6
|
-
* groups its own object IDs + per-ticker maps). External chain infra
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* groups its own object IDs + per-ticker maps). External chain infra is
|
|
7
|
+
* **not** in the JSON — each oracle source owns its own per-network table
|
|
8
|
+
* (`PYTH_CORE_INFRA` in `oracle/pyth.ts`, `LAZER_INFRA` in
|
|
9
|
+
* `oracle/rules/pyth-lazer-rule.ts`); Wormhole bridge infra lives in
|
|
10
|
+
* `WORMHOLE_DEFAULTS` below.
|
|
10
11
|
*/
|
|
11
12
|
import type { AccountPackages, BasePackageEntry, WormholeInfraConfig } from "../account/config.ts";
|
|
12
13
|
import type { OraclePackages } from "../oracle/config.ts";
|
|
13
14
|
import type { Network } from "./constants.ts";
|
|
14
15
|
export type { AccountConfig, AccountPackages, BasePackageEntry, NativeCustodyAsset, NativeCustodyPackage, WaterxCreditPackage, WaterxReferralPackage, WithdrawalQueuePackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "../account/config.ts";
|
|
15
|
-
export type { ConstantFeedEntry, OracleConfig, OraclePackages,
|
|
16
|
-
export { PYTH_DEFAULTS } from "../oracle/config.ts";
|
|
16
|
+
export type { ConstantFeedEntry, OracleConfig, OraclePackages, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, PythRulePackage, PythSponsorRulePackage, SupraFeedEntry, SupraRulePackage, WaterxConstantRulePackage, WaterxAccessConfig, WaterxOraclePackage, WaterxRulePackage, } from "../oracle/config.ts";
|
|
17
17
|
export interface WaterxPerpMarketEntry {
|
|
18
18
|
market: string;
|
|
19
19
|
config: string;
|
|
@@ -71,7 +71,6 @@ export interface WaterXPackages extends AccountPackages, OraclePackages {
|
|
|
71
71
|
mock_usdc?: MockCoinPackage;
|
|
72
72
|
mock_usdsui?: MockCoinPackage;
|
|
73
73
|
mock_sui?: MockCoinPackage;
|
|
74
|
-
waterx_rule?: BasePackageEntry;
|
|
75
74
|
waterx_rule_nautilus_enclave?: BasePackageEntry;
|
|
76
75
|
}
|
|
77
76
|
export declare const WORMHOLE_DEFAULTS: Record<Network, WormholeInfraConfig>;
|
|
@@ -4,28 +4,29 @@
|
|
|
4
4
|
* `waterx-config` repo (default: GitHub raw).
|
|
5
5
|
*
|
|
6
6
|
* The schema mirrors the canonical JSON layout one-to-one (each package
|
|
7
|
-
* groups its own object IDs + per-ticker maps). External chain infra
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* groups its own object IDs + per-ticker maps). External chain infra is
|
|
8
|
+
* **not** in the JSON — each oracle source owns its own per-network table
|
|
9
|
+
* (`PYTH_CORE_INFRA` in `oracle/pyth.ts`, `LAZER_INFRA` in
|
|
10
|
+
* `oracle/rules/pyth-lazer-rule.ts`); Wormhole bridge infra lives in
|
|
11
|
+
* `WORMHOLE_DEFAULTS` below.
|
|
11
12
|
*/
|
|
12
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.WORMHOLE_DEFAULTS =
|
|
14
|
+
exports.WORMHOLE_DEFAULTS = void 0;
|
|
14
15
|
exports.clearConfigCache = clearConfigCache;
|
|
15
16
|
exports.loadConfig = loadConfig;
|
|
16
17
|
const update_fetch_ts_1 = require("../oracle/update-fetch.js");
|
|
17
|
-
var config_ts_1 = require("../oracle/config.js");
|
|
18
|
-
Object.defineProperty(exports, "PYTH_DEFAULTS", { enumerable: true, get: function () { return config_ts_1.PYTH_DEFAULTS; } });
|
|
19
18
|
// ============================================================================
|
|
20
|
-
// Wormhole
|
|
19
|
+
// Wormhole — external chain infra, defaults by network
|
|
21
20
|
// ============================================================================
|
|
22
21
|
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
22
|
+
// Oracle-source infra lives with each source (`PYTH_CORE_INFRA` in
|
|
23
|
+
// `oracle/pyth.ts`, `LAZER_INFRA` in `oracle/rules/pyth-lazer-rule.ts`);
|
|
24
|
+
// `client.pyth` is the caller-supplied access slice only (`PythAccessConfig`,
|
|
25
|
+
// re-exported at the top of this file).
|
|
25
26
|
// `WormholeInfraConfig` is defined in `account/config.ts` (funding base) and
|
|
26
27
|
// re-exported at the top of this file. `state_id` is the same shared Sui
|
|
27
28
|
// Wormhole `State` object Pyth uses (kept in sync with
|
|
28
|
-
// `
|
|
29
|
+
// `PYTH_CORE_INFRA[*].wormhole_state_id`).
|
|
29
30
|
exports.WORMHOLE_DEFAULTS = {
|
|
30
31
|
MAINNET: {
|
|
31
32
|
state_id: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
export * from "../constants.ts";
|
|
2
|
-
/** Default crypto market trading fee rate (3 bps). Per-market value lives in MarketConfig. */
|
|
3
|
-
export declare const CRYPTO_FEE_RATE = 0.0003;
|
|
4
|
-
/** Default stock / commodity market trading fee rate (5 bps). Per-market value lives in MarketConfig. */
|
|
5
|
-
export declare const STOCK_FEE_RATE = 0.0005;
|
|
6
|
-
/** Default maintenance margin rate (150 bps = 1.5%). Per-market value lives in MarketConfig. */
|
|
7
|
-
export declare const MAINTENANCE_MARGIN_RATE = 0.015;
|
|
8
2
|
export declare const PERM_OPEN_POSITION = 1;
|
|
9
3
|
export declare const PERM_CLOSE_POSITION = 2;
|
|
10
4
|
export declare const PERM_INCREASE_POSITION = 4;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Perp-line domain constants (trading permissions / order tags / action codes /
|
|
3
|
-
//
|
|
3
|
+
// well-known addresses). Re-exports the shared primitives from
|
|
4
4
|
// `../constants.ts` so perp code and the `./perp` barrel get the full set from
|
|
5
5
|
// a single import.
|
|
6
|
+
//
|
|
7
|
+
// NOTE: there are deliberately NO fee-rate / maintenance-margin constants here.
|
|
8
|
+
// `CRYPTO_FEE_RATE` / `STOCK_FEE_RATE` / `MAINTENANCE_MARGIN_RATE` were removed
|
|
9
|
+
// — they were defaults masquerading as truth; per-market `MarketConfig` on
|
|
10
|
+
// chain is the only source for fee and margin parameters (real MMRs span
|
|
11
|
+
// 0.5%–5%; the flat 1.5% understated AAPLX-class risk >3x — mainnet incident
|
|
12
|
+
// 2026-07-28: shorts displayed liq ~$364 but were liquidated at ~$343). When
|
|
13
|
+
// the market rate is unavailable, treat the value as NOT estimable and fail
|
|
14
|
+
// safe — never substitute a flat default.
|
|
6
15
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
16
|
if (k2 === undefined) k2 = k;
|
|
8
17
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -18,15 +27,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
27
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
28
|
};
|
|
20
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.ACCUMULATOR_ROOT = exports.ACTION_ADD_PRE_ORDER = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_UPDATE_ORDER = exports.ACTION_DECREASE_POSITION = exports.ACTION_INCREASE_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_CANCEL_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_CLOSE_POSITION = exports.ACTION_OPEN_POSITION = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_ALL = exports.PERM_ALL_TRADING = exports.PERM_REDEEM_WLP = exports.PERM_MINT_WLP = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_CANCEL_ORDER = exports.PERM_PLACE_ORDER = exports.PERM_DECREASE_POSITION = exports.PERM_INCREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_OPEN_POSITION =
|
|
30
|
+
exports.ACCUMULATOR_ROOT = exports.ACTION_ADD_PRE_ORDER = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_UPDATE_ORDER = exports.ACTION_DECREASE_POSITION = exports.ACTION_INCREASE_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_CANCEL_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_CLOSE_POSITION = exports.ACTION_OPEN_POSITION = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_ALL = exports.PERM_ALL_TRADING = exports.PERM_REDEEM_WLP = exports.PERM_MINT_WLP = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_CANCEL_ORDER = exports.PERM_PLACE_ORDER = exports.PERM_DECREASE_POSITION = exports.PERM_INCREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_OPEN_POSITION = void 0;
|
|
22
31
|
__exportStar(require("../constants.js"), exports);
|
|
23
|
-
// ======== Fee rates & risk parameters ========
|
|
24
|
-
/** Default crypto market trading fee rate (3 bps). Per-market value lives in MarketConfig. */
|
|
25
|
-
exports.CRYPTO_FEE_RATE = 0.0003;
|
|
26
|
-
/** Default stock / commodity market trading fee rate (5 bps). Per-market value lives in MarketConfig. */
|
|
27
|
-
exports.STOCK_FEE_RATE = 0.0005;
|
|
28
|
-
/** Default maintenance margin rate (150 bps = 1.5%). Per-market value lives in MarketConfig. */
|
|
29
|
-
exports.MAINTENANCE_MARGIN_RATE = 0.015;
|
|
30
32
|
// ======== Permission Bitmasks (matches account_data.move) ========
|
|
31
33
|
exports.PERM_OPEN_POSITION = 1;
|
|
32
34
|
exports.PERM_CLOSE_POSITION = 2;
|
|
@@ -56,6 +56,9 @@ async function getSpendableCreditBalance(client, accountId) {
|
|
|
56
56
|
(0, balance_ts_1.probeParkedBackingAssets)(client, accountId),
|
|
57
57
|
(0, balance_ts_1.probeAddressCreditBalance)(client, accountId),
|
|
58
58
|
]);
|
|
59
|
+
// COLLATERAL_DECIMALS here is the CREDIT/wxUSD *target* scale (collateral-typed;
|
|
60
|
+
// 6 on all current deployments — config carries no credit decimal). The
|
|
61
|
+
// per-asset backing decimals come from config via each row's `decimals`.
|
|
59
62
|
const pendingBackingRaw = (0, balance_ts_1.sumParkedBackingAsCreditRaw)(parkedBacking, constants_ts_1.COLLATERAL_DECIMALS);
|
|
60
63
|
const pendingCreditAtAddressRaw = addressCredit.fundsRaw + addressCredit.coinsRaw;
|
|
61
64
|
const totalRaw = internalRaw + pendingBackingRaw + pendingCreditAtAddressRaw;
|
|
@@ -10,6 +10,7 @@ const bcs_1 = require("@mysten/sui/bcs");
|
|
|
10
10
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
11
11
|
const withdrawal_queue_ts_1 = require("../../generated/withdrawal_queue/withdrawal_queue.js");
|
|
12
12
|
const wormhole_bridge_ts_1 = require("../../generated/wormhole_bridge/wormhole_bridge.js");
|
|
13
|
+
const validate_ts_1 = require("../../utils/validate.js");
|
|
13
14
|
const simulate_ts_1 = require("./simulate.js");
|
|
14
15
|
/**
|
|
15
16
|
* Batched read of the bridge's rate-limit / cap state in a single simulate.
|
|
@@ -100,7 +101,7 @@ function requireWithdrawalQueue(client) {
|
|
|
100
101
|
*/
|
|
101
102
|
async function getBridgeFee(client, args) {
|
|
102
103
|
const { pkg, queue } = requireWithdrawalQueue(client);
|
|
103
|
-
const amount =
|
|
104
|
+
const amount = (0, validate_ts_1.toU64)(args.amount, "amount");
|
|
104
105
|
const common = {
|
|
105
106
|
package: pkg,
|
|
106
107
|
typeArguments: [args.creditType ?? client.creditType()],
|
|
@@ -12,6 +12,7 @@ exports.getGlobalConfigData = getGlobalConfigData;
|
|
|
12
12
|
const bcs_1 = require("@mysten/sui/bcs");
|
|
13
13
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
14
14
|
const view_ts_1 = require("../../generated/waterx_perp_view/view.js");
|
|
15
|
+
const validate_ts_1 = require("../../utils/validate.js");
|
|
15
16
|
const simulate_ts_1 = require("./simulate.js");
|
|
16
17
|
/**
|
|
17
18
|
* Look up the registered AccountData for a given wxa account ID.
|
|
@@ -59,7 +60,7 @@ async function getTokenPoolData(client, args) {
|
|
|
59
60
|
package: client.config.packages.waterx_perp_view.published_at,
|
|
60
61
|
arguments: {
|
|
61
62
|
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
62
|
-
tokenIndex: args.tokenIndex,
|
|
63
|
+
tokenIndex: (0, validate_ts_1.toU64)(args.tokenIndex, "tokenIndex"),
|
|
63
64
|
},
|
|
64
65
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
65
66
|
})(tx);
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* list (`waterx_perp_view`).
|
|
4
4
|
*/
|
|
5
5
|
import { OrderData, PositionData, RedeemRequestData } from "../../generated/waterx_perp_view/view.ts";
|
|
6
|
+
import { parseWholeDollarU64, type WholeDollarUsdPrice } from "../../utils/validate.ts";
|
|
6
7
|
import type { PerpClient } from "../client.ts";
|
|
8
|
+
export { parseWholeDollarU64, type WholeDollarUsdPrice };
|
|
7
9
|
export type PositionDataView = ReturnType<typeof PositionData.parse>;
|
|
8
10
|
export declare function positionExists(client: PerpClient, args: {
|
|
9
11
|
ticker: string;
|
|
@@ -13,9 +15,8 @@ export declare function positionExists(client: PerpClient, args: {
|
|
|
13
15
|
export declare function getPosition(client: PerpClient, args: {
|
|
14
16
|
ticker: string;
|
|
15
17
|
positionId: bigint | number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
collateralPriceUsd: bigint | number;
|
|
18
|
+
basePriceUsd: WholeDollarUsdPrice;
|
|
19
|
+
collateralPriceUsd: WholeDollarUsdPrice;
|
|
19
20
|
lpType?: string;
|
|
20
21
|
}): Promise<PositionDataView>;
|
|
21
22
|
export type OrderDataView = ReturnType<typeof OrderData.parse>;
|
|
@@ -23,8 +24,9 @@ export declare function getOrder(client: PerpClient, args: {
|
|
|
23
24
|
ticker: string;
|
|
24
25
|
orderId: bigint | number;
|
|
25
26
|
orderTypeTag: number;
|
|
27
|
+
/** Raw 1e9-scaled u128 order-book key — same scale as tx-build `rawPrice()`. */
|
|
26
28
|
triggerPrice: bigint | number;
|
|
27
|
-
basePriceUsd:
|
|
29
|
+
basePriceUsd: WholeDollarUsdPrice;
|
|
28
30
|
lpType?: string;
|
|
29
31
|
}): Promise<OrderDataView>;
|
|
30
32
|
export interface PageOpts {
|
|
@@ -33,7 +35,8 @@ export interface PageOpts {
|
|
|
33
35
|
}
|
|
34
36
|
export declare function getMarketOrders(client: PerpClient, args: {
|
|
35
37
|
ticker: string;
|
|
36
|
-
|
|
38
|
+
/** Defaults to `0n`. */
|
|
39
|
+
basePriceUsd?: WholeDollarUsdPrice;
|
|
37
40
|
lpType?: string;
|
|
38
41
|
} & PageOpts): Promise<{
|
|
39
42
|
orders: OrderDataView[];
|
|
@@ -41,8 +44,9 @@ export declare function getMarketOrders(client: PerpClient, args: {
|
|
|
41
44
|
}>;
|
|
42
45
|
export declare function getMarketPositions(client: PerpClient, args: {
|
|
43
46
|
ticker: string;
|
|
44
|
-
basePriceUsd:
|
|
45
|
-
|
|
47
|
+
basePriceUsd: WholeDollarUsdPrice;
|
|
48
|
+
/** Defaults to `0n`. */
|
|
49
|
+
collateralPriceUsd?: WholeDollarUsdPrice;
|
|
46
50
|
lpType?: string;
|
|
47
51
|
} & PageOpts): Promise<{
|
|
48
52
|
positions: PositionDataView[];
|
|
@@ -51,14 +55,16 @@ export declare function getMarketPositions(client: PerpClient, args: {
|
|
|
51
55
|
export declare function getAccountPositions(client: PerpClient, args: {
|
|
52
56
|
ticker: string;
|
|
53
57
|
accountObjectAddress: string;
|
|
54
|
-
basePriceUsd:
|
|
55
|
-
|
|
58
|
+
basePriceUsd: WholeDollarUsdPrice;
|
|
59
|
+
/** Defaults to `0n`. */
|
|
60
|
+
collateralPriceUsd?: WholeDollarUsdPrice;
|
|
56
61
|
lpType?: string;
|
|
57
62
|
}): Promise<PositionDataView[]>;
|
|
58
63
|
export declare function getAccountOrders(client: PerpClient, args: {
|
|
59
64
|
ticker: string;
|
|
60
65
|
accountObjectAddress: string;
|
|
61
|
-
|
|
66
|
+
/** Defaults to `0n`. */
|
|
67
|
+
basePriceUsd?: WholeDollarUsdPrice;
|
|
62
68
|
lpType?: string;
|
|
63
69
|
}): Promise<OrderDataView[]>;
|
|
64
70
|
export type RedeemRequestDataView = ReturnType<typeof RedeemRequestData.parse>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* list (`waterx_perp_view`).
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.parseWholeDollarU64 = void 0;
|
|
7
8
|
exports.positionExists = positionExists;
|
|
8
9
|
exports.getPosition = getPosition;
|
|
9
10
|
exports.getOrder = getOrder;
|
|
@@ -15,6 +16,8 @@ exports.getRedeemRequests = getRedeemRequests;
|
|
|
15
16
|
const bcs_1 = require("@mysten/sui/bcs");
|
|
16
17
|
const transactions_1 = require("@mysten/sui/transactions");
|
|
17
18
|
const view_ts_1 = require("../../generated/waterx_perp_view/view.js");
|
|
19
|
+
const validate_ts_1 = require("../../utils/validate.js");
|
|
20
|
+
Object.defineProperty(exports, "parseWholeDollarU64", { enumerable: true, get: function () { return validate_ts_1.parseWholeDollarU64; } });
|
|
18
21
|
const constants_ts_1 = require("../constants.js");
|
|
19
22
|
const simulate_ts_1 = require("./simulate.js");
|
|
20
23
|
async function positionExists(client, args) {
|
|
@@ -24,7 +27,7 @@ async function positionExists(client, args) {
|
|
|
24
27
|
arguments: {
|
|
25
28
|
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
26
29
|
ticker: args.ticker,
|
|
27
|
-
positionId: args.positionId,
|
|
30
|
+
positionId: (0, validate_ts_1.toU64)(args.positionId, "positionId"),
|
|
28
31
|
},
|
|
29
32
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
30
33
|
})(tx);
|
|
@@ -39,9 +42,9 @@ async function getPosition(client, args) {
|
|
|
39
42
|
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
40
43
|
ticker: args.ticker,
|
|
41
44
|
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
42
|
-
basePriceUsd: args.basePriceUsd,
|
|
43
|
-
collateralPriceUsd: args.collateralPriceUsd,
|
|
44
|
-
positionId: args.positionId,
|
|
45
|
+
basePriceUsd: (0, validate_ts_1.toU64)(args.basePriceUsd, "basePriceUsd"),
|
|
46
|
+
collateralPriceUsd: (0, validate_ts_1.toU64)(args.collateralPriceUsd, "collateralPriceUsd"),
|
|
47
|
+
positionId: (0, validate_ts_1.toU64)(args.positionId, "positionId"),
|
|
45
48
|
},
|
|
46
49
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
47
50
|
})(tx);
|
|
@@ -54,10 +57,10 @@ async function getOrder(client, args) {
|
|
|
54
57
|
arguments: {
|
|
55
58
|
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
56
59
|
ticker: args.ticker,
|
|
57
|
-
basePriceUsd: args.basePriceUsd,
|
|
58
|
-
orderTypeTag: args.orderTypeTag,
|
|
59
|
-
triggerPrice: args.triggerPrice,
|
|
60
|
-
orderId: args.orderId,
|
|
60
|
+
basePriceUsd: (0, validate_ts_1.toU64)(args.basePriceUsd, "basePriceUsd"),
|
|
61
|
+
orderTypeTag: (0, validate_ts_1.toU8)(args.orderTypeTag, "orderTypeTag"),
|
|
62
|
+
triggerPrice: (0, validate_ts_1.toU128)(args.triggerPrice, "triggerPrice"),
|
|
63
|
+
orderId: (0, validate_ts_1.toU64)(args.orderId, "orderId"),
|
|
61
64
|
},
|
|
62
65
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
63
66
|
})(tx);
|
|
@@ -70,9 +73,9 @@ async function getMarketOrders(client, args) {
|
|
|
70
73
|
arguments: {
|
|
71
74
|
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
72
75
|
ticker: args.ticker,
|
|
73
|
-
basePriceUsd: args.basePriceUsd ?? 0n,
|
|
74
|
-
cursor: args.cursor ?? 0n,
|
|
75
|
-
pageSize: args.pageSize ?? 100n,
|
|
76
|
+
basePriceUsd: (0, validate_ts_1.toU64)(args.basePriceUsd ?? 0n, "basePriceUsd"),
|
|
77
|
+
cursor: (0, validate_ts_1.toU64)(args.cursor ?? 0n, "cursor"),
|
|
78
|
+
pageSize: (0, validate_ts_1.toU64)(args.pageSize ?? 100n, "pageSize"),
|
|
76
79
|
},
|
|
77
80
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
78
81
|
})(tx);
|
|
@@ -104,10 +107,10 @@ async function getMarketPositions(client, args) {
|
|
|
104
107
|
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
105
108
|
ticker: args.ticker,
|
|
106
109
|
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
107
|
-
basePriceUsd: args.basePriceUsd,
|
|
108
|
-
collateralPriceUsd: args.collateralPriceUsd ?? 0n,
|
|
109
|
-
cursor: args.cursor ?? 0n,
|
|
110
|
-
pageSize: args.pageSize ?? 100n,
|
|
110
|
+
basePriceUsd: (0, validate_ts_1.toU64)(args.basePriceUsd, "basePriceUsd"),
|
|
111
|
+
collateralPriceUsd: (0, validate_ts_1.toU64)(args.collateralPriceUsd ?? 0n, "collateralPriceUsd"),
|
|
112
|
+
cursor: (0, validate_ts_1.toU64)(args.cursor ?? 0n, "cursor"),
|
|
113
|
+
pageSize: (0, validate_ts_1.toU64)(args.pageSize ?? 100n, "pageSize"),
|
|
111
114
|
},
|
|
112
115
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
113
116
|
})(tx);
|
|
@@ -140,8 +143,8 @@ async function getAccountPositions(client, args) {
|
|
|
140
143
|
ticker: args.ticker,
|
|
141
144
|
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
142
145
|
wxaRegistry: tx.object(client.config.packages.waterx_account.account_registry),
|
|
143
|
-
basePriceUsd: args.basePriceUsd,
|
|
144
|
-
collateralPriceUsd: args.collateralPriceUsd ?? 0n,
|
|
146
|
+
basePriceUsd: (0, validate_ts_1.toU64)(args.basePriceUsd, "basePriceUsd"),
|
|
147
|
+
collateralPriceUsd: (0, validate_ts_1.toU64)(args.collateralPriceUsd ?? 0n, "collateralPriceUsd"),
|
|
145
148
|
accountObjectAddress: args.accountObjectAddress,
|
|
146
149
|
},
|
|
147
150
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
@@ -155,7 +158,7 @@ async function getAccountOrders(client, args) {
|
|
|
155
158
|
arguments: {
|
|
156
159
|
marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
|
|
157
160
|
ticker: args.ticker,
|
|
158
|
-
basePriceUsd: args.basePriceUsd ?? 0n,
|
|
161
|
+
basePriceUsd: (0, validate_ts_1.toU64)(args.basePriceUsd ?? 0n, "basePriceUsd"),
|
|
159
162
|
accountObjectAddress: args.accountObjectAddress,
|
|
160
163
|
},
|
|
161
164
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
@@ -168,8 +171,8 @@ async function getRedeemRequests(client, args = {}) {
|
|
|
168
171
|
package: client.config.packages.waterx_perp_view.published_at,
|
|
169
172
|
arguments: {
|
|
170
173
|
pool: tx.object(client.config.packages.wlp.wlp_pool),
|
|
171
|
-
cursor: args.cursor ?? 0n,
|
|
172
|
-
pageSize: args.pageSize ?? 100n,
|
|
174
|
+
cursor: (0, validate_ts_1.toU64)(args.cursor ?? 0n, "cursor"),
|
|
175
|
+
pageSize: (0, validate_ts_1.toU64)(args.pageSize ?? 100n, "pageSize"),
|
|
173
176
|
},
|
|
174
177
|
typeArguments: [(0, simulate_ts_1.withLp)(client, args.lpType)],
|
|
175
178
|
})(tx);
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
export { PerpClient } from "./client.ts";
|
|
2
2
|
export type { CreateClientOptions } from "./client.ts";
|
|
3
|
-
export {
|
|
4
|
-
export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage,
|
|
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,
|
|
3
|
+
export { WORMHOLE_DEFAULTS, clearConfigCache, loadConfig } from "./config.ts";
|
|
4
|
+
export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, PythRulePackage, PythSponsorRulePackage, SupraFeedEntry, SupraRulePackage, TestnetFaucetPackage, WaterXConfig, WaterXPackages, WaterxCreditPackage, WaterxOraclePackage, WaterxPerpMarketEntry, WaterxPerpPackage, WaterxStakingPackage, WithdrawalQueuePackage, WlpPackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "./config.ts";
|
|
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
7
|
export { getMarketTickers, getCollateralAssets } from "../utils/config.ts";
|
|
8
|
-
export { annualizedApyFromRatio, annualizeFundingRate, calcBorrowRate, calcBorrowRateAccrual, calcDynamicFeeBps, calcEffectiveCollateralUsd, calcEstLiqPrice, calcFee, calcFundingFeeUsd, calcFundingRate, calcImpactFeeRate, calcLeverage, calcMaxReducibleCollateralUsd, calcNotional, calcPositionBorrowFee, calcTokenUtilizationBps, calcTotalTradingFeeRate, calcUnrealizedPnl, calcWlpIncentiveApy, calcWlpMintOut, calcWlpPrice, calcWlpRedeemOut, decodeFundingIndexDelta, rawPrice, } from "../utils/math.ts";
|
|
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
|
+
export type { ExactDecimalUsd, LiqFeeBundle, RawPriceInput } from "../utils/math.ts";
|
|
10
|
+
export { formatFundingInterval } from "../utils/format.ts";
|
|
11
|
+
export { calcEstLiqPriceRawFromView } from "./liq-view.ts";
|
|
12
|
+
export type { EstLiqPriceViewOpts } from "./liq-view.ts";
|
|
9
13
|
export * from "./user/index.ts";
|
|
10
14
|
export * from "./tx-builders.ts";
|
|
11
15
|
export * from "./fetch.ts";
|
|
12
|
-
export { FetchPolicyError, LazerApiKeyMissingError, OracleFeeSourceUnavailableError, OracleSourceNotImplementedError, PythCache, aggregateTicker, aggregateTickerWithConstant, aggregateTickerWithPyth, buildPythPriceUpdateCalls, fetchPriceFeedsUpdateData, refreshOraclePrices, updatePythPrices, } from "../oracle/index.ts";
|
|
16
|
+
export { FetchPolicyError, LazerApiKeyMissingError, OracleFeeSourceUnavailableError, OracleSourceNotImplementedError, PythCache, aggregateTicker, aggregateTickerWithConstant, aggregateTickerWithPyth, buildPythPriceUpdateCalls, fetchPriceFeedsUpdateData, pythCoreHermesEndpoint, pythProHermesEndpoint, resolveHermesReadEndpoint, waterxQuoteCenterEndpoint, refreshOraclePrices, updatePythPrices, } from "../oracle/index.ts";
|
|
13
17
|
export type { FetchPolicy, OracleFeeSource, OracleSource, UpdateDataProvider, } from "../oracle/index.ts";
|
|
14
18
|
export { fetchDepositVaa, fetchVaa, listBridgeWithdrawalVaas, listVaasByEmitter, padEvmEmitter, toWormholescanEmitter, vaaBase64ToBytes, vaaBase64ToHex, vaaBytesToBase64, waitForVaa, } from "../account/funding/wormhole.ts";
|
|
15
19
|
export type { VaaListItem, VaaResponse, WormholescanOptions } from "../account/funding/wormhole.ts";
|
|
@@ -36,14 +36,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TOKEN_DECIMALS = exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.MS_PER_YEAR = exports.
|
|
40
|
-
exports.
|
|
41
|
-
exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.pythSponsorRuleCalls = exports.pythRuleCalls = 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 = void 0;
|
|
39
|
+
exports.getCollateralAssets = 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.padEvmEmitter = exports.listVaasByEmitter = exports.listBridgeWithdrawalVaas = exports.fetchVaa = exports.fetchDepositVaa = exports.updatePythPrices = exports.refreshOraclePrices = exports.waterxQuoteCenterEndpoint = exports.resolveHermesReadEndpoint = exports.pythProHermesEndpoint = exports.pythCoreHermesEndpoint = exports.fetchPriceFeedsUpdateData = exports.buildPythPriceUpdateCalls = exports.aggregateTickerWithPyth = exports.aggregateTickerWithConstant = exports.aggregateTicker = exports.PythCache = exports.OracleSourceNotImplementedError = exports.OracleFeeSourceUnavailableError = 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 = exports.annualizedApyFromRatio = void 0;
|
|
41
|
+
exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.pythSponsorRuleCalls = exports.pythRuleCalls = 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 = 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; } });
|
|
45
45
|
var config_ts_1 = require("./config.js");
|
|
46
|
-
Object.defineProperty(exports, "PYTH_DEFAULTS", { enumerable: true, get: function () { return config_ts_1.PYTH_DEFAULTS; } });
|
|
47
46
|
Object.defineProperty(exports, "WORMHOLE_DEFAULTS", { enumerable: true, get: function () { return config_ts_1.WORMHOLE_DEFAULTS; } });
|
|
48
47
|
Object.defineProperty(exports, "clearConfigCache", { enumerable: true, get: function () { return config_ts_1.clearConfigCache; } });
|
|
49
48
|
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_ts_1.loadConfig; } });
|
|
@@ -62,11 +61,9 @@ Object.defineProperty(exports, "ACTION_PLACE_ORDER", { enumerable: true, get: fu
|
|
|
62
61
|
Object.defineProperty(exports, "ACTION_UPDATE_ORDER", { enumerable: true, get: function () { return constants_ts_1.ACTION_UPDATE_ORDER; } });
|
|
63
62
|
Object.defineProperty(exports, "ACTION_WITHDRAW_COLLATERAL", { enumerable: true, get: function () { return constants_ts_1.ACTION_WITHDRAW_COLLATERAL; } });
|
|
64
63
|
Object.defineProperty(exports, "BPS_SCALE", { enumerable: true, get: function () { return constants_ts_1.BPS_SCALE; } });
|
|
65
|
-
Object.defineProperty(exports, "CRYPTO_FEE_RATE", { enumerable: true, get: function () { return constants_ts_1.CRYPTO_FEE_RATE; } });
|
|
66
64
|
Object.defineProperty(exports, "DOUBLE_SCALE", { enumerable: true, get: function () { return constants_ts_1.DOUBLE_SCALE; } });
|
|
67
65
|
Object.defineProperty(exports, "DRY_RUN_SENDER", { enumerable: true, get: function () { return constants_ts_1.DRY_RUN_SENDER; } });
|
|
68
66
|
Object.defineProperty(exports, "FLOAT_SCALE", { enumerable: true, get: function () { return constants_ts_1.FLOAT_SCALE; } });
|
|
69
|
-
Object.defineProperty(exports, "MAINTENANCE_MARGIN_RATE", { enumerable: true, get: function () { return constants_ts_1.MAINTENANCE_MARGIN_RATE; } });
|
|
70
67
|
Object.defineProperty(exports, "ORDER_LIMIT_BUY", { enumerable: true, get: function () { return constants_ts_1.ORDER_LIMIT_BUY; } });
|
|
71
68
|
Object.defineProperty(exports, "ORDER_LIMIT_SELL", { enumerable: true, get: function () { return constants_ts_1.ORDER_LIMIT_SELL; } });
|
|
72
69
|
Object.defineProperty(exports, "ORDER_STOP_BUY", { enumerable: true, get: function () { return constants_ts_1.ORDER_STOP_BUY; } });
|
|
@@ -88,7 +85,8 @@ Object.defineProperty(exports, "STAKING_PERM_DEPOSIT_STAKE", { enumerable: true,
|
|
|
88
85
|
Object.defineProperty(exports, "STAKING_PERM_REDEEM_STAKE", { enumerable: true, get: function () { return constants_ts_1.STAKING_PERM_REDEEM_STAKE; } });
|
|
89
86
|
Object.defineProperty(exports, "STAKING_PERM_CLAIM_REWARD", { enumerable: true, get: function () { return constants_ts_1.STAKING_PERM_CLAIM_REWARD; } });
|
|
90
87
|
Object.defineProperty(exports, "STAKING_PERM_ALL", { enumerable: true, get: function () { return constants_ts_1.STAKING_PERM_ALL; } });
|
|
91
|
-
Object.defineProperty(exports, "
|
|
88
|
+
Object.defineProperty(exports, "MS_PER_MINUTE", { enumerable: true, get: function () { return constants_ts_1.MS_PER_MINUTE; } });
|
|
89
|
+
Object.defineProperty(exports, "MS_PER_HOUR", { enumerable: true, get: function () { return constants_ts_1.MS_PER_HOUR; } });
|
|
92
90
|
Object.defineProperty(exports, "MS_PER_YEAR", { enumerable: true, get: function () { return constants_ts_1.MS_PER_YEAR; } });
|
|
93
91
|
Object.defineProperty(exports, "SUI_DECIMALS", { enumerable: true, get: function () { return constants_ts_1.SUI_DECIMALS; } });
|
|
94
92
|
Object.defineProperty(exports, "WLP_DECIMALS", { enumerable: true, get: function () { return constants_ts_1.WLP_DECIMALS; } });
|
|
@@ -106,6 +104,7 @@ Object.defineProperty(exports, "calcBorrowRateAccrual", { enumerable: true, get:
|
|
|
106
104
|
Object.defineProperty(exports, "calcDynamicFeeBps", { enumerable: true, get: function () { return math_ts_1.calcDynamicFeeBps; } });
|
|
107
105
|
Object.defineProperty(exports, "calcEffectiveCollateralUsd", { enumerable: true, get: function () { return math_ts_1.calcEffectiveCollateralUsd; } });
|
|
108
106
|
Object.defineProperty(exports, "calcEstLiqPrice", { enumerable: true, get: function () { return math_ts_1.calcEstLiqPrice; } });
|
|
107
|
+
Object.defineProperty(exports, "calcEstLiqPriceRaw", { enumerable: true, get: function () { return math_ts_1.calcEstLiqPriceRaw; } });
|
|
109
108
|
Object.defineProperty(exports, "calcFee", { enumerable: true, get: function () { return math_ts_1.calcFee; } });
|
|
110
109
|
Object.defineProperty(exports, "calcFundingFeeUsd", { enumerable: true, get: function () { return math_ts_1.calcFundingFeeUsd; } });
|
|
111
110
|
Object.defineProperty(exports, "calcFundingRate", { enumerable: true, get: function () { return math_ts_1.calcFundingRate; } });
|
|
@@ -114,15 +113,21 @@ Object.defineProperty(exports, "calcLeverage", { enumerable: true, get: function
|
|
|
114
113
|
Object.defineProperty(exports, "calcMaxReducibleCollateralUsd", { enumerable: true, get: function () { return math_ts_1.calcMaxReducibleCollateralUsd; } });
|
|
115
114
|
Object.defineProperty(exports, "calcNotional", { enumerable: true, get: function () { return math_ts_1.calcNotional; } });
|
|
116
115
|
Object.defineProperty(exports, "calcPositionBorrowFee", { enumerable: true, get: function () { return math_ts_1.calcPositionBorrowFee; } });
|
|
116
|
+
Object.defineProperty(exports, "calcRealLiqNetCostUsd", { enumerable: true, get: function () { return math_ts_1.calcRealLiqNetCostUsd; } });
|
|
117
117
|
Object.defineProperty(exports, "calcTokenUtilizationBps", { enumerable: true, get: function () { return math_ts_1.calcTokenUtilizationBps; } });
|
|
118
118
|
Object.defineProperty(exports, "calcTotalTradingFeeRate", { enumerable: true, get: function () { return math_ts_1.calcTotalTradingFeeRate; } });
|
|
119
119
|
Object.defineProperty(exports, "calcUnrealizedPnl", { enumerable: true, get: function () { return math_ts_1.calcUnrealizedPnl; } });
|
|
120
|
+
Object.defineProperty(exports, "calcViewEstLiqFeesUsd", { enumerable: true, get: function () { return math_ts_1.calcViewEstLiqFeesUsd; } });
|
|
120
121
|
Object.defineProperty(exports, "calcWlpIncentiveApy", { enumerable: true, get: function () { return math_ts_1.calcWlpIncentiveApy; } });
|
|
121
122
|
Object.defineProperty(exports, "calcWlpMintOut", { enumerable: true, get: function () { return math_ts_1.calcWlpMintOut; } });
|
|
122
123
|
Object.defineProperty(exports, "calcWlpPrice", { enumerable: true, get: function () { return math_ts_1.calcWlpPrice; } });
|
|
123
124
|
Object.defineProperty(exports, "calcWlpRedeemOut", { enumerable: true, get: function () { return math_ts_1.calcWlpRedeemOut; } });
|
|
124
125
|
Object.defineProperty(exports, "decodeFundingIndexDelta", { enumerable: true, get: function () { return math_ts_1.decodeFundingIndexDelta; } });
|
|
125
126
|
Object.defineProperty(exports, "rawPrice", { enumerable: true, get: function () { return math_ts_1.rawPrice; } });
|
|
127
|
+
var format_ts_1 = require("../utils/format.js");
|
|
128
|
+
Object.defineProperty(exports, "formatFundingInterval", { enumerable: true, get: function () { return format_ts_1.formatFundingInterval; } });
|
|
129
|
+
var liq_view_ts_1 = require("./liq-view.js");
|
|
130
|
+
Object.defineProperty(exports, "calcEstLiqPriceRawFromView", { enumerable: true, get: function () { return liq_view_ts_1.calcEstLiqPriceRawFromView; } });
|
|
126
131
|
// ======== Transaction builders (user-side) ========
|
|
127
132
|
__exportStar(require("./user/index.js"), exports);
|
|
128
133
|
// ======== High-level Tx builders ========
|
|
@@ -141,6 +146,10 @@ Object.defineProperty(exports, "aggregateTickerWithConstant", { enumerable: true
|
|
|
141
146
|
Object.defineProperty(exports, "aggregateTickerWithPyth", { enumerable: true, get: function () { return index_ts_1.aggregateTickerWithPyth; } });
|
|
142
147
|
Object.defineProperty(exports, "buildPythPriceUpdateCalls", { enumerable: true, get: function () { return index_ts_1.buildPythPriceUpdateCalls; } });
|
|
143
148
|
Object.defineProperty(exports, "fetchPriceFeedsUpdateData", { enumerable: true, get: function () { return index_ts_1.fetchPriceFeedsUpdateData; } });
|
|
149
|
+
Object.defineProperty(exports, "pythCoreHermesEndpoint", { enumerable: true, get: function () { return index_ts_1.pythCoreHermesEndpoint; } });
|
|
150
|
+
Object.defineProperty(exports, "pythProHermesEndpoint", { enumerable: true, get: function () { return index_ts_1.pythProHermesEndpoint; } });
|
|
151
|
+
Object.defineProperty(exports, "resolveHermesReadEndpoint", { enumerable: true, get: function () { return index_ts_1.resolveHermesReadEndpoint; } });
|
|
152
|
+
Object.defineProperty(exports, "waterxQuoteCenterEndpoint", { enumerable: true, get: function () { return index_ts_1.waterxQuoteCenterEndpoint; } });
|
|
144
153
|
Object.defineProperty(exports, "refreshOraclePrices", { enumerable: true, get: function () { return index_ts_1.refreshOraclePrices; } });
|
|
145
154
|
Object.defineProperty(exports, "updatePythPrices", { enumerable: true, get: function () { return index_ts_1.updatePythPrices; } });
|
|
146
155
|
// ======== Wormhole / Wormholescan utilities (credit bridge) ========
|