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.3.0';
3export const license = 'MIT';
4
5const STKAAVE_ADDRESS = '0x4da27a545c0c5b758a6ba100e3a049001de870f5';
6const STKABPT_ADDRESS = '0xa1116930326d21fb917d5a27f1e9943a9595fb47';
7const AAVE = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9';
8const ECOSYSTEM_RESERVE = '0x25f2226b597e8f9514b3f68f00f494cf4f286491';
9const SECONDS_IN_DAY = 24 * 60 * 60;
10const SECONDS_IN_WEEK = 7 * 24 * 60 * 60;
11const STAAVE_ABI = [
12  'function assets(address) external view returns (uint128 emissionPerSecond, uint128, uint256)',
13];
14
15export async function setup(sdk: Context) {
16  const issuancePerDay = async () => {
17    const stkaaveContract = sdk.ethers.getContract(STKAAVE_ADDRESS, STAAVE_ABI);
18    const stkabptContract = sdk.ethers.getContract(STKABPT_ADDRESS, STAAVE_ABI)
19    const [stkaaveAssetData,stkabptAssetData] = await Promise.all([
20      stkaaveContract.assets(STKAAVE_ADDRESS),
21      stkabptContract.assets(STKABPT_ADDRESS)
22    ]);
23
24    const aaveIssuance = stkaaveAssetData.emissionPerSecond.add(stkabptAssetData.emissionPerSecond).mul(SECONDS_IN_DAY);
25    return Number(sdk.ethers.utils.formatEther(aaveIssuance));
26  }
27
28  const issuancePerDayUSD = async () => {
29    const issuance = await issuancePerDay();
30    const aavePrice = await sdk.coinGecko.getCurrentPrice('aave');
31
32    return issuance * aavePrice;
33  }
34
35  const getIssuanceRate = async () => {
36    const aaveToken = sdk.ethers.getERC20Contract(AAVE);
37  
38    const [supply, reserveBalance, issuance] = await Promise.all([
39      aaveToken.totalSupply(),
40      aaveToken.balanceOf(ECOSYSTEM_RESERVE),
41      issuancePerDay(),
42    ]);
43
44    const adjustedSupply = (supply.toString() - reserveBalance.toString()) / 1e18;
45    const issuanceRate = (issuance * 365) / adjustedSupply;
46    return issuanceRate;
47  }
48
49  sdk.register({
50    id: 'aave',
51    queries: {
52      issuance7DayAvgUSD: issuancePerDayUSD,
53      issuanceRateCurrent: getIssuanceRate,
54      issuancePerDay: issuancePerDay
55    },
56    metadata: {
57      icon: sdk.ipfs.getDataURILoader('QmW4X8Q36jjPm8fzU21NzFKRxNzReQy4JnehKbRrgybFh6', 'image/svg+xml'),
58      category: 'app',
59      name: 'Aave',
60      issuanceDescription: 'AAVE tokens are paid to users who stake AAVE and AAVE/ETH Balancer LP tokens in the Safety Module.',
61      website: 'https://aave.com',
62    },
63  });
64}
65

It's something off?

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

Adapter Info

Version

0.3.0

License

MIT

IPFS CID

Qmbr7s4jHshat3QknYngJCCLQmBNTr853ebf35QSJfi2pm

CID (source)

QmckvdMPoDiqn7SyUi8yNFjbGVYr4ryyNrK27EmZ5KUeCF

Collections

Author

0x2F058034a88772C9334F764FB591a1f344cb8d5D