 #### DW

03-08-2021

18:21

1/ A general way to construct a @CurveFinance -esque curve, so you can make your own one. The general form of the invariant: (x+K) (y+K) = (s+K)^2 - s is the constant, a representation of pool liquidity - K controls the curve's flatness

2/ We define u = xy/s^2 and let K be an increasing function of u such that when x:y gets closer to the 1:1 peg, K becomes higher, the curve then becomes flatter examples: - Uniswap: K = 0 - Curve V1: K = Asu - Curve V2: K = Asu/(1+u)^2

3/ Plotting the graph...

4/ Intuitively, we can raise the "u" in K to a higher degree for a "flatter" curve (e.g. K = Asu^10) (though it's likely intractable and not computable on-chain due to gas consumption & precision loss)

5/ yet, we can use forms like y=1/(1-x) to get a similar effect like y=x^n, while keeping the formula computable on-chain K = Asu^10 (exponential) K = Asu/(1-u) (hyperbolic) you can find similar term in @CurveFinance v2

6/ lastly, to peg to a ratio other than 1:1, simply apply a linear transformation to the xy-plane. peace 