How to

Uniswap: where you can swap any ERC20 token

Important: To do this tutorial, you will need to have a Metamask wallet. If you don’t have one, I recommend visiting this link, which will take you to a tutorial to learn how to use this wallet.

Uniswap is a decentralized exchange marketplace that enables exchanges between any ERC20 token and ETH, without intermediaries and with a commission of only 0.3%.

Every token can be exchanged within this platform, thanks to the fact that every user can open a new exchange market, adding your own ERC20 token to the catalog through an exchange contract that the platform allows to generate.

Similarly, the platform allows you to change any ERC20 to ETH or vice versa in a single operation, but exchanging between tokens requires an additional step, as the exchange transaction is first performed from ERC20 to ETH and then from ETH to ERC20. This leads to a commission of 0.6% corresponding to two completed operations must be paid.

Since we use a decentralized market, we need a reserve in ERC20 and ETH, in order to have sufficient liquidity and subsequently determine the exchange rate. To make this possible, Uniswap uses a smart contract (works as a pool) that pools all reserves in ERC20 and ETH certain exchange, and where all users of the network can make deposits of 50% ETH and 50% ERC20 (in this case, the amount for the deposit in ERC20 is calculated at the current exchange rate for ether) which will allow increasing the liquidity of the token and in return receive profits from this type of deposit .

Arbitration for price regulation

Pools are formed by the first user who creates an exchange and makes a first deposit of 50% ERC20 and 50% ETH. Also, whoever creates the foreign exchange contract is the one who sets the initial exchange rate. But it is worth asking how this rate is regulated. This is set arbitrarily and completely at the discretion of the user.which may result in a high or unfair rate compared to the market rate.

To regulate this rate, a trading concept called arbitrage is used. That is, users will seek to benefit from the different exchange rates of the various existing markets – whether centralized or decentralized – where that particular ERC20/ETH pair is listed, making the exchange rate self-regulating without any kind of intermediary, in addition to the user community itself.

Smart contracts for exchange

As I mentioned above, every stock market within Uniswap It is based on a smart contract on the Ethereum network. For example, when you open a new stock market, a smart contract is generated from which the deposit and initial exchange rate will be set, which will serve to organize the token’s liquidity reserve.


Getting started with Uniswap

To be able to enter the platform We must have previously installed the Metamask walletsince it is a decentralized Ethereum application and it is through it that we will be able to communicate with Uniswap.

So with the wallet installed, let’s go to Uniswap main portal.

Source: Metamask.

When opening, we will be asked to confirm the connection between Metamask and Uniswap, so we will click on Connect.

Source: Uniswap.

What we see in the image above is the Uniswap exchange portal, specifically the Swap section. As you can see, it’s a pretty simple portal that only has 3 sections: Swap, Send and Pool.

Before proceeding, you must pay attention to the following message shown in the previous image.

“This project is in beta. Use it at your own risk.” Source: Uniswap.

We are warned here that this is a project in the development phase and that we must therefore use it at our own risk.

On the other hand, considering the work of different sections, we have the following functions:

Swap section

Source: Uniswap.

From here we can exchange ETH or ERC20 tokens available within Uniswap.

Send section

Source: Uniswap.

It has the same configuration as the Swap section, i.e. we can make exchanges, but with one peculiarity: The person who will receive the result of the operation will be an address outside of ours, which we will have to enter at the time of the exchangewhile everything from the Swap section remains in our own wallet.

Pool section

Source: Uniswap.

In this section, you will be able to provide liquidity to an already created exchange market, withdraw liquidity you have previously added AND open a new ETH/ERC20 exchange market.

Trade with Uniswap

Now, at this point, and knowing the functions performed by the various sections, we will understand that there are two ways to make an exchangealthough it is basically the same, where only who will be the recipient changes.

Let’s start by making an exchange through the Swap section.

Source: Uniswap.

The first step is to select the pair that we want to exchange, and we will do this by pressing the buttons shown in the previous image. You have to remember that above we will choose what we want to send, and below what we want to receive.

Some default tokens are locked, which causes us to not be able to see the available balance from the Metamask wallet. Source: Uniswap.

Sometimes we’ll see an Unlock option next to the token we select. This is because we will need to unlock it in order for its balance to be reflected in the Metamask wallet. So to do that we’re going to click Unlock and we’re going to confirm a transaction from Metamask that allows this token to be enabled.

Now we will indicate the amount to exchange.

Source: Uniswap.

With the amount set, we will see how much ERC20 or ETH we will receive in exchange, and at the bottom the current exchange rate. As a recommendation, and because of how young this platform is, Check the current market rate at another exchangethis so you know if you are exchanging at a fair exchange rate.

To finalize the exchange, all that remains is to click on Swap, which will open our Metamask wallet from where we will confirm the operation. Then there is only wait for confirmations from the smart contract network to receive tokens or ethers appropriate.

Exchanges with third parties

One of the features offered by Uniswap, in terms of exchange, consists of the possibility of sending the results of the operation directly to a third-party walletthis through the Submit section.

Source: Uniswap.

Here we will do exactly the same as the Swap section, where we will select the pair to swap along with the amount. The only exception is that we will need to add a destination address. It must be remembered that these are public addresses must belong to an Ethereum walletbecause otherwise we risk losing funds.

Add and withdraw liquidity

We will start by adding liquidity to the existing exchange: we will add 50% ERC20 and 50% ETH funds to the reserves of this token. To make this process profitable, In each change transaction, 0.3% is charged on the total amount., and that commission is evenly distributed among all those who have deposits in that pool. That is, if your deposit is equal to 50% of the total reservation, you will receive half of the commission on the completed transaction.

Something to consider with deposits is that they can be withdrawn whenever the user wants, but it must be taken into account that when withdrawing the deposit we will receive the total amount in ETH, but ERC20 will be calculated at the current rate at the time of withdrawal, not at the rate that existed when you made the deposit.

To better illustrate this, let’s imagine that we deposit 1 ETH plus its equivalent which would be 20 ERC20, keeping in mind that the deposit is 50% ETH and 50% ERC20, calculated at the current exchange rate, where each ERC20 will have a value of 0.05 Ether . That is, the total deposit will be for a net worth of 2 ETH. Now, if at the time of withdrawal the current exchange rate is 0.1 ETH for each ERC20, we will receive 1 ETH plus 10 ERC20 which would be equivalent to its total value of 2 ETH, plus the profit made.

Note that exchange rates may not be fair at times, which is why I recommend checking the actual market rate. This is done to achieve a fair rate and prevent possible loss of money.

You may be curious to know why is 50% deposited in ETH and 50% in its equivalent in ERC20. Basically, this is done in order to keep the liquidity of the market in balance, that is, not to increase the offer on one side or the other. And that way you keep the same exchange rate after paying the deposit.

Now, let’s start with the steps to make the deposit. First, we’ll go to the Pool section and make sure the Add Liquidity option is selected.

Source: Uniswap.

Otherwise, select the option in the red box and select Add Liquidity.

Next, we will need to select a token to deposit, along with an amount. In the case of the latter, we can put the value in ETH or ERC20, because regardless of which one we put first, the second box will be filled automatically. calculating the value of the deposit in relation to the current exchange rate.

Source: Uniswap.

At this point we already have the total value we can deposit, all we have to do is click Add Liquidity at the bottom, where our Metamask wallet will open asking us to approve the transaction to transfer the funds. We are waiting for confirmations from the network and that’s it.

As for the withdrawal, we have to select the Remove Liquidity option

Source: Uniswap.

Here we will need to put the amount, expressed in ETH, along with the corresponding withdrawal token. And we will see how the estimated withdrawal total is shown in both Ether and ERC20. Likewise, at the bottom we will have an exchange rate that estimates the total amount to withdraw.

All you have to do is click Remove Liquidity, confirm the transaction from our Metamask wallet and that’s it. When the transaction is confirmed, we will see the wallet balance.

Create stock markets on Uniswap

To create an effective exchange market within this platform we will need two things: to have the address of the smart contract where the ERC20 is created and the funds in ETH and the token we will add. However, to add a marketplace to the platform, just an address is enough. Although, if we want to set an initial rate, funds will be necessary.

Let’s start then by going to the Swap section and selecting the Create Swap option

Source: Uniswap.

Here we just need to enter the address of the token we want to add and we will immediately see some details about it, such as its acronym and number of decimals.

Then it is necessary to click on Create exchange and confirm the transaction from Metamask in order to add the token to the Uniswap catalog.

With ERC20 ready, we now need to provide liquidity to this newly created stock market. We will select the Add Liquidity option and then we have to repeat what we did when we added liquidity to a token. Although there is one peculiarity: when depositing an amount in ETH, the amount in ERC20 to be added is not loaded automatically, because we will have to put it manually since we are the first to deposit into this pool.

therefore, Depending on the amount in ETH and ERC20 we place, the exchange rate value will be calculated. For example, if we deposit 1 ETH and 100 ERC20, it means that the value of each ERC20 will be 0.01 ETH. Where the rate will vary depending on the ETH and ERC20 supply the pool has.


Uniswap is definitely a promising platform in the field of exchange. First of all, something that is quite striking is the fact of accessibility that Uniswap can have, because we are talking about the fact that any ERC20 can be exchanged through it, regardless of whether you are a creator.

Another interesting thing is that with this platform we will not only exchange ERC20 or ETH, but we will be able to generate dividends by offering liquidity in token reserveswhich seems to me a plus for those who have savings in ETH or some ERC20 and don’t know what to do.

Uniswap is definitely a platform with a great future, so all that remains is to invite you to try it out and tell us what you think.

If you want to see this and other video tutorials, visit our channel YouTube.

Leave a Reply

Your email address will not be published. Required fields are marked *