We start with two equations. Equation 1: χDn−1∑xi+∏xi=χDn+(nD)n Equation 2: χ=(D/n)nA∏xi
Step 1: Simplify Equation 2
Before plugging the messy χ fraction into Equation 1, let’s simplify it first. The denominator is (D/n)n. Distributing the exponent gives nnDn. Since this quantity is in the denominator of a larger fraction, we can invert it and move nn to the numerator:
χ=DnA⋅(∏xi)⋅nn
Now we have a cleaner expression for χ to use going forward.
Step 2: Plug χ into the left side of Equation 1
Let’s start with the left side of Eq. 1: χD˙n−1∑xi+∏xi. Substitute our simplified χ:
[DnA⋅(∏xi)⋅nn]⋅Dn−1∑xi+∏xi
Now group the two D terms so we can simplify them:
DnDn−1⋅(A⋅(∏xi)⋅nn∑xi)+∏xi
To simplifyDnDn−1, subtract exponents: (n−1)−n=−1. That gives D−1=D1. So the D terms collapse into a single D in the denominator.
New left side: DA⋅(∏xi)⋅nn∑xi+∏xi
Step 3: Plug χ into the right side of Equation 1
Start with the right side of Eq 1: χDn+(nD)n. (To save a step, rewrite (D/n)n as nnDn.
Right Side: χDn+nnDn
Substitute our clean χ:
[DnA⋅(∏xi)⋅nn]⋅Dn+nnDn
This is straightforward: the Dn in the denominator cancels with the Dn we are multiplying by.
New Right Side: A⋅(∏xi)⋅nn+nnDn
Step 4: Add the Equals Sign back
Let's glue our New Left Side to our New Right Side.
DA⋅(∏xi)⋅nn∑xi+∏xi=A⋅(∏xi)⋅nn+nnDn
This equation is perfectly accurate! To get the final whitepaper formula, the author just cleans it up in the next two steps so there isn't a giant messy fraction on the left side.
Step 5: Clean-up (Multiply the whole equation by D)
To get rid of the D on the bottom of the Left Side, let's multiply the entire equation by D.
Multiply the Left Side by D:
The D on the bottom of the first part cancels out. The second part becomes D∏xi. Result: A⋅(∏xi)⋅nn∑xi+D∏xi
Multiply the Right Side by D:
The first part just gets a D added to the front. In the second part, Dn×D= Dn+1. Result: A⋅D⋅(∏xi)⋅nn+nnDn+1
Our current equation looks like this:
A⋅(∏xi)⋅nn∑xi+D∏xi=A⋅D⋅(∏xi)⋅nn+nnDn+1
Step 6: Final Clean-up (Divide the whole equation by ∏xi)
Notice how there is a messy (∏xi) floating around in almost every single term? Let's get rid of it by dividing the entire equation by ∏xi.
Divide the Left Side by ∏xi:
It perfectly cancels out in the first term, leaving Ann∑xi. It perfectly cancels out in the second term, leaving just D. Final Left Side: Ann∑xi+D
Divide the Right Side by ∏xi:
It perfectly cancels out in the first term, leaving ADnn. Because the second term doesn't have a ∏xi to cancel, it just drops to the bottom of the fraction, leaving nn∏xiDn+1. Final Right Side: ADnn+nn∏xiDn+1
Glue those two final results together, and you have exactly derived the holy grail Stableswap equation:
Ann∑xi+D=ADnn+nn∏xiDn+1