Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexer: User Position APR stats #4

Open
dib542 opened this issue May 2, 2023 · 0 comments
Open

Indexer: User Position APR stats #4

dib542 opened this issue May 2, 2023 · 0 comments

Comments

@dib542
Copy link
Contributor

dib542 commented May 2, 2023

Required

User stats: Pair position APR

The calculation of a user's position's generated APR requires knowledge of:

  • the value that the user deposited into a pool: ie. the equivalent reserve value at that point in time
    (available from /tx_query each deposit and withdrawal has Reserves[0/1][Deposited/Withdrawn])
  • the value of those user's shares now: ie. the most recent equivalent reserve value
    (using current pools state: value = userShares/totalShares*(reserve0*price0 + reserve1*price1))

Solution

This would be best calculated via the indexer so that the query for original deposited value can be calculated from all of the matching rows and return only that value (rather than having to send the entire paginated history of the user's deposits and withdrawals to calculate the previous deposit value).

This endpoint could receive a query of /users/deposits/{address}/APY and that could return a single number for each deposit pair. Or if extended a query of /dualitylabs/duality/dex/user/deposits/{address} could have APY appended to the rest of the row data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant