Skip to main content
In this tutorial, we’ll show you how to set up a Tenderly Web3 Action to monitor new pool creations in the UniswapV3Factory contract and perform automated actions. This project demonstrates how to use Web3 Actions to interact with smart contracts and Tenderly’s features to create a custom monitoring system.

UniswapV3Factory monitoring Web3 Action template

Project Overview

The purpose of this project is to set up a system that monitors new pool creations in the UniswapV3Factory contract and performs automated actions when specific conditions are met. Here’s a quick breakdown of the project’s flow:
  1. The Web3 Action listens for PoolCreated events from the UniswapV3Factory contract on the Ethereum mainnet.
  2. When an event is detected, it extracts the new pool’s address from the event data.
  3. The action adds the new pool contract to your Tenderly project and tags it for easier management.

Prerequisites

Before you begin, make sure you have the following:

Setup

Let’s go through the steps to set up your UniswapV3Factory Monitoring system:

How it Works

The Web3 Action you’ve set up will automatically trigger whenever the PoolCreated event is emitted by the UniswapV3Factory contract. Here’s a breakdown of the actionFn function:
  1. Retreive the ACCESS-KEY secret from the Tenderly context.
  2. Initialize a new Tenderly SDK instance with your account and project details.
  3. Define the PoolCreated event signature using ethers.js.
  4. Loop through the event logs to find the PoolCreated event and extracts the new pool’s address.
  5. Using the Tenderly SDK, add the new pool contract to your Tenderly project with the display name Pool.
  6. Tag the new pool contract with the pool tag for easier management.
  7. Log the pool address and confirmation of the tagging process.
This implementation automatically adds new Uniswap V3 pools to your Tenderly project and tags them, making it easier to monitor and manage these contracts.

Customization

To modify the behavior of your Web3 Action:
  1. Edit the actionFn in the uniswapV3Monitoring.ts file.
  2. You can change the tagName variable to use a different tag for the pools.
  3. Add additional logic to process more information from the event or perform other actions with the Tenderly SDK.
For example, to add more detailed logging:

Monitoring and Troubleshooting

To ensure your Web3 Action is working correctly:
  • Monitor your Web3 Action executions in the Tenderly dashboard
  • Check the Tenderly logs for any error messages or execution details
  • Use Tenderly’s debugging tools to inspect transaction details and contract interactions
  • Check your Tenderly project’s Contracts page to see the newly added and tagged pool contracts
This setup is specifically designed to monitor the UniswapV3Factory contract on the Ethereum mainnet.

Conclusion

You’ve now set up a custom monitoring system using Tenderly Web3 Actions to track new pool creations in the UniswapV3Factory contract. This project demonstrates how to interact with smart contracts, use Tenderly’s SDK, and create an automated system for monitoring and responding to specific blockchain events. For more information on Uniswap V3 and its contracts, refer to the Uniswap V3 documentation.