# Solving Constant Product for ratio

The constant product is used in decentralized finance. It is used to calculate how much someone gets of currency $Y$ when giving funds of currency $X$ into a trading pool. $X$ and $Y$ indicate the size of funds in the corresponding trading pool, $z$ stands for the amount of funds of currency $X$ given into the pool, $a$ stands for the amount of funds received in currency $Y$. $R$ represents the ratio of the two currencies, $R = Y/X$, $R'$ represents the ratio of the two currencies after the trade

$k = XY$

$a = Y − k/(X+z)$

$X' = X+z$

$Y' = Y-a$

$R' = Y'/X'$

Now my question is: How to solve for $z$ given the variables $X$, $Y$ and $R'$?

Example:

$X=20, Y=10, R=0, z=1$

$k=20∗10 = 200$

$a=10 − 200/(20+1)=0.47619...$

$X'=X+z=21$

$Y'=Y-a=9.5238...$

$R'=9.5238... / 21 = 0.4535...$

## Answer

**Answers can only be viewed under the following conditions:**

- The questioner was satisfied with and accepted the answer, or
- The answer was evaluated as being 100% correct by the judge.

- answered
- 361 views
- $20.00

### Related Questions

- Reconciling Kelly Criterion derivatives
- Compound Interest with monthly added capital
- Amortization Table
- Internal Rate of Return vs Discount Rate
- Optimal Control - Calculus of Variations
- Year 12 Finance - Home loans
- Finding Probability Density Function of a Standard Brownian motion: Conditioning for two different cases
- Solving Constant Product for price

The offered bounty is low.

I increased the bounty

The bounty is too low

I increased the bounty