Sub-Adapters 1
Preview and test each sub adapter.
Liquity (liquity)
Metadata
- ID
- liquity
- name
- "Liquity" 
- category
- "lending" 
- website
- "https://liquity.org" 
- blockchain
- "Ethereum" 
- source
- "The Graph Protocol" 
- tokenTicker
- "LQTY" 
- tokenCoingecko
- "liquity" 
- protocolLaunch
- "2020-04-05" 
- tokenLaunch
- "2021-04-05" 
- icon
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source. 
1export const name = 'Liquity Fees';
2export const version = '0.1.0';
3export const license = 'MIT';
4
5export function setup(sdk: Context) {
6  const getLiquityFee = async (date: string): Promise<number> => {
7
8    const graphQuery = `query fees($startOfDayBlock: Int!, $endOfDayBlock: Int!) {
9      startOfDay: global(id: "only", block: {number: $startOfDayBlock}) {
10        totalBorrowingFeesPaid
11        totalRedemptionFeesPaid
12      }
13      endOfDay: global(id: "only", block: {number: $endOfDayBlock}) {
14        totalBorrowingFeesPaid
15        totalRedemptionFeesPaid
16      }
17    }`;
18    const data = await sdk.graph.query(
19      'liquity/liquity',
20      graphQuery,
21      {
22        variables: {
23          startOfDayBlock: await sdk.chainData.getBlockNumber(date),
24          endOfDayBlock: await sdk.chainData.getBlockNumber(sdk.date.offsetDaysFormatted(date, 1)),
25        }
26      }
27    );
28
29    const borrowingFees = data.endOfDay.totalBorrowingFeesPaid - data.startOfDay.totalBorrowingFeesPaid;
30    const redemptionFeesETH = data.endOfDay.totalRedemptionFeesPaid - data.startOfDay.totalRedemptionFeesPaid;
31
32    const ethPrice = await sdk.coinGecko.getHistoricalPrice('ethereum', date);
33    const redemptionFeesUSD = redemptionFeesETH * ethPrice;
34    
35    return borrowingFees + redemptionFeesUSD;
36  }
37
38  sdk.register({
39    id: 'liquity',
40    queries: {
41      oneDayTotalFees: getLiquityFee,
42    },
43    metadata: {
44      name: 'Liquity',
45      category: 'lending',
46      website: 'https://liquity.org',
47      blockchain: 'Ethereum',
48      source: 'The Graph Protocol',
49      tokenTicker: 'LQTY',
50      tokenCoingecko: 'liquity',
51      protocolLaunch: '2020-04-05',
52      tokenLaunch: '2021-04-05',
53      icon: sdk.ipfs.getDataURILoader('QmbQkK78NB9czUbcMTEduhpquDkRVj9bMkNY9APBBA391c', 'image/svg+xml'),
54    },
55  })
56}
57
It's something off?
Report it to the discussion board on Discord, we will take care of it.