dexbot 1.6.5 → 1.6.6
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 +36 -4
- package/README.md +104 -35
- package/analysis/README.md +11 -16
- package/analysis/account_resolver.ts +1 -11
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
- package/analysis/chain_pool.ts +1 -1
- package/analysis/fills_source.ts +0 -6
- package/analysis/grid_correction_check.ts +20 -26
- package/analysis/resolve_source.ts +1 -1
- package/analysis/trade_profitability.ts +2 -5
- package/analysis/trend_detection/README.md +1 -3
- package/analysis/trend_detection/package.json +1 -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/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/account_resolver.d.ts +1 -4
- package/dist/analysis/account_resolver.d.ts.map +1 -1
- package/dist/analysis/account_resolver.js +1 -1
- package/dist/analysis/account_resolver.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -2
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chain_pool.d.ts +1 -3
- package/dist/analysis/chain_pool.d.ts.map +1 -1
- package/dist/analysis/chain_pool.js +1 -1
- package/dist/analysis/chain_pool.js.map +1 -1
- package/dist/analysis/fills_source.d.ts +1 -51
- package/dist/analysis/fills_source.d.ts.map +1 -1
- package/dist/analysis/fills_source.js +1 -1
- package/dist/analysis/fills_source.js.map +1 -1
- package/dist/analysis/grid_correction_check.d.ts +2 -3
- package/dist/analysis/grid_correction_check.d.ts.map +1 -1
- package/dist/analysis/grid_correction_check.js +18 -26
- package/dist/analysis/grid_correction_check.js.map +1 -1
- package/dist/analysis/resolve_source.d.ts +1 -1
- package/dist/analysis/resolve_source.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +2 -7
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +60 -74
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.d.ts +1 -15
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +1 -1
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -35
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +10 -54
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +1 -8
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +1 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +2 -63
- package/dist/market_adapter/inputs/window_cache.d.ts.map +1 -1
- package/dist/market_adapter/inputs/window_cache.js +22 -102
- package/dist/market_adapter/inputs/window_cache.js.map +1 -1
- package/dist/modules/account_bots.d.ts +16 -2
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +107 -44
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +0 -31
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts +0 -2
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +1 -10
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +13 -10
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +0 -9
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +13 -0
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +13 -1
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +4 -18
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +4 -34
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/export.d.ts +9 -12
- package/dist/modules/order/export.d.ts.map +1 -1
- package/dist/modules/order/export.js +9 -12
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/grid.d.ts +35 -40
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +43 -43
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +111 -20
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts +5 -3
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +18 -3
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/manager.d.ts +0 -8
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +0 -10
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +22 -7
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +103 -21
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.d.ts +12 -0
- package/dist/modules/order/utils/withPoolRef.d.ts.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +17 -0
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.d.ts +8 -13
- package/dist/modules/order/working_grid.d.ts.map +1 -1
- package/dist/modules/order/working_grid.js +8 -29
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/scripts/sync-version.js +0 -22
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/update_dist_freshness.d.ts +12 -0
- package/dist/scripts/update_dist_freshness.d.ts.map +1 -1
- package/dist/scripts/update_dist_freshness.js +30 -1
- package/dist/scripts/update_dist_freshness.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +9 -6
- package/docs/COW_INVARIANTS.md +1 -0
- package/docs/DEXBOT_COMPARISON.md +11 -11
- package/docs/EVOLUTION.md +8 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +518 -0
- package/docs/GRID_RECALCULATION.md +1 -1
- package/docs/GRID_RECONCILE.md +60 -39
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +556 -0
- package/docs/README.md +3 -3
- package/docs/WORKFLOW.md +12 -6
- package/docs/architecture.md +40 -38
- package/docs/developer_guide.md +4 -8
- package/market_adapter/README.md +16 -12
- package/modules/README.md +1 -1
- package/package.json +7 -3
- package/scripts/README.md +0 -9
- package/scripts/reset-settings.sh +1 -1
- package/analysis/ama_fitting/package.json +0 -12
- package/analysis/analyze_derivatives.ts +0 -320
- package/analysis/derivative_chart_generator.ts +0 -874
- package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +0 -403
- package/analysis/trend_detection/derivative_analyzer.ts +0 -1059
- package/dist/analysis/analyze_derivatives.d.ts +0 -68
- package/dist/analysis/analyze_derivatives.d.ts.map +0 -1
- package/dist/analysis/analyze_derivatives.js +0 -287
- package/dist/analysis/analyze_derivatives.js.map +0 -1
- package/dist/analysis/derivative_chart_generator.d.ts +0 -12
- package/dist/analysis/derivative_chart_generator.d.ts.map +0 -1
- package/dist/analysis/derivative_chart_generator.js +0 -891
- package/dist/analysis/derivative_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +0 -248
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.js +0 -910
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +0 -1
|
@@ -12,63 +12,58 @@
|
|
|
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 (22 exported functions)
|
|
16
16
|
* ===============================================================================
|
|
17
17
|
*
|
|
18
|
-
* CONFIGURATION & CALCULATION (
|
|
19
|
-
* 1.
|
|
18
|
+
* CONFIGURATION & CALCULATION (2 functions)
|
|
19
|
+
* 1. resolveRmsThresholdPct(manager) - Resolve the structural-divergence threshold
|
|
20
|
+
* 2. calculateGapSlots(incrementPercent, targetSpreadPercent) - Calculate spread gap size
|
|
20
21
|
*
|
|
21
|
-
* GRID SIZING & CONTEXT (1
|
|
22
|
-
* 3. _getSizingContext(manager, side) - Get budget and sizing parameters
|
|
23
|
-
* Determines budget from allocated funds
|
|
22
|
+
* GRID SIZING & CONTEXT (1 function)
|
|
23
|
+
* 3. _getSizingContext(manager, side, options) - Get budget and sizing parameters
|
|
24
|
+
* Determines budget from allocated funds and optionally deducts BTS fees
|
|
24
25
|
*
|
|
25
|
-
* GRID CREATION (1
|
|
26
|
+
* GRID CREATION (1 function)
|
|
26
27
|
* 4. createOrderGrid(config) - Create geometric price grid
|
|
27
28
|
* Returns price levels from minPrice to maxPrice with increment spacing
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
* 5.
|
|
30
|
+
* GRID LOADING & INITIALIZATION (2 functions - async)
|
|
31
|
+
* 5. loadGrid(manager, grid, boundaryIdx, genesisInput, options) - Load grid into manager orders
|
|
32
|
+
* 6. initializeGrid(manager) - Full grid initialization from config
|
|
31
33
|
*
|
|
32
|
-
* GRID
|
|
33
|
-
*
|
|
34
|
-
* 7. initializeGrid(manager) - Full grid initialization from config
|
|
34
|
+
* GRID RECALCULATION (1 function - async)
|
|
35
|
+
* 7. recalculateGrid(manager, opts) - Recalculate grid based on current state
|
|
35
36
|
*
|
|
36
|
-
* GRID
|
|
37
|
-
* 8.
|
|
37
|
+
* GRID STATE CHECKING (1 function)
|
|
38
|
+
* 8. checkAndUpdateGridIfNeeded(manager) - Check if grid needs update
|
|
38
39
|
*
|
|
39
|
-
*
|
|
40
|
-
* 9.
|
|
40
|
+
* BLOCKCHAIN SYNCHRONIZATION (2 functions - async)
|
|
41
|
+
* 9. _recalculateGridOrderSizesFromBlockchain(manager, orderType, options) - Recalculate sizes from blockchain
|
|
42
|
+
* 10. updateGridFromBlockchainSnapshot(manager, orderType, fromBlockchainTimer, overrideBoundaryIdx) - Update grid from blockchain
|
|
41
43
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* 11. updateGridFromBlockchainSnapshot(manager, orderType, fromBlockchainTimer) - Update grid from blockchain
|
|
45
|
-
*
|
|
46
|
-
* GRID COMPARISON (2 methods - async)
|
|
47
|
-
* 12. compareGrids(calculatedGrid, persistedGrid, manager) - Compare two grids
|
|
44
|
+
* GRID COMPARISON (2 functions - async)
|
|
45
|
+
* 11. compareGrids(calculatedGrid, persistedGrid, manager) - Compare two grids
|
|
48
46
|
* Validates grid structure and reports divergence metrics
|
|
49
|
-
*
|
|
47
|
+
* 12. monitorDivergence(manager, calculatedGrid, persistedGrid) - Unified divergence check
|
|
50
48
|
* Runs ratio-based + RMS-based checks and returns combined result
|
|
51
49
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* SPREAD MANAGEMENT (2 methods - async)
|
|
56
|
-
* 15. calculateCurrentSpread(manager) - Calculate current bid-ask spread
|
|
57
|
-
* 16. checkSpreadCondition(manager, BitShares, updateOrdersOnChainBatch) - Check and flag spread condition
|
|
50
|
+
* SPREAD MANAGEMENT (2 functions)
|
|
51
|
+
* 13. calculateCurrentSpread(manager) - Calculate current bid-ask spread
|
|
52
|
+
* 14. checkSpreadCondition(manager, BitShares, updateOrdersOnChainBatch) - Check and flag spread condition
|
|
58
53
|
*
|
|
59
|
-
* GRID HEALTH MONITORING (
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* 21. getDustOrders(manager, partials, side) - Get all dust order IDs (public)
|
|
65
|
-
* 22. determineOrderSideByFunds(manager, currentMarketPrice) - Determine priority side
|
|
54
|
+
* GRID HEALTH MONITORING (4 functions)
|
|
55
|
+
* 15. checkGridHealth(manager, updateOrdersOnChainBatch) - Monitor grid health
|
|
56
|
+
* 16. checkWindowDust(manager) - Dust check scoped to the active buy/sell window
|
|
57
|
+
* 17. hasAnyDust(manager, partials, side) - Check for dust orders
|
|
58
|
+
* 18. getDustOrders(manager, partials, side) - Get dust order IDs
|
|
66
59
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
60
|
+
* SIDE SELECTION (1 function)
|
|
61
|
+
* 19. determineOrderSideByFunds(manager, currentMarketPrice) - Determine priority side
|
|
69
62
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
63
|
+
* BLOAT STATUS (3 functions)
|
|
64
|
+
* 20. isGridBloated(manager, orders) - Check whether the grid is bloated
|
|
65
|
+
* 21. isGridBloatGraceActive(manager) - Check the bloat grace state
|
|
66
|
+
* 22. clearGridBloatFlag(manager) - Clear the bloat state
|
|
72
67
|
*
|
|
73
68
|
* ===============================================================================
|
|
74
69
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../modules/order/grid.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../modules/order/grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAG,OAAO,CAAC,GAAG,CAAC,CAenG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACP,wBAAsB,eAAe,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAiF5D;AA8ED;;;;;;GAMG;AACP,wBAAsB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAIrF;AAED;;;;;;;GAOG;AACP,wBAAsB,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAItF;AAED;;;;;;GAMG;AACP,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,GAAG,GAAG,CAyEhF;AAmED;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,GAAE,MAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CA6b3H"}
|
|
@@ -12,63 +12,58 @@
|
|
|
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 (22 exported functions)
|
|
16
16
|
* ===============================================================================
|
|
17
17
|
*
|
|
18
|
-
* CONFIGURATION & CALCULATION (
|
|
19
|
-
* 1.
|
|
18
|
+
* CONFIGURATION & CALCULATION (2 functions)
|
|
19
|
+
* 1. resolveRmsThresholdPct(manager) - Resolve the structural-divergence threshold
|
|
20
|
+
* 2. calculateGapSlots(incrementPercent, targetSpreadPercent) - Calculate spread gap size
|
|
20
21
|
*
|
|
21
|
-
* GRID SIZING & CONTEXT (1
|
|
22
|
-
* 3. _getSizingContext(manager, side) - Get budget and sizing parameters
|
|
23
|
-
* Determines budget from allocated funds
|
|
22
|
+
* GRID SIZING & CONTEXT (1 function)
|
|
23
|
+
* 3. _getSizingContext(manager, side, options) - Get budget and sizing parameters
|
|
24
|
+
* Determines budget from allocated funds and optionally deducts BTS fees
|
|
24
25
|
*
|
|
25
|
-
* GRID CREATION (1
|
|
26
|
+
* GRID CREATION (1 function)
|
|
26
27
|
* 4. createOrderGrid(config) - Create geometric price grid
|
|
27
28
|
* Returns price levels from minPrice to maxPrice with increment spacing
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
* 5.
|
|
30
|
+
* GRID LOADING & INITIALIZATION (2 functions - async)
|
|
31
|
+
* 5. loadGrid(manager, grid, boundaryIdx, genesisInput, options) - Load grid into manager orders
|
|
32
|
+
* 6. initializeGrid(manager) - Full grid initialization from config
|
|
31
33
|
*
|
|
32
|
-
* GRID
|
|
33
|
-
*
|
|
34
|
-
* 7. initializeGrid(manager) - Full grid initialization from config
|
|
34
|
+
* GRID RECALCULATION (1 function - async)
|
|
35
|
+
* 7. recalculateGrid(manager, opts) - Recalculate grid based on current state
|
|
35
36
|
*
|
|
36
|
-
* GRID
|
|
37
|
-
* 8.
|
|
37
|
+
* GRID STATE CHECKING (1 function)
|
|
38
|
+
* 8. checkAndUpdateGridIfNeeded(manager) - Check if grid needs update
|
|
38
39
|
*
|
|
39
|
-
*
|
|
40
|
-
* 9.
|
|
40
|
+
* BLOCKCHAIN SYNCHRONIZATION (2 functions - async)
|
|
41
|
+
* 9. _recalculateGridOrderSizesFromBlockchain(manager, orderType, options) - Recalculate sizes from blockchain
|
|
42
|
+
* 10. updateGridFromBlockchainSnapshot(manager, orderType, fromBlockchainTimer, overrideBoundaryIdx) - Update grid from blockchain
|
|
41
43
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* 11. updateGridFromBlockchainSnapshot(manager, orderType, fromBlockchainTimer) - Update grid from blockchain
|
|
45
|
-
*
|
|
46
|
-
* GRID COMPARISON (2 methods - async)
|
|
47
|
-
* 12. compareGrids(calculatedGrid, persistedGrid, manager) - Compare two grids
|
|
44
|
+
* GRID COMPARISON (2 functions - async)
|
|
45
|
+
* 11. compareGrids(calculatedGrid, persistedGrid, manager) - Compare two grids
|
|
48
46
|
* Validates grid structure and reports divergence metrics
|
|
49
|
-
*
|
|
47
|
+
* 12. monitorDivergence(manager, calculatedGrid, persistedGrid) - Unified divergence check
|
|
50
48
|
* Runs ratio-based + RMS-based checks and returns combined result
|
|
51
49
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* SPREAD MANAGEMENT (2 methods - async)
|
|
56
|
-
* 15. calculateCurrentSpread(manager) - Calculate current bid-ask spread
|
|
57
|
-
* 16. checkSpreadCondition(manager, BitShares, updateOrdersOnChainBatch) - Check and flag spread condition
|
|
50
|
+
* SPREAD MANAGEMENT (2 functions)
|
|
51
|
+
* 13. calculateCurrentSpread(manager) - Calculate current bid-ask spread
|
|
52
|
+
* 14. checkSpreadCondition(manager, BitShares, updateOrdersOnChainBatch) - Check and flag spread condition
|
|
58
53
|
*
|
|
59
|
-
* GRID HEALTH MONITORING (
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* 21. getDustOrders(manager, partials, side) - Get all dust order IDs (public)
|
|
65
|
-
* 22. determineOrderSideByFunds(manager, currentMarketPrice) - Determine priority side
|
|
54
|
+
* GRID HEALTH MONITORING (4 functions)
|
|
55
|
+
* 15. checkGridHealth(manager, updateOrdersOnChainBatch) - Monitor grid health
|
|
56
|
+
* 16. checkWindowDust(manager) - Dust check scoped to the active buy/sell window
|
|
57
|
+
* 17. hasAnyDust(manager, partials, side) - Check for dust orders
|
|
58
|
+
* 18. getDustOrders(manager, partials, side) - Get dust order IDs
|
|
66
59
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
60
|
+
* SIDE SELECTION (1 function)
|
|
61
|
+
* 19. determineOrderSideByFunds(manager, currentMarketPrice) - Determine priority side
|
|
69
62
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
63
|
+
* BLOAT STATUS (3 functions)
|
|
64
|
+
* 20. isGridBloated(manager, orders) - Check whether the grid is bloated
|
|
65
|
+
* 21. isGridBloatGraceActive(manager) - Check the bloat grace state
|
|
66
|
+
* 22. clearGridBloatFlag(manager) - Clear the bloat state
|
|
72
67
|
*
|
|
73
68
|
* ===============================================================================
|
|
74
69
|
*
|
|
@@ -125,7 +120,7 @@ import { floatToBlockchainInt, getPrecisionByOrderType, getPrecisionsForManager,
|
|
|
125
120
|
import { filterOrdersByType, checkSizesBeforeMinimum, checkSizeThreshold, resolveConfiguredPriceBound, shouldFlagOutOfSpread, isOrderHealthy, isPhantomOrder, isSlotAvailable, isOrderOnChain, isOrderPlaced, hasOnChainId, isEmptyGridSlot, parseSlotIndex, calculateIdealBoundary, assignGridRoles, resolveOnChainRetypeType, resolveReserveCount, reserveEdgeIdSet, resolveLiveReserveEdgeAnchorPrice } from './utils/order.js';
|
|
126
121
|
import { loadAmaCenterPrice, loadAmaCenterSnapshot, withBlockchainRetry } from './utils/system.js';
|
|
127
122
|
import * as MathUtils from './utils/math.js';
|
|
128
|
-
import { derivePriceWithPoolRef } from './utils/withPoolRef.js';
|
|
123
|
+
import { derivePriceWithPoolRef, resolveStartPriceMode } from './utils/withPoolRef.js';
|
|
129
124
|
import { getWhitelistFlags } from '../market_adapter_whitelist.js';
|
|
130
125
|
import { getErrorMessage } from '../utils/errors.js';
|
|
131
126
|
const calculateGapSlots = _mathGapSlots;
|
|
@@ -954,9 +949,14 @@ export async function initializeGrid(manager) {
|
|
|
954
949
|
if (typeof mpRaw !== 'number' || isNaN(mpRaw)) {
|
|
955
950
|
try {
|
|
956
951
|
const { BitShares } = require('../bitshares_client');
|
|
957
|
-
|
|
952
|
+
// startPrice is the master price source: pass its own mode so a
|
|
953
|
+
// pinned poolRef only refines pool discovery. Without this,
|
|
954
|
+
// the old `priceMode || 'auto'` read (priceMode is never set in
|
|
955
|
+
// the runtime path) let a poolRef override startPrice:"book".
|
|
956
|
+
const startPriceMode = resolveStartPriceMode(mpRaw, manager.config.priceMode || 'auto');
|
|
957
|
+
const derived = await derivePriceWithPoolRef(BitShares, manager.config.assetA, manager.config.assetB, startPriceMode, manager.config.poolRef);
|
|
958
958
|
if (derived) {
|
|
959
|
-
manager.logger?.log?.(`[DIAGNOSTIC] initializeGrid: Derived new startPrice=${derived.toFixed(8)} (mode=${
|
|
959
|
+
manager.logger?.log?.(`[DIAGNOSTIC] initializeGrid: Derived new startPrice=${derived.toFixed(8)} (mode=${startPriceMode})`, 'info');
|
|
960
960
|
manager.config.startPrice = Number(derived);
|
|
961
961
|
}
|
|
962
962
|
else {
|