Behind the scenes of one of the most active DeFi protocols in the Ethereum ecosystem.
Cryptocurrency exchanges and token swaps usually require buyers and sellers to create liquidity. Uniswap is a protocol built on the Ethereum blockchain that helps solve decentralized exchanges’ liquidity problem by creating these token swap markets automatically. The protocol pools token liquidity on-chain in smart contracts so that DeFi users can make trades against the reserves at any time. In terms of daily trading volume, Uniswap has emerged as one of the most active protocols in the DeFi ecosystem and is now sending around 30 million requests per day.
Since Uniswap’s launch to mainnet in 2018, the team has used the Infura API suite to meet the data demands of the exchange’s interface. Uniswap uses Infura as the go-to provider for connecting to MetaMask and also for querying information when a user has not connected a wallet to the Uniswap exchange. Infura’s easy integration and ability to handle Uniswap’s high volume of requests have made it the ideal infrastructure solution for Uniswap’s increasingly popular DeFi protocol.
“Infura is a great solution for us. It’s easy to integrate, can handle our requests, and has really helpful and thorough documentation. If we were to run and manage our own infrastructure, we would need at least one full time engineer to monitor that on a consistent basis. Infura helps us improve the reliability and performance of our service and saves us developer time and resources so we can focus instead on accelerating core product development.”
–Ian Iapham, Software Engineer at Uniswap
The Uniswap interface, one of the products that the Uniswap team has built atop their liquidity protocol, allows users to easily trade tokens, add liquidity, and create new pools. Behind the scenes, Uniswap needs to pull an array of information from smart contracts on the Ethereum blockchain to feed into the interface and populate data such as pricing between pairs, user balances, and swap rates. The team needed an easy-to-integrate solution for accessing this data that could also scale to meet the growing volume of requests.
Uniswap uses Infura to query information when a user has not yet connected a wallet, or connected to a client. To fetch data like token swap rates, token balances, and other information from the Uniswap smart contracts, they pair Infura with web3-react. The web3-react framework is able to connect directly to Infura and pull useful information for Uniswap.
Uniswap’s team has created two different contexts for their application to connect to a provider: one with Infura, and another with whichever wallet the user eventually connects with. They do this by creating another provider root for the web3-react library.
With the recent launch of V2 of their protocol, the Uniswap team is eager to attract greater liquidity to the DeFi ecosystem, and in so doing, more users and integrations. They plan to keep using Infura for their interfaces to provide a seamless, stable experience for end users.