About Uniswap Protocol:
UniSwap is a contract for commercial substitute ERC-20 tokens on Ethereum. Eliminates intermediaries and an unneeded class of rent-seeking, allowing faster and competed for exchanges.
It makes trade-offs decentralization, censorship resistance, and security prioritized. UniSwap is an Open-source software licensed under GPL. Its protocol is developed by a small team in Brooklyn, NY, alongside collaborators worldwide. We are committed to open-source software and building on the decentralized web. The objective of UniSwap is to allow users to execute 'swaps' between tokens generated on the Ethereum network (mainly ERC-20 tokens).
What does this mean?
It's like doing a trading card swap. When you want to change a token, you are forced to go through a centralized exchange, pay commissions, and compromise some privacy. Not counting the fact that usually to exchange one ERC-20 token for another (let's say Chainlink for BAT), you have to buy ETH with your Link token, and with that ETH, buy BAT, a very high gas expense and commissions. The swap offers another solution, to be able to make immediate changes at the atomic level, without going through any centralized entity, all through a protocol. And despite how wonderful this sounds, the most revolutionary thing about UniSwap is not the "swap" itself, but the logic that they have integrated into the protocol to make this possible.
How does Uniswap work?
UniSwap is an automated liquidity protocol. In practical terms, this means smart template commitments are defining a regular manner to make that liquidity pools and corresponding markets that are compatible with each other. There is no order book and also, no centralized parties, and no facilitator of sales. Each fund is determined by a quick deal, including services to facilitate tokens exchange, adding liquidity. Each fund uses the function x*y='k' to maintain a curve along which trades can happen.
How are the calculations been done?
Values are calculated according to the amounts of each token. The smart-contract maintains a constant using the following function: x*y='k'. In this case 'x' = token0, 'y' = token1, 'k' = is the constant obtained. For each business, a certain amount of tokens are removed from the pool for the other token. The balances held by the smart contract are adjusted during the trade's execution, therefore changing the price to maintain 'k.'