ref-finance / ref-contracts

Smart contracts for Ref Finance
MIT License
96 stars 55 forks source link

Get map of liquidity info for given account #23

Open marco-sundsk opened 3 years ago

marco-sundsk commented 3 years ago

There is a nature and strong requirement that a ref LP wanna know all his liquidity share throughout all the pools. But now, the contract is lack of liquidity record for given user. There are two ways to address that:

I would prefer the second way, cause the amount of LP woundn't be so large, and this would be a frequently query entry.

kcole16 commented 3 years ago

@marco-sundsk Seems fine to me to add the lookup. Thoughts @ilblackdragon?

kcole16 commented 3 years ago

@evgenykuzyakov What are your thoughts on this approach?

referencedev commented 3 years ago

This doesn't really provide enough information and adds extra storage needs which is complicated to track. Instead indexer should be used. By processing all add/remove liquidity, indexer can maintain current amount of deposited liquidity by user and also calculate ROI from fees by maintaining deposited base vs the current amounts allocated for this LP tokens. Doing this as part of smart contract is possible but will be very complex.

Generally, indexer is needed to maintain all the relevant info anyway and it all should shift there.