@mysten/deepbook-v3 2.1.4 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/PREDICT.md +17 -5
- package/dist/account.d.mts.map +1 -1
- package/dist/account.mjs +3 -1
- package/dist/account.mjs.map +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs +1 -1
- package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +15 -6
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +53 -31
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +7 -7
- package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/predict_account.mjs +1 -1
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +13 -1
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/registry.mjs +2 -1
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +13 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs +19 -7
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/deployments/index.d.mts +3 -2
- package/dist/deployments/index.d.mts.map +1 -1
- package/dist/deployments/index.mjs +4 -1
- package/dist/deployments/index.mjs.map +1 -1
- package/dist/deployments/mainnet.d.mts +14 -0
- package/dist/deployments/mainnet.d.mts.map +1 -0
- package/dist/deployments/mainnet.mjs +73 -0
- package/dist/deployments/mainnet.mjs.map +1 -0
- package/dist/deployments/testnet.mjs +23 -23
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/deployments/types.d.mts +1 -1
- package/dist/predict/client.d.mts +25 -4
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +4 -4
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/index.d.mts +2 -0
- package/dist/predict/config/index.d.mts.map +1 -1
- package/dist/predict/config/index.mjs +4 -1
- package/dist/predict/config/index.mjs.map +1 -1
- package/dist/predict/config/mainnet.d.mts +17 -0
- package/dist/predict/config/mainnet.d.mts.map +1 -0
- package/dist/predict/config/mainnet.mjs +26 -0
- package/dist/predict/config/mainnet.mjs.map +1 -0
- package/dist/predict/config/types.d.mts +6 -0
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/index.d.mts +4 -2
- package/dist/predict/index.mjs +3 -1
- package/dist/predict/pricing.d.mts +6 -6
- package/dist/predict/pricing.d.mts.map +1 -1
- package/dist/predict/pricing.mjs +6 -6
- package/dist/predict/pricing.mjs.map +1 -1
- package/dist/predict/reads/balances.mjs.map +1 -1
- package/dist/predict/reads/markets.mjs +1 -1
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pricing.d.mts +2 -1
- package/dist/predict/reads/pricing.d.mts.map +1 -1
- package/dist/predict/reads/pricing.mjs.map +1 -1
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +3 -1
- 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/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/package.json +3 -3
- package/src/account.ts +3 -1
- package/src/contracts/deepbook_predict/builder_code.ts +3 -3
- package/src/contracts/deepbook_predict/config_events.ts +9 -2
- package/src/contracts/deepbook_predict/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_predict/expiry_cash.ts +1 -1
- package/src/contracts/deepbook_predict/expiry_market.ts +70 -11
- package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +3 -10
- package/src/contracts/deepbook_predict/market_manager.ts +2 -2
- package/src/contracts/deepbook_predict/order_events.ts +6 -6
- package/src/contracts/deepbook_predict/plp.ts +263 -81
- package/src/contracts/deepbook_predict/pool_accounting.ts +14 -14
- package/src/contracts/deepbook_predict/pool_valuation_cap.ts +69 -0
- package/src/contracts/deepbook_predict/predict_account.ts +1 -1
- package/src/contracts/deepbook_predict/pricing.ts +16 -4
- package/src/contracts/deepbook_predict/protocol_config.ts +202 -7
- package/src/contracts/deepbook_predict/registry.ts +91 -17
- package/src/contracts/deepbook_predict/strike_exposure.ts +1 -1
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +27 -0
- package/src/contracts/deepbook_predict/vault_events.ts +45 -14
- package/src/contracts/propbook/block_scholes_store.ts +8 -42
- package/src/deployments/index.ts +13 -3
- package/src/deployments/mainnet.ts +107 -0
- package/src/deployments/testnet.ts +25 -25
- package/src/deployments/types.ts +1 -1
- package/src/predict/client.ts +45 -15
- package/src/predict/config/index.ts +7 -2
- package/src/predict/config/mainnet.ts +27 -0
- package/src/predict/config/types.ts +7 -1
- package/src/predict/index.ts +5 -0
- package/src/predict/pricing.ts +11 -9
- package/src/predict/reads/balances.ts +1 -1
- package/src/predict/reads/markets.ts +1 -1
- package/src/predict/reads/pricing.ts +2 -1
- package/src/sessions.ts +4 -1
|
@@ -32,6 +32,18 @@ export const PricingSVI = new MoveStruct({
|
|
|
32
32
|
sigma: U64,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
+
export const FrozenPricer = new MoveStruct({
|
|
36
|
+
name: `${$moduleName}::FrozenPricer`,
|
|
37
|
+
fields: {
|
|
38
|
+
expiry_market_id: bcs.Address,
|
|
39
|
+
forward: U64,
|
|
40
|
+
svi: PricingSVI,
|
|
41
|
+
pyth_spot_source_timestamp_ms: U64,
|
|
42
|
+
block_scholes_spot_source_timestamp_ms: U64,
|
|
43
|
+
block_scholes_forward_source_timestamp_ms: U64,
|
|
44
|
+
block_scholes_svi_source_timestamp_ms: U64,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
35
47
|
export const Pricer = new MoveStruct({
|
|
36
48
|
name: `${$moduleName}::Pricer`,
|
|
37
49
|
fields: {
|
|
@@ -42,10 +54,10 @@ export const Pricer = new MoveStruct({
|
|
|
42
54
|
/**
|
|
43
55
|
* Timestamps of the oracle observations this snapshot validated, as trade events
|
|
44
56
|
* report them — each observation's own economic clock. Pyth carries its source
|
|
45
|
-
* timestamp (`0` only when no usable normalized observation exists);
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
57
|
+
* timestamp (`0` only when no usable normalized observation exists); Block Scholes
|
|
58
|
+
* spot and forward carry the provider `value_timestamp`, and SVI carries the
|
|
59
|
+
* provider `svi_timestamp`. Those timestamps are the clocks freshness gates and
|
|
60
|
+
* SVI roll-down use.
|
|
49
61
|
*/
|
|
50
62
|
pyth_spot_source_timestamp_ms: U64,
|
|
51
63
|
block_scholes_spot_source_timestamp_ms: U64,
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* Protocol-wide configuration and flow gates for Predict.
|
|
7
7
|
*
|
|
8
8
|
* This shared object owns the admin-tunable config structs, the trading pause
|
|
9
|
-
* gate, the protocol-wide emergency freeze, and the
|
|
10
|
-
*
|
|
9
|
+
* gate, the protocol-wide emergency freeze, and the full-pool valuation in-flight
|
|
10
|
+
* state (flag + flush ordinal, held across the transactions a flush spans;
|
|
11
|
+
* keeper/config flows gate on it, trading flows read it only to discard stale
|
|
12
|
+
* stamps lazily). Flow modules decide which gates apply before they mutate expiry,
|
|
11
13
|
* oracle, pool, or account state.
|
|
12
14
|
*/
|
|
13
15
|
|
|
@@ -41,7 +43,7 @@ export const ProtocolConfig = new MoveStruct({
|
|
|
41
43
|
referral_fee_rate: U64,
|
|
42
44
|
/**
|
|
43
45
|
* Fee charged on an executed PLP supply fill, in FLOAT_SCALING, deducted from the
|
|
44
|
-
*
|
|
46
|
+
* USDC taken in before shares are priced. Ships at zero — a deposit dilutes the
|
|
45
47
|
* pool's risk per dollar rather than concentrating it, so it is not taxed; the
|
|
46
48
|
* knob exists to keep that reversible.
|
|
47
49
|
*/
|
|
@@ -62,10 +64,25 @@ export const ProtocolConfig = new MoveStruct({
|
|
|
62
64
|
lp_request_limit_flush_attempts: U64,
|
|
63
65
|
/**
|
|
64
66
|
* Ceiling on LP-attributable pool value that queued supplies may raise the pool
|
|
65
|
-
* to, enforced at the flush against the frozen mark. Defaults to
|
|
66
|
-
*
|
|
67
|
+
* to, enforced at the flush against the frozen mark. Defaults to 500,000 USDC
|
|
68
|
+
* (RP-23).
|
|
67
69
|
*/
|
|
68
70
|
max_lp_pool_value: U64,
|
|
71
|
+
/**
|
|
72
|
+
* Hard staleness bound: `finish_flush` refuses to complete a flush in flight
|
|
73
|
+
* longer than this, so no LP request fills at a mark older than the window; past
|
|
74
|
+
* it the operator starts a fresh flush (which discards the stale one). A stalled
|
|
75
|
+
* flush blocks only LP queue fills and the flush-set markets' settlement — trading
|
|
76
|
+
* continues — so this also bounds LP-fill latency and is tuned alongside flush
|
|
77
|
+
* cadence (RP-29).
|
|
78
|
+
*/
|
|
79
|
+
max_valuation_window_ms: U64,
|
|
80
|
+
/**
|
|
81
|
+
* Window before a market's expiry in which live quotes, mints, and live redeems
|
|
82
|
+
* abort. Read live at trade time rather than snapshotted per market, so it can be
|
|
83
|
+
* widened on markets already trading. `0` disables.
|
|
84
|
+
*/
|
|
85
|
+
no_trade_window_ms: U64,
|
|
69
86
|
strike_exposure_template_config: strike_exposure_config.StrikeExposureConfig,
|
|
70
87
|
ewma_config: ewma_config.EwmaConfig,
|
|
71
88
|
/**
|
|
@@ -88,10 +105,30 @@ export const ProtocolConfig = new MoveStruct({
|
|
|
88
105
|
*/
|
|
89
106
|
frozen: bcs.bool(),
|
|
90
107
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
108
|
+
* True for the whole duration of a full-pool valuation, across every transaction
|
|
109
|
+
* it spans. Keeper cash flows, market lifecycle, and config mutations gate on it;
|
|
110
|
+
* trading flows do NOT — they read it (with `flush_seq`) only to discard a stale
|
|
111
|
+
* valuation stamp lazily; a pending market's snapshot state is captured, never
|
|
112
|
+
* recorded per trade (see `plp`).
|
|
93
113
|
*/
|
|
94
114
|
valuation_in_progress: bcs.bool(),
|
|
115
|
+
/**
|
|
116
|
+
* True ONLY while the atomic snapshot stage is open — set by `begin_snapshot` at
|
|
117
|
+
* `start_pool_valuation` and cleared by `end_snapshot` at
|
|
118
|
+
* `seal_valuation_snapshot`. Both live in one PTB (the `SnapshotStage` hot potato
|
|
119
|
+
* forces it), so this can never be observed across transactions: it blocks only a
|
|
120
|
+
* trade the keeper composes INTO its own snapshot PTB, where a mid-stamp cash move
|
|
121
|
+
* would skew the figures the seal freezes. The resumable valuation stage after the
|
|
122
|
+
* seal leaves it false, so trading stays live.
|
|
123
|
+
*/
|
|
124
|
+
snapshot_in_progress: bcs.bool(),
|
|
125
|
+
/**
|
|
126
|
+
* Monotonic flush ordinal, bumped by `begin_valuation`. A market's valuation stamp
|
|
127
|
+
* names the flush that made it; a stamp whose ordinal is not the current one — or
|
|
128
|
+
* held while no valuation is in flight — is stale and is lazily discarded by the
|
|
129
|
+
* next trade, so aborting a flush never has to visit its stamped markets.
|
|
130
|
+
*/
|
|
131
|
+
flush_seq: U64,
|
|
95
132
|
},
|
|
96
133
|
});
|
|
97
134
|
export interface IdArguments {
|
|
@@ -193,6 +230,43 @@ export function frozen(options: FrozenOptions) {
|
|
|
193
230
|
),
|
|
194
231
|
});
|
|
195
232
|
}
|
|
233
|
+
export interface ValuationInProgressArguments {
|
|
234
|
+
config?: RawTransactionArgument<string>;
|
|
235
|
+
}
|
|
236
|
+
export interface ValuationInProgressOptions {
|
|
237
|
+
package?: string;
|
|
238
|
+
arguments?: ValuationInProgressArguments;
|
|
239
|
+
config?: {
|
|
240
|
+
protocolConfig: ConfigValue;
|
|
241
|
+
predictPackageId?: string;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Return whether a full-pool valuation is in flight, for SDK and devInspect reads.
|
|
246
|
+
* The flush spans transactions, so "in flight" is an observable state: a keeper
|
|
247
|
+
* reads it to notice a flush it must finish or discard, and an integrator reads it
|
|
248
|
+
* to explain a gated keeper/config transaction. Trading is not gated on it.
|
|
249
|
+
*/
|
|
250
|
+
export function valuationInProgress(options: ValuationInProgressOptions) {
|
|
251
|
+
const packageAddress =
|
|
252
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
253
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
254
|
+
const parameterNames = ['config'];
|
|
255
|
+
return (tx: Transaction) =>
|
|
256
|
+
tx.moveCall({
|
|
257
|
+
package: packageAddress,
|
|
258
|
+
module: 'protocol_config',
|
|
259
|
+
function: 'valuation_in_progress',
|
|
260
|
+
arguments: normalizeMoveArguments(
|
|
261
|
+
{
|
|
262
|
+
...options.arguments,
|
|
263
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
264
|
+
},
|
|
265
|
+
argumentsTypes,
|
|
266
|
+
parameterNames,
|
|
267
|
+
),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
196
270
|
export interface ReferralFeeRateArguments {
|
|
197
271
|
config?: RawTransactionArgument<string>;
|
|
198
272
|
}
|
|
@@ -225,6 +299,43 @@ export function referralFeeRate(options: ReferralFeeRateOptions) {
|
|
|
225
299
|
),
|
|
226
300
|
});
|
|
227
301
|
}
|
|
302
|
+
export interface NoTradeWindowMsArguments {
|
|
303
|
+
config?: RawTransactionArgument<string>;
|
|
304
|
+
}
|
|
305
|
+
export interface NoTradeWindowMsOptions {
|
|
306
|
+
package?: string;
|
|
307
|
+
arguments?: NoTradeWindowMsArguments;
|
|
308
|
+
config?: {
|
|
309
|
+
protocolConfig: ConfigValue;
|
|
310
|
+
predictPackageId?: string;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Window before expiry in which live quotes, mints, and live redeems abort.
|
|
315
|
+
* `public` for SDK and devInspect reads: a client that cannot see this value can
|
|
316
|
+
* only learn the window closed by decoding `ETradeWindowClosed` from a failed
|
|
317
|
+
* quote.
|
|
318
|
+
*/
|
|
319
|
+
export function noTradeWindowMs(options: NoTradeWindowMsOptions) {
|
|
320
|
+
const packageAddress =
|
|
321
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
322
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
323
|
+
const parameterNames = ['config'];
|
|
324
|
+
return (tx: Transaction) =>
|
|
325
|
+
tx.moveCall({
|
|
326
|
+
package: packageAddress,
|
|
327
|
+
module: 'protocol_config',
|
|
328
|
+
function: 'no_trade_window_ms',
|
|
329
|
+
arguments: normalizeMoveArguments(
|
|
330
|
+
{
|
|
331
|
+
...options.arguments,
|
|
332
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
333
|
+
},
|
|
334
|
+
argumentsTypes,
|
|
335
|
+
parameterNames,
|
|
336
|
+
),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
228
339
|
export interface SetTemplateBaseFeeArguments {
|
|
229
340
|
config?: RawTransactionArgument<string>;
|
|
230
341
|
AdminCap: RawTransactionArgument<string>;
|
|
@@ -690,6 +801,47 @@ export function setLpRequestLimitFlushAttempts(options: SetLpRequestLimitFlushAt
|
|
|
690
801
|
),
|
|
691
802
|
});
|
|
692
803
|
}
|
|
804
|
+
export interface SetMaxValuationWindowMsArguments {
|
|
805
|
+
config?: RawTransactionArgument<string>;
|
|
806
|
+
AdminCap: RawTransactionArgument<string>;
|
|
807
|
+
windowMs: RawTransactionArgument<number | bigint>;
|
|
808
|
+
}
|
|
809
|
+
export interface SetMaxValuationWindowMsOptions {
|
|
810
|
+
package?: string;
|
|
811
|
+
arguments: SetMaxValuationWindowMsArguments;
|
|
812
|
+
config?: {
|
|
813
|
+
protocolConfig: ConfigValue;
|
|
814
|
+
predictPackageId?: string;
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Set how long a started full-pool valuation may stay in flight before anyone may
|
|
819
|
+
* discard it. A stalled flush costs LP-fill latency (and settlement latency for
|
|
820
|
+
* its own market set), not a trading pause, so this is an operator liveness knob:
|
|
821
|
+
* too short and a legitimate long flush can be discarded from under the keeper,
|
|
822
|
+
* too long and an abandoned one delays queued LP fills for that duration. See
|
|
823
|
+
* RP-29.
|
|
824
|
+
*/
|
|
825
|
+
export function setMaxValuationWindowMs(options: SetMaxValuationWindowMsOptions) {
|
|
826
|
+
const packageAddress =
|
|
827
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
828
|
+
const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[];
|
|
829
|
+
const parameterNames = ['config', 'AdminCap', 'windowMs'];
|
|
830
|
+
return (tx: Transaction) =>
|
|
831
|
+
tx.moveCall({
|
|
832
|
+
package: packageAddress,
|
|
833
|
+
module: 'protocol_config',
|
|
834
|
+
function: 'set_max_valuation_window_ms',
|
|
835
|
+
arguments: normalizeMoveArguments(
|
|
836
|
+
{
|
|
837
|
+
...options.arguments,
|
|
838
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
839
|
+
},
|
|
840
|
+
argumentsTypes,
|
|
841
|
+
parameterNames,
|
|
842
|
+
),
|
|
843
|
+
});
|
|
844
|
+
}
|
|
693
845
|
export interface SetMaxLpPoolValueArguments {
|
|
694
846
|
config?: RawTransactionArgument<string>;
|
|
695
847
|
AdminCap: RawTransactionArgument<string>;
|
|
@@ -802,6 +954,49 @@ export function setEwmaEnabled(options: SetEwmaEnabledOptions) {
|
|
|
802
954
|
),
|
|
803
955
|
});
|
|
804
956
|
}
|
|
957
|
+
export interface SetNoTradeWindowMsArguments {
|
|
958
|
+
config?: RawTransactionArgument<string>;
|
|
959
|
+
AdminCap: RawTransactionArgument<string>;
|
|
960
|
+
value: RawTransactionArgument<number | bigint>;
|
|
961
|
+
}
|
|
962
|
+
export interface SetNoTradeWindowMsOptions {
|
|
963
|
+
package?: string;
|
|
964
|
+
arguments: SetNoTradeWindowMsArguments;
|
|
965
|
+
config?: {
|
|
966
|
+
protocolConfig: ConfigValue;
|
|
967
|
+
predictPackageId?: string;
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Set the window before expiry in which live quotes, mints, and live redeems
|
|
972
|
+
* abort. `0` disables the block. Read live at trade time, so a change applies to
|
|
973
|
+
* markets already trading and stays available as an incident control.
|
|
974
|
+
*
|
|
975
|
+
* Deliberately not gated on `assert_not_valuation_in_progress`, matching
|
|
976
|
+
* `set_trading_paused`: a stalled flush must not be able to trap a safety control.
|
|
977
|
+
* Nothing in the flush reads this value, so a mid-valuation change cannot skew a
|
|
978
|
+
* frozen mark.
|
|
979
|
+
*/
|
|
980
|
+
export function setNoTradeWindowMs(options: SetNoTradeWindowMsOptions) {
|
|
981
|
+
const packageAddress =
|
|
982
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
983
|
+
const argumentsTypes = [null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];
|
|
984
|
+
const parameterNames = ['config', 'AdminCap', 'value'];
|
|
985
|
+
return (tx: Transaction) =>
|
|
986
|
+
tx.moveCall({
|
|
987
|
+
package: packageAddress,
|
|
988
|
+
module: 'protocol_config',
|
|
989
|
+
function: 'set_no_trade_window_ms',
|
|
990
|
+
arguments: normalizeMoveArguments(
|
|
991
|
+
{
|
|
992
|
+
...options.arguments,
|
|
993
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
994
|
+
},
|
|
995
|
+
argumentsTypes,
|
|
996
|
+
parameterNames,
|
|
997
|
+
),
|
|
998
|
+
});
|
|
999
|
+
}
|
|
805
1000
|
export interface SetTradingPausedArguments {
|
|
806
1001
|
config?: RawTransactionArgument<string>;
|
|
807
1002
|
AdminCap: RawTransactionArgument<string>;
|
|
@@ -38,11 +38,15 @@ export const Registry = new MoveStruct({
|
|
|
38
38
|
*/
|
|
39
39
|
allowed_pause_caps: vec_set.VecSet(bcs.Address),
|
|
40
40
|
/**
|
|
41
|
-
* IDs of `MarketLifecycleCap` objects currently authorized
|
|
42
|
-
*
|
|
43
|
-
* into this set and revokes from it.
|
|
41
|
+
* IDs of `MarketLifecycleCap` objects currently authorized to create expiry
|
|
42
|
+
* markets. Admin mints into this set and revokes from it.
|
|
44
43
|
*/
|
|
45
44
|
allowed_lifecycle_caps: vec_set.VecSet(bcs.Address),
|
|
45
|
+
/**
|
|
46
|
+
* IDs of `PoolValuationCap` objects currently authorized to start the full-pool
|
|
47
|
+
* valuation. Admin mints into this set and revokes from it.
|
|
48
|
+
*/
|
|
49
|
+
allowed_pool_valuation_caps: vec_set.VecSet(bcs.Address),
|
|
46
50
|
},
|
|
47
51
|
});
|
|
48
52
|
export interface IdArguments {
|
|
@@ -269,10 +273,7 @@ export interface MintLifecycleCapOptions {
|
|
|
269
273
|
predictPackageId?: string;
|
|
270
274
|
};
|
|
271
275
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Mint a version-gated `MarketLifecycleCap` with market-creation and valuation
|
|
274
|
-
* authority.
|
|
275
|
-
*/
|
|
276
|
+
/** Mint a version-gated `MarketLifecycleCap` with market-creation authority. */
|
|
276
277
|
export function mintLifecycleCap(options: MintLifecycleCapOptions) {
|
|
277
278
|
const packageAddress =
|
|
278
279
|
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
@@ -328,33 +329,106 @@ export function revokeLifecycleCap(options: RevokeLifecycleCapOptions) {
|
|
|
328
329
|
),
|
|
329
330
|
});
|
|
330
331
|
}
|
|
331
|
-
export interface
|
|
332
|
+
export interface MintPoolValuationCapArguments {
|
|
332
333
|
registry?: RawTransactionArgument<string>;
|
|
333
|
-
|
|
334
|
+
AdminCap: RawTransactionArgument<string>;
|
|
335
|
+
config?: RawTransactionArgument<string>;
|
|
336
|
+
}
|
|
337
|
+
export interface MintPoolValuationCapOptions {
|
|
338
|
+
package?: string;
|
|
339
|
+
arguments: MintPoolValuationCapArguments;
|
|
340
|
+
config?: {
|
|
341
|
+
registry: ConfigValue;
|
|
342
|
+
protocolConfig: ConfigValue;
|
|
343
|
+
predictPackageId?: string;
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Mint a version-gated `PoolValuationCap` with authority to start the full-pool
|
|
348
|
+
* valuation.
|
|
349
|
+
*/
|
|
350
|
+
export function mintPoolValuationCap(options: MintPoolValuationCapOptions) {
|
|
351
|
+
const packageAddress =
|
|
352
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
353
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
354
|
+
const parameterNames = ['registry', 'AdminCap', 'config'];
|
|
355
|
+
return (tx: Transaction) =>
|
|
356
|
+
tx.moveCall({
|
|
357
|
+
package: packageAddress,
|
|
358
|
+
module: 'registry',
|
|
359
|
+
function: 'mint_pool_valuation_cap',
|
|
360
|
+
arguments: normalizeMoveArguments(
|
|
361
|
+
{
|
|
362
|
+
...options.arguments,
|
|
363
|
+
registry: options.arguments?.registry ?? options.config?.registry,
|
|
364
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
365
|
+
},
|
|
366
|
+
argumentsTypes,
|
|
367
|
+
parameterNames,
|
|
368
|
+
),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
export interface RevokePoolValuationCapArguments {
|
|
372
|
+
registry?: RawTransactionArgument<string>;
|
|
373
|
+
AdminCap: RawTransactionArgument<string>;
|
|
374
|
+
poolValuationCapId: RawTransactionArgument<string>;
|
|
375
|
+
}
|
|
376
|
+
export interface RevokePoolValuationCapOptions {
|
|
377
|
+
package?: string;
|
|
378
|
+
arguments: RevokePoolValuationCapArguments;
|
|
379
|
+
config?: {
|
|
380
|
+
registry: ConfigValue;
|
|
381
|
+
predictPackageId?: string;
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/** Revoke a `PoolValuationCap` by ID without applying the version gate. */
|
|
385
|
+
export function revokePoolValuationCap(options: RevokePoolValuationCapOptions) {
|
|
386
|
+
const packageAddress =
|
|
387
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
388
|
+
const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[];
|
|
389
|
+
const parameterNames = ['registry', 'AdminCap', 'poolValuationCapId'];
|
|
390
|
+
return (tx: Transaction) =>
|
|
391
|
+
tx.moveCall({
|
|
392
|
+
package: packageAddress,
|
|
393
|
+
module: 'registry',
|
|
394
|
+
function: 'revoke_pool_valuation_cap',
|
|
395
|
+
arguments: normalizeMoveArguments(
|
|
396
|
+
{
|
|
397
|
+
...options.arguments,
|
|
398
|
+
registry: options.arguments?.registry ?? options.config?.registry,
|
|
399
|
+
},
|
|
400
|
+
argumentsTypes,
|
|
401
|
+
parameterNames,
|
|
402
|
+
),
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
export interface GeneratePoolValuationProofArguments {
|
|
406
|
+
registry?: RawTransactionArgument<string>;
|
|
407
|
+
poolValuationCap: RawTransactionArgument<string>;
|
|
334
408
|
}
|
|
335
|
-
export interface
|
|
409
|
+
export interface GeneratePoolValuationProofOptions {
|
|
336
410
|
package?: string;
|
|
337
|
-
arguments:
|
|
411
|
+
arguments: GeneratePoolValuationProofArguments;
|
|
338
412
|
config?: {
|
|
339
413
|
registry: ConfigValue;
|
|
340
414
|
predictPackageId?: string;
|
|
341
415
|
};
|
|
342
416
|
}
|
|
343
417
|
/**
|
|
344
|
-
* Generate a transaction-local proof that `
|
|
345
|
-
* allowlisted.
|
|
346
|
-
*
|
|
418
|
+
* Generate a transaction-local proof that `pool_valuation_cap` is currently
|
|
419
|
+
* allowlisted. `plp::start_pool_valuation` takes the proof by value so a revoked
|
|
420
|
+
* cap cannot start a valuation.
|
|
347
421
|
*/
|
|
348
|
-
export function
|
|
422
|
+
export function generatePoolValuationProof(options: GeneratePoolValuationProofOptions) {
|
|
349
423
|
const packageAddress =
|
|
350
424
|
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
351
425
|
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
352
|
-
const parameterNames = ['registry', '
|
|
426
|
+
const parameterNames = ['registry', 'poolValuationCap'];
|
|
353
427
|
return (tx: Transaction) =>
|
|
354
428
|
tx.moveCall({
|
|
355
429
|
package: packageAddress,
|
|
356
430
|
module: 'registry',
|
|
357
|
-
function: '
|
|
431
|
+
function: 'generate_pool_valuation_proof',
|
|
358
432
|
arguments: normalizeMoveArguments(
|
|
359
433
|
{
|
|
360
434
|
...options.arguments,
|
|
@@ -36,7 +36,7 @@ export const StrikeExposure = new MoveStruct({
|
|
|
36
36
|
/** Snapshotted exposure and fee policy for this expiry. */
|
|
37
37
|
config: strike_exposure_config.StrikeExposureConfig,
|
|
38
38
|
/**
|
|
39
|
-
* Immutable
|
|
39
|
+
* Immutable USDC scale for the inventory-impact curve. This is the expiry's
|
|
40
40
|
* snapshotted maximum pool allocation: a risk-capacity parameter, not live pool
|
|
41
41
|
* equity, so LP flows cannot reprice an existing book.
|
|
42
42
|
*/
|
|
@@ -31,6 +31,12 @@
|
|
|
31
31
|
* abort depends on which prefixes a given shape happens to visit, so it is not a
|
|
32
32
|
* desync detector — the per-boundary underflow in `apply_net_delta` is the
|
|
33
33
|
* authority.
|
|
34
|
+
*
|
|
35
|
+
* The module also owns the valuation snapshot for the resumable flush: while a
|
|
36
|
+
* flush generation is active, each node lazily captures its boundary quantities
|
|
37
|
+
* immediately before its first mutation under that generation (an untouched node
|
|
38
|
+
* is its own snapshot), and `walk_linear_frozen` prices the tree exactly as it
|
|
39
|
+
* stood at the snapshot instant through the same walk the live read uses.
|
|
34
40
|
*/
|
|
35
41
|
|
|
36
42
|
import { MoveStruct } from '../utils/index.js';
|
|
@@ -49,6 +55,19 @@ export const StrikePayoutTree = new MoveStruct({
|
|
|
49
55
|
* settled payout.
|
|
50
56
|
*/
|
|
51
57
|
base: U64,
|
|
58
|
+
/**
|
|
59
|
+
* Flush generation whose snapshot this tree holds. Node shadows are valid only
|
|
60
|
+
* against this value; monotonically increasing, 0 = never snapshotted.
|
|
61
|
+
*/
|
|
62
|
+
snapshot_seq: U64,
|
|
63
|
+
/**
|
|
64
|
+
* True from `activate_snapshot` until `release_snapshot`/`deactivate_snapshot`.
|
|
65
|
+
* While set, mutations capture shadows and emptied nodes with shadow quantities
|
|
66
|
+
* are retained for the frozen walk instead of removed.
|
|
67
|
+
*/
|
|
68
|
+
snapshot_active: bcs.bool(),
|
|
69
|
+
/** `base` as of the snapshot instant, captured eagerly at activation. */
|
|
70
|
+
snapshot_base: U64,
|
|
52
71
|
},
|
|
53
72
|
});
|
|
54
73
|
export const PayoutSummary = new MoveStruct({
|
|
@@ -84,6 +103,14 @@ export const PayoutNode = new MoveStruct({
|
|
|
84
103
|
*/
|
|
85
104
|
local_start: U64,
|
|
86
105
|
local_end: U64,
|
|
106
|
+
/**
|
|
107
|
+
* Boundary terms at generation `snapshot_seq`'s instant, captured before the first
|
|
108
|
+
* mutation under it. Active generation + zero shadows = created post-snapshot;
|
|
109
|
+
* older generation = untouched, live terms ARE the shadow.
|
|
110
|
+
*/
|
|
111
|
+
snapshot_local_start: U64,
|
|
112
|
+
snapshot_local_end: U64,
|
|
113
|
+
snapshot_seq: U64,
|
|
87
114
|
summary: PayoutSummary,
|
|
88
115
|
},
|
|
89
116
|
});
|
|
@@ -63,7 +63,7 @@ export const WithdrawRequested = new MoveStruct({
|
|
|
63
63
|
recipient: bcs.Address,
|
|
64
64
|
index: U64,
|
|
65
65
|
amount: U64,
|
|
66
|
-
|
|
66
|
+
min_usdc_out: U64,
|
|
67
67
|
requests_pending_after: U64,
|
|
68
68
|
},
|
|
69
69
|
});
|
|
@@ -107,20 +107,20 @@ export const SupplyFilled = new MoveStruct({
|
|
|
107
107
|
recipient: bcs.Address,
|
|
108
108
|
index: U64,
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* USDC actually taken into the pool, which is less than the request's escrow when
|
|
111
111
|
* the supply cap left only part of it room. Shares were priced on
|
|
112
|
-
* `
|
|
112
|
+
* `usdc_amount - fee_usdc`.
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
usdc_amount: U64,
|
|
115
115
|
shares_minted: U64,
|
|
116
|
-
/** Supply fee withheld from `
|
|
117
|
-
|
|
116
|
+
/** Supply fee withheld from `usdc_amount` and retained by the pool. */
|
|
117
|
+
fee_usdc: U64,
|
|
118
118
|
/**
|
|
119
119
|
* Escrow still queued at the head after a partial fill; `0` on a full fill, in
|
|
120
|
-
* which case the request is gone. `
|
|
121
|
-
*
|
|
120
|
+
* which case the request is gone. `usdc_amount + usdc_remaining` is the amount the
|
|
121
|
+
* request carried into this flush.
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
usdc_remaining: U64,
|
|
124
124
|
requests_pending_after: U64,
|
|
125
125
|
},
|
|
126
126
|
});
|
|
@@ -133,12 +133,12 @@ export const WithdrawFilled = new MoveStruct({
|
|
|
133
133
|
index: U64,
|
|
134
134
|
shares_burned: U64,
|
|
135
135
|
/**
|
|
136
|
-
* Net
|
|
137
|
-
*
|
|
136
|
+
* Net USDC delivered to `recipient`. The gross marked value of `shares_burned` was
|
|
137
|
+
* `usdc_amount + fee_usdc`.
|
|
138
138
|
*/
|
|
139
|
-
|
|
139
|
+
usdc_amount: U64,
|
|
140
140
|
/** Withdraw fee withheld from the payout and retained by the pool. */
|
|
141
|
-
|
|
141
|
+
fee_usdc: U64,
|
|
142
142
|
/**
|
|
143
143
|
* Escrowed PLP still queued at the head after a partial fill; `0` on a full fill,
|
|
144
144
|
* in which case the request is gone. `shares_burned + shares_remaining` is the
|
|
@@ -174,14 +174,45 @@ export const FlushExecuted = new MoveStruct({
|
|
|
174
174
|
active_market_nav: U64,
|
|
175
175
|
/** Number of active markets valued for this flush. */
|
|
176
176
|
market_count: U64,
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* LIVE idle USDC read at finish time, immediately before the drain — NOT a mark
|
|
179
|
+
* input. It brackets the drain with `idle_balance_after`; because maintenance,
|
|
180
|
+
* settlement sweeps, and trading run mid-window, it can differ from
|
|
181
|
+
* `frozen_idle_balance` below. Drain telemetry, not the mark.
|
|
182
|
+
*/
|
|
178
183
|
idle_balance_before: U64,
|
|
184
|
+
/**
|
|
185
|
+
* The mark's idle component: idle USDC FROZEN at the seal. `frozen_idle_balance
|
|
186
|
+
*
|
|
187
|
+
* - active_market_nav`reconstructs the priced mark's gross; every fill in the flush is priced from this, never from`idle_balance_before`.
|
|
188
|
+
*/
|
|
189
|
+
frozen_idle_balance: U64,
|
|
179
190
|
supplies_filled: U64,
|
|
180
191
|
withdrawals_filled: U64,
|
|
181
192
|
requests_processed: U64,
|
|
182
193
|
idle_balance_after: U64,
|
|
183
194
|
/** PLP supply after the drain's completed mints and burns. */
|
|
184
195
|
total_supply_after: U64,
|
|
196
|
+
/**
|
|
197
|
+
* Each queue's `next_index` at this flush's snapshot instant; the drain filled
|
|
198
|
+
* only requests indexed strictly below these.
|
|
199
|
+
*/
|
|
200
|
+
supply_request_cutoff: U64,
|
|
201
|
+
withdraw_request_cutoff: U64,
|
|
202
|
+
/**
|
|
203
|
+
* Clock instant the snapshot stage froze every market's pricer — the moment the
|
|
204
|
+
* mark prices the pool at. Fills execute later in the same flush; this is the
|
|
205
|
+
* timestamp they were priced as of.
|
|
206
|
+
*/
|
|
207
|
+
snapshot_timestamp_ms: U64,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
export const FlushRestarted = new MoveStruct({
|
|
211
|
+
name: `${$moduleName}::FlushRestarted`,
|
|
212
|
+
fields: {
|
|
213
|
+
pool_vault_id: bcs.Address,
|
|
214
|
+
expected_market_count: U64,
|
|
215
|
+
valued_market_count: U64,
|
|
185
216
|
},
|
|
186
217
|
});
|
|
187
218
|
export const CapitalLocked = new MoveStruct({
|