Uniswap V2 API
In the Uniswap V2 protocol, there are two contracts: Factory and Pair. The Factory is seen externally as a site like Pancakeswap or Sushiswap, while the Pair is the actual exchange between two tokens. The relationship between the two contracts ensures that the correct codebase is deployed and that fees are collected properly.
Uniswap V2 is a constant function market maker where tokens are swapped at a price on the constant function curve.
reserve0 * reserve1 = k
Liquidty providers receive an LP Token for the Pair
for adding tokens in the correct proportions of reserve0
and reserve1
. In return a new LP Token for the Pair
is received. Fees are accumulated in reserve0
and reserve1
redeemable by LP Token holders making it a passive income strategy. Traders need to know the volumes of reserve0
and reserve1
to build a quote for a swap.
amount1 = amount0 * reserve1 / reserve0
Liquidity Providers have to pursue an active strategy to mitigate risk of impermanent loss and liquidation.
This toolbox covers Uniswap V2 and all of its forks, cross chain.