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:
- Yearn Subgraph (main source of historical data)
- Yearn Meta (static data updated by yearn team, like strategy descriptions)
- Yearn API (APY computations)
- Yearn Lens (token prices)
- Yearn Risk Framework (soon)
yDaemon exposes 4 routes for you to work with data:
getSupportedChains: lists every valid
getAllVaults: lists information all vaults for a
getVault: lists information for a single vault
getBlacklistedVaults: lists vaults not included in yDaemon API
chainIDis a unique number that represents a blockchain, for example Ethereum ID is 1.
The main routes to use are
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:
- Vault Data: Address, Symbol, Name, Icon, Version, Creation Date, Last Update.
- Vault Underlying Token Data: Address, Name, Symbol, Icon.
- Vault TVL: Total Assets, Total Assets in USD, Value of Token in USD .
- Vault APY: Gross APR, Net APY, Performance Fees, Management Fees, APY based on Weekly/Monthly/Lifetime performance, Curve APRs breakdown.
- Vault Strategies: Address, Name, Description, Strategist, Total Gain, Total Loss, Total Debt, Debt Limit.
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:
- Download and install Docker
- Download and install Git
- Create an Alchemy or Infura account (or another RPC provider) and get RPC HTTPS keys for the blockchains you want to query data from. Fantom only has the public RPC
- Open your terminal and type
git clone https://github.com/yearn/ydaemon.gitto download yDaemon source code and
cd ydaemonto enter the project’s folder
- Create a
.envfile containing the lines for the blockchains you want to query from, you don’t need to add URLs for the ones you don’t want to query:
- In the terminal, type
docker-compose up --build --detachto run yDaemon.
- To stop type
To keep data up-to-date the API daemons are spawned on deploy and work in the following cadence:
- Prices from the oracle are updated every 30 seconds for every tokens and vaults, since the price may change at every block.
- APY information is updated every 10 minutes, as the underlying API is updated every 30 minutes.
- Metadata is updated every day and whenever you deploy yDaemon API.
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
The public endpoint to use yDaemon is:
You can test the API endpoints by changing the
:address in the URLs below to what you want to query for
- Local: http://localhost:8080/:chainID/vaults/all | ETH | OP | FTM | ARBI
- Live: https://ydaemon.yearn.finance/:chainID/vaults/all | ETH | OP | FTM | ARBI
- Local: http://localhost:8080/:chainID/vaults/:address
- Live: https://ydaemon.yearn.finance/:chainID/vaults/:address
- Local: http://localhost:8080/info/vaults/blacklisted
- Live: https://ydaemon.yearn.finance/info/vaults/blacklisted
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):
getAllVaults might return a huge list so it has some query tools you can use to filter and reorder results:
?skip=Nwill skip N vault from the graphQL query. Default is 0
?first=Nwill limit the result to N vaults on the graphQL query. Default is 1000
?strategiesDetails=withDetailsadds more details to vault strategies
?strategiesCondition=absoluteremoves strategies with 0 TVL
So if I want the listing result to return only 5 vaults, I can use
If I’m building some sort of pagination system that shows vaults in groups of 5, I can ask for the next page using
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: