Repository navigation
feat(backstop): expose solvency and coverage-ratio health views with threshold alert events (#239) - #501
Merged
techisigu merged 1 commit intoOct 24, 2026
Conversation
…threshold alert events (Refract-Protocol#239) Closes Refract-Protocol#239
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
Exposes first-class solvency and coverage-ratio health views on
RefractBackstopalongside a permissionlesscheck_healthevaluator that emits threshold crossing and recovery events with configurable hysteresis.Closes #239
Changes
pool/src/lib.rs):aggregate_in_force_coverage(env)as a cheap single-read view returning the pool's active in-force coverage fromPoolAccounting.backstop/src/lib.rs):total_staked_capital(env): pure read-only view returning total staked capital across tranches.aggregate_in_force_coverage(env): pulls live coverage fromRefractPool::aggregate_in_force_coverageviatry_invoke_contractand degrades gracefully to the cached coverage counter (DataKey::CachedCoverage) when the pool read is unavailable.encumbered_capital(env)andidle_capital(env): pure read-only views for capital encumbered by in-force coverage vs. unencumbered capital.solvency_ratio_bps(env),coverage_ratio_bps(env), andfeed_utilization_bps(env, feed): pure read-only views computed via the1e7fixed-point helper (FP_SCALE), returningOk(None)(never panicking) when the denominator is zero.health_snapshot(env): consolidated read-only view returningBackstopHealthSnapshot.backstop/src/lib.rs):set_health_thresholds(env, caller, min_solvency_bps, max_coverage_bps, hysteresis_bps): admin-gated configuration for alert thresholds and recovery hysteresis band.check_health(env): permissionless evaluator that checks solvency and coverage ratios against configured thresholds and emitsHLTHALRT/HLTHRECVevents only on state transitions across the threshold / hysteresis band.backstop/src/test.rs):Nonewithout panickingi128upper bounds (1e30)Checklist
unwrap(),expect(), orpanic!()calls in non-test contract code