@mysten/deepbook-v3 2.6.4 → 2.8.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/CHANGELOG.md +153 -0
- package/PREDICT.md +389 -61
- package/dist/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_registry.d.mts +13 -13
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
- package/dist/contracts/deepbook_predict/config_events.d.mts +93 -68
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.mjs +45 -1
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +652 -235
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +652 -186
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/lp_book.mjs +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.mjs +3 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/plp.d.mts +184 -82
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +126 -7
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
- package/dist/contracts/deepbook_predict/pricing.d.mts +91 -58
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +30 -3
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +400 -92
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.mjs +451 -61
- package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
- package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +17 -12
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +154 -106
- package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs +57 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +106 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs +125 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts +284 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.mjs +364 -0
- package/dist/contracts/deepbook_predict_math/math.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs +87 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs +52 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts +187 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs +261 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +1042 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs +849 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts +683 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs +912 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +195 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs +187 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/sessions.d.mts +163 -28
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.mjs +234 -5
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
- package/dist/deployments/mainnet.mjs +7 -4
- package/dist/deployments/mainnet.mjs.map +1 -1
- package/dist/deployments/testnet.mjs +7 -4
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/predict/bindings/expiry-market.d.mts +77 -0
- package/dist/predict/bindings/expiry-market.d.mts.map +1 -0
- package/dist/predict/bindings/expiry-market.mjs +139 -0
- package/dist/predict/bindings/expiry-market.mjs.map +1 -0
- package/dist/predict/bindings/protocol-config.d.mts +39 -0
- package/dist/predict/bindings/protocol-config.d.mts.map +1 -0
- package/dist/predict/bindings/protocol-config.mjs +90 -0
- package/dist/predict/bindings/protocol-config.mjs.map +1 -0
- package/dist/predict/bindings/rename.mjs +9 -0
- package/dist/predict/bindings/rename.mjs.map +1 -0
- package/dist/predict/client.d.mts +595 -16
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +986 -10
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/generated.d.mts +22 -1
- package/dist/predict/config/generated.d.mts.map +1 -1
- package/dist/predict/config/generated.mjs +30 -1
- package/dist/predict/config/generated.mjs.map +1 -1
- package/dist/predict/config/mainnet.mjs +11 -3
- package/dist/predict/config/mainnet.mjs.map +1 -1
- package/dist/predict/config/testnet.mjs +11 -3
- package/dist/predict/config/testnet.mjs.map +1 -1
- package/dist/predict/config/types.d.mts +50 -1
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/cost.d.mts +38 -11
- package/dist/predict/cost.d.mts.map +1 -1
- package/dist/predict/cost.mjs +37 -11
- package/dist/predict/cost.mjs.map +1 -1
- package/dist/predict/decode.d.mts +251 -1
- package/dist/predict/decode.d.mts.map +1 -1
- package/dist/predict/decode.mjs +342 -4
- package/dist/predict/decode.mjs.map +1 -1
- package/dist/predict/errors.d.mts +69 -6
- package/dist/predict/errors.d.mts.map +1 -1
- package/dist/predict/errors.mjs +277 -4
- package/dist/predict/errors.mjs.map +1 -1
- package/dist/predict/index.d.mts +21 -10
- package/dist/predict/index.mjs +24 -12
- package/dist/predict/queue-id.d.mts +13 -0
- package/dist/predict/queue-id.d.mts.map +1 -0
- package/dist/predict/queue-id.mjs +19 -0
- package/dist/predict/queue-id.mjs.map +1 -0
- package/dist/predict/queue.d.mts +505 -0
- package/dist/predict/queue.d.mts.map +1 -0
- package/dist/predict/queue.mjs +774 -0
- package/dist/predict/queue.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +1 -1
- package/dist/predict/reads/markets.mjs +46 -5
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pool.mjs +1 -1
- package/dist/predict/reads/pricing.d.mts +1 -1
- package/dist/predict/reads/queue.d.mts +105 -0
- package/dist/predict/reads/queue.d.mts.map +1 -0
- package/dist/predict/reads/queue.mjs +445 -0
- package/dist/predict/reads/queue.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +9 -1
- package/dist/predict/ticks.d.mts.map +1 -1
- package/dist/predict/ticks.mjs +18 -1
- package/dist/predict/ticks.mjs.map +1 -1
- package/dist/predict/tx/authed.mjs +1 -1
- package/dist/predict/tx/common.d.mts.map +1 -1
- package/dist/predict/tx/common.mjs +12 -1
- package/dist/predict/tx/common.mjs.map +1 -1
- package/dist/predict/tx/queue.d.mts +220 -0
- package/dist/predict/tx/queue.d.mts.map +1 -0
- package/dist/predict/tx/queue.mjs +399 -0
- package/dist/predict/tx/queue.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts.map +1 -1
- package/dist/predict/tx/trade.mjs +61 -43
- package/dist/predict/tx/trade.mjs.map +1 -1
- package/dist/sessions.d.mts +90 -2
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +107 -2
- package/dist/sessions.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- 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/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- 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/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/package.json +4 -4
- package/src/contracts/deepbook_predict/config_events.ts +39 -0
- package/src/contracts/deepbook_predict/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +960 -169
- package/src/contracts/deepbook_predict/order_events.ts +3 -1
- package/src/contracts/deepbook_predict/plp.ts +150 -9
- package/src/contracts/deepbook_predict/pricing.ts +46 -7
- package/src/contracts/deepbook_predict/pricing_config.ts +3 -1
- package/src/contracts/deepbook_predict/protocol_config.ts +648 -33
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +25 -21
- package/src/contracts/deepbook_predict/vault_events.ts +65 -0
- package/src/contracts/deepbook_predict_math/config-arguments.ts +6 -0
- package/src/contracts/deepbook_predict_math/lazer_price.ts +196 -0
- package/src/contracts/deepbook_predict_math/math.ts +553 -0
- package/src/contracts/deepbook_predict_orders/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict_orders/delayed_execution_config.ts +430 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.ts +108 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.ts +58 -0
- package/src/contracts/deepbook_predict_orders/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict_orders/desk.ts +419 -0
- package/src/contracts/deepbook_predict_orders/order_flow.ts +19 -0
- package/src/contracts/deepbook_predict_orders/order_queue.ts +1670 -0
- package/src/contracts/deepbook_predict_orders/queue.ts +1394 -0
- package/src/contracts/deepbook_predict_orders/queue_events.ts +189 -0
- package/src/contracts/deepbook_sessions/sessions.ts +355 -4
- package/src/deployments/mainnet.ts +7 -2
- package/src/deployments/testnet.ts +7 -2
- package/src/deployments/types.ts +14 -1
- package/src/predict/bindings/expiry-market.ts +127 -0
- package/src/predict/bindings/protocol-config.ts +59 -0
- package/src/predict/bindings/rename.ts +14 -0
- package/src/predict/client.ts +2076 -13
- package/src/predict/config/generated.ts +50 -0
- package/src/predict/config/mainnet.ts +16 -2
- package/src/predict/config/testnet.ts +16 -2
- package/src/predict/config/types.ts +51 -1
- package/src/predict/cost.ts +62 -14
- package/src/predict/decode.ts +691 -2
- package/src/predict/errors.ts +391 -14
- package/src/predict/index.ts +87 -6
- package/src/predict/queue-id.ts +22 -0
- package/src/predict/queue.ts +1231 -0
- package/src/predict/reads/markets.ts +30 -0
- package/src/predict/reads/queue.ts +606 -0
- package/src/predict/ticks.ts +35 -0
- package/src/predict/tx/common.ts +25 -1
- package/src/predict/tx/queue.ts +525 -0
- package/src/predict/tx/trade.ts +80 -49
- package/src/sessions.ts +206 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PredictInputError } from "../errors.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/predict/config/generated.ts
|
|
2
4
|
function toGeneratedConfig(cfg) {
|
|
3
5
|
return {
|
|
@@ -11,7 +13,34 @@ function toGeneratedConfig(cfg) {
|
|
|
11
13
|
accountRegistry: cfg.objects.accountRegistry
|
|
12
14
|
};
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Project a config that records delayed execution onto {@link OrdersGeneratedConfig}. Throws
|
|
18
|
+
* `PredictInputError` while the config lacks the Predict upgrade, the companion package, its desk
|
|
19
|
+
* or its queue registry: building a queued order against a guessed package would abort on chain
|
|
20
|
+
* or, worse, address the wrong one.
|
|
21
|
+
*/
|
|
22
|
+
function toOrdersConfig(cfg) {
|
|
23
|
+
const { predictDelayedExecution, predictOrders, predictOrdersV1, predictMath } = cfg.packages;
|
|
24
|
+
const { orderDesk, queueRegistry } = cfg.objects;
|
|
25
|
+
if (!predictDelayedExecution || !predictOrders || !orderDesk || !queueRegistry) {
|
|
26
|
+
const missing = [
|
|
27
|
+
!predictDelayedExecution && "`packages.predictDelayedExecution`",
|
|
28
|
+
!predictOrders && "`packages.predictOrders`",
|
|
29
|
+
!orderDesk && "`objects.orderDesk`",
|
|
30
|
+
!queueRegistry && "`objects.queueRegistry`"
|
|
31
|
+
].filter(Boolean);
|
|
32
|
+
throw new PredictInputError(`delayed execution isn't recorded for ${cfg.network} in this SDK version (missing ${missing.join(", ")}): pass a \`config\` that records the Predict upgrade, the \`deepbook_predict_orders\` package, its order desk and its queue registry`);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
...toGeneratedConfig(cfg),
|
|
36
|
+
predictOrdersPackageId: predictOrders,
|
|
37
|
+
predictOrdersPackageIdV1: predictOrdersV1 ?? predictOrders,
|
|
38
|
+
predictMathPackageId: predictMath,
|
|
39
|
+
orderDesk,
|
|
40
|
+
queueRegistry
|
|
41
|
+
};
|
|
42
|
+
}
|
|
14
43
|
|
|
15
44
|
//#endregion
|
|
16
|
-
export { toGeneratedConfig };
|
|
45
|
+
export { toGeneratedConfig, toOrdersConfig };
|
|
17
46
|
//# sourceMappingURL=generated.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated.mjs","names":[],"sources":["../../../src/predict/config/generated.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { AccountConfig } from '../../account.js';\nimport type { DeepbookPredictConfig } from '../../contracts/deepbook_predict/config-arguments.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * The flat config slice the generated bindings resolve `options.config` against, projected from\n * the nested public `PredictConfig`. Each generated call declares only the keys it consumes, so a\n * single object carrying all of them satisfies every call site.\n *\n * Typed as the intersection of the two generated interfaces on purpose: if codegen adds, drops, or\n * renames a config key, this file stops compiling instead of silently building a PTB against the\n * wrong object.\n *\n * `predictPackageId` is narrowed to `string` because codegen types package ids as optional, while\n * this projection always supplies one. `predictPackageIdV1` separately supplies the original\n * identity for existing struct tags and dynamic-field keys. The two account ids restate a narrowing\n * `AccountConfig` already applies, so they are redundant today; they are kept so this projection\n * still compiles to plain ids if that package ever widens them back.\n */\nexport type GeneratedConfig = DeepbookPredictConfig &\n\tAccountConfig & {\n\t\tpredictPackageId: string;\n\t\tpredictPackageIdV1: string;\n\t\taccountPackageId: string;\n\t\taccountRegistry: string;\n\t};\n\nexport function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {\n\treturn {\n\t\tpredictPackageId: cfg.packages.predict,\n\t\tpredictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,\n\t\taccountPackageId: cfg.packages.account,\n\t\tprotocolConfig: cfg.objects.protocolConfig,\n\t\tpoolVault: cfg.objects.poolVault,\n\t\tregistry: cfg.objects.registry,\n\t\toracleRegistry: cfg.objects.oracleRegistry,\n\t\taccountRegistry: cfg.objects.accountRegistry,\n\t};\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generated.mjs","names":[],"sources":["../../../src/predict/config/generated.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { AccountConfig } from '../../account.js';\nimport type { DeepbookPredictConfig } from '../../contracts/deepbook_predict/config-arguments.js';\nimport type { DeepbookPredictMathConfig } from '../../contracts/deepbook_predict_math/config-arguments.js';\nimport type { DeepbookPredictOrdersConfig } from '../../contracts/deepbook_predict_orders/config-arguments.js';\nimport { PredictInputError } from '../errors.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * The flat config slice the generated bindings resolve `options.config` against, projected from\n * the nested public `PredictConfig`. Each generated call declares only the keys it consumes, so a\n * single object carrying all of them satisfies every call site.\n *\n * Typed as the intersection of the two generated interfaces on purpose: if codegen adds, drops, or\n * renames a config key, this file stops compiling instead of silently building a PTB against the\n * wrong object.\n *\n * `predictPackageId` is narrowed to `string` because codegen types package ids as optional, while\n * this projection always supplies one. `predictPackageIdV1` separately supplies the original\n * identity for existing struct tags and dynamic-field keys. The two account ids restate a narrowing\n * `AccountConfig` already applies, so they are redundant today; they are kept so this projection\n * still compiles to plain ids if that package ever widens them back.\n */\nexport type GeneratedConfig = DeepbookPredictConfig &\n\tAccountConfig & {\n\t\tpredictPackageId: string;\n\t\tpredictPackageIdV1: string;\n\t\taccountPackageId: string;\n\t\taccountRegistry: string;\n\t};\n\nexport function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {\n\treturn {\n\t\tpredictPackageId: cfg.packages.predict,\n\t\tpredictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,\n\t\taccountPackageId: cfg.packages.account,\n\t\tprotocolConfig: cfg.objects.protocolConfig,\n\t\tpoolVault: cfg.objects.poolVault,\n\t\tregistry: cfg.objects.registry,\n\t\toracleRegistry: cfg.objects.oracleRegistry,\n\t\taccountRegistry: cfg.objects.accountRegistry,\n\t};\n}\n\n/**\n * {@link GeneratedConfig} plus the order-flow companion (`deepbook_predict_orders`) and the math\n * library: the slice the queued-order thunks and reads take. A queued order calls the companion,\n * which calls into Predict, so one object carries both packages' keys. `predictOrdersPackageIdV1`\n * is the companion's original ID, which types `OrderFlow` and the queue events.\n */\nexport type OrdersGeneratedConfig = GeneratedConfig &\n\tDeepbookPredictOrdersConfig &\n\tDeepbookPredictMathConfig & {\n\t\tpredictOrdersPackageId: string;\n\t\tpredictOrdersPackageIdV1: string;\n\t\torderDesk: string;\n\t\tqueueRegistry: string;\n\t};\n\n/**\n * Project a config that records delayed execution onto {@link OrdersGeneratedConfig}. Throws\n * `PredictInputError` while the config lacks the Predict upgrade, the companion package, its desk\n * or its queue registry: building a queued order against a guessed package would abort on chain\n * or, worse, address the wrong one.\n */\nexport function toOrdersConfig(cfg: PredictConfig): OrdersGeneratedConfig {\n\tconst { predictDelayedExecution, predictOrders, predictOrdersV1, predictMath } = cfg.packages;\n\tconst { orderDesk, queueRegistry } = cfg.objects;\n\tif (!predictDelayedExecution || !predictOrders || !orderDesk || !queueRegistry) {\n\t\tconst missing = [\n\t\t\t!predictDelayedExecution && '`packages.predictDelayedExecution`',\n\t\t\t!predictOrders && '`packages.predictOrders`',\n\t\t\t!orderDesk && '`objects.orderDesk`',\n\t\t\t!queueRegistry && '`objects.queueRegistry`',\n\t\t].filter(Boolean);\n\t\tthrow new PredictInputError(\n\t\t\t`delayed execution isn't recorded for ${cfg.network} in this SDK version (missing ` +\n\t\t\t\t`${missing.join(', ')}): pass a \\`config\\` that records the Predict upgrade, the ` +\n\t\t\t\t'`deepbook_predict_orders` package, its order desk and its queue registry',\n\t\t);\n\t}\n\treturn {\n\t\t...toGeneratedConfig(cfg),\n\t\tpredictOrdersPackageId: predictOrders,\n\t\tpredictOrdersPackageIdV1: predictOrdersV1 ?? predictOrders,\n\t\tpredictMathPackageId: predictMath,\n\t\torderDesk,\n\t\tqueueRegistry,\n\t};\n}\n"],"mappings":";;;AAgCA,SAAgB,kBAAkB,KAAqC;AACtE,QAAO;EACN,kBAAkB,IAAI,SAAS;EAC/B,oBAAoB,IAAI,SAAS,aAAa,IAAI,SAAS;EAC3D,kBAAkB,IAAI,SAAS;EAC/B,gBAAgB,IAAI,QAAQ;EAC5B,WAAW,IAAI,QAAQ;EACvB,UAAU,IAAI,QAAQ;EACtB,gBAAgB,IAAI,QAAQ;EAC5B,iBAAiB,IAAI,QAAQ;EAC7B;;;;;;;;AAwBF,SAAgB,eAAe,KAA2C;CACzE,MAAM,EAAE,yBAAyB,eAAe,iBAAiB,gBAAgB,IAAI;CACrF,MAAM,EAAE,WAAW,kBAAkB,IAAI;AACzC,KAAI,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,aAAa,CAAC,eAAe;EAC/E,MAAM,UAAU;GACf,CAAC,2BAA2B;GAC5B,CAAC,iBAAiB;GAClB,CAAC,aAAa;GACd,CAAC,iBAAiB;GAClB,CAAC,OAAO,QAAQ;AACjB,QAAM,IAAI,kBACT,wCAAwC,IAAI,QAAQ,gCAChD,QAAQ,KAAK,KAAK,CAAC,uIAEvB;;AAEF,QAAO;EACN,GAAG,kBAAkB,IAAI;EACzB,wBAAwB;EACxB,0BAA0B,mBAAmB;EAC7C,sBAAsB;EACtB;EACA;EACA"}
|
|
@@ -13,12 +13,20 @@ import { MAINNET_PREDICT } from "../../deployments/mainnet.mjs";
|
|
|
13
13
|
*/
|
|
14
14
|
const MAINNET_CONFIG = Object.freeze({
|
|
15
15
|
network: "mainnet",
|
|
16
|
-
packages:
|
|
17
|
-
|
|
16
|
+
packages: Object.freeze({
|
|
17
|
+
...MAINNET_PREDICT.packages,
|
|
18
|
+
predictDelayedExecution: "0x98235c5842831c9b5f51dc637cf34c91db2aca5510802eb6ebfec63f5b71a7bb"
|
|
19
|
+
}),
|
|
20
|
+
objects: Object.freeze({
|
|
21
|
+
...MAINNET_PREDICT.objects,
|
|
22
|
+
orderDesk: "0x87b0a87262aacf58eaff567eed2fb7cb0f9cbc1f5ce33ef79216cd26d13a1b5b",
|
|
23
|
+
queueRegistry: "0x8d4f0c671862f065ac7f2c2cb24abc47cf75ed8fc8e5e52c1d4bdfa53eee164f"
|
|
24
|
+
}),
|
|
18
25
|
quoteCoinType: MAINNET_PREDICT.quoteCoinType,
|
|
19
26
|
coinTypes: MAINNET_PREDICT.coinTypes,
|
|
20
27
|
units: MAINNET_PREDICT.units,
|
|
21
|
-
underlyings: MAINNET_PREDICT.underlyings
|
|
28
|
+
underlyings: MAINNET_PREDICT.underlyings,
|
|
29
|
+
oracle: MAINNET_PREDICT.oracle
|
|
22
30
|
});
|
|
23
31
|
|
|
24
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mainnet.mjs","names":[],"sources":["../../../src/predict/config/mainnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MAINNET_PREDICT } from '../../deployments/mainnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Mainnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.mainnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('mainnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const MAINNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the mainnet config by construction.\n\tnetwork: 'mainnet',\n\tpackages: MAINNET_PREDICT.packages,\n\tobjects: MAINNET_PREDICT.objects,\n\tquoteCoinType: MAINNET_PREDICT.quoteCoinType,\n\tcoinTypes: MAINNET_PREDICT.coinTypes,\n\tunits: MAINNET_PREDICT.units,\n\tunderlyings: MAINNET_PREDICT.underlyings,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;
|
|
1
|
+
{"version":3,"file":"mainnet.mjs","names":[],"sources":["../../../src/predict/config/mainnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MAINNET_PREDICT } from '../../deployments/mainnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Mainnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.mainnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('mainnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const MAINNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the mainnet config by construction.\n\tnetwork: 'mainnet',\n\t// Delayed execution (DBU-885) is recorded on Mainnet. The generated record carries the package\n\t// IDs that move with upgrades (Predict, `deepbook_predict_orders`, `deepbook_predict_math`) and\n\t// the Lazer `State`. The three IDs pinned below are in no publication record and never move:\n\t// the Predict version that introduced delayed execution (Mainnet v4), which defines its new\n\t// types and events, and the `OrderDesk` and `QueueRegistry` that `deepbook_predict_orders`'s\n\t// `init` shared at publish.\n\tpackages: Object.freeze({\n\t\t...MAINNET_PREDICT.packages,\n\t\tpredictDelayedExecution: '0x98235c5842831c9b5f51dc637cf34c91db2aca5510802eb6ebfec63f5b71a7bb',\n\t}),\n\tobjects: Object.freeze({\n\t\t...MAINNET_PREDICT.objects,\n\t\torderDesk: '0x87b0a87262aacf58eaff567eed2fb7cb0f9cbc1f5ce33ef79216cd26d13a1b5b',\n\t\tqueueRegistry: '0x8d4f0c671862f065ac7f2c2cb24abc47cf75ed8fc8e5e52c1d4bdfa53eee164f',\n\t}),\n\tquoteCoinType: MAINNET_PREDICT.quoteCoinType,\n\tcoinTypes: MAINNET_PREDICT.coinTypes,\n\tunits: MAINNET_PREDICT.units,\n\tunderlyings: MAINNET_PREDICT.underlyings,\n\toracle: MAINNET_PREDICT.oracle,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;CAOT,UAAU,OAAO,OAAO;EACvB,GAAG,gBAAgB;EACnB,yBAAyB;EACzB,CAAC;CACF,SAAS,OAAO,OAAO;EACtB,GAAG,gBAAgB;EACnB,WAAW;EACX,eAAe;EACf,CAAC;CACF,eAAe,gBAAgB;CAC/B,WAAW,gBAAgB;CAC3B,OAAO,gBAAgB;CACvB,aAAa,gBAAgB;CAC7B,QAAQ,gBAAgB;CACxB,CAAC"}
|
|
@@ -13,12 +13,20 @@ import { TESTNET_PREDICT } from "../../deployments/testnet.mjs";
|
|
|
13
13
|
*/
|
|
14
14
|
const TESTNET_CONFIG = Object.freeze({
|
|
15
15
|
network: "testnet",
|
|
16
|
-
packages:
|
|
17
|
-
|
|
16
|
+
packages: Object.freeze({
|
|
17
|
+
...TESTNET_PREDICT.packages,
|
|
18
|
+
predictDelayedExecution: "0x0654ecbed7c0f2645d9de7cb6cf08e65c2ee05cdbb39a415f17a6bd1cd92e267"
|
|
19
|
+
}),
|
|
20
|
+
objects: Object.freeze({
|
|
21
|
+
...TESTNET_PREDICT.objects,
|
|
22
|
+
orderDesk: "0x160fc026c4143f3dec36acfc6556379d54661d37fe28ad837b6a85e42aeddfea",
|
|
23
|
+
queueRegistry: "0xe9d75ed05b089d52a660a94b94963cdc89aeb7f3c75b57f76771454c81faae1f"
|
|
24
|
+
}),
|
|
18
25
|
quoteCoinType: TESTNET_PREDICT.quoteCoinType,
|
|
19
26
|
coinTypes: TESTNET_PREDICT.coinTypes,
|
|
20
27
|
units: TESTNET_PREDICT.units,
|
|
21
|
-
underlyings: TESTNET_PREDICT.underlyings
|
|
28
|
+
underlyings: TESTNET_PREDICT.underlyings,
|
|
29
|
+
oracle: TESTNET_PREDICT.oracle
|
|
22
30
|
});
|
|
23
31
|
|
|
24
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testnet.mjs","names":[],"sources":["../../../src/predict/config/testnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TESTNET_PREDICT } from '../../deployments/testnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Testnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.testnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('testnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const TESTNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the testnet config by construction.\n\tnetwork: 'testnet',\n\tpackages: TESTNET_PREDICT.packages,\n\tobjects: TESTNET_PREDICT.objects,\n\tquoteCoinType: TESTNET_PREDICT.quoteCoinType,\n\tcoinTypes: TESTNET_PREDICT.coinTypes,\n\tunits: TESTNET_PREDICT.units,\n\tunderlyings: TESTNET_PREDICT.underlyings,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;
|
|
1
|
+
{"version":3,"file":"testnet.mjs","names":[],"sources":["../../../src/predict/config/testnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TESTNET_PREDICT } from '../../deployments/testnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Testnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.testnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('testnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const TESTNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the testnet config by construction.\n\tnetwork: 'testnet',\n\t// Delayed execution (DBU-885) is recorded on Testnet. The generated record carries the package\n\t// IDs that move with upgrades (Predict, `deepbook_predict_orders`, `deepbook_predict_math`) and\n\t// the Lazer `State`. The three IDs pinned below are in no publication record and never move:\n\t// the Predict version that introduced delayed execution (Testnet v5), which defines its new\n\t// types and events, and the `OrderDesk` and `QueueRegistry` that `deepbook_predict_orders`'s\n\t// `init` shared at publish.\n\tpackages: Object.freeze({\n\t\t...TESTNET_PREDICT.packages,\n\t\tpredictDelayedExecution: '0x0654ecbed7c0f2645d9de7cb6cf08e65c2ee05cdbb39a415f17a6bd1cd92e267',\n\t}),\n\tobjects: Object.freeze({\n\t\t...TESTNET_PREDICT.objects,\n\t\torderDesk: '0x160fc026c4143f3dec36acfc6556379d54661d37fe28ad837b6a85e42aeddfea',\n\t\tqueueRegistry: '0xe9d75ed05b089d52a660a94b94963cdc89aeb7f3c75b57f76771454c81faae1f',\n\t}),\n\tquoteCoinType: TESTNET_PREDICT.quoteCoinType,\n\tcoinTypes: TESTNET_PREDICT.coinTypes,\n\tunits: TESTNET_PREDICT.units,\n\tunderlyings: TESTNET_PREDICT.underlyings,\n\toracle: TESTNET_PREDICT.oracle,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;CAOT,UAAU,OAAO,OAAO;EACvB,GAAG,gBAAgB;EACnB,yBAAyB;EACzB,CAAC;CACF,SAAS,OAAO,OAAO;EACtB,GAAG,gBAAgB;EACnB,WAAW;EACX,eAAe;EACf,CAAC;CACF,eAAe,gBAAgB;CAC/B,WAAW,gBAAgB;CAC3B,OAAO,gBAAgB;CACvB,aAAa,gBAAgB;CAC7B,QAAQ,gBAAgB;CACxB,CAAC"}
|
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
//#region src/predict/config/types.d.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The published Move packages a Predict deployment spans.
|
|
4
|
+
*
|
|
5
|
+
* Delayed execution (DBU-885) ships as three packages: the Predict upgrade, the order-flow
|
|
6
|
+
* companion `deepbook_predict_orders` (a fresh publish), and the math library
|
|
7
|
+
* `deepbook_predict_math` (a fresh publish). The queued-order builders, reads and decoders need
|
|
8
|
+
* `predictDelayedExecution`, `predictOrders`, `objects.orderDesk` and `objects.queueRegistry` all
|
|
9
|
+
* recorded, and throw
|
|
10
|
+
* `PredictInputError` otherwise rather than address the wrong package. Pass a custom `config`
|
|
11
|
+
* (a localnet publish) to use them before a network record exists.
|
|
12
|
+
*/
|
|
3
13
|
interface PredictPackages {
|
|
4
14
|
/** Latest published package ID, used for Move calls. */
|
|
5
15
|
predict: string;
|
|
6
16
|
/** Original ID for v1 structs/events. Omit only for an unupgraded custom deployment. */
|
|
7
17
|
predictV1?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The Predict version that introduced delayed execution (Mainnet v4, Testnet v5): the
|
|
20
|
+
* defining ID of the Predict types and events that version added (`ExpiryPnlRealized`,
|
|
21
|
+
* `FlushOperatorUpdated`, `OrderFlowUpdated`, `OrderReceipt`). A later upgrade does not move
|
|
22
|
+
* it, so it is pinned once per network rather than read from the latest publication.
|
|
23
|
+
*/
|
|
24
|
+
predictDelayedExecution?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Latest published `deepbook_predict_orders` package ID: the call target of every queued-order
|
|
27
|
+
* entry point (`queue::enqueue_*`, `commit`, `resolve`, `refund`, `settle_step`, …), the queue
|
|
28
|
+
* reads and the desk setters.
|
|
29
|
+
*/
|
|
30
|
+
predictOrders?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Original `deepbook_predict_orders` ID, which types `MarketQueue`, `OrderDesk`, the queue
|
|
33
|
+
* events and the `OrderFlow` witness. Omit until the package is first upgraded: it then
|
|
34
|
+
* defaults to `predictOrders`.
|
|
35
|
+
*/
|
|
36
|
+
predictOrdersV1?: string;
|
|
37
|
+
/** The `deepbook_predict_math` package ID, for its pure calls and layouts. */
|
|
38
|
+
predictMath?: string;
|
|
8
39
|
account: string;
|
|
9
40
|
propbook: string;
|
|
10
41
|
}
|
|
@@ -33,6 +64,17 @@ interface PredictConfig {
|
|
|
33
64
|
poolVault: string;
|
|
34
65
|
oracleRegistry: string;
|
|
35
66
|
accountRegistry: string;
|
|
67
|
+
/**
|
|
68
|
+
* The order-flow companion's shared `OrderDesk`: the delayed-execution policy and the
|
|
69
|
+
* companion's version floor. Created once, by the package's `init` at publish.
|
|
70
|
+
*/
|
|
71
|
+
orderDesk?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The order-flow companion's shared `QueueRegistry`, created next to the desk by the same
|
|
74
|
+
* `init`. Each market's `MarketQueue` sits at an ID derived from it and the market
|
|
75
|
+
* (`deriveQueueId`), and `queue::create_and_share` writes it.
|
|
76
|
+
*/
|
|
77
|
+
queueRegistry?: string;
|
|
36
78
|
};
|
|
37
79
|
/**
|
|
38
80
|
* The deployment's settlement coin type. Always read this rather than assuming a type:
|
|
@@ -58,6 +100,13 @@ interface PredictConfig {
|
|
|
58
100
|
positionQuantityDecimals: number;
|
|
59
101
|
};
|
|
60
102
|
underlyings: Record<string, UnderlyingConfig>;
|
|
103
|
+
/**
|
|
104
|
+
* Oracle objects only the delayed-execution filler needs. Optional: traders never pass
|
|
105
|
+
* them, and a filler can name the Lazer `State` per call instead.
|
|
106
|
+
*/
|
|
107
|
+
oracle?: {
|
|
108
|
+
/** Pyth Lazer's shared `State`, which carries the current Lazer package ID. */pythLazerState?: string;
|
|
109
|
+
};
|
|
61
110
|
}
|
|
62
111
|
//#endregion
|
|
63
112
|
export { PredictConfig, PredictPackages, UnderlyingConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/predict/config/types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/predict/config/types.ts"],"mappings":";;AAaA;;;;;;;;;;UAAiB,eAAA;EA2BhB;EAzBA,OAAA;EAyBQ;EAvBR,SAAA;EA+BgC;;;;;;EAxBhC,uBAAA;EAgCA;;;AAID;;EA9BC,aAAA;EAgCU;;;;;EA1BV,eAAA;EA0BA;EAxBA,WAAA;EACA,OAAA;EACA,QAAA;AAAA;;;;;;UAQgB,gBAAA;EAChB,MAAA;EACA,oBAAA;EA2C0B;EAzC1B,QAAA;EA4CC;EA1CD,sBAAA;EA4CC;EA1CD,oBAAA;AAAA;;UAIgB,aAAA;EAChB,OAAA;EACA,QAAA,EAAU,eAAA;EACV,OAAA;IACC,QAAA;IACA,cAAA;IACA,SAAA;IACA,cAAA;IACA,eAAA;;;;;IAKA,SAAA;;;;;;IAMA,aAAA;EAAA;;;;;;;EAQD,aAAA;;;;;;EAMA,SAAA;IAAa,GAAA;IAAa,IAAA;EAAA;;EAE1B,KAAA;IACC,eAAA;IACA,eAAA;IACA,iBAAA;IACA,wBAAA;EAAA;EAED,WAAA,EAAa,MAAA,SAAe,gBAAA;;;;;EAK5B,MAAA;mFAEC,cAAA;EAAA;AAAA"}
|
package/dist/predict/cost.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { POS_INF_TICK } from "./ticks.mjs";
|
|
|
3
3
|
|
|
4
4
|
//#region src/predict/cost.d.ts
|
|
5
5
|
declare namespace cost_d_exports {
|
|
6
|
-
export { BUILDER_FEE_MULTIPLIER, Boundaries, CloseBookTerms, CongestionPolicy, CongestionState, FEE_INCENTIVE_SUBSIDY_RATE, FLOAT_SCALING, FeePolicy, MAX_BUILDER_FEE_RATE, MAX_QUANTITY_LOTS, MIN_PREMIUM, MintBookTerms, MintBudgetCost, MintBudgetInputs, MintCost, MintCostInputs, OrderRange, POSITION_LOT_SIZE, POS_INF_TICK, ProbabilitySource, RedeemLiveInputs, RedeemLiveProceeds, SHIPPED_FEE_POLICY, bernoulliFeeRate, boundaryProbabilities, builderFee, closeInventoryImpact, congestionPenaltyRate, decodeOrderRange, expiryFeeMultiplier, feeIncentiveSubsidy, inventoryImpactPotential, mintCost, mintCostForBudget, mintInventoryImpact, orderStrikes, rangeProbability, redeemLiveProceeds, sqrtDown, tradingFee };
|
|
6
|
+
export { BUILDER_FEE_MULTIPLIER, Boundaries, CloseBookTerms, CongestionPolicy, CongestionState, FEE_INCENTIVE_SUBSIDY_RATE, FLOAT_SCALING, FeePolicy, MAX_BUILDER_FEE_RATE, MAX_QUANTITY_LOTS, MIN_PREMIUM, MintBookTerms, MintBudgetCost, MintBudgetInputs, MintCost, MintCostInputs, OrderRange, POSITION_LOT_SIZE, POS_INF_TICK, ProbabilitySource, RedeemLiveInputs, RedeemLiveProceeds, SHIPPED_FEE_POLICY, bernoulliFeeRate, boundaryProbabilities, builderFee, closeInventoryImpact, congestionPenaltyRate, decodeOrderRange, expiryFeeMultiplier, feeIncentiveSubsidy, inventoryImpactPotential, mintCost, mintCostForBudget, mintInventoryImpact, orderStrikes, rangeProbability, redeemLiveProceeds, settledPayout, sqrtDown, tradingFee };
|
|
7
7
|
}
|
|
8
8
|
/** `math::float_scaling` — 1e9 is 1.0 for every rate and probability here. */
|
|
9
9
|
declare const FLOAT_SCALING = 1000000000n;
|
|
@@ -15,7 +15,14 @@ declare const MIN_PREMIUM = 1000000n;
|
|
|
15
15
|
declare const BUILDER_FEE_MULTIPLIER = 100000000n;
|
|
16
16
|
/** `constants::max_builder_fee_rate` — cap on the builder fee as a share of quantity (0.5%). */
|
|
17
17
|
declare const MAX_BUILDER_FEE_RATE = 5000000n;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The default sponsor share of a trader's mint fee (20%), and the rate the chain reads while the
|
|
20
|
+
* admin hasn't set one.
|
|
21
|
+
* @deprecated From delayed execution (DBU-885) the rate is admin-set: read it with
|
|
22
|
+
* `protocol_config::fee_incentive_subsidy_rate` (`read.queue(...).protocol.feeIncentiveSubsidyRate`)
|
|
23
|
+
* and pass it as `feeIncentiveSubsidyRate`. A hardcoded 20% underquotes every mint once the rate
|
|
24
|
+
* moves.
|
|
25
|
+
*/
|
|
19
26
|
declare const FEE_INCENTIVE_SUBSIDY_RATE = 200000000n;
|
|
20
27
|
/** `order::max_quantity_lots` — the order ID's 32-bit lot field. */
|
|
21
28
|
declare const MAX_QUANTITY_LOTS: bigint;
|
|
@@ -24,8 +31,8 @@ declare function sqrtDown(x: bigint): bigint;
|
|
|
24
31
|
/**
|
|
25
32
|
* One market's fee policy: the `StrikeExposureConfig` it snapshotted at creation, in raw 1e9
|
|
26
33
|
* rates. Snapshotted means later admin changes do NOT reprice a market already trading, so
|
|
27
|
-
* read it per market (the `MarketCreated` event carries every field
|
|
28
|
-
* template. The last three are the inventory-impact parameters, inert while
|
|
34
|
+
* read it per market with `read.feePolicy(market)` (the `MarketCreated` event carries every field
|
|
35
|
+
* too) rather than assuming the template. The last three are the inventory-impact parameters, inert while
|
|
29
36
|
* `inventoryImpactMaxRate` is `0n` (the shipped value).
|
|
30
37
|
*/
|
|
31
38
|
interface FeePolicy {
|
|
@@ -51,9 +58,11 @@ interface FeePolicy {
|
|
|
51
58
|
/**
|
|
52
59
|
* The shipped template (`config_constants` defaults): 10% Bernoulli fee, a 2.2% per-leg floor,
|
|
53
60
|
* a one-day ramp window that is inert at a 1.0 multiplier, a 1%–99% entry band, and inventory
|
|
54
|
-
* impact disabled.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
61
|
+
* impact disabled. Neither recorded deployment's template matches it any more: both charge a
|
|
62
|
+
* 20.4% Bernoulli fee, ramp it to 3× over the last 60 s and admit entries in 25%–75% (checked
|
|
63
|
+
* 2026-10-09), so a live market's costs from this policy come out low. Pass
|
|
64
|
+
* `read.feePolicy(market)` instead. This stays for tests and for a deployment still on the
|
|
65
|
+
* defaults.
|
|
57
66
|
*/
|
|
58
67
|
declare const SHIPPED_FEE_POLICY: FeePolicy;
|
|
59
68
|
/** A range's two boundary UP probabilities, raw 1e9. `null` is an infinite boundary — the
|
|
@@ -119,8 +128,9 @@ declare function tradingFee(policy: FeePolicy, boundaries: Boundaries, quantity:
|
|
|
119
128
|
* multiple of its trading fee, capped as a share of quantity. */
|
|
120
129
|
declare function builderFee(fee: bigint, quantity: bigint, hasBuilderCode: boolean): bigint;
|
|
121
130
|
/** `expiry_market::fee_incentive_subsidy_amount` — a sponsor pays part of the trader's MINT
|
|
122
|
-
* fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full.
|
|
123
|
-
|
|
131
|
+
* fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full.
|
|
132
|
+
* `rate` is the protocol's `fee_incentive_subsidy_rate` (1e9-scaled), 20% when omitted. */
|
|
133
|
+
declare function feeIncentiveSubsidy(fee: bigint, feeIncentiveBalance: bigint, rate?: bigint): bigint;
|
|
124
134
|
/**
|
|
125
135
|
* `ewma::penalty_fee`'s firing test, as a per-unit RATE: `penalty_rate` when the transaction's
|
|
126
136
|
* gas price is a high outlier against the market's pre-trade EWMA, else zero. It is a rate and
|
|
@@ -163,7 +173,15 @@ interface MintInputsBase {
|
|
|
163
173
|
builderCode?: boolean;
|
|
164
174
|
/** The expiry's remaining sponsored fee balance (`fee_incentive_balance`). Default `0n`. */
|
|
165
175
|
feeIncentiveBalance?: number | bigint;
|
|
166
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* The protocol's admin-set mint fee subsidy rate (`protocol_config::fee_incentive_subsidy_rate`),
|
|
178
|
+
* 1e9-scaled. Defaults to the 20% the chain reads while unset.
|
|
179
|
+
*/
|
|
180
|
+
feeIncentiveSubsidyRate?: bigint;
|
|
181
|
+
/**
|
|
182
|
+
* Per-unit congestion surcharge rate — see {@link congestionPenaltyRate}. Default `0n`. A
|
|
183
|
+
* queued (delayed-execution) fill pays no congestion penalty, so queued previews keep it 0.
|
|
184
|
+
*/
|
|
167
185
|
penaltyRate?: bigint;
|
|
168
186
|
/** Pre-trade payout-tree terms. Required when inventory impact is enabled. */
|
|
169
187
|
book?: MintBookTerms;
|
|
@@ -341,6 +359,15 @@ interface OrderRange {
|
|
|
341
359
|
/** Decode an order ID's range and quantity — the TypeScript mirror of `order::lower_tick` /
|
|
342
360
|
* `higher_tick` / `quantity`. */
|
|
343
361
|
declare function decodeOrderRange(orderId: bigint, lotSize?: bigint): OrderRange;
|
|
362
|
+
/**
|
|
363
|
+
* What an order pays at settlement, raw USDC: its full quantity when the settlement price lies
|
|
364
|
+
* in `(lower, higher]`, else 0. The mirror of `strike_exposure::settled_order_payout`, which
|
|
365
|
+
* rounds the settlement price up to the market's tick grid (`range_codec::limit_tick`) before
|
|
366
|
+
* comparing it with the order's ticks, so a price inside a tick counts as that tick's upper edge.
|
|
367
|
+
* Pass `read.settlement`'s `settlementPriceRaw` and `tickSizeRaw`, and the config's
|
|
368
|
+
* `units.positionLotSize` when it isn't the default.
|
|
369
|
+
*/
|
|
370
|
+
declare function settledPayout(orderId: bigint, settlementPriceRaw: bigint, tickSizeRaw: bigint, lotSize?: bigint): bigint;
|
|
344
371
|
/** The strikes an {@link OrderRange} prices against, in USD, with `null` for each infinite
|
|
345
372
|
* side — the shape {@link boundaryProbabilities} takes. `tickSize` is the market's raw tick
|
|
346
373
|
* size (`ActiveMarket.tickSize` in USD, or the raw value from the deployment). */
|
|
@@ -349,5 +376,5 @@ declare function orderStrikes(range: OrderRange, tickSizeRaw: bigint): {
|
|
|
349
376
|
upper: number | null;
|
|
350
377
|
};
|
|
351
378
|
//#endregion
|
|
352
|
-
export { cost_d_exports };
|
|
379
|
+
export { FeePolicy, cost_d_exports };
|
|
353
380
|
//# sourceMappingURL=cost.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost.d.mts","names":[],"sources":["../../src/predict/cost.ts"],"mappings":";;;;;;;;cA8Ca,aAAA;;cAEA,iBAAA;;cAEA,WAAA;;cAEA,sBAAA;;cAEA,oBAAA
|
|
1
|
+
{"version":3,"file":"cost.d.mts","names":[],"sources":["../../src/predict/cost.ts"],"mappings":"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"}
|
package/dist/predict/cost.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/rolldown_runtime.mjs";
|
|
2
2
|
import { PredictInputError } from "./errors.mjs";
|
|
3
|
-
import { U64_MAX, fromRaw, usdcToRaw } from "./units.mjs";
|
|
4
|
-
import { POS_INF_TICK } from "./ticks.mjs";
|
|
5
3
|
import { upProbability } from "./pricing.mjs";
|
|
4
|
+
import { POS_INF_TICK } from "./ticks.mjs";
|
|
5
|
+
import { U64_MAX, fromRaw, usdcToRaw } from "./units.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/predict/cost.ts
|
|
8
8
|
var cost_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -30,6 +30,7 @@ var cost_exports = /* @__PURE__ */ __exportAll({
|
|
|
30
30
|
orderStrikes: () => orderStrikes,
|
|
31
31
|
rangeProbability: () => rangeProbability,
|
|
32
32
|
redeemLiveProceeds: () => redeemLiveProceeds,
|
|
33
|
+
settledPayout: () => settledPayout,
|
|
33
34
|
sqrtDown: () => sqrtDown,
|
|
34
35
|
tradingFee: () => tradingFee
|
|
35
36
|
});
|
|
@@ -43,7 +44,14 @@ const MIN_PREMIUM = 1000000n;
|
|
|
43
44
|
const BUILDER_FEE_MULTIPLIER = 100000000n;
|
|
44
45
|
/** `constants::max_builder_fee_rate` — cap on the builder fee as a share of quantity (0.5%). */
|
|
45
46
|
const MAX_BUILDER_FEE_RATE = 5000000n;
|
|
46
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The default sponsor share of a trader's mint fee (20%), and the rate the chain reads while the
|
|
49
|
+
* admin hasn't set one.
|
|
50
|
+
* @deprecated From delayed execution (DBU-885) the rate is admin-set: read it with
|
|
51
|
+
* `protocol_config::fee_incentive_subsidy_rate` (`read.queue(...).protocol.feeIncentiveSubsidyRate`)
|
|
52
|
+
* and pass it as `feeIncentiveSubsidyRate`. A hardcoded 20% underquotes every mint once the rate
|
|
53
|
+
* moves.
|
|
54
|
+
*/
|
|
47
55
|
const FEE_INCENTIVE_SUBSIDY_RATE = 200000000n;
|
|
48
56
|
/** `order::max_quantity_lots` — the order ID's 32-bit lot field. */
|
|
49
57
|
const MAX_QUANTITY_LOTS = (1n << 32n) - 1n;
|
|
@@ -101,9 +109,11 @@ function sqrtDown(x) {
|
|
|
101
109
|
/**
|
|
102
110
|
* The shipped template (`config_constants` defaults): 10% Bernoulli fee, a 2.2% per-leg floor,
|
|
103
111
|
* a one-day ramp window that is inert at a 1.0 multiplier, a 1%–99% entry band, and inventory
|
|
104
|
-
* impact disabled.
|
|
105
|
-
*
|
|
106
|
-
*
|
|
112
|
+
* impact disabled. Neither recorded deployment's template matches it any more: both charge a
|
|
113
|
+
* 20.4% Bernoulli fee, ramp it to 3× over the last 60 s and admit entries in 25%–75% (checked
|
|
114
|
+
* 2026-10-09), so a live market's costs from this policy come out low. Pass
|
|
115
|
+
* `read.feePolicy(market)` instead. This stays for tests and for a deployment still on the
|
|
116
|
+
* defaults.
|
|
107
117
|
*/
|
|
108
118
|
const SHIPPED_FEE_POLICY = Object.freeze({
|
|
109
119
|
baseFee: 100000000n,
|
|
@@ -185,11 +195,13 @@ function builderFee(fee, quantity, hasBuilderCode) {
|
|
|
185
195
|
return min(mulDown(fee, BUILDER_FEE_MULTIPLIER), mulDown(quantity, MAX_BUILDER_FEE_RATE));
|
|
186
196
|
}
|
|
187
197
|
/** `expiry_market::fee_incentive_subsidy_amount` — a sponsor pays part of the trader's MINT
|
|
188
|
-
* fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full.
|
|
189
|
-
|
|
198
|
+
* fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full.
|
|
199
|
+
* `rate` is the protocol's `fee_incentive_subsidy_rate` (1e9-scaled), 20% when omitted. */
|
|
200
|
+
function feeIncentiveSubsidy(fee, feeIncentiveBalance, rate = FEE_INCENTIVE_SUBSIDY_RATE) {
|
|
190
201
|
assertUint(fee, "fee");
|
|
191
202
|
assertUint(feeIncentiveBalance, "feeIncentiveBalance");
|
|
192
|
-
|
|
203
|
+
assertUint(rate, "feeIncentiveSubsidyRate", FLOAT_SCALING);
|
|
204
|
+
return min(mulDown(fee, rate), feeIncentiveBalance);
|
|
193
205
|
}
|
|
194
206
|
/**
|
|
195
207
|
* `ewma::penalty_fee`'s firing test, as a per-unit RATE: `penalty_rate` when the transaction's
|
|
@@ -323,7 +335,7 @@ function timeToExpiry(expiryMs, nowMs) {
|
|
|
323
335
|
function mintQuoteAt(inputs, boundaries, quantity, timeToExpiryMs) {
|
|
324
336
|
const premium = mulDown(rangeProbability(boundaries), quantity);
|
|
325
337
|
const fee = tradingFee(inputs.fees, boundaries, quantity, timeToExpiryMs);
|
|
326
|
-
const subsidy = feeIncentiveSubsidy(fee, rawAmount(inputs.feeIncentiveBalance ?? 0n));
|
|
338
|
+
const subsidy = feeIncentiveSubsidy(fee, rawAmount(inputs.feeIncentiveBalance ?? 0n), inputs.feeIncentiveSubsidyRate);
|
|
327
339
|
const builder = builderFee(fee, quantity, inputs.builderCode ?? false);
|
|
328
340
|
const penalty = mulDown(inputs.penaltyRate ?? 0n, quantity);
|
|
329
341
|
const impact = inputs.book ? mintInventoryImpact(inputs.fees, inputs.book, quantity) : 0n;
|
|
@@ -540,6 +552,20 @@ function decodeOrderRange(orderId, lotSize = POSITION_LOT_SIZE) {
|
|
|
540
552
|
quantity: (orderId >> QUANTITY_LOTS_OFFSET & U32_MASK) * lotSize
|
|
541
553
|
};
|
|
542
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* What an order pays at settlement, raw USDC: its full quantity when the settlement price lies
|
|
557
|
+
* in `(lower, higher]`, else 0. The mirror of `strike_exposure::settled_order_payout`, which
|
|
558
|
+
* rounds the settlement price up to the market's tick grid (`range_codec::limit_tick`) before
|
|
559
|
+
* comparing it with the order's ticks, so a price inside a tick counts as that tick's upper edge.
|
|
560
|
+
* Pass `read.settlement`'s `settlementPriceRaw` and `tickSizeRaw`, and the config's
|
|
561
|
+
* `units.positionLotSize` when it isn't the default.
|
|
562
|
+
*/
|
|
563
|
+
function settledPayout(orderId, settlementPriceRaw, tickSizeRaw, lotSize = POSITION_LOT_SIZE) {
|
|
564
|
+
if (tickSizeRaw <= 0n) throw new PredictInputError("tickSizeRaw must be positive");
|
|
565
|
+
const { lowerTick, higherTick, quantity } = decodeOrderRange(orderId, lotSize);
|
|
566
|
+
const limit = (settlementPriceRaw + tickSizeRaw - 1n) / tickSizeRaw;
|
|
567
|
+
return lowerTick < limit && (higherTick === POS_INF_TICK || limit <= higherTick) ? quantity : 0n;
|
|
568
|
+
}
|
|
543
569
|
/** The strikes an {@link OrderRange} prices against, in USD, with `null` for each infinite
|
|
544
570
|
* side — the shape {@link boundaryProbabilities} takes. `tickSize` is the market's raw tick
|
|
545
571
|
* size (`ActiveMarket.tickSize` in USD, or the raw value from the deployment). */
|
|
@@ -551,5 +577,5 @@ function orderStrikes(range, tickSizeRaw) {
|
|
|
551
577
|
}
|
|
552
578
|
|
|
553
579
|
//#endregion
|
|
554
|
-
export { cost_exports };
|
|
580
|
+
export { FLOAT_SCALING, MAX_QUANTITY_LOTS, MIN_PREMIUM, POSITION_LOT_SIZE, cost_exports, decodeOrderRange };
|
|
555
581
|
//# sourceMappingURL=cost.mjs.map
|