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

Recipient mapping! #246

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
gas tests
  • Loading branch information
hensha256 committed Aug 2, 2024
commit 77ae9c7484a2744fda6e19918947d28a756f8115
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
134575
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
127370
39 changes: 35 additions & 4 deletions test/router/Payments.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract PaymentsTests is RoutingTestHelpers, GasSnapshot {
plan = Planner.init();
}

function test_gas_swap_settleFromCaller_takeAll() public {
function test_gas_swap_settleFromCaller_takeAllToSpecifiedAddress() public {
uint256 amountIn = 1 ether;
IV4Router.ExactInputSingleParams memory params =
IV4Router.ExactInputSingleParams(key0, true, uint128(amountIn), 0, 0, bytes(""));
Expand All @@ -29,10 +29,24 @@ contract PaymentsTests is RoutingTestHelpers, GasSnapshot {

bytes memory data = plan.encode();
router.executeActions(data);
snapLastCall("Payments_swap_settleFromCaller_takeAll");
snapLastCall("Payments_swap_settleFromCaller_takeAllToSpecifiedAddress");
}

function test_gas_swap_settleFromRouter_takeAll() public {
function test_gas_swap_settleFromCaller_takeAllToMsgSender() public {
uint256 amountIn = 1 ether;
IV4Router.ExactInputSingleParams memory params =
IV4Router.ExactInputSingleParams(key0, true, uint128(amountIn), 0, 0, bytes(""));

plan = plan.add(Actions.SWAP_EXACT_IN_SINGLE, abi.encode(params));
plan = plan.add(Actions.SETTLE_ALL, abi.encode(key0.currency0));
plan = plan.add(Actions.TAKE_ALL, abi.encode(key0.currency1, Actions.MSG_SENDER));

bytes memory data = plan.encode();
router.executeActions(data);
snapLastCall("Payments_swap_settleFromCaller_takeAllToMsgSender");
}

function test_gas_swap_settleWithBalance_takeAllToSpecifiedAddress() public {
uint256 amountIn = 1 ether;
IV4Router.ExactInputSingleParams memory params =
IV4Router.ExactInputSingleParams(key0, true, uint128(amountIn), 0, 0, bytes(""));
Expand All @@ -46,6 +60,23 @@ contract PaymentsTests is RoutingTestHelpers, GasSnapshot {

bytes memory data = plan.encode();
router.executeActions(data);
snapLastCall("Payments_swap_settleFromRouter_takeAll");
snapLastCall("Payments_swap_settleWithBalance_takeAllToSpecifiedAddress");
}

function test_gas_swap_settleWithBalance_takeAllToMsgSender() public {
uint256 amountIn = 1 ether;
IV4Router.ExactInputSingleParams memory params =
IV4Router.ExactInputSingleParams(key0, true, uint128(amountIn), 0, 0, bytes(""));

// seed the router with tokens
key0.currency0.transfer(address(router), amountIn);

plan = plan.add(Actions.SWAP_EXACT_IN_SINGLE, abi.encode(params));
plan = plan.add(Actions.SETTLE_WITH_BALANCE, abi.encode(key0.currency0));
plan = plan.add(Actions.TAKE_ALL, abi.encode(key0.currency1, Actions.MSG_SENDER));

bytes memory data = plan.encode();
router.executeActions(data);
snapLastCall("Payments_swap_settleWithBalance_takeAllToMsgSender");
}
}
Loading