A simple http api to get Aave interest rates from the blockchain.
-
Node >= v12
-
Mongodb >= 4.2
There are two services:
-
API
-
Worker (listens to the ethereum network for events)
The worker uses an in memory queue and a configurable number of workers (default is 10 for testnet and 3 for mainnet) to process the events in the queue. The configuration of the number of workers should be based on number of requests your Ethereum node is able to process (Infura was ~1-2 while testing) else you would have request timeouts
Manual
Start Http Server
It can connect to either the mainnet
or ropsten
ethereum network
$ npm run build
$ npm start -- --network=mainnet
Start Worker Service
It listens to the ethereum network for ReserveUpdated
Aave events and stores in the database
It can listen to either the mainnet
or ropsten
ethereum network
$ npm run build
$ npm run start-worker -- --network=mainnet
Docker
This automatically startups both the Http and Worker service
$ docker-compose up
For the tests to pass you MUST seed the database
$ npm run seed-database
Run tests
$ npm test
The reserves list is updated every hour from the blockchain, this is to prevent having to make a expensive blockchain network call on every request.
/
{
data: ["0x6B175474E89094C44Da98b954EedeAC495271d0F"],
updatedAt: "2020-02-06T06:48:53.037Z"
}
Returns the rates for the last 24 hours by default
/deposit/:reserve/:mode?
reserve: Reserve address (e.g. 0x6B175474E89094C44Da98b954EedeAC495271d0F)
mode (optional): Get weighted average rate for the options ['week', 'month', 'all-time']
{
data: [
{
liquidityRate: 0.0000005,
time: "2020-02-06T06:48:53.037Z"
}
]
}
Returns the rates for the last 24 hours by default
/borrow/:reserve/:mode?
reserve: Reserve address (e.g. 0x6B175474E89094C44Da98b954EedeAC495271d0F)
mode (optional): Get weighted average rate for the options ['week', 'month', 'all-time']
borrowRate: ['stable', 'variable']
{
data: [
{
stableBorrowRate: 0.0000005,
time: "2020-02-06T06:48:53.037Z"
}
]
}
There is a sample Mongodb dump data in the ./data
directory. It can be imported to the
local mongodb server
$ cd ./data
$ mongorestore
There is should now be a collection of sample 208 documents in your local database that you can test against
MIT