Coder Social home page Coder Social logo

yearn-exporter-api's Introduction

yearn-exporter-api

Light-weight API in front of yearn.vision that makes some data available for external sites.

Usage

Start the API with make build && make up. This will expose it at http://localhost:5000.

Make commands

All these are prefaced with make.

  • build, up, down, destroy, stop, restart, ps

Configuration

You can export the following environment variables if you want to override the defaults:

  • FLASK_RUN_PORT: the listening port for the api, default: 5000
  • BASE_URL: the URL pointing to the grafana instance, default: "https://yearn.vision"

Routes

/tvl

returns the summed TVLs grouped by network and a summed total:

$ curl localhost:5000/tvl
{
  "ts":1642600346,
  "tvl_eth":5101043121.68,
  "tvl_ftm":533590588.63,
  "tvl_total":533590588.63,
  "unit":"USD"
}

/tvl/<network>

returns the tvl for the given network, e.g. for ETH:

$ curl localhost:5000/tvl/eth
{
  "ts":1642600393,
  "tvl_eth":5101041358.88,
  "unit":"USD"
}

supported networks are:

  • eth
  • ftm
  • opt
  • arb
  • base

/tvl/total

returns the sum of the TVLs of all networks:

$ curl localhost:5000/tvl/total
{
  "ts":1642600475,
  "tvl_total":534919919.17,
  "unit":"USD"
}

/partners/{query}

returns b2b fee-sharing partners' info

/partners/total

returns the total fees to be paid out to date, measured in USD value from all chains:

$ curl localhost:5000/partners/total
{
  "partners_total": 2601705.85,
  "ts": 1665017101,
  "unit": "USD"
}

/partners/count

returns the number of partners to-date from all chains:

$ curl localhost:5000/partners/count
{
  "partners_count": 22,
  "ts": 1665017986,
  "unit": ""
}

/partners/<partner>/<param>

returns for a specific partner the parameter you specify:

  • parameters are: allowed_params: balance, payout_daily, payout_weekly, payout_monthly, payout_total
  • partners are the names of the b2b partners
$ curl localhost:5000/partners/sturdy/payout_total
 "partners_indiv_sturdy_payout_total": {
   "FTM": {
     "0x0DEC85e74A92c52b7F708c4B10207D9560CEFaf0": {
       "balance": 2238.09,
       "bucket": "Other short term assets",
       "token": "yvWFTM",
       "tvl": 1732.48
     },
     "0x0fBbf9848D969776a5Eb842EdAfAf29ef4467698": {
       "balance": 15.17,
       "bucket": "Other short term assets",
       "token": "yvBOO",
       "tvl": 123.41
     },
     "0x1e2fe8074a5ce1Bb7394856B0C618E75D823B93b": {
       "balance": 1714.68,
       "bucket": "Other short term assets",
       "token": "yvfBEETS",
       "tvl": 389.16
     },
     "0xf2d323621785A066E64282d2B407eAc79cC04966": {
       "balance": 5.92,
       "bucket": "Other short term assets",
       "token": "yvLINK",
       "tvl": 66.84
     }
   }
 },
 "ts": 1671244960,
 "unit": "USD"
}

Optional Query Params

  • ts
curl localhost:5000/tvl?ts=1642664109
{
  "ts":1642664109,
  "tvl_eth":5081490281.98,
  "tvl_ftm":574308185.62,
  "tvl_total":5655798467.6,
  "unit":"USD"
}

set a ts (millis) for retrieving the data at that specific timestamp

yearn-exporter-api's People

Contributors

0xbasically avatar bobthebuidler avatar crebsy avatar darkghost7 avatar kyhoon avatar mariuspod avatar marsh-sudo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yearn-exporter-api's Issues

feat: add make file for easy building

add a make file so it can be started easily
make build
docker build -t ghcr.io/yearn/yearn-exporter-api .
make up
docker-compose up -d
make down
docker-compose down

feat: for partner/count add network delete unit

localhost:5000/partners/count
outputs the following

{
  "partners_count": 22,
  "ts": 1665017986,
  "unit": ""
}

delete the unit section and output how many networks partners are on, if only eth and fantom list those networks. This will let us know if there are new b2b partners on other networks.

  "partners_count": 22,
  "ts": 1665017986,
  "networks": "ETH", "FTM"

feat: vault tvl history

Seafood is currently fetching 3-week TVL history for every vault on each network by posting promql to https://yearn.vision/api/ds/query. This has been OK, but may prove fragile long term (eg because of feature\design drift on the exporter side, promql is a relatively uncommon skill, etc).

Can TVL history be added to the high level api? Suggesting something like this:

/tvl/[network]/vaults?frequency=weekly&periods=3

Fwiw, here's the promql seafood uses, https://github.com/yearn/seafood/blob/main/api/routes/vision/tvls.json

feat: add partner params that return the sum of them

For the endpoint /partners/<partner>/<param> of a new endpoint such as /partners/<partner>/<param>/sum or ?summed=true
either make a new query or add at the end of this query a summed account of what they are asking

SUM_QUERY_PAR_INDIV = """sum((partners{{partner=\"{0}\", param=\"{1}\"}}))"""
This is the summed expression.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.