# Swap Details

## #

Constant Function Market Maker (CFMM)The swap feature uses a CFMM with a curve which has the following features.

- It is flat around
`x = y`

. - As in a CPMM, even very high inputs of asset 1 in a trade will never empty the asset 2 side of the trade as the function can make the outgoing asset arbitrarily expensive.

This flat curve function is suitable for asset pairs that are highly correlated.

### #

Formulas#### #

Before Fees`U(x,y) = (x+y)^8 - (x-y)^8`

#### #

Application and Integration of FeesThe fees on each pair will be applied to the gross input on the swap, leaving the net input. The output of the swap is calculated using the Newton-Raphson method (MathWorld or Wikipedia) applied to the CFMM curve and the net input.

Below are graphs for the constant sum, the constant product and the constant function.

#### #

Utility CurveGreen: Constant product (hyperbola)

Blue: Constant sum (line)

Orange: Constant function

Source: https://github.com/tezos-checker/flat-cfmm

#### #

Response FunctionGreen: Constant product
Blue: Constant sum

Orange: Constant function

Source: https://github.com/tezos-checker/flat-cfmm

## #

PairsFor convenience the youves swap frontend also offers to swap pairs, which are not on the youves backend. This includes for example the uUSD/YOU pair on Quipuswap.

Pairs considered for the flat curve CFMM, should be highly correlated.

# | Pair | Fees | Status | Swap Location |
---|---|---|---|---|

1 | wwBTC/tzBTC | 0.15% | Active | youves swap |

2 | uBTC/tzBTC | 0.15% | Active | youves swap |

3 | uUSD/wUSDC | 0.15% | Active | youves swap |

4 | uUSD/kUSD | 0.15% | Active | youves swap |

For the pairs on youves, 50% of the fees go to the platform profits and 50% go to the liquidity providers.

## #

Liquidity ProvisionAny user can become a liquidity provider.

### #

Adding LiquidityFor each pair, a user can become a liquidty provider by adding the tokens of the first and the second asset exactly in the same proportion as they are in the liquidity pool at that moment.

### #

Removing LiquidityAt any point in time a liquidity provider can remove its share of liquidity from the Swap feature. The proportion of the two assets may be different than what was initially put in.