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

Add weth wrapping hook #436

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Add weth wrapping hook #436

wants to merge 12 commits into from

Conversation

marktoda
Copy link
Contributor

@marktoda marktoda commented Feb 2, 2025

token wrapper adapter

Overview

This PR introduces a WETH (Wrapped Ether) hook for Uniswap v4, enabling native ETH to WETH conversions directly through v4 pools. The implementation provides a convenient way to wrap and unwrap ETH within a v4 lock / route.

@marktoda marktoda requested a review from hensha256 February 2, 2025 01:57
@marktoda
Copy link
Contributor Author

marktoda commented Feb 2, 2025

Note one constraint of this approach is that the input currency must already exist in poolmanager before the swap call. This could either be from existing standing liquidity or else the user must transfer input assets first

src/base/hooks/BaseTokenWrapperHook.sol Outdated Show resolved Hide resolved
src/base/hooks/BaseTokenWrapperHook.sol Outdated Show resolved Hide resolved
src/base/hooks/BaseTokenWrapperHook.sol Outdated Show resolved Hide resolved
src/base/hooks/BaseTokenWrapperHook.sol Outdated Show resolved Hide resolved
src/base/hooks/BaseTokenWrapperHook.sol Show resolved Hide resolved
src/base/hooks/BaseTokenWrapperHook.sol Show resolved Hide resolved
@marktoda marktoda force-pushed the add-weth-wrapping-hook branch from 73bb4a1 to a13739b Compare February 6, 2025 19:17
)
)
);
deployCodeTo("./foundry-out/WETHHook.sol/WETHHook.default.json", abi.encode(manager, weth), address(hook));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh whats the difference between this and etch? 👀 ive always used etch, never seen this function before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etch you have to have the bytecode inline. best way to get that was to deploy a dummy version and then etch the bytecode over to the right address. but that the dummy version reverts on hook validation - so this lets me skip the dummy deployments tep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants