Giter VIP home page Giter VIP logo

yearn-exporter's Introduction

Yearn Exporter

Collects real-time on-chain numeric data about all Yearn products and exposes it in multiple formats. Currently, it's able to export data from the following networks: Ethereum, Fantom, Arbitrum, Gnosis, and Optimism.

The hosted version is available at https://yearn.vision.

Installation

You will need:

  • Etherscan API key (and API keys for other networks block explorer that you want to use)
  • Docker and Docker Compose

Usage

Run make up to start all of the exporters.

Grafana Dashboard & Exporters

Export the environment variables required in .env.example into .env to run the dashboards and exporters:

# Make sure all .env variables loaded (`source .env`), check with `echo $variable_name_here`
make build && make dashboards

After a successful startup, you can go directly to Grafana at http://localhost:3000. If you want to change your dashboards you can sign in at the lower left with admin:admin.

Historical TVL

# Make sure all .env variables loaded (`source .env`), check with `echo $variable_name_here`
make build && make tvl

After a successful start up you can access the tvl rest endpoint at http://localhost:4000.

Run All

# Make sure all .env variables loaded (`source .env`), check with `echo $variable_name_here`
make build && make up
# Optionally you can filter `make up` by `make up network=eth` or network=ftm ect for networks supported in the make file

Setting up GitHub Actions

Create Access Keys for apy-exporter-service-user user.

Create a new environment named production and add the newly created AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Docker setup

The dockerized exporter is controlled via make up command which is invoked via multiple Makefile recipes. It is possible to specify multiple Makefile args that control which exporters are started on which network. The available args to control the startup sequence of containers are the following:

  • network: one of ethereum, fantom, arbitrum, optimism, see make list-networks
  • commands: a list of strings delimited with comma pointing to brownie scripts in ./scripts/ e.g. exporters/partners,exporters/vaults, see make list-commands
  • filter: used for make logs and make down to match the container name substring.

This is a flexible approach to start multiple containers on multiple networks which can be used for a given network or given exporters of a certain type and a combination of both.

Usage examples:

  • list supported networks:
    make list-networks

  • list supported exporter commands:
    make list-commands

  • build the docker image:
    make build

  • start all exporters on all supported networks (requires at least num_exporters x num_networks available cpu cores):
    make up

  • stop all exporters:
    make down

  • stop all docker infrastructure:
    make down filter=infra

  • start only the vaults exporter for ethereum:
    make up network=ethereum commands="exporters/vaults"

  • start only the vaults exporter for all supported networks:
    make up commands="exporters/vaults"

  • start only the treasury exporters for all supported networks:
    make treasury

  • start all available exporters on arbitrum:
    make up network=arbitrum

  • show the logs of all exporters on arbitrum:
    make logs network=arbitrum

  • stop all containers matching a string in their name, e.g. treasury:
    make down filter=treasury

  • start veYFI exporter on ethereum:
    make veYFI

  • start APY exporter on ethereum:
    make apy network=eth

  • start APY Debug on ethereum for a specific vault:
    export DEBUG_ADDRESS=vault_address_here && make debug-apy network=eth

  • start APY preview for curve pools:
    make curve-apy-previews

  • debug ypm prices: make debug-price network=optimism

yearn-exporter's People

Contributors

0xbasically avatar 0xkofee avatar amantay-a avatar anthonymartin avatar banteg avatar bobthebuidler avatar crebsy avatar darkghost7 avatar dudesahn avatar dyk3878 avatar franzns avatar garywackett5 avatar iris112 avatar jainkunal avatar jstashh avatar kyhoon avatar mariuspod avatar numan avatar nymmrx avatar petrovska-petro avatar plutoegg avatar pmdaly avatar rashiq-ddc avatar saltyfacu avatar sandra-deeelite avatar smmackey avatar spoolfi avatar thetechnocratic avatar tymmesyde avatar xgambitox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yearn-exporter's Issues

count Ribbon's yvUSDC in Opyn

IMAGE 2021-12-03 12:01:47

0xJiji, [15 Nov 2021, 05:22:59 (15 Nov 2021, 05:17:40)]:
yvUSDC Theta Vault address: 0x8FE74471F198E426e96bE65f40EeD1F8BA96e54f

Lookup from Opyn Controller: https://etherscan.io/address/0x4ccc2339F87F6c59c6893E1A678c2266cA58dC72#readProxyContract

  1. First, call the accountVaultCounter function accountVaultCounter(0x8FE74471F198E426e96bE65f40EeD1F8BA96e54f)
  2. Then call the getVault function getVault(0x8FE74471F198E426e96bE65f40EeD1F8BA96e54f, 20)
  3. The deposited yvUSDC amount is the last number in the tuple

Relevant telegram thread: https://t.me/c/1410227556/4218

Reliably publish APY data from yearn exporter

Background

APY data for all data is is generated and published to S3. The data is consumed and displayed in various places, including https://yearn.finance .

It is critical this data be reliably generated and published to S3. Currently, the data is generated a published using systemd just running on a random machine that is not actively managed or monitored.

Goal

We want to publish publish this data in a more reliable way. More specifically we want:

  1. Run the script in a docker container using a scheduled task on AWS Fargate. The infrastructure should be defined using AWS CDK .
  2. Capture any errors when generating this data with Sentry.
  3. Export useful metrics to Graphite. Create a dashboard in Grafana with alerting.

Each step can be implemented in parallel.

[EXP-50-250] s3 script: No data for vaults was found in generated data

[2022-02-27 15:45:14.379505]
๐Ÿ”ฅ API (vaults) update for Fantom failed!
Traceback (most recent call last):
File "/yearn-exporter-fantom/scripts/s3.py", line 237, in with_monitoring
main()
File "/yearn-exporter-fantom/scripts/s3.py", line 180, in main
raise EmptyS3Export(f"No data for vaults was found in generated data, aborting upload")
yearn.exceptions.EmptyS3Export: No data for vaults was found in generated data, aborting upload

[EXP-47-247] Abort S3 upload if generated data is empty

Sometimes S3 script generates empty files which overwrites the data in the S3 bucket and effectively brings down the API used to populate the APY on the website.
Add a simple check before S3 upload is done to prevent above situation.

[EXP-44-245] FTM: s3 script fails because gauge contract is missing controller function

[EXP-138-338] Update partner address - Badger

Previously the vault (0xA696a63cc78DfFa1a63E9E50587C197387FF6C7E) fee split for badger the recipient was 0xB65cef03b9B89f99517643226d76e286ee999e77, moving forward it will require to be 0xD0A7A8B98957b9CD3cFB9c0425AbE44551158e9e

Add missing module

  1. git clone [email protected]:yearn/yearn-exporter.git
    2.brownie run treasury throws an error:
milkyklim@laptop ~/p/y/yearn-exporter (master)> brownie run treasury
Brownie v1.15.2 - Python development framework for Ethereum
Generating interface ABIs...
YearnExporterProject is the active project.
  File "brownie/_cli/run.py", line 49, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 53, in run
    module = _import_from_path(script)
  File "brownie/project/scripts.py", line 149, in _import_from_path
    _import_cache[import_str] = importlib.import_module(import_str)
  File "/Users/milkyklim/.pyenv/versions/3.8.6/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "<frozen, line line, in in
  File "./scripts/treasury.py", line 8, in <module>
    from ypricemagic import magic
ModuleNotFoundError: No module named 'ypricemagic'

Introduced in #111. @BobTheBuidler can you check if all files are in place?

Prices for crvEURSUSDC and crvEURTUSD are incorrect

To reproduce

In a file e.g. scripts/incorrect_prices.py

from yearn.prices.magic import get_price

def eursusdc():
    price = get_price("0x3D229E1B4faab62F621eF2F6A610961f7BD7b23B")
    print(price)

def eurtusd():
    price = get_price("0x3b6831c0077a1e44ed0a21841c3bc4dc11bce833")
    print(price)

brownie run incorrect_prices eursusdc
brownie run incorrect_prices eurtusd

For eursusdc the outputted price is ~$10415.46
This should be (1 eurs + 1 usdc) i.e. ~$2.16

The cause

The registry is providing incorrect information about the number of decimals

  1. Go to https://etherscan.io/address/0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5#readContract
  2. Call get_decimals with the eursusdc pool (0x9838eccc42659fa8aa7daf2ad134b53984c9427b)
  3. The output is (2,6)
  4. This is in the incorrect order, and should be (6,2)

The fix

Use the new V2 registry at 0x4AacF35761d06Aa7142B9326612A42A2b9170E33 which provides the correct values. Fall back to the current registry if get_pool_name is blank.

Likewise the decimal data provided by the registry for eurtusd is incorrect

Base currency must be ETH!

Makes no sense to show the chart (only) with dollar TVL. ETH as base currency should at least be an option. Otherwise it is difficult to say whether there is really any growth at all or whether the chart just shows the price growth of ETH and the corresponding tokens.

Consolidate exporter-endpoints

Currently we have our code for the various api endpoints in multiple repos:

This has the following drawbacks:

  • request sending/parsing is duplicated, possibly in different programming languages
  • portability is weak

Therefore we should merge this into a single repo, possibly yearn-exporter as it's the closest to the data and we have already the /v1 routes in it.

Use introspection for describing strategies

We can infer which numeric parameters an unknown strategy has to offer by introspecting the contract's ABI.

It would still require to manually specify which ones are to be scaled.

A simple example:

>>> {x['name']: getattr(s, x['name'])() for x in s.abi if x['type'] == 'function' and x['stateMutability'] == 'view' and
 not x['inputs'] and x['outputs'][0]['type'] == 'uint256'}
{
    'blocksToLiquidationDangerZone': 46500,
    'collateralTarget': 730000000000000000,
    'debtThreshold': 0,
    'dyDxMarketId': 3,
    'estimatedTotalAssets': 0,
    'expectedReturn': 0,
    'getCurrentPosition': (0, 0),
    'getblocksUntilLiquidation': 115792089237316195423570985008687907853269984665640564039457584007913129639935,
    'minCompToSell': 100000000000000000,
    'minReportDelay': 86400,
    'minWant': 0,
    'netBalanceLent': 0,
    'predictCompAccrued': 0,
    'profitFactor': 100,
    'storedCollateralisation': 0
}

[EXP-65-265] Empty ABI for WBTC on arbitrum

using Contract.from_explorer fails

>>> c1 = Contract.from_explorer('0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f')
>>> c1.name()
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 765, in __getattribute__
    raise AttributeError(f"Contract '{self._name}' object has no attribute '{name}'")
AttributeError: Contract 'ClonableBeaconProxy' object has no attribute 'name'
>>> c1.abi
[
    {
        'inputs': [],
        'stateMutability': "nonpayable",
        'type': "constructor"
    },
    {
        'stateMutability': "payable",
        'type': "fallback"
    },
    {
        'stateMutability': "payable",
        'type': "receive"
    }
]

using interface.ERC20 works

>>> c2 = interface.ERC20('0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f')
>>> c2.name()
'Wrapped BTC'

https://sentry.yearn.vision/organizations/yearn/issues/1050/?environment=aws-production&project=2&query=is%3Aunresolved

[EXP-67-267] APY calculation error for EURT vault

APY is erroring for the EURT vault 0x0d4EA8536F9A13e4FBa16042a46c30f092b06aA5

Add this to the bottom of scripts/apy.py

def eurt():
    calculate_apy("0x0d4EA8536F9A13e4FBa16042a46c30f092b06aA5")

then run brownie run apy eurt

The following error should be outputted:

Running 'scripts/apy.py::eurt'...\
File "brownie/_cli/run.py", line 51, in main\
return_value, frame = run(\
File "brownie/project/scripts.py", line 103, in run\
return_value = f_locals\[method_name\](\*args, \*\*kwargs)\
File "./scripts/apy.py", line 135, in eurt\
calculate_apy("0x0d4EA8536F9A13e4FBa16042a46c30f092b06aA5")\
File "./scripts/apy.py", line 55, in calculate_apy\
print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))\
File "./yearn/v2/vaults.py", line 201, in apy\
return apy.curve.simple(self, samples)\
File "./yearn/apy/curve/simple.py", line 40, in simple\
raise ApyError("crv", "no gauge")\
ApyError: ('crv', 'no gauge')

[EXP-63-263] APY calculation of eurs-usdc vault fails

brownie run apy eurs_usdc

fails with this error:

Running 'scripts/apy.py::eurs_usdc'...
  File "brownie/_cli/run.py", line 51, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "./scripts/apy.py", line 132, in eurs_usdc
    calculate_apy("0x801Ab06154Bf539dea4385a39f5fa8534fB53073")
  File "./scripts/apy.py", line 55, in calculate_apy
    print(json.dumps(dataclasses.asdict(vault.apy(samples)), indent=2))
  File "./yearn/v2/vaults.py", line 201, in apy
    return apy.curve.simple(self, samples)
  File "./yearn/apy/curve/simple.py", line 43, in simple
    raise ApyError("crv", "no gauge")
ApyError: ('crv', 'no gauge')

nginx-prometheus-exporter can not start nginx client

Hi
I was trying to run the yearn-exporter on my Ubuntu but I am getting the error related to nginx client starting.
Here is my error message.

2021/07/13 19:02:23 Could not create Nginx Client: expected 200 response, got 404

Is there any additional settings to be customized in prometheus?
Thanks.

Yearn marketing idea: rabbithole for v3 Yearn

Would be effective if we allocated funds so users who access v3 Yearn when it is passed beta phase can earn a reward. I believe Yearn has done this in the past. This would be a good way to reach out to the community and grow our brand

Add Earn

Add Earn v1 and v2 (and v3?) for better tvl stats.

[EXP-72-272] Implement uniswap v3 for price magic

Implement a uniswap v3 price oracle because some tokens don't have enough liquidity and return incorrect values.

rETH: https://etherscan.io/token/0xae78736Cd615f374D3085123A210448E74Fc6393

>>> magic.get_price('0x5c0A86A32c129538D62C106Eb8115a8b02358d57')
DEBUG yearn.prices.magic:101 getting price for token 0xae78736Cd615f374D3085123A210448E74Fc6393 with market UniswapV2Multiplexer
DEBUG yearn.prices.magic:106 UniswapV2Multiplexer -> 0.06600946269098168
DEBUG yearn.prices.magic:106 CurveRegistry -> 0.06606106891317451

https://docs.uniswap.org/protocol/reference/smart-contracts

[EXP-52-252] Malformed token errors breaking historical exporters

FTM

could not fetch price for malformed token 0x58e57cA18B7A47112b877E31929798Cd3D703b0f on Fantom at 27501504
https://sentry.yearn.vision/organizations/yearn/issues/534/?environment=staging&project=2

reproduce with brownie:

from yearn.prices import magic
magic.get_price('0x58e57cA18B7A47112b877E31929798Cd3D703b0f', block=27501504)

ETH

failed to get price for malformed token 0xEd4064f376cB8d68F770FB1Ff088a3d0F3FF5c4d on Mainnet at 13967922
https://sentry.yearn.vision/organizations/yearn/issues/651/?environment=staging&project=2

reproduce with brownie:

from yearn.prices import magic
magic.get_price('0xEd4064f376cB8d68F770FB1Ff088a3d0F3FF5c4d', block=13967922)

BlockNotFound crash

When BlockNotFound comes up it crashes the exporter, and it has to be manually restarted.
yearn exporter crash

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.