RealToken-Community / dashboard-v2

https://dashboard.realt.community/
4 stars 2 forks source link

Improved accuracy in state indexing: Addressing inaccuracies in TheGraph implementation #19

Open NandyBa opened 9 months ago

NandyBa commented 9 months ago

Issue

According to the following illustrations, it's evident that the current implementation of TheGraph only considers deposit and borrow amounts, neglecting the borrow and deposit rates. This leads to inaccuracies in the representation of borrowed amounts, as detailed below.

Illustration of the Issue:

Case 1: Illustration of borrow balance issue

For instance, a 10.5k xDAI borrow balance is misrepresented as a 10k xDAI borrow on the community dashboard due to the omission of borrow rate by TheGraph’s current implementation.

Capture d’écran 2023-10-02 à 00 49 40

Screenshot 1: Screenshot of RMM (match on-chain data)

Capture d’écran 2023-10-02 à 00 48 43

Screenshot 2: Screenshot of Community Dashboard (un-match on-chain data)

Case 2: Illustration of deposit balance issue

For instance, a 54,1k xDAI is misrepresented as a 53k xDAI deposit on the community dashboard due to the omission of deposit rate by TheGraph’s current implementation.

Capture d’écran 2023-10-02 à 00 57 58

Screenshot 3: Screenshot of Gnosisscan (Gnosis chain explorer) Show the 53k deposit and the current balance at 54,1k armmWXDAI (xDAI deposited on the RMM) link

Capture d’écran 2023-10-02 à 00 58 22

Screenshot 4: Screenshot of Community Dashboard (un-match on-chain data)

Here, the screenshot illustrates how the borrow amount is inaccurately depicted on the community dashboard due to the lack of consideration for borrow and deposit rates in TheGraph’s current indexing methodology.

Proposed Solution:

The feature/rmm-debt-from-smart-contract branch has been developed to address this oversight by incorporating borrow and deposit rates, ensuring the accurate representation of borrow amounts in state indexing.

Benefits of the Solution:

Additional Advisory:

While the feature/rmm-debt-from-smart-contract branch serves to rectify the inaccuracies in state representation due to the current limitations of TheGraph implementation, a more sustainable solution would be to address this issue at its root – by updating the indexing code of TheGraph itself.

However, as of now, the codebase for TheGraph’s indexing code is private, and therefore inaccessible for external contributions or modifications. This restricts the possibility of submitting updates or enhancements directly to the source and necessitates interim solutions like the one provided in this branch to manage and mitigate the inaccuracies observed.

Call to Action:

I strongly advise that, once accessible, the TheGraph indexing code be updated to inherently account for borrow and deposit rates to ensure accuracy and reliability in state representations. This would eliminate the need for workaround solutions and provide a more streamlined and cohesive experience for the community.

In the interim, I recommend the integration of the feature/rmm-debt-from-smart-contract branch as a temporary measure to address the current inaccuracies.

Final Thoughts:

Until the accessibility status of TheGraph's indexing code changes, solutions like the one proposed in this branch are pivotal in maintaining accuracy and trust within the community. I look forward to a time when such inherent inaccuracies can be resolved at their source, fostering a more stable and reliable ecosystem for all users.

jycssu-com commented 9 months ago

Unfortunately, even if the code for the subgraph becomes public, it will not be possible to take this change into account. Indeed, the data from the graph can only save the balances at the time of their indexing. As a result, the balances are only updated when the user interacts with the RMM, like make a deposit.

This issue is described and documented on the AAVE subgraphs Github. They offer a solution to calculate real values from data extracted from the graph, using their library @aave/math-utils. It would be interesting to see if this solution would be more durable to integrate because it would avoid unnecessary calls to an RPC

Source :

NandyBa commented 9 months ago

To implement it I need the REALT_GNOSIS_POOL_ADDRESS_PRIVIDER and the REALT_GNOSIS_UI_POOL_DATA_PROVIDER. I already have the REALT_GNOSIS_POOL_ADDRESS_PRIVIDER but missing REALT_GNOSIS_UI_POOL_DATA_PROVIDER.

It's can be good to fork the bgd-labs/aave-address-book adding RealT Market or more easy link all important address on a doc readme.