Skip to content

Commit

Permalink
gas opt
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipp Makarov authored and Filipp Makarov committed Nov 26, 2024
1 parent 9a77305 commit 240a823
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions contracts/token/swaps/Uniswapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { IV3SwapRouter } from "@uniswap/swap-router-contracts/contracts/interfac
abstract contract Uniswapper {

event SwappingReverted(address tokenIn, uint256 amountIn, bytes reason);
error UnwrappingReverted(uint256 amount);

/// @notice The Uniswap V3 SwapRouter contract
IV3SwapRouter public immutable uniswapRouter;

Expand Down Expand Up @@ -75,7 +77,7 @@ abstract contract Uniswapper {

function _unwrapWeth(uint256 amount) internal {
if(amount == 0) return;
IERC20(wrappedNative).transfer(address(uniswapRouter), amount);
IPeripheryPayments(address(uniswapRouter)).unwrapWETH9(amount, address(this));
(bool success, ) = address(wrappedNative).call(abi.encodeWithSignature("withdraw(uint256)", amount));
if (!success) revert UnwrappingReverted(amount);
}
}
3 changes: 1 addition & 2 deletions test/unit/concrete/TestTokenPaymaster.Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ contract TestTokenPaymasterBase is TestBase {
// IF THIS CASE FAILS ON 2% TOLERANCE => PUT THE FRESH PRICE FROM ORACLE HERE
// https://basescan.org/address/0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70#readContract#F8
// and remove two last digits from the price
//3344583445,
3478381850,
3358580000,
_PRICE_MARKUP_DENOMINATOR,
this.getMaxPenalty(ops[0]),
this.getRealPenalty(ops[0], gasValue, customGasPrice));
Expand Down

0 comments on commit 240a823

Please sign in to comment.