Sub-Adapters 1

Preview and test each sub adapter.

Aave (aave)

Metadata

ID
aave
icon
category

"app"

name

"Aave"

website

"https://aave.com"

governanceSite

"https://app.aave.com/governance"

governanceForum

"https://governance.aave.com"

governanceModel

""

treasuries

[ "0x25F2226B597E8F9514B3F68F00f494cF4f286491", "0x464C71f6c2F760DdA6093dCB91C24c39e5d6e18c" ]

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Aave Treasury';
2export const version = '0.2.0';
3export const license = 'MIT';
4
5const ECOSYSTEM_RESERVE = '0x25F2226B597E8F9514B3F68F00f494cF4f286491';
6const REVENUE_COLLECTOR = '0x464C71f6c2F760DdA6093dCB91C24c39e5d6e18c';
7
8interface PortfolioAsset {
9  address: string
10  amount: number
11  name: string
12  symbol: string
13  icon: string
14  price: number
15  value: number
16}
17
18export async function setup(sdk: Context) {
19  let portfolioCache: { [address: string]: Promise<any> } = {}
20  const getPortfolio = (key: string): Promise<any> => {
21    if (!portfolioCache[key]) {
22      portfolioCache[key] = sdk.http.get(`https://cryptostats-api-proxy.vercel.app/api/v1/zapper/${key}`)
23        .then(result => {
24          if (result.success) {
25            return result.value
26          }
27          sdk.log.error(`https://cryptostats-api-proxy.vercel.app/api/v1/zapper/${key}`, result)
28          throw new Error(result.error)
29        })
30    }
31    return portfolioCache[key]
32  }
33
34  const getTreasuryInUSD = async () => {
35    const [ecosystemReserve, revenueCollector] = await Promise.all([
36      getPortfolio(ECOSYSTEM_RESERVE),
37      getPortfolio(REVENUE_COLLECTOR),
38    ])
39
40    let totalValue = 0;
41
42    for (const portItem of ecosystemReserve) {
43        totalValue += portItem.balanceUSD;
44      }
45     for (const portItem of revenueCollector) {
46        totalValue += portItem.balanceUSD;
47      } 
48    return totalValue
49  }
50
51  const getFullPortfolio = async () => {
52      const [ecosystemReserve, revenueCollector] = await Promise.all([
53      getPortfolio(ECOSYSTEM_RESERVE),
54      getPortfolio(REVENUE_COLLECTOR),
55    ])
56
57    let fullPortfolio:PortfolioAsset[] = []
58
59    for (const portItem of ecosystemReserve) {
60      fullPortfolio.push({
61        address: portItem.address,
62        amount: portItem.context.balance,
63        name: portItem.context.symbol,
64        symbol:portItem.context.symbol, 
65        icon:portItem.displayProps.images[0], 
66        price:portItem.context.price,
67        value:portItem.balanceUSD,
68      })
69    }
70
71    for (const portItem of revenueCollector) {
72      fullPortfolio.push({
73        address: portItem.address,
74        amount: portItem.context.balance,
75        name: portItem.context.symbol,
76        symbol:portItem.context.symbol, 
77        icon:portItem.displayProps.images[0], 
78        price:portItem.context.price,
79        value:portItem.balanceUSD,
80      })
81    }
82
83    return fullPortfolio
84  }
85
86  const getRecentProposals = async () => {
87    const query = `{
88      proposals(
89        first: 5,
90        orderBy: createdTimestamp,
91        orderDirection: desc
92      ) {
93        title
94        id
95        ipfsHash
96        createdTimestamp
97        state
98      }
99    }`
100    const data = await sdk.graph.query('aave/governance-v2', query);
101    return data.proposals.map((proposal: any) => ({
102      title: proposal.title,
103      start: proposal.createdTimestamp,
104      state: proposal.state,
105      link: `https://app.aave.com/governance/${proposal.id}-${proposal.ipfsHash}`,
106    }))
107  }
108
109  sdk.register({
110    id: 'aave',
111    queries: {
112      currentTreasuryUSD: getTreasuryInUSD,
113      currentLiquidTreasuryUSD: getTreasuryInUSD,
114      currentTreasuryPortfolio: getFullPortfolio,
115      recentProposals: getRecentProposals,
116    },
117    metadata: {
118      icon: sdk.ipfs.getDataURILoader('QmW4X8Q36jjPm8fzU21NzFKRxNzReQy4JnehKbRrgybFh6', 'image/svg+xml'),
119      category: 'app',
120      name: 'Aave',
121      website: 'https://aave.com',
122      governanceSite: 'https://app.aave.com/governance',
123      governanceForum: 'https://governance.aave.com',
124      governanceModel: '',
125      treasuries: [ECOSYSTEM_RESERVE, REVENUE_COLLECTOR],
126    },
127  })
128}

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

QmWrzu7DCHTP9pkVoSQwVwmc3R5ZMD6bSwXigHZb5NzPM7

CID (source)

QmbTzbYrhrv2GJVodGTePPPxjrGqmAgsS5xh7XySrHztYN

Collections

Author

0x70c0EE6bd4a42e9Dc5487e30a765370b65e670A5