Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: full solver failure surcharge solution #427

Merged
merged 18 commits into from
Oct 17, 2024

Conversation

BenSparksCode
Copy link
Contributor

@BenSparksCode BenSparksCode commented Sep 11, 2024

Changes to Accounting Treatment of Surcharges

Variables

  • cost = the base gas cost of execution, on which surcharges are calculated.
  • a = Atlas gas surcharge
  • b = Bundler surcharge
  • d = deficit due to insufficient solver balance during _assign()

Latest Accounting Rules

  • When a solver wins:
    • No change in rules. Surcharges are calculated on the full metacall gas cost.
    • Bundler receives cost + b, paid by winning solver.
    • Atlas receives a, paid by winning solver.
  • When zero solverOps:
    • No surcharges applied.
    • Bundler incurs cost and does not receive a refund.
    • Atlas does not receive any surcharge.
  • When some solverOps, but all fail:
    • claims is set to 0, but the following treatment is applied on a per-solverOp basis.
    • When solverOp failure is the Bundler's fault:
      • Solver pays nothing.
      • Bundler incurs cost, and writeoffs increases by a + b, but gets cleared when claims gets set to 0 unless their is a winning solver.
      • Atlas does not receive any surcharge.
    • When solverOp failure is the Solver's fault:
      • Solver pays cost + a + b - d via _assign().
      • Bundler incurs cost but is refunded cost + b - d via _credit().
      • Atlas receives a via an increase in cumulative surcharge.

Capping Bundler refund when all solverOps fail

Bundling should not be profitable when all solvers fail. If they fail due to fault of the solver, the current accounting charges Atlas and Bundler surcharges on the gas costs of the execution of those SolverOperations. This was then distributed to Atlas and Bundler at the end of the metacall.

However, the Bundler may also collect storage refunds after bundling a metacall, which in combination with the Bundler surcharges, could result in a profitable tx (ETH spent on gas cost vs refunds and surcharges received). As such, we now cap the Bundler surcharge, only in the case of all solvers failing, to a max of 80% of the metacall gas cost. The remaining 20% may be made up through storage refunds.

If the max is exceeded, the excess is instead taken as Atlas gas surcharge.

@BenSparksCode BenSparksCode marked this pull request as ready for review September 11, 2024 15:55
@BenSparksCode BenSparksCode marked this pull request as draft September 11, 2024 15:56
Copy link
Contributor

@jj1980a jj1980a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@BenSparksCode BenSparksCode merged commit 54a6c98 into atlas-v1.1 Oct 17, 2024
3 checks passed
@BenSparksCode BenSparksCode deleted the solver-surcharge-tracking branch October 17, 2024 12:56
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.

3 participants