Adapter

Messari Subgraphs - Fees

Compound is an open borrowing & lending protocol.

Sub-Adapters 1

Preview and test each sub adapter.

Compound (compound)

Metadata

ID
compound
source

"Messari Subgraph"

icon
name

"Compound"

category

"lending"

description

"Compound is an open borrowing & lending protocol."

feeDescription

"Interest fees are paid from borrowers to lenders."

blockchain

"Ethereum"

website

"https://compound.finance"

tokenTicker

"COMP"

tokenCoingecko

"compound-governance-token"

protocolLaunch

"2019-05-07"

tokenLaunch

"2020-06-22"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Messari Subgraphs - Fees';
2export const version = '0.0.1';
3export const license = 'MIT';
4
5interface Protocol {
6  id: string
7  subgraph: string
8  icon: string
9  metadata: any
10}
11
12const protocols: Protocol[] = [
13  {
14    id: 'compound',
15    subgraph: 'messari/compound-ethereum',
16    icon: 'QmZpZsg829EnBxE2MPZykZpAfsxyRsu6EuGbtfTkf2EFNj',
17    metadata: {
18      name: 'Compound',
19      category: 'lending',
20      description: 'Compound is an open borrowing & lending protocol.',
21      feeDescription: 'Interest fees are paid from borrowers to lenders.',
22      blockchain: 'Ethereum',
23      website: 'https://compound.finance',
24      tokenTicker: 'COMP',
25      tokenCoingecko: 'compound-governance-token',
26      protocolLaunch: '2019-05-07',
27      tokenLaunch: '2020-06-22',
28    },
29  },
30]
31
32const ONE_DAY = 86400;
33
34export function setup(sdk: Context) {
35  for (const protocol of protocols) {
36    const getFees = async (date: string): Promise<number> => {
37      const dateId = Math.floor(sdk.date.dateToTimestamp(date) / ONE_DAY);
38      
39      const query = `query txFees($dateId: Int!, $nextDay: Int!){
40        financialsDailySnapshot(id: $dateId) {
41          dailyTotalRevenueUSD
42        }
43        nextDay: financialsDailySnapshot(id: $nextDay) {
44          id
45        }
46      }`;
47
48      const data = await sdk.graph.query(protocol.subgraph, query, {
49        dateId,
50        nextDay: dateId + 1,
51      });
52
53      if (!data.nextDay) {
54        throw new Error('Date incomplete');
55      }
56
57      return parseFloat(data.financialsDailySnapshot.dailyTotalRevenueUSD);
58    }
59
60    sdk.register({
61      id: protocol.id,
62      queries: {
63        oneDayTotalFees: getFees,
64      },
65      metadata: {
66        source: 'Messari Subgraph',
67        icon: sdk.ipfs.getDataURILoader(protocol.icon, 'image/svg+xml'),
68        ...protocol.metadata,
69      },
70    })
71  }
72}
73

It's something off?

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

Adapter Info

Version

0.0.1

License

MIT

IPFS CID

Qma4GXtZX2uV1HhoUEf9E8puW5nYuK3MPpndcXGDKLwBVx

CID (source)

QmbD4EPP5Mn8b3r3RKVbRFpzB7kCSQ9jS2DcgjbF3RQtN2

Collections

Author

mihal.eth