@mysten-incubation/devstack 0.4.0 → 0.5.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/README.md CHANGED
@@ -6,7 +6,7 @@ Walrus, Seal, and DeepBook, and generate typed files for app and test code.
6
6
 
7
7
  The current docs live at <https://ts-sdks-incubation.vercel.app/devstack>.
8
8
 
9
- ## Quick Start
9
+ ## Quick start
10
10
 
11
11
  Scaffold a new app from the canonical template:
12
12
 
@@ -67,7 +67,6 @@ const app = hostService({
67
67
  export default defineDevstack({
68
68
  members: [localnet, app],
69
69
  stackName: 'main',
70
- codegen: { outputDir: 'src/generated' },
71
70
  });
72
71
  ```
73
72
 
@@ -90,10 +89,10 @@ pnpm devstack apply
90
89
  If `pnpm devstack up` is already live for this stack, `apply` asks that supervisor to reconcile and
91
90
  waits for completion. Without a live supervisor, it runs one-shot setup and exits.
92
91
 
93
- Generated files are written under `src/generated` by default. Runtime state, manifests, snapshots,
94
- and logs stay under `.devstack/`.
92
+ Generated bindings are written under `src/generated` by default. Runtime state, manifests,
93
+ snapshots, and logs stay under `.devstack/`.
95
94
 
96
- ## Package Surface
95
+ ## Package surface
97
96
 
98
97
  - Root API: stack composition, built-in factories, plugin-author helpers, and public types.
99
98
  - CLI: `devstack up`, `apply`, `codegen`, `dump-deployment`, `status`, `doctor`, `config`, `schema`,
@@ -108,8 +107,8 @@ engine internals directly.
108
107
 
109
108
  ## Docs
110
109
 
111
- - [Quickstart](https://ts-sdks-incubation.vercel.app/devstack/quickstart)
112
- - [Local development](https://ts-sdks-incubation.vercel.app/devstack/features/local-dev)
113
- - [Vitest integration](https://ts-sdks-incubation.vercel.app/devstack/features/testing-vitest)
114
- - [Playwright integration](https://ts-sdks-incubation.vercel.app/devstack/features/testing-playwright)
115
- - [Services](https://ts-sdks-incubation.vercel.app/devstack/features/services)
110
+ - [Overview](https://ts-sdks-incubation.vercel.app/devstack)
111
+ - [Local development](https://ts-sdks-incubation.vercel.app/devstack/configure/local-dev)
112
+ - [Vitest integration](https://ts-sdks-incubation.vercel.app/devstack/testing/testing-vitest)
113
+ - [Playwright integration](https://ts-sdks-incubation.vercel.app/devstack/testing/testing-playwright)
114
+ - [Codegen & deployments](https://ts-sdks-incubation.vercel.app/devstack/codegen/config-and-deployments)
package/dist/index.d.mts CHANGED
@@ -74,8 +74,8 @@ import { WalrusLocalClusterOptions } from "./plugins/walrus/mode/local-cluster.m
74
74
  import { WalrusKnownDeploymentOptions, WalrusKnownNetwork } from "./plugins/walrus/mode/known-deploy.mjs";
75
75
  import { WalrusBindings, WalrusNodeBinding } from "./plugins/walrus/codegen.mjs";
76
76
  import { WalCoinValue, WalrusResolved, walCoin, walrus, walrusFor } from "./plugins/walrus/index.mjs";
77
- import { SealKeyServer, SealKeyServerEntry, SealKnownResolved, SealLocalKeygenResolved, SealResolved } from "./plugins/seal/registry-publish.mjs";
78
77
  import { SealAnyError, SealConfigError, SealError } from "./plugins/seal/errors.mjs";
78
+ import { SealKeyServer, SealKeyServerEntry, SealKnownResolved, SealLocalKeygenResolved, SealResolved } from "./plugins/seal/registry-publish.mjs";
79
79
  import { SealBindings } from "./plugins/seal/codegen.mjs";
80
80
  import { SealCommonOptions, SealForkKnownOptions, SealLiveOptions, SealLocalKeygenOptions, SealOptions, seal, sealFor } from "./plugins/seal/index.mjs";
81
81
  import { DeepbookConfigError, DeepbookError, DeepbookPhase, DeepbookPluginError } from "./plugins/deepbook/errors.mjs";
@@ -94,6 +94,11 @@ interface DeepbookKnownExplicitOptions extends DeepbookKnownCommonOptions {
94
94
  readonly network?: DeepbookKnownNetwork;
95
95
  }
96
96
  type DeepbookKnownOptions = DeepbookKnownNetworkOptions | DeepbookKnownExplicitOptions;
97
+ /** Per-network factory options for `deepbookFor(net).testnet()`/`.mainnet()`.
98
+ * The `network` is injected by the namespace method, so the caller only
99
+ * supplies optional per-field overrides (`packageId`/`registryId`/`name`).
100
+ * Plugin-INTERNAL — deliberately NOT re-exported from `src/index.ts`. */
101
+ type DeepbookKnownByNetworkOptions = Omit<DeepbookKnownNetworkOptions, 'network'>;
97
102
  type DeepbookOptions<Publisher extends AccountMemberAlias = AccountMemberAlias, Pyth extends PythOptions | undefined = PythOptions | undefined> = ({
98
103
  readonly mode: 'local';
99
104
  } & DeepbookLocalOptions<Publisher, DeepbookPackageMember, ReadonlyArray<DeepbookPoolSpec>, Pyth>) | ({
@@ -134,14 +139,21 @@ declare function deepbookCore<const Publisher extends AccountMemberAlias, const
134
139
  * const local = { mode: 'local', network: 'localnet' } as const;
135
140
  * deepbookFor(local).local({publisher, package, pools}) // OK
136
141
  * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK
137
- * deepbookFor(local).known({...}) // OK
142
+ * deepbookFor(local).testnet() // OK (known testnet)
143
+ * deepbookFor(local).known({packageId, registryId}) // OK (raw-id override)
144
+ *
145
+ * const live = { mode: 'live', chainId: 'sui:testnet' } as const;
146
+ * deepbookFor(live).mainnet() // OK (known mainnet)
138
147
  *
139
148
  * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;
140
149
  * deepbookFor(fork).local({...}) // COMPILE ERROR
141
150
  * deepbookFor(fork).override({...}) // COMPILE ERROR
142
151
  *
143
- * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`
144
- * is a compile-time refusal. */
152
+ * Per-network methods (`.testnet`/`.mainnet`) inject the network into
153
+ * `buildKnownPlugin`; `.known(...)` is now the raw-id explicit-override form
154
+ * only (`DeepbookKnownExplicitOptions`) — the `network`-in-`.known()` path was
155
+ * HARD CUT. The fork branch has NO `.local` or `.override` entry —
156
+ * `deepbookFor(forkNetwork).local` is a compile-time refusal. */
145
157
  declare const deepbookFor: ModeNamespace<{
146
158
  local: {
147
159
  local: <const Publisher extends AccountMemberAlias, const Package extends DeepbookPackageMember, const Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [], const Pyth extends PythOptions | undefined = undefined>(opts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
@@ -150,17 +162,35 @@ declare const deepbookFor: ModeNamespace<{
150
162
  override: (opts: DeepbookOverrideOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
151
163
  readonly mode: SuiOptions["mode"];
152
164
  }>]>;
153
- known: (opts: DeepbookKnownOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
165
+ known: (opts: DeepbookKnownExplicitOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
166
+ readonly mode: SuiOptions["mode"];
167
+ }>]>;
168
+ testnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
169
+ readonly mode: SuiOptions["mode"];
170
+ }>]>;
171
+ mainnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
154
172
  readonly mode: SuiOptions["mode"];
155
173
  }>]>;
156
174
  };
157
175
  live: {
158
- known: (opts: DeepbookKnownOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
176
+ known: (opts: DeepbookKnownExplicitOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
177
+ readonly mode: SuiOptions["mode"];
178
+ }>]>;
179
+ testnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
180
+ readonly mode: SuiOptions["mode"];
181
+ }>]>;
182
+ mainnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
159
183
  readonly mode: SuiOptions["mode"];
160
184
  }>]>;
161
185
  };
162
186
  fork: {
163
- known: (opts: DeepbookKnownOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
187
+ known: (opts: DeepbookKnownExplicitOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
188
+ readonly mode: SuiOptions["mode"];
189
+ }>]>;
190
+ testnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
191
+ readonly mode: SuiOptions["mode"];
192
+ }>]>;
193
+ mainnet: (opts?: DeepbookKnownByNetworkOptions) => Plugin<`deepbook/${string}`, DeepbookResolved, readonly [ResourceRef<"sui", SuiClient & {
164
194
  readonly mode: SuiOptions["mode"];
165
195
  }>]>;
166
196
  };
@@ -19,31 +19,32 @@ import { createDeepbookPools, seedDeepbookPools } from "./deploy.mjs";
19
19
  import "./types.mjs";
20
20
  import { initLocalPythFeeds } from "./pyth/index.mjs";
21
21
  import { Effect } from "effect";
22
+ import { mainnetPackageIds, mainnetPythConfigs, testnetPackageIds, testnetPythConfigs } from "@mysten/deepbook-v3";
22
23
  //#region src/plugins/deepbook/index.ts
23
24
  const makeDeepbookResource = (name) => resource(`deepbook/${name}`);
24
25
  const DEFAULT_NAME = "deepbook";
25
26
  const KNOWN_DEEPBOOK_DEPLOYMENTS = {
26
27
  testnet: {
27
28
  network: "testnet",
28
- packageId: "0x22be4cade64bf2d02412c7e8d0e8beea2f78828b948118d46735315409371a3c",
29
- registryId: "0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1",
30
- deepTreasuryId: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb",
29
+ packageId: testnetPackageIds.DEEPBOOK_PACKAGE_ID,
30
+ registryId: testnetPackageIds.REGISTRY_ID,
31
+ deepTreasuryId: testnetPackageIds.DEEP_TREASURY_ID,
31
32
  pyth: {
32
33
  packageId: null,
33
- stateId: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c",
34
- wormholeStateId: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
34
+ stateId: testnetPythConfigs.pythStateId,
35
+ wormholeStateId: testnetPythConfigs.wormholeStateId,
35
36
  feeds: []
36
37
  }
37
38
  },
38
39
  mainnet: {
39
40
  network: "mainnet",
40
- packageId: "0xf48222c4e057fa468baf136bff8e12504209d43850c5778f76159292a96f621e",
41
- registryId: "0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d",
42
- deepTreasuryId: "0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe",
41
+ packageId: mainnetPackageIds.DEEPBOOK_PACKAGE_ID,
42
+ registryId: mainnetPackageIds.REGISTRY_ID,
43
+ deepTreasuryId: mainnetPackageIds.DEEP_TREASURY_ID,
43
44
  pyth: {
44
45
  packageId: null,
45
- stateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
46
- wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
46
+ stateId: mainnetPythConfigs.pythStateId,
47
+ wormholeStateId: mainnetPythConfigs.wormholeStateId,
47
48
  feeds: []
48
49
  }
49
50
  }
@@ -408,22 +409,57 @@ function deepbookCore(opts) {
408
409
  * const local = { mode: 'local', network: 'localnet' } as const;
409
410
  * deepbookFor(local).local({publisher, package, pools}) // OK
410
411
  * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK
411
- * deepbookFor(local).known({...}) // OK
412
+ * deepbookFor(local).testnet() // OK (known testnet)
413
+ * deepbookFor(local).known({packageId, registryId}) // OK (raw-id override)
414
+ *
415
+ * const live = { mode: 'live', chainId: 'sui:testnet' } as const;
416
+ * deepbookFor(live).mainnet() // OK (known mainnet)
412
417
  *
413
418
  * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;
414
419
  * deepbookFor(fork).local({...}) // COMPILE ERROR
415
420
  * deepbookFor(fork).override({...}) // COMPILE ERROR
416
421
  *
417
- * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`
418
- * is a compile-time refusal. */
422
+ * Per-network methods (`.testnet`/`.mainnet`) inject the network into
423
+ * `buildKnownPlugin`; `.known(...)` is now the raw-id explicit-override form
424
+ * only (`DeepbookKnownExplicitOptions`) — the `network`-in-`.known()` path was
425
+ * HARD CUT. The fork branch has NO `.local` or `.override` entry —
426
+ * `deepbookFor(forkNetwork).local` is a compile-time refusal. */
419
427
  const deepbookFor = defineModeNamespace({
420
428
  local: {
421
429
  local: (opts) => buildLocalPluginPublic(opts),
422
430
  override: (opts) => buildOverridePlugin(opts),
423
- known: (opts) => buildKnownPlugin(opts)
431
+ known: (opts) => buildKnownPlugin(opts),
432
+ testnet: (opts = {}) => buildKnownPlugin({
433
+ network: "testnet",
434
+ ...opts
435
+ }),
436
+ mainnet: (opts = {}) => buildKnownPlugin({
437
+ network: "mainnet",
438
+ ...opts
439
+ })
440
+ },
441
+ live: {
442
+ known: (opts) => buildKnownPlugin(opts),
443
+ testnet: (opts = {}) => buildKnownPlugin({
444
+ network: "testnet",
445
+ ...opts
446
+ }),
447
+ mainnet: (opts = {}) => buildKnownPlugin({
448
+ network: "mainnet",
449
+ ...opts
450
+ })
424
451
  },
425
- live: { known: (opts) => buildKnownPlugin(opts) },
426
- fork: { known: (opts) => buildKnownPlugin(opts) }
452
+ fork: {
453
+ known: (opts) => buildKnownPlugin(opts),
454
+ testnet: (opts = {}) => buildKnownPlugin({
455
+ network: "testnet",
456
+ ...opts
457
+ }),
458
+ mainnet: (opts = {}) => buildKnownPlugin({
459
+ network: "mainnet",
460
+ ...opts
461
+ })
462
+ }
427
463
  });
428
464
  //#endregion
429
465
  export { deepbookCore, deepbookFor };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["coinFromPackage","builtinCoin","localOpts"],"sources":["../../../src/plugins/deepbook/index.ts"],"sourcesContent":["// Deepbook plugin — barrel + factories.\n//\n// Architecture: Deepbook is a task plugin that resolves a managed\n// local deployment, a known deployment, or explicit caller-supplied\n// override ids, then emits bindings.\n//\n// Mode discipline:\n//\n// - `deepbook(opts)` — explicit mode selection.\n// Localnet can default to local when\n// passed local options.\n// - `deepbookFor(network).local` — local-branch managed deployment.\n// - `deepbookFor(network).override` — local-branch override for\n// caller-supplied deployment ids.\n// - `deepbookFor(network).known` — known-deployment branch (live +\n// fork networks; wraps an already-\n// deployed canonical instance).\n//\n// During `start`, the plugin emits (via the typed `ctx.*` verbs):\n//\n// Local mode:\n// 1. `ctx.snapshotExtra` — `deepbook/<name>` subtree.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Override mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Known mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings (mode='known').\n//\n// Resource id: `deepbook/<name>`. Plugin key: `deepbook:<name>`.\n\nimport { Effect } from 'effect';\n\nimport { defineModeNamespace } from '../../api/mode-narrowed-factory.ts';\nimport { definePlugin, resource, type ResourceValueOf } from '../../api/define-plugin.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport { PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { setCurrentPluginPhase } from '../../substrate/runtime/current-plugin.ts';\nimport { passthroughOrWrap } from '../../substrate/runtime/passthrough-or-wrap.ts';\nimport { IdentityContext } from '../../substrate/runtime/paths.ts';\nimport { suiResource } from '../sui/index.ts';\nimport type { AccountValue } from '../account/index.ts';\nimport {\n\tbuiltin as builtinCoin,\n\tfromPackage as coinFromPackage,\n\ttype CoinValue,\n} from '../coin/index.ts';\nimport type { LocalPackageResolved } from '../package/index.ts';\n\nimport { deepbookPluginKey } from './plugin-key.ts';\nimport {\n\tDEEPBOOK_ERROR_TAGS,\n\tdeepbookConfigError,\n\tdeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n} from './errors.ts';\nimport {\n\tmakeDeepbookCodegenable,\n\tmakeDeepbookStaticCodegen,\n\ttype DeepbookBindings,\n} from './codegen.ts';\nimport { LOCAL_NETWORK_NAME } from '../../api/inference-network.ts';\nimport {\n\tmakeDeepbookDeepFundingContribution,\n\tmakeDeepbookDeepFundingStrategy,\n\ttype DeepbookDeepFundingStrategy,\n} from './faucet-strategy.ts';\nimport { makeKnownSnapshotable, makeLocalSnapshotable } from './snapshot.ts';\nimport {\n\tcreateDeepbookPools,\n\tseedDeepbookPools,\n\ttype DeepbookDeployment,\n\ttype ResolvedDeepbookPoolSpec,\n} from './deploy.ts';\nimport { initLocalPythFeeds } from './pyth/index.ts';\nimport type {\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolSpec,\n\tPythHandle,\n\tPythOptions,\n} from './types.ts';\n\n// ---------------------------------------------------------------------------\n// Resource — the resolved value all consumers read\n// ---------------------------------------------------------------------------\n\nexport type DeepbookResourceId<Name extends string> = `deepbook/${Name}`;\n\nconst makeDeepbookResource = <Name extends string>(name: Name) =>\n\tresource<DeepbookResourceId<Name>, DeepbookResolved>(\n\t\t`deepbook/${name}` as DeepbookResourceId<Name>,\n\t);\n\n/** The deepbook resolved value. Mode-asymmetric:\n *\n * - `adminCapId` is `null` for known-deployment mode.\n * - `margin` / `serverUrl` / `indexerUrl` are `null` when the\n * corresponding sub-feature is not enabled.\n * - `hasSeedLiquidity` is `true` when one or more pools placed seed\n * orders at boot (it is NOT a market-maker process state). */\nexport interface DeepbookResolved {\n\treadonly mode: 'local' | 'override' | 'known';\n\treadonly network: string;\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string | null;\n\treadonly deepTreasuryId: string | null;\n\treadonly pools: ReadonlyArray<DeepbookPool>;\n\treadonly pyth: PythHandle | null;\n\treadonly margin: {\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t} | null;\n\treadonly serverUrl: string | null;\n\treadonly indexerUrl: string | null;\n\t/** `true` when one or more pools placed seed orders at boot. This reflects\n\t * \"a pool was seeded with liquidity\", NOT a running market-maker process. */\n\treadonly hasSeedLiquidity: boolean;\n\treadonly deepFundingStrategy: DeepbookDeepFundingStrategy | null;\n}\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface DeepbookCommonOptions {\n\treadonly name?: string;\n}\n\n/** Override mode wraps an explicitly supplied deployment. It does not\n * publish or manage DeepBook locally. */\nexport interface DeepbookOverrideOptions extends DeepbookCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string;\n\treadonly network?: string;\n}\n\n/** Local mode wraps an explicitly supplied local DeepBook package.\n *\n * Explicit-config discipline: `publisher`, `package`, and `pools` are all\n * REQUIRED — the caller publishes the DeepBook Move tree, funds a publisher,\n * and declares the pools. There is no zero-arg auto-synthesis; an\n * under-specified `deepbook({ mode: 'local' })` fails fast with a tagged\n * config error (see the guard in `resolveLocalOptions`). `pyth` stays\n * optional — pass it to seed local mock price feeds, omit it for a\n * feed-less DeX. */\nexport interface DeepbookLocalOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPackage extends DeepbookPackageMember = DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tPyth extends PythOptions | undefined = undefined,\n> extends DeepbookCommonOptions {\n\t/** Publisher account — Direct Member Ref (locked API decision). Required. */\n\treadonly publisher: Publisher;\n\t/** Published DeepBook package member. The package must capture the\n\t * `registry::Registry` and `registry::DeepbookAdminCap` object ids.\n\t * Required. */\n\treadonly package: Package;\n\t/** Optional local mock-Pyth package + feed setup. Omit for a feed-less\n\t * local DeX. */\n\treadonly pyth?: Pyth;\n\t/** Capture key for the package-created `registry::Registry`. */\n\treadonly registryIdKey?: string;\n\t/** Capture key for the package-created `registry::DeepbookAdminCap`. */\n\treadonly adminCapIdKey?: string;\n\t/** Optional capture key for a DEEP treasury object used by SDK bindings. */\n\treadonly deepTreasuryIdKey?: string;\n\t/** Pools to create after the DeepBook package publishes. OPTIONAL: when\n\t * omitted, a single unseeded (empty-book) `DEEP/SUI` pool is synthesized\n\t * (the DEEP coin comes from `package`, SUI is built-in — no extra package\n\t * needed), so a minimal `deepbook({ mode:'local', publisher, package })`\n\t * boots a usable DeX. Pass `[]` explicitly for a known-empty deployment, or your own\n\t * pools for full control. */\n\treadonly pools?: Pools;\n}\n\nexport type DeepbookKnownNetwork = 'mainnet' | 'testnet';\n\ninterface DeepbookKnownCommonOptions extends DeepbookCommonOptions {\n\t/** Optional network override (defaults to the configured network). */\n\treadonly network?: string;\n}\n\ninterface DeepbookKnownNetworkOptions extends DeepbookKnownCommonOptions {\n\treadonly network: DeepbookKnownNetwork;\n\treadonly packageId?: string;\n\treadonly registryId?: string;\n}\n\ninterface DeepbookKnownExplicitOptions extends DeepbookKnownCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly network?: DeepbookKnownNetwork;\n}\n\nexport type DeepbookKnownOptions = DeepbookKnownNetworkOptions | DeepbookKnownExplicitOptions;\n\nexport type DeepbookOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPyth extends PythOptions | undefined = PythOptions | undefined,\n> =\n\t| ({\n\t\t\treadonly mode: 'local';\n\t } & DeepbookLocalOptions<\n\t\t\tPublisher,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPyth\n\t >)\n\t| ({ readonly mode: 'override' } & DeepbookOverrideOptions)\n\t| ({ readonly mode: 'known' } & DeepbookKnownOptions);\n\n// ---------------------------------------------------------------------------\n// Plugin construction — override\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_NAME = 'deepbook';\n\nconst KNOWN_DEEPBOOK_DEPLOYMENTS: Record<\n\tDeepbookKnownNetwork,\n\t{\n\t\treadonly network: string;\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t\treadonly deepTreasuryId: string;\n\t\treadonly pyth: PythHandle;\n\t}\n> = {\n\ttestnet: {\n\t\tnetwork: 'testnet',\n\t\tpackageId: '0x22be4cade64bf2d02412c7e8d0e8beea2f78828b948118d46735315409371a3c',\n\t\tregistryId: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',\n\t\tdeepTreasuryId: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: '0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c',\n\t\t\twormholeStateId: '0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790',\n\t\t\tfeeds: [],\n\t\t},\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\tpackageId: '0xf48222c4e057fa468baf136bff8e12504209d43850c5778f76159292a96f621e',\n\t\tregistryId: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',\n\t\tdeepTreasuryId: '0x032abf8948dda67a271bcc18e776dbbcfb0d58c8d288a700ff0d5521e57a1ffe',\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: '0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8',\n\t\t\twormholeStateId: '0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c',\n\t\t\tfeeds: [],\n\t\t},\n\t},\n};\n\ntype PoolCoinRefs<Pools extends ReadonlyArray<DeepbookPoolSpec>> =\n\tPools[number] extends DeepbookPoolSpec<infer Base, infer Quote> ? Base | Quote : never;\ntype PoolCoinRefTuple<Pools extends ReadonlyArray<DeepbookPoolSpec>> = Pools extends readonly []\n\t? readonly []\n\t: readonly PoolCoinRefs<Pools>[];\n\ntype PythRefs<Pyth extends PythOptions | undefined> =\n\tPyth extends PythOptions<infer Package, infer Pusher> ? readonly [Pusher, Package] : readonly [];\n\ntype LocalDependsOn<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n> = readonly [\n\ttypeof suiResource,\n\tPublisher,\n\tPackage,\n\t...PythRefs<Pyth>,\n\t...PoolCoinRefTuple<Pools>,\n];\n\nconst poolCoinRefs = <Pools extends ReadonlyArray<DeepbookPoolSpec>>(\n\tpools: Pools,\n): ReadonlyArray<PoolCoinRefs<Pools>> =>\n\tpools.flatMap((pool) => [pool.base.coin, pool.quote.coin]) as unknown as ReadonlyArray<\n\t\tPoolCoinRefs<Pools>\n\t>;\n\nconst pythRefs = <Pyth extends PythOptions | undefined>(pyth: Pyth): PythRefs<Pyth> =>\n\t(pyth === undefined ? [] : [pyth.pusher, pyth.package]) as unknown as PythRefs<Pyth>;\n\nconst localDependsOn = <\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): LocalDependsOn<Publisher, Package, Pools, Pyth> =>\n\t[\n\t\tsuiResource,\n\t\topts.publisher,\n\t\topts.package,\n\t\t...pythRefs(opts.pyth),\n\t\t...poolCoinRefs((opts.pools ?? []) as Pools),\n\t] as unknown as LocalDependsOn<Publisher, Package, Pools, Pyth>;\n\nconst requireCapturedId = (\n\tpkg: LocalPackageResolved,\n\tkey: string,\n\tkind: 'registryId' | 'adminCapId',\n): Effect.Effect<string, DeepbookPluginError> => {\n\tconst value = pkg.captured[key];\n\tif (typeof value === 'string' && value.length > 0) {\n\t\treturn Effect.succeed(value);\n\t}\n\treturn Effect.fail(\n\t\tdeepbookPluginError(\n\t\t\t'publish',\n\t\t\t`deepbook local package '${pkg.name}' is missing captured ${kind} '${key}'.`,\n\t\t),\n\t);\n};\n\nconst requirePoolCoinValue = (\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n\tpoolName: string,\n\tside: 'base' | 'quote',\n\tcoinRefId: string,\n): Effect.Effect<CoinValue, DeepbookConfigError> => {\n\tconst value = coinValuesByRefId.get(coinRefId);\n\tif (value === undefined) {\n\t\t// Compose-time bug — `dependsOn`/`poolCoinRefs` dropped this coin.\n\t\t// Surface a typed config error naming the missing coin id rather\n\t\t// than letting a double-cast `undefined` slip into the resolved\n\t\t// pool spec. Lands on the typed E channel (not a sync throw, which\n\t\t// inside Effect.gen would become an uncaught DEFECT that\n\t\t// `passthroughOrWrap` could not see); `DeepbookConfigError` is in\n\t\t// `DEEPBOOK_ERROR_TAGS`, so the outer pipeline passes it through\n\t\t// untouched.\n\t\treturn Effect.fail(\n\t\t\tdeepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook: pool '${poolName}' ${side} coin '${coinRefId}' was not resolved by the dependency tuple.`,\n\t\t\t\t'This is a compose-time bug — ensure the coin member is included in `dependsOn`/`poolCoinRefs`.',\n\t\t\t),\n\t\t);\n\t}\n\treturn Effect.succeed(value);\n};\n\nconst resolvePoolSpecs = (\n\tpools: ReadonlyArray<DeepbookPoolSpec>,\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n): Effect.Effect<ReadonlyArray<ResolvedDeepbookPoolSpec>, DeepbookConfigError> =>\n\tEffect.forEach(pools, (pool) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst base = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'base',\n\t\t\t\tpool.base.coin.id,\n\t\t\t);\n\t\t\tconst quote = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'quote',\n\t\t\t\tpool.quote.coin.id,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tname: pool.name,\n\t\t\t\tbase: pool.base.key,\n\t\t\t\tquote: pool.quote.key,\n\t\t\t\tbaseCoinType: base.fullCoinType,\n\t\t\t\tquoteCoinType: quote.fullCoinType,\n\t\t\t\t...(base.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { baseFundingStrategy: base.fundingStrategy }),\n\t\t\t\t...(quote.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { quoteFundingStrategy: quote.fundingStrategy }),\n\t\t\t\ttickSize: pool.tickSize,\n\t\t\t\tlotSize: pool.lotSize,\n\t\t\t\tminSize: pool.minSize,\n\t\t\t\twhitelisted: pool.whitelisted ?? true,\n\t\t\t\tstablePool: pool.stablePool ?? false,\n\t\t\t\t...(pool.seed === undefined ? {} : { seed: pool.seed }),\n\t\t\t};\n\t\t}),\n\t);\n\nconst assertUniquePoolNames = (name: string, pools: ReadonlyArray<DeepbookPoolSpec>) => {\n\tconst seen = new Set<string>();\n\tfor (const pool of pools) {\n\t\tif (seen.has(pool.name)) {\n\t\t\tthrow deepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook({mode:'local', name:'${name}'}) has duplicate pool '${pool.name}'.`,\n\t\t\t\t'Give each local DeepBook pool a unique SDK key.',\n\t\t\t);\n\t\t}\n\t\tseen.add(pool.name);\n\t\tfor (const order of pool.seed?.orders ?? []) {\n\t\t\tif (order.quantity < pool.minSize) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is below minSize.`,\n\t\t\t\t\t'Use a seed order quantity greater than or equal to the pool minSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.quantity % pool.lotSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not lot-aligned.`,\n\t\t\t\t\t'Use a seed order quantity divisible by the pool lotSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.price % pool.tickSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not tick-aligned.`,\n\t\t\t\t\t'Use a seed order price divisible by the pool tickSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst buildOverridePlugin = (opts: DeepbookOverrideOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tif (!opts.packageId || !opts.registryId || !opts.adminCapId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'override', name:'${name}'}) requires packageId, registryId, and adminCapId.`,\n\t\t\t`Pass explicit deployment ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Override mode's deployment ids are DECLARED config — bake them as\n\t\t// literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst network = opts.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'override',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t\tadminCapId: opts.adminCapId,\n\t\t\t\t\tdeepTreasuryId: null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: false,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; `snap` is the override-mode\n\t\t\t\t// identity-guard snapshotable in scope. No DEEP funding.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n/** Concrete local options after the explicit-config guard: `publisher`,\n * `package`, and `pools` are guaranteed present. */\ntype ResolvedLocalOptions = DeepbookLocalOptions<\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tReadonlyArray<DeepbookPoolSpec>,\n\tPythOptions | undefined\n> & {\n\treadonly publisher: AccountMemberAlias;\n\treadonly package: DeepbookPackageMember;\n\treadonly pools: ReadonlyArray<DeepbookPoolSpec>;\n};\n\n/** Default local pool synthesized when `pools` is omitted: a single whitelisted\n * `DEEP/SUI` pool. DEEP is the deepbook package's own coin (no extra package to\n * publish), SUI is built-in, so this needs nothing beyond the `package` the\n * caller already passes — and NO seed, so it requires no DEEP minting (i.e. no\n * `deepTreasuryIdKey`) and works for a bare `deepbook({ publisher, package })`.\n * The pool is created with an empty book; pass explicit `pools` with a `seed`\n * (see `examples/deepbook-trader`) for pre-populated liquidity. */\nconst defaultLocalPools = (pkg: DeepbookPackageMember): ReadonlyArray<DeepbookPoolSpec> => [\n\t{\n\t\tname: 'DEEP_SUI',\n\t\tbase: { key: 'DEEP', coin: coinFromPackage(pkg, 'DEEP') },\n\t\tquote: { key: 'SUI', coin: builtinCoin('sui') },\n\t\ttickSize: 1_000_000n,\n\t\tlotSize: 1_000_000n,\n\t\tminSize: 10_000_000n,\n\t\twhitelisted: true,\n\t\tstablePool: false,\n\t},\n];\n\n/** Fail-fast guard for local mode: `publisher` and `package` are REQUIRED — a\n * publish tx needs a signer and the DeepBook Move package must be published\n * (capturing `registry::Registry` + `registry::DeepbookAdminCap`). `pools` is\n * OPTIONAL: omit it for a default unseeded (empty-book) `DEEP/SUI` pool (a\n * minimal usable DeX), pass `[]` for a pool-less deployment, or declare your own. `pyth`\n * stays optional (omit for a feed-less DeX). Missing a required field raises a\n * tagged `DeepbookConfigError` naming what to pass. */\nconst resolveLocalOptions = (\n\topts: DeepbookLocalOptions<\n\t\tAccountMemberAlias,\n\t\tDeepbookPackageMember,\n\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\tPythOptions | undefined\n\t>,\n): ResolvedLocalOptions => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst missing: string[] = [];\n\tif (!opts.publisher) {\n\t\tmissing.push('publisher');\n\t}\n\tif (!opts.package) {\n\t\tmissing.push('package');\n\t}\n\tif (missing.length > 0) {\n\t\tthrow deepbookConfigError(\n\t\t\tmissing[0] as string,\n\t\t\t`deepbook({mode:'local', name:'${name}'}) requires explicit ${missing.join(', ')}.`,\n\t\t\t`Publish the DeepBook Move package and pass at least { publisher, package } ` +\n\t\t\t\t`(see examples/deepbook-trader). Pools default to an unseeded (empty-book) DEEP/SUI pool.`,\n\t\t);\n\t}\n\t// Default to a single unseeded (empty-book) DEEP/SUI pool when none are declared.\n\tconst pools = opts.pools ?? defaultLocalPools(opts.package);\n\treturn { ...opts, pools } as ResolvedLocalOptions;\n};\n\nconst buildLocalPlugin = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\trawOpts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n) => {\n\tconst opts = resolveLocalOptions(\n\t\trawOpts as DeepbookLocalOptions<\n\t\t\tAccountMemberAlias,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPythOptions | undefined\n\t\t>,\n\t);\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tassertUniquePoolNames(name, opts.pools);\n\n\tconst deepbookResource = makeDeepbookResource(name);\n\t// Runtime `dependsOn` carries the caller's explicit member refs so\n\t// `defineDevstack`'s dependency-closure expander pulls the publisher /\n\t// package / coin / pyth members into the stack. The STATIC type stays keyed\n\t// to the caller's narrow generics so explicit callers keep their exact\n\t// closure (no generic `coin:`/`package:` provider demands).\n\tconst dependsOn = localDependsOn(opts) as unknown as LocalDependsOn<\n\t\tPublisher,\n\t\tPackage,\n\t\tPools,\n\t\tPyth\n\t>;\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Stack-free codegen: a local deployment's ids / pools / pyth feeds\n\t\t// are LOADED CONFIG DATA -- the committed `deepbook.ts` stub emits\n\t\t// `requireValue(dep, 'deepbook:<name>', '<key>')`, never a baked id.\n\t\tstaticCodegen: () => [makeDeepbookStaticCodegen({ name, network: LOCAL_NETWORK_NAME })],\n\t\t// `deps` auto-infers from the runtime-built `dependsOn`; it\n\t\t// resolves to a heterogeneous tuple the body re-narrows via the\n\t\t// `as unknown as` cast below. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui, publisher, deepbookPackage, ...extraValues] = deps as unknown as readonly [\n\t\t\t\t\tResourceValueOf<typeof suiResource>,\n\t\t\t\t\tAccountValue,\n\t\t\t\t\tLocalPackageResolved,\n\t\t\t\t\t...(AccountValue | LocalPackageResolved | CoinValue)[],\n\t\t\t\t];\n\t\t\t\tconst pythValueCount = opts.pyth === undefined ? 0 : 2;\n\t\t\t\tconst pythValues = extraValues.slice(0, pythValueCount);\n\t\t\t\tconst coinValues = extraValues.slice(pythValueCount) as CoinValue[];\n\n\t\t\t\tyield* setCurrentPluginPhase('reading deployment captures');\n\n\t\t\t\tconst registryId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.registryIdKey ?? 'registryId',\n\t\t\t\t\t'registryId',\n\t\t\t\t);\n\t\t\t\tconst adminCapId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.adminCapIdKey ?? 'adminCapId',\n\t\t\t\t\t'adminCapId',\n\t\t\t\t);\n\t\t\t\tconst deepTreasuryId =\n\t\t\t\t\topts.deepTreasuryIdKey === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: (deepbookPackage.captured[opts.deepTreasuryIdKey] ?? null);\n\t\t\t\tconst deployment: DeepbookDeployment = {\n\t\t\t\t\tpackageId: deepbookPackage.packageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t};\n\t\t\t\tconst poolRefs = poolCoinRefs(opts.pools);\n\t\t\t\tconst coinValuesByRefId = new Map<string, CoinValue>();\n\t\t\t\tfor (let i = 0; i < poolRefs.length; i += 1) {\n\t\t\t\t\tconst ref = poolRefs[i];\n\t\t\t\t\tconst value = coinValues[i];\n\t\t\t\t\tif (ref !== undefined && value !== undefined) {\n\t\t\t\t\t\tcoinValuesByRefId.set(ref.id, value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst poolSpecs = yield* resolvePoolSpecs(opts.pools, coinValuesByRefId);\n\t\t\t\tconst artifactPublisher = yield* CacheService;\n\t\t\t\tyield* setCurrentPluginPhase(\n\t\t\t\t\topts.pyth === undefined ? 'creating pools' : 'initializing Pyth feeds',\n\t\t\t\t);\n\t\t\t\tconst pyth =\n\t\t\t\t\topts.pyth === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* initLocalPythFeeds(\n\t\t\t\t\t\t\t\tartifactPublisher,\n\t\t\t\t\t\t\t\tsui.sdk,\n\t\t\t\t\t\t\t\tsui.chainId,\n\t\t\t\t\t\t\t\tpythValues[0] as AccountValue,\n\t\t\t\t\t\t\t\t{ packageId: (pythValues[1] as LocalPackageResolved).packageId },\n\t\t\t\t\t\t\t\topts.pyth.feeds,\n\t\t\t\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('creating pools');\n\t\t\t\tconst poolResult = yield* createDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('seeding pools');\n\t\t\t\tconst seedResults = yield* seedDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t\tpoolResult.pools,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase(null);\n\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tnetwork: identity.network,\n\t\t\t\t\tpackageId: deployment.packageId,\n\t\t\t\t\tregistryId: deployment.registryId,\n\t\t\t\t\tadminCapId: deployment.adminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t\tpools: poolResult.pools,\n\t\t\t\t\tpyth,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: seedResults.length > 0,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; the snapshotable is the local-mode\n\t\t\t\t// `deepbook/<name>` subtree. No DEEP funding (null in local).\n\t\t\t\tconst snap: SnapshotableDecl = makeLocalSnapshotable({ name });\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: resolved.pools.map((p) => ({\n\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\tpoolId: p.poolId,\n\t\t\t\t\t\tbase: p.base,\n\t\t\t\t\t\tquote: p.quote,\n\t\t\t\t\t\tbaseCoinType: p.baseCoinType,\n\t\t\t\t\t\tquoteCoinType: p.quoteCoinType,\n\t\t\t\t\t})),\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: resolved.margin,\n\t\t\t\t\tserverUrl: resolved.serverUrl,\n\t\t\t\t\tindexerUrl: resolved.indexerUrl,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}).pipe(\n\t\t\t\t// The body's aggregate E channel includes substrate Effects\n\t\t\t\t// whose error shape is unknown to TS (ArtifactPublisher\n\t\t\t\t// produce bodies, dependency reads). `Effect.catchTags`\n\t\t\t\t// would need a statically-known tagged union; the\n\t\t\t\t// substrate's `passthroughOrWrap` runtime-checks the `_tag`\n\t\t\t\t// against `DEEPBOOK_ERROR_TAGS`, passing typed deepbook\n\t\t\t\t// errors through untouched and wrapping everything else\n\t\t\t\t// under `'publish'` so cascade attribution stays with the\n\t\t\t\t// plugin.\n\t\t\t\tpassthroughOrWrap.for<DeepbookError>()(DEEPBOOK_ERROR_TAGS, (err) =>\n\t\t\t\t\tdeepbookPluginError('publish', `deepbook acquire failed: ${String(err)}`, {\n\t\t\t\t\t\tcause: err,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n};\n\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(opts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>) {\n\treturn buildLocalPlugin(opts);\n}\n\n// ---------------------------------------------------------------------------\n// Plugin construction — known\n// ---------------------------------------------------------------------------\n\nconst buildKnownPlugin = (opts: DeepbookKnownOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst known = opts.network ? KNOWN_DEEPBOOK_DEPLOYMENTS[opts.network] : null;\n\tconst packageId = opts.packageId ?? known?.packageId;\n\tconst registryId = opts.registryId ?? known?.registryId;\n\tif (!packageId || !registryId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'known', name:'${name}'}) requires packageId and registryId, or network:'mainnet'|'testnet'.`,\n\t\t\t`Pass explicit ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Known mode's deployment ids (package / registry / deep-treasury) and\n\t\t// its declared testnet/mainnet Pyth ids are DECLARED config — bake them\n\t\t// as literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? known?.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpyth: known?.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: known.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: known.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: known.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: known.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui] = deps;\n\t\t\t\tconst network = opts.network ?? known?.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: known?.pyth ?? null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: false,\n\t\t\t\t\t// DEEP funding is a testnet-deepbook concern — gate on the\n\t\t\t\t\t// network name alone. (The old `&& String(chain) === 'sui:testnet'`\n\t\t\t\t\t// conjunct compared a genesis-digest chainId against a network\n\t\t\t\t\t// literal and was dead for every non-literal `chain` value.)\n\t\t\t\t\tdeepFundingStrategy:\n\t\t\t\t\t\topts.network === 'testnet'\n\t\t\t\t\t\t\t? makeDeepbookDeepFundingStrategy({ suiSdk: sui.sdk })\n\t\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen -> (optional\n\t\t\t\t// DEEP funding strategy). `resolved` is the just-computed value;\n\t\t\t\t// `snap` is the known-mode identity-guard snapshotable in scope.\n\t\t\t\t// The DEEP funding contributor is emitted only when\n\t\t\t\t// `resolved.deepFundingStrategy` is non-null.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\tif (resolved.deepFundingStrategy != null) {\n\t\t\t\t\tctx.provides(makeDeepbookDeepFundingContribution(resolved.deepFundingStrategy));\n\t\t\t\t}\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Default option resolution (env-driven)\n// ---------------------------------------------------------------------------\n\nconst resolveDefaultMode = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookOptions<Publisher, Pyth> => {\n\tconst env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n\t\t?.env?.DEVSTACK_NETWORK;\n\tif (env === undefined || env === 'localnet') {\n\t\t// Local DeepBook: default to local mode on localnet. The caller must\n\t\t// supply explicit `{ publisher, package, pools }`; `resolveLocalOptions`\n\t\t// fails fast otherwise (no auto-synthesis).\n\t\treturn { mode: 'local', ...opts } as DeepbookOptions<Publisher, Pyth>;\n\t}\n\t// Non-local default: refuse — known mode requires explicit\n\t// packageId/registryId. The user passes them via\n\t// `deepbookFor(network).known({...})` or `deepbook({mode:'known',...})`.\n\tthrow deepbookConfigError(\n\t\t'mode',\n\t\t`deepbook(): cannot auto-default to known mode on network='${env}'.`,\n\t\t`Use deepbookFor(network).known({packageId, registryId, ...}).`,\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// User-facing factories\n// ---------------------------------------------------------------------------\n\n/** Env-driven factory. Defaults to local mode on localnet when passed local\n * options. Explicit `override` and `known` modes bypass env inference. */\ntype DeepbookLocalMember<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined = undefined,\n> = ReturnType<typeof buildLocalPlugin<Publisher, Package, Pools, Pyth>>;\ntype DeepbookOverrideMember = ReturnType<typeof buildOverridePlugin>;\ntype DeepbookKnownMember = ReturnType<typeof buildKnownPlugin>;\n\n// Local DeepBook requires explicit `{ publisher, package, pools }`. There is\n// no zero-arg/synthesized overload — an under-specified call fails fast (see\n// `resolveLocalOptions`).\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: { readonly mode: 'local' } & DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore(\n\topts: { readonly mode: 'override' } & DeepbookOverrideOptions,\n): DeepbookOverrideMember;\nexport function deepbookCore(\n\topts: { readonly mode: 'known' } & DeepbookKnownOptions,\n): DeepbookKnownMember;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | DeepbookOptions<Publisher, Pyth>,\n):\n\t| DeepbookLocalMember<Publisher, Package, Pools, Pyth>\n\t| DeepbookOverrideMember\n\t| DeepbookKnownMember {\n\tconst resolved: DeepbookOptions<Publisher, Pyth> =\n\t\topts !== undefined && 'mode' in opts\n\t\t\t? (opts as DeepbookOptions<Publisher, Pyth>)\n\t\t\t: resolveDefaultMode(\n\t\t\t\t\topts as DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | undefined,\n\t\t\t\t);\n\tswitch (resolved.mode) {\n\t\tcase 'local': {\n\t\t\tconst localOpts = resolved as { readonly mode: 'local' } & DeepbookLocalOptions<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t\t// Explicit-config path only; `buildLocalPlugin` -> `resolveLocalOptions`\n\t\t\t// fails fast when `publisher`/`package`/`pools` are missing.\n\t\t\treturn buildLocalPluginPublic(localOpts) as DeepbookLocalMember<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t}\n\t\tcase 'override':\n\t\t\treturn buildOverridePlugin(resolved);\n\t\tcase 'known':\n\t\t\treturn buildKnownPlugin(resolved);\n\t}\n}\n\n/** Mode-narrowed factory namespace.\n *\n * Usage:\n * const local = { mode: 'local', network: 'localnet' } as const;\n * deepbookFor(local).local({publisher, package, pools}) // OK\n * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK\n * deepbookFor(local).known({...}) // OK\n *\n * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;\n * deepbookFor(fork).local({...}) // COMPILE ERROR\n * deepbookFor(fork).override({...}) // COMPILE ERROR\n *\n * The fork branch has NO `.local` or `.override` entry — `deepbookFor(forkNetwork).local`\n * is a compile-time refusal. */\nexport const deepbookFor = defineModeNamespace({\n\tlocal: {\n\t\tlocal: <\n\t\t\tconst Publisher extends AccountMemberAlias,\n\t\t\tconst Package extends DeepbookPackageMember,\n\t\t\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\t\t\tconst Pyth extends PythOptions | undefined = undefined,\n\t\t>(\n\t\t\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n\t\t) => buildLocalPluginPublic(opts),\n\t\toverride: (opts: DeepbookOverrideOptions) => buildOverridePlugin(opts),\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n\tlive: {\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n\tfork: {\n\t\t// `.override` intentionally absent — compile-time refusal.\n\t\tknown: (opts: DeepbookKnownOptions) => buildKnownPlugin(opts),\n\t},\n});\n\nexport { deepbookCore as deepbook };\n\n// ---------------------------------------------------------------------------\n// Re-exports for advanced callers\n// ---------------------------------------------------------------------------\n\nexport {\n\tDEEPBOOK_DEEP_FAUCET_STRATEGY_KEY,\n\tDEEPBOOK_TESTNET_DEEP_COIN_TYPE,\n} from './faucet-strategy.ts';\nexport {\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookPhase,\n} from './errors.ts';\nexport type { DeepbookBindings } from './codegen.ts';\nexport type {\n\tAccountMemberAlias,\n\tCoinMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolCoin,\n\tDeepbookPoolSeedLiquidity,\n\tDeepbookPoolSeedOrder,\n\tDeepbookPoolSpec,\n} from './types.ts';\nexport {\n\tDEEP_PRICE_FEED_ID,\n\tpythPriceFeedId,\n\tSUI_PRICE_FEED_ID,\n\tUSDC_PRICE_FEED_ID,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAM,wBAA6C,SAClD,SACC,YAAY,MACb;AA8HD,MAAM,eAAe;AAErB,MAAM,6BASF;CACH,SAAS;EACR,SAAS;EACT,WAAW;EACX,YAAY;EACZ,gBAAgB;EAChB,MAAM;GACL,WAAW;GACX,SAAS;GACT,iBAAiB;GACjB,OAAO,CAAC;EACT;CACD;CACA,SAAS;EACR,SAAS;EACT,WAAW;EACX,YAAY;EACZ,gBAAgB;EAChB,MAAM;GACL,WAAW;GACX,SAAS;G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BAML,SACsC;CACtC,MAAM,MAAO,WAA0E,SACpF,KAAK;CACR,IAAI,QAAQ,KAAA,KAAa,QAAQ,YAIhC,OAAO;EAAE,MAAM;EAAS,GAAG;CAAK;CAKjC,MAAM,oBACL,QACA,6DAA6D,IAAI,KACjE,+DACD;AACD;AA0CA,SAAgB,aAMf,MAIsB;CACtB,MAAM,WACL,SAAS,KAAA,KAAa,UAAU,OAC5B,OACD,mBACA,IACD;CACH,QAAQ,SAAS,MAAjB;EACC,KAAK,SASJ,OAAO,uBAAuBC,QAAS;EAOxC,KAAK,YACJ,OAAO,oBAAoB,QAAQ;EACpC,KAAK,SACJ,OAAO,iBAAiB,QAAQ;CAClC;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,cAAc,oBAAoB;CAC9C,OAAO;EACN,QAMC,SACI,uBAAuB,IAAI;EAChC,WAAW,SAAkC,oBAAoB,IAAI;EACrE,QAAQ,SAA+B,iBAAiB,IAAI;CAC7D;CACA,MAAM,EACL,QAAQ,SAA+B,iBAAiB,IAAI,EAC7D;CACA,MAAM,EAEL,QAAQ,SAA+B,iBAAiB,IAAI,EAC7D;AACD,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["coinFromPackage","builtinCoin","localOpts"],"sources":["../../../src/plugins/deepbook/index.ts"],"sourcesContent":["// Deepbook plugin — barrel + factories.\n//\n// Architecture: Deepbook is a task plugin that resolves a managed\n// local deployment, a known deployment, or explicit caller-supplied\n// override ids, then emits bindings.\n//\n// Mode discipline:\n//\n// - `deepbook(opts)` — explicit mode selection.\n// Localnet can default to local when\n// passed local options.\n// - `deepbookFor(network).local` — local-branch managed deployment.\n// - `deepbookFor(network).override` — local-branch override for\n// caller-supplied deployment ids.\n// - `deepbookFor(network).known` — known-deployment branch (live +\n// fork networks; wraps an already-\n// deployed canonical instance).\n//\n// During `start`, the plugin emits (via the typed `ctx.*` verbs):\n//\n// Local mode:\n// 1. `ctx.snapshotExtra` — `deepbook/<name>` subtree.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Override mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings.\n//\n// Known mode:\n// 1. `ctx.snapshotExtra` — identity guard only.\n// 2. `ctx.codegen` — `deepbook-network` bindings (mode='known').\n//\n// Resource id: `deepbook/<name>`. Plugin key: `deepbook:<name>`.\n\nimport { Effect } from 'effect';\nimport {\n\tmainnetPackageIds,\n\tmainnetPythConfigs,\n\ttestnetPackageIds,\n\ttestnetPythConfigs,\n} from '@mysten/deepbook-v3';\n\nimport { defineModeNamespace } from '../../api/mode-narrowed-factory.ts';\nimport { definePlugin, resource, type ResourceValueOf } from '../../api/define-plugin.ts';\nimport type { SnapshotableDecl } from '../../contracts/snapshotable.ts';\nimport { PluginContext } from '../../substrate/plugin-ctx.ts';\nimport { CacheService } from '../../substrate/runtime/cache/index.ts';\nimport { setCurrentPluginPhase } from '../../substrate/runtime/current-plugin.ts';\nimport { passthroughOrWrap } from '../../substrate/runtime/passthrough-or-wrap.ts';\nimport { IdentityContext } from '../../substrate/runtime/paths.ts';\nimport { suiResource } from '../sui/index.ts';\nimport type { AccountValue } from '../account/index.ts';\nimport {\n\tbuiltin as builtinCoin,\n\tfromPackage as coinFromPackage,\n\ttype CoinValue,\n} from '../coin/index.ts';\nimport type { LocalPackageResolved } from '../package/index.ts';\n\nimport { deepbookPluginKey } from './plugin-key.ts';\nimport {\n\tDEEPBOOK_ERROR_TAGS,\n\tdeepbookConfigError,\n\tdeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n} from './errors.ts';\nimport {\n\tmakeDeepbookCodegenable,\n\tmakeDeepbookStaticCodegen,\n\ttype DeepbookBindings,\n} from './codegen.ts';\nimport { LOCAL_NETWORK_NAME } from '../../api/inference-network.ts';\nimport {\n\tmakeDeepbookDeepFundingContribution,\n\tmakeDeepbookDeepFundingStrategy,\n\ttype DeepbookDeepFundingStrategy,\n} from './faucet-strategy.ts';\nimport { makeKnownSnapshotable, makeLocalSnapshotable } from './snapshot.ts';\nimport {\n\tcreateDeepbookPools,\n\tseedDeepbookPools,\n\ttype DeepbookDeployment,\n\ttype ResolvedDeepbookPoolSpec,\n} from './deploy.ts';\nimport { initLocalPythFeeds } from './pyth/index.ts';\nimport type {\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolSpec,\n\tPythHandle,\n\tPythOptions,\n} from './types.ts';\n\n// ---------------------------------------------------------------------------\n// Resource — the resolved value all consumers read\n// ---------------------------------------------------------------------------\n\nexport type DeepbookResourceId<Name extends string> = `deepbook/${Name}`;\n\nconst makeDeepbookResource = <Name extends string>(name: Name) =>\n\tresource<DeepbookResourceId<Name>, DeepbookResolved>(\n\t\t`deepbook/${name}` as DeepbookResourceId<Name>,\n\t);\n\n/** The deepbook resolved value. Mode-asymmetric:\n *\n * - `adminCapId` is `null` for known-deployment mode.\n * - `margin` / `serverUrl` / `indexerUrl` are `null` when the\n * corresponding sub-feature is not enabled.\n * - `hasSeedLiquidity` is `true` when one or more pools placed seed\n * orders at boot (it is NOT a market-maker process state). */\nexport interface DeepbookResolved {\n\treadonly mode: 'local' | 'override' | 'known';\n\treadonly network: string;\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string | null;\n\treadonly deepTreasuryId: string | null;\n\treadonly pools: ReadonlyArray<DeepbookPool>;\n\treadonly pyth: PythHandle | null;\n\treadonly margin: {\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t} | null;\n\treadonly serverUrl: string | null;\n\treadonly indexerUrl: string | null;\n\t/** `true` when one or more pools placed seed orders at boot. This reflects\n\t * \"a pool was seeded with liquidity\", NOT a running market-maker process. */\n\treadonly hasSeedLiquidity: boolean;\n\treadonly deepFundingStrategy: DeepbookDeepFundingStrategy | null;\n}\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface DeepbookCommonOptions {\n\treadonly name?: string;\n}\n\n/** Override mode wraps an explicitly supplied deployment. It does not\n * publish or manage DeepBook locally. */\nexport interface DeepbookOverrideOptions extends DeepbookCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly adminCapId: string;\n\treadonly network?: string;\n}\n\n/** Local mode wraps an explicitly supplied local DeepBook package.\n *\n * Explicit-config discipline: `publisher`, `package`, and `pools` are all\n * REQUIRED — the caller publishes the DeepBook Move tree, funds a publisher,\n * and declares the pools. There is no zero-arg auto-synthesis; an\n * under-specified `deepbook({ mode: 'local' })` fails fast with a tagged\n * config error (see the guard in `resolveLocalOptions`). `pyth` stays\n * optional — pass it to seed local mock price feeds, omit it for a\n * feed-less DeX. */\nexport interface DeepbookLocalOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPackage extends DeepbookPackageMember = DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tPyth extends PythOptions | undefined = undefined,\n> extends DeepbookCommonOptions {\n\t/** Publisher account — Direct Member Ref (locked API decision). Required. */\n\treadonly publisher: Publisher;\n\t/** Published DeepBook package member. The package must capture the\n\t * `registry::Registry` and `registry::DeepbookAdminCap` object ids.\n\t * Required. */\n\treadonly package: Package;\n\t/** Optional local mock-Pyth package + feed setup. Omit for a feed-less\n\t * local DeX. */\n\treadonly pyth?: Pyth;\n\t/** Capture key for the package-created `registry::Registry`. */\n\treadonly registryIdKey?: string;\n\t/** Capture key for the package-created `registry::DeepbookAdminCap`. */\n\treadonly adminCapIdKey?: string;\n\t/** Optional capture key for a DEEP treasury object used by SDK bindings. */\n\treadonly deepTreasuryIdKey?: string;\n\t/** Pools to create after the DeepBook package publishes. OPTIONAL: when\n\t * omitted, a single unseeded (empty-book) `DEEP/SUI` pool is synthesized\n\t * (the DEEP coin comes from `package`, SUI is built-in — no extra package\n\t * needed), so a minimal `deepbook({ mode:'local', publisher, package })`\n\t * boots a usable DeX. Pass `[]` explicitly for a known-empty deployment, or your own\n\t * pools for full control. */\n\treadonly pools?: Pools;\n}\n\nexport type DeepbookKnownNetwork = 'mainnet' | 'testnet';\n\ninterface DeepbookKnownCommonOptions extends DeepbookCommonOptions {\n\t/** Optional network override (defaults to the configured network). */\n\treadonly network?: string;\n}\n\ninterface DeepbookKnownNetworkOptions extends DeepbookKnownCommonOptions {\n\treadonly network: DeepbookKnownNetwork;\n\treadonly packageId?: string;\n\treadonly registryId?: string;\n}\n\ninterface DeepbookKnownExplicitOptions extends DeepbookKnownCommonOptions {\n\treadonly packageId: string;\n\treadonly registryId: string;\n\treadonly network?: DeepbookKnownNetwork;\n}\n\nexport type DeepbookKnownOptions = DeepbookKnownNetworkOptions | DeepbookKnownExplicitOptions;\n\n/** Per-network factory options for `deepbookFor(net).testnet()`/`.mainnet()`.\n * The `network` is injected by the namespace method, so the caller only\n * supplies optional per-field overrides (`packageId`/`registryId`/`name`).\n * Plugin-INTERNAL — deliberately NOT re-exported from `src/index.ts`. */\ntype DeepbookKnownByNetworkOptions = Omit<DeepbookKnownNetworkOptions, 'network'>;\n\nexport type DeepbookOptions<\n\tPublisher extends AccountMemberAlias = AccountMemberAlias,\n\tPyth extends PythOptions | undefined = PythOptions | undefined,\n> =\n\t| ({\n\t\t\treadonly mode: 'local';\n\t } & DeepbookLocalOptions<\n\t\t\tPublisher,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPyth\n\t >)\n\t| ({ readonly mode: 'override' } & DeepbookOverrideOptions)\n\t| ({ readonly mode: 'known' } & DeepbookKnownOptions);\n\n// ---------------------------------------------------------------------------\n// Plugin construction — override\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_NAME = 'deepbook';\n\n// Known-deployment ids are DERIVED from the `@mysten/deepbook-v3` SDK\n// constants rather than hand-copied, so they can never drift from the SDK\n// (a stale mainnet packageId is exactly what this guards against). Future\n// SDK bumps flow through automatically. DeepBook ships testnet + mainnet\n// only — there is no devnet deployment.\n//\n// We surface only the core ids the plugin needs. The SDK's MARGIN_*/\n// LIQUIDATION_* package ids and its coin/pool maps are intentionally NOT\n// re-exported here (out of scope); consumers that need them import from\n// `@mysten/deepbook-v3` directly.\nconst KNOWN_DEEPBOOK_DEPLOYMENTS: Record<\n\tDeepbookKnownNetwork,\n\t{\n\t\treadonly network: string;\n\t\treadonly packageId: string;\n\t\treadonly registryId: string;\n\t\treadonly deepTreasuryId: string;\n\t\treadonly pyth: PythHandle;\n\t}\n> = {\n\ttestnet: {\n\t\tnetwork: 'testnet',\n\t\tpackageId: testnetPackageIds.DEEPBOOK_PACKAGE_ID,\n\t\tregistryId: testnetPackageIds.REGISTRY_ID,\n\t\tdeepTreasuryId: testnetPackageIds.DEEP_TREASURY_ID,\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: testnetPythConfigs.pythStateId,\n\t\t\twormholeStateId: testnetPythConfigs.wormholeStateId,\n\t\t\tfeeds: [],\n\t\t},\n\t},\n\tmainnet: {\n\t\tnetwork: 'mainnet',\n\t\tpackageId: mainnetPackageIds.DEEPBOOK_PACKAGE_ID,\n\t\tregistryId: mainnetPackageIds.REGISTRY_ID,\n\t\tdeepTreasuryId: mainnetPackageIds.DEEP_TREASURY_ID,\n\t\tpyth: {\n\t\t\tpackageId: null,\n\t\t\tstateId: mainnetPythConfigs.pythStateId,\n\t\t\twormholeStateId: mainnetPythConfigs.wormholeStateId,\n\t\t\tfeeds: [],\n\t\t},\n\t},\n};\n\ntype PoolCoinRefs<Pools extends ReadonlyArray<DeepbookPoolSpec>> =\n\tPools[number] extends DeepbookPoolSpec<infer Base, infer Quote> ? Base | Quote : never;\ntype PoolCoinRefTuple<Pools extends ReadonlyArray<DeepbookPoolSpec>> = Pools extends readonly []\n\t? readonly []\n\t: readonly PoolCoinRefs<Pools>[];\n\ntype PythRefs<Pyth extends PythOptions | undefined> =\n\tPyth extends PythOptions<infer Package, infer Pusher> ? readonly [Pusher, Package] : readonly [];\n\ntype LocalDependsOn<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n> = readonly [\n\ttypeof suiResource,\n\tPublisher,\n\tPackage,\n\t...PythRefs<Pyth>,\n\t...PoolCoinRefTuple<Pools>,\n];\n\nconst poolCoinRefs = <Pools extends ReadonlyArray<DeepbookPoolSpec>>(\n\tpools: Pools,\n): ReadonlyArray<PoolCoinRefs<Pools>> =>\n\tpools.flatMap((pool) => [pool.base.coin, pool.quote.coin]) as unknown as ReadonlyArray<\n\t\tPoolCoinRefs<Pools>\n\t>;\n\nconst pythRefs = <Pyth extends PythOptions | undefined>(pyth: Pyth): PythRefs<Pyth> =>\n\t(pyth === undefined ? [] : [pyth.pusher, pyth.package]) as unknown as PythRefs<Pyth>;\n\nconst localDependsOn = <\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): LocalDependsOn<Publisher, Package, Pools, Pyth> =>\n\t[\n\t\tsuiResource,\n\t\topts.publisher,\n\t\topts.package,\n\t\t...pythRefs(opts.pyth),\n\t\t...poolCoinRefs((opts.pools ?? []) as Pools),\n\t] as unknown as LocalDependsOn<Publisher, Package, Pools, Pyth>;\n\nconst requireCapturedId = (\n\tpkg: LocalPackageResolved,\n\tkey: string,\n\tkind: 'registryId' | 'adminCapId',\n): Effect.Effect<string, DeepbookPluginError> => {\n\tconst value = pkg.captured[key];\n\tif (typeof value === 'string' && value.length > 0) {\n\t\treturn Effect.succeed(value);\n\t}\n\treturn Effect.fail(\n\t\tdeepbookPluginError(\n\t\t\t'publish',\n\t\t\t`deepbook local package '${pkg.name}' is missing captured ${kind} '${key}'.`,\n\t\t),\n\t);\n};\n\nconst requirePoolCoinValue = (\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n\tpoolName: string,\n\tside: 'base' | 'quote',\n\tcoinRefId: string,\n): Effect.Effect<CoinValue, DeepbookConfigError> => {\n\tconst value = coinValuesByRefId.get(coinRefId);\n\tif (value === undefined) {\n\t\t// Compose-time bug — `dependsOn`/`poolCoinRefs` dropped this coin.\n\t\t// Surface a typed config error naming the missing coin id rather\n\t\t// than letting a double-cast `undefined` slip into the resolved\n\t\t// pool spec. Lands on the typed E channel (not a sync throw, which\n\t\t// inside Effect.gen would become an uncaught DEFECT that\n\t\t// `passthroughOrWrap` could not see); `DeepbookConfigError` is in\n\t\t// `DEEPBOOK_ERROR_TAGS`, so the outer pipeline passes it through\n\t\t// untouched.\n\t\treturn Effect.fail(\n\t\t\tdeepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook: pool '${poolName}' ${side} coin '${coinRefId}' was not resolved by the dependency tuple.`,\n\t\t\t\t'This is a compose-time bug — ensure the coin member is included in `dependsOn`/`poolCoinRefs`.',\n\t\t\t),\n\t\t);\n\t}\n\treturn Effect.succeed(value);\n};\n\nconst resolvePoolSpecs = (\n\tpools: ReadonlyArray<DeepbookPoolSpec>,\n\tcoinValuesByRefId: ReadonlyMap<string, CoinValue>,\n): Effect.Effect<ReadonlyArray<ResolvedDeepbookPoolSpec>, DeepbookConfigError> =>\n\tEffect.forEach(pools, (pool) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst base = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'base',\n\t\t\t\tpool.base.coin.id,\n\t\t\t);\n\t\t\tconst quote = yield* requirePoolCoinValue(\n\t\t\t\tcoinValuesByRefId,\n\t\t\t\tpool.name,\n\t\t\t\t'quote',\n\t\t\t\tpool.quote.coin.id,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tname: pool.name,\n\t\t\t\tbase: pool.base.key,\n\t\t\t\tquote: pool.quote.key,\n\t\t\t\tbaseCoinType: base.fullCoinType,\n\t\t\t\tquoteCoinType: quote.fullCoinType,\n\t\t\t\t...(base.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { baseFundingStrategy: base.fundingStrategy }),\n\t\t\t\t...(quote.fundingStrategy === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { quoteFundingStrategy: quote.fundingStrategy }),\n\t\t\t\ttickSize: pool.tickSize,\n\t\t\t\tlotSize: pool.lotSize,\n\t\t\t\tminSize: pool.minSize,\n\t\t\t\twhitelisted: pool.whitelisted ?? true,\n\t\t\t\tstablePool: pool.stablePool ?? false,\n\t\t\t\t...(pool.seed === undefined ? {} : { seed: pool.seed }),\n\t\t\t};\n\t\t}),\n\t);\n\nconst assertUniquePoolNames = (name: string, pools: ReadonlyArray<DeepbookPoolSpec>) => {\n\tconst seen = new Set<string>();\n\tfor (const pool of pools) {\n\t\tif (seen.has(pool.name)) {\n\t\t\tthrow deepbookConfigError(\n\t\t\t\t'pools',\n\t\t\t\t`deepbook({mode:'local', name:'${name}'}) has duplicate pool '${pool.name}'.`,\n\t\t\t\t'Give each local DeepBook pool a unique SDK key.',\n\t\t\t);\n\t\t}\n\t\tseen.add(pool.name);\n\t\tfor (const order of pool.seed?.orders ?? []) {\n\t\t\tif (order.quantity < pool.minSize) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is below minSize.`,\n\t\t\t\t\t'Use a seed order quantity greater than or equal to the pool minSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.quantity % pool.lotSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not lot-aligned.`,\n\t\t\t\t\t'Use a seed order quantity divisible by the pool lotSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (order.price % pool.tickSize !== 0n) {\n\t\t\t\tthrow deepbookConfigError(\n\t\t\t\t\t'pools',\n\t\t\t\t\t`deepbook({mode:'local', name:'${name}'}) seed order for pool '${pool.name}' is not tick-aligned.`,\n\t\t\t\t\t'Use a seed order price divisible by the pool tickSize.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst buildOverridePlugin = (opts: DeepbookOverrideOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tif (!opts.packageId || !opts.registryId || !opts.adminCapId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'override', name:'${name}'}) requires packageId, registryId, and adminCapId.`,\n\t\t\t`Pass explicit deployment ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Override mode's deployment ids are DECLARED config — bake them as\n\t\t// literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: () =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst network = opts.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'override',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId: opts.packageId,\n\t\t\t\t\tregistryId: opts.registryId,\n\t\t\t\t\tadminCapId: opts.adminCapId,\n\t\t\t\t\tdeepTreasuryId: null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: false,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; `snap` is the override-mode\n\t\t\t\t// identity-guard snapshotable in scope. No DEEP funding.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n/** Concrete local options after the explicit-config guard: `publisher`,\n * `package`, and `pools` are guaranteed present. */\ntype ResolvedLocalOptions = DeepbookLocalOptions<\n\tAccountMemberAlias,\n\tDeepbookPackageMember,\n\tReadonlyArray<DeepbookPoolSpec>,\n\tPythOptions | undefined\n> & {\n\treadonly publisher: AccountMemberAlias;\n\treadonly package: DeepbookPackageMember;\n\treadonly pools: ReadonlyArray<DeepbookPoolSpec>;\n};\n\n/** Default local pool synthesized when `pools` is omitted: a single whitelisted\n * `DEEP/SUI` pool. DEEP is the deepbook package's own coin (no extra package to\n * publish), SUI is built-in, so this needs nothing beyond the `package` the\n * caller already passes — and NO seed, so it requires no DEEP minting (i.e. no\n * `deepTreasuryIdKey`) and works for a bare `deepbook({ publisher, package })`.\n * The pool is created with an empty book; pass explicit `pools` with a `seed`\n * (see `examples/deepbook-trader`) for pre-populated liquidity. */\nconst defaultLocalPools = (pkg: DeepbookPackageMember): ReadonlyArray<DeepbookPoolSpec> => [\n\t{\n\t\tname: 'DEEP_SUI',\n\t\tbase: { key: 'DEEP', coin: coinFromPackage(pkg, 'DEEP') },\n\t\tquote: { key: 'SUI', coin: builtinCoin('sui') },\n\t\ttickSize: 1_000_000n,\n\t\tlotSize: 1_000_000n,\n\t\tminSize: 10_000_000n,\n\t\twhitelisted: true,\n\t\tstablePool: false,\n\t},\n];\n\n/** Fail-fast guard for local mode: `publisher` and `package` are REQUIRED — a\n * publish tx needs a signer and the DeepBook Move package must be published\n * (capturing `registry::Registry` + `registry::DeepbookAdminCap`). `pools` is\n * OPTIONAL: omit it for a default unseeded (empty-book) `DEEP/SUI` pool (a\n * minimal usable DeX), pass `[]` for a pool-less deployment, or declare your own. `pyth`\n * stays optional (omit for a feed-less DeX). Missing a required field raises a\n * tagged `DeepbookConfigError` naming what to pass. */\nconst resolveLocalOptions = (\n\topts: DeepbookLocalOptions<\n\t\tAccountMemberAlias,\n\t\tDeepbookPackageMember,\n\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\tPythOptions | undefined\n\t>,\n): ResolvedLocalOptions => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst missing: string[] = [];\n\tif (!opts.publisher) {\n\t\tmissing.push('publisher');\n\t}\n\tif (!opts.package) {\n\t\tmissing.push('package');\n\t}\n\tif (missing.length > 0) {\n\t\tthrow deepbookConfigError(\n\t\t\tmissing[0] as string,\n\t\t\t`deepbook({mode:'local', name:'${name}'}) requires explicit ${missing.join(', ')}.`,\n\t\t\t`Publish the DeepBook Move package and pass at least { publisher, package } ` +\n\t\t\t\t`(see examples/deepbook-trader). Pools default to an unseeded (empty-book) DEEP/SUI pool.`,\n\t\t);\n\t}\n\t// Default to a single unseeded (empty-book) DEEP/SUI pool when none are declared.\n\tconst pools = opts.pools ?? defaultLocalPools(opts.package);\n\treturn { ...opts, pools } as ResolvedLocalOptions;\n};\n\nconst buildLocalPlugin = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\trawOpts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n) => {\n\tconst opts = resolveLocalOptions(\n\t\trawOpts as DeepbookLocalOptions<\n\t\t\tAccountMemberAlias,\n\t\t\tDeepbookPackageMember,\n\t\t\tReadonlyArray<DeepbookPoolSpec>,\n\t\t\tPythOptions | undefined\n\t\t>,\n\t);\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tassertUniquePoolNames(name, opts.pools);\n\n\tconst deepbookResource = makeDeepbookResource(name);\n\t// Runtime `dependsOn` carries the caller's explicit member refs so\n\t// `defineDevstack`'s dependency-closure expander pulls the publisher /\n\t// package / coin / pyth members into the stack. The STATIC type stays keyed\n\t// to the caller's narrow generics so explicit callers keep their exact\n\t// closure (no generic `coin:`/`package:` provider demands).\n\tconst dependsOn = localDependsOn(opts) as unknown as LocalDependsOn<\n\t\tPublisher,\n\t\tPackage,\n\t\tPools,\n\t\tPyth\n\t>;\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Stack-free codegen: a local deployment's ids / pools / pyth feeds\n\t\t// are LOADED CONFIG DATA -- the committed `deepbook.ts` stub emits\n\t\t// `requireValue(dep, 'deepbook:<name>', '<key>')`, never a baked id.\n\t\tstaticCodegen: () => [makeDeepbookStaticCodegen({ name, network: LOCAL_NETWORK_NAME })],\n\t\t// `deps` auto-infers from the runtime-built `dependsOn`; it\n\t\t// resolves to a heterogeneous tuple the body re-narrows via the\n\t\t// `as unknown as` cast below. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui, publisher, deepbookPackage, ...extraValues] = deps as unknown as readonly [\n\t\t\t\t\tResourceValueOf<typeof suiResource>,\n\t\t\t\t\tAccountValue,\n\t\t\t\t\tLocalPackageResolved,\n\t\t\t\t\t...(AccountValue | LocalPackageResolved | CoinValue)[],\n\t\t\t\t];\n\t\t\t\tconst pythValueCount = opts.pyth === undefined ? 0 : 2;\n\t\t\t\tconst pythValues = extraValues.slice(0, pythValueCount);\n\t\t\t\tconst coinValues = extraValues.slice(pythValueCount) as CoinValue[];\n\n\t\t\t\tyield* setCurrentPluginPhase('reading deployment captures');\n\n\t\t\t\tconst registryId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.registryIdKey ?? 'registryId',\n\t\t\t\t\t'registryId',\n\t\t\t\t);\n\t\t\t\tconst adminCapId = yield* requireCapturedId(\n\t\t\t\t\tdeepbookPackage,\n\t\t\t\t\topts.adminCapIdKey ?? 'adminCapId',\n\t\t\t\t\t'adminCapId',\n\t\t\t\t);\n\t\t\t\tconst deepTreasuryId =\n\t\t\t\t\topts.deepTreasuryIdKey === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: (deepbookPackage.captured[opts.deepTreasuryIdKey] ?? null);\n\t\t\t\tconst deployment: DeepbookDeployment = {\n\t\t\t\t\tpackageId: deepbookPackage.packageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t};\n\t\t\t\tconst poolRefs = poolCoinRefs(opts.pools);\n\t\t\t\tconst coinValuesByRefId = new Map<string, CoinValue>();\n\t\t\t\tfor (let i = 0; i < poolRefs.length; i += 1) {\n\t\t\t\t\tconst ref = poolRefs[i];\n\t\t\t\t\tconst value = coinValues[i];\n\t\t\t\t\tif (ref !== undefined && value !== undefined) {\n\t\t\t\t\t\tcoinValuesByRefId.set(ref.id, value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst poolSpecs = yield* resolvePoolSpecs(opts.pools, coinValuesByRefId);\n\t\t\t\tconst artifactPublisher = yield* CacheService;\n\t\t\t\tyield* setCurrentPluginPhase(\n\t\t\t\t\topts.pyth === undefined ? 'creating pools' : 'initializing Pyth feeds',\n\t\t\t\t);\n\t\t\t\tconst pyth =\n\t\t\t\t\topts.pyth === undefined\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: yield* initLocalPythFeeds(\n\t\t\t\t\t\t\t\tartifactPublisher,\n\t\t\t\t\t\t\t\tsui.sdk,\n\t\t\t\t\t\t\t\tsui.chainId,\n\t\t\t\t\t\t\t\tpythValues[0] as AccountValue,\n\t\t\t\t\t\t\t\t{ packageId: (pythValues[1] as LocalPackageResolved).packageId },\n\t\t\t\t\t\t\t\topts.pyth.feeds,\n\t\t\t\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('creating pools');\n\t\t\t\tconst poolResult = yield* createDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase('seeding pools');\n\t\t\t\tconst seedResults = yield* seedDeepbookPools(\n\t\t\t\t\tartifactPublisher,\n\t\t\t\t\tsui.sdk,\n\t\t\t\t\tsui.chainId,\n\t\t\t\t\tpublisher,\n\t\t\t\t\tdeployment,\n\t\t\t\t\tpoolSpecs,\n\t\t\t\t\tpoolResult.pools,\n\t\t\t\t);\n\t\t\t\tyield* setCurrentPluginPhase(null);\n\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'local',\n\t\t\t\t\tnetwork: identity.network,\n\t\t\t\t\tpackageId: deployment.packageId,\n\t\t\t\t\tregistryId: deployment.registryId,\n\t\t\t\t\tadminCapId: deployment.adminCapId,\n\t\t\t\t\tdeepTreasuryId,\n\t\t\t\t\tpools: poolResult.pools,\n\t\t\t\t\tpyth,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: seedResults.length > 0,\n\t\t\t\t\tdeepFundingStrategy: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen. `resolved` is\n\t\t\t\t// the just-computed value; the snapshotable is the local-mode\n\t\t\t\t// `deepbook/<name>` subtree. No DEEP funding (null in local).\n\t\t\t\tconst snap: SnapshotableDecl = makeLocalSnapshotable({ name });\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: resolved.adminCapId,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: resolved.pools.map((p) => ({\n\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\tpoolId: p.poolId,\n\t\t\t\t\t\tbase: p.base,\n\t\t\t\t\t\tquote: p.quote,\n\t\t\t\t\t\tbaseCoinType: p.baseCoinType,\n\t\t\t\t\t\tquoteCoinType: p.quoteCoinType,\n\t\t\t\t\t})),\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: resolved.margin,\n\t\t\t\t\tserverUrl: resolved.serverUrl,\n\t\t\t\t\tindexerUrl: resolved.indexerUrl,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\treturn resolved;\n\t\t\t}).pipe(\n\t\t\t\t// The body's aggregate E channel includes substrate Effects\n\t\t\t\t// whose error shape is unknown to TS (ArtifactPublisher\n\t\t\t\t// produce bodies, dependency reads). `Effect.catchTags`\n\t\t\t\t// would need a statically-known tagged union; the\n\t\t\t\t// substrate's `passthroughOrWrap` runtime-checks the `_tag`\n\t\t\t\t// against `DEEPBOOK_ERROR_TAGS`, passing typed deepbook\n\t\t\t\t// errors through untouched and wrapping everything else\n\t\t\t\t// under `'publish'` so cascade attribution stays with the\n\t\t\t\t// plugin.\n\t\t\t\tpassthroughOrWrap.for<DeepbookError>()(DEEPBOOK_ERROR_TAGS, (err) =>\n\t\t\t\t\tdeepbookPluginError('publish', `deepbook acquire failed: ${String(err)}`, {\n\t\t\t\t\t\tcause: err,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t});\n};\n\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nfunction buildLocalPluginPublic<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec>,\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(opts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>) {\n\treturn buildLocalPlugin(opts);\n}\n\n// ---------------------------------------------------------------------------\n// Plugin construction — known\n// ---------------------------------------------------------------------------\n\nconst buildKnownPlugin = (opts: DeepbookKnownOptions) => {\n\tconst name = opts.name ?? DEFAULT_NAME;\n\tconst known = opts.network ? KNOWN_DEEPBOOK_DEPLOYMENTS[opts.network] : null;\n\tconst packageId = opts.packageId ?? known?.packageId;\n\tconst registryId = opts.registryId ?? known?.registryId;\n\tif (!packageId || !registryId) {\n\t\tthrow deepbookConfigError(\n\t\t\t'packageId',\n\t\t\t`deepbook({mode:'known', name:'${name}'}) requires packageId and registryId, or network:'mainnet'|'testnet'.`,\n\t\t\t`Pass explicit ids or use deepbook({mode:'known', network:'testnet'}).`,\n\t\t);\n\t}\n\tconst deepbookResource = makeDeepbookResource(name);\n\tconst snap = makeKnownSnapshotable({ name });\n\n\treturn definePlugin({\n\t\tid: deepbookResource.id,\n\t\tdependsOn: [suiResource] as const,\n\t\trole: 'task',\n\t\tsection: 'service',\n\t\tpluginKey: deepbookPluginKey(name),\n\t\t// Known mode's deployment ids (package / registry / deep-treasury) and\n\t\t// its declared testnet/mainnet Pyth ids are DECLARED config — bake them\n\t\t// as literals in the committed tree (mirrors `knownPackage`).\n\t\tstaticCodegen: () => [\n\t\t\tmakeDeepbookStaticCodegen({\n\t\t\t\tname,\n\t\t\t\tnetwork: opts.network ?? known?.network ?? LOCAL_NETWORK_NAME,\n\t\t\t\tknown: {\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpyth: known?.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: known.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: known.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: known.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: known.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t},\n\t\t\t}),\n\t\t],\n\t\t// `deps` auto-infers the resolved `[sui]` tuple from the\n\t\t// `[suiResource] as const` dependency. `ctx` arrives via the\n\t\t// `PluginContext` service.\n\t\tstart: (deps) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst ctx = yield* PluginContext;\n\t\t\t\tconst identity = yield* IdentityContext;\n\t\t\t\tconst [sui] = deps;\n\t\t\t\tconst network = opts.network ?? known?.network ?? identity.network;\n\t\t\t\tconst resolved: DeepbookResolved = {\n\t\t\t\t\tmode: 'known',\n\t\t\t\t\tnetwork,\n\t\t\t\t\tpackageId,\n\t\t\t\t\tregistryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: known?.deepTreasuryId ?? null,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: known?.pyth ?? null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t\thasSeedLiquidity: false,\n\t\t\t\t\t// DEEP funding is a testnet-deepbook concern — gate on the\n\t\t\t\t\t// network name alone. (The old `&& String(chain) === 'sui:testnet'`\n\t\t\t\t\t// conjunct compared a genesis-digest chainId against a network\n\t\t\t\t\t// literal and was dead for every non-literal `chain` value.)\n\t\t\t\t\tdeepFundingStrategy:\n\t\t\t\t\t\topts.network === 'testnet'\n\t\t\t\t\t\t\t? makeDeepbookDeepFundingStrategy({ suiSdk: sui.sdk })\n\t\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t\t// Emit contributions inline: snapshot -> codegen -> (optional\n\t\t\t\t// DEEP funding strategy). `resolved` is the just-computed value;\n\t\t\t\t// `snap` is the known-mode identity-guard snapshotable in scope.\n\t\t\t\t// The DEEP funding contributor is emitted only when\n\t\t\t\t// `resolved.deepFundingStrategy` is non-null.\n\t\t\t\tconst bindings: DeepbookBindings = {\n\t\t\t\t\tname,\n\t\t\t\t\tnetwork: resolved.network,\n\t\t\t\t\tpackageId: resolved.packageId,\n\t\t\t\t\tregistryId: resolved.registryId,\n\t\t\t\t\tadminCapId: null,\n\t\t\t\t\tdeepTreasuryId: resolved.deepTreasuryId,\n\t\t\t\t\tpools: [],\n\t\t\t\t\tpyth: resolved.pyth\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpackageId: resolved.pyth.packageId,\n\t\t\t\t\t\t\t\tstateId: resolved.pyth.stateId,\n\t\t\t\t\t\t\t\twormholeStateId: resolved.pyth.wormholeStateId,\n\t\t\t\t\t\t\t\tfeeds: resolved.pyth.feeds.map((feed) => ({\n\t\t\t\t\t\t\t\t\tsymbol: feed.symbol,\n\t\t\t\t\t\t\t\t\tfeedId: feed.feedId,\n\t\t\t\t\t\t\t\t\tpriceInfoObjectId: feed.priceInfoObjectId,\n\t\t\t\t\t\t\t\t\tprice: feed.price.toString(),\n\t\t\t\t\t\t\t\t\texpo: feed.expo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t\tmargin: null,\n\t\t\t\t\tserverUrl: null,\n\t\t\t\t\tindexerUrl: null,\n\t\t\t\t};\n\t\t\t\tctx.snapshotExtra(snap);\n\t\t\t\tctx.codegen(makeDeepbookCodegenable(bindings));\n\t\t\t\tif (resolved.deepFundingStrategy != null) {\n\t\t\t\t\tctx.provides(makeDeepbookDeepFundingContribution(resolved.deepFundingStrategy));\n\t\t\t\t}\n\t\t\t\treturn resolved;\n\t\t\t}),\n\t});\n};\n\n// ---------------------------------------------------------------------------\n// Default option resolution (env-driven)\n// ---------------------------------------------------------------------------\n\nconst resolveDefaultMode = <\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookOptions<Publisher, Pyth> => {\n\tconst env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n\t\t?.env?.DEVSTACK_NETWORK;\n\tif (env === undefined || env === 'localnet') {\n\t\t// Local DeepBook: default to local mode on localnet. The caller must\n\t\t// supply explicit `{ publisher, package, pools }`; `resolveLocalOptions`\n\t\t// fails fast otherwise (no auto-synthesis).\n\t\treturn { mode: 'local', ...opts } as DeepbookOptions<Publisher, Pyth>;\n\t}\n\t// Non-local default: refuse — known mode requires explicit\n\t// packageId/registryId. The user passes them via\n\t// `deepbookFor(network).known({...})` or `deepbook({mode:'known',...})`.\n\tthrow deepbookConfigError(\n\t\t'mode',\n\t\t`deepbook(): cannot auto-default to known mode on network='${env}'.`,\n\t\t`Use deepbookFor(network).known({packageId, registryId, ...}).`,\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// User-facing factories\n// ---------------------------------------------------------------------------\n\n/** Env-driven factory. Defaults to local mode on localnet when passed local\n * options. Explicit `override` and `known` modes bypass env inference. */\ntype DeepbookLocalMember<\n\tPublisher extends AccountMemberAlias,\n\tPackage extends DeepbookPackageMember,\n\tPools extends ReadonlyArray<DeepbookPoolSpec>,\n\tPyth extends PythOptions | undefined = undefined,\n> = ReturnType<typeof buildLocalPlugin<Publisher, Package, Pools, Pyth>>;\ntype DeepbookOverrideMember = ReturnType<typeof buildOverridePlugin>;\ntype DeepbookKnownMember = ReturnType<typeof buildKnownPlugin>;\n\n// Local DeepBook requires explicit `{ publisher, package, pools }`. There is\n// no zero-arg/synthesized overload — an under-specified call fails fast (see\n// `resolveLocalOptions`).\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: { readonly mode: 'local' } & DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore(\n\topts: { readonly mode: 'override' } & DeepbookOverrideOptions,\n): DeepbookOverrideMember;\nexport function deepbookCore(\n\topts: { readonly mode: 'known' } & DeepbookKnownOptions,\n): DeepbookKnownMember;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n): DeepbookLocalMember<Publisher, Package, Pools, Pyth>;\nexport function deepbookCore<\n\tconst Publisher extends AccountMemberAlias,\n\tconst Package extends DeepbookPackageMember,\n\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\tconst Pyth extends PythOptions | undefined = undefined,\n>(\n\topts?: DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | DeepbookOptions<Publisher, Pyth>,\n):\n\t| DeepbookLocalMember<Publisher, Package, Pools, Pyth>\n\t| DeepbookOverrideMember\n\t| DeepbookKnownMember {\n\tconst resolved: DeepbookOptions<Publisher, Pyth> =\n\t\topts !== undefined && 'mode' in opts\n\t\t\t? (opts as DeepbookOptions<Publisher, Pyth>)\n\t\t\t: resolveDefaultMode(\n\t\t\t\t\topts as DeepbookLocalOptions<Publisher, Package, Pools, Pyth> | undefined,\n\t\t\t\t);\n\tswitch (resolved.mode) {\n\t\tcase 'local': {\n\t\t\tconst localOpts = resolved as { readonly mode: 'local' } & DeepbookLocalOptions<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t\t// Explicit-config path only; `buildLocalPlugin` -> `resolveLocalOptions`\n\t\t\t// fails fast when `publisher`/`package`/`pools` are missing.\n\t\t\treturn buildLocalPluginPublic(localOpts) as DeepbookLocalMember<\n\t\t\t\tPublisher,\n\t\t\t\tPackage,\n\t\t\t\tPools,\n\t\t\t\tPyth\n\t\t\t>;\n\t\t}\n\t\tcase 'override':\n\t\t\treturn buildOverridePlugin(resolved);\n\t\tcase 'known':\n\t\t\treturn buildKnownPlugin(resolved);\n\t}\n}\n\n/** Mode-narrowed factory namespace.\n *\n * Usage:\n * const local = { mode: 'local', network: 'localnet' } as const;\n * deepbookFor(local).local({publisher, package, pools}) // OK\n * deepbookFor(local).override({packageId, registryId, adminCapId}) // OK\n * deepbookFor(local).testnet() // OK (known testnet)\n * deepbookFor(local).known({packageId, registryId}) // OK (raw-id override)\n *\n * const live = { mode: 'live', chainId: 'sui:testnet' } as const;\n * deepbookFor(live).mainnet() // OK (known mainnet)\n *\n * const fork = { mode: 'fork', network: 'mainnet-fork', upstream: 'mainnet' } as const;\n * deepbookFor(fork).local({...}) // COMPILE ERROR\n * deepbookFor(fork).override({...}) // COMPILE ERROR\n *\n * Per-network methods (`.testnet`/`.mainnet`) inject the network into\n * `buildKnownPlugin`; `.known(...)` is now the raw-id explicit-override form\n * only (`DeepbookKnownExplicitOptions`) — the `network`-in-`.known()` path was\n * HARD CUT. The fork branch has NO `.local` or `.override` entry —\n * `deepbookFor(forkNetwork).local` is a compile-time refusal. */\nexport const deepbookFor = defineModeNamespace({\n\tlocal: {\n\t\tlocal: <\n\t\t\tconst Publisher extends AccountMemberAlias,\n\t\t\tconst Package extends DeepbookPackageMember,\n\t\t\tconst Pools extends ReadonlyArray<DeepbookPoolSpec> = readonly [],\n\t\t\tconst Pyth extends PythOptions | undefined = undefined,\n\t\t>(\n\t\t\topts: DeepbookLocalOptions<Publisher, Package, Pools, Pyth>,\n\t\t) => buildLocalPluginPublic(opts),\n\t\toverride: (opts: DeepbookOverrideOptions) => buildOverridePlugin(opts),\n\t\tknown: (opts: DeepbookKnownExplicitOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tlive: {\n\t\tknown: (opts: DeepbookKnownExplicitOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n\tfork: {\n\t\t// `.override` intentionally absent — compile-time refusal.\n\t\tknown: (opts: DeepbookKnownExplicitOptions) => buildKnownPlugin(opts),\n\t\ttestnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'testnet', ...opts }),\n\t\tmainnet: (opts: DeepbookKnownByNetworkOptions = {}) =>\n\t\t\tbuildKnownPlugin({ network: 'mainnet', ...opts }),\n\t},\n});\n\nexport { deepbookCore as deepbook };\n\n// ---------------------------------------------------------------------------\n// Re-exports for advanced callers\n// ---------------------------------------------------------------------------\n\nexport {\n\tDEEPBOOK_DEEP_FAUCET_STRATEGY_KEY,\n\tDEEPBOOK_TESTNET_DEEP_COIN_TYPE,\n} from './faucet-strategy.ts';\nexport {\n\ttype DeepbookError,\n\ttype DeepbookPluginError,\n\ttype DeepbookConfigError,\n\ttype DeepbookPhase,\n} from './errors.ts';\nexport type { DeepbookBindings } from './codegen.ts';\nexport type {\n\tAccountMemberAlias,\n\tCoinMemberAlias,\n\tDeepbookPackageMember,\n\tDeepbookPool,\n\tDeepbookPoolCoin,\n\tDeepbookPoolSeedLiquidity,\n\tDeepbookPoolSeedOrder,\n\tDeepbookPoolSpec,\n} from './types.ts';\nexport {\n\tDEEP_PRICE_FEED_ID,\n\tpythPriceFeedId,\n\tSUI_PRICE_FEED_ID,\n\tUSDC_PRICE_FEED_ID,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsGA,MAAM,wBAA6C,SAClD,SACC,YAAY,MACb;AAoID,MAAM,eAAe;AAYrB,MAAM,6BASF;CACH,SAAS;EACR,SAAS;EACT,WAAW,kBAAkB;EAC7B,YAAY,kBAAkB;EAC9B,gBAAgB,kBAAkB;EAClC,MAAM;GACL,WAAW;GACX,SAAS,mBAAmB;GAC5B,iBAAiB,mBAAmB;GACpC,OAAO,CAAC;EACT;CACD;CACA,SAAS;EACR,SAAS;EACT,WAAW,kBAAkB;EAC7B,YAAY,kBAAkB;EAC9B,gBAAgB,kBAAkB;EAClC,MAAM;GACL,WAAW;GACX,SAAS,mBAAmB;GAC5B,iBAAiB,mBAAmB;GACpC,OAAO,CAAC;EACT;CACD;AACD;AAwBA,MAAM,gBACL,UAEA,MAAM,SAAS,SAAS,CAAC,KAAK,KAAK,MAAM,KAAK,MAAM,IAAI,CAAC;AAI1D,MAAM,YAAkD,SACtD,SAAS,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK,QAAQ,KAAK,OAAO;AAEtD,MAAM,kBAML,SAEA;CACC;CACA,KAAK;CACL,KAAK;CACL,GAAG,SAAS,KAAK,IAAI;CACrB,GAAG,aAAc,KAAK,SAAS,CAAC,CAAW;AAC5C;AAED,MAAM,qBACL,KACA,KACA,SACgD;CAChD,MAAM,QAAQ,IAAI,SAAS;CAC3B,IAAI,OAAO,UAAU,YAAY,MAAM,SAAS,GAC/C,OAAO,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,oBAAoB;CAC9C,OAAO;EACN,QAMC,SACI,uBAAuB,IAAI;EAChC,WAAW,SAAkC,oBAAoB,IAAI;EACrE,QAAQ,SAAuC,iBAAiB,IAAI;EACpE,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;CACA,MAAM;EACL,QAAQ,SAAuC,iBAAiB,IAAI;EACpE,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;CACA,MAAM;EAEL,QAAQ,SAAuC,iBAAiB,IAAI;EACpE,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;EACjD,UAAU,OAAsC,CAAC,MAChD,iBAAiB;GAAE,SAAS;GAAW,GAAG;EAAK,CAAC;CAClD;AACD,CAAC"}
@@ -7,6 +7,11 @@ interface SealBindings {
7
7
  readonly objectId: string;
8
8
  readonly keyServerUrl: string;
9
9
  readonly serverConfigs: ReadonlyArray<SealKeyServerEntry>;
10
+ /** Whether the SDK should verify the key servers (true on live /
11
+ * fork-known, false on local-keygen). Declared config — known at
12
+ * factory time, emitted as a plain boolean literal (never a
13
+ * `requireValue`, since it's not a secret). */
14
+ readonly verifyKeyServers: boolean;
10
15
  readonly mode: 'local-keygen' | 'live' | 'fork-known';
11
16
  }
12
17
  //#endregion
@@ -1,5 +1,23 @@
1
1
  import { keyedBucketSpec, liveBucketCodegen, staticBucketCodegen } from "../../contracts/config-bindings.mjs";
2
2
  //#region src/plugins/seal/codegen.ts
3
+ /** Static-codegen TS type for the `serverConfigs` field — mirrors
4
+ * `SealKeyServerEntry` (the structural literal so the committed `seal.ts`
5
+ * carries the concrete type with NO emitted import). The `apiKey?` slot is
6
+ * kept in the TYPE so a consumer can inject the secret at runtime, but devstack
7
+ * never emits a `apiKey` VALUE (see `stripApiKey`). */
8
+ const SERVER_CONFIGS_TS_TYPE = "ReadonlyArray<{ readonly objectId: string; readonly weight: number; readonly apiKeyName?: string; readonly apiKey?: string; readonly aggregatorUrl?: string }>";
9
+ /** Defense-in-depth: drop any `apiKey` from an emitted `serverConfigs` array.
10
+ * devstack NEVER carries the secret committee apiKey value — both the committed
11
+ * `seal.ts` and the browser-injected `deployment.json` (the `values` channel)
12
+ * are world-readable. `validateLiveInputs` already refuses to accept an apiKey,
13
+ * so this is belt-and-suspenders at the codegen boundary. The app injects the
14
+ * apiKey into `serverConfigs` at runtime, keyed by the emitted non-secret
15
+ * `apiKeyName`. */
16
+ const stripApiKey = (serverConfigs) => serverConfigs.map((entry) => {
17
+ const rest = { ...entry };
18
+ delete rest.apiKey;
19
+ return rest;
20
+ });
3
21
  /** Build the seal instance's config-binding spec for `name`. `name` / `mode`
4
22
  * are structural literals. For a `local-keygen` instance the object id / URL
5
23
  * are dynamically-deployed (`requireValue(dep, …)`) and `serverConfigs` is a runtime
@@ -31,7 +49,12 @@ const sealBucketSpec = (structural) => {
31
49
  {
32
50
  key: "serverConfigs",
33
51
  variant: "literal",
34
- value: known.serverConfigs
52
+ value: stripApiKey(known.serverConfigs)
53
+ },
54
+ {
55
+ key: "verifyKeyServers",
56
+ variant: "literal",
57
+ value: known.verifyKeyServers
35
58
  }
36
59
  ] : [
37
60
  {
@@ -59,8 +82,14 @@ const sealBucketSpec = (structural) => {
59
82
  {
60
83
  key: "serverConfigs",
61
84
  variant: "resolved",
62
- tsType: "ReadonlyArray<{ readonly objectId: string; readonly weight: number; readonly aggregatorUrl?: string }>",
63
- live: (s) => s.serverConfigs
85
+ tsType: SERVER_CONFIGS_TS_TYPE,
86
+ live: (s) => stripApiKey(s.serverConfigs)
87
+ },
88
+ {
89
+ key: "verifyKeyServers",
90
+ variant: "resolved",
91
+ tsType: "boolean",
92
+ live: (s) => s.verifyKeyServers
64
93
  }
65
94
  ];
66
95
  return keyedBucketSpec({
@@ -70,13 +99,27 @@ const sealBucketSpec = (structural) => {
70
99
  fields
71
100
  });
72
101
  };
73
- /** Build the LIVE Codegenable contribution for a seal instance. Bakes the
74
- * resolved key-server fields + feeds the generic deployment `values`
75
- * channel. */
76
- const makeSealCodegenable = (bindings) => liveBucketCodegen(sealBucketSpec({
77
- name: bindings.name,
78
- mode: bindings.mode
79
- }), bindings);
102
+ /** Build the LIVE Codegenable contribution for a seal instance.
103
+ *
104
+ * Live / fork-known deployments resolve their ids at factory time, so they
105
+ * are DECLARED config — pass `known` so they bake as literals (the SAME branch
106
+ * the static codegen uses). This keeps the two derivations consistent AND
107
+ * keeps the known `serverConfigs` OUT of the world-readable `values` channel
108
+ * entirely (literals don't ride `values`). Only `local-keygen`'s
109
+ * dynamically-deployed ids flow through the resolved/`values` channel. */
110
+ const makeSealCodegenable = (bindings) => {
111
+ const known = bindings.mode === "local-keygen" ? void 0 : {
112
+ objectId: bindings.objectId,
113
+ keyServerUrl: bindings.keyServerUrl,
114
+ serverConfigs: bindings.serverConfigs,
115
+ verifyKeyServers: bindings.verifyKeyServers
116
+ };
117
+ return liveBucketCodegen(sealBucketSpec({
118
+ name: bindings.name,
119
+ mode: bindings.mode,
120
+ known
121
+ }), bindings);
122
+ };
80
123
  /** Build the STATIC (stack-free) Codegenable contribution for a seal
81
124
  * instance. Emits `requireValue(dep, 'seal:<name>', '<key>')` for the runtime
82
125
  * fields; the committed `seal.ts` carries no baked object id / endpoint URL. */