Adapter

BSC Fees

BNB Smart Chain is an inexpensive, EVM-compatible chain created by Binance.

Sub-Adapters 1

Preview and test each sub adapter.

BNB Smart Chain (bsc)

Metadata

ID
bsc
icon
category

"l1"

name

"BNB Smart Chain"

shortName

"BSC"

description

"BNB Smart Chain is an inexpensive, EVM-compatible chain created by Binance."

feeDescription

"10% of fees are burnt, with the remainder paid to validators."

blockchain

"BSC"

source

"Etherscan"

website

"https://bnbchain.org"

tokenTicker

"BNB"

tokenCoingecko

"binancecoin"

protocolLaunch

"2020-09-11"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'BSC Fees';
2export const version = '0.2.0';
3export const license = 'MIT';
4
5export function setup(sdk: Context) {
6  async function getBSCData(date: string): Promise<number> {
7    const query = `query txFees($startOfDay: Int!, $endOfDay: Int!){
8      startOfDay: fee(id: "1", block: { number: $startOfDay }) {
9        totalFees
10      }
11      endOfDay: fee(id: "1", block: { number: $endOfDay }) {
12        totalFees
13      }
14    }`;
15
16    const data = await sdk.graph.query('dmihal/bsc-validator-rewards', query, {
17      variables: {
18        startOfDay: await sdk.chainData.getBlockNumber(date, 'bsc'),
19        endOfDay: await sdk.chainData.getBlockNumber(sdk.date.offsetDaysFormatted(date, 1), 'bsc'),
20      },
21    })
22
23    const bnbFees = data.endOfDay.totalFees - data.startOfDay.totalFees;
24
25    const bnbPrice = await sdk.coinGecko.getHistoricalPrice('binancecoin', date);
26
27    return bnbFees * bnbPrice;
28  }
29
30  const getBurntFees = async (date: string) => {
31    if (sdk.date.isBefore(date, '2021-12-01')) { // Date that BEP-95 was enabled
32      return 0;
33    }
34
35    const totalFees = await getBSCData(date);
36    return totalFees * 0.1;
37  }
38
39  sdk.register({
40    id: 'bsc',
41    queries: {
42      oneDayTotalFees: getBSCData,
43      networkFeesByDayUSD: getBSCData,
44      oneDayProtocolFees: getBurntFees,
45    },
46    metadata: {
47      icon: sdk.ipfs.getDataURILoader('QmYCfAzYWvHf1NBQodQedqGhs3QRZxCs1QeA4saneyTJgu', 'image/svg+xml'),
48      category: 'l1',
49      name: 'BNB Smart Chain',
50      shortName: 'BSC',
51      description: 'BNB Smart Chain is an inexpensive, EVM-compatible chain created by Binance.',
52      feeDescription: '10% of fees are burnt, with the remainder paid to validators.',
53      blockchain: 'BSC',
54      source: 'Etherscan',
55      website: 'https://bnbchain.org',
56      tokenTicker: 'BNB',
57      tokenCoingecko: 'binancecoin',
58      protocolLaunch: '2020-09-11',
59    },
60  });
61}
62
63

It's something off?

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

Adapter Info

Version

0.2.0

License

MIT

IPFS CID

QmQdhH6wp1rt6QNS3EUBpA2HMpMgYtSb1WGBkNwZpKQ9MZ

CID (source)

QmZzqYTm9r82Gk52a2Y3guQM2C8sDPPgRrUEetCT6h1hXQ

Collections

Author

mihal.eth