Marco Guaspari Worms
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # yDaemon: one API to unify all yearn data ![](https://i.imgur.com/ObuN6Vj.png) yDaemon [(source)](https://github.com/yearn/ydaemon) is a yearn [REST](https://restfulapi.net/) 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**](https://medium.com/iearn/subgraphs-explained-yearning-for-data-4e90d18e33e) (main source of historical data) - Yearn [**Meta**](https://github.com/yearn/ydaemon/tree/main/data/meta) (static data updated by yearn team, like strategy descriptions) - Yearn [**API**](https://docs.yearn.finance/vaults/yearn-api) (APY computations) - Yearn [**Lens**](https://docs.yearn.finance/vaults/yearn-lens/) (token prices) - Yearn [**Risk Framework**](https://docs.yearn.finance/resources/risks/risk-score) (soon) yDaemon exposes 4 routes for you to work with data: - [`getSupportedChains`](https://ydaemon.ycorpo.com/docs/routes/getSupportedChains): lists every valid `chainID` - [`getAllVaults`](https://ydaemon.ycorpo.com/docs/routes/getAllVaults): lists information all vaults for a `chainID` - [`getVault`](https://ydaemon.ycorpo.com/docs/routes/getVault): lists information for a single vault - [`getBlacklistedVaults`](https://ydaemon.ycorpo.com/docs/routes/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](https://github.com/yearn/ydaemon/blob/main/INSTALL.md), I will proceed with using Docker since it works with fewer dependencies in any OS: 1) [Download](https://docs.docker.com/get-docker/) and install Docker 2) [Download](https://git-scm.com/downloads) and install Git 3) Create an [Alchemy](https://auth.alchemyapi.io/) or [Infura](https://infura.io/) account (or other RPC provider) and get RPC HTTPS keys for the blockchains you want to query data from. Fantom only has the [public](https://docs.fantom.foundation/api/public-api-endpoints) RPC 4) 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 5) 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 ``` 6) In the terminal, type `docker-compose up --build --detach` to run yDaemon. 7) To stop type `docker-compose down`. ### Daemons ![](https://i.imgur.com/xvIP5o6.png) 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](https://ydaemon.ycorpo.com/docs/daemons/intro#cache) it if needed, most data that doesn't come from the Subgraph is cached on deploy and then periodically updated. All daemons are written in [Go](https://go.dev/) and you can find them in the source code at the [`daemons`](https://github.com/yearn/ydaemon/tree/main/internal/daemons) folder. ## Query yDaemon The public endpoint to use yDaemon is: - https://ydaemon.yearn.finance/ You can test the API [endpoints](https://github.com/yearn/ydaemon#endpoints) by changing the`:chainID` and `:address` in the URLs below to what you want to query for - **getSupportedChains**: GET - Local: http://localhost:8080/info/chains - Live: https://ydaemon.yearn.finance/info/chains - **getAllVaults**: GET - Local: http://localhost:8080/:chainID/vaults/all | [ETH](http://localhost:8080/1/vaults/all) | [OP](http://localhost:8080/10/vaults/all) | [FTM](http://localhost:8080/250/vaults/all) | [ARBI](http://localhost:8080/42161/vaults/all) - Live: https://ydaemon.yearn.finance/:chainID/vaults/all | [ETH](https://ydaemon.yearn.finance/1/vaults/all) | [OP](https://ydaemon.yearn.finance/10/vaults/all) | [FTM](https://ydaemon.yearn.finance/250/vaults/all) | [ARBI](https://ydaemon.yearn.finance/42161/vaults/all) - **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): - https://ydaemon.yearn.finance/1/vaults/0xdA816459F1AB5631232FE5e97a05BBBb94970c95 Copy the returned text and paste it into something like [json2table](http://json2table.com) so you can prettify the JSON. For example we can see that management fees for this vault are now 0 (announced recently on [twitter](https://twitter.com/iearnfinance/status/1565217164122103809)): ![](https://i.imgur.com/tLxh4go.png) ### 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`: - https://ydaemon.yearn.finance/1/vaults/all?first=5 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`: - https://ydaemon.yearn.finance/1/vaults/all?first=5?skip=5 Query vaults with complete strategy details only for strategies with 0 TVL: - https://ydaemon.yearn.finance/1/vaults/all?strategiesDetails=withDetails?strategiesCondition=absolute See all available [fillters](https://github.com/yearn/ydaemon#endpoints) ## Build with Yearn If you are using yDaemon to build anything let our community know! Here are some useful links: - [yDaemon Github Repository](https://github.com/yearn/ydaemon) - [Yearn Documentation](https://docs.yearn.finance/) - [Yearn Partnership Documentation](https://docs.yearn.finance/partners/introduction) - [Yearn Community Discord](https://discord.com/invite/yearn) - [Yearn Community Telegram](https://t.me/yearnfinance)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully