First of all, a short Q&A.
What is Uniswap?
Uniswap (Uniswap protocol) is a DeFi (Decentralised Finance) application and protocol that swaps tokens. E.g. you have an ETH and you want to get USDT that’s – that’s swap. The beauty is that Uniswap is decentralized, not controlled by anyone and lives on blockchain.
Why another Uniswap tutorial?
I wanted to implement swap functionality with Uniswap and was looking for Uniswap V3 SDK example, and it turned out (a) there are lack of examples on the Internet (b) official docs have an example of Uniswap V3 SDK, but there are lot of practical concepts up there that are not explained detailed enough for a newcomer.
In this example V3 SDK version is used. Source code is in TypeScript. Module syntax is used so that you can copy this code in both console and React apps. Please note this code can’t be considered production-ready. Tutorial consists of 5 parts for clarity: