Skip to content

Commit

Permalink
feat: apply max bundler refund if no winning solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Oct 16, 2024
1 parent a9b4cbf commit 74cf073
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/contracts/atlas/GasAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,16 @@ abstract contract GasAccounting is SafetyLocks {
// If no successful solvers, only collect partial surcharges from solver's fault failures (if any)
uint256 _solverSurcharge = solverSurcharge();
if (_solverSurcharge > 0) {
// NOTE: This only works when BUNDLER_SURCHARGE > ATLAS_SURCHARGE.
netAtlasGasSurcharge = _solverSurcharge.getAtlasPortionFromTotalSurcharge();

// When no winning solvers, bundler max refund is 80% of metacall gas cost. The remaining 20% can be
// collected through storage refunds. Any excess bundler surcharge is instead taken as Atlas surcharge.
uint256 _bundlerSurcharge = _solverSurcharge - netAtlasGasSurcharge;
uint256 _maxBundlerRefund = adjustedClaims.withoutBundlerSurcharge().maxBundlerRefund();
if (_bundlerSurcharge > _maxBundlerRefund) {
netAtlasGasSurcharge += _bundlerSurcharge - _maxBundlerRefund;
}

adjustedWithdrawals += netAtlasGasSurcharge;
S_cumulativeSurcharge = _surcharge + netAtlasGasSurcharge;
}
Expand Down

0 comments on commit 74cf073

Please sign in to comment.