0
1
28
We know that since we are swapping in an amount, the next reserve of that asset is just the previous reserve plus the amount in __with fees__
29
equals
30
Use the x2 risky reserve to calculate the next stable reserve, y2. This uses the `getStableGivenRisky` function.
31
equals
32
Calculate the amountOut, o1, of stable tokens, by finding the difference between next stable and previous stable
33
equals
34
Plot the new reserves on the curve
35
equals
36
Note: the next risky reserves should not include the fees
37
equals
38
Plot the new marginal price using the new points
39
equals
40
equals
41
Since we swapped the risky asset in, which is selling it, the marginal price should decrease between points, which does happen here.
42
Next, lets do a stable swap in: riskyForStable = false, a2 = 1
43
0
10
44
Calculate the next stable reserves, since we know how much stable is being swapped in, include fees in
45
equals
46
Calculate the next risky reserves using the stable reserves, using the function `getRiskyGivenStable`
47
equals
48
The next stable reserve will not include the fee amount
49
equals
50
Plot the reserves after the stable swap in
51
equals
52
Plot the marginal price after the swap stable in
53
equals
54
equals
55
56
57
powered by
powered by
New Blank Graph
Examples