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

refactor: simplify gas beneficiary logic #458

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/contracts/atlas/Atlas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ contract Atlas is Escrow, Factory {
try this.execute(_dConfig, userOp, solverOps, _executionEnvironment, _bundler, dAppOp.userOpHash, _isSimulation)
returns (Context memory ctx) {
// Gas Refund to sender only if execution is successful
(uint256 _ethPaidToBundler, uint256 _netGasSurcharge) = _settle(
ctx, _dConfig.solverGasLimit, gasRefundBeneficiary != address(0) ? gasRefundBeneficiary : msg.sender
);
(uint256 _ethPaidToBundler, uint256 _netGasSurcharge) =
_settle(ctx, _dConfig.solverGasLimit, gasRefundBeneficiary);

auctionWon = ctx.solverSuccessful;
emit MetacallResult(
Expand Down
9 changes: 4 additions & 5 deletions src/contracts/atlas/GasAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ abstract contract GasAccounting is SafetyLocks {
// If a solver won, their address is still in the _solverLock
(address _winningSolver,,) = _solverLockData();

if (gasRefundBeneficiary == address(0)) gasRefundBeneficiary = ctx.bundler;

// Load what we can from storage so that it shows up in the gasleft() calc

uint256 _claims;
Expand Down Expand Up @@ -457,8 +459,9 @@ abstract contract GasAccounting is SafetyLocks {
} else if (_winningSolver == ctx.bundler) {
claimsPaidToBundler = 0;
} else {
// this else block is only executed if there is no successful solver
claimsPaidToBundler = 0;
_winningSolver = ctx.bundler;
_winningSolver = gasRefundBeneficiary;
}

if (_amountSolverPays > _amountSolverReceives) {
Expand All @@ -473,10 +476,6 @@ abstract contract GasAccounting is SafetyLocks {
}
claimsPaidToBundler -= _currentDeficit;
} else {
if (_winningSolver == ctx.bundler) {
_winningSolver = gasRefundBeneficiary;
}

_credit(_winningSolver, _amountSolverReceives - _amountSolverPays, _adjustedClaims);
}

Expand Down
Loading