messari / subgraphs

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

Osmosis - OSMOSIS QA #1775

Open SerenityFund opened 1 year ago

SerenityFund commented 1 year ago

Review Info

Description Info
Subgraph Reviewed https://subgraphs.messari.io/subgraph?endpoint=https://api.thegraph.com/subgraphs/name/corerouter/osmosisdex&tab=protocol
Schema Version 1.3.0
Subgraph Version 1.0.0
Methodology Version 1.0.0
Evidence Spreadsheet https://docs.google.com/spreadsheets/d/1bJ5oC-0HW84huduXLxMMDmCyycNEJKjS/edit?usp=share_link&ouid=104027705798814439445&rtpof=true&sd=true

Metric to Review

TVL

TVL data shows a massive 5-day average discrepancy of more than 11k% with the official website data and Defi Llama data.

Subgraph - TVL (5-day average) Official Website - TVL (5-day average) Absolute difference Difference %
20,886,164,864 176,949,959 20,709,214,905 11,703.43%
Subgraph - TVL (5-day average) Defi Llama - TVL (5-day average) Absolute difference Difference %
20,886,164,864 171,500,179 20,714,664,685 12,078.51%

Daily Volume USD

The daily volume data is showing a high 5-day average discrepancy of -28.5% with the official website data and Defi Llama data.

Subgraph - Volume (5-day average) Official Website - Volume (5-day average) Absolute difference Difference %
11,292,759 15,796,955 -4,504,196 -28.5%
Subgraph - Volume (5-day average) Defi Llama - Volume (5-day average) Absolute difference Difference %
11,292,759 15,794,000 -4,501,241 -28.5%

Revenue

Subgraph - Daily Total Revenue (5-day average) Defi Llama - Daily Total Revenue (5-day average) Absolute difference Difference %
23,653 34,232 -10,579 -30.90%
Subgraph - Daily Total Revenue (5-day average) Token Terminal - Daily Total Revenue (5-day average) Absolute difference Difference %
23,653 32,888 -9,234 -28.08%

Daily Transaction Count

Daily transaction count data is not mathematically in line with the sum of deposit, withdraw, and swap daily counts in the past five days.

Total Pool Count

The official website data only shows pools up to 926 instead of 1088.

Pool Overview - TVL

Subgraph - Osmosis-1 Pool TVL Official Website - Osmosis-1 Pool TVL Difference %
$260,362,875 $68,585,239 279.62%
Subgraph - Osmosis-678 Pool TVL Official Website - Osmosis-678 Pool TVL Difference %
$80,226,121 $25,790,501 211.07%
Subgraph - Osmosis-604 Pool TVL Official Website - Osmosis-604 Pool TVL Difference %
$72,276,302 $2,328,586 3003.87%
Subgraph - Osmosis-13 Pool TVL Official Website - Osmosis-13 Pool TVL Difference %
$49,148,538 $8,313 591125.05%
Subgraph - Osmosis-4 Pool TVL Official Website - Osmosis-4 Pool TVL Difference %
$34,373,951 $812,972 4128.18%
Subgraph - Osmosis-704 Pool TVL Official Website - Osmosis-704 Pool TVL Difference %
$17,828,100 $11,894,722 49.88%
Subgraph - Osmosis-6 Pool TVL Official Website - Osmosis-6 Pool TVL Difference %
$17,528,180 $212,526 8147.55%

Editorials

There are some errors that we've noticed and are not necessarily data errors.

Subgraph data is not updated

Pool and Events section

Please refer to the attached worksheet for more details.

bye43 commented 1 year ago

@corerouter Osmosis QA here

corerouter commented 1 year ago

Thank you very much for the validation. Please find my feedbacks below.

Osmosis Dex is the first DeFi subgraphs for Cosmos blockchain according to my knowledge. The support for Cosmos by The Graph is just rolled out and so far I did not find any important projects using the infrastructure. Just some demo subgraphs from the graph node development team can be found. It causes great challenges for the subgraph development.

  1. For TVL, volume and revenue related data, they all relate with the problem there are not price and accurate token balance data for osmosis dex.

At the beginning , there is not even stable coin on osmosis. So as suggested by @this-username-is-taken I retrieve daily price data from coingecko and use them as baseline price. Once the USDC was introduced into osmosis, I then deduce other coin's price when they swap with each other. In this way, I can get a relatively accurate price data for tokens in osmosis dex.

However, in osmosis, someone can deposit one coin, for example ATOM, into a liquidity pool such as ATOM/WETH, as liquidity. It is called "Join Swap Extern Amount In" transaction. The problem is in the log for the transaction, it just show how much ATOM is deposited into the pool in the beginning but did not show how ATOM and WETH are swapped, and their respective amount added into the pool as liquidity, as shown in the sample log at https://bigdipper.live/osmosis/transactions/20845D9BA3C17158C660D7EE9BD97755055B49D8C01ABB54E4FAC77BF86384FE Meanwhile, there are not eth_call supported for cosmos subgraph to retrieve the inputTokenBalance change from the block chain.

As a result, I can only compute the resulting inputTokenBalance change by myself. It looks the previous computation causes the TVL and volume problems for some pools. I just came out another solution and initial test shows it has better result.

  1. For Daily Transaction Count, the google sheet shows status is ok, so I assume the result is fine.

  2. For total pool count, the problem will be fixed.

  3. For the problem of Subgraph data is not updated. currently the host service only support data for osmosis chain up to 7.9M blocks, as shown in the status pages for all osmosis subgraph.

    image
  4. According to some Pool and Events sections can not be retrieved at https://subgraphs.messari.io/, I can successfully query such data at https://thegraph.com/hosted-service/subgraph/corerouter/osmosisdex, as shown below. So I think it is because there are some missmatch between the subgraph and validation portal's query graphQL. We may need to involve the validation portal's developers into the loop in order to fix the problem.

    image

The current fix right now is tested in some pools. Once the result is ok, I will deploy the new version to sync the whole osmosis dex transactions. However, as the subgraph will index all the osmosis chain from block 0, it may takes weeks to fully sync. The whole develop-test-develop process is very slow due to the slow syncing speed for osmosis chain by the host service.

Meanwhile, given the limited functionality of cosmos subgraph and infrastructure support of The Graph host service for cosmos block chain, I am afraid the non-EVM osmosis dex subgraph, based on new delivered The Graph support for cosmos block chain, may be very difficult, even impossible, to reach the same level data accuracy comparable with EVM subgraph.

Thank you very much for your work again.

bye43 commented 1 year ago

@corerouter Thanks for the comprehensive write-up looks like to me the majority of the issues are around TVL, but there should be a fix in place for that? When you deploy the new deployment with the fixes do you mind doing uploading the link here?

corerouter commented 1 year ago

Thanks for the comprehensive write-up looks like to me the majority of the issues are around TVL, but there should be a fix in place for that? When you deploy the new deployment with the fixes do you mind doing uploading the link here?

@bye43 No problem. It may takes weeks as the osmosis subgraph on host service is very slow right now. Thank you very much for your understanding.

bye43 commented 1 year ago

@corerouter Is the deployment link above the same one for the updated version. If not, do you mind sharing just so we can track the syncing % to re-QA ASAP? Thanks!

corerouter commented 1 year ago

@corerouter Is the deployment link above the same one for the updated version. If not, do you mind sharing just so we can track the syncing % to re-QA ASAP? Thanks!

Yes. It is the same one. I just checked it and found the latest fix has finished syncing. The TVL data in the latest version improve a lot in terms of accuracy but still somehow off. (The subgraph shows total TVL about 591M while the dapp shows TVL at about 163M. I will be able to dig deeper into it early next week to see whether I can still make some progress on this issue. Thanks!

bye43 commented 1 year ago

@corerouter Any update on the TVL issue here?

corerouter commented 1 year ago

@corerouter Any update on the TVL issue here?

It looks like the method used in EVM subgraph to add up inputTokenAmount and then totalValueLocked does not accurately matches with data shown at osmosis stats pages at https://info.osmosis.zone/

I tried to solve it by querying the current pool's token amount directly with querying interface provided by osmosis chain from time to time in the subgraph, which is similar with EVM chain's contract call. Whether or not the feature is supported by cosmos subgraph remains an unknown issue. This question was asked in cosmos channel of The Graph discord several weeks ago, but so far it does not receive any positive confirmation from the team.

Meanwhile, I am also making some changes on the input token amount and total value locked tracking and then test it. Once there is any positive result, I will update in this issue. Thanks!

bye43 commented 1 year ago

@corerouter Just checking on this again, if you need anything on our side let us know!

corerouter commented 1 year ago

A test fix was deployed and is syncing at https://thegraph.com/hosted-service/subgraph/corerouter/osmosis?version=pending now.

The problem now is related with USD denominated TVL and volume data. The USD value for osmos and cosmos token in this subgraph comes from coingecko and then other coins' price derive from them as there are not USDC and USDT stable coin before, which creates a lot of mess here. I would suggest to have a price lib for osmosis as same as for other chain such as Ethereum and Arbitrum. Then this subgraph will get token price by calling the price lib. It can isolate problem better and will also make it easier to deduce USD denominated TVL and volume data.

bye43 commented 1 year ago

@corerouter Thanks for the update! @steegecs @harsh9200 any thoughts on supporting a price library for cosmos?

cc: @dmelotik for visibility

steegecs commented 1 year ago

@harsh9200 is probably better suited to answer this, I am not sure that Cosmos can be integrated into the pricing library with existing methods.

harsh9200 commented 1 year ago

@bye43 I will get back to you on this after doing some research on osmosis.