Skip to content

Commit

Permalink
[TokenPaymaster] Support chains without WETH9
Browse files Browse the repository at this point in the history
For chains like Celo we can swap directly to it without unwrapping
  • Loading branch information
0xFirekeeper committed Oct 30, 2024
1 parent cf51bfa commit 91dbdaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions contracts/prebuilts/account/utils/UniswapHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ abstract contract UniswapHelper {
uint256 minSwapAmount;
uint24 uniswapPoolFee;
uint8 slippage;
bool wethIsNativeAsset;
}

/// @notice The Uniswap V3 SwapRouter contract
Expand Down Expand Up @@ -85,6 +86,9 @@ abstract contract UniswapHelper {
}

function unwrapWeth(uint256 amount) internal {
if (uniswapHelperConfig.wethIsNativeAsset) {
return;
}
IPeripheryPayments(address(uniswap)).unwrapWETH9(amount, address(this));
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/smart-wallet/token-paymaster/TokenPaymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ contract TokenPaymasterTest is BaseTest {
UniswapHelper.UniswapHelperConfig memory uniswapHelperConfig = UniswapHelper.UniswapHelperConfig({
minSwapAmount: 1,
slippage: 5,
uniswapPoolFee: 3
uniswapPoolFee: 3,
wethIsNativeAsset: false
});

paymaster = new TokenPaymaster(
Expand Down

0 comments on commit 91dbdaa

Please sign in to comment.