Skip to content

Conversation

@marktoda
Copy link
Contributor

@marktoda marktoda commented Aug 22, 2025

Proof of concept for a purist approach of Uniswap V2 style liquidity on Uniswap V4:

  • Every pair has its own fungible ERC20 token
  • reserves are stored as ERC6909 claims on Uniswap V4 for efficient routing across pools
  • Full interface parity with Uniswap V2
  • Possible to build uniswap v2 style routers directly integrating with the pair contract

@marktoda marktoda marked this pull request as draft August 22, 2025 02:44
@marktoda
Copy link
Contributor Author

marktoda commented Aug 22, 2025

swap with tokens could look something like this:

+    function _swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) internal {
+        // settle any raw token balances that we've received
+        uint256 amount0In = _settle(token0);
+        uint256 amount1In = _settle(token1);
+
+        // mint into new claims
+        if (amount0In > 0) poolManager.mint(address(this), token0.toId(), amount0In);
+        if (amount1In > 0) poolManager.mint(address(this), token0.toId(), amount1In);
+
+        // swap input claims for output claims
+        swapClaims(amount0Out, amount1Out, address(this), data);
+
+        // take outputs and send to the recipient
+        if (amount0Out > 0) {
+            poolManager.burn(address(this), token0.toId(), amount0Out);
+            poolManager.take(token0, to, amount0Out);
+        }
+        if (amount1Out > 0) {
+            poolManager.burn(address(this), token1.toId(), amount1Out);
+            poolManager.take(token1, to, amount1Out);
+        }
+    }

@marktoda marktoda marked this pull request as ready for review August 22, 2025 21:52
…on Uniswap V4:

Every pair has its own fungible ERC20 token
reserves are stored as ERC6909 claims on Uniswap V4 for efficient routing across pools
Full interface parity with Uniswap V2
Possible to build uniswap v2 style routers directly integrating with the pair contract
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