Skip to content

Instantly share code, notes, and snippets.

@gayleQN
Created May 28, 2025 19:56
Show Gist options
  • Save gayleQN/94879643798ca9aa169065d69162251a to your computer and use it in GitHub Desktop.
Save gayleQN/94879643798ca9aa169065d69162251a to your computer and use it in GitHub Desktop.
Uniswap V2/V3 pool creation Telegram Bot: QuickNode Streams filter code
function main(payload) {
const CONFIG = {
CHAT_ID: "<your_chat_id>",
SCAN_BASE_URL: "https://etherscan.io",
POOL_ABI: [
{
anonymous: false,
inputs: [
{ indexed: true, name: "token0", type: "address" },
{ indexed: true, name: "token1", type: "address" },
{ indexed: false, name: "pair", type: "address" },
{ indexed: false, name: "allPairsLength", type: "uint256" }
],
name: "PairCreated",
type: "event"
},
{
anonymous: false,
inputs: [
{ indexed: true, name: "token0", type: "address" },
{ indexed: true, name: "token1", type: "address" },
{ indexed: true, name: "fee", type: "uint24" },
{ indexed: false, name: "tickSpacing", type: "int24" },
{ indexed: false, name: "pool", type: "address" }
],
name: "PoolCreated",
type: "event"
}
]
};
const abis = [CONFIG.POOL_ABI];
const base = CONFIG.SCAN_BASE_URL;
const allDecoded = payload.data
.flatMap(block => {
const receipts = Array.isArray(block.receipts) ? block.receipts : [];
return decodeEVMReceipts(receipts, abis);
})
.filter(decoded => decoded.decodedLogs?.length > 0);
if (allDecoded.length === 0) {
return null;
}
const messages = [];
allDecoded.forEach(({ decodedLogs }) => {
decodedLogs.forEach(log => {
const isV2 = log?.name === 'PairCreated';
const isV3 = log?.name === 'PoolCreated';
if ((isV2 || isV3) && log.token0 && log.token1) {
const token0 = `[token0](${base}/address/${log.token0})`;
const token1 = `[token1](${base}/address/${log.token1})`;
const poolAddress = isV2 ? log.pair : log.pool;
const pool = `[pool](${base}/address/${poolAddress})`;
const tx = `[tx](${base}/tx/${log.transactionHash})`;
const msg = isV2
? `🟢 *New UniV2 Pool Created*\n${token0} + ${token1} → ${pool}\n${tx}`
: `🔵 *New UniV3 Pool Created*\n${token0} + ${token1} (fee: ${log.fee}) → ${pool}\n${tx}`;
messages.push(msg);
}
});
});
return {
chat_id: CONFIG.CHAT_ID,
text: messages.join('\n\n'),
parse_mode: "Markdown"
};
}
@gayleQN
Copy link
Author

gayleQN commented May 28, 2025

Visit https://dashboard.quicknode.com/streams/new to create your stream

Dataset: Block with Receipts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment