Skip to content

feat(fees): add adaptive fee planner (#1324 #1326 #1327 #1328) - #1603

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
aniokedianne:fix/1324-1326-1327-1328
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
aniokedianne:fix/1324-1326-1327-1328

Conversation

@aniokedianne

Copy link
Copy Markdown
Contributor

Closes #1324
Closes #1326
Closes #1327
Closes #1328

#1326 — Implement adaptive network-fee planner with per-corridor historical priors

  • Adds backend/src/services/feePlanner.ts with FeePlanner: observe(corridor, paidFee), plan(corridor, urgency, liveFee?), getPrior, globalPrior.
  • Each corridor keeps an exponentially weighted mean and variance of fees actually paid. A plan blends that prior with the live quote and trusts the prior more as samples grow (full trust at 20 samples, configurable).
  • Urgency (low/normal/high) adds 0/1/2 standard deviations of headroom. The plan is capped at a configurable multiple of the live quote and rounded up to a whole unit (bigint).
  • A corridor with no history uses a global prior at half weight; with no history anywhere it uses the live quote alone; with neither it throws instead of inventing a fee. If the live quote is unavailable, it plans from the prior alone.
  • Pure in-memory state, no clock or I/O, so results are deterministic. Bad fees, corridors, urgencies and config throw FeePlannerError.
  • Tests in backend/src/services/__tests__/feePlanner.test.ts cover the EWMA maths, corridor isolation, prior trust growth, urgency headroom, the global fallback, prior-only planning, the live-quote cap, rounding, validation and determinism.
  • Not done: wiring into a route or persisting priors, and the observability hooks and docs the issue lists.

#1324, #1327, #1328

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@aniokedianne is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@aniokedianne Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@github-actions
github-actions Bot merged commit bd4fe4a into Smartdevs17:main Nov 24, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant