Uniswap 🛠️ An Introduction To Building On Uniswap - Tyllen Bicakcic
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join Tyllen Bicakcic from Uniswap for a talk titled "An Introduction To Building On Uniswap". Thank you to everyone who joined us for ETHGlobal Lisbon! After being away from Europe for almost a year, we've decided to bring the heat and excitement back to the stunning historic streets of Lisbon! All over the world, hundreds of thousands of developers, users, hobbyists, creators, artists, and market makers spend their days and nights thinking, building, talking about Ethereum because we are... excited. We're excited by the idea that Ethereum can change things. This May, we invited you to come learn what all the talk is about. We were joined by the leading teams in the ecosystem such as Polygon, Metamask, Aave, 1inch and Gnosis Chain who have a number of prizes up for grabs! This event is focused on building a new product/protocol, learning at the summits through talks and workshops, and giving opportunities to gain valuable feedback from ecosystem champions at the beautiful Convento do Beato. Find your future team at our Hacker Café and create even more meaningful connections while engaging with some of the most notable speakers in the industry at Pragma Lisbon. At ETHGlobal Lisbon you'll have the support of a huge community of experts, mentors, sponsors, developer advocates, and other community members who want to help you build something awesome. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
foreign [Music] so today what we're going to go over is a quick introduction into what uniswap is the uniswot foundation specifically and how we're different and teaching you parts of our SDK and how to get started building on unisoft before I get started how many people are familiar with uniswap here okay cool how many people have built on uniswot before okay sweet so a lot of people familiar some new Builders um cool so before we get started a little bit about me my name is Tylan I'm the head of developer relations at uniswap and if you guys have any issues or any you know questions about building on top of uniswap this is my contact information happy to help out uh with whatever you guys need our mission at the uniswot foundation for devrel is to fuel creativity and cultivate a community of empowered and influential developers who are shaping the future of technology we feel like uniswap has pushed crypto and D5 forward and we believe that the people that build on top of uniswap will keep on doing the same thing so we want to empower you to do that and we think we have a great community that enables that now what is the uniswot foundation do most of you have have you guys heard of the uniswot foundation first of all okay sweet so for those of you who haven't we we were created almost a year ago and the foundation passed as a governance vote to create a foundation that would be the Mainstay and the hold for pushing unit Swap and the protocol forward in addition to helping out on the developer Community side we also help provide grants so if you guys are looking to build on top of uniswap if you have a great hackathon idea that you want to keep pushing forward after this is done please connect with me we do provide grants so that we can help support you even afterwards we have tons of rfps as well for things that we're looking for we release them every quarter our teams is here that actually does that as well so you can ask them what we're looking for also and we'd be you know happy to explain some of the workings of the foundation and and how we how we go about doing that so to the hackathon we have this really great resource for people that are new to uniswap that are new to building on top of uniswap it's called our hacker home and what we do here is we actually have a page that allows you to go to it and we have some intro resources to building on top of uniswap to learning things from how do you do swaps how do you create liquidity pools how do you go a little bit more advanced and how do you use sub graphs how do you create flash swaps all of these things and if you have any ideas you're thinking about building please go to our hacker homepage and we'd be you know it's a great resource for a ton of hackers and also if you have feedback on how we could improve the hacking experience we would love to have that also um so with that we you know let's get into for those of you who don't know what uniswap is and how it operates or for even those of you that do know how it operates but maybe don't know the inner workings of you know maybe more than a swap let's take a look at that so what is a uniswap pool well it consists of basically two tokens token a and token B so in order to swap token a for token B you need to have people providing liquidity into this pool so that this pool can have funds to actually execute the swaps so you have accounts that provide liquidity to both sides of the pool and then when this liquidity is provided and when swaps occur the people who are actually providing liquidity collect fees on these swaps so there's a whole mechanism behind unit swap that's not just swapping but it's also a whole liquidity side that's very engaging and enticing for people to build on top of and uniswap has a lot of liquidity and there are a lot of full projects that can be built using that liquidity now maybe you know you see this and it's a little abstract it's token and token B well what what does that look like in real life well if you're trading ethereum can anyone think of a pretty popular token that people are trading E4 right now Pepe oh yes so to actually have Pepe and to have trades happening on Pepe a lot of people are going through uniswap uh to do this so you would have accounts depositing both ethereum and pepe at different price ranges and then when that happens you create a pool and now things can be swapped on top of uniswap so now that we've gotten over this kind of cringe meme coin maybe we can go into some code and see how now that you have a pool how you can actually interact with that pool and do something simple like pulling the price of the certain coins in that pool so we're going to be looking at fetching spot prices Live for uniswot pools and to do that we're going to be using uh documentation on the uniswap SDK and how we do that is the first thing in case you're new to uh crypto you have to create a provider and essentially you're going to be using a tool called ethersjs to interact with the smart contracts and call certain functions on there so that you're able to live pull data that you need on chain um so what we'll do is we're going to get a provider from infero once we get that provider we're going to call ethers Js and we're going to use the pool address of the uniswap pool that we want the spot price for and we're going to use the quota address which is a built-in uh contract that uniswap created to actually get live quotes from the pools so if we're looking at this pool address right here you might be thinking okay you know these are just a random contract number what you know what pool is this actually calling well this is for the eth BTC pool and a really simple way to get the pool information that you want is you can go to info.uniswap.org for rap BTC slash E I can click on this info and in the URL you can see the contract for the pool right here so anytime you want to get you know if it's Pepe and Heath if it's usdc die you can just go and click on this website and you can see the contract that you want and then you can plug it in to basically this code to get the live spot pricing so and once we get the pool address and once we have the quota address and we've set up our provider variables we can now start the start creating the function to get the live price of the pool so what we do here is we create a constant called pull contract and then we use ethers to initiate the contract and we put in our address we also call in the uniswot V3 pool ABI what an ABI is essentially it dictates all the functions in the smart contract and then you can call these functions and when you're calling these functions you're able to read and write real time on the smart contracts so the unisot B3 API comes with the inner swap B3 SDK so you're going to be using this API to pull the addresses to pull basically the addresses of each of these token pairs now once you have the addresses of these token pairs you can use that to call these contracts individually to pull information from each specific token so here we have wrap BTC and eth we're using this code to go and get the actual uh contract information so as we're doing this we're starting to get variables that will help us get the live spot price and the unit swap pool so we'll go here and we're going to use this helper function we just created called get apis we're going to pass this into our get price function when we're getting the abis for these token addresses that we just got from our full contract we use that to now get information all right we use that now to instantiate new ethers contracts for the specific token contracts so now that we have wrap BTC individually and eth individually we have Avis we can now access in those contracts to get additional information as well so what we're going to do here is we're going to get the symbols for each contract so wvtc and Heath and then we're also going to get the decimal information decimal information is pretty important in crypto and it's a good thing to note as you're working with the uniswap it really impacts the formatting of How It's certain tokens look and operate or even field so you would use this token decimal information to uh as you're outputting the information to Output it in a format and the other thing to note is that tokens have varying decimals attached to it I believe like rap BTC may have eight decimals after it and I think uh e eth may have like 16 or something more we go on to that into the code but it makes a difference as you're thinking of how do I like do the swap exactly so we then create another uh helper function that will take in that pool contract that we initiated early on and we will get the actual tokens in that pool contract and then we're going to get the fee of that contract if you've used uniswot before you've probably seen that we have different amounts of fees based on you know what the liquidity provider has provided liquidity at so it can be one basis point three five basis points and based on that fee it dictates the actual price in the pool pairing so or and it dictates how much the liquidity providers will get in return for providing liquidity of those fees and we need to know that as we're calculating the spot pricing so we get the symbols we have the decimals now is the time where we use our quota contract our quota contract is going to be used to get the quotes for the prices and then it'll be used in our calculations as well so we have our helper function that we did earlier which was right here get our pool immutables we're going to be getting our token information and our fees for app BTC and Es and then what we're going to do is we're going to pass in our pool contract which we initiated right here so we use the pool address for wrap Etc the ABI the providers and now we're going to get all that information and what we're going to do is now that we have all the information we need to actually get the live spot price we're going to use ethers to calculate an amount in and then a quoted amount out and then format that and get our result so here we're putting in an input amount which will be what is uh the price of one BT one rep BTC to eat and then we're going to also include the decimals for one wrap BTC so it could be formatted correctly as you can see here one wrap BTC has eight decimals while as one eighth has 18 decimals after it and that will impact what your result looks like after you've actually calculated it so we take in our amount in and then what we're going to do now is create this cons called quoted amount out and we're going to take in our tokens our fees the amount in that we're looking for and then zero is just a constant variable you put in there and then we're going to get an amount out that will be showing us the live spot price of this pool so you can console log your result here you get the price and then boom you run your code and you can see the live price of one rep BTC whether this is live today or not is that it can be swapped for 13.3 rapty and this is a simple way to just start getting used to the uniswap contract integrating with it and then start building on top of uniswap really seamlessly and easily the more you get familiar and comfortable with the Avis the better you can get with doing more advanced things like liquidity providing creating different variable fees or working with fees and building more unique Solutions on top of uniswap with that I do want to go into our bounties that we're having for this hackathon so if it's your first time if you built on uniswap if you've got some kind of idea we have a wide variety of bounties for you to go after we have an ecosystem prize which is essentially any tools that you could build that are unique and help our ecosystem grow this could be expanding the realm in which uniswap even operates anything around decentralized social applications that are integrating unique tokens that you create in these experiences and then helping provide liquidity pools for people to trade on top of these tokens we have a whole governance Suite that's important to us and we we also help lead a lot of governance in the space so we're constantly looking for ways to improve the communication between delegates to improve the voting experience to work on different uh I think even different Chains would be exciting to see how they could help operate and expedite the voting process and again liquidity you're working with a ton of liquidity within uniswap I think there's lots of ample ways to use that liquidity that isn't that it isn't being built right now that is very uh very relevant to this hackathon and I would love to see things like that bill developer tooling things that will help developers build on top of uniswap we're looking at infrastructure we're looking at things that could help people understand lping understanding different analytics for helping strategies be developed and then we also have an open Innovation price it's whatever goes anything that is the most exciting and Innovative project on top of uniswap can apply for this prize you're also welcome to apply for all three of them if you think your idea hits all three um but yeah uh that was our intro to uniswap a quick overview I'll open for any questions if you guys have any yes sir the best yeah so he he the gentleman asked the question about uh using we showed how to just do one pool and pick the spot price of the pool but when you're using the actual application it shows you three or so different or it shows you the best route to the best price and then it routes it to the best price for you to execute the swap is that correct and how does it do that and is there an easy way to do that we do have documentation on how to do routes and it is within our SDK so if you go to uh docs.uniswap you'll be able to actually use are routing a swap documentation here and then it will show you how to do that and how to use uh the different tools we built as well with like the permit 2 router cool any other questions I saw a few hands up sweet well maybe now you guys have time to go get the Rave tickets that this has finished early uh uh I it's a party here so that that's about as much as I know sweet thank you guys for your time hope you guys build on uniswap looking forward to ask any good lap he did it
Automatic transcript — names and jargon may be misspelled.