
Uniswap V1 was a decentralized exchange (DEX) launched in November 2018. It was created by Hayden Adams.
Uniswap V1 was the first major DEX to use a liquidity pool model, where liquidity providers could earn fees by contributing to the pool. This model allowed for decentralized trading of Ethereum-based tokens.
Uniswap V1 used a simple swap functionality, where users could swap one token for another without the need for an order book.
You might like: Uniswap Liquidity Pool Address
Introduction
Uniswap V1 is a decentralized trading protocol on the Ethereum blockchain that enables token exchanges without intermediaries through an automated market maker (AMM) model.
Launched in November 2018 at Devcon 4, it will persist as long as Ethereum exists due to its permissionless nature.
The protocol is designed for simplicity, providing a seamless interface for exchanging ERC20 tokens on Ethereum.
It eliminates rent extraction and middlemen, allowing for faster and more efficient exchanges.
Uniswap is open source and functions as a public good, with no central token or platform fee.
There is no special treatment for early investors, adopters, or developers, which promotes fairness and equality.
Token listing is open and free, and all smart contract functions are public with opt-in upgrades.
How Uniswap V1 Works

Uniswap V1 is a decentralized exchange that allows users to swap Ethereum (ETH) for tokens and vice versa. It's built on the ERC20 standard and inherits basic functionalities from Uniswap V1.
The Exchange contract, which is the core of Uniswap V1, includes three main features: adding liquidity, removing liquidity, and swapping ETH for tokens or tokens for ETH.
To add liquidity, users provide tokens and ETH, which helps to create a pool of assets that can be traded. This is done by calling a function that transfers tokens and ETH from the user's balance to the contract.
Removing liquidity is the opposite process, where users receive tokens and ETH in return for removing their liquidity from the pool. This is also done by calling a specific function that transfers tokens and ETH from the contract to the user's balance.
Swapping ETH for tokens or tokens for ETH is a crucial feature of Uniswap V1. This process involves sending ETH or tokens to a payable contract function and receiving the desired asset in return.
Check this out: Uniswap Usdc Liquidity Pool

Here's a breakdown of the swapping process:
The __minTokens variable is a crucial mechanism that protects users from front-running bots that try to intercept their transactions and modify pool balances for their profit. It's a minimal amount of tokens the user wants to get in exchange for their ETH, calculated in the UI and including slippage tolerance.
Key Features
Uniswap V1 is a decentralized exchange that operates without a central authority, ensuring full decentralization.
One of the key features of Uniswap V1 is its automated market maker protocol, which uses the constant product formula (x * y = k) to set prices.
This formula helps to create liquidity pools where users can contribute tokens and earn fees from trades. The Uniswap factory contract can support any ERC20 token, making it a versatile platform.
Users can participate in liquidity pools to earn fees on ETH-ERC20 pairs, and the pricing is automatically adjusted using the constant product formula. This ensures that prices are always accurate and up-to-date.
Here's an interesting read: Uniswap Liquidity Pool

One of the most convenient features of Uniswap V1 is the ability to trade ETH directly with any ERC20 token without needing to wrap it. This eliminates the need for additional steps and makes the trading process more efficient.
Here are some of the key features of Uniswap V1:
- Decentralized: Operates without a central authority
- Automated Market Maker: Uses the constant product formula to set prices
- Liquidity Pools: Users can contribute tokens and earn fees from trades
- Support for Any ERC20 Token: The Uniswap factory contract can support any ERC20 token
- Join Liquidity Pools: Users can participate in liquidity pools to earn fees on ETH-ERC20 pairs
- Liquidity-Sensitive Automated Pricing: Pricing is automatically adjusted using the constant product formula
- Trade ETH Directly: Users can trade any ERC20 token directly with ETH without needing to wrap it
Creating and Interacting
To create a Uniswap V1 pool and interact with it, you need to create a new token on Goerli, then create a pool to swap between this token and ETH. The pool TOTO / ETH was created by calling the createExchange function of the Uniswap V1 factory contract.
The pool's contract can be interacted with using Remix IDE, where you first need to create a .ABI file with the ABI of the TOTO / ETH pool. This can be found by using the ABI of the factory contract of Uniswap V1, which is used to create new pools.
To add liquidity to the pool, you need to call the addLiquidity function with parameters such as min_liquidity, max_tokens, and deadline. However, you'll receive an error message saying you have insufficient allowance.
A fresh viewpoint: Function Health A16z
Swapping Functions

Swapping functions are a crucial part of creating and interacting with contracts, and they're actually quite simple once you understand the basics.
To implement swapping, you need to send some amount of ethers to a payable contract function and get tokens in return. This is done by subtracting the msg.value from the contract's balance, as the ethers sent have already been added to it.
The __minTokens variable is a minimal amount of tokens the user wants to get in exchange for their ethers, calculated in the UI and including slippage tolerance. This is a vital mechanism that protects users from front-running bots that try to intercept their transactions and modify pool balances for their profit.
The swapping function transfers _tokensSold of tokens from the user's balance and sends them ethBought of ethers in exchange.
Creating a Pool and Interacting with It
Creating a pool and interacting with it can be a bit tricky, but don't worry, I've got you covered.

To start, you'll need to create a new token on Goerli, which can be done using Etherscan. The token in question is TOTO, with an address of 0xdf3c316d3ae3a24c548458d5c847740cba553753.
You'll also need to create a Uniswap V1 pool to swap between this token and ETH. This can be done by calling the createExchange function of the Uniswap V1 factory contract, which has an address of 0x6ce570d02d73d4c384b46135e87f8c592a8c86da.
If you're using Remix IDE, you can create a .ABI file in Remix with the ABI of the TOTO / ETH pool. To find the ABI, you can use the one from the factory contract of Uniswap V1, which is located here: https://goerli.etherscan.io/address/0xf9555870C0575A4ECB47cB1587bCA162A3076d7F#code.
Once you have the ABI, you can call the addLiquidity function to add liquidity to the pool. However, you'll need to set the allowance for the token you're trying to add liquidity for, which in this case is TOTO. The allowance can be set to 5000000000000000000 using the approve method of the token.
Here's a step-by-step guide to setting the allowance and adding liquidity:
- Set the allowance for TOTO to 5000000000000000000 using the approve method.
- Call the addLiquidity function with the required parameters, including min_liquidity, max_tokens, and deadline.
- Send 1000000000000 wei in the "VALUE" field, as the addLiquidity function is payable.
Note that if you don't set the allowance correctly, you'll get an error message saying "you have insufficient allowance".
Limitations and Considerations

Uniswap V1 has several limitations and considerations that make it unsuitable for production use. The contract doesn't implement any mechanism to prevent front-running attacks, which can lead to malicious exploitation of known outcomes.
Front-running attacks can occur when an attacker observes a transaction and quickly submits a transaction to exploit the known outcome, potentially manipulating prices in their favor. This is a serious issue, especially when users are swapping tokens.
The contract also lacks access control mechanisms for critical functions, allowing anyone to call functions like addLiquidity, removeLiquidity, and swaps, which can lead to unauthorized or malicious use of the contract.
Here are some of the key limitations and considerations of Uniswap V1:
- Front-running attacks
- Reentrancy vulnerability
- Integer overflow/underflow
- Lack of access control
- Lack of oracle and price manipulation
- Gas limit issues
- Unchecked return values
- Missing events and logging
- Front-running token transfers
- Non-reentrancy guard missing
Limitations
As you explore the world of decentralized exchanges, it's essential to be aware of their limitations. Large trades can cause significant price slippage, which can be a major concern for traders.
Liquidity providers may face impermanent loss, a risk that can be challenging to navigate. This is particularly true in situations where market conditions change rapidly.

Uniswap V1, for example, has limited features compared to later versions. One notable absence is direct ERC-20 to ERC-20 trading support.
Here are some key limitations to keep in mind:
- Slippage: Large trades can cause significant price slippage.
- Liquidity Risk: Liquidity providers may face impermanent loss.
- Limited Features: Uniswap V1 has limited features compared to later versions.
Caution
The Uniswap V1 Exchange contract has several potential vulnerabilities that should be addressed before using it for production purposes. One major issue is the lack of protection against front-running attacks, which can be exploited when users swap tokens.
Front-running attacks occur when an attacker observes a transaction about to be included in a block and quickly submits a transaction to manipulate prices in their favor. This can be a problem, especially when users are swapping tokens.
The contract also lacks explicit checks for reentrancy attacks, which could lead to issues where a malicious contract calls back into critical functions before the previous call completes. This can result in unintended behavior or draining funds.
Integer overflow and underflow vulnerabilities are also present due to arithmetic operations without proper checks and mitigations. This can lead to incorrect calculations or unexpected behavior.
For another approach, see: When Was the Uni Token by Uniswap Launched

The contract doesn't use oracles to obtain accurate price information, making it vulnerable to price manipulation attacks. Malicious actors could exploit this by artificially inflating or deflating prices during token swaps.
Some functions in the contract consume a high amount of gas, potentially causing transactions to fail due to gas limits. This can lead to unpredictable behavior or failed transactions.
Here are the potential vulnerabilities listed:
- Front-Running Attacks
- Reentrancy Vulnerability
- Integer Overflow/Underflow
- Lack of Access Control
- Lack of Oracle and Price Manipulation
- Gas Limit Issues
- Unchecked Return Values
- Missing Events and Logging
- Front-Running Token Transfers
- Non-Reentrancy Guard Missing
Technical Details
The Uniswap V1 contract is built on top of the ERC20 standard, which means it inherits many of the standard's features and functionalities. This foundation provides a solid base for the exchange's operations.
The contract includes three main features: adding liquidity, removing liquidity, and swapping tokens for ETH and vice versa. This allows users to participate in the exchange in various ways.
Here are the specific features of the Uniswap V1 contract:
- Adding liquidity by providing tokens and ETH.
- Removing liquidity and receiving tokens and ETH in return.
- Swapping ETH for tokens and tokens for ETH.
Contract Deployment & Testing
To deploy and test the Exchange contract, you'll need to set up a development environment with a Solidity compiler and an Ethereum node. This will allow you to run and test the contract locally.

First, you'll need to deploy the contract to a local or testnet Ethereum network using a development tool like Remix or Truffle. This step is crucial in ensuring the contract functions as expected.
To write and execute tests, you should cover different scenarios, including adding/removing liquidity and performing swaps. This will help you catch any potential issues before deploying the contract to a live network.
Here are the steps to deploy and test the contract in a concise format:
- Set up a development environment with Solidity compiler and Ethereum node.
- Deploy the contract to a local or testnet Ethereum network using a development tool like Remix or Truffle.
- Write and execute tests to ensure the contract behaves as expected.
Pricing Function
The pricing function of a decentralized exchange like Uniswap is a crucial aspect of its operation. It determines how prices are calculated based on the exchange's reserves of ether and tokens.
The initial pricing function attempted to use a simple ratio of reserves, but it had a flaw: it allowed for the exchange to be drained of its reserves. This was because Solidity's integer division rounds down to the nearest whole number, resulting in prices being rounded to zero.
See what others are reading: Does Chainlink Have Its Own Blockchain
To fix this, the pricing function was updated to increase the precision. However, this still didn't solve the problem, as the function belonged to a constant sum formula, which allows for zero reserves in either ether or tokens.
The correct pricing function is based on the constant product market maker formula, which is a fundamental concept in Uniswap. This formula is represented by the equation x * y = k, where x and y are the reserves of ether and tokens, and k is a constant.
Here's a breakdown of the constant product market maker formula:
This formula is more sophisticated than the initial pricing function and takes into account the changing reserves of the exchange. It's also responsible for pricing calculations and ensures that the exchange remains solvent.
Broaden your view: Token Exchange Embed Code Uniswap
Conclusion
Uniswap V1 is a groundbreaking innovation in the decentralized finance (DeFi) space.
Despite its limitations, it lays the foundation for decentralized trading, which is a game-changer for the industry. The automated market maker model and decentralized design of Uniswap V1 demonstrate the potential and advantages of decentralized trading.
Uniswap V1's impact will be felt for a long time, paving the way for future innovations in the DeFi space.
Frequently Asked Questions
Is Uniswap V1 still available?
Uniswap V1 is still operational due to its permissionless nature on the Ethereum blockchain. However, its long-term viability is tied to the existence of Ethereum itself
What is the difference between Uniswap V1 and v2?
Uniswap V2 improved upon V1 by adding features like ERC-20 token swaps, flash swaps, and a new price oracle system, enhancing user experience and transaction efficiency
Featured Images: pexels.com