@mysten/deepbook-v3 2.8.2 → 2.9.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 +10 -0
- package/PREDICT.md +26 -13
- package/dist/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/account/account_events.d.mts.map +1 -1
- package/dist/contracts/account/account_registry.d.mts +19 -19
- package/dist/contracts/account/account_registry.d.mts.map +1 -1
- 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 +86 -81
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.mjs +9 -0
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +59 -59
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/market_manager.d.mts +33 -28
- package/dist/contracts/deepbook_predict/market_manager.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/market_manager.mjs +5 -3
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +2 -2
- package/dist/contracts/deepbook_predict/plp.d.mts +74 -74
- 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/predict_account.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.d.mts +67 -67
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +82 -82
- package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
- package/dist/contracts/deepbook_predict/registry.d.mts +108 -36
- package/dist/contracts/deepbook_predict/registry.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/registry.mjs +111 -7
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +131 -131
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +13 -13
- package/dist/contracts/deepbook_predict_math/math.d.mts +14 -14
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +30 -30
- package/dist/contracts/deepbook_predict_orders/desk.d.mts +28 -28
- package/dist/contracts/deepbook_predict_orders/desk.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +187 -187
- package/dist/contracts/deepbook_predict_orders/queue.d.mts +49 -49
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +140 -140
- 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 +27 -27
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/deployments/testnet.mjs +1 -1
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/predict/bindings/expiry-market.d.mts +5 -5
- package/dist/predict/bindings/protocol-config.d.mts +3 -3
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/package.json +1 -1
- package/src/contracts/deepbook_predict/config_events.ts +8 -0
- package/src/contracts/deepbook_predict/market_manager.ts +11 -5
- package/src/contracts/deepbook_predict/registry.ts +162 -6
- package/src/contracts/propbook/block_scholes_store.ts +48 -3
- package/src/contracts/propbook/registry.ts +45 -0
- package/src/deployments/testnet.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginProposalParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions343 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/poolProxy.d.ts
|
|
@@ -20,7 +20,7 @@ declare class PoolProxyContract {
|
|
|
20
20
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
23
|
+
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Place a market order. Enforces a post-trade `risk_ratio >=
|
|
26
26
|
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
@@ -28,7 +28,7 @@ declare class PoolProxyContract {
|
|
|
28
28
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
29
29
|
* @returns A function that takes a Transaction object
|
|
30
30
|
*/
|
|
31
|
-
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
31
|
+
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
32
32
|
/**
|
|
33
33
|
* @description Place a reduce only limit order. Requires the manager to have
|
|
34
34
|
* debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -37,7 +37,7 @@ declare class PoolProxyContract {
|
|
|
37
37
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
38
38
|
* @returns A function that takes a Transaction object
|
|
39
39
|
*/
|
|
40
|
-
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
40
|
+
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
41
41
|
/**
|
|
42
42
|
* @description Place a reduce only market order. Requires the manager to
|
|
43
43
|
* have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -46,7 +46,7 @@ declare class PoolProxyContract {
|
|
|
46
46
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
47
47
|
* @returns A function that takes a Transaction object
|
|
48
48
|
*/
|
|
49
|
-
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
49
|
+
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
50
50
|
/**
|
|
51
51
|
* @description Place a market order and repay the loan from the fill proceeds.
|
|
52
52
|
* The taker fill settles into the manager's balance, so the proceeds (plus any
|
|
@@ -58,7 +58,7 @@ declare class PoolProxyContract {
|
|
|
58
58
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
59
59
|
* @returns A function that takes a Transaction object
|
|
60
60
|
*/
|
|
61
|
-
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
61
|
+
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
62
62
|
/**
|
|
63
63
|
* @description Place a reduce only limit order and repay the loan from the
|
|
64
64
|
* fill proceeds. Requires debt on the relevant side (a bid needs base debt; an
|
|
@@ -68,7 +68,7 @@ declare class PoolProxyContract {
|
|
|
68
68
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
69
69
|
* @returns A function that takes a Transaction object
|
|
70
70
|
*/
|
|
71
|
-
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
71
|
+
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
72
72
|
/**
|
|
73
73
|
* @description Place a reduce only market order and repay the loan from the
|
|
74
74
|
* fill proceeds. Same reduce-only direction guard as
|
|
@@ -78,7 +78,7 @@ declare class PoolProxyContract {
|
|
|
78
78
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
79
79
|
* @returns A function that takes a Transaction object
|
|
80
80
|
*/
|
|
81
|
-
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
81
|
+
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions343.TransactionResult;
|
|
82
82
|
/**
|
|
83
83
|
* @description Modify an existing order
|
|
84
84
|
* @param {string} marginManagerKey The key to identify the MarginManager
|
package/package.json
CHANGED
|
@@ -153,6 +153,14 @@ export const CadenceConfigUpdated = new MoveStruct({
|
|
|
153
153
|
window_size: U64,
|
|
154
154
|
},
|
|
155
155
|
});
|
|
156
|
+
export const CadenceAdded = new MoveStruct({
|
|
157
|
+
name: `${$moduleName}::CadenceAdded`,
|
|
158
|
+
fields: {
|
|
159
|
+
registry_id: bcs.Address,
|
|
160
|
+
cadence_id: bcs.u8(),
|
|
161
|
+
period_ms: U64,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
156
164
|
export const ExpiryMarketMintPausedUpdated = new MoveStruct({
|
|
157
165
|
name: `${$moduleName}::ExpiryMarketMintPausedUpdated`,
|
|
158
166
|
fields: {
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Market identity and deployment cadence manager for Predict.
|
|
7
7
|
*
|
|
8
|
-
* `Registry` owns this state and delegates market admission to it.
|
|
9
|
-
*
|
|
10
|
-
* deployment terms, and per-underlying
|
|
8
|
+
* `Registry` owns this state and delegates market admission to it. Cadence periods
|
|
9
|
+
* live in the registry's admin-extended cadence table and are passed in, indexed
|
|
10
|
+
* by cadence ID; underlying rows, cadence deployment terms, and per-underlying
|
|
11
|
+
* watermarks are stored here. When two enabled cadences can create the same
|
|
12
|
+
* expiry, the one with the longer period owns it.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
@@ -66,9 +68,13 @@ export const DeployableMarket = new MoveStruct({
|
|
|
66
68
|
export const UnderlyingMarketConfig = new MoveStruct({
|
|
67
69
|
name: `${$moduleName}::UnderlyingMarketConfig`,
|
|
68
70
|
fields: {
|
|
69
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Deployment config indexed by cadence ID. Rows past its length are disabled; the
|
|
73
|
+
* vector grows past the six built-ins only when an added cadence is set or
|
|
74
|
+
* created, because package versions before the cadence table abort on longer rows.
|
|
75
|
+
*/
|
|
70
76
|
cadences: bcs.vector(CadenceConfig),
|
|
71
|
-
/** Highest deployed expiry timestamp indexed by cadence ID. */
|
|
77
|
+
/** Highest deployed expiry timestamp indexed by cadence ID; missing rows are 0. */
|
|
72
78
|
last_deployed_expiries: bcs.vector(U64),
|
|
73
79
|
},
|
|
74
80
|
});
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
MoveStruct,
|
|
17
|
+
MoveTuple,
|
|
17
18
|
normalizeMoveArguments,
|
|
18
19
|
type RawTransactionArgument,
|
|
19
20
|
type ConfigValue,
|
|
@@ -49,6 +50,10 @@ export const Registry = new MoveStruct({
|
|
|
49
50
|
allowed_pool_valuation_caps: vec_set.VecSet(bcs.Address),
|
|
50
51
|
},
|
|
51
52
|
});
|
|
53
|
+
export const CadencePeriodsKey = new MoveTuple({
|
|
54
|
+
name: `${$moduleName}::CadencePeriodsKey`,
|
|
55
|
+
fields: [bcs.bool()],
|
|
56
|
+
});
|
|
52
57
|
export interface IdArguments {
|
|
53
58
|
registry?: RawTransactionArgument<string>;
|
|
54
59
|
}
|
|
@@ -165,9 +170,9 @@ export interface CadenceConfigsOptions {
|
|
|
165
170
|
* Return one underlying's complete deployment policy as a single coherent
|
|
166
171
|
* snapshot, for off-chain consumers (SDK and devInspect cadence discovery by the
|
|
167
172
|
* keeper, price updater, and dashboard) that would otherwise need one read per
|
|
168
|
-
* cadence. The vector holds one entry per
|
|
169
|
-
* ID; disabled cadences are present as their all-zero configuration.
|
|
170
|
-
* underlying is not registered.
|
|
173
|
+
* cadence. The vector holds one entry per cadence in `cadence_periods`, indexed by
|
|
174
|
+
* cadence ID; disabled cadences are present as their all-zero configuration.
|
|
175
|
+
* Aborts if the underlying is not registered.
|
|
171
176
|
*/
|
|
172
177
|
export function cadenceConfigs(options: CadenceConfigsOptions) {
|
|
173
178
|
const packageAddress =
|
|
@@ -189,6 +194,43 @@ export function cadenceConfigs(options: CadenceConfigsOptions) {
|
|
|
189
194
|
),
|
|
190
195
|
});
|
|
191
196
|
}
|
|
197
|
+
export interface CadencePeriodsArguments {
|
|
198
|
+
registry?: RawTransactionArgument<string>;
|
|
199
|
+
}
|
|
200
|
+
export interface CadencePeriodsOptions {
|
|
201
|
+
package?: string;
|
|
202
|
+
arguments?: CadencePeriodsArguments;
|
|
203
|
+
config?: {
|
|
204
|
+
registry: ConfigValue;
|
|
205
|
+
predictPackageId?: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Return every cadence's period in milliseconds, indexed by cadence ID, for
|
|
210
|
+
* devInspect cadence discovery by the keeper, price collector, and dashboard. The
|
|
211
|
+
* table starts with the six built-in cadences and grows through `add_cadence`;
|
|
212
|
+
* read it in the same transaction as `cadence_configs` for a consistent pair.
|
|
213
|
+
*/
|
|
214
|
+
export function cadencePeriods(options: CadencePeriodsOptions) {
|
|
215
|
+
const packageAddress =
|
|
216
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
217
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
218
|
+
const parameterNames = ['registry'];
|
|
219
|
+
return (tx: Transaction) =>
|
|
220
|
+
tx.moveCall({
|
|
221
|
+
package: packageAddress,
|
|
222
|
+
module: 'registry',
|
|
223
|
+
function: 'cadence_periods',
|
|
224
|
+
arguments: normalizeMoveArguments(
|
|
225
|
+
{
|
|
226
|
+
...options.arguments,
|
|
227
|
+
registry: options.arguments?.registry ?? options.config?.registry,
|
|
228
|
+
},
|
|
229
|
+
argumentsTypes,
|
|
230
|
+
parameterNames,
|
|
231
|
+
),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
192
234
|
export interface MintPauseCapArguments {
|
|
193
235
|
registry?: RawTransactionArgument<string>;
|
|
194
236
|
AdminCap: RawTransactionArgument<string>;
|
|
@@ -592,6 +634,49 @@ export function registerUnderlying(options: RegisterUnderlyingOptions) {
|
|
|
592
634
|
),
|
|
593
635
|
});
|
|
594
636
|
}
|
|
637
|
+
export interface AddCadenceArguments {
|
|
638
|
+
registry?: RawTransactionArgument<string>;
|
|
639
|
+
config?: RawTransactionArgument<string>;
|
|
640
|
+
AdminCap: RawTransactionArgument<string>;
|
|
641
|
+
periodMs: RawTransactionArgument<number | bigint>;
|
|
642
|
+
}
|
|
643
|
+
export interface AddCadenceOptions {
|
|
644
|
+
package?: string;
|
|
645
|
+
arguments: AddCadenceArguments;
|
|
646
|
+
config?: {
|
|
647
|
+
registry: ConfigValue;
|
|
648
|
+
protocolConfig: ConfigValue;
|
|
649
|
+
predictPackageId?: string;
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Append a cadence with period `period_ms` to the cadence table and return its ID.
|
|
654
|
+
* The period is a whole number of minutes, at most one year, and not already in
|
|
655
|
+
* the table, which holds at most 16 cadences. A new cadence is disabled on every
|
|
656
|
+
* underlying until `set_template_cadence_config` sets its terms; periods never
|
|
657
|
+
* change, so retire a cadence by disabling it.
|
|
658
|
+
*/
|
|
659
|
+
export function addCadence(options: AddCadenceOptions) {
|
|
660
|
+
const packageAddress =
|
|
661
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
662
|
+
const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[];
|
|
663
|
+
const parameterNames = ['registry', 'config', 'AdminCap', 'periodMs'];
|
|
664
|
+
return (tx: Transaction) =>
|
|
665
|
+
tx.moveCall({
|
|
666
|
+
package: packageAddress,
|
|
667
|
+
module: 'registry',
|
|
668
|
+
function: 'add_cadence',
|
|
669
|
+
arguments: normalizeMoveArguments(
|
|
670
|
+
{
|
|
671
|
+
...options.arguments,
|
|
672
|
+
registry: options.arguments?.registry ?? options.config?.registry,
|
|
673
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
674
|
+
},
|
|
675
|
+
argumentsTypes,
|
|
676
|
+
parameterNames,
|
|
677
|
+
),
|
|
678
|
+
});
|
|
679
|
+
}
|
|
595
680
|
export interface SetTemplateCadenceConfigArguments {
|
|
596
681
|
registry?: RawTransactionArgument<string>;
|
|
597
682
|
config?: RawTransactionArgument<string>;
|
|
@@ -616,6 +701,8 @@ export interface SetTemplateCadenceConfigOptions {
|
|
|
616
701
|
/**
|
|
617
702
|
* Set all deployment terms for one underlying's cadence. Passing zero for all five
|
|
618
703
|
* values disables the cadence; otherwise all values must be nonzero and valid.
|
|
704
|
+
* Aborts if the underlying's enabled windows would sum past the pool's live-market
|
|
705
|
+
* cap.
|
|
619
706
|
*/
|
|
620
707
|
export function setTemplateCadenceConfig(options: SetTemplateCadenceConfigOptions) {
|
|
621
708
|
const packageAddress =
|
|
@@ -686,9 +773,10 @@ export interface CreateAndShareExpiryMarketOptions {
|
|
|
686
773
|
*
|
|
687
774
|
* Requires an allowlisted lifecycle capability, a registered underlying with all
|
|
688
775
|
* canonical feed objects bound, and an enabled cadence with a deployable slot.
|
|
689
|
-
*
|
|
690
|
-
* snapshots cadence and expiry policy, starts with zero cash, and cannot
|
|
691
|
-
* until pool rebalancing funds it. Live pricing reads current Propbook
|
|
776
|
+
* Slots owned by a longer enabled cadence and existing markets are skipped. The
|
|
777
|
+
* market snapshots cadence and expiry policy, starts with zero cash, and cannot
|
|
778
|
+
* mint until pool rebalancing funds it. Live pricing reads current Propbook
|
|
779
|
+
* bindings.
|
|
692
780
|
*/
|
|
693
781
|
export function createAndShareExpiryMarket(options: CreateAndShareExpiryMarketOptions) {
|
|
694
782
|
const packageAddress =
|
|
@@ -730,6 +818,74 @@ export function createAndShareExpiryMarket(options: CreateAndShareExpiryMarketOp
|
|
|
730
818
|
),
|
|
731
819
|
});
|
|
732
820
|
}
|
|
821
|
+
export interface CreateAndShareExpiryMarketAtArguments {
|
|
822
|
+
registry?: RawTransactionArgument<string>;
|
|
823
|
+
poolVault?: RawTransactionArgument<string>;
|
|
824
|
+
config?: RawTransactionArgument<string>;
|
|
825
|
+
propbookRegistry?: RawTransactionArgument<string>;
|
|
826
|
+
lifecycleCap: RawTransactionArgument<string>;
|
|
827
|
+
propbookUnderlyingId: RawTransactionArgument<number>;
|
|
828
|
+
cadenceId: RawTransactionArgument<number>;
|
|
829
|
+
expectedExpiry: RawTransactionArgument<number | bigint>;
|
|
830
|
+
}
|
|
831
|
+
export interface CreateAndShareExpiryMarketAtOptions {
|
|
832
|
+
package?: string;
|
|
833
|
+
arguments: CreateAndShareExpiryMarketAtArguments;
|
|
834
|
+
config?: {
|
|
835
|
+
registry: ConfigValue;
|
|
836
|
+
poolVault: ConfigValue;
|
|
837
|
+
protocolConfig: ConfigValue;
|
|
838
|
+
oracleRegistry: ConfigValue;
|
|
839
|
+
predictPackageId?: string;
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* `create_and_share_expiry_market`, aborting unless the deployable expiry is
|
|
844
|
+
* `expected_expiry`. A keeper that planned the expiry off chain uses this so that
|
|
845
|
+
* a stale view of the cadence table fails instead of creating an unplanned market.
|
|
846
|
+
*/
|
|
847
|
+
export function createAndShareExpiryMarketAt(options: CreateAndShareExpiryMarketAtOptions) {
|
|
848
|
+
const packageAddress =
|
|
849
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
850
|
+
const argumentsTypes = [
|
|
851
|
+
null,
|
|
852
|
+
null,
|
|
853
|
+
null,
|
|
854
|
+
null,
|
|
855
|
+
null,
|
|
856
|
+
'u32',
|
|
857
|
+
'u8',
|
|
858
|
+
'u64',
|
|
859
|
+
'0x2::clock::Clock',
|
|
860
|
+
] satisfies (string | null)[];
|
|
861
|
+
const parameterNames = [
|
|
862
|
+
'registry',
|
|
863
|
+
'poolVault',
|
|
864
|
+
'config',
|
|
865
|
+
'propbookRegistry',
|
|
866
|
+
'lifecycleCap',
|
|
867
|
+
'propbookUnderlyingId',
|
|
868
|
+
'cadenceId',
|
|
869
|
+
'expectedExpiry',
|
|
870
|
+
];
|
|
871
|
+
return (tx: Transaction) =>
|
|
872
|
+
tx.moveCall({
|
|
873
|
+
package: packageAddress,
|
|
874
|
+
module: 'registry',
|
|
875
|
+
function: 'create_and_share_expiry_market_at',
|
|
876
|
+
arguments: normalizeMoveArguments(
|
|
877
|
+
{
|
|
878
|
+
...options.arguments,
|
|
879
|
+
registry: options.arguments?.registry ?? options.config?.registry,
|
|
880
|
+
poolVault: options.arguments?.poolVault ?? options.config?.poolVault,
|
|
881
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
882
|
+
propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry,
|
|
883
|
+
},
|
|
884
|
+
argumentsTypes,
|
|
885
|
+
parameterNames,
|
|
886
|
+
),
|
|
887
|
+
});
|
|
888
|
+
}
|
|
733
889
|
export interface CreateAndShareBuilderCodeArguments {
|
|
734
890
|
registry?: RawTransactionArgument<string>;
|
|
735
891
|
config?: RawTransactionArgument<string>;
|
|
@@ -13,11 +13,18 @@
|
|
|
13
13
|
* so an unusable observation cannot claim a permanent key. Value and SVI
|
|
14
14
|
* observations use separate stores because the verifier exposes distinct batch and
|
|
15
15
|
* value types. The registry creates and binds both stores atomically from one
|
|
16
|
-
* base-asset input.
|
|
16
|
+
* base-asset input. An SVI store also derives its series ids from an admin-set
|
|
17
|
+
* provider model, so the admin chooses which of the provider's SVI surfaces the
|
|
18
|
+
* store accepts and serves.
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
import { type BcsType, bcs } from '@mysten/sui/bcs';
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
MoveStruct,
|
|
24
|
+
MoveTuple,
|
|
25
|
+
normalizeMoveArguments,
|
|
26
|
+
type RawTransactionArgument,
|
|
27
|
+
} from '../utils/index.js';
|
|
21
28
|
import { U64, U128, U256 } from '../../bcs/integers.js';
|
|
22
29
|
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
23
30
|
import * as table from './deps/sui/table.js';
|
|
@@ -86,6 +93,10 @@ export const BlockScholesSVIStore = new MoveStruct({
|
|
|
86
93
|
svis: table.Table,
|
|
87
94
|
},
|
|
88
95
|
});
|
|
96
|
+
export const SviModelKey = new MoveTuple({
|
|
97
|
+
name: `${$moduleName}::SviModelKey`,
|
|
98
|
+
fields: [bcs.bool()],
|
|
99
|
+
});
|
|
89
100
|
/**
|
|
90
101
|
* Emitted only for observations that were stored, so its presence means the series
|
|
91
102
|
* advanced.
|
|
@@ -119,6 +130,14 @@ export function BlockScholesObservationInserted<Observation extends BcsType<any>
|
|
|
119
130
|
},
|
|
120
131
|
});
|
|
121
132
|
}
|
|
133
|
+
export const BlockScholesSVIModelSet = new MoveStruct({
|
|
134
|
+
name: `${$moduleName}::BlockScholesSVIModelSet`,
|
|
135
|
+
fields: {
|
|
136
|
+
propbook_underlying_id: bcs.u32(),
|
|
137
|
+
propbook_oracle_id: bcs.Address,
|
|
138
|
+
svi_model: bcs.string(),
|
|
139
|
+
},
|
|
140
|
+
});
|
|
122
141
|
export const BlockScholesBatchIngested = new MoveStruct({
|
|
123
142
|
name: `${$moduleName}::BlockScholesBatchIngested`,
|
|
124
143
|
fields: {
|
|
@@ -257,6 +276,29 @@ export function sviStoreVersion(options: SviStoreVersionOptions) {
|
|
|
257
276
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
258
277
|
});
|
|
259
278
|
}
|
|
279
|
+
export interface SviModelArguments {
|
|
280
|
+
store: RawTransactionArgument<string>;
|
|
281
|
+
}
|
|
282
|
+
export interface SviModelOptions {
|
|
283
|
+
package?: string;
|
|
284
|
+
arguments: SviModelArguments | [store: RawTransactionArgument<string>];
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Returns the provider model this store's SVI series ids derive from, for relayer
|
|
288
|
+
* subscription construction through devInspect.
|
|
289
|
+
*/
|
|
290
|
+
export function sviModel(options: SviModelOptions) {
|
|
291
|
+
const packageAddress = options.package ?? '@local-pkg/propbook';
|
|
292
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
293
|
+
const parameterNames = ['store'];
|
|
294
|
+
return (tx: Transaction) =>
|
|
295
|
+
tx.moveCall({
|
|
296
|
+
package: packageAddress,
|
|
297
|
+
module: 'block_scholes_store',
|
|
298
|
+
function: 'svi_model',
|
|
299
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
300
|
+
});
|
|
301
|
+
}
|
|
260
302
|
export interface SpotSidArguments {
|
|
261
303
|
store: RawTransactionArgument<string>;
|
|
262
304
|
}
|
|
@@ -310,7 +352,10 @@ export interface SviSidOptions {
|
|
|
310
352
|
| SviSidArguments
|
|
311
353
|
| [store: RawTransactionArgument<string>, expiryMs: RawTransactionArgument<number | bigint>];
|
|
312
354
|
}
|
|
313
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Returns one canonical SVI series id, under the store's current model, for
|
|
357
|
+
* external subscription construction.
|
|
358
|
+
*/
|
|
314
359
|
export function sviSid(options: SviSidOptions) {
|
|
315
360
|
const packageAddress = options.package ?? '@local-pkg/propbook';
|
|
316
361
|
const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
|
|
@@ -594,3 +594,48 @@ export function replacePythBindingForUnderlying(options: ReplacePythBindingForUn
|
|
|
594
594
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
|
+
export interface SetBlockScholesSviModelArguments {
|
|
598
|
+
sviStore: RawTransactionArgument<string>;
|
|
599
|
+
AdminCap: RawTransactionArgument<string>;
|
|
600
|
+
sviModel: RawTransactionArgument<string>;
|
|
601
|
+
}
|
|
602
|
+
export interface SetBlockScholesSviModelOptions {
|
|
603
|
+
package?: string;
|
|
604
|
+
arguments:
|
|
605
|
+
| SetBlockScholesSviModelArguments
|
|
606
|
+
| [
|
|
607
|
+
sviStore: RawTransactionArgument<string>,
|
|
608
|
+
AdminCap: RawTransactionArgument<string>,
|
|
609
|
+
sviModel: RawTransactionArgument<string>,
|
|
610
|
+
];
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Admin-set the Block Scholes model `svi_store` derives its accepted and served
|
|
614
|
+
* SVI series ids from.
|
|
615
|
+
*
|
|
616
|
+
* The provider can publish more than one SVI surface for the same asset and
|
|
617
|
+
* expiry, each under its own model name, and the series id hashes that name.
|
|
618
|
+
* Setting the model therefore chooses which surface every consumer of this store
|
|
619
|
+
* prices from, for every expiry at once. A store whose model was never set uses
|
|
620
|
+
* `"SVI"`, and the store must be at the running package version. After a change, a
|
|
621
|
+
* batch signed under any other model aborts as a foreign series, so a relayer must
|
|
622
|
+
* resubscribe under the new model. A model never used on this store reads `none`
|
|
623
|
+
* until its first signed observation lands; a model set back serves its last
|
|
624
|
+
* stored rows again, which consumers accept for as long as those rows are within
|
|
625
|
+
* their freshness windows. Consumers linked to package version 1 keep reading the
|
|
626
|
+
* `"SVI"` rows under that version's hardcoded model until those rows age out.
|
|
627
|
+
* Confirm the provider publishes the model for every expiry the store serves
|
|
628
|
+
* before setting it.
|
|
629
|
+
*/
|
|
630
|
+
export function setBlockScholesSviModel(options: SetBlockScholesSviModelOptions) {
|
|
631
|
+
const packageAddress = options.package ?? '@local-pkg/propbook';
|
|
632
|
+
const argumentsTypes = [null, null, '0x1::string::String'] satisfies (string | null)[];
|
|
633
|
+
const parameterNames = ['sviStore', 'AdminCap', 'sviModel'];
|
|
634
|
+
return (tx: Transaction) =>
|
|
635
|
+
tx.moveCall({
|
|
636
|
+
package: packageAddress,
|
|
637
|
+
module: 'registry',
|
|
638
|
+
function: 'set_block_scholes_svi_model',
|
|
639
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
640
|
+
});
|
|
641
|
+
}
|
|
@@ -75,7 +75,7 @@ export const TESTNET_UNITS: DeploymentUnits = Object.freeze({
|
|
|
75
75
|
export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
76
76
|
network: 'testnet',
|
|
77
77
|
packages: Object.freeze({
|
|
78
|
-
predict: '
|
|
78
|
+
predict: '0x0e6ce5fcfd8f647f2a1ba134d9f3bc919bc3ea767871d24f6c2799e3d7d47fc9',
|
|
79
79
|
predictV1: '0x59d71119e990573a738dd3ff9c4c7d28d6893af69c87c1a7f3a2e90e280ce2f4',
|
|
80
80
|
account: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
|
|
81
81
|
propbook: '0xa83f9d7651de09672a40cea371c387bf954e0f3092947670d71428d4fbc9edd9',
|