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

It's something off?

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

Adapter Info

Version

0.1.3

License

MIT

IPFS CID

Qmf2XhAJc3zLQrU2EKgqNyUWmCAyGAQBrn1z8drF45m1Cy

CID (source)

QmZbi66V51XUt73wZ1MgTRGVybhWAhRU2hn8Y3BBymmyAb

Collections

Author

mihal.eth