Developers
Swap
Verified Pools currently utilize the Uniswap Universal Router as the main entrypoint for executing swaps. We recommend that developers start with the Universal Router when integrating swaps. For use cases that require a custom router, please see Integrating with a Custom Router.
The Universal Router is an ETH, ERC20 and NFT swap router that allows users greater flexibility when performing trades across multiple token types and pools. The flexible command style allows it to provide users with:
- Splitting and interleaving of Uniswap trades across pools
- Partial fills of trades
- Wrapping and Unwrapping of ETH
- Time-bound, signature controlled token approvals using Permit2
Transactions are encoded using a string of commands, allowing users to have maximum flexibility over what they want to perform.
When getting started with the Universal Router, we recommend that you utilize the official Uniswap documentation and tools, including their universal-router-sdk which is available in TypeScript:
- Universal Router - Overview
- Universal Router - Swap Routing Guide
- Universal Router - Github Repo
- Universal Router - TypeScript SDK
Integrating with the Universal Router
Integrators can build transactions where the transacting user interacts directly with the UniversalRouter. In these transactions, the `msg.sender` would be the transacting user as there is no intermediate contract between the user and the router. These transactions will be successful as long as the user has a valid set of verifications.
Note that when passing the hookData as part of the built transaction, no data is required and the value can be left as “”.
Before submitting a transaction, the user’s address can be verified using the correct policy contract to ensure that the user has been sufficiently verified to interact with the pool.
Integrating with a Custom Router
There are two possible scenarios which are both supported:
- A custom routing contract interacts with the Uniswap V4 PoolManager directly
- A custom routing contract interacts with the UniversalRouter
In both scenarios, the routing contract will need to implement the following interface:
interface IMessageSender {
function msgSender() external view returns (address);
}
This function must return the address of the user initiating the swap.
The routing contract must be approved before it will be able to interact with any of the Verified Pools. To onboard a custom router contract, please reach out to [email protected].