Swap (Uniswap V3) event signature and topic0
The topic0 of the Swap (Uniswap V3) event is 0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67, the keccak-256 hash of Swap(address,address,int256,int256,uint160,uint128,int24); 2 of its 7 arguments are indexed. Swap on a Uniswap V3-style pool.
Topics
- topic00xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67keccak256("Swap(address,address,int256,int256,uint160,uint128,int24)")
- topic1sender (address)indexed: filterable
- topic2recipient (address)indexed: filterable
Data
- dataamount0 (int256), amount1 (int256), sqrtPriceX96 (uint160), liquidity (uint128), tick (int24)ABI-encoded, decoded with the ABI
Arguments and where they sit in the log
Indexed arguments travel as topics and can be filtered cheaply; the others are ABI-encoded together in the data.
| Name | Type | In the log |
|---|---|---|
| sender | address | topic1 |
| recipient | address | topic2 |
| amount0 | int256 | data |
| amount1 | int256 | data |
| sqrtPriceX96 | uint160 | data |
| liquidity | uint128 | data |
| tick | int24 | data |
Solidity declaration
event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick);
Canonical signature
Swap(address,address,int256,int256,uint160,uint128,int24)
topic0
0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67
Get an alert on Swap
Each rule opens with the contract and the conditions filled in. Sign in, pick your chat and click Create.
Contracts we list that emit Swap
Any other contract with the same signature emits a log with the same topic0.
Read Swap logs in code
The same filter in viem, ethers and plain JSON-RPC, and the Solidity that emits it. The address is Uniswap V3 USDC/WETH 0.05% pool, a contract we list that emits it.
import { createPublicClient, http, parseAbiItem } from "viem"
import { mainnet } from "viem/chains"
const client = createPublicClient({ chain: mainnet, transport: http() })
const logs = await client.getLogs({
address: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
event: parseAbiItem("event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)"),
fromBlock: "latest",
})
for (const log of logs) console.log(log.args) // { sender, recipient, amount0, amount1, sqrtPriceX96, liquidity, tick }import { Interface, JsonRpcProvider } from "ethers"
const provider = new JsonRpcProvider(process.env.RPC_URL)
const iface = new Interface(["event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)"])
const logs = await provider.getLogs({
address: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
topics: [iface.getEvent("Swap")!.topicHash],
})
for (const log of logs) console.log(iface.parseLog(log)?.args){
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getLogs",
"params": [
{
"address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
"topics": [
"0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67"
],
"fromBlock": "latest"
}
]
}event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick);
// inside a function:
emit Swap(sender, recipient, amount0, amount1, sqrtPriceX96, liquidity, tick);An example Swap log, encoded and decoded
Placeholder values, not a real transaction: how each argument is stored in the topics and the data, and what decoding gives back.
- topic0keccak256("Swap(address,address,int256,int256,uint160,uint128,int24)")0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67
- topic1sender0x0000000000000000000000001111111111111111111111111111111111111111
- topic2recipient0x0000000000000000000000002222222222222222222222222222222222222222
- data0x0000000000000000000000000000000000000000000000000000000000000bb80000000000000000000000000000000000000000000000000000000000000fa0000000000000000000000000000000000000000000000000000000000000138800000000000000000000000000000000000000000000000000000000000017700000000000000000000000000000000000000000000000000000000000001b58
- senderaddress · indexed0x1111111111111111111111111111111111111111
- recipientaddress · indexed0x2222222222222222222222222222222222222222
- amount0int2563000
- amount1int2564000
- sqrtPriceX96uint1605000
- liquidityuint1286000
- tickint247000
Frequently asked questions
What is the topic0 of the Swap (Uniswap V3) event?
0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67: the keccak-256 hash of Swap(address,address,int256,int256,uint160,uint128,int24).
Which Swap (Uniswap V3) arguments are indexed?
sender, recipient are indexed and sit in the log's topics; amount0, amount1, sqrtPriceX96, liquidity, tick are in the data.
How do I get an alert when a contract emits Swap (Uniswap V3)?
Open one of the ready-made rules on this page, or add any contract and pick Swap (Uniswap V3) from the event list. Conditions can be set on indexed and non-indexed arguments, and each alert names the contract and links to the transaction.
More event signatures and tools
Know the moment a contract emits it
The Beta plan is free: one wallet and one contract, no credit card.