Skip to content

Use TVL ratios for CAP withdrawable liquidity alerts - #412

Merged
spalen0 merged 2 commits into
mainfrom
cap-threshold
Oct 5, 2026
Merged

spalen0 merged 2 commits into
mainfrom
cap-threshold

Conversation

@spalen0

@spalen0 spalen0 commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

CAP withdrawable liquidity currently sends a high alert below a fixed 15 million threshold, regardless of protocol size. Replace this with a high alert when withdrawable liquidity is at least 3% but below 10% of total TVL, and a critical alert below 3%. Exactly 10% sends no liquidity alert; exactly 3% sends high.

TVL sums cUSD's totalSupplies(asset) values, including borrowed assets, using the existing at-par valuation after adjusting for token decimals. Read TVL and liquidity at the same block, and include totals and the liquidity percentage in alerts. Use local Decimal precision so other monitors cannot round threshold comparisons. Zero TVL skips the ratio check; missing total-supply data raises an error.

Update CAP documentation and add coverage for boundaries, mixed token decimals, TVL scaling, zero/missing TVL, shared Decimal precision, and large-mint monitoring.

Validation:

  • Full test suite: 993 passed, 4 skipped, 5 subtests passed.
  • ruff check . and ruff format --check . passed.
  • git diff --check passed.

@spalen0
spalen0 marked this pull request as ready for review October 5, 2026 06:39
@spalen0
spalen0 merged commit bc8271c into main Oct 5, 2026
3 checks passed
@spalen0
spalen0 deleted the cap-threshold branch October 5, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant