Skip to content

Commit

Permalink
Merge pull request #458 from FastLane-Labs/simplify-gas-beneficiary
Browse files Browse the repository at this point in the history
refactor: simplify gas beneficiary logic
  • Loading branch information
BenSparksCode authored Nov 18, 2024
2 parents fcb02f3 + fe2fb3d commit 8127c01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
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

0 comments on commit 8127c01

Please sign in to comment.