Skip to content

fix(fee_collector): add lifetime_withdrawn tracking and reconciliation view - #63

Open
DavidAkere204 wants to merge 1 commit into
StellarSend:mainfrom
DavidAkere204:fix/fee-collector-observability-41
Open

fix(fee_collector): add lifetime_withdrawn tracking and reconciliation view#63
DavidAkere204 wants to merge 1 commit into
StellarSend:mainfrom
DavidAkere204:fix/fee-collector-observability-41

Conversation

@DavidAkere204

Copy link
Copy Markdown
Contributor
  • Add KEY_WITHDRAWN persistent storage key per token
  • Update withdraw() to increment the lifetime-withdrawn counter on every successful withdrawal (parallel to KEY_TOTAL / lifetime-collected)
  • Add get_total_withdrawn(token) view function
  • Add get_expected_balance(token) view function: expected = get_total_collected(token) - get_total_withdrawn(token) Diffing this against get_balance(token) surfaces any drift between reported accounting and actual token holdings
  • Update module doc comment to clearly state that get_total_collected is a reported/claimed figure, not independently verified against real token movement, and document the reconciliation invariant
  • Add test_reconciliation_detects_divergence covering:
    • normal collect + withdraw produces zero drift
    • over-reported collect_fee (50 reported vs 30 received) produces a detectable 20-token drift via get_expected_balance - get_balance

Closes #41

…n view

- Add KEY_WITHDRAWN persistent storage key per token
- Update withdraw() to increment the lifetime-withdrawn counter on every
  successful withdrawal (parallel to KEY_TOTAL / lifetime-collected)
- Add get_total_withdrawn(token) view function
- Add get_expected_balance(token) view function:
    expected = get_total_collected(token) - get_total_withdrawn(token)
  Diffing this against get_balance(token) surfaces any drift between
  reported accounting and actual token holdings
- Update module doc comment to clearly state that get_total_collected is
  a reported/claimed figure, not independently verified against real
  token movement, and document the reconciliation invariant
- Add test_reconciliation_detects_divergence covering:
    * normal collect + withdraw produces zero drift
    * over-reported collect_fee (50 reported vs 30 received) produces a
      detectable 20-token drift via get_expected_balance - get_balance

Closes StellarSend#41
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.

fee_collector::collect_fee has no reconciliation between claimed amounts and actual balance, and no invariant-check function exists

1 participant