{"id":18263730,"url":"https://github.com/yearn/ydaemon","last_synced_at":"2025-04-07T19:16:13.179Z","repository":{"id":38180683,"uuid":"499550379","full_name":"yearn/ydaemon","owner":"yearn","description":"Next gen API for Yearn","archived":false,"fork":false,"pushed_at":"2025-03-25T08:40:21.000Z","size":18500,"stargazers_count":35,"open_issues_count":1,"forks_count":35,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-31T16:19:57.972Z","etag":null,"topics":["api","ethereum","golang"],"latest_commit_sha":null,"homepage":"https://ydaemon.yearn.farm/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yearn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-03T14:54:16.000Z","updated_at":"2025-03-31T08:20:58.000Z","dependencies_parsed_at":"2023-07-18T10:00:40.013Z","dependency_job_id":"733fce59-475e-4fbf-9ee3-d4ae553affa5","html_url":"https://github.com/yearn/ydaemon","commit_stats":{"total_commits":806,"total_committers":20,"mean_commits":40.3,"dds":0.620347394540943,"last_synced_commit":"5373c99bf9828edf507c08191a04aad7af834b8c"},"previous_names":["majorfi/ydaemon"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yearn%2Fydaemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yearn%2Fydaemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yearn%2Fydaemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yearn%2Fydaemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yearn","download_url":"https://codeload.github.com/yearn/ydaemon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713258,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","ethereum","golang"],"created_at":"2024-11-05T11:12:26.773Z","updated_at":"2025-04-07T19:16:13.149Z","avatar_url":"https://github.com/yearn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yDaemon\n\n![](./.github/banner.png)\n\nyDaemon is the next-gen API for Yearn. Based on the API from [yearn-exporter](https://github.com/yearn/yearn-exporter), it brings a lot of new features and benefits without breaking the existing system.\n\nSee documentation here: https://ydaemon.yearn.farm/\n## Use with Docker\nFirst, ensure [Docker](https://docs.docker.com/get-started/overview/) is installed on your system then, clone the repo and create the '.env' file:\n```\nRPC_URI_FOR_1=\nRPC_URI_FOR_10=\nRPC_URI_FOR_137=\nRPC_URI_FOR_250=\nRPC_URI_FOR_8453=\nRPC_URI_FOR_42161=\n```\nThen to run, type:\n```\nmake deploy\n```\nTo stop, type:\n```\nmake down\n```\n\n## Manual Install\nFirst, ensure [Go](https://go.dev/) is installed on your system. then, clone the repo and create the `.env` file:\n```\nRPC_URI_FOR_1=\nRPC_URI_FOR_10=\nRPC_URI_FOR_137=\nRPC_URI_FOR_250=\nRPC_URI_FOR_8453=\nRPC_URI_FOR_42161=\n\n# Optional\nWEBHOOK_SECRET=\nGRAPH_API_URI=\nSENTRY_DSN=\nSENTRY_SAMPLE_RATE=\nLOG_LEVEL=        # DEBUG, INFO, WARNING, SUCCESS, ERROR\n```\n\nThen, install, build and run the API:\n```bash\ngo mod vendor\ngo build -o yDaemon ./cmd\n./yDaemon\n```\n\nAfter a few seconds, you should see the API running. You can test it by running the following command:\n```bash\ncurl http://localhost:8080/1/vaults/all\n```\n\n## Endpoints\n`GET` `[BASE_URL]/[chainID]/vaults/all`  \n\u003e This endpoint returns all the vaults of the specified chainID. Supported chains are `1`, `10`, `137`, `250`, `8453` and `42161`.  \n\u003e  \n\u003e **Query**  \n`?skip=N` will skip N vault from the graphQL query. Default is `0`  \n`?first=N` will limit the result to N vaults on the graphQL query. Default is `1000`  \n`?orderBy=S` will order the result by S on the graphQL query. Default is `activation`  \n`?orderDirection=asc|desc` will order the result by ascending or descending on the graphQL query. Default is `desc`  \n\u003e`?strategiesCondition=debtLimit|inQueue|absolute` will select the \"active\" strategies based on the specified strategy. Default is `debtLimit`  \n\u003e`?strategiesDetails=withDetails|noDetails` indicates if we should also query and serve the details about the strategies. If noDetails is set, the Details field will be ignored. Default is noDetails.  \n-------\n\n`GET` `[BASE_URL]/[chainID]/vaults/[address]`  \n\u003e This endpoint returns the vault matching the specified address, for the specified chainID. Supported chains are `1`, `10`, `137`, `250`, `8453`, and `42161`.  \n\u003e  \n\u003e **Query**  \n\u003e `?strategiesCondition=debtLimit|inQueue|absolute` will select the \"active\" strategies based on the specified strategy. Default is `debtLimit`  \n\u003e`?strategiesDetails=withDetails|noDetails` indicates if we should also query and serve the details about the strategies. If noDetails is set, the Details field will be ignored. Default is noDetails.  \n-------\n\n`GET` `[BASE_URL]/info/chains`  \n\u003e This endpoint returns the supported chains for this API.  \n\n-------\n\n`GET` `[BASE_URL]/info/vaults/blacklisted`  \n\u003e This endpoint returns the blacklisted vaults for all chains. A blacklisted vault is a vault that will be ignored by the API.  \n\n-------\n`GET` `[BASE_URL]/[chainID]/vaults/tvl`  \n\u003e This endpoint returns the Total Value Locked for the specified chainID. Does not subtract delegated deposits from one vault to another.  \n\n## Data Sources\nTo build this API data is fetched from several Yearn data sources:\n- [Yearn Subgraph](https://thegraph.com/explorer/subgraph?id=5xMSe3wTNLgFQqsAc5SCVVwT4MiRb5AogJCuSN9PjzXF) as the base data source.\n- [Yearn Meta](https://github.com/yearn/yearn-meta) for some basic data and information updated by the Yearn team.\n- [Yearn API](https://api.yearn.fi/) for the APY computation.\n- [Yearn Lens Oracle](https://etherscan.io/address/0xca11bde05977b3631167028862be2a173976ca11) for tokens and vault prices.\n\nTo provide a fast and up-to-date experience, a bunch of daemons are summoned with the API, running in the background, forever and ever.\n- Prices from the oracle are updated every 30 seconds for every tokens and vaults, as the price may change at every block.\n- APY information is updated every 10 minutes, as the underlying API is updated every 30 minutes\n- Meta data is updated every minute. This will be moved to every 30 minutes in the future, and trust a webhook from the github deployement system to update the data.\n\n## Folder and structure\nThe project is divided as follow:\n- `cmd`: contains the `main.go` entry point for this API. Its role is _only_ to init the project.\n- `contracts`: contains the `.sol` and `.vy` files used to generate the contract `.go` files with `abigen`\n- `internal`: contains the actual code of the API. It's divided in subpackages, each one representing a different part of the API, keeping the code clean and easy to maintain.\n\nThe `internal` folder is the _private application and library code_. This is the code we don't want others importing in their applications or libraries. This layout pattern is enforced by the Go compiler itself. Inside of it, we have the following subpackages:\n- `contracts`: contains the `abigen` generated contract `.go` files. These files should not be altered.\n- `controllers`: contains the logic around the `REST` API: routes, server, actions by route, etc. This is where the entry-point and the wrapper around the logic for a specific `REST` endpoint is.\n- `daemons`: contains all our background processes. They will run forever in the background to update the data we may need in our application.\n- `ethereum`: contains all the logic around the Blockchain calls. It's the place where we call the RPC, connect to the client, call the methods, etc.\n- `logs`: helper package used to display nice logs.\n- `models`: contains all the cross-package types we need.\n- `store`: contains all the cross-package global variables.\n- `utils`: contains all the cross-package utility functions.\n\n## Docs\nTo run docs locally use the following:\n```bash\ncd docs\nyarn\nyarn dev\n```\n## Go Test and Coverage\n```\n?       github.com/yearn/ydaemon/cmd  [no test files]\n?       github.com/yearn/ydaemon/internal/contracts   [no test files]\nok      github.com/yearn/ydaemon/internal/controllers 34.167s coverage: 98.6% of statements\nok      github.com/yearn/ydaemon/internal/daemons     31.366s coverage: 94.7% of statements\nok      github.com/yearn/ydaemon/internal/utils/ethereum    30.505s coverage: 78.3% of statements\nok      github.com/yearn/ydaemon/internal/logs        0.674s  coverage: 100.0% of statements\nok      github.com/yearn/ydaemon/internal/models      0.521s  coverage: [no statements]\nok      github.com/yearn/ydaemon/internal/utils/store       0.213s  coverage: [no statements]\nok      github.com/yearn/ydaemon/internal/utils       0.406s  coverage: 100.0% of statements\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyearn%2Fydaemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyearn%2Fydaemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyearn%2Fydaemon/lists"}