monorepo
monorepo copied to clipboard
As a dev user, I need to calculate optimal proportion for stableswap deposits
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:
- the slippage from the swap
- 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
addLiquiditywith new balanced amounts[]
Other
Please add your planning poker estimate with Zenhub @rhlsthrm
Confirm if we should remove from Alpha
@just-a-node evaluate getvirtual price vs optimal solution please
This can be calculated using calculateTokenAmount on the user's input for tokenX and tokenY.