@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
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Admin-tunable policy for delayed execution: the timing, capacity, fee, and
|
|
7
|
+
* settlement-batch settings that queued mints and early sells run under.
|
|
8
|
+
*
|
|
9
|
+
* A leaf module, so `queue_events` can embed the policy and `desk` can store it.
|
|
10
|
+
* It owns the struct, its launch defaults, the field getters, and the package
|
|
11
|
+
* setters with every bound: each field's own range, the relational timing rules,
|
|
12
|
+
* and the per-account cap against the capacities. Predict caps what admission
|
|
13
|
+
* accepts on its side (`constants::max_svi_max_age_ms` and the deadline margin),
|
|
14
|
+
* and these bounds stay inside it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
18
|
+
import { U64 } from '../../bcs/integers.js';
|
|
19
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
20
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
21
|
+
const $moduleName = '@local-pkg/deepbook_predict_orders::delayed_execution_config';
|
|
22
|
+
export const DelayedExecutionPolicy = new MoveStruct({
|
|
23
|
+
name: `${$moduleName}::DelayedExecutionPolicy`,
|
|
24
|
+
fields: {
|
|
25
|
+
/**
|
|
26
|
+
* Latest τ may fall after placement. τ rounds down to the policy channel's tick at
|
|
27
|
+
* or before `t₀ + delay_ms`.
|
|
28
|
+
*/
|
|
29
|
+
delay_ms: U64,
|
|
30
|
+
/**
|
|
31
|
+
* Sets each order's deadline:
|
|
32
|
+
* `max(min(τ + stall_timeout_ms, expiry), last deadline)`. At or past it the
|
|
33
|
+
* order is refunded, never filled.
|
|
34
|
+
*/
|
|
35
|
+
stall_timeout_ms: U64,
|
|
36
|
+
/**
|
|
37
|
+
* Placement refuses new orders while an uncommitted cohort is this far past its τ
|
|
38
|
+
* with nothing newer committed, or while two or more uncommitted cohorts are each
|
|
39
|
+
* this far past their τ.
|
|
40
|
+
*/
|
|
41
|
+
stuck_threshold_ms: U64,
|
|
42
|
+
/** Commit accepts a backup tick for a cohort only once now is this far past its τ. */
|
|
43
|
+
gap_wait_ms: U64,
|
|
44
|
+
/**
|
|
45
|
+
* Switches the backup tick on or off. `0` accepts only the update stamped exactly
|
|
46
|
+
* τ. Above `0`, once now is `gap_wait_ms` past τ, a cohort also accepts its single
|
|
47
|
+
* backup: the update stamped one tick of its own stored channel after τ. The value
|
|
48
|
+
* is not a window: the setter keeps it at `0` or one tick of the policy channel.
|
|
49
|
+
*/
|
|
50
|
+
pyth_price_buffer_ms: U64,
|
|
51
|
+
/**
|
|
52
|
+
* Pyth Lazer channel new orders are priced on: `2` (`fixed_rate@50ms`) or `3`
|
|
53
|
+
* (`fixed_rate@200ms`). Its tick period is τ's grid. Each order stores the channel
|
|
54
|
+
* it was placed under.
|
|
55
|
+
*/
|
|
56
|
+
pyth_channel: bcs.u8(),
|
|
57
|
+
/**
|
|
58
|
+
* Oldest Block Scholes SVI a placement accepts into an order's volatility
|
|
59
|
+
* snapshot.
|
|
60
|
+
*/
|
|
61
|
+
svi_max_age_ms: U64,
|
|
62
|
+
/** Most unfinished queued mints per market. */
|
|
63
|
+
mint_capacity: U64,
|
|
64
|
+
/** Most unfinished queued sells per market. */
|
|
65
|
+
sell_capacity: U64,
|
|
66
|
+
/** Most unfinished queued orders per account per market. */
|
|
67
|
+
per_account_cap: U64,
|
|
68
|
+
/**
|
|
69
|
+
* Flat fee charged at placement. Kept on a fill and on limit or admission refunds;
|
|
70
|
+
* returned on every other refund.
|
|
71
|
+
*/
|
|
72
|
+
order_fee: U64,
|
|
73
|
+
/** Smallest early-sell close quantity. */
|
|
74
|
+
min_sell_quantity: U64,
|
|
75
|
+
/** Most records one `settle_step` call visits while refunding leftover orders. */
|
|
76
|
+
settle_refund_batch: U64,
|
|
77
|
+
/** Most records one `settle_step` call visits while paying Open records. */
|
|
78
|
+
settle_payout_batch: U64,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
export interface DelayMsArguments {
|
|
82
|
+
policy: TransactionArgument;
|
|
83
|
+
}
|
|
84
|
+
export interface DelayMsOptions {
|
|
85
|
+
package?: string;
|
|
86
|
+
arguments: DelayMsArguments | [policy: TransactionArgument];
|
|
87
|
+
config?: {
|
|
88
|
+
predictOrdersPackageId?: string;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function delayMs(options: DelayMsOptions) {
|
|
92
|
+
const packageAddress =
|
|
93
|
+
options.package ??
|
|
94
|
+
options.config?.predictOrdersPackageId ??
|
|
95
|
+
'@local-pkg/deepbook_predict_orders';
|
|
96
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
97
|
+
const parameterNames = ['policy'];
|
|
98
|
+
return (tx: Transaction) =>
|
|
99
|
+
tx.moveCall({
|
|
100
|
+
package: packageAddress,
|
|
101
|
+
module: 'delayed_execution_config',
|
|
102
|
+
function: 'delay_ms',
|
|
103
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export interface StallTimeoutMsArguments {
|
|
107
|
+
policy: TransactionArgument;
|
|
108
|
+
}
|
|
109
|
+
export interface StallTimeoutMsOptions {
|
|
110
|
+
package?: string;
|
|
111
|
+
arguments: StallTimeoutMsArguments | [policy: TransactionArgument];
|
|
112
|
+
config?: {
|
|
113
|
+
predictOrdersPackageId?: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export function stallTimeoutMs(options: StallTimeoutMsOptions) {
|
|
117
|
+
const packageAddress =
|
|
118
|
+
options.package ??
|
|
119
|
+
options.config?.predictOrdersPackageId ??
|
|
120
|
+
'@local-pkg/deepbook_predict_orders';
|
|
121
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
122
|
+
const parameterNames = ['policy'];
|
|
123
|
+
return (tx: Transaction) =>
|
|
124
|
+
tx.moveCall({
|
|
125
|
+
package: packageAddress,
|
|
126
|
+
module: 'delayed_execution_config',
|
|
127
|
+
function: 'stall_timeout_ms',
|
|
128
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
export interface StuckThresholdMsArguments {
|
|
132
|
+
policy: TransactionArgument;
|
|
133
|
+
}
|
|
134
|
+
export interface StuckThresholdMsOptions {
|
|
135
|
+
package?: string;
|
|
136
|
+
arguments: StuckThresholdMsArguments | [policy: TransactionArgument];
|
|
137
|
+
config?: {
|
|
138
|
+
predictOrdersPackageId?: string;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export function stuckThresholdMs(options: StuckThresholdMsOptions) {
|
|
142
|
+
const packageAddress =
|
|
143
|
+
options.package ??
|
|
144
|
+
options.config?.predictOrdersPackageId ??
|
|
145
|
+
'@local-pkg/deepbook_predict_orders';
|
|
146
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
147
|
+
const parameterNames = ['policy'];
|
|
148
|
+
return (tx: Transaction) =>
|
|
149
|
+
tx.moveCall({
|
|
150
|
+
package: packageAddress,
|
|
151
|
+
module: 'delayed_execution_config',
|
|
152
|
+
function: 'stuck_threshold_ms',
|
|
153
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export interface GapWaitMsArguments {
|
|
157
|
+
policy: TransactionArgument;
|
|
158
|
+
}
|
|
159
|
+
export interface GapWaitMsOptions {
|
|
160
|
+
package?: string;
|
|
161
|
+
arguments: GapWaitMsArguments | [policy: TransactionArgument];
|
|
162
|
+
config?: {
|
|
163
|
+
predictOrdersPackageId?: string;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export function gapWaitMs(options: GapWaitMsOptions) {
|
|
167
|
+
const packageAddress =
|
|
168
|
+
options.package ??
|
|
169
|
+
options.config?.predictOrdersPackageId ??
|
|
170
|
+
'@local-pkg/deepbook_predict_orders';
|
|
171
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
172
|
+
const parameterNames = ['policy'];
|
|
173
|
+
return (tx: Transaction) =>
|
|
174
|
+
tx.moveCall({
|
|
175
|
+
package: packageAddress,
|
|
176
|
+
module: 'delayed_execution_config',
|
|
177
|
+
function: 'gap_wait_ms',
|
|
178
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
export interface PythPriceBufferMsArguments {
|
|
182
|
+
policy: TransactionArgument;
|
|
183
|
+
}
|
|
184
|
+
export interface PythPriceBufferMsOptions {
|
|
185
|
+
package?: string;
|
|
186
|
+
arguments: PythPriceBufferMsArguments | [policy: TransactionArgument];
|
|
187
|
+
config?: {
|
|
188
|
+
predictOrdersPackageId?: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export function pythPriceBufferMs(options: PythPriceBufferMsOptions) {
|
|
192
|
+
const packageAddress =
|
|
193
|
+
options.package ??
|
|
194
|
+
options.config?.predictOrdersPackageId ??
|
|
195
|
+
'@local-pkg/deepbook_predict_orders';
|
|
196
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
197
|
+
const parameterNames = ['policy'];
|
|
198
|
+
return (tx: Transaction) =>
|
|
199
|
+
tx.moveCall({
|
|
200
|
+
package: packageAddress,
|
|
201
|
+
module: 'delayed_execution_config',
|
|
202
|
+
function: 'pyth_price_buffer_ms',
|
|
203
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
export interface PythChannelArguments {
|
|
207
|
+
policy: TransactionArgument;
|
|
208
|
+
}
|
|
209
|
+
export interface PythChannelOptions {
|
|
210
|
+
package?: string;
|
|
211
|
+
arguments: PythChannelArguments | [policy: TransactionArgument];
|
|
212
|
+
config?: {
|
|
213
|
+
predictOrdersPackageId?: string;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export function pythChannel(options: PythChannelOptions) {
|
|
217
|
+
const packageAddress =
|
|
218
|
+
options.package ??
|
|
219
|
+
options.config?.predictOrdersPackageId ??
|
|
220
|
+
'@local-pkg/deepbook_predict_orders';
|
|
221
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
222
|
+
const parameterNames = ['policy'];
|
|
223
|
+
return (tx: Transaction) =>
|
|
224
|
+
tx.moveCall({
|
|
225
|
+
package: packageAddress,
|
|
226
|
+
module: 'delayed_execution_config',
|
|
227
|
+
function: 'pyth_channel',
|
|
228
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
export interface SviMaxAgeMsArguments {
|
|
232
|
+
policy: TransactionArgument;
|
|
233
|
+
}
|
|
234
|
+
export interface SviMaxAgeMsOptions {
|
|
235
|
+
package?: string;
|
|
236
|
+
arguments: SviMaxAgeMsArguments | [policy: TransactionArgument];
|
|
237
|
+
config?: {
|
|
238
|
+
predictOrdersPackageId?: string;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export function sviMaxAgeMs(options: SviMaxAgeMsOptions) {
|
|
242
|
+
const packageAddress =
|
|
243
|
+
options.package ??
|
|
244
|
+
options.config?.predictOrdersPackageId ??
|
|
245
|
+
'@local-pkg/deepbook_predict_orders';
|
|
246
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
247
|
+
const parameterNames = ['policy'];
|
|
248
|
+
return (tx: Transaction) =>
|
|
249
|
+
tx.moveCall({
|
|
250
|
+
package: packageAddress,
|
|
251
|
+
module: 'delayed_execution_config',
|
|
252
|
+
function: 'svi_max_age_ms',
|
|
253
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
export interface MintCapacityArguments {
|
|
257
|
+
policy: TransactionArgument;
|
|
258
|
+
}
|
|
259
|
+
export interface MintCapacityOptions {
|
|
260
|
+
package?: string;
|
|
261
|
+
arguments: MintCapacityArguments | [policy: TransactionArgument];
|
|
262
|
+
config?: {
|
|
263
|
+
predictOrdersPackageId?: string;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export function mintCapacity(options: MintCapacityOptions) {
|
|
267
|
+
const packageAddress =
|
|
268
|
+
options.package ??
|
|
269
|
+
options.config?.predictOrdersPackageId ??
|
|
270
|
+
'@local-pkg/deepbook_predict_orders';
|
|
271
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
272
|
+
const parameterNames = ['policy'];
|
|
273
|
+
return (tx: Transaction) =>
|
|
274
|
+
tx.moveCall({
|
|
275
|
+
package: packageAddress,
|
|
276
|
+
module: 'delayed_execution_config',
|
|
277
|
+
function: 'mint_capacity',
|
|
278
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
export interface SellCapacityArguments {
|
|
282
|
+
policy: TransactionArgument;
|
|
283
|
+
}
|
|
284
|
+
export interface SellCapacityOptions {
|
|
285
|
+
package?: string;
|
|
286
|
+
arguments: SellCapacityArguments | [policy: TransactionArgument];
|
|
287
|
+
config?: {
|
|
288
|
+
predictOrdersPackageId?: string;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
export function sellCapacity(options: SellCapacityOptions) {
|
|
292
|
+
const packageAddress =
|
|
293
|
+
options.package ??
|
|
294
|
+
options.config?.predictOrdersPackageId ??
|
|
295
|
+
'@local-pkg/deepbook_predict_orders';
|
|
296
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
297
|
+
const parameterNames = ['policy'];
|
|
298
|
+
return (tx: Transaction) =>
|
|
299
|
+
tx.moveCall({
|
|
300
|
+
package: packageAddress,
|
|
301
|
+
module: 'delayed_execution_config',
|
|
302
|
+
function: 'sell_capacity',
|
|
303
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
export interface PerAccountCapArguments {
|
|
307
|
+
policy: TransactionArgument;
|
|
308
|
+
}
|
|
309
|
+
export interface PerAccountCapOptions {
|
|
310
|
+
package?: string;
|
|
311
|
+
arguments: PerAccountCapArguments | [policy: TransactionArgument];
|
|
312
|
+
config?: {
|
|
313
|
+
predictOrdersPackageId?: string;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
export function perAccountCap(options: PerAccountCapOptions) {
|
|
317
|
+
const packageAddress =
|
|
318
|
+
options.package ??
|
|
319
|
+
options.config?.predictOrdersPackageId ??
|
|
320
|
+
'@local-pkg/deepbook_predict_orders';
|
|
321
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
322
|
+
const parameterNames = ['policy'];
|
|
323
|
+
return (tx: Transaction) =>
|
|
324
|
+
tx.moveCall({
|
|
325
|
+
package: packageAddress,
|
|
326
|
+
module: 'delayed_execution_config',
|
|
327
|
+
function: 'per_account_cap',
|
|
328
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
export interface OrderFeeArguments {
|
|
332
|
+
policy: TransactionArgument;
|
|
333
|
+
}
|
|
334
|
+
export interface OrderFeeOptions {
|
|
335
|
+
package?: string;
|
|
336
|
+
arguments: OrderFeeArguments | [policy: TransactionArgument];
|
|
337
|
+
config?: {
|
|
338
|
+
predictOrdersPackageId?: string;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
export function orderFee(options: OrderFeeOptions) {
|
|
342
|
+
const packageAddress =
|
|
343
|
+
options.package ??
|
|
344
|
+
options.config?.predictOrdersPackageId ??
|
|
345
|
+
'@local-pkg/deepbook_predict_orders';
|
|
346
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
347
|
+
const parameterNames = ['policy'];
|
|
348
|
+
return (tx: Transaction) =>
|
|
349
|
+
tx.moveCall({
|
|
350
|
+
package: packageAddress,
|
|
351
|
+
module: 'delayed_execution_config',
|
|
352
|
+
function: 'order_fee',
|
|
353
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
export interface MinSellQuantityArguments {
|
|
357
|
+
policy: TransactionArgument;
|
|
358
|
+
}
|
|
359
|
+
export interface MinSellQuantityOptions {
|
|
360
|
+
package?: string;
|
|
361
|
+
arguments: MinSellQuantityArguments | [policy: TransactionArgument];
|
|
362
|
+
config?: {
|
|
363
|
+
predictOrdersPackageId?: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
export function minSellQuantity(options: MinSellQuantityOptions) {
|
|
367
|
+
const packageAddress =
|
|
368
|
+
options.package ??
|
|
369
|
+
options.config?.predictOrdersPackageId ??
|
|
370
|
+
'@local-pkg/deepbook_predict_orders';
|
|
371
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
372
|
+
const parameterNames = ['policy'];
|
|
373
|
+
return (tx: Transaction) =>
|
|
374
|
+
tx.moveCall({
|
|
375
|
+
package: packageAddress,
|
|
376
|
+
module: 'delayed_execution_config',
|
|
377
|
+
function: 'min_sell_quantity',
|
|
378
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
export interface SettleRefundBatchArguments {
|
|
382
|
+
policy: TransactionArgument;
|
|
383
|
+
}
|
|
384
|
+
export interface SettleRefundBatchOptions {
|
|
385
|
+
package?: string;
|
|
386
|
+
arguments: SettleRefundBatchArguments | [policy: TransactionArgument];
|
|
387
|
+
config?: {
|
|
388
|
+
predictOrdersPackageId?: string;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
export function settleRefundBatch(options: SettleRefundBatchOptions) {
|
|
392
|
+
const packageAddress =
|
|
393
|
+
options.package ??
|
|
394
|
+
options.config?.predictOrdersPackageId ??
|
|
395
|
+
'@local-pkg/deepbook_predict_orders';
|
|
396
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
397
|
+
const parameterNames = ['policy'];
|
|
398
|
+
return (tx: Transaction) =>
|
|
399
|
+
tx.moveCall({
|
|
400
|
+
package: packageAddress,
|
|
401
|
+
module: 'delayed_execution_config',
|
|
402
|
+
function: 'settle_refund_batch',
|
|
403
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
export interface SettlePayoutBatchArguments {
|
|
407
|
+
policy: TransactionArgument;
|
|
408
|
+
}
|
|
409
|
+
export interface SettlePayoutBatchOptions {
|
|
410
|
+
package?: string;
|
|
411
|
+
arguments: SettlePayoutBatchArguments | [policy: TransactionArgument];
|
|
412
|
+
config?: {
|
|
413
|
+
predictOrdersPackageId?: string;
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
export function settlePayoutBatch(options: SettlePayoutBatchOptions) {
|
|
417
|
+
const packageAddress =
|
|
418
|
+
options.package ??
|
|
419
|
+
options.config?.predictOrdersPackageId ??
|
|
420
|
+
'@local-pkg/deepbook_predict_orders';
|
|
421
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
422
|
+
const parameterNames = ['policy'];
|
|
423
|
+
return (tx: Transaction) =>
|
|
424
|
+
tx.moveCall({
|
|
425
|
+
package: packageAddress,
|
|
426
|
+
module: 'delayed_execution_config',
|
|
427
|
+
function: 'settle_payout_batch',
|
|
428
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
429
|
+
});
|
|
430
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Per-expiry Predict market.
|
|
7
|
+
*
|
|
8
|
+
* An ExpiryMarket is the hot shared object for one expiry. It owns trade
|
|
9
|
+
* execution, strike exposure state, and an embedded expiry-cash custody component,
|
|
10
|
+
* plus local sponsor-funded fee incentives. Live oracle validation is delegated to
|
|
11
|
+
* `pricing::load_live_pricer`; this module owns market flow policy and then passes
|
|
12
|
+
* loaded `Pricer` snapshots into exposure business logic. Pool-wide PLP accounting
|
|
13
|
+
* and profit accounting remain outside this module.
|
|
14
|
+
*
|
|
15
|
+
* It also owns the order-flow primitives an order-flow companion package drives.
|
|
16
|
+
* `admit_mint` and `admit_sell` admit one queued order, pin a mint's boundary
|
|
17
|
+
* nodes, record the order's cash need in the market's `OrderFlowLedger`, and issue
|
|
18
|
+
* or advance its `OrderReceipt`. `commit` stores the bounded Pyth price the order
|
|
19
|
+
* fills at, `try_fill` fills or refunds it, `release` takes it out without
|
|
20
|
+
* filling, and `try_pay_settled` pays a queue-held position after settlement. A
|
|
21
|
+
* queued fill never enters the account: its position stays in the receipt.
|
|
22
|
+
* Admission, commit, and fill need an allowlisted companion witness; release and
|
|
23
|
+
* the settled payout need only the receipt. The queue itself, its escrow, its
|
|
24
|
+
* policy, and its events live in the companion.
|
|
25
|
+
*
|
|
26
|
+
* Mainnet USDC is a regulated coin: Sui aborts a transaction that sends it to an
|
|
27
|
+
* address on its deny list, or to anyone while it is globally paused. So the fill,
|
|
28
|
+
* the fee routing, and the settled payout read `sui::deny_list` first and never
|
|
29
|
+
* send to such an address. A fill for a denied receive address is refused, a
|
|
30
|
+
* denied builder or referrer's fee stays in market cash, and a denied winner's
|
|
31
|
+
* payout is skipped for a later `try_pay_settled`.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
35
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
36
|
+
import { U64, U256 } from '../../../../bcs/integers.js';
|
|
37
|
+
import * as pricing from './pricing.js';
|
|
38
|
+
const $moduleName = 'deepbook_predict::expiry_market';
|
|
39
|
+
export const OrderParties = new MoveStruct({
|
|
40
|
+
name: `${$moduleName}::OrderParties`,
|
|
41
|
+
fields: {
|
|
42
|
+
account_id: bcs.Address,
|
|
43
|
+
owner: bcs.Address,
|
|
44
|
+
/** Sell proceeds and the settled payout go only here. */
|
|
45
|
+
receive_address: bcs.Address,
|
|
46
|
+
referrer_account_id: bcs.option(bcs.Address),
|
|
47
|
+
referrer_receive_address: bcs.option(bcs.Address),
|
|
48
|
+
builder_code_id: bcs.option(bcs.Address),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
export const OrderReceipt = new MoveStruct({
|
|
52
|
+
name: `${$moduleName}::OrderReceipt`,
|
|
53
|
+
fields: {
|
|
54
|
+
expiry_market_id: bcs.Address,
|
|
55
|
+
stage: bcs.u8(),
|
|
56
|
+
/** A `constants` mint kind, or `order_kind_sell` once a sell is admitted. */
|
|
57
|
+
kind: bcs.u8(),
|
|
58
|
+
/** The account's snapshot at the last admission. */
|
|
59
|
+
parties: OrderParties,
|
|
60
|
+
lower_tick: U64,
|
|
61
|
+
higher_tick: U64,
|
|
62
|
+
/** The exact mint quantity, or the sell's close quantity. */
|
|
63
|
+
quantity: U64,
|
|
64
|
+
max_premium: U64,
|
|
65
|
+
min_quantity: U64,
|
|
66
|
+
max_probability: U64,
|
|
67
|
+
min_probability: U64,
|
|
68
|
+
min_proceeds: U64,
|
|
69
|
+
/** Earliest Pyth generation time the order may price at. */
|
|
70
|
+
tau_ms: U64,
|
|
71
|
+
/** At or past it the order is refunded, never filled. */
|
|
72
|
+
deadline_ms: U64,
|
|
73
|
+
/** The Lazer channel τ was planned on; the committed price must come from it. */
|
|
74
|
+
channel: bcs.u8(),
|
|
75
|
+
vol: pricing.VolSnapshot,
|
|
76
|
+
budget: U64,
|
|
77
|
+
order_fee: U64,
|
|
78
|
+
/**
|
|
79
|
+
* Worst-case market cash the fill can consume. Counted in the ledger's
|
|
80
|
+
* `waiting_cash_need` while the order is admitted.
|
|
81
|
+
*/
|
|
82
|
+
cash_need: U64,
|
|
83
|
+
/**
|
|
84
|
+
* The t₀ quote's pre-subsidy trading fee, capped at `budget`. Bounds the subsidy
|
|
85
|
+
* `commit` reserves.
|
|
86
|
+
*/
|
|
87
|
+
subsidy_bound: U64,
|
|
88
|
+
subsidy_rate: U64,
|
|
89
|
+
subsidy_reserved: U64,
|
|
90
|
+
/** The committed Pyth price, 1e9-normalized; `0` until `commit`. */
|
|
91
|
+
spot: U64,
|
|
92
|
+
/** The committed update's envelope, in ms. The fill prices at it. */
|
|
93
|
+
tick_ms: U64,
|
|
94
|
+
/** The committed feed's own update time, in µs. */
|
|
95
|
+
generation_us: U64,
|
|
96
|
+
/** The open position's order ID; `0` until the mint fills. */
|
|
97
|
+
order_id: U256,
|
|
98
|
+
/** Stable economic-position handle, constant across partial closes. */
|
|
99
|
+
root_id: U256,
|
|
100
|
+
opened_at_ms: U64,
|
|
101
|
+
/**
|
|
102
|
+
* The open position's size, the quantity `order_id` names. The request's
|
|
103
|
+
* `quantity` is the mint or close quantity, so a sell admission never overwrites
|
|
104
|
+
* the size it closes.
|
|
105
|
+
*/
|
|
106
|
+
held_quantity: U64,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Pricing for Predict markets.
|
|
7
|
+
*
|
|
8
|
+
* This module reads canonical Propbook Pyth and Block Scholes feeds and computes
|
|
9
|
+
* SVI-adjusted digital probabilities. Live reads require fresh, pricing-safe Block
|
|
10
|
+
* Scholes spot, forward, and SVI observations. The latest forward is paired with
|
|
11
|
+
* an exact source-timestamp spot from Propbook's bounded recent history. The live
|
|
12
|
+
* forward comes from one of two admin-selected sources
|
|
13
|
+
* (`PricingConfig.use_pyth_spot_for_forward`): a fresh positive Pyth spot carrying
|
|
14
|
+
* the Block Scholes basis, or the Block Scholes forward directly. A load falls
|
|
15
|
+
* back to the Block Scholes forward when the selected Pyth spot is stale or
|
|
16
|
+
* unavailable; valuation prices on that fallback, while every live trade (mints,
|
|
17
|
+
* mint quotes, and live redeems) refuses it through `assert_pyth_spot_fresh`.
|
|
18
|
+
* Exact-history reads do not apply live freshness policy.
|
|
19
|
+
*
|
|
20
|
+
* Delayed execution splits that read in two. `load_vol` validates the same live
|
|
21
|
+
* inputs when an order is admitted and returns the raw Block Scholes basis and SVI
|
|
22
|
+
* its receipt stores; `pricer_at` later rebuilds a `Pricer` from them at the
|
|
23
|
+
* order's committed Pyth tick. The `try_*` reads price exactly as `up_price` and
|
|
24
|
+
* `range_price` do, and return `none` where those abort, so an order-flow fill
|
|
25
|
+
* never aborts on a surface.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
29
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
30
|
+
import { U64 } from '../../../../bcs/integers.js';
|
|
31
|
+
import * as i64 from '../fixed_math/i64.js';
|
|
32
|
+
const $moduleName = 'deepbook_predict::pricing';
|
|
33
|
+
export const VolSnapshot = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::VolSnapshot`,
|
|
35
|
+
fields: {
|
|
36
|
+
/**
|
|
37
|
+
* Canonical Propbook Pyth source for the market's underlying; commit finds this
|
|
38
|
+
* feed in each Lazer update.
|
|
39
|
+
*/
|
|
40
|
+
pyth_source_id: bcs.u32(),
|
|
41
|
+
/** The matched Block Scholes spot and forward, narrowed to Predict's width. */
|
|
42
|
+
bs_spot: U64,
|
|
43
|
+
bs_forward: U64,
|
|
44
|
+
/** Raw SVI parameters before roll-down, at 1e9. */
|
|
45
|
+
svi_a: i64.I64,
|
|
46
|
+
svi_b: U64,
|
|
47
|
+
svi_rho: i64.I64,
|
|
48
|
+
svi_m: i64.I64,
|
|
49
|
+
svi_sigma: U64,
|
|
50
|
+
/**
|
|
51
|
+
* Provider source timestamps of the three reads. The SVI one is also the roll-down
|
|
52
|
+
* anchor.
|
|
53
|
+
*/
|
|
54
|
+
bs_spot_source_timestamp_ms: U64,
|
|
55
|
+
bs_forward_source_timestamp_ms: U64,
|
|
56
|
+
svi_source_timestamp_ms: U64,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Signed integers represented by a `u64` magnitude and a canonical nonnegative
|
|
7
|
+
* zero. Scaled multiplication and division use 1e9 fixed point and truncate the
|
|
8
|
+
* result's magnitude toward zero.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
12
|
+
import { U64 } from '../../../../bcs/integers.js';
|
|
13
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
14
|
+
const $moduleName = 'fixed_math::i64';
|
|
15
|
+
export const I64 = new MoveStruct({
|
|
16
|
+
name: `${$moduleName}::I64`,
|
|
17
|
+
fields: {
|
|
18
|
+
magnitude: U64,
|
|
19
|
+
is_negative: bcs.bool(),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A storable handler for Balances in general. Is used in the `Coin` module to
|
|
7
|
+
* allow balance operations and can be used to implement custom coins with `Supply`
|
|
8
|
+
* and `Balance`s.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
12
|
+
import { U64 } from '../../../../bcs/integers.js';
|
|
13
|
+
const $moduleName = '0x2::balance';
|
|
14
|
+
export const Balance = new MoveStruct({
|
|
15
|
+
name: `${$moduleName}::Balance<phantom T>`,
|
|
16
|
+
fields: {
|
|
17
|
+
value: U64,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A table is a map-like collection. But unlike a traditional collection, it's keys
|
|
7
|
+
* and values are not stored within the `Table` value, but instead are stored using
|
|
8
|
+
* Sui's object system. The `Table` struct acts only as a handle into the object
|
|
9
|
+
* system to retrieve those keys and values. Note that this means that `Table`
|
|
10
|
+
* values with exactly the same key-value mapping will not be equal, with `==`, at
|
|
11
|
+
* runtime. For example
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* let table1 = table::new<u64, bool>();
|
|
15
|
+
* let table2 = table::new<u64, bool>();
|
|
16
|
+
* table::add(&mut table1, 0, false);
|
|
17
|
+
* table::add(&mut table1, 1, true);
|
|
18
|
+
* table::add(&mut table2, 0, false);
|
|
19
|
+
* table::add(&mut table2, 1, true);
|
|
20
|
+
* // table1 does not equal table2, despite having the same entries
|
|
21
|
+
* assert!(&table1 != &table2);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { MoveStruct } from '../../../utils/index.js';
|
|
26
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
27
|
+
import { U64 } from '../../../../bcs/integers.js';
|
|
28
|
+
const $moduleName = '0x2::table';
|
|
29
|
+
export const Table = new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::Table<phantom K, phantom V>`,
|
|
31
|
+
fields: {
|
|
32
|
+
/** the ID of this table */
|
|
33
|
+
id: bcs.Address,
|
|
34
|
+
/** the number of key-value pairs in the table */
|
|
35
|
+
size: U64,
|
|
36
|
+
},
|
|
37
|
+
});
|