dexbot 1.6.13 → 1.6.14
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 +32 -0
- package/README.md +2 -2
- package/claw/docs/AI_BOT_LIBRARY_API.md +1 -1
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -4
- package/claw/modules/claw_catalog.ts +8 -4
- package/claw/modules/dexbot_profiles.ts +59 -15
- package/claw/modules/types.ts +2 -1
- 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/claw/skills/margin-trading/SKILL.md +1 -1
- package/claw/skills/margin-trading/references/position-management.md +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +25 -25
- package/dist/modules/account_bots.d.ts +7 -6
- package/dist/modules/account_bots.js +10 -10
- package/dist/modules/account_orders.d.ts +36 -4
- package/dist/modules/account_orders.js +76 -5
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +1 -2
- package/dist/modules/bitshares-native/crypto/ecc_core.js +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +1 -2
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -2
- package/dist/modules/bot_defaults.d.ts +16 -2
- package/dist/modules/bot_defaults.js +34 -8
- package/dist/modules/bot_settings.d.ts +4 -0
- package/dist/modules/bot_settings.js +55 -21
- package/dist/modules/config.js +6 -1
- package/dist/modules/constants.d.ts +7 -5
- package/dist/modules/constants.js +12 -5
- package/dist/modules/dexbot_class.d.ts +5 -0
- package/dist/modules/dexbot_class.js +8 -3
- package/dist/modules/dexbot_cow_runtime.d.ts +62 -174
- package/dist/modules/dexbot_cow_runtime.js +331 -46
- package/dist/modules/dexbot_credential_client.d.ts +1 -16
- package/dist/modules/dexbot_credential_client.js +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +1 -1
- package/dist/modules/dexbot_fill_runtime.js +12 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +18 -80
- package/dist/modules/dexbot_maintenance_runtime.js +57 -68
- package/dist/modules/dexbot_startup_runtime.js +12 -0
- package/dist/modules/dexbot_state_recovery.js +16 -0
- package/dist/modules/key_store.d.ts +0 -5
- package/dist/modules/key_store.js +1 -1
- package/dist/modules/order/accounting.js +11 -11
- package/dist/modules/order/export.js +2 -2
- package/dist/modules/order/format.d.ts +15 -1
- package/dist/modules/order/format.js +19 -1
- package/dist/modules/order/genesis_policy.d.ts +1 -1
- package/dist/modules/order/genesis_policy.js +1 -1
- package/dist/modules/order/grid.d.ts +23 -11
- package/dist/modules/order/grid.js +383 -51
- package/dist/modules/order/grid_reconcile.d.ts +1 -1
- package/dist/modules/order/grid_reconcile.js +5 -5
- package/dist/modules/order/grid_reconcile_internal.js +48 -40
- package/dist/modules/order/index.d.ts +34 -8
- package/dist/modules/order/logger.js +2 -2
- package/dist/modules/order/manager.d.ts +9 -2
- package/dist/modules/order/manager.js +58 -24
- package/dist/modules/order/strategy.d.ts +2 -2
- package/dist/modules/order/strategy.js +51 -21
- package/dist/modules/order/sync_engine.js +4 -0
- package/dist/modules/order/utils/math.d.ts +3 -3
- package/dist/modules/order/utils/math.js +38 -27
- package/dist/modules/order/utils/order.d.ts +58 -58
- package/dist/modules/order/utils/order.js +119 -102
- package/dist/modules/order/utils/system.d.ts +193 -6
- package/dist/modules/order/utils/system.js +392 -29
- package/dist/modules/order/utils/validate.js +26 -4
- package/dist/modules/runtime_settings.d.ts +1 -1
- package/dist/modules/runtime_settings.js +3 -3
- package/dist/modules/types.d.ts +48 -4
- package/dist/scripts/analyze-orders.d.ts +1 -1
- package/dist/scripts/analyze-orders.js +4 -4
- package/dist/scripts/divergence-calc.js +6 -6
- package/dist/scripts/validate_bots.d.ts +1 -1
- package/dist/scripts/validate_bots.js +3 -3
- package/dist/unlock.js +7 -2
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -2
- package/docs/COW_INVARIANTS.md +6 -6
- package/docs/DEXBOT_COMPARISON.md +5 -5
- package/docs/EVOLUTION.md +8 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +8 -6
- package/docs/GRID_PRICE_INVARIANT.md +3 -3
- package/docs/GRID_RECALCULATION.md +4 -1
- package/docs/GRID_RECONCILE.md +4 -4
- package/docs/LIFECYCLE.md +11 -11
- package/docs/LOGGING.md +14 -0
- package/docs/MPA_CREDIT_USAGE.md +1 -1
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +12 -4
- package/docs/README.md +3 -3
- package/docs/architecture.md +6 -6
- package/docs/developer_guide.md +7 -2
- package/package.json +1 -1
- package/tests/README.md +1 -1
|
@@ -258,6 +258,24 @@ function positiveOrNull(value) {
|
|
|
258
258
|
const num = Number(value);
|
|
259
259
|
return Number.isFinite(num) && num > 0 ? num : null;
|
|
260
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Convert a value to a finite number but treat an explicitly absent value
|
|
263
|
+
* (`null`/`undefined`/`''`) as unknown (`NaN`) instead of `0`.
|
|
264
|
+
*
|
|
265
|
+
* `Number(null) === 0` and `Number('') === 0` are finite, so a plain `Number()`
|
|
266
|
+
* coercion reads "no value" as the valid value 0 — the trap that made an
|
|
267
|
+
* unknown boundary read as slot 0, an unknown gap width collapse the band, and
|
|
268
|
+
* an unknown fill timestamp read as epoch. Use this for any geometry/index/
|
|
269
|
+
* count field where 0 is legitimate and absence must stay detectable.
|
|
270
|
+
*
|
|
271
|
+
* A genuine `0` (number, `'0'`, `false`) still converts to `0`. Pair with
|
|
272
|
+
* `Number.isFinite` at the call site where absent must fail closed.
|
|
273
|
+
*/
|
|
274
|
+
function toKnownNumber(value) {
|
|
275
|
+
if (value === null || value === undefined || value === '')
|
|
276
|
+
return NaN;
|
|
277
|
+
return Number(value);
|
|
278
|
+
}
|
|
261
279
|
/**
|
|
262
280
|
* Safely format a numeric value with specified decimals and fallback.
|
|
263
281
|
*
|
|
@@ -280,5 +298,5 @@ function safeFormat(value, decimals, fallback = 'N/A') {
|
|
|
280
298
|
// ===============================================================================
|
|
281
299
|
// EXPORTS
|
|
282
300
|
// ===============================================================================
|
|
283
|
-
export { formatAmount8, formatAmount, formatAmountByPrecision, formatSizeByOrderType, formatPrice, formatPrice6, formatPrice4, formatCurrency, formatFundsValue, formatPercent2, formatPercent, formatMetric2, isValidNumber, toFiniteNumber, positiveOrNull, safeFormat };
|
|
301
|
+
export { formatAmount8, formatAmount, formatAmountByPrecision, formatSizeByOrderType, formatPrice, formatPrice6, formatPrice4, formatCurrency, formatFundsValue, formatPercent2, formatPercent, formatMetric2, isValidNumber, toFiniteNumber, toKnownNumber, positiveOrNull, safeFormat };
|
|
284
302
|
//# sourceMappingURL=format.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* missing is therefore not a degraded grid -- it is an undefined one: every
|
|
7
7
|
* consumer that reads `priceForSlot(idx, genesis)` has no authority for a
|
|
8
8
|
* slot's price (nearest-slot adoption, the materialize descriptor-price
|
|
9
|
-
* fallback,
|
|
9
|
+
* fallback, edge anchoring, the `isSlotInRail` fail-open), and that is
|
|
10
10
|
* precisely the state on which an off-grid price became grid evidence and got
|
|
11
11
|
* re-emitted. The tolerance matcher that used to cover it has been removed:
|
|
12
12
|
* E2 refuses to sync such a grid and asks for the resync that re-derives the
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* missing is therefore not a degraded grid -- it is an undefined one: every
|
|
7
7
|
* consumer that reads `priceForSlot(idx, genesis)` has no authority for a
|
|
8
8
|
* slot's price (nearest-slot adoption, the materialize descriptor-price
|
|
9
|
-
* fallback,
|
|
9
|
+
* fallback, edge anchoring, the `isSlotInRail` fail-open), and that is
|
|
10
10
|
* precisely the state on which an off-grid price became grid evidence and got
|
|
11
11
|
* re-emitted. The tolerance matcher that used to cover it has been removed:
|
|
12
12
|
* E2 refuses to sync such a grid and asks for the resync that re-derives the
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - Detects and flags out-of-spread conditions
|
|
13
13
|
*
|
|
14
14
|
* ===============================================================================
|
|
15
|
-
* TABLE OF CONTENTS - Grid Functions (
|
|
15
|
+
* TABLE OF CONTENTS - Grid Functions (23 exported functions)
|
|
16
16
|
* ===============================================================================
|
|
17
17
|
*
|
|
18
18
|
* CONFIGURATION & CALCULATION (2 functions)
|
|
@@ -34,8 +34,11 @@
|
|
|
34
34
|
* GRID RECALCULATION (1 function - async)
|
|
35
35
|
* 7. recalculateGrid(manager, opts) - Recalculate grid based on current state
|
|
36
36
|
*
|
|
37
|
-
* GRID STATE CHECKING (
|
|
38
|
-
* 8. checkAndUpdateGridIfNeeded(manager) -
|
|
37
|
+
* GRID STATE CHECKING (2 functions)
|
|
38
|
+
* 8. checkAndUpdateGridIfNeeded(manager) - Complete fund trigger: available-
|
|
39
|
+
* funds ratio + over-allocation + on-chain committed-drift legs
|
|
40
|
+
* 8b. checkCommittedSizeDrift(manager) - Async committed-drift-only accessor
|
|
41
|
+
* (the drift core is folded into checkAndUpdateGridIfNeeded)
|
|
39
42
|
*
|
|
40
43
|
* BLOCKCHAIN SYNCHRONIZATION (2 functions - async)
|
|
41
44
|
* 9. _recalculateGridOrderSizesFromBlockchain(manager, orderType, options) - Recalculate sizes from blockchain
|
|
@@ -94,7 +97,7 @@ interface SpreadCorrection {
|
|
|
94
97
|
newSize: number;
|
|
95
98
|
}>;
|
|
96
99
|
plannedCount?: number;
|
|
97
|
-
stallHint?:
|
|
100
|
+
stallHint?: SpreadCorrectionStall;
|
|
98
101
|
boundaryIdx?: number;
|
|
99
102
|
origin?: string;
|
|
100
103
|
[key: string]: unknown;
|
|
@@ -152,13 +155,9 @@ export declare function isGridBloatGraceActive(manager: OrderManagerLike): {
|
|
|
152
155
|
*/
|
|
153
156
|
export declare function clearGridBloatFlag(manager: OrderManagerLike): void;
|
|
154
157
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* @param {import('./types').OrderManager} manager - OrderManager instance
|
|
159
|
-
* @param {string} side - 'buy' or 'sell'
|
|
160
|
-
* @returns {Promise<any|null>}
|
|
161
|
-
* @private
|
|
158
|
+
* Async sizing-context accessor. Refreshes funds unless `skipRecalc`, then
|
|
159
|
+
* delegates to the sync core. Both divergence legs (ratio and committed
|
|
160
|
+
* drift) size through the sync core so they read one fund snapshot.
|
|
162
161
|
*/
|
|
163
162
|
export declare function _getSizingContext(manager: OrderManagerLike, side: string, { skipRecalc }?: {
|
|
164
163
|
skipRecalc?: boolean;
|
|
@@ -287,6 +286,19 @@ export declare function checkAndUpdateGridIfNeeded(manager: OrderManagerLike): {
|
|
|
287
286
|
buyShrink: boolean;
|
|
288
287
|
sellShrink: boolean;
|
|
289
288
|
};
|
|
289
|
+
/**
|
|
290
|
+
* Async committed-drift accessor: refresh funds, then run the sync core.
|
|
291
|
+
* Public for callers/tests that want the drift-only result; the complete
|
|
292
|
+
* trigger is checkAndUpdateGridIfNeeded, which folds this core in.
|
|
293
|
+
* Naming mirrors the sizing pair: _computeCommittedSizeDriftSync is the
|
|
294
|
+
* private computation, checkCommittedSizeDrift the public accessor.
|
|
295
|
+
*/
|
|
296
|
+
export declare function checkCommittedSizeDrift(manager: OrderManagerLike): Promise<{
|
|
297
|
+
buyUpdated: boolean;
|
|
298
|
+
sellUpdated: boolean;
|
|
299
|
+
buyShrink: boolean;
|
|
300
|
+
sellShrink: boolean;
|
|
301
|
+
}>;
|
|
290
302
|
/**
|
|
291
303
|
* Standardize grid sizes using blockchain total context.
|
|
292
304
|
*
|