Skip to content

feat(budgetTracker): add onOverspend callback when spending exceeds budget ceiling - #724

Closed
rupesh-kumar-sah wants to merge 1 commit into
Stellar-split:mainfrom
rupesh-kumar-sah:feat/issue-704-budget-tracker-on-overspend
Closed

rupesh-kumar-sah wants to merge 1 commit into
Stellar-split:mainfrom
rupesh-kumar-sah:feat/issue-704-budget-tracker-on-overspend

Conversation

@rupesh-kumar-sah

Copy link
Copy Markdown

Summary of Changes

Resolves #704

This PR adds an onOverspend(overspentBy: number, budgetId: string) callback option to budgetTracker:

  1. Configuration Acceptance:
    • onOverspend callback is accepted via configureBudgetTracker(config), setBudgetLimit(address, limit, options), BudgetTracker class configuration, or recordPayment(address, amount, options).
  2. Exact Trigger Semantics:
    • The callback fires exactly once per payment that crosses the budget ceiling (prevSpent <= limit && newSpent > limit). Subsequent payments made while the budget is already exceeded do not trigger repeated callbacks.
  3. Difference Calculation:
    • overspentBy is calculated as the exact positive difference between the new total spent and the budget ceiling in USDC.
  4. Backward Compatibility & Verification:
    • All existing tests pass without regressions.
    • Added unit test suite covering ceiling crossing, subsequent payments exclusion, positive difference calculation, and configuration options.

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

@rupesh-kumar-sah is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

budgetTracker: Add onOverspend callback when spending exceeds budget ceiling

2 participants