Skip to content

V4 support beta#418

Open
liquid-8 wants to merge 157 commits into
masterfrom
dev/v4-fin
Open

V4 support beta#418
liquid-8 wants to merge 157 commits into
masterfrom
dev/v4-fin

Conversation

@liquid-8
Copy link
Copy Markdown
Member

Basic functionality, like price fetching, quoting, and making simple swaps etc

@liquid-8 liquid-8 linked an issue Jan 5, 2026 that may be closed by this pull request
Pool manager contract ABI
Liquidity pools list management class added, UniswapV4 improvements.
Copy link
Copy Markdown
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Generally approved. Haven't checked why CI is failing yet.

Could use some auto-formatting by ruff.

@ErikBjare
Copy link
Copy Markdown
Member

Ah, I see CI is failing due to outdated actions. I think we can merge this and address the outdated CI and any CI issues related to this PR in follow-up.

Comment thread uniswap/configs/chains.ini Outdated
Comment thread uniswap/uniswap4.py Outdated
@liquid-8
Copy link
Copy Markdown
Member Author

@greptileai review

Comment thread uniswap/uniswap4.py Outdated
@liquid-8
Copy link
Copy Markdown
Member Author

liquid-8 commented May 4, 2026

@greptileai review

Comment thread uniswap/uniswap4.py
Comment thread uniswap/uniswap4.py
Comment thread uniswap/constants.py
Comment thread uniswap/constants.py
liquid-8 and others added 3 commits May 14, 2026 20:20
…niversal router' commands and actions ABIs clarified
Add custom transactions' nonce; custom delay time within approve(); universal router' commands and actions ABIs clarified
Comment thread uniswap/constants.py
Comment thread uniswap/uniswap4.py
Comment thread uniswap/uniswap4.py
Comment on lines +861 to +865
function = self.position_manager.functions.permit(
owner, astuple(permit_single), spender, sig_deadline, signature
)
tx = self._build_and_send_tx(
function, self._get_tx_params(value=payable_amount)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 position_manager_permit2_single dispatches to the wrong permit overload

The function passes 5 arguments to self.position_manager.functions.permit(...): (owner, astuple(permit_single), spender, sig_deadline, signature). The PositionManager ABI only has two permit overloads — a 5-arg ERC721 permit (spender, tokenId, deadline, nonce, sig) and a 3-arg Permit2 single permit (owner, PermitSingle, signature). Web3.py will attempt to match the 5-arg call to the ERC721 overload, where the second argument is tokenId: uint256, but astuple(permit_single) is a tuple — ABI encoding will raise a TypeError at runtime. The spender and sig_deadline parameters are already encoded inside permit_single; the correct call is permit(owner, astuple(permit_single), signature) with 3 arguments.

Suggested change
function = self.position_manager.functions.permit(
owner, astuple(permit_single), spender, sig_deadline, signature
)
tx = self._build_and_send_tx(
function, self._get_tx_params(value=payable_amount)
def position_manager_permit2_single(
self,
owner: str,
permit_single: PermitSingle,
signature: bytes,
payable_amount: int,
) -> HexBytes:
"""
Allows forwarding a single permit to permit2
"""
function = self.position_manager.functions.permit(
owner, astuple(permit_single), signature
)

Comment thread uniswap/uniswap4.py
Comment on lines +1587 to +1591
else:
result = self.get_quote_exact_output(token0, qty, route)
return result

# Swap functions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Multi-hop exact-output quote passes the input token as exactCurrency

get_quote_exact_output is called with token0 (the input/selling token) as its first argument, but the Quoter contract's quoteExactOutput struct field is exactCurrency — the output token (the one being received). For a single-hop call, get_quote_exact_output_single handles ordering internally and is passed both tokens, so that path is fine. For multi-hop, however, token0 is passed where token1 should be, causing the quoter to report the cost of buying the wrong token. The correct call is self.get_quote_exact_output(token1, qty, route).

Suggested change
else:
result = self.get_quote_exact_output(token0, qty, route)
return result
# Swap functions
else:
result = self.get_quote_exact_output(token1, qty, route)
return result
# Swap functions

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.

Uniswap v4 support

3 participants