@mysten/deepbook-v3 2.8.2 → 2.9.1
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 +28 -0
- package/PREDICT.md +26 -13
- package/dist/client.d.mts +2 -2
- 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/admin.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -1
- 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_lifecycle_cap.d.mts.map +1 -1
- 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 +5 -5
- package/dist/contracts/deepbook_predict/pause_cap.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.d.mts +74 -74
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts.map +1 -1
- 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/pricing.d.mts.map +1 -1
- 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/range_codec.d.mts.map +1 -1
- 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/expiry-market.d.mts.map +1 -1
- package/dist/predict/bindings/protocol-config.d.mts +3 -3
- package/dist/predict/bindings/protocol-config.d.mts.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/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/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +14 -4
- package/dist/utils/constants.mjs.map +1 -1
- 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
- package/src/utils/constants.ts +24 -9
|
@@ -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',
|
package/src/utils/constants.ts
CHANGED
|
@@ -17,11 +17,13 @@ export interface DeepbookPackageIds {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const testnetPackageIds = {
|
|
20
|
-
|
|
20
|
+
// deepbook core v21, kept in step with MARGIN_PACKAGE_ID (see the mainnet ids below).
|
|
21
|
+
DEEPBOOK_PACKAGE_ID: '0x4b1c2a827983d8fa73f6dc366cfab23636ae52e81e499d8724b71408fe6a00a4',
|
|
21
22
|
REGISTRY_ID: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',
|
|
22
23
|
DEEP_TREASURY_ID: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',
|
|
23
|
-
// deepbook_margin
|
|
24
|
-
|
|
24
|
+
// deepbook_margin v17, linked to core v21 — the same source as mainnet margin v8
|
|
25
|
+
// (`MARGIN_VERSION = 8`, legacy-Pyth entrypoints retired).
|
|
26
|
+
MARGIN_PACKAGE_ID: '0x0ad965f35189c7eca57d4718c8f5bf1b7f9f7eb4ced6d5b7aa6496a16d71e8d2',
|
|
25
27
|
MARGIN_V1: '0xb8620c24c9ea1a4a41e79613d2b3d1d93648d1bb6f6b789a7c8f261c94110e4b',
|
|
26
28
|
MARGIN_REGISTRY_ID: '0x48d7640dfae2c6e9ceeada197a7a1643984b5a24c55a0c6c023dac77e0339f75',
|
|
27
29
|
// margin_liquidation v4 — carries liquidate_base_upgraded / liquidate_quote_upgraded.
|
|
@@ -29,14 +31,16 @@ export const testnetPackageIds = {
|
|
|
29
31
|
} satisfies DeepbookPackageIds;
|
|
30
32
|
|
|
31
33
|
export const mainnetPackageIds = {
|
|
32
|
-
|
|
34
|
+
// deepbook core v9. Keep it in step with MARGIN_PACKAGE_ID: margin v8 links core v9, and a
|
|
35
|
+
// transaction that calls core v8 directly next to margin v8 fails with `InvalidLinkage`.
|
|
36
|
+
DEEPBOOK_PACKAGE_ID: '0xbca0cefe720330e7bb4f2283438b68de6a0e656688db4ac90d61e71fe6151fe8',
|
|
33
37
|
REGISTRY_ID: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',
|
|
34
38
|
DEEP_TREASURY_ID: '0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe',
|
|
35
|
-
// deepbook_margin
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
MARGIN_PACKAGE_ID: '
|
|
39
|
+
// deepbook_margin v8, linked to core v9. Its gate constant is `MARGIN_VERSION = 8`, which the
|
|
40
|
+
// upgrade transaction enabled on the mainnet MarginRegistry. v8 retires the legacy-Pyth
|
|
41
|
+
// entrypoints in the base modules (they abort `EDeprecatedUseUpgradedPyth`); every
|
|
42
|
+
// oracle-taking builder here already targets the `_upgraded` modules.
|
|
43
|
+
MARGIN_PACKAGE_ID: '0x40fa183b5602cd0f6c4d7b16c08766ad8d7d581608fbe3b2570fe72ab4f5625f',
|
|
40
44
|
MARGIN_V1: '0x97d9473771b01f77b0940c589484184b49f6444627ec121314fae6a6d36fb86b',
|
|
41
45
|
MARGIN_REGISTRY_ID: '0x0e40998b359a9ccbab22a98ed21bd4346abf19158bc7980c8291908086b3a742',
|
|
42
46
|
LIQUIDATION_PACKAGE_ID: '0xba2b39c026650fef52038c93c526fc5314a4286318a0d2a7054b65815178fb74',
|
|
@@ -245,6 +249,12 @@ export const mainnetCoins: CoinMap = {
|
|
|
245
249
|
type: `0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT`,
|
|
246
250
|
scalar: 1000000,
|
|
247
251
|
},
|
|
252
|
+
// Hashi BTC (on-chain symbol hBTC).
|
|
253
|
+
HBTC: {
|
|
254
|
+
address: `0xd30fb3f8914efdbeb7b8e85fae1d65dc584b44a1281f66737b92bb9f03a59d06`,
|
|
255
|
+
type: `0xd30fb3f8914efdbeb7b8e85fae1d65dc584b44a1281f66737b92bb9f03a59d06::btc::BTC`,
|
|
256
|
+
scalar: 100000000,
|
|
257
|
+
},
|
|
248
258
|
};
|
|
249
259
|
|
|
250
260
|
export const testnetPools: PoolMap = {
|
|
@@ -406,6 +416,11 @@ export const mainnetPools: PoolMap = {
|
|
|
406
416
|
baseCoin: 'USDSUI',
|
|
407
417
|
quoteCoin: 'USDC',
|
|
408
418
|
},
|
|
419
|
+
HBTC_USDC: {
|
|
420
|
+
address: '0x61368ab907934d7840d2e639b7fc2ee74785ffe3d46427d70e1ab8545f320c9b',
|
|
421
|
+
baseCoin: 'HBTC',
|
|
422
|
+
quoteCoin: 'USDC',
|
|
423
|
+
},
|
|
409
424
|
};
|
|
410
425
|
|
|
411
426
|
export const testnetMarginPools = {
|