Introduction
Demons are often described as troublesome and mischievous more than seriously threatening or dangerous, and as lesser beings rather than more important supernatural beings.
The yDaemon API is a REST API that provides access to the Yearn data sources. It should provide all the data that the Yearn team needs to build the Yearn ecosystem, based on a system of Daemons, little subprocesses (Goroutines) that are responsible for fetching, handling, and storing data from the various sources to make them available to the rest of the system.
You can access the live API at the following URL:
The lib is far from complete and is being actively developed. Some part heavily depends on some other libs and APIs. Please, use it with caution and be aware of the fact that it is not guaranteed to be stable.
Feel free to contribute to the daemon and report any issues you might encounter.
What is happening on startup?
If you want to learn more about the startup routine check cmd/main.go
Folder and structure
The project is organized following the Go Standards folder structure with some tweaks. In a nutshell, the project is divided as follows:
cmd
: contains themain.go
entry point for this API. Its role is only to init the project.contracts
: contains the.sol
and.vy
files used to generate the contract.go
files withabigen
internal
: contains the actual code of the API. It's divided into subpackages, each representing a different part of the API, keeping the code clean and easy to maintain.
The 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:
contracts
: contains theabigen
generated contract.go
files. Theses files should not be altered.controllers
: contains the logic around theREST
API: routes, server, actions by route, etc. This is where the entry-point and the wrapper around the logic for a specificREST
endpoint is.daemons
: contains all our background processes. They will run forever in the background to update the data we may need in our application.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.logs
: helper package used to display nice logs.models
: contains all the cross-package types we need.store
: contains all the cross-package global variables.utils
: contains all the cross-package utility functions.