Skip to content

Commit

Permalink
solver value for txbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Code0x2 committed Dec 5, 2023
1 parent 0f1fbaf commit 8d2a36c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/contracts/helpers/TxBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ contract TxBuilder {
bytes memory solverOpData,
address solverEOA,
address solverContract,
uint256 bidAmount
uint256 bidAmount,
uint256 value
)
public
view
Expand All @@ -90,7 +91,7 @@ contract TxBuilder {
solverOp = SolverOperation({
from: solverEOA,
to: atlas,
value: 0,
value: value,
gas: gas,
maxFeePerGas: userOp.maxFeePerGas,
deadline: userOp.deadline,
Expand Down
3 changes: 2 additions & 1 deletion test/Accounting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ contract AccountingTest is BaseTest {
solverOpData: solverOpData,
solverEOA: solverOneEOA,
solverContract: rfqSolver,
bidAmount: solverMsgValue
bidAmount: solverMsgValue,
value: 0
});

solverOps[0].value = solverMsgValue;
Expand Down
3 changes: 1 addition & 2 deletions test/FlashLoan.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ contract FlashLoanTest is BaseTest {
vm.stopPrank();

// Input params for Atlas.metacall() - will be populated below
DAppOperation memory dAppOp;

vm.startPrank(userEOA);
address executionEnvironment = atlas.createExecutionEnvironment(txBuilder.control());
Expand All @@ -59,7 +58,7 @@ contract FlashLoanTest is BaseTest {

UserOperation memory userOp = txBuilder.buildUserOperation({
from: userEOA, // NOTE: Would from ever not be user?
to: address(DummyController),
to: address(controller),
maxFeePerGas: tx.gasprice + 1, // TODO update
value: 0,
deadline: block.number + 2,
Expand Down
8 changes: 4 additions & 4 deletions test/MainTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ contract MainTest is BaseTest {
// First SolverOperation
solverOpData = helper.buildV2SolverOperationData(POOL_TWO, POOL_ONE);
solverOps[1] = helper.buildSolverOperation(
userOp, solverOpData, solverOneEOA, address(solverOne), WETH.balanceOf(address(solverOne)) / 20
userOp, solverOpData, solverOneEOA, address(solverOne), WETH.balanceOf(address(solverOne)) / 20, 0
);

(v, r, s) = vm.sign(solverOnePK, atlasVerification.getSolverPayload(solverOps[1]));
Expand All @@ -68,7 +68,7 @@ contract MainTest is BaseTest {
// Second SolverOperation
solverOpData = helper.buildV2SolverOperationData(POOL_ONE, POOL_TWO);
solverOps[0] = helper.buildSolverOperation(
userOp, solverOpData, solverTwoEOA, address(solverTwo), WETH.balanceOf(address(solverTwo)) / 3000
userOp, solverOpData, solverTwoEOA, address(solverTwo), WETH.balanceOf(address(solverTwo)) / 3000, 0
);

(v, r, s) = vm.sign(solverTwoPK, atlasVerification.getSolverPayload(solverOps[0]));
Expand Down Expand Up @@ -368,7 +368,7 @@ contract MainTest is BaseTest {

// Success case
bytes memory solverOpData = helper.buildV2SolverOperationData(POOL_TWO, POOL_ONE);
solverOps[0] = helper.buildSolverOperation(userOp, solverOpData, solverOneEOA, address(solverOne), 2e17);
solverOps[0] = helper.buildSolverOperation(userOp, solverOpData, solverOneEOA, address(solverOne), 2e17, 0);
(v, r, s) = vm.sign(solverOnePK, atlasVerification.getSolverPayload(solverOps[0]));
solverOps[0].signature = abi.encodePacked(r, s, v);
DAppOperation memory dAppOp = helper.buildDAppOperation(governanceEOA, userOp, solverOps);
Expand All @@ -388,7 +388,7 @@ contract MainTest is BaseTest {
// Failure case
solverOpData = helper.buildV2SolverOperationData(POOL_TWO, POOL_TWO); // this will make the solver operation
// revert
solverOps[0] = helper.buildSolverOperation(userOp, solverOpData, solverOneEOA, address(solverOne), 2e17);
solverOps[0] = helper.buildSolverOperation(userOp, solverOpData, solverOneEOA, address(solverOne), 2e17, 0);
(v, r, s) = vm.sign(solverOnePK, atlasVerification.getSolverPayload(solverOps[0]));
solverOps[0].signature = abi.encodePacked(r, s, v);
dAppOp = helper.buildDAppOperation(governanceEOA, userOp, solverOps);
Expand Down
6 changes: 4 additions & 2 deletions test/SwapIntent.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ contract SwapIntentTest is BaseTest {
solverOpData: solverOpData,
solverEOA: solverOneEOA,
solverContract: address(rfqSolver),
bidAmount: 1e18
bidAmount: 1e18,
value: 0
});

// Solver signs the solverOp
Expand Down Expand Up @@ -261,7 +262,8 @@ contract SwapIntentTest is BaseTest {
solverOpData: solverOpData,
solverEOA: solverOneEOA,
solverContract: address(uniswapSolver),
bidAmount: 1e18
bidAmount: 1e18,
value: 0
});

// Solver signs the solverOp
Expand Down

0 comments on commit 8d2a36c

Please sign in to comment.