Sub-Adapters 3

Preview and test each sub adapter.

Swapr - Ethereum (swapr-ethereum)

Swapr - xDai (swapr-xdai)

Swapr - Arbitrum (swapr-arbitrum)

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Swapr Fees';
2export const version = '0.1.1';
3export const license = 'MIT';
4
5export function setup(sdk: Context) {
6  const getSwaprData = (subgraph: string) => async (date: string): Promise<number> => {
7    const graphQuery = `query fees($date: Int!) {
8      swaprDayDatas(where: { date: $date }) {
9        dailyVolumeUSD
10      }
11    }`;
12
13    const data = await sdk.graph.query(
14      subgraph,
15      graphQuery,
16      {
17        date: sdk.date.dateToTimestamp(date),
18      },
19    );
20
21    if (data.swaprDayDatas.length === 0) {
22      // throw new Error(`No Sushi data found on ${date} form ${subgraph}`);
23      return 0; // Temp, to allow arbitrum to show up
24    }
25
26    const oneDay = parseFloat(data.swaprDayDatas[0].dailyVolumeUSD) * 0.003;
27
28    return oneDay;
29  }
30
31  const metadata = {
32    category: 'dex',
33    name: 'Swapr',
34    icon: sdk.ipfs.getDataURILoader('QmZs62obE5ojw3VZd8ZuLSk3wymeyEbegQc9qVThWPHMqH', 'image/svg+xml'),
35    bundle: 'swapr',
36    blockchain: 'Ethereum',
37    description: 'Swapr is an automated market maker powered by the DXDAO',
38    feeDescription: 'Trading fees are paid by traders to liquidity providers',
39    source: 'The Graph Protocol',
40    adapter: 'swpar',
41    tokenTicker: 'SWPR',
42    website: 'https://swapr.eth.link',
43    protocolLaunch: '2020-12-10',
44  };
45
46
47  sdk.register({
48    id: 'swapr-ethereum',
49    bundle: 'swapr',
50    queries: {
51      oneDayTotalFees: getSwaprData('luzzif/swapr-mainnet-alpha'),
52    },
53    metadata: {
54      ...metadata,
55      subtitle: 'Ethereum',
56      protocolLaunch: '2020-12-10',
57    },
58  });
59
60  sdk.register({
61    id: 'swapr-xdai',
62    bundle: 'swapr',
63    queries: {
64      oneDayTotalFees: getSwaprData('luzzif/swapr-xdai'),
65    },
66    metadata: {
67      ...metadata,
68      subtitle: 'xDai',
69      blockchain: 'xDai',
70      protocolLaunch: '2021-03-10',
71    },
72  });
73
74  sdk.register({
75    id: 'swapr-arbitrum',
76    bundle: 'swapr',
77    queries: {
78      oneDayTotalFees: getSwaprData('luzzif/swapr-arbitrum-one-v2'),
79    },
80    metadata: {
81      ...metadata,
82      subtitle: 'Arbitrum',
83      blockchain: 'Arbitrum One',
84      protocolLaunch: '2021-08-30',
85    },
86  });
87
88  sdk.registerBundle('swapr', metadata);
89}
90

It's something off?

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

Adapter Info

Version

0.1.1

License

MIT

IPFS CID

Qma68nFPGdYfhghW9BbWc9wxwXZXvf2PxYJ2CMFuwfUnMR

CID (source)

QmXe7aPPvQiA894tbu9uJdRNHSWneZgEVQhGbjXL1jL4nC

Collections

Author

mihal.eth