Simplify unstable XCH pricing and expiry path#55
Merged
Conversation
Use Cloud Wallet chia quotes as the primary daemon XCH/USD source with cached CoinCodex fallback, add cache layers and per-market unstable cancel thresholds, and migrate market config to minutes-based strategy expiry with legacy field cleanup. This reduces unstable-pair configuration complexity while keeping offer cancellation and refresh behavior responsive. Made-with: Cursor
Prevent sub-1-CAT coin-op targets and default XCH quote amounts to 1e12 mojos when multipliers are omitted, fixing severe underpricing on ECO.181.2020 XCH offers while keeping CAT defaults at 1000 mojos. Made-with: Cursor
Use one canonical SDK parsing path for offer expiry checks by evaluating each coin spend puzzle/solution and scanning resulting conditions for ASSERT_BEFORE constraints. This removes the legacy direct-conditions fallback that misclassified valid offers on current SDK bindings. Made-with: Cursor
- Move canonical_is_xch and default_mojo_multiplier_for_asset into hex_utils.py (single source of truth); remove the two divergent local copies from daemon/main.py and cloud_wallet_offer_runtime.py. The cloud_wallet_offer_runtime copy was missing "1" from the XCH symbol set, which would have produced the wrong 1000-mojo default multiplier. - Complete the pending-visibility write path: when Dexie visibility check returns a transient 404, store status=executed with reason= _PENDING_VISIBILITY_REASON so _is_stale_pending_visibility_offer can keep the offer in scope until the grace period expires. Previously is_transient_dexie_visibility_404_error was defined but never called. - Extract _normalize_target_counts helper in daemon/main.py to eliminate the duplicated dict comprehension in _strategy_config_from_market and _strategy_config_for_side. - Refactor DexieAdapter TTL cache into a _RowCache dataclass + shared _cached_fetch helper, removing the duplicated check/store logic from _fetch_token_rows and _fetch_ticker_rows. - Add _CloudWalletProgram, _ParallelCloudWalletProgram, and _CoinOpsProgram module-level stubs in test_daemon_offer_execution.py, replacing ~25 identical inner _Program class definitions with aliases. - Add missing tests: _is_stale_pending_visibility_offer with no Dexie snapshot, XchPriceProvider last-good-price fallback, and assert fallback adapter is never called when cloud wallet is healthy. - Simplify _effective_sell_bucket_counts_for_coin_ops tests to pass ladder entries directly instead of building full market objects. - Add defensive comments to the inner split/combine sub-minimum guards in _execute_coin_ops_cloud_wallet_kms_only explaining the outer vs inner validation boundary. Made-with: Cursor
Expire watched offers when direct Dexie lookups return 404 so stale local open rows do not block replacement ladder postings. Made-with: Cursor
Limit repeated reseed actions for small short-expiry ladders so the daemon stops refilling the full 1-offer deficit in a single cycle. This keeps ECO/XCH posts from expiring in synchronized bursts while preserving a small bootstrap refill when a rung is empty. Made-with: Cursor
Extend short-TTL cadence limiting to the main strategy path so repeated below-target actions stop burst-posting small offers outside the reseed fallback. Record the separate BYC two-sided buy-side builder gap found during the John-Deere soak. Made-with: Cursor
Allow the last missing offer in a short-TTL ladder to bypass cadence suppression so ECO/XCH can return from 4/5 to its configured target without waiting for the next spacing window. Record the confirmed BYC buy-side quote-balance blocker from the John-Deere wallet state. Made-with: Cursor
Fail closed when Dexie still returns 404s after a cloud-wallet post, and reconcile CAT-quoted markets with Dexie's canonical asset ids so daemon state matches the exchange. Made-with: Cursor
Acquire cloud-wallet reservations at worker execution time and log queue/reservation timing so refill batches stop sitting pre-leased for minutes. Made-with: Cursor
Add a read-only Cloud Wallet tracing script to inspect hidden locked quote coins, lineage, and nearby creator offers when spendable and locked balances diverge. Made-with: Cursor
Replace the race-prone sqlite-backed contention setup with a deterministic coordinator stub so the parallel reservation test behaves consistently across CI runners. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
quote(asset: \"chia\")with cached CoinCodex fallback, plus stale-safe cache behavior.strategy_offer_expiry_minutes, removing legacy reference fields, and adding per-marketcancel_move_threshold_bpssupport.eco1812020_sell_xch, and extend tests/daemon paths for unstable-market cancellation and expiry behavior.Test plan
PATH=\"$(pwd)/.venv/bin:$PATH\" pre-commit run --all-filesPATH=\"$(pwd)/.venv/bin:$PATH\" pytest tests/test_price_adapter.py tests/test_cloud_wallet_adapter.py tests/test_dexie_adapter.py tests/test_config_models.py tests/test_strategy.py tests/test_daemon_cancel_policy.py tests/test_manager_post_offer.pyMade with Cursor