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
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Pure numeric calculations, blockchain conversions, fee math, and fund allocation.
|
|
5
5
|
*
|
|
6
6
|
* ===============================================================================
|
|
7
|
-
* TABLE OF CONTENTS (
|
|
7
|
+
* TABLE OF CONTENTS (80 exports + the GridGenesis and FeeCacheEntry types)
|
|
8
8
|
* ===============================================================================
|
|
9
9
|
*
|
|
10
|
-
* SECTION 1: GENESIS LADDER & RAIL GEOMETRY (
|
|
10
|
+
* SECTION 1: GENESIS LADDER & RAIL GEOMETRY (29 exports + the GridGenesis type)
|
|
11
11
|
* - GridGenesis - Genesis ladder type: start price, increment, gap slots,
|
|
12
12
|
* price levels and their hash
|
|
13
13
|
* - priceLevelsForGenesis(genesis) - Extract the frozen price ladder from a genesis
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
* - isEvacuationSizeStillValid(...) - Re-proof a stamped evacuation size against live geometry
|
|
37
37
|
* - validateBoundaryCommit(...) - Validate a proposed boundary commit against geometry
|
|
38
38
|
* - validatePersistedBoundary(...) - Validate a boundary restored from disk
|
|
39
|
+
* - boundaryMoveReducesStrands(...) - Whether a boundary move reduces stranded rail slots
|
|
40
|
+
* - pricesWithinHalfStep(a, b, ...) - Same ladder level within half a grid step
|
|
39
41
|
* - isTransientInBandRejection(reason) - Whether a persisted-boundary rejection is transient
|
|
40
42
|
* - BOUNDARY_REJECT_PLACED_IN_BAND - Rejection reason: target slot holds an in-band order
|
|
41
43
|
*
|
|
@@ -51,9 +53,10 @@
|
|
|
51
53
|
* - resolveRelativePrice(value, startPrice, mode) - Resolve relative price values
|
|
52
54
|
* - validateGridPriceBounds(min, max, center) - Reject bounds not bracketing center
|
|
53
55
|
*
|
|
54
|
-
* SECTION 3: FUND CALCULATIONS (
|
|
56
|
+
* SECTION 3: FUND CALCULATIONS (9 functions)
|
|
55
57
|
* - computeChainFundTotals(accountTotals, committedChain) - Compute total funds
|
|
56
58
|
* - calculateAvailableFundsValue(side, accountTotals, funds, ...) - Calculate available funds
|
|
59
|
+
* - deriveChainTruthFundBudget(...) - Side budget derived from chain-truth totals
|
|
57
60
|
* - adjustBudgetForBtsFees(budget, btsFeeData, ...) - Reserve BTS fees from a side budget
|
|
58
61
|
* - getGridBestPrices(manager) - Best (highest) buy and best (lowest) sell price
|
|
59
62
|
* - calculateSpreadFromOrders(activeBuys, activeSells) - Calculate spread percentage
|
|
@@ -89,6 +92,7 @@
|
|
|
89
92
|
* - getAssetFees(assetSymbol, assetAmount, isMaker) - Get fee info for asset
|
|
90
93
|
* - getAssetFeesSafe(assetSymbol, assetAmount, isMaker) - Fee info without throwing
|
|
91
94
|
* - _setFeeCache(cache) - Set internal fee cache (internal)
|
|
95
|
+
* - FeeCacheEntry - Per-asset fee-cache row type consumed by _setFeeCache
|
|
92
96
|
*
|
|
93
97
|
* SECTION 8: FUND ALLOCATION (6 functions)
|
|
94
98
|
* - allocateFundsByWeights(available, targetCount) - Allocate funds by weight
|
|
@@ -1026,6 +1030,7 @@ declare function validateBoundaryCommit(proposedBoundary: number | null | undefi
|
|
|
1026
1030
|
ok: boolean;
|
|
1027
1031
|
reason?: string;
|
|
1028
1032
|
detail?: string;
|
|
1033
|
+
inBandCount?: number;
|
|
1029
1034
|
};
|
|
1030
1035
|
/**
|
|
1031
1036
|
* Validate a boundary restored from PERSISTED state (disk snapshot) before it
|
|
@@ -1061,7 +1066,27 @@ declare function validatePersistedBoundary(proposedBoundary: number | null | und
|
|
|
1061
1066
|
ok: boolean;
|
|
1062
1067
|
reason?: string;
|
|
1063
1068
|
detail?: string;
|
|
1069
|
+
inBandCount?: number;
|
|
1064
1070
|
};
|
|
1071
|
+
/**
|
|
1072
|
+
* Whether moving a boundary from `current` to `candidate` strands FEWER placed
|
|
1073
|
+
* orders (a violation-reducing repair). Strictly fewer — an equal count is not
|
|
1074
|
+
* a repair, and a structural refusal on either side is never a repair.
|
|
1075
|
+
*
|
|
1076
|
+
* This is the one rule behind the fill re-anchor and the rail clamp accepting a
|
|
1077
|
+
* move the strict validator would refuse only for transient stranding; both
|
|
1078
|
+
* bounds stay in force (fill-anchor direction at the caller, strand count here).
|
|
1079
|
+
*
|
|
1080
|
+
* @param currentBoundary - Boundary currently committed
|
|
1081
|
+
* @param candidateBoundary - Proposed boundary
|
|
1082
|
+
* @param orders - Placed-order slots
|
|
1083
|
+
* @param gapSlots - Gap band width
|
|
1084
|
+
* @param options - Optional in-band allow-list (a fill's own partial residual)
|
|
1085
|
+
* @returns True when the candidate strands strictly fewer placed orders
|
|
1086
|
+
*/
|
|
1087
|
+
declare function boundaryMoveReducesStrands(currentBoundary: number | null | undefined, candidateBoundary: number | null | undefined, orders: Iterable<unknown>, gapSlots: number, options?: {
|
|
1088
|
+
allowInBandSlotIds?: Iterable<string>;
|
|
1089
|
+
}): boolean;
|
|
1065
1090
|
/**
|
|
1066
1091
|
* Whether a persisted-boundary rejection is the TRANSIENT kind that must not
|
|
1067
1092
|
* trigger a rebuild: stranding (`placed_order_in_band`) with no accompanying
|
|
@@ -1272,7 +1297,7 @@ declare function derivePriceLevels(startPrice: number, minPrice: number, maxPric
|
|
|
1272
1297
|
declare function pricesWithinHalfStep(priceA: number, priceB: number, incrementPercent: number | null | undefined): boolean;
|
|
1273
1298
|
declare function buildGenesisFromPriceLevels(startPrice: number, incrementPercent: number, gapSlots: number, priceLevels: number[]): GridGenesis;
|
|
1274
1299
|
export type { FeeCacheEntry };
|
|
1275
|
-
export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, deriveChainTruthFundBudget, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, floorToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findCrossedOrder, pricesOnSameLevel, sameGridPrice, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, sameGridLevel, pricesWithinHalfStep, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
|
|
1300
|
+
export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, boundaryMoveReducesStrands, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, deriveChainTruthFundBudget, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, floorToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findCrossedOrder, pricesOnSameLevel, sameGridPrice, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, sameGridLevel, pricesWithinHalfStep, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
|
|
1276
1301
|
/**
|
|
1277
1302
|
* Round a value to a given factor.
|
|
1278
1303
|
* @param {number} value - Value to round
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Pure numeric calculations, blockchain conversions, fee math, and fund allocation.
|
|
5
5
|
*
|
|
6
6
|
* ===============================================================================
|
|
7
|
-
* TABLE OF CONTENTS (
|
|
7
|
+
* TABLE OF CONTENTS (80 exports + the GridGenesis and FeeCacheEntry types)
|
|
8
8
|
* ===============================================================================
|
|
9
9
|
*
|
|
10
|
-
* SECTION 1: GENESIS LADDER & RAIL GEOMETRY (
|
|
10
|
+
* SECTION 1: GENESIS LADDER & RAIL GEOMETRY (29 exports + the GridGenesis type)
|
|
11
11
|
* - GridGenesis - Genesis ladder type: start price, increment, gap slots,
|
|
12
12
|
* price levels and their hash
|
|
13
13
|
* - priceLevelsForGenesis(genesis) - Extract the frozen price ladder from a genesis
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
* - isEvacuationSizeStillValid(...) - Re-proof a stamped evacuation size against live geometry
|
|
37
37
|
* - validateBoundaryCommit(...) - Validate a proposed boundary commit against geometry
|
|
38
38
|
* - validatePersistedBoundary(...) - Validate a boundary restored from disk
|
|
39
|
+
* - boundaryMoveReducesStrands(...) - Whether a boundary move reduces stranded rail slots
|
|
40
|
+
* - pricesWithinHalfStep(a, b, ...) - Same ladder level within half a grid step
|
|
39
41
|
* - isTransientInBandRejection(reason) - Whether a persisted-boundary rejection is transient
|
|
40
42
|
* - BOUNDARY_REJECT_PLACED_IN_BAND - Rejection reason: target slot holds an in-band order
|
|
41
43
|
*
|
|
@@ -51,9 +53,10 @@
|
|
|
51
53
|
* - resolveRelativePrice(value, startPrice, mode) - Resolve relative price values
|
|
52
54
|
* - validateGridPriceBounds(min, max, center) - Reject bounds not bracketing center
|
|
53
55
|
*
|
|
54
|
-
* SECTION 3: FUND CALCULATIONS (
|
|
56
|
+
* SECTION 3: FUND CALCULATIONS (9 functions)
|
|
55
57
|
* - computeChainFundTotals(accountTotals, committedChain) - Compute total funds
|
|
56
58
|
* - calculateAvailableFundsValue(side, accountTotals, funds, ...) - Calculate available funds
|
|
59
|
+
* - deriveChainTruthFundBudget(...) - Side budget derived from chain-truth totals
|
|
57
60
|
* - adjustBudgetForBtsFees(budget, btsFeeData, ...) - Reserve BTS fees from a side budget
|
|
58
61
|
* - getGridBestPrices(manager) - Best (highest) buy and best (lowest) sell price
|
|
59
62
|
* - calculateSpreadFromOrders(activeBuys, activeSells) - Calculate spread percentage
|
|
@@ -89,6 +92,7 @@
|
|
|
89
92
|
* - getAssetFees(assetSymbol, assetAmount, isMaker) - Get fee info for asset
|
|
90
93
|
* - getAssetFeesSafe(assetSymbol, assetAmount, isMaker) - Fee info without throwing
|
|
91
94
|
* - _setFeeCache(cache) - Set internal fee cache (internal)
|
|
95
|
+
* - FeeCacheEntry - Per-asset fee-cache row type consumed by _setFeeCache
|
|
92
96
|
*
|
|
93
97
|
* SECTION 8: FUND ALLOCATION (6 functions)
|
|
94
98
|
* - allocateFundsByWeights(available, targetCount) - Allocate funds by weight
|
|
@@ -1686,6 +1690,7 @@ function validateBoundaryCommit(proposedBoundary, orders, gapSlots, options = {}
|
|
|
1686
1690
|
return {
|
|
1687
1691
|
ok: false,
|
|
1688
1692
|
reason: BOUNDARY_REJECT_PLACED_IN_BAND,
|
|
1693
|
+
inBandCount,
|
|
1689
1694
|
detail: `boundary=${raw} gapSlots=${gapSlots} placed count=${inBandCount} first idx=${firstInBandIdx} price=${firstInBandPrice} ` +
|
|
1690
1695
|
`sits strictly inside implied band (${raw}, ${sellStart})`
|
|
1691
1696
|
};
|
|
@@ -1726,6 +1731,58 @@ function validatePersistedBoundary(proposedBoundary, orders, gapSlots, options =
|
|
|
1726
1731
|
...(options.allowInBandSlotIds ? { allowInBandSlotIds: options.allowInBandSlotIds } : {})
|
|
1727
1732
|
});
|
|
1728
1733
|
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Count the placed orders a boundary would strand inside its implied band.
|
|
1736
|
+
*
|
|
1737
|
+
* Returns 0 for a clean boundary, the validator's own count for a pure
|
|
1738
|
+
* stranding rejection, and null for a STRUCTURAL refusal (crossed book, ceiling,
|
|
1739
|
+
* range, non-integer) — the two are not comparable, so callers must not treat a
|
|
1740
|
+
* structural refusal as "zero strands". Uses the same validator (and the same
|
|
1741
|
+
* allow-list) as the commit/restore paths: no second stranding predicate.
|
|
1742
|
+
*
|
|
1743
|
+
* @param proposedBoundary - Boundary to judge
|
|
1744
|
+
* @param orders - Placed-order slots
|
|
1745
|
+
* @param gapSlots - Gap band width
|
|
1746
|
+
* @param options - Optional in-band allow-list (a fill's own partial residual)
|
|
1747
|
+
* @returns Strand count, or null when the refusal is structural
|
|
1748
|
+
*/
|
|
1749
|
+
function countInBandPlacements(proposedBoundary, orders, gapSlots, options = {}) {
|
|
1750
|
+
const check = validateBoundaryCommit(proposedBoundary, orders, gapSlots, {
|
|
1751
|
+
rejectInBandPlacements: true,
|
|
1752
|
+
...(options.allowInBandSlotIds ? { allowInBandSlotIds: options.allowInBandSlotIds } : {})
|
|
1753
|
+
});
|
|
1754
|
+
if (check.ok)
|
|
1755
|
+
return 0;
|
|
1756
|
+
if (check.reason === BOUNDARY_REJECT_PLACED_IN_BAND) {
|
|
1757
|
+
// Unknown is NOT zero: a validator that cannot report the count must not
|
|
1758
|
+
// read as "strands nothing" (the Number(null)===0 trap this stack keeps
|
|
1759
|
+
// guarding). Fail closed instead.
|
|
1760
|
+
const count = Number(check.inBandCount);
|
|
1761
|
+
return Number.isFinite(count) ? count : null;
|
|
1762
|
+
}
|
|
1763
|
+
return null;
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Whether moving a boundary from `current` to `candidate` strands FEWER placed
|
|
1767
|
+
* orders (a violation-reducing repair). Strictly fewer — an equal count is not
|
|
1768
|
+
* a repair, and a structural refusal on either side is never a repair.
|
|
1769
|
+
*
|
|
1770
|
+
* This is the one rule behind the fill re-anchor and the rail clamp accepting a
|
|
1771
|
+
* move the strict validator would refuse only for transient stranding; both
|
|
1772
|
+
* bounds stay in force (fill-anchor direction at the caller, strand count here).
|
|
1773
|
+
*
|
|
1774
|
+
* @param currentBoundary - Boundary currently committed
|
|
1775
|
+
* @param candidateBoundary - Proposed boundary
|
|
1776
|
+
* @param orders - Placed-order slots
|
|
1777
|
+
* @param gapSlots - Gap band width
|
|
1778
|
+
* @param options - Optional in-band allow-list (a fill's own partial residual)
|
|
1779
|
+
* @returns True when the candidate strands strictly fewer placed orders
|
|
1780
|
+
*/
|
|
1781
|
+
function boundaryMoveReducesStrands(currentBoundary, candidateBoundary, orders, gapSlots, options = {}) {
|
|
1782
|
+
const current = countInBandPlacements(currentBoundary, orders, gapSlots, options);
|
|
1783
|
+
const candidate = countInBandPlacements(candidateBoundary, orders, gapSlots, options);
|
|
1784
|
+
return current !== null && candidate !== null && candidate < current;
|
|
1785
|
+
}
|
|
1729
1786
|
/**
|
|
1730
1787
|
* Whether a persisted-boundary rejection is the TRANSIENT kind that must not
|
|
1731
1788
|
* trigger a rebuild: stranding (`placed_order_in_band`) with no accompanying
|
|
@@ -2188,7 +2245,7 @@ function buildGenesisFromPriceLevels(startPrice, incrementPercent, gapSlots, pri
|
|
|
2188
2245
|
createdAt: Date.now()
|
|
2189
2246
|
};
|
|
2190
2247
|
}
|
|
2191
|
-
export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, deriveChainTruthFundBudget, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, floorToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findCrossedOrder, pricesOnSameLevel, sameGridPrice, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, sameGridLevel, pricesWithinHalfStep, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
|
|
2248
|
+
export { getBtsSide, getSellStartIdx, resolveGapBand, countGapBandSpread, calculateGapSlots, isSlotInRail, isSlotIndexInGapBand, isEvacuationRotationAllowed, isEvacuationSizeStillValid, validateBoundaryCommit, validatePersistedBoundary, boundaryMoveReducesStrands, isTransientInBandRejection, BOUNDARY_REJECT_PLACED_IN_BAND, resolveGapSlots, isPercentageString, isPositiveNumber, isPositiveNumberOrPercent, isPositiveInt, parsePercentageString, toDecimal, resolveRelativePrice, parseRelativeMultiplier, validateGridPriceBounds, isExplicitZeroAllocation, getPrecision, computeChainFundTotals, calculateAvailableFundsValue, deriveChainTruthFundBudget, adjustBudgetForBtsFees, getGridBestPrices, calculateSpreadFromOrders, resolveConfigValue, resolveConfigValueWithRegistry, hasValidAccountTotals, blockchainToFloat, floatToBlockchainInt, floorToBlockchainInt, quantizeFloat, normalizeInt, getPrecisionByOrderType, getPrecisionsForManager, getPrecisionSlack, quantumForPrecision, calculatePriceTolerance, findCrossedOrder, pricesOnSameLevel, sameGridPrice, validateOrderAmountsWithinLimits, getMinOrderSize, getDustThresholdFactor, getSingleDustThreshold, getDoubleDustThreshold, validateOrderSize, getAssetFees, getAssetFeesSafe, allocateFundsByWeights, calculateOrderSizes, calculateRotationOrderSizes, calculateGridSideDivergenceMetric, calculateOrderCreationFees, calculateSwapInAmount, _setFeeCache, cloneWeightDistribution, clamp, roundTo, fixedTo, roundToDecimals, priceLevelsForGenesis, priceForSlot, slotIndexForPrice, slotIdForPrice, assertSlotPriceInvariant, priceSlotEqual, derivePriceLevels, sameGridLevel, pricesWithinHalfStep, buildGenesisFromPriceLevels, hashPriceLevels, isChainPriceOutOfGrid };
|
|
2192
2249
|
/**
|
|
2193
2250
|
* Round a value to a given factor.
|
|
2194
2251
|
* @param {number} value - Value to round
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Includes grid indexing, order comparison, delta building, and strategy calculations.
|
|
6
6
|
*
|
|
7
7
|
* ===============================================================================
|
|
8
|
-
* TABLE OF CONTENTS (
|
|
8
|
+
* TABLE OF CONTENTS (82 exported functions)
|
|
9
9
|
* ===============================================================================
|
|
10
10
|
*
|
|
11
|
-
* SECTION 1: CHAIN ORDER MATCHING & RECONCILIATION (
|
|
11
|
+
* SECTION 1: CHAIN ORDER MATCHING & RECONCILIATION (11 functions)
|
|
12
12
|
* - parseChainOrder(chainOrder, assets) - Parse blockchain order to grid format
|
|
13
13
|
* - applyChainSizeToGridOrder(manager, gridOrder, chainSize) - Apply chain size to grid
|
|
14
14
|
* - correctOrderPriceOnChain(manager, correctionInfo, ...) - Correct order price on chain
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* - _validatePriceCorrectionEntry(...) - Drain-time staleness check for a queued correction
|
|
17
17
|
* - _stampCorrectionProvenance(...) - Stamp queue provenance on a correction entry
|
|
18
18
|
* - findLiveOrderOwnerByChainId(...) - Find the live grid slot that owns a chain order
|
|
19
|
+
* - resolveLiveOrderLadderPosition(...) - Ladder position of a live chain order
|
|
20
|
+
* - resolveExecutionPrice(...) - Execution price from the paid/received amounts
|
|
21
|
+
* - resolveSlotIdForFillPrice(...) - Slot a fill price belongs to under the genesis ladder
|
|
22
|
+
* - attributeUnmatchedFillToGrid(...) - Attribute a fill whose slot was already virtualised
|
|
19
23
|
*
|
|
20
24
|
* SECTION 2: CROSSING-PLACEMENT GUARDS (8 functions)
|
|
21
25
|
* - chainOrderMatchesSlot(...) - Exact chain-order/grid-slot match
|
|
@@ -31,11 +35,12 @@
|
|
|
31
35
|
* - buildCreateOrderArgs(order, assetA, assetB) - Build create order arguments
|
|
32
36
|
* - getOrderTypeFromUpdatedFlags(buyUpdated, sellUpdated) - Get type from update flags
|
|
33
37
|
* - resolveConfiguredPriceBound(value, fallback, startPrice, mode) - Resolve price bounds
|
|
34
|
-
* - buildFillKey(fillOrParts) -
|
|
38
|
+
* - buildFillKey(fillOrParts) - Stable fill dedupe key (delegates to order/fill_ledger.ts)
|
|
35
39
|
* - buildCreateOpFingerprint(params) - Build fingerprint for create operations
|
|
36
40
|
*
|
|
37
|
-
* SECTION 4: STATE TRANSITIONS & PLACEHOLDERS (
|
|
41
|
+
* SECTION 4: STATE TRANSITIONS & PLACEHOLDERS (7 functions)
|
|
38
42
|
* - virtualizeOrder(order) - Convert order to VIRTUAL state
|
|
43
|
+
* - reviveVirtualSlotFromChain(...) - Re-materialise a virtualised slot from its chain order
|
|
39
44
|
* - convertToSpreadPlaceholder(order) - Convert order to SPREAD placeholder
|
|
40
45
|
* - toRailHolePlaceholder(order) - Convert to a rail-typed hole placeholder
|
|
41
46
|
* - geometryTypeForSlotIndex(...) - BUY/SELL type for a slot index
|
|
@@ -47,8 +52,9 @@
|
|
|
47
52
|
* - updateGapEvacuationStreaks(...) - Tick per-slot gap-evacuation streak counter
|
|
48
53
|
* - collectRefillSlotIds(...) - Refill-slot wire for the COW boundary hold
|
|
49
54
|
*
|
|
50
|
-
* SECTION 6: FILTERING & DRIFT DIAGNOSTICS (
|
|
55
|
+
* SECTION 6: FILTERING & DRIFT DIAGNOSTICS (12 functions)
|
|
51
56
|
* - filterOrdersByType(orders, orderType) - Filter orders by type
|
|
57
|
+
* - isStructuralRebuildStaleReason(reason) - Whether a refusal label means a structural rebuild
|
|
52
58
|
* - buildOutsideInPairGroups(items, accessors) - Outside->center pair grouping
|
|
53
59
|
* - extractBatchOperationResults(result) - Extract operation_results from chain batch result
|
|
54
60
|
* - formatUnmatchedChainOrder(order) - Format structural drift diagnostics
|
|
@@ -106,13 +112,19 @@
|
|
|
106
112
|
* - checkGridPriceInvariant(...) - The price emitted for a slot must equal its genesis price
|
|
107
113
|
* - reportGridPriceInvariant(...) - Report one GRID-PRICE-INVARIANT check
|
|
108
114
|
*
|
|
109
|
-
* SECTION 14: PERSISTED CRAWL & PLACEMENT GRACE (
|
|
115
|
+
* SECTION 14: PERSISTED CRAWL & PLACEMENT GRACE (2 functions + the CrawlEntry type)
|
|
110
116
|
* - consumePendingFillCrawls(...) - Apply recorded-but-uncommitted fill crawls to the boundary
|
|
111
|
-
* - recordOrderPlacement(...) - Record a fresh on-chain placement timestamp
|
|
112
117
|
* - isFreshlyPlacedOrder(...) - Chain order placed within the surplus-cancel grace
|
|
118
|
+
* (the stamp itself is written only by the lifecycle funnel)
|
|
119
|
+
*
|
|
120
|
+
* SECTION 15: LIVE BROADCAST & EDGE PROJECTIONS (2 functions)
|
|
121
|
+
* - getLivePendingBroadcasts(manager, options?) - Live pending-broadcast list (expired entries deleted)
|
|
122
|
+
* - collectEdgePinnedFillIds(manager, fills) - Fill ids pinned to the configured/live edge
|
|
113
123
|
*
|
|
114
124
|
* ===============================================================================
|
|
115
125
|
*/
|
|
126
|
+
import { fillKeyOf } from '../fill_ledger.js';
|
|
127
|
+
import type { PlacementLease } from '../placement_lock.js';
|
|
116
128
|
import type { OrderManagerLike, PendingPriceCorrection, ChainOrder, ParsedChainOrder, AssetPair, AssetInfo, OrderType, ManagedOrder, UnmatchedChainOrder, CowAction, ProjectedFunds } from '../../types.js';
|
|
117
129
|
import type { GridGenesis } from './math.js';
|
|
118
130
|
interface CorrectionAccountOrdersLike {
|
|
@@ -142,6 +154,24 @@ interface CorrectionAccountOrdersLike {
|
|
|
142
154
|
* @returns {boolean} True if the message indicates the order is gone.
|
|
143
155
|
*/
|
|
144
156
|
declare function isOrderGoneErrorMessage(message: string | null | undefined, orderId?: string | null): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Classify a working-grid staleness reason as a STRUCTURAL rebuild.
|
|
159
|
+
*
|
|
160
|
+
* `_syncWorkingGridFromMasterMutation` stamps reasons such as
|
|
161
|
+
* `master mutation during broadcasting (grid-init)` (a full grid rebuild) or
|
|
162
|
+
* `(fill-place)` (a fill landing during the plan). The two are NOT
|
|
163
|
+
* interchangeable: after a rebuild the fresh master no longer carries the live
|
|
164
|
+
* chain order IDs, so re-planning from it emits CREATEs for price levels the
|
|
165
|
+
* startup reconcile is concurrently re-pricing via UPDATE — both generations
|
|
166
|
+
* land and the loser becomes a duplicate-price orphan backlog.
|
|
167
|
+
*
|
|
168
|
+
* Single source of truth for every planner/guard that must treat a rebuild
|
|
169
|
+
* differently from a fill. Keep the pattern anchored to the context tokens
|
|
170
|
+
* emitted by manager._syncWorkingGridFromMasterMutation / structural paths.
|
|
171
|
+
* @param {unknown} reason - evaluateCommit refusal reason or staleness label.
|
|
172
|
+
* @returns {boolean} True when the master was structurally rebuilt.
|
|
173
|
+
*/
|
|
174
|
+
declare function isStructuralRebuildStaleReason(reason: unknown): boolean;
|
|
145
175
|
/**
|
|
146
176
|
* Record a duplicate-orphan detection for an orderId.
|
|
147
177
|
* First sighting stays quiet (count 1). A repeated sighting of the same
|
|
@@ -171,14 +201,6 @@ declare function duplicateOrphanLogInfo(orderId: string | null | undefined): {
|
|
|
171
201
|
suffix: string;
|
|
172
202
|
};
|
|
173
203
|
declare function _filterUnmatchedChainOrders(manager: OrderManagerLike, chainOrderId: string): void;
|
|
174
|
-
/**
|
|
175
|
-
* Record a fresh on-chain placement timestamp for surplus-cancel grace.
|
|
176
|
-
* Called when a slot gains a chain orderId it did not have before (create,
|
|
177
|
-
* adopt, rotation target). Powers isFreshlyPlacedOrder below.
|
|
178
|
-
* @param {unknown} manager - OrderManager instance (owns `_placedAt`)
|
|
179
|
-
* @param {string} chainOrderId - Chain order id that was just placed
|
|
180
|
-
*/
|
|
181
|
-
declare function recordOrderPlacement(manager: OrderManagerLike, chainOrderId: string | null | undefined): void;
|
|
182
204
|
/**
|
|
183
205
|
* True when the chain order was placed within the surplus-cancel grace
|
|
184
206
|
* window. Surplus sweeps must skip such orders: a fill landing between two
|
|
@@ -340,11 +362,17 @@ declare function findLiveOrderOwnerByChainId(manager: OrderManagerLike, chainOrd
|
|
|
340
362
|
* replayed cancel would then destroy the freshly updated in-place order.
|
|
341
363
|
*
|
|
342
364
|
* Type-mismatch and gap-evacuation surplus decisions have their own source-
|
|
343
|
-
* specific checks. A type mismatch is actionable
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
365
|
+
* specific checks. A type mismatch is actionable while the same live slot
|
|
366
|
+
* still owns the id AND (its stored type OR its rail geometry — index vs
|
|
367
|
+
* boundary, including the gap band) still disagrees with the chain side. A
|
|
368
|
+
* stored type that a fill (or another in-place writer) retagged to the chain
|
|
369
|
+
* side is NOT a repair on its own: an order can carry the chain's side while
|
|
370
|
+
* sitting on the opposite rail or inside the band, and dropping the cancel
|
|
371
|
+
* there would let the residual rest on the wrong side (2026-11-04 incident).
|
|
372
|
+
* A gap evacuation is actionable only while the same live slot remains in the
|
|
373
|
+
* current gap band. Both otherwise use the old cancellation branch, so
|
|
374
|
+
* allowing either decision to replay would recreate the same stale-replay
|
|
375
|
+
* regression.
|
|
348
376
|
*
|
|
349
377
|
* @param {Object} manager - OrderManager instance (live grid + assets)
|
|
350
378
|
* @param {Object} entry - Queued correction entry
|
|
@@ -378,22 +406,18 @@ declare function parseChainOrder(chainOrder: ChainOrder | null | undefined, asse
|
|
|
378
406
|
*/
|
|
379
407
|
declare function applyChainSizeToGridOrder(manager: OrderManagerLike, gridOrder: ManagedOrder, chainSize: number | string | null | undefined): Promise<ManagedOrder | null>;
|
|
380
408
|
/**
|
|
381
|
-
* Build a stable fill dedupe key
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
409
|
+
* Build a stable fill dedupe key: `orderId:blockNum:historyId`.
|
|
410
|
+
*
|
|
411
|
+
* Delegates to `order/fill_ledger.ts` — the single owner of fill identity.
|
|
412
|
+
* Kept exported under this name because `dexbot_fill_runtime` resolves it
|
|
413
|
+
* through a lazy shim and the orphan path reuses it. Returns null when a
|
|
414
|
+
* required field is missing: callers skip dedup rather than operate on a
|
|
415
|
+
* degraded key.
|
|
385
416
|
*
|
|
386
417
|
* @param {Object} fillOrParts - Fill entry ({ op, block_num, id }) or { orderId, blockNum, historyId }
|
|
387
|
-
* @returns {string|null} Stable key
|
|
418
|
+
* @returns {string|null} Stable key, or null if fields are missing
|
|
388
419
|
*/
|
|
389
|
-
declare
|
|
390
|
-
op?: unknown[];
|
|
391
|
-
orderId?: string;
|
|
392
|
-
block_num?: number;
|
|
393
|
-
blockNum?: number;
|
|
394
|
-
id?: string;
|
|
395
|
-
historyId?: string;
|
|
396
|
-
} | null | undefined): string | null;
|
|
420
|
+
declare const buildFillKey: typeof fillKeyOf;
|
|
397
421
|
/**
|
|
398
422
|
* Correct a single order's price on blockchain.
|
|
399
423
|
* Cancels surplus orders; updates price for others.
|
|
@@ -449,13 +473,23 @@ declare function correctOrderPriceOnChain(manager: OrderManagerLike, correctionI
|
|
|
449
473
|
* Cancel-type corrections (duplicate orphans, surplus) are batched into
|
|
450
474
|
* chunked multi-op transactions; price updates run sequentially.
|
|
451
475
|
*
|
|
476
|
+
* Runs inside the exclusive placement region: every correction broadcasts a
|
|
477
|
+
* chain mutation, so it must never interleave with a COW batch, startup
|
|
478
|
+
* reconcile Phase 2 or a dust/residual cancel. A caller already holding the
|
|
479
|
+
* region (COW pre-batch drain) passes its lease so the nested call does not
|
|
480
|
+
* deadlock.
|
|
481
|
+
*
|
|
452
482
|
* @param {Object} manager - OrderManager instance
|
|
453
483
|
* @param {string} accountName - Account name for blockchain transactions
|
|
454
484
|
* @param {string} privateKey - Private key for signing
|
|
455
485
|
* @param {Object} accountOrders - AccountOrders accessor for blockchain ops
|
|
486
|
+
* @param {Object} [options] - placementLease (reuse) + timeoutMs (bounded wait)
|
|
456
487
|
* @returns {Promise<Object>} Summary {corrected, failed, results}
|
|
457
488
|
*/
|
|
458
|
-
declare function correctAllPriceMismatches(manager: OrderManagerLike, accountName: string, privateKey: string, accountOrders: CorrectionAccountOrdersLike
|
|
489
|
+
declare function correctAllPriceMismatches(manager: OrderManagerLike, accountName: string, privateKey: string, accountOrders: CorrectionAccountOrdersLike, options?: {
|
|
490
|
+
placementLease?: PlacementLease | null;
|
|
491
|
+
timeoutMs?: number;
|
|
492
|
+
}): Promise<{
|
|
459
493
|
corrected: number;
|
|
460
494
|
failed: number;
|
|
461
495
|
results: (PendingPriceCorrection & {
|
|
@@ -673,9 +707,16 @@ declare function detectGapEvacuationCandidates(masterGrid: Map<string, ManagedOr
|
|
|
673
707
|
* @param {Map} streakMap - Mutable Map slotId -> consecutive-cycle count
|
|
674
708
|
* @param {Array} candidates - detectGapEvacuationCandidates output
|
|
675
709
|
* @param {number} [threshold] - GRID_LIMITS.GAP_EVACUATION_STREAK_THRESHOLD default
|
|
710
|
+
* @param {Object} [options] - `increment: false` re-derives the ledger (prune
|
|
711
|
+
* resolved ids + report readiness) WITHOUT counting a new observation. The
|
|
712
|
+
* committed-geometry sweep uses it because the plan ticks the same ledger in
|
|
713
|
+
* the same cycle; counting twice would arm the cancel-only teeth in the very
|
|
714
|
+
* cycle whose rotation is about to evacuate the order.
|
|
676
715
|
* @returns {{streaks: Object, ready: Array}}
|
|
677
716
|
*/
|
|
678
|
-
declare function updateGapEvacuationStreaks(streakMap: Map<string, number>, candidates: unknown, threshold?: number | null
|
|
717
|
+
declare function updateGapEvacuationStreaks(streakMap: Map<string, number>, candidates: unknown, threshold?: number | null, options?: {
|
|
718
|
+
increment?: boolean;
|
|
719
|
+
}): {
|
|
679
720
|
streaks: Record<string, number>;
|
|
680
721
|
ready: Array<{
|
|
681
722
|
id: string;
|
|
@@ -752,6 +793,34 @@ declare function crossingCandidateChainId(o: CrossingCandidate | null | undefine
|
|
|
752
793
|
* @returns {boolean} True when the candidate participates in crossing checks
|
|
753
794
|
*/
|
|
754
795
|
declare function isCrossingCheckCandidate(o: CrossingCandidate | null | undefined, excludeChainOrderId?: string | null, cancelOpIndexByOrderId?: Map<string, unknown> | null): boolean;
|
|
796
|
+
/**
|
|
797
|
+
* LIVE (unexpired) pending-broadcast entries — the SINGLE liveness authority.
|
|
798
|
+
*
|
|
799
|
+
* A pending entry protects a slot/price whose uncertain CREATE may already be
|
|
800
|
+
* live on chain but is not adopted yet. Three readers need that set (the COW
|
|
801
|
+
* pre-broadcast guard, the reconcile CREATE path, and the reconcile surplus
|
|
802
|
+
* sweep) and they used to disagree: two re-implemented the TTL by hand with
|
|
803
|
+
* different rules and one read the raw map with no TTL at all, so a reconcile
|
|
804
|
+
* could stay blocked by an entry the COW guard already considered dead.
|
|
805
|
+
*
|
|
806
|
+
* Liveness rule (unchanged from the COW guard, now the only one):
|
|
807
|
+
* - younger than `PENDING_BROADCAST_TTL_MS` → live;
|
|
808
|
+
* - older than the TTL but a successful open-orders sync completed AFTER it was
|
|
809
|
+
* recorded → expired (a caught-up read re-verifies the level);
|
|
810
|
+
* - older than 2× the TTL → expired regardless (a permanently lagging node must
|
|
811
|
+
* not park CREATEs forever);
|
|
812
|
+
* - no usable `recordedAt` → live (fail closed, never a silent unblock).
|
|
813
|
+
*
|
|
814
|
+
* Expired entries are DELETED here; callers get the live list.
|
|
815
|
+
*
|
|
816
|
+
* @param {Object} manager - OrderManager (`_pendingBroadcasts`, `_lastSyncAt`)
|
|
817
|
+
* @param {Object} [options] - `now` clock override (tests)
|
|
818
|
+
* @returns {Array} Live pending-broadcast entries
|
|
819
|
+
*/
|
|
820
|
+
declare function getLivePendingBroadcasts(manager: OrderManagerLike | null | undefined, options?: {
|
|
821
|
+
now?: number;
|
|
822
|
+
gc?: boolean;
|
|
823
|
+
}): unknown[];
|
|
755
824
|
/**
|
|
756
825
|
* Shared candidate set for crossing-placement checks: master orders plus
|
|
757
826
|
* chain-side orders that may exist on chain but are not (yet) adopted into
|
|
@@ -1561,7 +1630,7 @@ declare function collectKnownOnChainOrderIds(mgr: OrderManagerLike, placedResult
|
|
|
1561
1630
|
createIds: string[];
|
|
1562
1631
|
all: string[];
|
|
1563
1632
|
};
|
|
1564
|
-
export { parseChainOrder, resolveLiveOrderLadderPosition, applyChainSizeToGridOrder, resolveExecutionPrice, resolveSlotIdForFillPrice, reviveVirtualSlotFromChain, attributeUnmatchedFillToGrid, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, _validatePriceCorrectionEntry, _stampCorrectionProvenance, findLiveOrderOwnerByChainId, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, toRailHolePlaceholder, geometryTypeForSlotIndex, detectGapEvacuationCandidates, updateGapEvacuationStreaks, resolveSpreadOrderSide, chainOrderMatchesSlot, chainOrderMatchesSlotWithTolerance, crossingCandidateChainId, isCrossingCheckCandidate, buildCrossingCheckCandidates, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isNonBlockingUnmatchedOrder, isStrandedHoldOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, deriveTargetBoundary, isShiftEligibleFill, resolveEdgeCount, resolveEdgeOrders, selectEdgeSlots, getCoreOrdersTotal, getSideBudget, calculateBudgetedSizes, buildCreateOpFingerprint, isOrderGoneErrorMessage, recordDuplicateOrphanDetection, clearDuplicateOrphanDetection, duplicateOrphanLogInfo, chainOrderUnchangedFromCache, detectCrossedBookPlan, collectKnownOnChainOrderIds, collectEdgePinnedFillIds, edgeOrderIdSet, liveWindowIdSet, checkGridPriceInvariant, reportGridPriceInvariant };
|
|
1633
|
+
export { parseChainOrder, resolveLiveOrderLadderPosition, applyChainSizeToGridOrder, resolveExecutionPrice, resolveSlotIdForFillPrice, reviveVirtualSlotFromChain, attributeUnmatchedFillToGrid, getLivePendingBroadcasts, buildFillKey, correctOrderPriceOnChain, correctAllPriceMismatches, _validatePriceCorrectionEntry, _stampCorrectionProvenance, findLiveOrderOwnerByChainId, buildCreateOrderArgs, getOrderTypeFromUpdatedFlags, resolveConfiguredPriceBound, virtualizeOrder, convertToSpreadPlaceholder, toRailHolePlaceholder, geometryTypeForSlotIndex, detectGapEvacuationCandidates, updateGapEvacuationStreaks, resolveSpreadOrderSide, chainOrderMatchesSlot, chainOrderMatchesSlotWithTolerance, crossingCandidateChainId, isCrossingCheckCandidate, buildCrossingCheckCandidates, filterOrdersByType, buildOutsideInPairGroups, extractBatchOperationResults, formatUnmatchedChainOrder, isNonBlockingUnmatchedOrder, isStrandedHoldOrder, isOrderOnChain, isOrderVirtual, hasOnChainId, isOrderPlaced, isPhantomOrder, isSlotAvailable, isEmptyGridSlot, isOrderHealthy, checkSizeThreshold, checkSizesBeforeMinimum, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, shouldFlagOutOfSpread, buildIndexes, validateIndexes, ordersEqual, buildDelta, deriveTargetBoundary, isShiftEligibleFill, resolveEdgeCount, resolveEdgeOrders, selectEdgeSlots, getCoreOrdersTotal, getSideBudget, calculateBudgetedSizes, buildCreateOpFingerprint, isOrderGoneErrorMessage, isStructuralRebuildStaleReason, recordDuplicateOrphanDetection, clearDuplicateOrphanDetection, duplicateOrphanLogInfo, chainOrderUnchangedFromCache, detectCrossedBookPlan, collectKnownOnChainOrderIds, collectEdgePinnedFillIds, edgeOrderIdSet, liveWindowIdSet, checkGridPriceInvariant, reportGridPriceInvariant };
|
|
1565
1634
|
export type { CrawlEntry };
|
|
1566
|
-
export { resolveEdgeAnchorPrice, resolveLiveEdgeAnchorPrice, compareEdge, collectRefillSlotIds,
|
|
1635
|
+
export { resolveEdgeAnchorPrice, resolveLiveEdgeAnchorPrice, compareEdge, collectRefillSlotIds, isFreshlyPlacedOrder, _filterUnmatchedChainOrders };
|
|
1567
1636
|
//# sourceMappingURL=order.d.ts.map
|