The Ultimate Uniswap Guide: Understanding the AMM Algorithm

Want to become the king of Uniswap? Let's take a deep dive into how Uniswap works, along with ways you can become a market maker using V3 of this platform!

You may have come across Uniswap quite often, considering how it is among the most well-funded DeFi protocols out there. Despite what you may have heard, Uniswap is an automated market maker (AMM) as well as a decentralized exchange – and quite a popular one.

If we were to represent Uniswap’s position in the market visually, it would quite literally be a unicorn that helps you benefit from price differences before the market adjusts itself and acts as an exchange while doing so. The fact that it doesn’t take a huge chunk of from fees is the icing on top of the cake and something that led to the platform’s skyrocketing customer base.

In this article, we will examine Uniswap as a DEX and an AMM to help you understand how the platform can help you expand your portfolio, or with the right investment, help you earn returns unlike ever before!

Uniswap – A Quick Overview

As one of the most popular DEX protocols out there since its inception in 2018, Uniswap has always offered more tools, features, and freedom to holders, especially those with its governance protocols. If you look at the birth of Uniswap in more detail, you will find that the key feature that made it so prominent was how it managed to simplify the complex world of crypto.

This was a much-needed trait at the time as the idea of owning, trading, and farming digital currency was all but foreign to many.

Uniswap is built within the Ethereum blockchain but still managed to reduce the gas fees that the Ethereum network charges and speeds up transactions significantly. This showed that unlike most exchanges at the time, Uniswap wasn’t geared towards the idea of ‘earning via more profit margins’ but instead focused on ‘earning more profits via volume.’ And it worked.

Now, one of the first steps for any new currency to turn market sentiment in its favor is to get listed on Uniswap. No matter how good the new currency performs, because of the level of trust and features offered by Uniswap, people will wait for it to get listed instead of heading on to another DEX and buying it.

Take Unifarm, for example, and how long investors have waited for it to come to Uniswap so that people can buy.

Unifarm is available on Uniswap but as an imported token, not an integrated one.

Uniswap is a DEX, a tool for the community to utilize for free and trade tokens and assets without platform fees. As a market maker, Uniswap allows almost anyone to create liquidity pools with their native token on the platform, imported or otherwise. There is a degree of uncertainty that comes with this, but it allows new currencies and tokens to make and gauge the market for their currency.

How Uniswap Works

As discussed, Uniswap’s operating protocols are not the same as other exchanges, especially centralized exchanges. Instead of the price of a cryptocurrency being determined by an order book (demand and supply, in essence), Uniswap uses smart contracts to determine the token price.

A typical transaction on Uniswap has the following base steps. Of course, this is a very simplified form of a transaction.

  1. A user decides to swap their tokens for any other ERC-20 token.
  2. The token’s value is sent to the smart contract pool.
  3. The same (or similar) value is then transferred to the new account in the form of the new token.

Throughout the process, there are always some crypto assets available in the contract pool (which ultimately helps increase the speed of transactions as well). These assets ensure that you don’t have to worry about your asset price-reducing during the transaction, as the token’s price is already determined and locked before initiating the transaction.

The constant availability of tokens in Uniswap reserves also means that if you want to buy a currency, you won’t have to wait for someone to show an interest in selling. For a currency seeing a bullish trend, the wait would quite literally be nerve-wracking.

The platform also stands out because of its oracles. Oracles are crucial for any DEX to operate effectively, and they need to be intuitive and effective enough to filter between true and false data. The platform’s Bug Bounty is a great initiative towards securing these oracles and the DEX itself.

Uniswap offers a reward of up to $500,000 to those who report vulnerabilities and issues in the website or its data collection/handling processes.

The Risks Associated With Uniswap

Uniswap has numerous features and benefits, but much like any other DEX, it also has its own set of risks. The most prevalent one, as mentioned before, is the fact that anyone can list their token on the platform.

While this is favorable for new developers, currencies, and tokens, you may not be at such an advantage. The decentralized nature of the platform means that several illegitimate projects will also be placed in the pools, replicating genuine projects at times or representing something new entirely.

Since the identity of project creators isn’t always displayed publicly, you should always double-check the contact address before investing. The contact address should be a viable, trusted source. Furthermore, while Uniswap offered low gas prices initially, as more users started using the DEX, gas fees rose to become nothing short of outrageous (especially for Ethereum).

Automated Market Maker (AMM) Explained

Automated Market Makers (AMMs) are subject to several restrictions, and the idea is still relatively in its infancy. Still, it has helped the market advance considerably over the years.

AMMs are specific to newer decentralized exchanges (including Uniswap), utilizing complex mathematical operations (through smart contracts in most instances) to set the price of any given token. Traditional finance uses a demand and supply model to determine the price of any asset.

Automated Market Maker algorithms, on the other hand, use the number of tokens available in the token’s primary liquidity pool and the final value they create.

Like any other DEX, the Uniswap automated market maker also asks users to turn their tokens into pairs, such as BTC-ETH, Ether-USDT, and more. However, normal and automated market maker coins differ in no buy-or-sell orders. Where normal exchanges use order books, AMM uses liquidity pools.**

A specific formula is used by the exchange to determine the price of a token, an example of which we shall discuss later on. The smart contracts monitoring this formula and implementing the price change act as the market makers.

Smart Contracts & AMM – What’s The Connection?

Uniswap automated market maker algorithms monitor liquidity pools and the token pairs therein. Whenever you make a transaction, you will be interacting with smart contracts to execute the trade, which will then send the tokens in the pool (held as reserve) to the targeted account and deposit your tokens into the pool.

This is what makes the transaction so quick.

Whenever there is a change in the number of tokens in a liquidity pool, the smart contracts execute a mathematical equation (different with respect to the automated market maker algorithm) which decides how many tokens from the one side of your trading pair is being used, how many are left, and what their value should be to maintain equilibrium.

Let’s consider an automated market maker example. For a pool containing a paired Token A-B, if the equation is:

a×b =k

Where,

a = Token A

b = Token B

It would mean that the number of Token A and Token B in the pool are inversely proportional. If the number of Token A increases to maintain the total value, the number of Token B should decrease. Of course, the algorithm can’t simply dump the tokens out. So, the AMM algorithm has the following options:

  1. Increase the value of Token A only
  2. Decrease the value of Token B only
  3. Increase the value of Token A AND decrease the value of Token B
  4. Increase the value of Token B AND decrease the value of Token A

Think of it this way. If the total value of the pool is $10, the value of Token A and B can fluctuate as follows:

Untitled

This is a very simplified automated market maker example. The idea is that you commit a specific asset into the pool, and then the formula decides how much you will get back after a few days of trading – either the same token or a different one.

Automated market maker algorithms also have some slippage, i.e., how the increase or decrease of the total transaction amount with respect to the tokens involved. The algorithms have a hyperbola structure, meaning that as the order size grows, so will the slippage, especially with Uniswap.

Quantity of Asset B vs. Quantity of Asset A chart

This makes Uniswap a great place for new traders to start in the automated market maker list as you learn about the price fluctuations you’ll experience.

The Appeal of Uniswap Automated Market Maker – Is It Really Worth It?

The world is rather comfortable using the demand and supply price determination model, and AMMs present a degree of uncertainty into the mix, especially recently with Uniswap’s outrageous gas fees, broker fee (if any), price impact, slippage, and other idiosyncrasies of public blockchain.

However, the Automated Market Maker coins, particularly UNI, solved one of the biggest problems the world of crypto faced: liquidity for DEXs. Instead of all the Know-Your-Customer (KYC) checks, AMMs adopted a permissionless policy with its platform, requiring nothing more than your wallet address.

That promise of privacy made the Uniswap automated market maker so popular. Users basically told the centralized system that:

You shall not violate my privacy

Its appeal was very well-founded, since the AMM model:

  • Had no listing fee or admission criteria
  • Did not limit access based on portfolio size (except of course, governance, which was released in 2020)
  • Allowed you to establish your own liquidity pool easily
  • Offer a much more streamlined user experience, and
  • Was straightforward with its investment opportunities and issues

Over time, more platforms also started using automated market maker algorithms.

Can Anyone Be a Market Maker?

You go to the fish market one day and find that in the tuna section, there are robots giving you a different quote for two different types of tunas. The first robot is using a simple formula, i.e., the freshwater tuna is more expensive than the saltwater tune, but the second robot is using a very complicated formula to determine the price. The second also takes into consideration how many tunas it has sold off and how many are left.

You first went to the first robot and got a quote; the freshwater tuna is $10 while the saltwater tuna is $8.

The second robot, on the other hand, made its calculations and told you that the freshwater tuna is $11 while the saltwater tuna is $5.

Why the price difference? Because the two used a different formula but are market makers nonetheless. Depending on the type of fish you want, you will go to the robot with the cheaper one, right? However, you go for a stroll through the park and come back to see that the prices are now different because someone else came in and bought a tuna from the second robot.

A similar principle applies to automated market maker coins. The smart contracts are always available for sale or transfer, but the formula differs. Uniswap uses a simple formula, but others such as Curve, Balancer, and Binance use a very complicated formula.

Here is what Binance’s automated market making algorithm looks like:

ADn-1i=1nxi+i=1n(Dwi)nwi=ADn+i=1nD2wi2xinwi

Here,

A = Leverage factor for function curve

D = Immutable constant along with an increase in transaction fee and liquidity

n = Types of assets in the pool

xi = i-th asset

wi = Value of assets in the pool. By default, it is 1/n.

Anyone can be a market maker, ****but you will need to provide a lot of liquidity into pools for that. Becoming a market maker on Uniswap is relatively easier as it uses a very simple formula, but this also means that the platform will already have other makers to compete with.

If you are looking to become a market maker, you should consider looking for smaller exchanges or cryptocurrencies that haven’t attracted much attention yet. The low volume on the exchange or for the currency may allow you to pour in enough liquidity to become a market maker.

You can become a liquidity provider or market maker for some smaller exchanges or for the cryptocurrencies that haven’t gone mainstream yet or don’t see a lot of action. Implement an AI and/or machine learning algorithm into the mix, and you become an automated market maker.

To become one, you may have to add liquidity of thousands of dollars worth of liquidity or even millions, depending on the currency and platform. However, no matter how much liquidity you add, you still get to be king of your token. Anyone who comes in shall bow!😉

"Should we bow? Yeah he's a king." meme

What Is the Main Activity Of Market Making?

As a market maker, your primary role is to manage liquidity functions properly. The more liquidity a pool has, the lower its slippage will be. As a market maker, you will need to keep a very close eye on the liquidity aspect.

You can either keep adding liquidity from your end or offer incentives to liquidity providers (LPs). These incentives may include better returns, quicker redeem periods, a larger portion of the transaction fees, more rewards, and more.

As the market maker, you will be issuing governance tokens to LPs reflecting market maker coins. For example, if your pool is on Uniswap, you will be offering UNI (may vary as well, but native LP tokens attract more traffic).

You will be directly monitoring the transactions in your liquidity pool and will have to manage the changing prices quickly. As your pool grows, consider automating it, as it will become overwhelming fairly quickly.

The biggest risks that you will need to manage as a market maker or a Uniswap automated market maker are those presented by exploits and platform vulnerabilities.

Uniswap has already seen several exploits where liquidity providers lost their investment. Examples include the “UNKNOWN” bug and the imBTC Uniswap pool exploit where hackers drained the pool of ~$300,000.

Furthermore, you will need to ensure that you don’t leave a trail of your activities, exposing yourself to exploiters. To manage these issues, consider revoking access to exchanges and dApps you no longer using a revoking tool.

Uniswap Automated Market Maker – Version 3

Uniswap V1 was launched in 2019, followed by V2 in 2020. On May 5th, 2021, after months of intense discussion, the protocol finalized the automated market maker algorithm V3. According to the platform, this new version will be the most flexible and efficient automated market maker ever.

This is a pretty bold claim by Uniswap, but key features being introduced in the platform have proven that the claim is credible. These features include:

  • Allowing concentrated liquidity
  • Introducing multiple fee tiers with respect to degrees of risk
  • Ability to provide liquidity with up to 4,000 times capital efficiency compared to v2, hence offering higher returns.
  • Lower slippage ratio
  • Increase exposure to preferred assets
  • Decrease downside risks
  • Faster and cheaper integration of oracles, and more.

It is important to note that Uniswap logic isn’t an upgradable project, meaning that it has to be an entirely new version. The v3 has built on core elements of the platform. You can read more about the update on the official Uniswap 3 release notes.

Becoming The Elon Musk of A New Pool With Uniswap Automated Market Maker

There are a lot of automated market maker examples out there, such as:

  1. Uniswap
  2. PancakeSwap
  3. Binance
  4. Balancer
  5. Curve, and more.

Because of the permissionless nature of these platforms, you can check the AMM system on your own as well. There is no denying that creating your new token is easier on Uniswap than on any other platform, so we recommend testing it out there.

Want to try it yourself? Simply head on to the Uniswap pool page and under More, click on Create a Pool.****

From personal experience, we can tell you that it feels great to have a token to your name. There was no approval process, no specific requirements, no manager looking to increase how much he can milk out of our investment. It was only the operator (or should we call it market maker), a laptop, an internet connection, and the wallet.

Uniswap is empowering investors and bringing forth a new paradigm of financial interaction, and the automated market-making algorithm has a major role to play here.

What are the next steps? Learn about arbitrage and how it works in our article here: Exploring Different Crypto Strategies: DeFi Arbitrage

Search

🟢 For owners who have made impactful changes and would like an update to their farm review:

1️⃣ Use #update at @RugDocChat with your description and proof of changes and it will be forwarded to our scanners.

2️⃣ This does not guarantee a change in your review.

3️⃣ Owners who have difficulty solving the issues can consider our Consultation Package – please contact @BaymaxCrypto on Telegram to discuss.

Our mission here at RugDoc is to screen for hard rug code that results in 100% theft of ALL underlying funds for ALL participants.

This is the ONE part of the due diligence process that most people cannot simply do on their own as it costs thousands of dollars to hire a senior solidity developer to look over a farm for safety.

A project coin with terrible code can go up in price, and a project with good code and a good team can also go down in price.

Do NOT use our ratings to refer to your likelihood in making money if you invest in the project. They are ONLY in reference to code safety.

Everything else beyond code safety is YOUR responsibility to go do research on. We just make sure the casino you’re betting in won’t rob you before you even get to place a bet.

Our reviews for projects are organized into a few colors.

🟢 Least Risk
These projects are the least likely to hard or soft rug. Usually reserved for cornerstone projects of an ecosystem where it makes no financial sense for them to rug in any manner as they make more money just being legit.

🔵 Low Risk
These projects are usually established projects in an ecosystem that have a track record of success or have KYC’d to us or other authoritative sources in the real world. As a result, it is extremely unlikely for them to soft rug or hard rug their projects. The projects can still fail and the token price can go down, but usually more as a result of natural market forces.

⚪️ Some Risk
This is the default rating for projects with unknown teams but have code that is unlikely to have hard rug risk. Since the team is unknown and doesn’t have a track record of success, it’s entirely possible that they may try to soft rug by dumping tokens, abandoning the project, etc. Even a last minute contract swap to a malicious contract is possible. The only thing that is unlikely is a complete hard rug as long as you are 100% sure you deposit into the contract we review.

🟠 Medium Risk
Similar to Some Risk, but the underlying code itself is custom enough or complex enough that it warrants an elevated risk rating that needs deeper research. Make sure you read every point presented to make sure you’re comfortable with that before entering. Still unlikely to hard rug, but more chances of custom code behaving incorrectly and causing other issues.

🔴 High Risk
Project contains code or practices that are HIGHLY LIKELY to lead to catastrophic losses as they are right now. Make sure you read the description carefully as we will always warn what these issues are. If you see the words Hard Rug anywhere in the review, STAY FAR AWAY!

⚫️ Not Eligible
We reserve the right to not review exceedingly complex projects that would require tens of thousands of dollars of senior security analyst man hours. Typically these are projects that deal with leverage, lending, options, derivatives, and anything that is overly complex and which requires tons of peer reviews and audits from top audit companies.