messari / subgraphs

Standardized subgraphs for blockchain data
MIT License
504 stars 238 forks source link

Inverse Finance QA (Ethereum) Schema Version 1.3.0 Subgraph Version 1.2.2 Methodology Version 1.0.0 #571

Closed bye43 closed 2 years ago

bye43 commented 2 years ago
Description Value
Subgraph Reviewed https://subgraphs.messari.io/subgraph?endpoint=https://api.thegraph.com/subgraphs/name/messari/inverse-finance-ethereum&tab=protocol
Date Reviewed July 13 2022
Schema Version 1.3.0
Subgraph Version 1.2.2
Methodology Version 1.0.0
Evidence Spreadsheet https://docs.google.com/spreadsheets/d/19wfBowLv5-2k4xH5Ubyo8aQKIPuQFDPiShRXhB0bR1A/edit?usp=sharing

Metrics To Review

Protocol Metrics Section Metric Issue
financialsDailySnapshots dailyProtocolSideRevenueUSD Data scaling is off. Some dates are correctly matching Dune, but others are exponentially too large. For example, 7/09/2022 is 1,992,000,000,000,000,500
financialsDailySnapshots cumulativeProtocolSideRevenueUSD Daily is off so this will be too
financialsDailySnapshots dailyTotalRevenueUSD Data scaling is off. Some dates are correctly matching Dune, but others are exponentially too large. For example, 7/09/2022 is 1,992,000,000,000,002,800
financialsDailySnapshots cumulativeTotalRevenueUSD Daily is off so this will be too
financialsDailySnapshots totalDepositBalanceUSD The trend looks correct for this, but based on the Inverse Finance UI, there is about a -50% difference in values for certain dates. Link - https://www.inverse.finance/analytics
financialsDailySnapshots dailyDepositUSD Big Spike on 04/02/2022 that does not look correct
financialsDailySnapshots cumulativeDepositUSD Daily is off, hence cumulative will also be
Pool Overview Pool Metric Issue
INV-DOLA-SLP Reward Token Should be INV rewards for this pool
Pool Metrics Pool Section Metric
marketDailySnapshots cumulativeSupplySideRevenueUSD Daily looks correct, but the cumulative is about 50% off from dune query. Link - https://dune.com/queries/1021789
marketDailySnapshots cumulativeProtocolSideRevenueUSD Scaling is off again here too. Y - axis is going up to 2E23
marketDailySnapshots cumulativeTotalRevenueUSD Scaling is off again here too. Y - axis is going up to 2E23
marketDailySnapshots inputTokenPriceUSD - DOLA: Dola USD Stablecoin Subgraph data type needs to be reviewed to decimals not int as the data does not show if DOLA depegs or not
marketDailySnapshots outputTokenSupply - anDola: Anchor Dola Values looks way off
marketDailySnapshots outputTokenPriceUSD - anDola: Anchor Dola Values looks way off, not close to 1USD
marketDailySnapshots exchangeRate This should be <=1
marketDailySnapshots market-rates Inverse Finance UI is displaying an APY of 1.79% and this field is empty. Link - https://www.inverse.finance/frontier
BroderickBonelli commented 2 years ago

It looks like dailyProtocolSideRevenue data under financialDailySnapshots is off from timestamp 1614125965 to 1615245579, values are too large. Screen Shot 2022-08-01 at 12 16 40 PM

tnkrxyz commented 2 years ago

Thanks for the QA report!

Metrics To Review

Protocol Metrics

Section Metric Issue Response
financialsDailySnapshots dailyProtocolSideRevenueUSD Data scaling is off. Some dates are correctly matching Dune, but others are exponentially too large. For example, 7/09/2022 is 1,992,000,000,000,000,500 This is due to incorrect handling of decimals in stabilizer fee; fixed in #856
financialsDailySnapshots cumulativeProtocolSideRevenueUSD Daily is off so this will be too same as above
financialsDailySnapshots dailyTotalRevenueUSD Data scaling is off. Some dates are correctly matching Dune, but others are exponentially too large. For example, 7/09/2022 is 1,992,000,000,000,002,800 same as above
financialsDailySnapshots cumulativeTotalRevenueUSD Daily is off so this will be too same as above
financialsDailySnapshots totalDepositBalanceUSD The trend looks correct for this, but based on the Inverse Finance UI, there is about a -50% difference in values for certain dates. Link - https://www.inverse.finance/analytics See note below
financialsDailySnapshots dailyDepositUSD Big Spike on 04/02/2022 that does not look correct This is due to price oracle exploit that inflated the price of INV. TVL and deposit balance are not affect, because they have been re-priced using new/un-manipulated price
financialsDailySnapshots cumulativeDepositUSD Daily is off, hence cumulative will also be same as above

totalDepositBalanceUSD

Inverse finance's own deposit balance/TVL at https://www.inverse.finance/analytics seems problematic - it reports $19M DOLA, $1.9M WBTC and $2.9M ETH for 8/23/2022. The on-chain data for these markets report different numbers:

Defillama reports TVL of $9.2M INV, 1.7M FLOKI, but $160k DOLA. If they have the correct DOLA amount ($7.7M), they would have a deposit balance/TVL close to our number of ~$20M.

Pool Overview

Pool Metric Issue Response/Comment
INV-DOLA-SLP Reward Token Should be INV rewards for this pool This is due more strict foreign key policy in newer version of graph-cli/graph-node; it worked fine with earlier version. Fixed in #856

Pool Metrics

Pool Section Metric Response/Comment
marketDailySnapshots cumulativeSupplySideRevenueUSD Daily looks correct, but the cumulative is about 50% off from dune query. Link - https://dune.com/queries/1021789 there was a bug in market level revenue fields. This is fixed in #856
marketDailySnapshots cumulativeProtocolSideRevenueUSD Scaling is off again here too. Y - axis is going up to 2E23 Due to incorrect handle of stablizer fee. Fixed in #856
marketDailySnapshots cumulativeTotalRevenueUSD Scaling is off again here too. Y - axis is going up to 2E23 same as above
marketDailySnapshots inputTokenPriceUSD - DOLA: Dola USD Stablecoin Subgraph data type needs to be reviewed to decimals not int as the data does not show if DOLA depegs or not The price of DOLA is returned from the oracle contract, getUnderlyingPrice() for "0x7fcb7dac61ee35b3d4a51117a7c58d53f0a8a670" (the Anchor DOLA market) returns exactly 1.
marketDailySnapshots outputTokenSupply - anDola: Anchor Dola Values looks way off This is the totalSupply of the anDOLA token. 908113024.0133958 is the correct number
marketDailySnapshots outputTokenPriceUSD - anDola: Anchor Dola Values looks way off, not close to 1USD the outputToken is anDOLA and its price is not the same as DOLA.
marketDailySnapshots exchangeRate This should be <=1 there is a bug in exchangeRate calculation. Fixed in #856
marketDailySnapshots market-rates Inverse Finance UI is displaying an APY of 1.79% and this field is empty. Link - https://www.inverse.finance/frontier Fixed in #856
bye43 commented 2 years ago

Thanks @tnkrxyz for the update! Looks like inverse is indexed fully, so I will give this another go.

tnkrxyz commented 2 years ago

@bye43 , no, the fix hasn't merged yet. Please wait until #856 is merged & the new version (1.2.3) is fully synced.

this-username-is-taken commented 2 years ago

This has been merged in and indexing

tnkrxyz commented 2 years ago

@bye43 the inverse finance subgraph is synced: https://subgraphs.messari.io/subgraph?endpoint=https%3A//api.thegraph.com/subgraphs/name/messari/inverse-finance-ethereum. From what I see, the issues are addressed. Can you please review & see if I missed anything? thx!

tnkrxyz commented 2 years ago

Also, I am adding notes to README about data inconsistencies: https://github.com/messari/subgraphs/pull/876. Feel free to comment here of anything you find.

You may find a lot of warning about 0 totalBorrowBalance and 0 reward token emissions on subgraph.messario.io; those I believe are correct and expected.

bye43 commented 2 years ago
Description Value
Subgraph Reviewed https://subgraphs.messari.io/subgraph?endpoint=https%3A//api.thegraph.com/subgraphs/name/messari/inverse-finance-ethereum
Date Reviewed August 25 2022
Schema Version 1.3.0
Subgraph Version 1.2.3
Methodology Version 1.0.0
Evidence Spreadsheet https://docs.google.com/spreadsheets/d/1nsW8RaV0fSdI9bDP6VO7yNOY2QaIheG_7s2-zliQFkA/edit?usp=sharing

Metrics To Review

Protocol Metrics Section Metric Issue
financialsDailySnapshots dailyProtocolSideRevenueUSD The current dates match and trend looks good, but in 2021 it looks like we are recording a lot more revenue than the dune dashboard. This is reflected in the cumulative protocol side value, as the subgraph number is almost 100% difference
financialsDailySnapshots cumulativeProtocolSideRevenueUSD See notes about daily. Dune dashboard is outputting around 270K and subgraph is outputting around 460K. Link to dashboard - https://dune.com/queries/1014265
financialsDailySnapshots dailyTotalRevenueUSD Same comments as protocolSideRevenueUSD
financialsDailySnapshots cumulativeTotalRevenueUSD The % difference here is much smaller because protocol side revenue is smaller than supply side revenue, but same comments as cumulative protocol side
financialsDailySnapshots dailyLiquidateUSD It looks like certain days are not reporting liquidations when they are recorded on the inverse finance liquidations table. 03/01/2022 (https://etherscan.io/tx/0xc27139d94ab89216822cd74831d5bb16cb98dea7731aa7c6001b5fdac17f8ef2/) and 02/01/2022 (https://etherscan.io/tx/0xe3940ecf00116c246006b84d07329831e29431b5154119d90a7f975bf718857a/) are outputting 0, when it looks like there are liquidations. I linked the etherscan transactions and here is the link to inverse dashboard - https://www.inverse.finance/analytics
financialsDailySnapshots cumulativeLiquidateUSD Daily is off, hence cumulative will also be
usageMetricsDailySnapshots totalPoolCount This time series looks weird and spikes up and down. Also currently reporting 0 pools, but this could be because Inverse has frozen a bunch of stuff.
Pool Overview Pool Metric Issue
ALL POOLS Reward Tokens The reward tokens look like they are outputting two different reward emissions for INV. I think there should only be one INV APR. Maybe this is a FE subgraph.xyz thing? Going to make a note though.
Pool Metrics Comments - I could not load any of the other pools besides DOLA, getting: "JAVASCRIPT ERROR - POOL TAB - Cannot read properties of undefined (reading 'date')". The stETH metrics are coming from what I could see on the schema. Pool Section Metric Issue
Anchor Dolar(DOLA) marketDailySnapshots outputTokenPriceUSD - anDola: Anchor Dola Is this calculated by TVL/outputTokenSupply? If so, the numbers match if the DOLA market TVL is the 19.49M reported on the Inverse UI. But, I think that this number is incorrect, so the actual TVL is 7.7M. Should this number be different then?
Anchor Dolar(DOLA) marketDailySnapshots exchangeRate Same as above
Anchor Dolar(DOLA) marketDailySnapshots rewardTokenEmissionsAmount There should be no INV rewards here, but there are three empty rewardTokenEmissionsUSD fields being output here. Not sure if that is supposed to be the case, making a note.
Anchor Dolar(DOLA) marketDailySnapshots market-rates This looks like it is static, but it is correct for the current lender APR. I think this should be dynamic. Same comments for borrower APR.
Anchor Dolar(DOLA) marketDailySnapshots rewardAPR This does not look wrong since I am not sure if DOLA pool ever had INV rewards, but looks like there two INV rewards in the array, so making a note (related to the pool overview note)
Anchor stETH marketDailySnapshots cumulativeLiquidateUSD This is being reported as 0, but I think there has been very minor liquidations. Link - https://www.inverse.finance/analytics (frontier -> operations -> liquidations -> filter for anstETH only)
tnkrxyz commented 2 years ago

Description Value Subgraph Reviewed https://subgraphs.messari.io/subgraph?endpoint=https%3A//api.thegraph.com/subgraphs/name/messari/inverse-finance-ethereum Date Reviewed August 25 2022 Schema Version 1.3.0 Subgraph Version 1.2.3 Methodology Version 1.0.0 Evidence Spreadsheet https://docs.google.com/spreadsheets/d/1nsW8RaV0fSdI9bDP6VO7yNOY2QaIheG_7s2-zliQFkA/edit?usp=sharing

Metrics To Review

Protocol Metrics

Section Metric Issue Response/Comment
financialsDailySnapshots dailyProtocolSideRevenueUSD The current dates match and trend looks good, but in 2021 it looks like we are recording a lot more revenue than the dune dashboard. This is reflected in the cumulative protocol side value, as the subgraph number is almost 100% difference This is because our subgraph includes stablizer fee from the Stablizer contract (basically trading between DAI and DOLA) in the protocol side revenue. The cumulative stabilizer fee is about $200k as of 26/8/2022: https://dune.com/queries/1205358
financialsDailySnapshots cumulativeProtocolSideRevenueUSD See notes about daily. Dune dashboard is outputting around 270K and subgraph is outputting around 460K. Link to dashboard - https://dune.com/queries/1014265 same as above
financialsDailySnapshots dailyTotalRevenueUSD Same comments as protocolSideRevenueUSD same as above
financialsDailySnapshots cumulativeTotalRevenueUSD The % difference here is much smaller because protocol side revenue is smaller than supply side revenue, but same comments as cumulative protocol side same as above
financialsDailySnapshots dailyLiquidateUSD It looks like certain days are not reporting liquidations when they are recorded on the inverse finance liquidations table. 03/01/2022 (https://etherscan.io/tx/0xc27139d94ab89216822cd74831d5bb16cb98dea7731aa7c6001b5fdac17f8ef2/) and 02/01/2022 (https://etherscan.io/tx/0xe3940ecf00116c246006b84d07329831e29431b5154119d90a7f975bf718857a/) are outputting 0, when it looks like there are liquidations. I linked the etherscan transactions and here is the link to inverse dashboard - https://www.inverse.finance/analytics Good catch! There is due to a bug introduced when fixing exchangeRate. The liquidate amount are tiny because of incorrect decimals. Fixed in #876
financialsDailySnapshots cumulativeLiquidateUSD Daily is off, hence cumulative will also be same as above
usageMetricsDailySnapshots totalPoolCount This time series looks weird and spikes up and down. Also currently reporting 0 pools, but this could be because Inverse has frozen a bunch of stuff. Fixed in #876.

Pool Overview

Pool Metric Issue Response/Comment
ALL POOLS Reward Tokens The reward tokens look like they are outputting two different reward emissions for INV. I think there should only be one INV APR. Maybe this is a FE subgraph.xyz thing? Going to make a note though. The reward tokens is an array because there are separate rewards for borrowers and supplier/lender.

Pool Metrics Comments - I could not load any of the other pools besides DOLA, getting: "JAVASCRIPT ERROR - POOL TAB - Cannot read properties of undefined (reading 'date')". The stETH metrics are coming from what I could see on the schema.

MichaelC is looking into this; hope it gets fixed soon.

Pool Section Metric Issue Response/Comment
Anchor Dolar(DOLA) marketDailySnapshots outputTokenPriceUSD - anDola: Anchor Dola Is this calculated by TVL/outputTokenSupply? If so, the numbers match if the DOLA market TVL is the 19.49M reported on the Inverse UI. But, I think that this number is incorrect, so the actual TVL is 7.7M. Should this number be different then? For all markets the outputTokenPrice is derived from inputTokenPriceUSD * exchangeRate
Anchor Dolar(DOLA) marketDailySnapshots exchangeRate Same as above same as above
Anchor Dolar(DOLA) marketDailySnapshots rewardTokenEmissionsAmount There should be no INV rewards here, but there are three empty rewardTokenEmissionsUSD fields being output here. Not sure if that is supposed to be the case, making a note. I think there are two for rewardTokenEmissionsUSD, again, one each for borrower and lender
Anchor Dolar(DOLA) marketDailySnapshots market-rates This looks like it is static, but it is correct for the current lender APR. I think this should be dynamic. Same comments for borrower APR. This seems to be an issue of the schema. Asked on the discord server: https://discord.com/channels/953684103012683796/961658223444787220/1012879068389183508
Anchor Dolar(DOLA) marketDailySnapshots rewardAPR This does not look wrong since I am not sure if DOLA pool ever had INV rewards, but looks like there two INV rewards in the array, so making a note (related to the pool overview note) the rewardTokens is an array; rewardAPR will be too.
Anchor stETH marketDailySnapshots cumulativeLiquidateUSD This is being reported as 0, but I think there has been very minor liquidations. Link - https://www.inverse.finance/analytics (frontier -> operations -> liquidations -> filter for anstETH only) This is due to the same bug affecting liquidation for financialsDailySnapshots. Fixed in #876

Thanks again for another helpful QA!

bye43 commented 2 years ago

Awesome. Thanks for the explanation for the revenues and the rewards! I will check the other stuff after inverse re-indexes.

tnkrxyz commented 2 years ago

For liquidations in the anStETH market, there were stETH collaterals seized and liquidated, but in our scheme, liquidation are attributed to the market from which the asset is borrowed (for example, if a user deposit stETH and borrow DOLA, when the position is liquidate, this liquidation is attributed to the anDOLA market, not the anStETH market). This is how Dune organizes data too and there is no results from this query: https://dune.com/queries/1210374

bye43 commented 2 years ago

Ahh this totally makes sense! Will mark this as fine too. Thanks again!

tnkrxyz commented 2 years ago

@bye43 , with #876 merged and inverse finance subgraph synced, it is ready for another (hopefully final) round of QA review. Please proceed when you're ready.

Please hold on, I realized I haven't really fixed totalPoolCount for daily metric. Will have to do another PR.

bye43 commented 2 years ago
Description Value
Subgraph Reviewed https://subgraphs.messari.io/subgraph?endpoint=https%3A//api.thegraph.com/subgraphs/name/messari/inverse-finance-ethereum
Date Reviewed September 1 2022
Schema Version 1.3.0
Subgraph Version 1.2.4
Methodology Version 1.0.0
Evidence Spreadsheet https://docs.google.com/spreadsheets/d/14X00utp9dHeeXlto9RCWvm-3cOwZMPy3qRfF5q7Upno/edit?usp=sharing
Pool Metrics Pool Section Metric Issue
Some Pools (ex. stETH) marketDailySnapshots All Metrics besides TVL Not exactly sure what is going on here, but there is a warning for totalBorrowBalanceUSD being 0, all revenue metrics are 0, and reward emissions. Is this because everything is borrowed in DOLA? Even if this is DOLA related, there should be supply APY, but there is nothing. Maybe because Inverse Finance is hacked?
bye43 commented 2 years ago

Description Value Subgraph Reviewed https://subgraphs.messari.io/subgraph?endpoint=https%3A//api.thegraph.com/subgraphs/name/messari/inverse-finance-ethereum Date Reviewed September 1 2022 Schema Version 1.3.0 Subgraph Version 1.2.4 Methodology Version 1.0.0 Evidence Spreadsheet https://docs.google.com/spreadsheets/d/14X00utp9dHeeXlto9RCWvm-3cOwZMPy3qRfF5q7Upno/edit?usp=sharing Pool Metrics

Pool Section Metric Issue Some Pools (ex. stETH) marketDailySnapshots All Metrics besides TVL Not exactly sure what is going on here, but there is a warning for totalBorrowBalanceUSD being 0, all revenue metrics are 0, and reward emissions. Is this because everything is borrowed in DOLA? Even if this is DOLA related, there should be supply APY, but there is nothing. Maybe because Inverse Finance is hacked?

These pool metrics being 0 are confirmed, as there was actually no borrowing during this time period. @this-username-is-taken @tnkrxyz this is good to be frozen. Going to close the issue!