-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcertus-one-12.02.2013.ts
68 lines (54 loc) · 2.19 KB
/
certus-one-12.02.2013.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { BigNumber } from "ethers";
import { formatEther } from "ethers/lib/utils";
import fetch from "node-fetch";
const possibleBidsAPI = [
`https://boost-relay.flashbots.net/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://bloxroute.max-profit.blxrbdn.com/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://bloxroute.ethical.blxrbdn.com/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://bloxroute.regulated.blxrbdn.com/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://builder-relay-mainnet.blocknative.com/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://relay.edennetwork.io/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://mainnet-relay.securerpc.com/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://relayooor.wtf/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://relay.ultrasound.money/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
`https://agnostic-relay.net/relay/v1/data/bidtraces/builder_blocks_received?slot=`,
];
const slots = [5779529, 5779222, 5778724, 5778576, 5777959, 5777776, 5777482];
const findMaxBid = <T extends { value: string }>(bids: T[]): T => {
return bids.reduce(
(max, cur) => {
if (BigNumber.from(cur.value).gt(BigNumber.from(max.value))) {
return cur;
}
return max;
},
{ value: "0" } as T
);
};
const findMaxBidForSlot = async (slot: number) => {
const bids = await Promise.all(
possibleBidsAPI.map(async (url) => {
const response = await fetch(url + slot);
const result = await response.json();
const hostname = new URL(url).hostname;
return result.map((bid) => ({ ...bid, hostname }));
})
);
const flatBids = bids.flat();
return findMaxBid(flatBids);
};
(async () => {
const result = [];
for (let i = 0; i < slots.length; i++) {
const slot = slots[i];
const maxBid = await findMaxBidForSlot(slot);
result.push({
slot,
maxBid: formatEther(maxBid.value),
relayUrl: maxBid.hostname,
});
console.log(`slot ${slot} processed`);
}
console.table(result);
// fs.writeFileSync("./dump.json", JSON.stringify(result));
})();