Are you looking for an Uniswap Clone Script?

You can make Massive $profit per day with this platform and we have the solution for you!

"We are only selling 7 Uniswap Clone Copies" Fast installation and you'll get the source code in your server.

Please try your Uniswap Clone DEMO:

DEMO URL:
www.CafeScripts.com/UniSwap

Did you know you can make more than 200k per month with this system?

More info? Uniswap is a decentralized protocol for automated liquidity provision on Ethereum

Exchange tokens and earn with liquidity pools with Uniswap

Introducing Uniswap

You may have heard of an Ethereum based exchange named Uniswap. Uniswap is a decentralised exchange in the form of two smart contracts hosted on the Ethereum blockchain, as well as a public, open source front-end client. It’s a 100% on-chain market maker allowing the swapping of ERC20 tokens, as well as ETH to an ERC20, and vice-versa.

It also allows you to contribute to liquidity pools for any ERC20 token, and therefore gain commissions in the form of exchange fees for doing so.

Uniswap sounds like a big deal; being able to exchange any ERC20 token, including the native ETH token, without middle men, and allowing anyone with an Ethereum address to contribute to the exchange’s liquidity, and thus earn from it, is no small feat.

This article will break down exactly what the exchange can do and how you can benefit from it, as well as the underlying formulas for calculating exchange rates for each token.

A live running front-end deployment of the exchange can be found at https://uniswap.exchange. At this time the MetaMask plugin is needed for the exchange to operate as a means to interact with your Ethereum addresses.

Let’s run through some high level features of Uniswap, before exploring the smart contracts and the underlying workings of the exchange.

Uniswap at a High Level

Let’s dive straight in to what Uniswap offers, starting with its Exchange infrastructure.

Uniswap Exchange at a High Level

  • Uniswap is a public, open source, non-profit project aimed to benefit the Ethereum ecosystem. The smart contracts of the project have been written in both Vyper and Solidity.
  • It’s 100% on-chain. There are no dependencies required outside the Ethereum blockchain for it to operate. As a result, anyone can access Uniswap’s full capabilities using web3 and embed Uniswap functionalities within their apps as they please.
  • Uniswap consists of 2 smart contracts — a “Factory” contract and “Exchange” contract.

The Exchange contract can support any ERC20 token. But how do we set up an exchange for a particular ERC20? With one method call from the Factory.

By calling the createExchange method from the Factory contract, an Exchange contract is then deployed for a particular ERC20 token you specify. Every ERC20 token therefore, by design, utilises its own Exchange smart contract.

Uniswap is 100% on-chain. The “Factory” smart contract contains an exchange registry, and a method to deploy an “Exchange” contract for a particular ERC20 token. An exchange can be created for any valid ERC20 token.

  • Cheap gas prices compared to other decentralised exchanges. Take a look at the gas benchmarks of the whitepaper, and observe that ERC20 swaps, ERC20 to ETH swaps, and ETH to ERC20 swaps are all significantly cheaper than alternative decentralised exchanges.
  • As mentioned, the exchange supports ERC20 to ETH, ETH to ERC20, and ERC20 to ERC20 token swaps. Not only this, you can also perform a token swap and then send the resulting tokens to another Ethereum address, all in one smart contract method call. This is handy if you are exchanging tokens for someone else, or if you are diversifying your holdings to multiple ETH addresses.

But in order for the exchange to work and for swaps to take place, there needs to be tokens readily available — where do they come from? They are supplied by liquidity providers, and anyone can be one, by depositing tokens into an Exchanges’ liquidity pool.

Liquidity Pools at a High Level

Liquidity pools are Uniswaps’ decentralised liquidity solution, allowing anyone to take part in them and to be rewarded for supplying this liquidity.

  • Liquidity (deposits) can be freely added and removed (withdrawn) from each ERC20 Exchange contract.
  • Adding liquidity to an ERC20 also requires an equivalent value of ETH to be deposited: Concretely, 50% value ETH and 50% value ERC20. In reality this is very simple to do: Within the official front end app (GithubLive Exchange), one simply chooses the amount of ETH to deposit and the ERC20 equivalent will automatically calculated using the current exchange rate from the contract.

Adding liquidity to a Uniswap token pool alsorequires an equivalent value of ETH to be deposited: Concretely, 50% value ETH and 50% value ERC20.

  • A 0.3% fee is charged with every swap made. This fee is then dispersed to liquidity providers dependent on each provider’s share of the liquidity pool. E.g. If my deposit accounted for 50% of the pool, I would receive half of that 0.3% fee.
  • In the event of ERC20 to ERC20 swaps, two transactions are made, therefore two 0.3% fees are charged. ETH to ERC20 or ERC20 to ETH swaps only require one 0.3% fee. Check out the fee structure of the white paper to see this in more detail.
  • You are free to withdraw your pool shares at any time, as well as any commissions you have made in the process.
  • When depositing a token into a liquidity pool, Uniswap’s own liquidity token is minted, the amount of which is based on your pool share. These tokens are used to keep a record of your share of a pool. This happens behind the scenes when you add liquidity. However, you are free to check the amount of liquidity tokens you own on Etherscan — they adhere to ERC20 standards and can be browsed on such platforms, on MetaMask, etc.
  • As liquidity tokens adhere to ERC20 standards, they can also be tradedenabling transfer of pool share ownership without removing actual liquidity from said pool.
  • Removing (withdrawing) tokens from a liquidity pool consequently burns the liquidity tokens associated with that share.

Every Uniswap Exchange mints its own Liquidity tokens (another ERC20 token) when liquidity is added to keep track of the share ratios of the liquidity pool. These tokens are burned upon withdrawing funds from a pool. You are also free to exchange your liquidity tokens to transfer share ownership, without disturbing the actual pool funds.

Exchange Rates at a High Level

  • Exchange rates for an ERC20 token are calculated based on an equation:
    x * y = k . The exchange rate of a token will always be at a particular point lying on the resulting curve of this equation.
  • k is a constant value that never changes, whereas x and y represent the quantity of ETH and ERC20 tokens available in a particular exchange that ultimately determines the exchange rate.

x * y = k Explained

The x * y = k formula is important to understand as it determines the price for all exchange tokens. Vitalik Buterin posted on Ether Research in early 2018 describing the equation and how it could be utilised with a decentralised exchange. The post has received a lot of attention and feedback, and ultimately has been adopted to make Uniswap function as a market maker.Within that aforementioned post, the following graph was posted describing the x * y = k formula:

Start Today your Uniswap Project!