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

Merged
merged 18 commits into from
Feb 14, 2025
Merged

Add weth wrapping hook #436

merged 18 commits into from
Feb 14, 2025

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 Outdated Show resolved Hide resolved
@marktoda marktoda force-pushed the add-weth-wrapping-hook branch from 73bb4a1 to a13739b Compare February 6, 2025 19:17
test/hooks/WETHHook.t.sol Outdated Show resolved Hide resolved
}

/// @inheritdoc BaseTokenWrapperHook
function withdraw(uint256 wrapperAmount) internal override returns (uint256 underlyingAmount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit but these are internal so would rather _withdraw and _deposit

Copy link
Contributor

Choose a reason for hiding this comment

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

also remove named return variable from both functions because youre never using it and returning a different variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like the named variables are helpful for future implementers, no? I.e. when I make stETH<>ETH hook I will need to do a conversion

Copy link
Contributor

Choose a reason for hiding this comment

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

i think thats true on the abstract base hook (which is what your stETH hook would inherit from), i'm happy for them to remain with names there, because those are abstract functions. But then in this specific implementation contract I'd argue that the named return variable makes it more confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh I thought you were referencing hte abstract

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok fixed

@marktoda marktoda merged commit fdb5d3e into main Feb 14, 2025
5 checks passed
@marktoda marktoda deleted the add-weth-wrapping-hook branch February 14, 2025 20:38
@@ -0,0 +1,185 @@
pragma solidity ^0.8.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

there's no license identifier in this file

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.

3 participants