yearn / ydaemon

Next gen API for Yearn
https://ydaemon.yearn.farm/
29 stars 31 forks source link
api ethereum golang

yDaemon

yDaemon is the next-gen API for Yearn. Based on the API from yearn-exporter, it brings a lot of new features and benefits without breaking the existing system.

See documentation here: https://ydaemon.yearn.farm/

Use with Docker

First, ensure Docker is installed on your system then, clone the repo and create the '.env' file:

RPC_URI_FOR_1=
RPC_URI_FOR_10=
RPC_URI_FOR_137=
RPC_URI_FOR_250=
RPC_URI_FOR_8453=
RPC_URI_FOR_42161=

Then to run, type:

make deploy

To stop, type:

make down

Manual Install

First, ensure Go is installed on your system. then, clone the repo and create the .env file:

RPC_URI_FOR_1=
RPC_URI_FOR_10=
RPC_URI_FOR_137=
RPC_URI_FOR_250=
RPC_URI_FOR_8453=
RPC_URI_FOR_42161=

# Optional
WEBHOOK_SECRET=
GRAPH_API_URI=
SENTRY_DSN=
SENTRY_SAMPLE_RATE=
LOG_LEVEL=        # DEBUG, INFO, WARNING, SUCCESS, ERROR

Then, install, build and run the API:

go mod vendor
go build -o yDaemon ./cmd
./yDaemon

After a few seconds, you should see the API running. You can test it by running the following command:

curl http://localhost:8080/1/vaults/all

Endpoints

GET[BASE_URL]/[chainID]/vaults/all

This endpoint returns all the vaults of the specified chainID. Supported chains are 1, 10, 137, 250, 8453 and 42161.

Query
?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
?orderBy=S will order the result by S on the graphQL query. Default is activation
?orderDirection=asc|desc will order the result by ascending or descending on the graphQL query. Default is desc
?strategiesCondition=debtLimit|inQueue|absolute will select the "active" strategies based on the specified strategy. Default is debtLimit
?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.

GET[BASE_URL]/[chainID]/vaults/[address]

This endpoint returns the vault matching the specified address, for the specified chainID. Supported chains are 1, 10, 137, 250, 8453, and 42161.

Query
?strategiesCondition=debtLimit|inQueue|absolute will select the "active" strategies based on the specified strategy. Default is debtLimit
?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.

GET[BASE_URL]/info/chains

This endpoint returns the supported chains for this API.


GET[BASE_URL]/info/vaults/blacklisted

This endpoint returns the blacklisted vaults for all chains. A blacklisted vault is a vault that will be ignored by the API.


GET[BASE_URL]/[chainID]/vaults/tvl

This endpoint returns the Total Value Locked for the specified chainID. Does not subtract delegated deposits from one vault to another.

Data Sources

To build this API data is fetched from several Yearn data sources:

To provide a fast and up-to-date experience, a bunch of daemons are summoned with the API, running in the background, forever and ever.

Folder and structure

The project is divided as follow:

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:

Docs

To run docs locally use the following:

cd docs
yarn
yarn dev

Go Test and Coverage

?       github.com/yearn/ydaemon/cmd  [no test files]
?       github.com/yearn/ydaemon/internal/contracts   [no test files]
ok      github.com/yearn/ydaemon/internal/controllers 34.167s coverage: 98.6% of statements
ok      github.com/yearn/ydaemon/internal/daemons     31.366s coverage: 94.7% of statements
ok      github.com/yearn/ydaemon/internal/utils/ethereum    30.505s coverage: 78.3% of statements
ok      github.com/yearn/ydaemon/internal/logs        0.674s  coverage: 100.0% of statements
ok      github.com/yearn/ydaemon/internal/models      0.521s  coverage: [no statements]
ok      github.com/yearn/ydaemon/internal/utils/store       0.213s  coverage: [no statements]
ok      github.com/yearn/ydaemon/internal/utils       0.406s  coverage: 100.0% of statements