Sub-Adapters 1
Preview and test each sub adapter.
Aave (aave)
Metadata
- ID
- aave
- icon
- category
"app"
- name
"Aave"
- issuanceDescription
"AAVE tokens are paid to users who stake AAVE and AAVE/ETH Balancer LP tokens in the Safety Module."
- website
"https://aave.com"
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'Aave Issuance';
2export const version = '0.2.0';
3export const license = 'MIT';
4
5const STAAVE_ADDRESS = '0x4da27a545c0c5b758a6ba100e3a049001de870f5';
6const AAVE = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9';
7const ECOSYSTEM_RESERVE = '0x25f2226b597e8f9514b3f68f00f494cf4f286491';
8const SECONDS_IN_DAY = 24 * 60 * 60;
9const SECONDS_IN_WEEK = 7 * 24 * 60 * 60;
10const STAAVE_ABI = [
11 'function assets(address) external view returns (uint128 emissionPerSecond, uint128, uint256)',
12];
13
14export async function setup(sdk: Context) {
15 const getAaveIssuance = async () => {
16 const staaveContract = sdk.ethers.getContract(STAAVE_ADDRESS, STAAVE_ABI);
17
18 const [assetData, aavePrice] = await Promise.all([
19 staaveContract.assets(STAAVE_ADDRESS),
20 sdk.coinGecko.getCurrentPrice('aave'),
21 ]);
22
23 const aaveRateDecimal = assetData.emissionPerSecond.toString() / 1e18;
24 const aaveInLastWeek = aaveRateDecimal * SECONDS_IN_WEEK;
25
26 return aaveInLastWeek * aavePrice;
27 }
28
29 const getIssuanceRate = async () => {
30 const aaveToken = sdk.ethers.getERC20Contract(AAVE);
31 const staaveContract = sdk.ethers.getContract(STAAVE_ADDRESS, STAAVE_ABI);
32
33 const [supply, reserveBalance, assetData] = await Promise.all([
34 aaveToken.totalSupply(),
35 aaveToken.balanceOf(ECOSYSTEM_RESERVE),
36 staaveContract.assets(STAAVE_ADDRESS),
37 ]);
38
39 const adjustedSupply = (supply.toString() - reserveBalance.toString()) / 1e18;
40 const emissionsPerDay = assetData.emissionPerSecond * SECONDS_IN_DAY / 1e18;
41 const issuanceRate = (emissionsPerDay * 365) / adjustedSupply;
42 return issuanceRate;
43 }
44
45 sdk.register({
46 id: 'aave',
47 queries: {
48 issuance7DayAvgUSD: getAaveIssuance,
49 issuanceRateCurrent: getIssuanceRate,
50 },
51 metadata: {
52 icon: sdk.ipfs.getDataURILoader('QmW4X8Q36jjPm8fzU21NzFKRxNzReQy4JnehKbRrgybFh6', 'image/svg+xml'),
53 category: 'app',
54 name: 'Aave',
55 issuanceDescription: 'AAVE tokens are paid to users who stake AAVE and AAVE/ETH Balancer LP tokens in the Safety Module.',
56 website: 'https://aave.com',
57 },
58 });
59}
60
It's something off?
Report it to the discussion board on Discord, we will take care of it.