Adapter

Arbitrum Fees - Clone

Tracks the fee collector add

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 - Clone';
2export const version = '0.3.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'
9const SEQUENCER_FEES_NITRO = '0xa4b1e63cb4901e327597bc35d36fe8a23e4c253f'
10const NETWORK_INFRA_FEES_NITRO = '0xD345e41aE2cb00311956aA7109fC801Ae8c81a52'
11const CONGESTION_FEES_NITRO = '0xa4B00000000000000000000000000000000000F6'
12
13const SEC_IN_DAY = 86400;
14
15export function setup(sdk: Context) {
16  const getTotalETHSentOnDay = async (address: string, date: string) => {
17    const [startblock, endblock] = await Promise.all([
18      sdk.chainData.getBlockNumber(date, 'arbitrum-one'),
19      sdk.chainData.getBlockNumber(sdk.date.offsetDaysFormatted(date, 1), 'arbitrum-one'),
20    ]);
21
22    const withdrawalTxs = await sdk.etherscan.query({
23      module: 'account',
24      action: 'txlist',
25      address,
26      startblock,
27      endblock,
28    }, 'arbitrum').catch(() => []);
29
30    let totalWithdrawn = 0;
31    for (const tx of withdrawalTxs) {
32      totalWithdrawn += tx.value / 1e18;
33    }
34    return totalWithdrawn;
35  }
36
37  const getArbitrumFee = async (date: string): Promise<number> => {
38    const startDateId = Math.floor(sdk.date.dateToTimestamp(date) / SEC_IN_DAY);
39    const endDateId = startDateId + 1;
40    
41    const query = `query txFees($startDateId: String!, $endDateId: String!){
42      startOfDay: fee(id: $startDateId) {
43        totalFeesETH
44      }
45      endOfDay: fee(id: $endDateId) {
46        totalFeesETH
47      }
48    }`;
49
50    const data = await sdk.graph.query('dmihal/arbitrum-fees-collected', query, {
51      variables: {
52        startDateId: startDateId.toString(),
53        endDateId: endDateId.toString(),
54      },
55    });
56
57    // Get withdrawan ETH from Etherscan
58
59    const [sequencerWithdrawn, infraWithdrawn, congestionWithdrawn,
60           sequencerWithdrawnNitro, infraWithdrawnNitro, congestionWithdrawnNitro,] = await Promise.all([
61      getTotalETHSentOnDay(SEQUENCER_FEES, date),
62      getTotalETHSentOnDay(NETWORK_INFRA_FEES, date),
63      getTotalETHSentOnDay(CONGESTION_FEES, date),
64      getTotalETHSentOnDay(SEQUENCER_FEES_NITRO, date),
65      getTotalETHSentOnDay(NETWORK_INFRA_FEES_NITRO, date),
66      getTotalETHSentOnDay(CONGESTION_FEES_NITRO, date),
67    ]);
68    const totalWithdrawn = sequencerWithdrawn + infraWithdrawn + congestionWithdrawn + sequencerWithdrawnNitro + infraWithdrawnNitro + congestionWithdrawnNitro;
69
70    const feesETH = data.endOfDay.totalFeesETH - data.startOfDay.totalFeesETH + totalWithdrawn;
71
72    const ethPrice = await sdk.coinGecko.getHistoricalPrice('ethereum', date);
73
74    return feesETH * ethPrice;
75  }
76
77  sdk.register({
78    id: 'arbitrum-one',
79    queries: {
80      oneDayTotalFees: getArbitrumFee,
81    },
82    metadata: {
83      name: 'Arbitrum One',
84      icon: sdk.ipfs.getDataURILoader('QmeRunQGxv3haLoMfgwD2VjKwScf7gDQiA1DCYd1HNBCG6', 'image/svg+xml'),
85      category: 'l2',
86      description: 'Arbitrum One is an optimistic-rollup scaling solution built on Ethereum.',
87      feeDescription: 'Transaction fees are paid to sequencers.',
88      blockchain: 'Arbitrum One',
89      source: 'The Graph Protocol',
90      website: 'https://arbitrum.io',
91      // The day that the BalanceChecker contract (0x153b436e5ea474f155f9a494ee954cd8d5be3247) was deployed
92      protocolLaunch: '2021-08-11',
93    },
94  })
95}

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

0.3.0

License

MIT

IPFS CID

QmNa61zw3NxJftoDpjfBWARGjzzafi2eK9DQDzPUgvourc

CID (source)

QmQEGZ74JTPmDFwTx74TWrU9yygM1rvHazhz18sHDDmNQT

Collections

Author

gzeon.eth