Honor mint filters in TVL and recognise payment failures #12

Closed
ye0man wants to merge 0 commits from feat/analytics-filters-attribution into main
Owner

Problem

  • /api/tvl ignored from_url/to_url: Filters::where_snapshots emitted only date bounds, so the filtered TVL still carried every mint.
  • The error classifier required the literal prefix lightning payment failed, but CDK surfaces wallet melt failures as Payment failed. On the live data, 117 of 122 errors fell through to Other / category unknown, making the error donut and blamed-mint categories uninformative.

Fix

  • Filters::where_snapshots now restricts the joined mints.url, so tvl_series respects the selected mints. The caller must join mints as m (the snapshot table only stores mint_id); documented on the method.
  • Broaden the payment pattern to (lightning )?payment (failed|unsuccessful); these errors now classify as Mint: payment failed / category mint.

Tests

  • analytics::tests::tvl_respects_mint_filters - a from_url-filtered TVL only carries the selected mint.
  • filters::tests::snapshot_url_filters_reference_the_joined_mints_alias.
  • classify::tests::classifies_cdk_payment_failures - covers paying the invoice - wallet error: Payment failed.

Full suite: cargo test --no-default-features --features=ssr -> 98 passed; cargo clippy --no-default-features --features=ssr and cargo fmt --check clean.

## Problem - `/api/tvl` ignored `from_url`/`to_url`: `Filters::where_snapshots` emitted only date bounds, so the filtered TVL still carried every mint. - The error classifier required the literal prefix `lightning payment failed`, but CDK surfaces wallet melt failures as `Payment failed`. On the live data, 117 of 122 errors fell through to `Other` / category `unknown`, making the error donut and blamed-mint categories uninformative. ## Fix - `Filters::where_snapshots` now restricts the joined `mints.url`, so `tvl_series` respects the selected mints. The caller must join `mints` as `m` (the snapshot table only stores `mint_id`); documented on the method. - Broaden the payment pattern to `(lightning )?payment (failed|unsuccessful)`; these errors now classify as `Mint: payment failed` / category `mint`. ## Tests - `analytics::tests::tvl_respects_mint_filters` - a `from_url`-filtered TVL only carries the selected mint. - `filters::tests::snapshot_url_filters_reference_the_joined_mints_alias`. - `classify::tests::classifies_cdk_payment_failures` - covers `paying the invoice - wallet error: Payment failed`. Full suite: `cargo test --no-default-features --features=ssr` -> 98 passed; `cargo clippy --no-default-features --features=ssr` and `cargo fmt --check` clean.
Honor mint filters in TVL and recognise payment failures
All checks were successful
Validate auditor / check (pull_request) Successful in 10m15s
08ea1d40b7
Filters::where_snapshots emitted only date bounds, so /api/tvl ignored from_url/to_url and always returned every mint. Restrict the joined mints.url in the snapshot scope and add a regression test proving a filtered TVL only carries the selected mint.

CDK wallet melt failures surface as Payment failed without the lightning prefix the classifier required, so 117 of 122 live errors fell through to Other/category unknown. Make the prefix optional and add tests; the donut and blamed-mint categories now attribute these to the mint.
asmo closed this pull request 2026-09-14 06:10:48 +00:00
All checks were successful
Validate auditor / check (pull_request) Successful in 10m15s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/auditor!12
No description provided.