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 chainID
- getAllVaults: lists information all vaults for a chainID
- getVault: lists information for a single vault
- getBlacklistedVaults: lists vaults not included in yDaemon API
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:
- 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.git to download yDaemon source code and cd ydaemon to enter the project’s folder
Create a .env file 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:
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
In the terminal, type docker-compose up –build –detach to run yDaemon.
To stop type docker-compose down.
Daemons
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 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
- Local: http://localhost:8080/:chainID/vaults/all | ETH | OP | FTM | ARBI
- Live: https://ydaemon.yearn.finance/:chainID/vaults/all | ETH | OP | FTM | ARBI
getVault: GET
- Local: http://localhost:8080/:chainID/vaults/:address
- Live: https://ydaemon.yearn.finance/:chainID/vaults/:address
getBlacklistedVaults: GET
- 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):
Filters
The getAllVaults might return a huge list so it has some query tools you can use to filter and reorder results:
?skip=N
will skip N vault from the graphQL query. Default is 0?first=N
will limit the result to N vaults on the graphQL query. Default is 1000?strategiesDetails=withDetails
adds more details to vault strategies?strategiesCondition=absolute
removes strategies with 0 TVL
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: