monorepo icon indicating copy to clipboard operation
monorepo copied to clipboard

As a dev user, I need to calculate optimal proportion for stableswap deposits

Open just-a-node opened this issue 3 years ago • 2 comments

Problem

Since users can deposit any arbitrary amounts via addLiquidity, UIs should be able to use the sdk to determine what the current optimal proportion is for token pairs in a pool.

This will allow for adding tokens in a balanced proportion (if a user has both sides available) OR supply any amounts and conduct a swap-then-deposit into the balanced proportion.

Ideas to solve this

Add a function that swaps any imbalanced amounts into the optimal proportion taking into account:

  1. the slippage from the swap
  2. the pool's altered reserve ratio due to the swap

Acceptance Criteria

  • [ ] takes input amounts[] and calculates the optimal proportion to deposit given current pool ratio + slippage from an internal swap if input amounts are imbalanced + new pool ratio
  • [ ] calls addLiquidity with new balanced amounts[]

Other

just-a-node avatar Jul 29 '22 22:07 just-a-node

Please add your planning poker estimate with Zenhub @rhlsthrm

alexwhte avatar Sep 21 '22 14:09 alexwhte

Confirm if we should remove from Alpha

alexwhte avatar Sep 26 '22 20:09 alexwhte

@just-a-node evaluate getvirtual price vs optimal solution please

alexwhte avatar Oct 13 '22 15:10 alexwhte

This can be calculated using calculateTokenAmount on the user's input for tokenX and tokenY.

just-a-node avatar Nov 03 '22 05:11 just-a-node