Sub-Adapters 1
Preview and test each sub adapter.
Arbitrum One (arbitrum-one)
Metadata
- ID
- arbitrum-one
- name
"Arbitrum One"
- icon
- category
"l2"
- description
"Arbitrum One is an optimistic-rollup scaling solution built on Ethereum."
- feeDescription
"Transaction fees are paid to sequencers."
- blockchain
"Arbitrum One"
- source
"The Graph Protocol"
- website
"https://arbitrum.io"
- protocolLaunch
"2021-08-11"
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'Arbitrum Fees';
2export const version = '0.2.0';
3export const license = 'MIT';
4export const description = 'Tracks the fee collector add';
5
6const SEQUENCER_FEES = '0x18A08f3CA72DC4B5928c26648958655690b215ac'
7const NETWORK_INFRA_FEES = '0x582A62dB643BCFF3B0Bf1DA45f812e3a354d7518'
8const CONGESTION_FEES = '0xb04D2C62c0Cd8cec5691Cefd2E7CF041EBD26382'
9
10const SEC_IN_DAY = 86400;
11
12export function setup(sdk: Context) {
13 const getTotalETHSentOnDay = async (address: string, date: string) => {
14 const [startblock, endblock] = await Promise.all([
15 sdk.chainData.getBlockNumber(date, 'arbitrum-one'),
16 sdk.chainData.getBlockNumber(sdk.date.offsetDaysFormatted(date, 1), 'arbitrum-one'),
17 ]);
18
19 const withdrawalTxs = await sdk.etherscan.query({
20 module: 'account',
21 action: 'txlist',
22 address,
23 startblock,
24 endblock,
25 }, 'arbitrum').catch(() => []);
26
27 let totalWithdrawn = 0;
28 for (const tx of withdrawalTxs) {
29 totalWithdrawn += tx.value / 1e18;
30 }
31 return totalWithdrawn;
32 }
33
34 const getArbitrumFee = async (date: string): Promise<number> => {
35 const startDateId = Math.floor(sdk.date.dateToTimestamp(date) / SEC_IN_DAY);
36 const endDateId = startDateId + 1;
37
38 const query = `query txFees($startDateId: String!, $endDateId: String!){
39 startOfDay: fee(id: $startDateId) {
40 totalFeesETH
41 }
42 endOfDay: fee(id: $endDateId) {
43 totalFeesETH
44 }
45 }`;
46
47 const data = await sdk.graph.query('dmihal/arbitrum-fees-collected', query, {
48 variables: {
49 startDateId: startDateId.toString(),
50 endDateId: endDateId.toString(),
51 },
52 });
53
54 // Get withdrawan ETH from Etherscan
55
56 const [sequencerWithdrawn, infraWithdrawn, congestionWithdrawn] = await Promise.all([
57 getTotalETHSentOnDay(SEQUENCER_FEES, date),
58 getTotalETHSentOnDay(NETWORK_INFRA_FEES, date),
59 getTotalETHSentOnDay(CONGESTION_FEES, date),
60 ]);
61 const totalWithdrawn = sequencerWithdrawn + infraWithdrawn + congestionWithdrawn;
62
63 const feesETH = data.endOfDay.totalFeesETH - data.startOfDay.totalFeesETH + totalWithdrawn;
64
65 const ethPrice = await sdk.coinGecko.getHistoricalPrice('ethereum', date);
66
67 return feesETH * ethPrice;
68 }
69
70 sdk.register({
71 id: 'arbitrum-one',
72 queries: {
73 oneDayTotalFees: getArbitrumFee,
74 },
75 metadata: {
76 name: 'Arbitrum One',
77 icon: sdk.ipfs.getDataURILoader('QmeRunQGxv3haLoMfgwD2VjKwScf7gDQiA1DCYd1HNBCG6', 'image/svg+xml'),
78 category: 'l2',
79 description: 'Arbitrum One is an optimistic-rollup scaling solution built on Ethereum.',
80 feeDescription: 'Transaction fees are paid to sequencers.',
81 blockchain: 'Arbitrum One',
82 source: 'The Graph Protocol',
83 website: 'https://arbitrum.io',
84 // The day that the BalanceChecker contract (0x153b436e5ea474f155f9a494ee954cd8d5be3247) was deployed
85 protocolLaunch: '2021-08-11',
86 },
87 })
88}
It's something off?
Report it to the discussion board on Discord, we will take care of it.