Liquidity#535
Open
TYDev01 wants to merge 3 commits into
Open
Conversation
|
@TYDev01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closed #507
feat(liquidity): add pool health and reserve drift monitoring (#507)
Introduce snapshot-based health tracking for liquidity pools. Each
reserve reading is persisted and compared against a 24-hour baseline to
detect ratio drift. Pools are classified as healthy, warning, or
critical based on reserve imbalance and drift thresholds, with the
signal surfaced through new API endpoints and Prometheus gauges.
Title:
feat(liquidity): add pool health and reserve drift monitoring (#507)Summary
Liquidity pools can silently enter unhealthy states — one reserve nearly depleted, a rapid ratio swing from a large swap, or slow drift from impermanent loss — with no signal to operators or routers. This PR wires up the full monitoring stack for issue #507.
What was added:
liquidity_pool_snapshots)liquidity_pool_health)reserve_a / reserve_bfalls outside configured bounds, the pool is flagged regardless of how gradually it arrived there/api/v1/liquidity/for ingest and readHealth Classification
Condition | Status -- | -- ratio < 0.1 or ratio > 10.0 | critical drift from 24h baseline ≥ 30% | critical ratio < 0.25 or ratio > 4.0 | warning drift from 24h baseline ≥ 10% | warning reserve_b == 0 (division undefined) | critical Everything else | healthyhealth_statusencodes0 = healthy,1 = warning,2 = critical. A Grafana alert onchainbridge_pool_health_status == 2is all that's needed to page on critical pools.Files Changed
Testing
Unit tests cover:
_safe_ratio— zero denominator, equal reserves, zero numerator_classify— all threshold boundaries (warn drift, critical drift, warn ratio low/high, critical ratio low/high,Noneratio, priority ordering)get_pool_health— not-found returnsNone, found returns recordlist_pool_health— empty list, multi-pool listget_pool_snapshots— populated and empty results404on unknown pool,422on path/bodypool_idmismatch, correcthealthy/warning/criticalcounts in summaryChecklist
liquidity_pool_snapshotswarning/criticalon imbalance or driftdowngrade()pathTitle:
feat(liquidity): add pool health and reserve drift monitoring (#507)Summary
Liquidity pools can silently enter unhealthy states — one reserve nearly depleted, a rapid ratio swing from a large swap, or slow drift from impermanent loss — with no signal to operators or routers. This PR wires up the full monitoring stack for issue #507.
What was added:
liquidity_pool_snapshots)liquidity_pool_health)reserve_a / reserve_bfalls outside configured bounds, the pool is flagged regardless of how gradually it arrived there/api/v1/liquidity/for ingest and readHealth Classification
Condition | Status -- | -- ratio < 0.1 or ratio > 10.0 | critical drift from 24h baseline ≥ 30% | critical ratio < 0.25 or ratio > 4.0 | warning drift from 24h baseline ≥ 10% | warning reserve_b == 0 (division undefined) | critical Everything else | healthyhealth_statusencodes0 = healthy,1 = warning,2 = critical. A Grafana alert onchainbridge_pool_health_status == 2is all that's needed to page on critical pools.Files Changed
Testing
Unit tests cover:
_safe_ratio— zero denominator, equal reserves, zero numerator_classify— all threshold boundaries (warn drift, critical drift, warn ratio low/high, critical ratio low/high,Noneratio, priority ordering)get_pool_health— not-found returnsNone, found returns recordlist_pool_health— empty list, multi-pool listget_pool_snapshots— populated and empty results404on unknown pool,422on path/bodypool_idmismatch, correcthealthy/warning/criticalcounts in summaryChecklist
liquidity_pool_snapshotswarning/criticalon imbalance or driftdowngrade()path