Sub-Adapters 1

Preview and test each sub adapter.

Rari Capital Fuse Markets (rari-fuse)

Metadata

ID
rari-fuse
name

"Rari Capital Fuse Markets"

icon

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Rari APY';
2export const version = '0.0.3';
3export const license = 'MIT';
4
5const CTOKEN_ABI = [
6  'function supplyRatePerBlock() external view returns (uint)',
7];
8
9const blocksPerDay = 6570; // (13.15 seconds per block)
10const daysPerYear = 365;
11
12const markets: { [underlying: string]: string[] } = {
13  // Right now, we just check a few popular pools
14  // Would be great to check more pools, but we need to be careful to not have unbounded queries
15  // Would be amazing to have a subgraph to track this
16  '0x6b175474e89094c44da98b954eedeac495271d0f': [ // Dai
17    '0x989273ec41274C4227bCB878C2c26fdd3afbE70d', // 6
18    '0x7322b10db09687fe8889ad8e87f333f95104839f', // 7
19    '0x7e9ce3caa9910cc048590801e64174957ed41d43', // 8
20    '0x8E4E0257A4759559B4B1AC087fe8d80c63f20D19', // 18
21  ],
22  '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': [ // USDC
23    '0x94C49563a3950424a2a7790c3eF5458A2A359C7e', // 3
24    '0xdb55b77f5e8a1a41931684cf9e4881d24e6b6cc9', // 6
25    '0x53De5A7B03dc24Ff5d25ccF7Ad337a0425Dfd8D1', // 7
26  ],
27  '0xdac17f958d2ee523a2206206994597c13d831ec7': [ // USDT
28    '0x8691927a91a032c23b895130074669f52cf6b1e7', // 6
29    '0x6f95d4d251053483f41c8718c30f4f3c404a8cf2', // 18
30  ],
31}
32
33export function setup(sdk: Context) {
34  const getInterestRate = async (cToken: string): Promise<number> => {
35    const contract = sdk.ethers.getContract(cToken, CTOKEN_ABI);
36    const supplyRate = await contract.supplyRatePerBlock();
37
38    const mantissa = 10 ** 18 // TODO: decimals
39    const apy = (Math.pow((supplyRate.toString() / mantissa * blocksPerDay + 1), daysPerYear)) - 1;
40    return apy;
41  }
42
43  const getAPYForFuse = async (token: string) => {
44    const marketsForUndelrying = markets[token];
45    const apys = await Promise.all(marketsForUndelrying.map(getInterestRate));
46    const topAPY = apys.reduce((top: number, current: number) => Math.max(top, current), 0);
47    return topAPY;
48  };
49
50  sdk.register({
51    id: 'rari-fuse',
52    queries: {
53      apyCurrent: getAPYForFuse,
54    },
55    metadata: {
56      name: 'Rari Capital Fuse Markets',
57      icon: sdk.ipfs.getDataURILoader('QmSoPnrN9369x4V7K6dYSVcX1NsHfdrJeVG5zaDJaskVrq', 'image/png'),
58    },
59  });
60}

It's something off?

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

Adapter Info

Version

0.0.3

License

MIT

IPFS CID

QmUKn6PJLs7VJ94m85ULhYv76JXMtZ5oP7jCwpoSCF3Gsy

CID (source)

QmappFQ6gXo8W6VgwdigrSgEH4SfmmWMMkAZFgTD1tc1mn

Author

mihal.eth