Created
May 28, 2023 20:40
-
-
Save BlockmanCodes/1b15ccb1f5e151938d47dbc240f1c479 to your computer and use it in GitHub Desktop.
Uniswap V3: Listen for liquidity events on pools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ethers = require('ethers') | |
const v3PoolArtifact = require("@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json") | |
const poolAddresses = [ | |
'0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640', // USDC/ETH 0.05% | |
'0xcbcdf9626bc03e24f779434178a73a0b4bad62ed', // WBTC/ETH 0.3% | |
'0x5777d92f208679db4b9778590fa3cab3ac9e2168', // DAI/USDC 0.01% | |
'0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8', // USDC/ETH 0.3% | |
'0x4585fe77225b41b697c938b018e2ac67ac5a20c0', // WBTC/ETH 0.05% | |
'0xc63b0708e2f7e69cb8a1df0e1389a98c35a76d52', // FRAX/USDC 0.05% | |
'0x3416cf6c708da44db2624d63ea0aaef7113527c6', // USDC/USDT 0.01% | |
'0x7379e81228514a1d2a6cf7559203998e20598346', // ETH/sETH2 0.3% | |
'0x6c6bc977e13df9b0de53b251522280bb72383700', // DAI/USDC 0.05% | |
'0x4e68ccd3e89f51c3074ca5072bbac773960dfa36', // ETH/USDT 0.3% | |
'0x11b815efb8f581194ae79006d24e0d814b7697f6', '0x99ac8ca7087fa4a2a1fb6357269965a2014abc35', '0x840deeef2f115cf50da625f7368c24af6fe74410', | |
'0x7bea39867e4169dbe237d55c8242a8f2fcdcc387', '0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801', '0x5c128d25a21f681e678cb050e551a895c9309945', | |
'0x97e7d56a0408570ba1a7852de36350f7713906ec', '0x40e629a26d96baa6d81fae5f97205c2ab2c1ff29', '0xa6cc3c2531fdaa6ae1a3ca84c2855806728693e8', | |
'0xc5af84701f98fa483ece78af83f11b6c38aca71d', '0x64a078926ad9f9e88016c199017aea196e3899e1', '0xe931b03260b2854e77e8da8378a1bc017b13cb97', | |
'0xf56d08221b5942c428acc5de8f78489a97fc5599', '0xc2e9f25be6257c210d7adf0d4cd6e3e881ba25f8', '0x9db9e0e53058c89e5b94e29621a205198648425b', | |
'0x290a6a7460b308ee3f19023d2d00de604bcf5b42', '0xe42318ea3b998e8355a3da364eb9d48ec725eb45', '0xa3f558aebaecaf0e11ca4b2199cc5ed341edfd74', | |
'0x7858e59e0c01ea06df3af3d20ac7b0003275d4bf', '0x6c4c7f46d9d4ef6bc5c9e155f011ad19fc4ef321', | |
] | |
const provider = new ethers.JsonRpcProvider('https://mainnet.infura.io/v3/abc') | |
poolAddresses.map(async address => { | |
const pool = new ethers.Contract(address, v3PoolArtifact.abi, provider) | |
await pool.on('Mint', (sender, owner, tickLower, tickUpper, amount, _amount0, _amount1) => { | |
console.log( | |
'Mint', '|', | |
'Address', address, '|', | |
'ticks:', tickLower, '-', tickUpper, '|', | |
'amount:', amount | |
) | |
}) | |
await pool.on('Collect', (owner, tickLower, tickUpper, amount0, amount1) => { | |
console.log( | |
'Collect', '|', | |
'Address', address, '|', | |
'ticks:', tickLower, '-', tickUpper, '|', | |
'amount0:', amount0, '|', | |
'amount1:', amount1, | |
) | |
}) | |
await pool.on('Burn', (owner, tickLower, tickUpper, amount, _amount0, _amount1) => { | |
console.log( | |
'Burn', '|', | |
'Address', address, '|', | |
'ticks:', tickLower, '-', tickUpper, '|', | |
'amount:', amount | |
) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @BlockmanCodes!