dexbot 1.7.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +3 -3
- package/analysis/README.md +33 -13
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/account_resolver.js +5 -6
- package/dist/analysis/analyze_liquidity.js +15 -4
- package/dist/analysis/bot_key_utils.d.ts +44 -1
- package/dist/analysis/bot_key_utils.js +76 -7
- package/dist/analysis/fills_cache.js +2 -1
- package/dist/analysis/grid_correction_check.d.ts +1 -19
- package/dist/analysis/grid_correction_check.js +12 -30
- package/dist/analysis/liquidity/liquidity_chart_generator.js +190 -20
- package/dist/analysis/liquidity/liquidity_depth_model.d.ts +41 -16
- package/dist/analysis/liquidity/liquidity_depth_model.js +49 -21
- package/dist/analysis/liquidity/liquidity_view.d.ts +15 -0
- package/dist/analysis/liquidity/liquidity_view.js +11 -0
- package/dist/analysis/resolve_bot_accounts.js +7 -6
- package/dist/analysis/trade_profitability.js +2 -1
- package/dist/credential-daemon.js +13 -2
- package/dist/dexbot.js +4 -4
- package/dist/modules/account_bots.d.ts +12 -1
- package/dist/modules/account_bots.js +7 -5
- package/dist/modules/account_orders.d.ts +12 -0
- package/dist/modules/account_orders.js +30 -0
- package/dist/modules/bitshares-native/transport.js +24 -6
- package/dist/modules/bitshares_client.d.ts +24 -6
- package/dist/modules/bitshares_client.js +44 -7
- package/dist/modules/bot_settings.d.ts +2 -0
- package/dist/modules/constants.d.ts +28 -3
- package/dist/modules/constants.js +79 -10
- package/dist/modules/dexbot_class.d.ts +23 -6
- package/dist/modules/dexbot_class.js +44 -0
- package/dist/modules/dexbot_cow_runtime.d.ts +128 -8
- package/dist/modules/dexbot_cow_runtime.js +688 -188
- package/dist/modules/dexbot_fill_runtime.js +124 -35
- package/dist/modules/dexbot_maintenance_runtime.d.ts +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +259 -79
- package/dist/modules/dexbot_startup_runtime.js +32 -20
- package/dist/modules/dexbot_state_recovery.d.ts +33 -1
- package/dist/modules/dexbot_state_recovery.js +167 -5
- package/dist/modules/node_connect_policy.d.ts +8 -1
- package/dist/modules/node_connect_policy.js +18 -2
- package/dist/modules/node_flap_score.d.ts +87 -0
- package/dist/modules/node_flap_score.js +124 -0
- package/dist/modules/node_health_cache.d.ts +40 -3
- package/dist/modules/node_health_cache.js +66 -20
- package/dist/modules/node_manager.d.ts +101 -19
- package/dist/modules/node_manager.js +255 -65
- package/dist/modules/order/accounting.d.ts +9 -4
- package/dist/modules/order/accounting.js +131 -19
- package/dist/modules/order/async_lock.d.ts +7 -1
- package/dist/modules/order/async_lock.js +7 -1
- package/dist/modules/order/export.js +25 -18
- package/dist/modules/order/fill_ledger.d.ts +99 -0
- package/dist/modules/order/fill_ledger.js +103 -0
- package/dist/modules/order/format.d.ts +24 -10
- package/dist/modules/order/format.js +30 -10
- package/dist/modules/order/grid.d.ts +75 -18
- package/dist/modules/order/grid.js +289 -72
- package/dist/modules/order/grid_reconcile.d.ts +5 -1
- package/dist/modules/order/grid_reconcile.js +333 -210
- package/dist/modules/order/grid_reconcile_internal.d.ts +38 -2
- package/dist/modules/order/grid_reconcile_internal.js +223 -91
- package/dist/modules/order/index.d.ts +18 -5
- package/dist/modules/order/index.js +5 -5
- package/dist/modules/order/lifecycle.d.ts +353 -0
- package/dist/modules/order/lifecycle.js +1109 -0
- package/dist/modules/order/manager.d.ts +277 -20
- package/dist/modules/order/manager.js +680 -64
- package/dist/modules/order/placement_lock.d.ts +102 -0
- package/dist/modules/order/placement_lock.js +222 -0
- package/dist/modules/order/strategy.js +13 -1
- package/dist/modules/order/sync_engine.d.ts +74 -114
- package/dist/modules/order/sync_engine.js +254 -198
- package/dist/modules/order/utils/math.d.ts +29 -4
- package/dist/modules/order/utils/math.js +61 -4
- package/dist/modules/order/utils/order.d.ts +106 -37
- package/dist/modules/order/utils/order.js +256 -81
- package/dist/modules/order/utils/system.d.ts +99 -6
- package/dist/modules/order/utils/system.js +249 -35
- package/dist/modules/order/utils/validate.d.ts +7 -1
- package/dist/modules/order/utils/validate.js +48 -2
- package/dist/modules/outcome.d.ts +54 -0
- package/dist/modules/outcome.js +51 -0
- package/dist/modules/settings_merge.d.ts +4 -0
- package/dist/modules/settings_merge.js +9 -0
- package/dist/modules/timing_policy.d.ts +82 -0
- package/dist/modules/timing_policy.js +244 -0
- package/dist/modules/types.d.ts +149 -22
- package/dist/scripts/analyze-credit.js +54 -17
- package/dist/scripts/analyze-orders.d.ts +4 -2
- package/dist/scripts/analyze-orders.js +113 -34
- package/dist/scripts/chart_targets.js +11 -15
- package/dist/scripts/test-credit-renewal.js +12 -5
- package/docs/COW_INVARIANTS.md +71 -8
- package/docs/DEXBOT_COMPARISON.md +6 -6
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +1 -1
- package/docs/GRID_RECONCILE.md +18 -13
- package/docs/LOGGING.md +25 -1
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +183 -26
- package/docs/README.md +23 -2
- package/docs/WORKFLOW.md +9 -3
- package/docs/architecture.md +68 -13
- package/docs/developer_guide.md +25 -8
- package/modules/README.md +6 -0
- package/package.json +3 -3
- package/scripts/README.md +16 -0
- package/scripts/pdev.sh +14 -1
- package/scripts/pmain.sh +23 -8
- package/scripts/ptest.sh +7 -0
- package/tests/README.md +30 -1
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modules/order/lifecycle.ts - Order Lifecycle Registry
|
|
3
|
+
*
|
|
4
|
+
* ONE owner for "does this order exist on chain, and how sure are we?".
|
|
5
|
+
*
|
|
6
|
+
* The engine used to answer that question from seven independent structures,
|
|
7
|
+
* each with its own clock:
|
|
8
|
+
*
|
|
9
|
+
* - `_pendingBroadcasts` (fingerprint -> entry, PENDING_BROADCAST_TTL_MS)
|
|
10
|
+
* - `createUncertain` (slot flag, persisted, no clock)
|
|
11
|
+
* - `_committedOrderIds` (Set + built-at stamp, SYNC_LOCK_TIMEOUT_MS)
|
|
12
|
+
* - `_orderIdAssignedAt` (orderId -> ts, no clock)
|
|
13
|
+
* - `_placedAt` (orderId -> ts, SURPLUS_CANCEL_GRACE_MS)
|
|
14
|
+
* - `_chainSizeAppliedFills` (orderId -> marker, CHAIN_SIZE_APPLIED_MARKER_TTL_MS)
|
|
15
|
+
* - `_lastUnmatchedChainOrders` (array, no clock)
|
|
16
|
+
*
|
|
17
|
+
* Four read sites consulted four different subsets and could therefore give
|
|
18
|
+
* four different answers for the same order. That disagreement is the bug
|
|
19
|
+
* class this module removes.
|
|
20
|
+
*
|
|
21
|
+
* MODEL
|
|
22
|
+
* -----
|
|
23
|
+
* A record is keyed by **slot** when the slot is known (a slot is the stable
|
|
24
|
+
* identity across its order incarnations: intent -> chain id -> partial ->
|
|
25
|
+
* gone), by **orderId** when only the chain id is known, and by **fingerprint**
|
|
26
|
+
* when a CREATE has neither yet. `LifecycleView` is the single read surface:
|
|
27
|
+
* every consumer asks the same questions of the same record.
|
|
28
|
+
*
|
|
29
|
+
* The legacy structures are preserved as *facade views* (`_placedAt`, ...)
|
|
30
|
+
* backed by this registry, so existing call sites keep working while the
|
|
31
|
+
* truth lives in one place. See `LifecycleRegistry` accessors below.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Where an order is in its chain life.
|
|
35
|
+
*
|
|
36
|
+
* `unknown` is a real state, not an absence: a CREATE whose receipt was lost,
|
|
37
|
+
* an ambiguous read, or a persisted `createUncertain` marker. Consumers must
|
|
38
|
+
* treat it as "may exist on chain" — never as "gone", never as "absent".
|
|
39
|
+
*/
|
|
40
|
+
export type LifecyclePhase = 'intent' | 'broadcasting' | 'landed' | 'filling' | 'gone' | 'unknown';
|
|
41
|
+
/** What backs the current phase. `none` means nothing was ever observed. */
|
|
42
|
+
export type LifecycleEvidence = 'none' | 'local' | 'broadcast-receipt' | 'chain-snapshot' | 'fill-history' | 'adoption';
|
|
43
|
+
/** Minimal shape of a pending CREATE entry (mirrors `PendingBroadcast`). */
|
|
44
|
+
export interface PendingBroadcastLike {
|
|
45
|
+
slotId?: string | null;
|
|
46
|
+
order?: unknown;
|
|
47
|
+
fingerprint?: string | null;
|
|
48
|
+
recordedAt?: number;
|
|
49
|
+
orderType?: string;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
/** One lifecycle record. All clocks live here; nothing else owns a copy. */
|
|
53
|
+
export interface OrderLifecycleRecord {
|
|
54
|
+
/** Stable registry key. */
|
|
55
|
+
key: string;
|
|
56
|
+
slotId: string | null;
|
|
57
|
+
orderId: string | null;
|
|
58
|
+
fingerprint: string | null;
|
|
59
|
+
phase: LifecyclePhase;
|
|
60
|
+
evidence: LifecycleEvidence;
|
|
61
|
+
/** When the current phase was recorded (our clock). */
|
|
62
|
+
recordedAt: number;
|
|
63
|
+
/** When the CHAIN last told us anything (0 = never). */
|
|
64
|
+
observedAt: number;
|
|
65
|
+
/** When the current chain id was assigned locally. */
|
|
66
|
+
assignedAt: number;
|
|
67
|
+
/** When the current chain id was placed/adopted (surplus-cancel grace). */
|
|
68
|
+
placedAt: number;
|
|
69
|
+
/** When the current chain id was committed by the COW engine. */
|
|
70
|
+
committedAt: number;
|
|
71
|
+
/** Chain-size resize already absorbed by sync pass 1 (dedupe marker). */
|
|
72
|
+
appliedFillInt: number | null;
|
|
73
|
+
appliedFillAt: number | null;
|
|
74
|
+
/** Snapshot stamp the COW engine published this id under (0 = per-id stamp). */
|
|
75
|
+
committedSnapshotAt: number;
|
|
76
|
+
/** The raw pending-CREATE entry, when this record is a broadcasting intent. */
|
|
77
|
+
pending: PendingBroadcastLike | null;
|
|
78
|
+
/** Bumped on every mutation; useful for change detection in tests. */
|
|
79
|
+
revision: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Read surface for one order. Methods take an explicit `now` where a clock
|
|
83
|
+
* matters so tests never depend on wall time.
|
|
84
|
+
*/
|
|
85
|
+
export interface LifecycleView {
|
|
86
|
+
slotId: string | null;
|
|
87
|
+
orderId: string | null;
|
|
88
|
+
phase: LifecyclePhase;
|
|
89
|
+
evidence: LifecycleEvidence;
|
|
90
|
+
recordedAt: number;
|
|
91
|
+
observedAt: number;
|
|
92
|
+
assignedAt: number;
|
|
93
|
+
placedAt: number;
|
|
94
|
+
committedAt: number;
|
|
95
|
+
/** Phase is `unknown`: the order may or may not exist on chain. */
|
|
96
|
+
isUnknown: boolean;
|
|
97
|
+
/** Phase is `unknown` or `broadcasting`: unresolved evidence, not absence. */
|
|
98
|
+
isUnresolved: boolean;
|
|
99
|
+
/** Phase is `broadcasting`, `landed`, `filling` or `unknown`. */
|
|
100
|
+
mayExistOnChain: boolean;
|
|
101
|
+
/** The chain confirmed the order is absent. */
|
|
102
|
+
isConfirmedGone: boolean;
|
|
103
|
+
/** Planned only; nothing was ever sent. */
|
|
104
|
+
isIntentOnly: boolean;
|
|
105
|
+
/** The chain confirmed an open order (full or partial size). */
|
|
106
|
+
isOnChain: boolean;
|
|
107
|
+
/** Pending-CREATE payload, when this record is a broadcasting intent. */
|
|
108
|
+
pending: PendingBroadcastLike | null;
|
|
109
|
+
/** True while inside the fresh-placement grace window. */
|
|
110
|
+
isFreshlyPlaced(graceMs?: number, now?: number): boolean;
|
|
111
|
+
/** True when the chain id was assigned locally within `windowMs`. */
|
|
112
|
+
isRecentlyAssigned(windowMs?: number, now?: number): boolean;
|
|
113
|
+
/** True when committed within `windowMs`. */
|
|
114
|
+
isRecentlyCommitted(windowMs?: number, now?: number): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* True when this order's absence from a snapshot is NOT yet trustworthy.
|
|
117
|
+
*
|
|
118
|
+
* This is the single definition of the in-flight guard. The engine used to
|
|
119
|
+
* answer it from four different subsets (`_committedOrderIds` only in one
|
|
120
|
+
* place, `_orderIdAssignedAt` only in another, both in a third), so the
|
|
121
|
+
* same order could be deferred in one path and virtualized-as-phantom in
|
|
122
|
+
* another. Treating an unknown or recently-touched order as "maybe live"
|
|
123
|
+
* is always the safe direction: the cost is one deferred cleanup cycle,
|
|
124
|
+
* the alternative is a duplicated live order.
|
|
125
|
+
*
|
|
126
|
+
* Bounded in time: an unresolved record stops suppressing cleanup after
|
|
127
|
+
* 2× `PENDING_BROADCAST_TTL_MS`, so a lagging node cannot park the grid.
|
|
128
|
+
*/
|
|
129
|
+
isInFlight(windowMs?: number, now?: number): boolean;
|
|
130
|
+
/** True when an unresolved phase is still inside the suppression bound. */
|
|
131
|
+
isUnresolvedFresh(now?: number): boolean;
|
|
132
|
+
/** True when sync pass 1 already absorbed this chain filled amount. */
|
|
133
|
+
appliedFillMatches(filledInt: number): boolean;
|
|
134
|
+
/** True when the phase was recorded by evidence from outside the process. */
|
|
135
|
+
isChainBacked(): boolean;
|
|
136
|
+
}
|
|
137
|
+
interface ObserveInput {
|
|
138
|
+
phase?: LifecyclePhase;
|
|
139
|
+
evidence?: LifecycleEvidence;
|
|
140
|
+
slotId?: string | null;
|
|
141
|
+
orderId?: string | null;
|
|
142
|
+
fingerprint?: string | null;
|
|
143
|
+
observedAt?: number;
|
|
144
|
+
at?: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Read a timing window in milliseconds with a fallback for a missing constant.
|
|
148
|
+
*
|
|
149
|
+
* The fallback exists for fixtures that stub `TIMING` with a partial object. It
|
|
150
|
+
* must never be a SECOND definition of the window: it is the value the constant
|
|
151
|
+
* already carries (see modules/constants.ts), applied only when the constant is
|
|
152
|
+
* absent or unusable.
|
|
153
|
+
*
|
|
154
|
+
* @param key - TIMING key
|
|
155
|
+
* @param fallback - Value to use when the constant is missing/unusable
|
|
156
|
+
* @returns {number} Positive window length in milliseconds
|
|
157
|
+
*/
|
|
158
|
+
export declare function timingWindowMs(key: string, fallback: number): number;
|
|
159
|
+
/** Retention of an unresolved pending-CREATE entry. */
|
|
160
|
+
export declare function pendingBroadcastTtlMs(): number;
|
|
161
|
+
export interface LifecycleRegistryOptions {
|
|
162
|
+
/** Clock seam for tests. Defaults to `Date.now`. */
|
|
163
|
+
now?: () => number;
|
|
164
|
+
/** Hard cap on retained records (GC bound, not a correctness gate). */
|
|
165
|
+
maxRecords?: number;
|
|
166
|
+
}
|
|
167
|
+
export declare class LifecycleRegistry {
|
|
168
|
+
private readonly records;
|
|
169
|
+
private readonly byOrderId;
|
|
170
|
+
private readonly bySlotId;
|
|
171
|
+
private readonly byFingerprint;
|
|
172
|
+
private readonly now;
|
|
173
|
+
private readonly maxRecords;
|
|
174
|
+
/**
|
|
175
|
+
* The single "last committed snapshot" stamp. The COW engine publishes a
|
|
176
|
+
* whole Set of committed ids at once, and the protection window is measured
|
|
177
|
+
* from that publish, not from each id. Kept here so the stamp cannot drift
|
|
178
|
+
* away from the ids it describes.
|
|
179
|
+
*/
|
|
180
|
+
private committedSnapshotAt;
|
|
181
|
+
/** Facade for `manager._placedAt`. */
|
|
182
|
+
readonly placedAt: Map<string, number>;
|
|
183
|
+
/** Facade for `manager._orderIdAssignedAt`. */
|
|
184
|
+
readonly assignedAt: Map<string, number>;
|
|
185
|
+
/** Facade for `manager._committedOrderIds`. */
|
|
186
|
+
readonly committedIds: Set<string>;
|
|
187
|
+
/** Facade for `manager._pendingBroadcasts` (keyed by fingerprint). */
|
|
188
|
+
readonly pendingBroadcasts: Map<string, PendingBroadcastLike>;
|
|
189
|
+
/** Facade for `manager._chainSizeAppliedFills`. */
|
|
190
|
+
readonly appliedFills: Map<string, {
|
|
191
|
+
filledInt: number;
|
|
192
|
+
at: number;
|
|
193
|
+
}>;
|
|
194
|
+
constructor(options?: LifecycleRegistryOptions);
|
|
195
|
+
private createRecord;
|
|
196
|
+
private keyForSlot;
|
|
197
|
+
private keyForOrder;
|
|
198
|
+
/**
|
|
199
|
+
* Find (or create) the record that owns this slot, claiming any order-only
|
|
200
|
+
* record for `orderId` on the way so a slot's life never forks in two.
|
|
201
|
+
*/
|
|
202
|
+
private recordForSlot;
|
|
203
|
+
private linkOrderId;
|
|
204
|
+
/** Record for a fingerprint whose CREATE has no slot id yet. */
|
|
205
|
+
private recordForFingerprint;
|
|
206
|
+
/** Resolve a record from any of the three identities. */
|
|
207
|
+
private findByIdentity;
|
|
208
|
+
private prune;
|
|
209
|
+
/** True when a record carries no live uncertainty and may be evicted. */
|
|
210
|
+
private isEvictable;
|
|
211
|
+
private dropRecord;
|
|
212
|
+
/** Resolve a read surface for any identity (slot / orderId / fingerprint). */
|
|
213
|
+
view(id: string | null | undefined): LifecycleView;
|
|
214
|
+
/** Raw record (diagnostics / tests). Returns a frozen copy. */
|
|
215
|
+
snapshot(id: string | null | undefined): Readonly<OrderLifecycleRecord> | null;
|
|
216
|
+
size(): number;
|
|
217
|
+
/**
|
|
218
|
+
* A read-only view with one phase overridden, without touching the record.
|
|
219
|
+
*
|
|
220
|
+
* Used where a caller holds extra evidence the registry does not (a
|
|
221
|
+
* persisted per-slot flag): the read must reflect it, but a read must not
|
|
222
|
+
* write. Mutating here would also refresh `recordedAt` on every call and
|
|
223
|
+
* keep `isUnresolvedFresh` eternally true.
|
|
224
|
+
*
|
|
225
|
+
* @param identity - Slot id, chain order id or fingerprint
|
|
226
|
+
* @param phase - Phase to report
|
|
227
|
+
* @param evidence - Evidence backing the overridden phase
|
|
228
|
+
* @returns {LifecycleView} Read surface over a copy
|
|
229
|
+
*/
|
|
230
|
+
withPhase(identity: string | null | undefined, phase: LifecyclePhase, evidence: LifecycleEvidence): LifecycleView;
|
|
231
|
+
/** Record a planned-only order (nothing broadcast). */
|
|
232
|
+
markIntent(identity: {
|
|
233
|
+
slotId?: string | null;
|
|
234
|
+
orderId?: string | null;
|
|
235
|
+
}, at?: number): LifecycleView;
|
|
236
|
+
/**
|
|
237
|
+
* Mark a slot as holding no chain order, but only when nothing unresolved is
|
|
238
|
+
* on record.
|
|
239
|
+
*
|
|
240
|
+
* "Nothing is out there" is a claim that requires evidence. If the record is
|
|
241
|
+
* still `unknown` or `broadcasting`, an unrelated slot mutation (a size tweak,
|
|
242
|
+
* a re-plan) must not silently erase that: the only ways out are an explicit
|
|
243
|
+
* decision by the caller (`markIntent`) or the chain answering.
|
|
244
|
+
*
|
|
245
|
+
* @param slotId - Slot id
|
|
246
|
+
* @param at - Clock override (tests)
|
|
247
|
+
* @returns {LifecycleView}
|
|
248
|
+
*/
|
|
249
|
+
markIntentIfResolved(slotId: string | null | undefined, at?: number): LifecycleView;
|
|
250
|
+
/**
|
|
251
|
+
* Record a state transition observed from an external source.
|
|
252
|
+
*
|
|
253
|
+
* Two rules make the clocks trustworthy:
|
|
254
|
+
*
|
|
255
|
+
* - `observedAt` only advances for chain-backed evidence, so "when did we
|
|
256
|
+
* last hear the truth" cannot be advanced by local bookkeeping.
|
|
257
|
+
* - `recordedAt` (the anchor of the unresolved bound) only advances when the
|
|
258
|
+
* phase actually changes or chain-backed evidence arrives. Re-asserting the
|
|
259
|
+
* same unresolved phase is not new information; refreshing the clock for it
|
|
260
|
+
* would keep `isInFlight()` true forever, which is the opposite of the
|
|
261
|
+
* documented 2× TTL escape hatch.
|
|
262
|
+
*
|
|
263
|
+
* Evidence is monotonic within a phase (see EVIDENCE_RANK): a local write
|
|
264
|
+
* that follows a chain observation keeps the stronger evidence.
|
|
265
|
+
*/
|
|
266
|
+
observe(orderId: string | null | undefined, input?: ObserveInput): LifecycleView;
|
|
267
|
+
/** The chain confirmed an open order (full or partial). */
|
|
268
|
+
markLanded(orderId: string, input?: ObserveInput): LifecycleView;
|
|
269
|
+
/** A receipt was lost / a read was ambiguous: the order may exist. */
|
|
270
|
+
markUnknown(orderId: string | null | undefined, input?: ObserveInput): LifecycleView;
|
|
271
|
+
/** Record the chain id assigned to a slot. */
|
|
272
|
+
markAssigned(slotId: string | null | undefined, orderId: string | null | undefined, at?: number): LifecycleView;
|
|
273
|
+
/** Record a fresh on-chain placement (surplus-cancel grace anchor). */
|
|
274
|
+
markPlaced(orderId: string | null | undefined, at?: number, slotId?: string | null): LifecycleView;
|
|
275
|
+
/**
|
|
276
|
+
* Publish a whole committed-id snapshot atomically (COW commit path).
|
|
277
|
+
* This is the only writer that moves the snapshot stamp.
|
|
278
|
+
*/
|
|
279
|
+
markCommittedSnapshot(orderIds: Iterable<string>, at?: number): void;
|
|
280
|
+
/** The stamp of the last published committed-id snapshot (0 = none). */
|
|
281
|
+
get committedBuiltAt(): number;
|
|
282
|
+
set committedBuiltAt(value: number);
|
|
283
|
+
/** Record that sync pass 1 already absorbed this chain filled amount. */
|
|
284
|
+
markAppliedFill(orderId: string | null | undefined, filledInt: number, at?: number): void;
|
|
285
|
+
/** Forget everything about an identity (cancel confirmed, slot cleared). */
|
|
286
|
+
forget(id: string | null | undefined): void;
|
|
287
|
+
setPending(fingerprint: string, entry: PendingBroadcastLike | null | undefined): void;
|
|
288
|
+
getPending(fingerprint: string | null | undefined): PendingBroadcastLike | undefined;
|
|
289
|
+
deletePending(fingerprint: string | null | undefined): void;
|
|
290
|
+
/** Drop a record's pending-CREATE payload and its fingerprint index entry. */
|
|
291
|
+
private dropPending;
|
|
292
|
+
clearPending(): void;
|
|
293
|
+
pendingSize(): number;
|
|
294
|
+
private pendingEntries;
|
|
295
|
+
private clock;
|
|
296
|
+
private writePlacedAt;
|
|
297
|
+
private writeAssignedAt;
|
|
298
|
+
private writeCommitted;
|
|
299
|
+
private writeAppliedFill;
|
|
300
|
+
private placedEntries;
|
|
301
|
+
private assignedEntries;
|
|
302
|
+
private appliedEntries;
|
|
303
|
+
private committedValues;
|
|
304
|
+
private clearPlacedAt;
|
|
305
|
+
private clearAssignedAt;
|
|
306
|
+
private clearCommitted;
|
|
307
|
+
private clearAppliedFills;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* True when a slot carries a persisted "the CREATE result was lost" marker.
|
|
311
|
+
*
|
|
312
|
+
* This is the single definition; the registry phase and the slot flag must
|
|
313
|
+
* never disagree, so every site that used to read `slot.createUncertain`
|
|
314
|
+
* directly goes through here.
|
|
315
|
+
*/
|
|
316
|
+
export declare function isSlotCreateUncertain(slot: unknown): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Read an order's lifecycle from any manager-shaped object.
|
|
319
|
+
*
|
|
320
|
+
* Production managers expose `getLifecycle`; partial test doubles and legacy
|
|
321
|
+
* call sites that only carry the raw maps still work, because the fallback
|
|
322
|
+
* synthesizes a record from exactly those maps. That keeps the *vocabulary*
|
|
323
|
+
* unified (callers ask one question) without requiring every fixture to grow a
|
|
324
|
+
* registry.
|
|
325
|
+
*
|
|
326
|
+
* @param manager - OrderManager, its interface, or a partial test double
|
|
327
|
+
* @param identity - Slot id, chain order id, or pending-broadcast fingerprint
|
|
328
|
+
* @returns {LifecycleView} Unified read surface (never null)
|
|
329
|
+
*/
|
|
330
|
+
export declare function readLifecycle(manager: unknown, identity: string | null | undefined): LifecycleView;
|
|
331
|
+
/**
|
|
332
|
+
* Read an order's lifecycle from a SLOT (preferred over an identity lookup).
|
|
333
|
+
*
|
|
334
|
+
* A slot is the stable identity (intent → chain id → partial → gone) and can
|
|
335
|
+
* carry evidence the registry does not: the persisted `createUncertain` marker,
|
|
336
|
+
* which must report `unknown` (may exist on chain) rather than a clean intent.
|
|
337
|
+
* Every absence decision that has the slot object in hand must go through this
|
|
338
|
+
* helper, not `readLifecycle(manager, slot.orderId)` — an orderId-keyed read
|
|
339
|
+
* silently ignores the marker and can virtualize an order whose CREATE landed.
|
|
340
|
+
*
|
|
341
|
+
* Falls back to the identity read for partial test doubles.
|
|
342
|
+
*
|
|
343
|
+
* @param manager - OrderManager, its interface, or a partial test double
|
|
344
|
+
* @param slot - Grid slot the decision is about
|
|
345
|
+
* @returns {LifecycleView} Unified read surface (never null)
|
|
346
|
+
*/
|
|
347
|
+
export declare function readSlotLifecycle(manager: unknown, slot: {
|
|
348
|
+
id?: string;
|
|
349
|
+
orderId?: string | null;
|
|
350
|
+
createUncertain?: boolean;
|
|
351
|
+
} | null | undefined): LifecycleView;
|
|
352
|
+
export {};
|
|
353
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|