[ADD] LP Position calculation reference implementation
LP Position calculation Reference Implementation
Context
Currently LPers use various ecosystem apps to check their LP position returns (redeemable asset/rune, earnings, fees etc.)
Calculating an LP'ers position is non-trivial. Providing a reference implementation using the midgard endpoints for the broader ecosystem will improve LPer quality-of-life and boost confidence while mitigating the duplicate work necessary for each ecosystem project.
Desired Outcome
A JS implementation to calculate LP positions by pool:
Input:
- thor address
Output:
- Liquidity Added - Asset, Rune
- Liquidity Withdrawn - Asset, Rune
- Redeemable - Asset, Rune
- Earnings - Asset, Rune
- Gain/Loss - Asset, Rune
- current price of asset, rune in USD
- price of asset, rune when Liquidity was added in USD (caveat: some complexity with multiple deposits.)
Out of scope
Historic LP position over time - will be a follow on feature.
Validation
To validate the implementation a raw sql query can be used: https://gitlab.com/thorchain/midgard/-/blob/feature-queries-leifthelucky/internal/db/queries/members_with_details.sql