Skip to content

Commit

Permalink
feat: add bidAmount to SolverTxResult event
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Nov 6, 2024
1 parent 3a4972d commit 17e81f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/contracts/atlas/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ abstract contract Escrow is AtlETH {

if (_result.executionSuccessful()) {
// First successful solver call that paid what it bid
emit SolverTxResult(solverOp.solver, solverOp.from, true, true, _result);
emit SolverTxResult(solverOp.solver, solverOp.from, true, true, _result, bidAmount);

ctx.solverSuccessful = true;
ctx.solverOutcome = uint24(_result);
Expand All @@ -221,7 +221,7 @@ abstract contract Escrow is AtlETH {
// Account for failed SolverOperation gas costs
_handleSolverAccounting(solverOp, _gasWaterMark, _result, !prevalidated);

emit SolverTxResult(solverOp.solver, solverOp.from, _result.executedWithError(), false, _result);
emit SolverTxResult(solverOp.solver, solverOp.from, _result.executedWithError(), false, _result, bidAmount);

return 0;
}
Expand Down
7 changes: 6 additions & 1 deletion src/contracts/types/AtlasEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ contract AtlasEvents {

// Escrow events
event SolverTxResult(
address indexed solverTo, address indexed solverFrom, bool executed, bool success, uint256 result
address indexed solverTo,
address indexed solverFrom,
bool executed,
bool success,
uint256 result,
uint256 bidAmount
);

// Factory events
Expand Down
14 changes: 8 additions & 6 deletions test/Escrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ contract EscrowTest is BaseTest {
uint256 private constant _SOLVER_GAS_BUFFER = 5; // out of 100
uint256 private constant _FASTLANE_GAS_BUFFER = 125_000; // integer amount

event MEVPaymentSuccess(address bidToken, uint256 bidAmount);
event SolverTxResult(
address indexed solverTo, address indexed solverFrom, bool executed, bool success, uint256 result
);

function defaultCallConfig() public returns (CallConfigBuilder) {
return new CallConfigBuilder();
}
Expand Down Expand Up @@ -662,7 +657,14 @@ contract EscrowTest is BaseTest {
DAppOperation memory dappOp = validDAppOperation(userOp, solverOps).build();

vm.expectEmit(false, false, false, true, address(atlas));
emit SolverTxResult(solverOps[0].solver, solverOps[0].from, solverOpExecuted, solverOpSuccess, expectedResult);
emit AtlasEvents.SolverTxResult(
solverOps[0].solver,
solverOps[0].from,
solverOpExecuted,
solverOpSuccess,
expectedResult,
solverOps[0].bidAmount
);

vm.prank(userEOA);
if (metacallShouldRevert) vm.expectRevert(); // Metacall should revert, the reason isn't important, we're only checking the event
Expand Down
6 changes: 3 additions & 3 deletions test/FlashLoan.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ contract FlashLoanTest is BaseTest {
vm.startPrank(userEOA);
vm.expectEmit(true, true, true, true);
uint256 result = (1 << uint256(SolverOutcome.BidNotPaid));
emit AtlasEvents.SolverTxResult(address(solver), solverOneEOA, true, false, result);
emit AtlasEvents.SolverTxResult(address(solver), solverOneEOA, true, false, result, solverOps[0].bidAmount);
vm.expectRevert();
atlas.metacall({ userOp: userOp, solverOps: solverOps, dAppOp: dAppOp });
vm.stopPrank();
Expand Down Expand Up @@ -153,7 +153,7 @@ contract FlashLoanTest is BaseTest {
vm.expectEmit(true, true, true, true);
result = (1 << uint256(SolverOutcome.CallValueTooHigh));
console.log("result", result);
emit AtlasEvents.SolverTxResult(address(solver), solverOneEOA, false, false, result);
emit AtlasEvents.SolverTxResult(address(solver), solverOneEOA, false, false, result, solverOps[0].bidAmount);
vm.expectRevert();
atlas.metacall({ userOp: userOp, solverOps: solverOps, dAppOp: dAppOp });
vm.stopPrank();
Expand Down Expand Up @@ -213,7 +213,7 @@ contract FlashLoanTest is BaseTest {
vm.startPrank(userEOA);
result = 0;
vm.expectEmit(true, true, true, true);
emit AtlasEvents.SolverTxResult(_solver, solverOneEOA, true, true, result);
emit AtlasEvents.SolverTxResult(_solver, solverOneEOA, true, true, result, solverOps[0].bidAmount);
atlas.metacall({ userOp: userOp, solverOps: solverOps, dAppOp: dAppOp });
vm.stopPrank();

Expand Down

0 comments on commit 17e81f2

Please sign in to comment.