Adapter

Polygon Fees

Total gas fees paid on Polygon using MATIC tokens

Sub-Adapters 1

Preview and test each sub adapter.

Polygon (polygon-pos)

Metadata

ID
polygon-pos
name

"Polygon"

icon
category

"l1"

description

"Polygon is a protocol for Ethereum-compatible blockchain networks."

feeDescription

"Transaction fees are paid by users to validators."

blockchain

"Polygon"

source

"The Graph Protocol"

website

"https://polygon.technology"

tokenTicker

"MATIC"

tokenCoingecko

"matic-network"

protocolLaunch

"2020-05-30"

tokenLaunch

"2017-09-09"

events

[ { "date": "2021-04-14", "description": "\"#DeFiForAll\" liquidity mining program launched" } ]

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Polygon Fees';
2export const version = '0.1.2';
3export const license = 'MIT';
4export const description = 'Total gas fees paid on Polygon using MATIC tokens';
5
6export function setup(sdk: Context) {
7  const getFees = async (date: string): Promise<number> => {
8    const nextDay = sdk.date.offsetDaysFormatted(date, 1);
9    const todayBlock = await sdk.chainData.getBlockNumber(nextDay, 'polygon');
10    const yesterdayBlock = await sdk.chainData.getBlockNumber(date, 'polygon');
11
12    const data = await sdk.graph.query(
13      'dmihal/polygon-fees',
14      `query txFees($today: Int!, $yesterday: Int!){
15        today: fee(id: "1", block: {number: $today}) {
16          totalFees
17        }
18        yesterday: fee(id: "1", block: {number: $yesterday}) {
19          totalFees
20        }
21      }`,
22      {
23        today: todayBlock,
24        yesterday: yesterdayBlock,
25      },
26    );
27
28    const maticPrice = await sdk.coinGecko.getHistoricalPrice('matic-network', date);
29    const feesInMatic = parseFloat(data.today.totalFees) - parseFloat(data.yesterday.totalFees);
30
31    return feesInMatic * maticPrice;
32  }
33
34  sdk.register({
35    id: 'polygon-pos',
36    queries: {
37      oneDayTotalFees: getFees,
38    },
39    metadata: {
40      name: 'Polygon',
41      icon: sdk.ipfs.getDataURILoader('QmcakfgwRpoXotCQdBc8fos31X4p9ujvJBuigSh9C59cKS', 'image/svg+xml'),
42      category: 'l1',
43      description: 'Polygon is a protocol for Ethereum-compatible blockchain networks.',
44      feeDescription: 'Transaction fees are paid by users to validators.',
45      blockchain: 'Polygon',
46      source: 'The Graph Protocol',
47      website: 'https://polygon.technology',
48      tokenTicker: 'MATIC',
49      tokenCoingecko: 'matic-network',
50      protocolLaunch: '2020-05-30',
51      tokenLaunch: '2017-09-09',
52      events: [
53        {
54          date: '2021-04-14',
55          description: '"#DeFiForAll" liquidity mining program launched',
56        },
57      ],
58    },
59  })
60}
61

It's something off?

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

Adapter Info

Version

0.1.2

License

MIT

IPFS CID

QmPxBnEdKoetJaSuwbRvHVRg46rBv2AytoZ4H45Pksu5nZ

CID (source)

QmVtNQxFhq4798YWuht1ciYuYnXMgpzNUmzRM5BJWYNcea

Author

mihal.eth