Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- calculateAdditionalLiquidity :: Amount A -> Amount B -> Amount Liquidity -> Amount A -> Amount B -> Amount Liquidity
- calculateInitialLiquidity :: Amount A -> Amount B -> Amount Liquidity
- calculateRemoval :: Amount A -> Amount B -> Amount Liquidity -> Amount Liquidity -> (Amount A, Amount B)
- checkSwap :: Amount A -> Amount B -> Amount A -> Amount B -> Bool
- lpTicker :: LiquidityPool -> TokenName

# Documentation

calculateAdditionalLiquidity :: Amount A -> Amount B -> Amount Liquidity -> Amount A -> Amount B -> Amount Liquidity Source #

calculateInitialLiquidity :: Amount A -> Amount B -> Amount Liquidity Source #

The initial liquidity is 'ceil( sqrt(x*y) )' where `x`

is the amount of
'Coin A' and y the amount of 'Coin B'. See Eq. 13 of the Uniswap v2 paper.

calculateRemoval :: Amount A -> Amount B -> Amount Liquidity -> Amount Liquidity -> (Amount A, Amount B) Source #

checkSwap :: Amount A -> Amount B -> Amount A -> Amount B -> Bool Source #

A swap is valid if the fee is computed correctly, and we're swapping some positive amount of A for B. See: https://uniswap.org/whitepaper.pdf Eq (11) (Page 7.)

lpTicker :: LiquidityPool -> TokenName Source #

Generate a unique token name for this particular pool; based on the tokens it exchanges. This should be such that looking for a pool exchanging any two tokens always yields a unique name.