@mysten/deepbook-v3 2.0.0 → 2.1.3
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/CHANGELOG.md +100 -0
- package/PREDICT.md +256 -0
- package/README.md +116 -0
- package/dist/account.d.mts +139 -0
- package/dist/account.d.mts.map +1 -0
- package/dist/account.mjs +181 -0
- package/dist/account.mjs.map +1 -0
- package/dist/bcs/integers.mjs +23 -0
- package/dist/bcs/integers.mjs.map +1 -0
- package/dist/contracts/account/account.d.mts +382 -0
- package/dist/contracts/account/account.d.mts.map +1 -0
- package/dist/contracts/account/account.mjs +443 -0
- package/dist/contracts/account/account.mjs.map +1 -0
- package/dist/contracts/account/account_events.d.mts +41 -0
- package/dist/contracts/account/account_events.d.mts.map +1 -0
- package/dist/contracts/account/account_events.mjs +72 -0
- package/dist/contracts/account/account_events.mjs.map +1 -0
- package/dist/contracts/account/account_registry.d.mts +210 -0
- package/dist/contracts/account/account_registry.d.mts.map +1 -0
- package/dist/contracts/account/account_registry.mjs +263 -0
- package/dist/contracts/account/account_registry.mjs.map +1 -0
- package/dist/contracts/account/config-arguments.d.mts +10 -0
- package/dist/contracts/account/config-arguments.d.mts.map +1 -0
- package/dist/contracts/account/deps/sui/bag.mjs +44 -0
- package/dist/contracts/account/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs.map +1 -1
- package/dist/contracts/deepbook/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code_events.mjs +38 -0
- package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/balance.mjs +25 -0
- package/dist/contracts/deepbook_predict/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/coin.mjs +24 -0
- package/dist/contracts/deepbook_predict/deps/sui/coin.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/ewma.mjs +29 -0
- package/dist/contracts/deepbook_predict/ewma.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs +27 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs +367 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/lp_book.mjs +92 -0
- package/dist/contracts/deepbook_predict/lp_book.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs +59 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/order.mjs +26 -0
- package/dist/contracts/deepbook_predict/order.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/order_events.mjs +84 -0
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/plp.mjs +284 -0
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +58 -0
- package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs +106 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/pricing.mjs +80 -0
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs +41 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/registry.mjs +55 -0
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +65 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_exposure_config.mjs +33 -0
- package/dist/contracts/deepbook_predict/strike_exposure_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +72 -0
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs +184 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_sessions/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +63 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.mjs +82 -0
- package/dist/contracts/deepbook_sessions/session_config.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/sessions.d.mts +275 -0
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/sessions.mjs +443 -0
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
- package/dist/contracts/utils/index.d.mts +18 -1
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/deployments/index.d.mts +31 -0
- package/dist/deployments/index.d.mts.map +1 -0
- package/dist/deployments/index.mjs +30 -0
- package/dist/deployments/index.mjs.map +1 -0
- package/dist/deployments/testnet.d.mts +14 -0
- package/dist/deployments/testnet.d.mts.map +1 -0
- package/dist/deployments/testnet.mjs +73 -0
- package/dist/deployments/testnet.mjs.map +1 -0
- package/dist/deployments/types.d.mts +36 -0
- package/dist/deployments/types.d.mts.map +1 -0
- package/dist/index.mjs +0 -1
- package/dist/predict/client.d.mts +255 -0
- package/dist/predict/client.d.mts.map +1 -0
- package/dist/predict/client.mjs +436 -0
- package/dist/predict/client.mjs.map +1 -0
- package/dist/predict/config/generated.d.mts +29 -0
- package/dist/predict/config/generated.d.mts.map +1 -0
- package/dist/predict/config/generated.mjs +16 -0
- package/dist/predict/config/generated.mjs.map +1 -0
- package/dist/predict/config/index.d.mts +10 -0
- package/dist/predict/config/index.d.mts.map +1 -0
- package/dist/predict/config/index.mjs +13 -0
- package/dist/predict/config/index.mjs.map +1 -0
- package/dist/predict/config/testnet.d.mts +17 -0
- package/dist/predict/config/testnet.d.mts.map +1 -0
- package/dist/predict/config/testnet.mjs +26 -0
- package/dist/predict/config/testnet.mjs.map +1 -0
- package/dist/predict/config/types.d.mts +55 -0
- package/dist/predict/config/types.d.mts.map +1 -0
- package/dist/predict/decode.d.mts +162 -0
- package/dist/predict/decode.d.mts.map +1 -0
- package/dist/predict/decode.mjs +175 -0
- package/dist/predict/decode.mjs.map +1 -0
- package/dist/predict/errors.d.mts +42 -0
- package/dist/predict/errors.d.mts.map +1 -0
- package/dist/predict/errors.mjs +37 -0
- package/dist/predict/errors.mjs.map +1 -0
- package/dist/predict/index.d.mts +18 -0
- package/dist/predict/index.mjs +14 -0
- package/dist/predict/pricing.d.mts +73 -0
- package/dist/predict/pricing.d.mts.map +1 -0
- package/dist/predict/pricing.mjs +129 -0
- package/dist/predict/pricing.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +41 -0
- package/dist/predict/reads/balances.mjs.map +1 -0
- package/dist/predict/reads/inspect.d.mts +8 -0
- package/dist/predict/reads/inspect.d.mts.map +1 -0
- package/dist/predict/reads/inspect.mjs +37 -0
- package/dist/predict/reads/inspect.mjs.map +1 -0
- package/dist/predict/reads/markets.mjs +130 -0
- package/dist/predict/reads/markets.mjs.map +1 -0
- package/dist/predict/reads/parse.mjs +20 -0
- package/dist/predict/reads/parse.mjs.map +1 -0
- package/dist/predict/reads/pool.mjs +26 -0
- package/dist/predict/reads/pool.mjs.map +1 -0
- package/dist/predict/reads/positions.d.mts +12 -0
- package/dist/predict/reads/positions.d.mts.map +1 -0
- package/dist/predict/reads/positions.mjs +77 -0
- package/dist/predict/reads/positions.mjs.map +1 -0
- package/dist/predict/reads/pricing.d.mts +20 -0
- package/dist/predict/reads/pricing.d.mts.map +1 -0
- package/dist/predict/reads/pricing.mjs +43 -0
- package/dist/predict/reads/pricing.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +11 -0
- package/dist/predict/ticks.d.mts.map +1 -0
- package/dist/predict/ticks.mjs +21 -0
- package/dist/predict/ticks.mjs.map +1 -0
- package/dist/predict/tx/authed.mjs +18 -0
- package/dist/predict/tx/authed.mjs.map +1 -0
- package/dist/predict/tx/common.d.mts +18 -0
- package/dist/predict/tx/common.d.mts.map +1 -0
- package/dist/predict/tx/common.mjs +52 -0
- package/dist/predict/tx/common.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts +15 -0
- package/dist/predict/tx/trade.d.mts.map +1 -0
- package/dist/predict/tx/trade.mjs +86 -0
- package/dist/predict/tx/trade.mjs.map +1 -0
- package/dist/predict/units.d.mts +11 -0
- package/dist/predict/units.d.mts.map +1 -0
- package/dist/predict/units.mjs +44 -0
- package/dist/predict/units.mjs.map +1 -0
- package/dist/queries/accountQueries.mjs +0 -1
- package/dist/queries/accountQueries.mjs.map +1 -1
- package/dist/queries/orderQueries.mjs +0 -1
- package/dist/queries/orderQueries.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +0 -1
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/sessions.d.mts +244 -0
- package/dist/sessions.d.mts.map +1 -0
- package/dist/sessions.mjs +291 -0
- package/dist/sessions.mjs.map +1 -0
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +1 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +33 -12
- package/src/account.ts +239 -0
- package/src/bcs/integers.ts +35 -0
- package/src/contracts/account/account.ts +706 -0
- package/src/contracts/account/account_events.ts +64 -0
- package/src/contracts/account/account_registry.ts +468 -0
- package/src/contracts/account/config-arguments.ts +8 -0
- package/src/contracts/account/deps/sui/bag.ts +42 -0
- package/src/contracts/deepbook/balance_manager.ts +1 -2
- package/src/contracts/deepbook/pool.ts +12 -24
- package/src/contracts/deepbook/registry.ts +1 -2
- package/src/contracts/deepbook_margin/margin_manager.ts +9 -18
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +5 -10
- package/src/contracts/deepbook_margin/margin_pool.ts +2 -4
- package/src/contracts/deepbook_margin/margin_registry.ts +3 -6
- package/src/contracts/deepbook_margin/pool_proxy.ts +3 -6
- package/src/contracts/deepbook_margin/protocol_config.ts +1 -2
- package/src/contracts/deepbook_margin/tpsl.ts +1 -2
- package/src/contracts/deepbook_predict/admin.ts +44 -0
- package/src/contracts/deepbook_predict/builder_code.ts +155 -0
- package/src/contracts/deepbook_predict/builder_code_events.ts +34 -0
- package/src/contracts/deepbook_predict/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict/config_events.ts +140 -0
- package/src/contracts/deepbook_predict/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict/deps/sui/balance.ts +25 -0
- package/src/contracts/deepbook_predict/deps/sui/coin.ts +20 -0
- package/src/contracts/deepbook_predict/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_predict/ewma.ts +26 -0
- package/src/contracts/deepbook_predict/ewma_config.ts +28 -0
- package/src/contracts/deepbook_predict/expiry_cash.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +1549 -0
- package/src/contracts/deepbook_predict/lp_book.ts +105 -0
- package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +75 -0
- package/src/contracts/deepbook_predict/market_manager.ts +218 -0
- package/src/contracts/deepbook_predict/order.ts +24 -0
- package/src/contracts/deepbook_predict/order_events.ts +129 -0
- package/src/contracts/deepbook_predict/pause_cap.ts +68 -0
- package/src/contracts/deepbook_predict/plp.ts +987 -0
- package/src/contracts/deepbook_predict/pool_accounting.ts +79 -0
- package/src/contracts/deepbook_predict/predict_account.ts +180 -0
- package/src/contracts/deepbook_predict/pricing.ts +124 -0
- package/src/contracts/deepbook_predict/pricing_config.ts +41 -0
- package/src/contracts/deepbook_predict/protocol_config.ts +1066 -0
- package/src/contracts/deepbook_predict/range_codec.ts +53 -0
- package/src/contracts/deepbook_predict/registry.ts +694 -0
- package/src/contracts/deepbook_predict/strike_exposure.ts +77 -0
- package/src/contracts/deepbook_predict/strike_exposure_config.ts +46 -0
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +89 -0
- package/src/contracts/deepbook_predict/vault_events.ts +222 -0
- package/src/contracts/deepbook_sessions/config-arguments.ts +8 -0
- package/src/contracts/deepbook_sessions/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_sessions/session_config.ts +130 -0
- package/src/contracts/deepbook_sessions/sessions.ts +663 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +2 -4
- package/src/contracts/propbook/block_scholes_store.ts +842 -0
- package/src/contracts/propbook/deps/sui/table.ts +37 -0
- package/src/contracts/propbook/oracle_lane.ts +170 -0
- package/src/contracts/propbook/pyth_feed.ts +414 -0
- package/src/contracts/propbook/registry.ts +596 -0
- package/src/contracts/pyth/pyth.ts +2 -4
- package/src/deployments/index.ts +73 -0
- package/src/deployments/testnet.ts +107 -0
- package/src/deployments/types.ts +81 -0
- package/src/index.ts +5 -0
- package/src/predict/client.ts +941 -0
- package/src/predict/config/generated.ts +39 -0
- package/src/predict/config/index.ts +25 -0
- package/src/predict/config/testnet.ts +27 -0
- package/src/predict/config/types.ts +52 -0
- package/src/predict/decode.ts +476 -0
- package/src/predict/errors.ts +83 -0
- package/src/predict/index.ts +94 -0
- package/src/predict/pricing.ts +199 -0
- package/src/predict/reads/balances.ts +55 -0
- package/src/predict/reads/inspect.ts +78 -0
- package/src/predict/reads/markets.ts +222 -0
- package/src/predict/reads/parse.ts +30 -0
- package/src/predict/reads/pool.ts +37 -0
- package/src/predict/reads/positions.ts +144 -0
- package/src/predict/reads/pricing.ts +79 -0
- package/src/predict/ticks.ts +42 -0
- package/src/predict/tx/authed.ts +20 -0
- package/src/predict/tx/common.ts +92 -0
- package/src/predict/tx/trade.ts +183 -0
- package/src/predict/units.ts +49 -0
- package/src/sessions.ts +471 -0
- package/src/types/index.ts +1 -2
- package/src/utils/constants.ts +1 -7
- package/dist/types/bcs.mjs +0 -7
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DeploymentInfo, DeploymentUnits } from "./types.mjs";
|
|
2
|
+
import { TESTNET_DEPLOYMENT, TESTNET_UNITS } from "./testnet.mjs";
|
|
3
|
+
import { SuiClientTypes } from "@mysten/sui/client";
|
|
4
|
+
|
|
5
|
+
//#region src/deployments/index.d.ts
|
|
6
|
+
/** Networks this package carries ids for. Predict and sessions are testnet-only so far. */
|
|
7
|
+
type DeployedNetwork = 'testnet';
|
|
8
|
+
/**
|
|
9
|
+
* Accepts the same wide network type the Sui client exposes, so `getUnits(client.network)`
|
|
10
|
+
* composes. Narrowing to `DeployedNetwork` would reject that, and listing
|
|
11
|
+
* `'testnet' | 'mainnet'` would be worse still: it admits exactly one value that always
|
|
12
|
+
* throws while rejecting `'devnet'` at compile time.
|
|
13
|
+
*/
|
|
14
|
+
type NetworkArg = SuiClientTypes.Network;
|
|
15
|
+
/**
|
|
16
|
+
* @description Which deployment the ids on `network` came from — its name and the
|
|
17
|
+
* deepbookv3 commit they were generated at. Useful when a bug report needs to say which
|
|
18
|
+
* on-chain deployment an SDK build was pinned to.
|
|
19
|
+
* @throws if the network has no deployment recorded, rather than returning placeholder ids.
|
|
20
|
+
*/
|
|
21
|
+
declare function getDeployment(network: NetworkArg): DeploymentInfo;
|
|
22
|
+
/**
|
|
23
|
+
* @description Scale constants for `network` — lot size, fixed-point scale, and coin
|
|
24
|
+
* decimals. Deployment-wide, so any subpath formatting a custody balance can read them
|
|
25
|
+
* rather than hardcoding 6.
|
|
26
|
+
* @throws if the network has no recorded deployment.
|
|
27
|
+
*/
|
|
28
|
+
declare function getUnits(network: NetworkArg): DeploymentUnits;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { DeployedNetwork, NetworkArg, getDeployment, getUnits };
|
|
31
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/deployments/index.ts"],"mappings":";;;;;;KAkCY,eAAA;AAwBZ;;;;;;AAAA,KAhBY,UAAA,GAAa,cAAA,CAAe,OAAA;;;AA2BxC;;;;iBAXgB,aAAA,CAAc,OAAA,EAAS,UAAA,GAAa,cAAA;;;;;;;iBAWpC,QAAA,CAAS,OAAA,EAAS,UAAA,GAAa,eAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TESTNET_ACCOUNT, TESTNET_DEPLOYMENT, TESTNET_PREDICT, TESTNET_SESSIONS, TESTNET_UNITS } from "./testnet.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/deployments/index.ts
|
|
4
|
+
function unrecorded(network, override) {
|
|
5
|
+
return /* @__PURE__ */ new Error(`@mysten/deepbook-v3: no deployment recorded for network '${network}'. Predict, sessions and the account primitive are testnet-only today. For your own deployment, ${override}`);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @description Which deployment the ids on `network` came from — its name and the
|
|
9
|
+
* deepbookv3 commit they were generated at. Useful when a bug report needs to say which
|
|
10
|
+
* on-chain deployment an SDK build was pinned to.
|
|
11
|
+
* @throws if the network has no deployment recorded, rather than returning placeholder ids.
|
|
12
|
+
*/
|
|
13
|
+
function getDeployment(network) {
|
|
14
|
+
if (network === "testnet") return TESTNET_DEPLOYMENT;
|
|
15
|
+
throw unrecorded(network, "read the deployment name and commit from your own deploy manifest.");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description Scale constants for `network` — lot size, fixed-point scale, and coin
|
|
19
|
+
* decimals. Deployment-wide, so any subpath formatting a custody balance can read them
|
|
20
|
+
* rather than hardcoding 6.
|
|
21
|
+
* @throws if the network has no recorded deployment.
|
|
22
|
+
*/
|
|
23
|
+
function getUnits(network) {
|
|
24
|
+
if (network === "testnet") return TESTNET_UNITS;
|
|
25
|
+
throw unrecorded(network, "read these scale constants from your own deploy manifest.");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getDeployment, getUnits };
|
|
30
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/deployments/index.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Canonical per-network deployment ids.\n *\n * Every subpath reads its slice of this one record rather than carrying its own copy, so a\n * redeploy is a single regeneration (`pnpm sync-deployment`) and the subpaths cannot end up\n * addressing different deployments. The records themselves are generated from the deploy\n * tooling's manifest — see `scripts/sync-deployment.ts`.\n */\n\nimport type { SuiClientTypes } from '@mysten/sui/client';\n\nimport {\n\tTESTNET_ACCOUNT,\n\tTESTNET_DEPLOYMENT,\n\tTESTNET_PREDICT,\n\tTESTNET_SESSIONS,\n\tTESTNET_UNITS,\n} from './testnet.js';\nimport type { DeploymentInfo, DeploymentUnits } from './types.js';\n\nexport type {\n\tAccountIds,\n\tDeploymentInfo,\n\tDeploymentUnits,\n\tPredictIds,\n\tSessionsIds,\n} from './types.js';\n\nexport { TESTNET_ACCOUNT, TESTNET_DEPLOYMENT, TESTNET_PREDICT, TESTNET_SESSIONS, TESTNET_UNITS };\n\n/** Networks this package carries ids for. Predict and sessions are testnet-only so far. */\nexport type DeployedNetwork = 'testnet';\n\n/**\n * Accepts the same wide network type the Sui client exposes, so `getUnits(client.network)`\n * composes. Narrowing to `DeployedNetwork` would reject that, and listing\n * `'testnet' | 'mainnet'` would be worse still: it admits exactly one value that always\n * throws while rejecting `'devnet'` at compile time.\n */\nexport type NetworkArg = SuiClientTypes.Network;\n\nfunction unrecorded(network: string, override: string): Error {\n\treturn new Error(\n\t\t`@mysten/deepbook-v3: no deployment recorded for network '${network}'. ` +\n\t\t\t'Predict, sessions and the account primitive are testnet-only today. ' +\n\t\t\t`For your own deployment, ${override}`,\n\t);\n}\n\n/**\n * @description Which deployment the ids on `network` came from — its name and the\n * deepbookv3 commit they were generated at. Useful when a bug report needs to say which\n * on-chain deployment an SDK build was pinned to.\n * @throws if the network has no deployment recorded, rather than returning placeholder ids.\n */\nexport function getDeployment(network: NetworkArg): DeploymentInfo {\n\tif (network === 'testnet') return TESTNET_DEPLOYMENT;\n\tthrow unrecorded(network, 'read the deployment name and commit from your own deploy manifest.');\n}\n\n/**\n * @description Scale constants for `network` — lot size, fixed-point scale, and coin\n * decimals. Deployment-wide, so any subpath formatting a custody balance can read them\n * rather than hardcoding 6.\n * @throws if the network has no recorded deployment.\n */\nexport function getUnits(network: NetworkArg): DeploymentUnits {\n\tif (network === 'testnet') return TESTNET_UNITS;\n\tthrow unrecorded(network, 'read these scale constants from your own deploy manifest.');\n}\n"],"mappings":";;;AA4CA,SAAS,WAAW,SAAiB,UAAyB;AAC7D,wBAAO,IAAI,MACV,4DAA4D,QAAQ,kGAEvC,WAC7B;;;;;;;;AASF,SAAgB,cAAc,SAAqC;AAClE,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,WAAW,SAAS,qEAAqE;;;;;;;;AAShG,SAAgB,SAAS,SAAsC;AAC9D,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,WAAW,SAAS,4DAA4D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeploymentInfo, DeploymentUnits } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/deployments/testnet.d.ts
|
|
4
|
+
/** Which on-chain deployment the ids below came from. */
|
|
5
|
+
declare const TESTNET_DEPLOYMENT: DeploymentInfo;
|
|
6
|
+
/**
|
|
7
|
+
* Scale constants the deployment owns rather than the SDK. Deployment-wide:
|
|
8
|
+
* `quoteCoinDecimals` and `fixedPointScale` apply to any subpath formatting a custody
|
|
9
|
+
* balance, not just Predict.
|
|
10
|
+
*/
|
|
11
|
+
declare const TESTNET_UNITS: DeploymentUnits;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { TESTNET_DEPLOYMENT, TESTNET_UNITS };
|
|
14
|
+
//# sourceMappingURL=testnet.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testnet.d.mts","names":[],"sources":["../../src/deployments/testnet.ts"],"mappings":";;;;cA2Ba,kBAAA,EAAoB,cAAA;;;;;;cAqCpB,aAAA,EAAe,eAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/deployments/testnet.ts
|
|
2
|
+
/** Which on-chain deployment the ids below came from. */
|
|
3
|
+
const TESTNET_DEPLOYMENT = Object.freeze({
|
|
4
|
+
deployment: "predict-testnet-8-21",
|
|
5
|
+
network: "testnet",
|
|
6
|
+
chainId: "4c78adac",
|
|
7
|
+
sourceCommit: "1f79fe87ab2f6b9df40cfdc2e647c93f45e6d737"
|
|
8
|
+
});
|
|
9
|
+
/** Ids for the shared `account` primitive — the `/account` subpath's slice. */
|
|
10
|
+
const TESTNET_ACCOUNT = Object.freeze({
|
|
11
|
+
accountPackageId: "0xa94ec89b6cbb3e2609c7ca65bd77885b7513f852922ebdf8e766851fb6f85259",
|
|
12
|
+
accountRegistry: "0x5682c73d657de1546374e632369a25c82744c8a20e9b4f47e6558e3d4bde88d3"
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Ids for time-limited sessions — the `/sessions` subpath's slice.
|
|
16
|
+
*
|
|
17
|
+
* `deepbookRegistry` is only needed by the DeepBook **spot** session wrappers; the Predict
|
|
18
|
+
* wrappers never take it. It is carried here so a spot caller does not have to reach into
|
|
19
|
+
* the package root for one id.
|
|
20
|
+
*/
|
|
21
|
+
const TESTNET_SESSIONS = Object.freeze({
|
|
22
|
+
sessionsPackageId: "0xb74170443d6d2d37cbe95c7e530dd4a1605ef714ff4f9e88e27a7ac1455451db",
|
|
23
|
+
sessionsConfig: "0xdfb8e23246678649cfdd6f3f6610057d5cadd6a8911a21dbe8e34788abbfab93",
|
|
24
|
+
accountPackageId: "0xa94ec89b6cbb3e2609c7ca65bd77885b7513f852922ebdf8e766851fb6f85259",
|
|
25
|
+
accountRegistry: "0x5682c73d657de1546374e632369a25c82744c8a20e9b4f47e6558e3d4bde88d3",
|
|
26
|
+
deepbookRegistry: "0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1",
|
|
27
|
+
deepbookCoreAccountPackageId: "0xcc9cf1029127e7bda6da4c2ab90164d7bef751783ff13c21c2bb804cec69ebec",
|
|
28
|
+
protocolConfig: "0x7ef1ac99c2f0a77e7aa2602b5ea7bff68750cff0d80f09bdf827bfb345128f33"
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Scale constants the deployment owns rather than the SDK. Deployment-wide:
|
|
32
|
+
* `quoteCoinDecimals` and `fixedPointScale` apply to any subpath formatting a custody
|
|
33
|
+
* balance, not just Predict.
|
|
34
|
+
*/
|
|
35
|
+
const TESTNET_UNITS = Object.freeze({
|
|
36
|
+
positionLotSize: 1e4,
|
|
37
|
+
fixedPointScale: 1e9,
|
|
38
|
+
quoteCoinDecimals: 6,
|
|
39
|
+
positionQuantityDecimals: 6
|
|
40
|
+
});
|
|
41
|
+
/** Ids for DeepBook Predict — the `/predict` subpath's slice. */
|
|
42
|
+
const TESTNET_PREDICT = Object.freeze({
|
|
43
|
+
network: "testnet",
|
|
44
|
+
packages: Object.freeze({
|
|
45
|
+
predict: "0x421041754244cf0e985fb9c9f5e1f49428caf3df4cde3a7b266d8e18ea63597b",
|
|
46
|
+
account: "0xa94ec89b6cbb3e2609c7ca65bd77885b7513f852922ebdf8e766851fb6f85259",
|
|
47
|
+
propbook: "0xd8b402609b1728f60cf20bfaaec5255701df54350ec13e93aac39463b00bf97b"
|
|
48
|
+
}),
|
|
49
|
+
objects: Object.freeze({
|
|
50
|
+
registry: "0x3d486bd50bb5bb5450ddbcb4f74776b6135f416c09024a6674ac266e77e1870a",
|
|
51
|
+
protocolConfig: "0x7ef1ac99c2f0a77e7aa2602b5ea7bff68750cff0d80f09bdf827bfb345128f33",
|
|
52
|
+
poolVault: "0x2a31f592d8fd3d0781e2233770d02d67797890ac82c3d18796d7eb0997896602",
|
|
53
|
+
oracleRegistry: "0x715f5ae4aac0078f4d0c6bf9ea2815614e799e909a90b577aeb8de9ad8bab142",
|
|
54
|
+
accountRegistry: "0x5682c73d657de1546374e632369a25c82744c8a20e9b4f47e6558e3d4bde88d3"
|
|
55
|
+
}),
|
|
56
|
+
quoteCoinType: "0xe95040085976bfd54a1a07225cd46c8a2b4e8e2b6732f140a0fc49850ba73e1a::dusdc::DUSDC",
|
|
57
|
+
coinTypes: Object.freeze({
|
|
58
|
+
plp: "0x421041754244cf0e985fb9c9f5e1f49428caf3df4cde3a7b266d8e18ea63597b::plp::PLP",
|
|
59
|
+
deep: "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"
|
|
60
|
+
}),
|
|
61
|
+
units: TESTNET_UNITS,
|
|
62
|
+
underlyings: Object.freeze({ BTC: Object.freeze({
|
|
63
|
+
symbol: "BTC",
|
|
64
|
+
propbookUnderlyingId: 1,
|
|
65
|
+
pythFeed: "0xea8fd4624002516b28b495051c838b2c9a34a4f22ae281d328e1bec47f54cd24",
|
|
66
|
+
blockScholesValueStore: "0x9b64cc860ac09e6dcd675fc579c1048792ddce51cc018f2ca16aeb4a1a5684a3",
|
|
67
|
+
blockScholesSviStore: "0xd5bc586e99c8d595e0ba5e0a2ef2295e652db8934ffbeda630d60e207bedab8f"
|
|
68
|
+
}) })
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { TESTNET_ACCOUNT, TESTNET_DEPLOYMENT, TESTNET_PREDICT, TESTNET_SESSIONS, TESTNET_UNITS };
|
|
73
|
+
//# sourceMappingURL=testnet.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testnet.mjs","names":[],"sources":["../../src/deployments/testnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// GENERATED by `pnpm sync-deployment` from the deploy tooling's own manifest\n// (`packages/predict/deployment/deployment.testnet.json`). Do not hand-edit:\n// the next regeneration overwrites it, and a hand-patched id is exactly the drift this\n// file exists to prevent. To move to a new deployment, check the sibling deepbookv3\n// checkout out to the new anchor and re-run the script.\n//\n// Deployment: predict-testnet-8-21\n// sourceCommit: 1f79fe87ab2f6b9df40cfdc2e647c93f45e6d737\n//\n// Runtime-dependency-free — every subpath reads a slice of this, so a value import here\n// would pull that module into all of their graphs. The type import below is erased.\n//\n// Frozen: these are shared module singletons, so an accessor handing one to a caller who\n// mutates it would change what every other caller sees.\n\nimport type {\n\tAccountIds,\n\tDeploymentInfo,\n\tDeploymentUnits,\n\tPredictIds,\n\tSessionsIds,\n} from './types.js';\n\n/** Which on-chain deployment the ids below came from. */\nexport const TESTNET_DEPLOYMENT: DeploymentInfo = Object.freeze({\n\tdeployment: 'predict-testnet-8-21',\n\tnetwork: 'testnet',\n\tchainId: '4c78adac',\n\tsourceCommit: '1f79fe87ab2f6b9df40cfdc2e647c93f45e6d737',\n});\n\n/** Ids for the shared `account` primitive — the `/account` subpath's slice. */\nexport const TESTNET_ACCOUNT: AccountIds = Object.freeze({\n\taccountPackageId: '0xa94ec89b6cbb3e2609c7ca65bd77885b7513f852922ebdf8e766851fb6f85259',\n\taccountRegistry: '0x5682c73d657de1546374e632369a25c82744c8a20e9b4f47e6558e3d4bde88d3',\n});\n\n/**\n * Ids for time-limited sessions — the `/sessions` subpath's slice.\n *\n * `deepbookRegistry` is only needed by the DeepBook **spot** session wrappers; the Predict\n * wrappers never take it. It is carried here so a spot caller does not have to reach into\n * the package root for one id.\n */\nexport const TESTNET_SESSIONS: SessionsIds = Object.freeze({\n\tsessionsPackageId: '0xb74170443d6d2d37cbe95c7e530dd4a1605ef714ff4f9e88e27a7ac1455451db',\n\tsessionsConfig: '0xdfb8e23246678649cfdd6f3f6610057d5cadd6a8911a21dbe8e34788abbfab93',\n\taccountPackageId: '0xa94ec89b6cbb3e2609c7ca65bd77885b7513f852922ebdf8e766851fb6f85259',\n\taccountRegistry: '0x5682c73d657de1546374e632369a25c82744c8a20e9b4f47e6558e3d4bde88d3',\n\tdeepbookRegistry: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',\n\tdeepbookCoreAccountPackageId:\n\t\t'0xcc9cf1029127e7bda6da4c2ab90164d7bef751783ff13c21c2bb804cec69ebec',\n\t/** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */\n\tprotocolConfig: '0x7ef1ac99c2f0a77e7aa2602b5ea7bff68750cff0d80f09bdf827bfb345128f33',\n});\n\n/**\n * Scale constants the deployment owns rather than the SDK. Deployment-wide:\n * `quoteCoinDecimals` and `fixedPointScale` apply to any subpath formatting a custody\n * balance, not just Predict.\n */\nexport const TESTNET_UNITS: DeploymentUnits = Object.freeze({\n\tpositionLotSize: 10000,\n\tfixedPointScale: 1000000000,\n\tquoteCoinDecimals: 6,\n\tpositionQuantityDecimals: 6,\n});\n\n/** Ids for DeepBook Predict — the `/predict` subpath's slice. */\nexport const TESTNET_PREDICT: PredictIds = Object.freeze({\n\tnetwork: 'testnet',\n\tpackages: Object.freeze({\n\t\tpredict: '0x421041754244cf0e985fb9c9f5e1f49428caf3df4cde3a7b266d8e18ea63597b',\n\t\taccount: '0xa94ec89b6cbb3e2609c7ca65bd77885b7513f852922ebdf8e766851fb6f85259',\n\t\tpropbook: '0xd8b402609b1728f60cf20bfaaec5255701df54350ec13e93aac39463b00bf97b',\n\t}),\n\tobjects: Object.freeze({\n\t\tregistry: '0x3d486bd50bb5bb5450ddbcb4f74776b6135f416c09024a6674ac266e77e1870a',\n\t\tprotocolConfig: '0x7ef1ac99c2f0a77e7aa2602b5ea7bff68750cff0d80f09bdf827bfb345128f33',\n\t\tpoolVault: '0x2a31f592d8fd3d0781e2233770d02d67797890ac82c3d18796d7eb0997896602',\n\t\toracleRegistry: '0x715f5ae4aac0078f4d0c6bf9ea2815614e799e909a90b577aeb8de9ad8bab142',\n\t\taccountRegistry: '0x5682c73d657de1546374e632369a25c82744c8a20e9b4f47e6558e3d4bde88d3',\n\t}),\n\tquoteCoinType: '0xe95040085976bfd54a1a07225cd46c8a2b4e8e2b6732f140a0fc49850ba73e1a::dusdc::DUSDC',\n\t/**\n\t * `plp` is the LP share coin type. It is NOT derivable from `packages.predict`: a Move\n\t * type tag keeps the ORIGINAL package id across an upgrade, while `packages.predict`\n\t * moves to the latest. They agree only while predict is at v1.\n\t */\n\tcoinTypes: Object.freeze({\n\t\tplp: '0x421041754244cf0e985fb9c9f5e1f49428caf3df4cde3a7b266d8e18ea63597b::plp::PLP',\n\t\tdeep: '0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP',\n\t}),\n\tunits: TESTNET_UNITS,\n\tunderlyings: Object.freeze({\n\t\tBTC: Object.freeze({\n\t\t\tsymbol: 'BTC',\n\t\t\tpropbookUnderlyingId: 1,\n\t\t\tpythFeed: '0xea8fd4624002516b28b495051c838b2c9a34a4f22ae281d328e1bec47f54cd24',\n\t\t\tblockScholesValueStore: '0x9b64cc860ac09e6dcd675fc579c1048792ddce51cc018f2ca16aeb4a1a5684a3',\n\t\t\tblockScholesSviStore: '0xd5bc586e99c8d595e0ba5e0a2ef2295e652db8934ffbeda630d60e207bedab8f',\n\t\t}),\n\t}),\n});\n"],"mappings":";;AA2BA,MAAa,qBAAqC,OAAO,OAAO;CAC/D,YAAY;CACZ,SAAS;CACT,SAAS;CACT,cAAc;CACd,CAAC;;AAGF,MAAa,kBAA8B,OAAO,OAAO;CACxD,kBAAkB;CAClB,iBAAiB;CACjB,CAAC;;;;;;;;AASF,MAAa,mBAAgC,OAAO,OAAO;CAC1D,mBAAmB;CACnB,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;CAClB,8BACC;CAED,gBAAgB;CAChB,CAAC;;;;;;AAOF,MAAa,gBAAiC,OAAO,OAAO;CAC3D,iBAAiB;CACjB,iBAAiB;CACjB,mBAAmB;CACnB,0BAA0B;CAC1B,CAAC;;AAGF,MAAa,kBAA8B,OAAO,OAAO;CACxD,SAAS;CACT,UAAU,OAAO,OAAO;EACvB,SAAS;EACT,SAAS;EACT,UAAU;EACV,CAAC;CACF,SAAS,OAAO,OAAO;EACtB,UAAU;EACV,gBAAgB;EAChB,WAAW;EACX,gBAAgB;EAChB,iBAAiB;EACjB,CAAC;CACF,eAAe;CAMf,WAAW,OAAO,OAAO;EACxB,KAAK;EACL,MAAM;EACN,CAAC;CACF,OAAO;CACP,aAAa,OAAO,OAAO,EAC1B,KAAK,OAAO,OAAO;EAClB,QAAQ;EACR,sBAAsB;EACtB,UAAU;EACV,wBAAwB;EACxB,sBAAsB;EACtB,CAAC,EACF,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/deployments/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shapes for the generated deployment records.
|
|
4
|
+
*
|
|
5
|
+
* The generated file annotates each record with one of these rather than using `as const`.
|
|
6
|
+
* That matters for consumers: `as const` would publish the literal ids in the `.d.mts`, so
|
|
7
|
+
* `getDeployment('testnet').network === 'mainnet'` would be a compile ERROR rather than
|
|
8
|
+
* `false`, spreading a record to override one field would fail, and every redeploy would
|
|
9
|
+
* silently change the published types.
|
|
10
|
+
*/
|
|
11
|
+
/** Which on-chain deployment a set of ids came from. */
|
|
12
|
+
interface DeploymentInfo {
|
|
13
|
+
deployment: string;
|
|
14
|
+
network: string;
|
|
15
|
+
chainId: string;
|
|
16
|
+
/** The deepbookv3 commit the deployed Move sources were built from. */
|
|
17
|
+
sourceCommit: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Scale constants the deployment owns rather than the SDK.
|
|
21
|
+
*
|
|
22
|
+
* Only `positionLotSize` is currently read by the SDK (`PredictClient#assertLot`); the other
|
|
23
|
+
* three are shipped as the deployment's own record of its scales. `units.ts` still hardcodes
|
|
24
|
+
* the DUSDC and fixed-point decimals, so do not read this as "the SDK derives its scaling
|
|
25
|
+
* from here" — wiring that up is separate work.
|
|
26
|
+
*/
|
|
27
|
+
interface DeploymentUnits {
|
|
28
|
+
/** Predict-only: order quantity must be a whole number of these. */
|
|
29
|
+
positionLotSize: number;
|
|
30
|
+
fixedPointScale: number;
|
|
31
|
+
quoteCoinDecimals: number;
|
|
32
|
+
positionQuantityDecimals: number;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { DeploymentInfo, DeploymentUnits };
|
|
36
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/deployments/types.ts"],"mappings":";;AAcA;;;;;;;;;UAAiB,cAAA;EAChB,UAAA;EACA,OAAA;EACA,OAAA;EAa+B;EAX/B,YAAA;AAAA;;;;;;;;;UAWgB,eAAA;;EAEhB,eAAA;EACA,eAAA;EACA,iBAAA;EACA,wBAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { Balances } from "./contracts/deepbook/balances.mjs";
|
|
|
3
3
|
import { Account } from "./contracts/deepbook/account.mjs";
|
|
4
4
|
import { OrderDeepPrice } from "./contracts/deepbook/deep_price.mjs";
|
|
5
5
|
import { Order } from "./contracts/deepbook/order.mjs";
|
|
6
|
-
import "./types/bcs.mjs";
|
|
7
6
|
import { BalanceManagerContract } from "./transactions/balanceManager.mjs";
|
|
8
7
|
import { ConfigurationError, DeepBookError, ErrorMessages, ResourceNotFoundError, ValidationError } from "./utils/errors.mjs";
|
|
9
8
|
import { DEEPBOOK_HERMES_PROXY, PYTH_UPGRADED_HERMES, mainnetCoins, mainnetMarginPools, mainnetPackageIds, mainnetPools, mainnetPythConfigs, testnetCoins, testnetMarginPools, testnetPackageIds, testnetPools, testnetPythConfigs } from "./utils/constants.mjs";
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { PredictConfig } from "./config/types.mjs";
|
|
2
|
+
import { BalanceChangeReceipt, BuilderCodeReceipt, ClaimReceipt, CreateManagerReceipt, DecodableTransactionResult, MintReceipt, PlpCancelReceipt, PlpRequestReceipt, RedeemReceipt } from "./decode.mjs";
|
|
3
|
+
import { OpenPosition } from "./reads/positions.mjs";
|
|
4
|
+
import { BoardPricer } from "./pricing.mjs";
|
|
5
|
+
import { PricerSnapshot } from "./reads/pricing.mjs";
|
|
6
|
+
import { Side } from "./ticks.mjs";
|
|
7
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
8
|
+
import { ClientWithCoreApi, SuiClientRegistration } from "@mysten/sui/client";
|
|
9
|
+
|
|
10
|
+
//#region src/predict/client.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Testnet's `position_lot_size`, read from the deployment record. Validation uses the lot
|
|
13
|
+
* size of the config actually in play; this is the convenience constant for testnet callers.
|
|
14
|
+
*/
|
|
15
|
+
declare const POSITION_LOT_SIZE: bigint;
|
|
16
|
+
/** A live/settled market addressed by its human coordinates: a binary position
|
|
17
|
+
* (single strike + side) or a two-strike range position. */
|
|
18
|
+
type MarketDescriptor = {
|
|
19
|
+
underlying: string;
|
|
20
|
+
expiryMs: number | bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Pin resolution to this exact `ExpiryMarket` object, skipping the
|
|
23
|
+
* underlying+expiry lookup — a caller that reviewed a specific market object
|
|
24
|
+
* mints against exactly that object, not whatever resolves at submit time.
|
|
25
|
+
*/
|
|
26
|
+
marketId?: string;
|
|
27
|
+
} & ({
|
|
28
|
+
side: Side;
|
|
29
|
+
/**
|
|
30
|
+
* Strike in USD, or "reference" to trade at the market's on-chain reference
|
|
31
|
+
* price (the Polymarket-style anchor: derived from the exact previous-window
|
|
32
|
+
* oracle observation, so consecutive windows chain settlement → next strike).
|
|
33
|
+
*/
|
|
34
|
+
strike: number | 'reference';
|
|
35
|
+
} | {
|
|
36
|
+
/** A range position: pays out when settlement lands inside `(lower, upper]`
|
|
37
|
+
* (left-open, right-closed — same convention as the on-chain range key). */
|
|
38
|
+
side: 'range'; /** Lower strike bound in USD — finite, on the tick grid. */
|
|
39
|
+
lower: number; /** Upper strike bound in USD — finite, on the tick grid, above `lower`. */
|
|
40
|
+
upper: number;
|
|
41
|
+
});
|
|
42
|
+
/** Options for the friendly `mint` (exact payout quantity). */
|
|
43
|
+
interface MintOptions {
|
|
44
|
+
quantity: number;
|
|
45
|
+
maxCost?: number;
|
|
46
|
+
maxProbability?: number;
|
|
47
|
+
}
|
|
48
|
+
/** Options for `mintAmount` (spend up to a premium budget, floor the quantity received). */
|
|
49
|
+
interface MintAmountOptions {
|
|
50
|
+
/** Premium budget in quote units — the max premium paid (chain also caps it at the account balance). */
|
|
51
|
+
spend: number;
|
|
52
|
+
minQuantity: number;
|
|
53
|
+
/** All-in cost ceiling in quote units (premium + fees). Omitted → uncapped. */
|
|
54
|
+
maxCost?: number;
|
|
55
|
+
}
|
|
56
|
+
/** Options for `redeem`: which order and how much to close. `claimSettled` takes only
|
|
57
|
+
* `orderId` — a settled claim closes the order in full. */
|
|
58
|
+
interface CloseOptions {
|
|
59
|
+
orderId: bigint;
|
|
60
|
+
quantity: number;
|
|
61
|
+
}
|
|
62
|
+
/** One tradeable market as returned by read.markets(). */
|
|
63
|
+
interface ActiveMarket {
|
|
64
|
+
id: string;
|
|
65
|
+
expiryMs: bigint;
|
|
66
|
+
/** Strike granularity in USD (e.g. 0.01). */
|
|
67
|
+
tickSize: number;
|
|
68
|
+
/**
|
|
69
|
+
* Coarser step new mint strikes must align to. A numeric strike must be a whole
|
|
70
|
+
* multiple of this (the market's `referencePrice` is the one exception the chain
|
|
71
|
+
* admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`.
|
|
72
|
+
*/
|
|
73
|
+
admissionTickSize: number;
|
|
74
|
+
mintPaused: boolean;
|
|
75
|
+
/** The window's anchor strike in USD, or null until the keeper seeds it. */
|
|
76
|
+
referencePrice: number | null;
|
|
77
|
+
}
|
|
78
|
+
/** A resolved live market: its on-chain state summary for the caller. */
|
|
79
|
+
interface MarketSummary {
|
|
80
|
+
id: string;
|
|
81
|
+
expiryMs: bigint;
|
|
82
|
+
tickSize: number;
|
|
83
|
+
/**
|
|
84
|
+
* Coarser step new mint strikes must align to. A numeric strike must be a whole
|
|
85
|
+
* multiple of this (the market's `referencePrice` is the one exception the chain
|
|
86
|
+
* admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`.
|
|
87
|
+
*/
|
|
88
|
+
admissionTickSize: number;
|
|
89
|
+
mintPaused: boolean;
|
|
90
|
+
nav: number;
|
|
91
|
+
/** The window's anchor strike in USD, or null until the keeper seeds it. */
|
|
92
|
+
referencePrice: number | null;
|
|
93
|
+
}
|
|
94
|
+
/** Aggregate pool figures. Balances in human units (shares raw); the pending fields
|
|
95
|
+
* are request COUNTS, not amounts — the on-chain getters expose queue lengths, and
|
|
96
|
+
* the escrowed DUSDC/PLP behind them is tracked separately. */
|
|
97
|
+
interface PoolSummary {
|
|
98
|
+
plpTotalSupply: bigint;
|
|
99
|
+
idleUsdc: number;
|
|
100
|
+
/** Number of LP supply requests queued for the next flush. */
|
|
101
|
+
supplyRequestsPending: number;
|
|
102
|
+
/** Number of LP withdraw requests queued for the next flush. */
|
|
103
|
+
withdrawRequestsPending: number;
|
|
104
|
+
}
|
|
105
|
+
/** Exact pre-trade quote: the dry-run receipt of the mint you are about to send. */
|
|
106
|
+
interface MintQuote {
|
|
107
|
+
/** Fill price, 0..1 per $1 payout. */
|
|
108
|
+
entryProbability: number;
|
|
109
|
+
/** Premium paid into LP backing (quote units). */
|
|
110
|
+
premium: number;
|
|
111
|
+
/**
|
|
112
|
+
* Fee breakdown. `referral` is a PORTION of the trader-paid trading fee and
|
|
113
|
+
* congestion surcharge routed to the referrer — it is already inside those
|
|
114
|
+
* numbers and is NOT an extra debit. `inventoryImpact` is a separate charge and
|
|
115
|
+
* IS part of `cost`.
|
|
116
|
+
*/
|
|
117
|
+
fees: {
|
|
118
|
+
trading: number;
|
|
119
|
+
subsidy: number;
|
|
120
|
+
builder: number;
|
|
121
|
+
penalty: number;
|
|
122
|
+
referral: number;
|
|
123
|
+
inventoryImpact: number;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* All-in account debit: premium + (trading − subsidy) + builder + penalty +
|
|
127
|
+
* inventoryImpact — exactly what the chain withdraws (the deployed
|
|
128
|
+
* `compute_mint_quote`'s `all_in_cost`); pass this (plus your buffer) as maxCost.
|
|
129
|
+
*/
|
|
130
|
+
cost: number;
|
|
131
|
+
quantity: number;
|
|
132
|
+
raw: {
|
|
133
|
+
premium: bigint;
|
|
134
|
+
cost: bigint;
|
|
135
|
+
quantity: bigint;
|
|
136
|
+
entryProbability: bigint;
|
|
137
|
+
};
|
|
138
|
+
/** True: computed by the real mint code path against real account state. */
|
|
139
|
+
feesExact: true;
|
|
140
|
+
}
|
|
141
|
+
/** Exact pre-close quote: the dry-run receipt of the redeem you are about to send. */
|
|
142
|
+
interface RedeemQuote {
|
|
143
|
+
/** NET quote credited to the account. */
|
|
144
|
+
proceeds: number;
|
|
145
|
+
/** Gross close value before fees. */
|
|
146
|
+
gross: number;
|
|
147
|
+
/** `inventoryImpactRebate` is credited back on the close, so `proceeds` is
|
|
148
|
+
* gross + rebate − trading − builder − penalty. */
|
|
149
|
+
fees: {
|
|
150
|
+
trading: number;
|
|
151
|
+
builder: number;
|
|
152
|
+
penalty: number;
|
|
153
|
+
inventoryImpactRebate: number;
|
|
154
|
+
};
|
|
155
|
+
quantityClosed: number;
|
|
156
|
+
remaining: number;
|
|
157
|
+
raw: {
|
|
158
|
+
proceeds: bigint;
|
|
159
|
+
gross: bigint;
|
|
160
|
+
quantityClosed: bigint;
|
|
161
|
+
};
|
|
162
|
+
feesExact: true;
|
|
163
|
+
}
|
|
164
|
+
type BinaryMarketCoordinates = Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'> & {
|
|
165
|
+
strike: number | 'reference';
|
|
166
|
+
};
|
|
167
|
+
/** The Sui client surface PredictClient reads through: any `ClientWithCoreApi`
|
|
168
|
+
* (gRPC or JSON-RPC) provides both the `simulateTransaction` the reads/quotes
|
|
169
|
+
* sit on and the `core` object methods position enumeration needs. */
|
|
170
|
+
interface PredictCompatibleClient extends ClientWithCoreApi {}
|
|
171
|
+
/**
|
|
172
|
+
* Register PredictClient as a `client.predict` extension, mirroring
|
|
173
|
+
* `@mysten/deepbook-v3`'s `deepbook(...)`: `client.$extend(predict({ network }))`.
|
|
174
|
+
*/
|
|
175
|
+
declare function predict<Name extends string = 'predict'>({
|
|
176
|
+
name,
|
|
177
|
+
network,
|
|
178
|
+
config
|
|
179
|
+
}: {
|
|
180
|
+
name?: Name;
|
|
181
|
+
network: 'testnet' | 'mainnet';
|
|
182
|
+
config?: PredictConfig;
|
|
183
|
+
}): SuiClientRegistration<PredictCompatibleClient, Name, PredictClient>;
|
|
184
|
+
/**
|
|
185
|
+
* The one object an app constructs. Wraps the config, a client for reads, and
|
|
186
|
+
* a derived-account model so callers pass owner addresses, decimal amounts, and
|
|
187
|
+
* human market coordinates — the facade converts to raw units, resolves markets
|
|
188
|
+
* (cached), and delegates to the internal tx primitives / reads. Callers who need
|
|
189
|
+
* to compose their own PTBs can use the generated bindings under `contracts/`.
|
|
190
|
+
*/
|
|
191
|
+
declare class PredictClient {
|
|
192
|
+
#private;
|
|
193
|
+
readonly cfg: PredictConfig;
|
|
194
|
+
constructor(opts: {
|
|
195
|
+
network: 'testnet' | 'mainnet';
|
|
196
|
+
client: PredictCompatibleClient;
|
|
197
|
+
config?: PredictConfig;
|
|
198
|
+
});
|
|
199
|
+
/** The deterministic id of an owner's canonical account wrapper — no chain read. */
|
|
200
|
+
wrapperIdFor(owner: string): string;
|
|
201
|
+
readonly tx: {
|
|
202
|
+
createManager: () => Transaction;
|
|
203
|
+
deposit: (owner: string, amountUsdc: number | string, opts?: {
|
|
204
|
+
create?: boolean;
|
|
205
|
+
}) => Transaction;
|
|
206
|
+
withdraw: (owner: string, amountUsdc: number | string, opts?: {
|
|
207
|
+
toCoinObject?: boolean;
|
|
208
|
+
}) => Transaction;
|
|
209
|
+
mint: (owner: string, m: MarketDescriptor, opts: MintOptions) => Promise<Transaction>;
|
|
210
|
+
mintAmount: (owner: string, m: MarketDescriptor, opts: MintAmountOptions) => Promise<Transaction>;
|
|
211
|
+
redeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise<Transaction>;
|
|
212
|
+
claimSettled: (owner: string, m: Pick<MarketDescriptor, "underlying" | "expiryMs" | "marketId">, opts: Pick<CloseOptions, "orderId">) => Promise<Transaction>;
|
|
213
|
+
supplyPlp: (owner: string, amountUsdc: number | string) => Transaction;
|
|
214
|
+
withdrawPlp: (owner: string, shares: bigint) => Transaction;
|
|
215
|
+
cancelSupplyPlp: (owner: string, index: bigint) => Transaction;
|
|
216
|
+
cancelWithdrawPlp: (owner: string, index: bigint) => Transaction;
|
|
217
|
+
setBuilderCode: (owner: string, builderCodeId: string) => Transaction;
|
|
218
|
+
unsetBuilderCode: (owner: string) => Transaction;
|
|
219
|
+
};
|
|
220
|
+
readonly read: {
|
|
221
|
+
markets: () => Promise<ActiveMarket[]>;
|
|
222
|
+
hasPosition: (owner: string, marketId: string, orderId: bigint) => Promise<boolean>;
|
|
223
|
+
positions: (owner: string) => Promise<OpenPosition[]>;
|
|
224
|
+
price: (m: BinaryMarketCoordinates) => Promise<{
|
|
225
|
+
up: number;
|
|
226
|
+
down: number;
|
|
227
|
+
}>;
|
|
228
|
+
pricer: (m: Pick<MarketDescriptor, "underlying" | "expiryMs">) => Promise<BoardPricer & {
|
|
229
|
+
asOf: PricerSnapshot["sources"];
|
|
230
|
+
}>;
|
|
231
|
+
quoteMint: (owner: string, m: MarketDescriptor, opts: Pick<MintOptions, "quantity">) => Promise<MintQuote>;
|
|
232
|
+
quoteRedeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise<RedeemQuote>;
|
|
233
|
+
market: (m: Pick<MarketDescriptor, "underlying" | "expiryMs">) => Promise<MarketSummary | null>;
|
|
234
|
+
balance: (owner: string) => Promise<number>;
|
|
235
|
+
plpBalance: (owner: string) => Promise<bigint>;
|
|
236
|
+
pool: () => Promise<PoolSummary>;
|
|
237
|
+
};
|
|
238
|
+
readonly decode: {
|
|
239
|
+
mint: (r: DecodableTransactionResult) => MintReceipt;
|
|
240
|
+
mints: (r: DecodableTransactionResult) => MintReceipt[];
|
|
241
|
+
redeem: (r: DecodableTransactionResult) => RedeemReceipt;
|
|
242
|
+
redeems: (r: DecodableTransactionResult) => RedeemReceipt[];
|
|
243
|
+
claim: (r: DecodableTransactionResult) => ClaimReceipt;
|
|
244
|
+
claims: (r: DecodableTransactionResult) => ClaimReceipt[];
|
|
245
|
+
createManager: (r: DecodableTransactionResult) => CreateManagerReceipt;
|
|
246
|
+
deposit: (r: DecodableTransactionResult) => BalanceChangeReceipt;
|
|
247
|
+
withdraw: (r: DecodableTransactionResult) => BalanceChangeReceipt;
|
|
248
|
+
plpRequest: (r: DecodableTransactionResult) => PlpRequestReceipt;
|
|
249
|
+
plpCancel: (r: DecodableTransactionResult) => PlpCancelReceipt;
|
|
250
|
+
builderCode: (r: DecodableTransactionResult) => BuilderCodeReceipt;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
export { ActiveMarket, CloseOptions, MarketDescriptor, MarketSummary, MintAmountOptions, MintOptions, MintQuote, POSITION_LOT_SIZE, PoolSummary, PredictClient, PredictCompatibleClient, RedeemQuote, predict };
|
|
255
|
+
//# sourceMappingURL=client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../../src/predict/client.ts"],"mappings":"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"}
|