forked from https://github.com/0ximmeas/univ4-swap-walkthrough
This is a simple contract that allows you to swap between two tokens using the Uniswap V4 protocol.
The contract supports swapExactInputSingle
using a PoolKey
and swapExactInput
using a PathKey
array.
This contract is designed to be intergrated with inside of the Super DCA Pool contracts. It can be integrated in Solidity as follows:
- One time token approval for the contract to spend the token.
swapContract.approveTokenWithPermit2(tokenAddress, amount, expiration);
- Transfer the token to the contract and call the swap function (must be one transaction)
inputToken.transfer(address(swapContract), amountIn);
swapContract.swapExactInputSingle(poolKey, zeroForOne, amountIn, minAmountOut, receiver);
Important: The transfer and swap must be in the same call (e.g., inside a multi-call transaction).
Network | Address |
---|---|
Base Sepolia | 0x0000000000000000000000000000000000000000 |
Unichain Sepolia | 0x4779F177d595ad1Dee69034a58A668fc6116aF96. |
$ forge build
$ forge test