Adapter

Aave Lending Rates

Sub-Adapters 1

Preview and test each sub adapter.

Aave V2 (aave-v2)

Metadata

ID
aave-v2
name

"Aave V2"

icon

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Aave Lending Rates';
2export const version = '0.0.2';
3export const license = 'MIT';
4
5const LENDING_POOL_ABI = [
6  {
7    inputs: [
8      { internalType: "address", name: "asset", "type": "address" }
9    ],
10    name: "getReserveData",
11    outputs: [
12      {
13        components: [
14          {
15            components: [
16              { internalType: "uint256", name: "data", "type": "uint256" },
17            ],
18            internalType: "struct DataTypes.ReserveConfigurationMap",
19            name: "configuration",
20            "type": "tuple"
21          },
22          { internalType: "uint128", name: "liquidityIndex", "type": "uint128" },
23          { internalType: "uint128", name: "variableBorrowIndex", "type": "uint128" },
24          { internalType: "uint128", name: "currentLiquidityRate", "type": "uint128" },
25          { internalType: "uint128", name: "currentVariableBorrowRate", "type": "uint128" },
26          { internalType: "uint128", name: "currentStableBorrowRate", "type": "uint128" },
27          { internalType: "uint40", name: "lastUpdateTimestamp", "type": "uint40" },
28          { internalType: "address", name: "aTokenAddress", "type": "address" },
29          { internalType: "address", name: "stableDebtTokenAddress", "type": "address" },
30          { internalType: "address", name: "variableDebtTokenAddress", "type": "address" },
31          { internalType: "address", name: "interestRateStrategyAddress", "type": "address" },
32          { internalType: "uint8", name: "id", "type": "uint8" },
33        ],
34        internalType: "struct DataTypes.ReserveData",
35        "type": "tuple"
36      }
37    ],
38    stateMutability: "view",
39    "type": "function",
40  },
41];
42
43const LENDING_POOL_V2_ADDRESS = '0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9';
44
45export function setup(sdk: Context) {
46  const getInterestRate = async (assetAddress: string): Promise<any> => {
47    const contract = sdk.ethers.getContract(LENDING_POOL_V2_ADDRESS, LENDING_POOL_ABI);
48
49    const reserveData = await contract.getReserveData(assetAddress);
50    const currentLiquidityRate = reserveData[3];
51    const apyDecimal = parseInt(currentLiquidityRate.toString()) / 1e27;
52
53    return apyDecimal;
54  }
55
56  sdk.register({
57    id: 'aave-v2',
58    queries: {
59      apyCurrent: getInterestRate,
60    },
61    metadata: {
62      name: 'Aave V2',
63      icon: sdk.ipfs.getDataURILoader('QmW4X8Q36jjPm8fzU21NzFKRxNzReQy4JnehKbRrgybFh6', 'image/svg+xml'),
64    },
65  });
66}
67
68

It's something off?

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

Adapter Info

Version

0.0.2

License

MIT

IPFS CID

QmZFYLsAarG3iUSa4cnaZ1X86xkcAWiSvdTRZrvvUdUHiZ

CID (source)

QmdqGT3VkVYYAkFXKexBkbFDDRtYYLmURbbgpTorkxwRR7

Collections

apy-current

Author

mihal.eth