Yearn
Published in

Yearn

yDaemon: one API to unify all yearn data

yDaemon (source) is a yearn REST API that provides a single unified interface to consume all relevant Yearn ecosystem data. The API data updates in near real-time thanks to the many daemons that it spawns in order to check data sources for changes:

yDaemon exposes 4 routes for you to work with data:

chainID is a unique number that represents a blockchain, for example Ethereum ID is 1.

The main routes to use are getAllVaults and getVault, both work with the same vault object type the only difference is that one route returns information for a list of all vaults and the other returns for a single one. Some of the most important information that these routes are:

Setup yDaemon locally

There are 2 ways to install and run it using either Docker or Manual Installation, I will proceed with using Docker since it works with fewer dependencies in any OS:

RPC_URI_FOR_1=https://eth-mainnet.g.alchemy.com/v2/secret_secret_secret
RPC_URI_FOR_10=https://another.rpc.url
RPC_URI_FOR_250=https://another.rpc.url
RPC_URI_FOR_42161=https://another.rpc.url

Daemons

To keep data up-to-date the API daemons are spawned on deploy and work in the following cadence:

Each daemon knows how to fetch and handle data from a specific source and cache it if needed, most data that doesn’t come from the Subgraph is cached on deployment and then periodically updated.

There is a list of all Daemons at the docs. All daemons are written in Go and you can find them in the source code at the daemons folder.

Query yDaemon

The public endpoint to use yDaemon is:

You can test the API endpoints by changing the:chainID and :address in the URLs below to what you want to query for

getSupportedChains: GET

getAllVaults: GET

getVault: GET

getBlacklistedVaults: GET

With the service up you can now query for vaults data, for example at Ethereum :chainID = 1 let’s query the DAI vault :address = 0xdA816459F1AB5631232FE5e97a05BBBb94970c95 by entering this URL in the browser (or query form any programming language):

Copy the returned text and paste it into something like json2table so you can prettify the JSON. For example, we can see that management fees for this vault are now 0 (announced recently on twitter):

Filters

The getAllVaults might return a huge list so it has some query tools you can use to filter and reorder results:

So if I want the listing result to return only 5 vaults, I can use first:

If I’m building some sort of pagination system that shows vaults in groups of 5, I can ask for the next page using skip:

Query vaults with complete strategy details only for strategies with 0 TVL:

See all available fillters

Build with Yearn

If you are using yDaemon to build anything let our community know! Here are some useful links:

--

--

the future of finance won’t belong to anybody but everybody

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store