101 lines
2.5 KiB
TypeScript
Executable File
101 lines
2.5 KiB
TypeScript
Executable File
import { ethers } from 'ethers';
|
|
|
|
import relayerAbi from './abi/RelayerRegistry.abi.json';
|
|
import tornethAbi from './abi/TornadoCash_eth.abi.json';
|
|
|
|
const RPC = 'https://eth.llamarpc.com';
|
|
|
|
// Affected TORN instance
|
|
const tornAddrs = [
|
|
// ETH
|
|
{
|
|
// 1
|
|
addr: '0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936',
|
|
from: 18577000,
|
|
to: 18583515,
|
|
},
|
|
{
|
|
// 10
|
|
addr: '0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF',
|
|
from: 18577000,
|
|
to: 18583515,
|
|
},
|
|
{
|
|
// 100
|
|
addr: '0xA160cdAB225685dA1d56aa342Ad8841c3b53f291',
|
|
from: 18577000,
|
|
to: 18583515,
|
|
},
|
|
|
|
// DAI
|
|
{
|
|
// 10000
|
|
addr: '0x07687e702b410Fa43f4cB4Af7FA097918ffD2730',
|
|
from: 18577000,
|
|
to: 18591849,
|
|
},
|
|
];
|
|
|
|
const relayerAddr = '0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2';
|
|
const relayerFrom = 18577000;
|
|
const relayerTo = 18591849;
|
|
|
|
type BurnInfo = {
|
|
relayer: string;
|
|
toBurn: bigint;
|
|
};
|
|
|
|
async function getBurnInfos() {
|
|
const p = new ethers.JsonRpcProvider(RPC);
|
|
const cont = new ethers.Contract(relayerAddr, relayerAbi, p);
|
|
const filter = cont.filters.StakeBurned();
|
|
|
|
let ret: { [key: string]: BurnInfo } = {};
|
|
const events = await cont.queryFilter(filter, relayerFrom, relayerTo);
|
|
for (const e of events) {
|
|
// decode StakeBurned data
|
|
const [ relayer, toBurn ] = ethers.AbiCoder.defaultAbiCoder().decode(
|
|
['address', 'uint256'],
|
|
e.data
|
|
);
|
|
|
|
ret[e.transactionHash] = {
|
|
relayer,
|
|
toBurn,
|
|
};
|
|
}
|
|
|
|
await p.destroy();
|
|
return ret;
|
|
}
|
|
|
|
async function main() {
|
|
const burnInfo = await getBurnInfos();
|
|
|
|
let relayerLost: { [key: string]: bigint } = {};
|
|
await Promise.all(tornAddrs.map(async ({ addr, from, to }) => {
|
|
const p = new ethers.JsonRpcProvider(RPC);
|
|
const cont = new ethers.Contract(addr, tornethAbi, p);
|
|
const filter = cont.filters.Withdrawal();
|
|
|
|
const events = await cont.queryFilter(filter, from, to);
|
|
for (const e of events) {
|
|
const info = burnInfo[e.transactionHash];
|
|
if (!info) continue;
|
|
|
|
if (!(info.relayer in relayerLost)) {
|
|
relayerLost[info.relayer] = BigInt(0);
|
|
}
|
|
relayerLost[info.relayer] += info.toBurn;
|
|
}
|
|
|
|
await p.destroy();
|
|
}));
|
|
|
|
for (const key in relayerLost) {
|
|
console.log(`${key} = ${relayerLost[key]} // ${ethers.formatEther(relayerLost[key])} TORN`);
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|