Skip to main content

Uniswap Token Pair / Pool Created

Updated on
Dec 14, 2023

Overview

Uniswap is a decentralized cryptocurrency exchange (DEX) that operates based on liquidity providers funding a "pool" of tokens and setting the initial price. Once the pool is funded and price is set, the trading pair is available for users to begin executing trades. To be the among the first to know when a new token pair is available on Uniswap, use the following QuickAlert expressions.

Uniswap deploys immutable smart contracts, meaning they are not upgradeable. Therefore, when they want to make enhancements, it requires a new smart contract. Below we'll cover how to track the creation of new pairs / pools on both Uniswap V3 and V2. While it is possible to create an expression that tracks both versions, it is advised that you set up separate alerts going to different webhook URLs. This is because the event formats are different and you don't want your backend to duplicate the logic we've implemented in the expressions.

To learn more about pools and how Uniswap works, check out thier documentation.

Uniswap v3 Contract

Launched in May of 2021, Uniswap's v3 contract became the latest deployment of their DEX. As of the time of writing, Uniswap v3 accounts for over 90% of the trading volume across the platform.

To create our expression, we will need to target two values:

  1. The Uniswap v3 contract address - For v3, the Uniswap team deployed their contract on a handful of chains (full documentation from Uniswap). This value gets set as the tx_logs_address, as we will be looking for transactions the originate from this address (the contract).
  2. The event the contract emits when the action we're interested in occurs - In the case of the v3 contract, it is the PoolCreated event (event documentation from Uniswap). On EVM blockchains, the event is encoded and can be found in tx_logs_topic0. To get the encoded value, you will need to take the event definition (event name and parameters' types), run it through the Keccak-256 hash function, and prefix it with 0x.
PoolCreated(address,address,uint24,int24,address)

783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118

0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118
Expression
Deploy
1
tx_logs_address == '0x1F98431c8aD98523631AE4a59f267346ea31F984'
2
&&
3
tx_logs_topic0 == '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118'

Uniswap v2 Contract

While the migration to v3 began years ago, as of the time of this writing, Uniswap v2 still accounts for 80% of weekly trades. Staying abreast of the latest events on v2 is just as critical as v3.

To create our expression, we will need to target two values:

  1. The Uniswap v2 contract address - For v2, the Uniswap team only deployed their contract on Ethereum mainnet and testnets (full documentation from Uniswap). This value gets set as the tx_logs_address, as we will be looking for any transactions from this address (the contract).
  2. The event the contract emits when the action we're interested in occurs - In the case of the v2 contract, it is the PairCreated event (event documentation from Uniswap). On EVM blockchains, the event is encoded and can be found in tx_logs_topic0. To get the encoded value, you will need to take the event definition (event name and parameters' types), run it through the Keccak-256 hash function, and prefix it with 0x.
PairCreated(address,address,address,uint256)

0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9

0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9
Expression
Deploy
1
tx_logs_address == '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'
2
&&
3
tx_logs_topic0 == '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9'
Share this doc