All You Should Know About Uniswap V2

Updated on 4 November, 2022 3:00 PM
1 min read

Jump to:

    Uniswap enables anyone to create markets and exchange tokens. Uniswap V1, the first version, was made available as a proof of concept in 2018. Production version 2 was released in 2020. Furthermore, Uniswap V3, the most recent version, debuted in 2021. Here we are going to discuss the second version of Uniswap - Uniswap V2.

    What is Uniswap V2?

    On May 19, 2020, Uniswap released its second edition on the Ethereum Mainnet. It came as a welcome upgrade to its predecessor Uniswap V1 which established the foundation for on-chain token swaps and decentralised liquidity pools by rewarding users for providing liquidity and charging small swap fees. Uniswap V2 was released with a lot of new features which made swapping tokens easier and more smooth on the platform.

    Swapping of ERC20 tokens

    Any ERC20 token can be directly pooled with any other ERC20 token in Uniswap V2. Though end users can still use native ETH through helper contracts, wrapped Ether (WETH) is used in place of it in the core contracts. When there isn't a pool established for a direct token swap, this enables Applications to efficiently find "routes" between different tokens.

    For liquidity providers, who could really keep more varied ERC20 token-denominated positions without having to be exposed to ETH, the addition of ERC20 tokens in Uniswap V2 can indeed be advantageous.

    Direct ERC20/ERC20 pairs can also raise costs since passing through Ethereum for a swap between two different assets (like DAI/USDC) requires paying the fees and losses on two different pairs rather than one.

    Price Oracles in Uniswap V2

    With the help of new features, Uniswap V2 makes it possible to have highly decentralized and tamper-resistant on-chain price feeds. This is accomplished by deftly compiling historical data and monitoring prices when they're difficult to manipulate. This makes it possible for outside smart contracts to provide time-weighted, fuel averages of Uniswap pricing over any period of time.

    Flash Swapping on Uniswap V2

    Flash swapping, also known as the ability to “borrow” tokens from a Uniswap pool, carry out any arbitrary transaction with third-party services and then repay the money users initially borrowed, all in one transaction. Since the transaction works instantaneously, if it fails at any point, the entire transaction is reverted. The most apparent application case for this feature is to conduct advantage trades using a liquidity pool, however, there are other use scenarios that have advantages as well, such as lowering gas prices for taking out certain DeFi activities like shutting down a Maker Vault.

    Improvements Compared to Uniswap V1

    Improvements in the technical field in this new version include - making the pool address more reliable and valid using CREATE2 and the ERC20 token pair; writing smart contracts with solidity in place of Vyper; having a built-in "approve" function in meta transaction for liquidity tokens and fixing bugs in Uniswap V1 that causes all remaining gas to be used on failed transactions, etc.

    How does Uniswap V2 work?

    The Manufacturing contract creates a pool for each pair of tokens, and preliminary deposits are made to the pool to provide liquidity. The token's exchange rate is calculated using a constant product formula, which takes into account the demand and supply of two tokens in the pool. The formula is then used to find the value of the token which moves along a curve of the equation.

    Exchange rates are calculated automatically using this simple formula and the corresponding curve indicates all potential token values, so each token pair will have a unique curve that governs the current state of its exchange rates.

    Like this article? Spread the word

    Subscribe to our

    Receive timely updates on new posts & articles about crypto world.