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
- The questioner was satisfied with and accepted the answer, or
- The answer was evaluated as being 100% correct by the judge.
- answered
- 414 views
- $20.00
Related Questions
- Finding Probability Density Function of a Standard Brownian motion: Conditioning for two different cases
- Black Scholes Calculation
- Disecting Constant Product formula
- Contract Crediting Rate Formula
- Reconciling Kelly Criterion derivatives
- Make a graphical of analysis of the Strong Axiom of Revelead Preference
- Fixed installment loans?
- Compound Interest with monthly added capital
The offered bounty is low.
I increased the bounty
The bounty is too low
I increased the bounty