Uniswap Foundation 🛠 Uniswap SDK Overview - Zach Pomerantz
ETHGlobal San Francisco 2022 · 12 Nov 2022 · 9:29
Zach Pomerantz of the Uniswap Foundation shows hackers how to add swapping to their own app. The session walks through the Uniswap swap widget, a React component that handles wallet connection, token selection and live pricing in a single line of code, and explains how to lock it to one token. It also points to the contract docs and SDKs, and describes how the Uniswap interface mocks trades through a client-side router to quote prices. Useful for developers planning token swaps or liquidity features.
Speakers
Topics
From ETHGlobal San Francisco 2022, hosted by ETHGlobal.
Transcript
foreign [Applause] [Music] so I'm just gonna quickly go over how to add a uniswap widget into your site if you're interested and then afterwards um it'll it it should be very quick and simple and then afterwards if you have any questions about um how to integrate uniswap or how to use any of our other apis I'm happy to answer them or to just go over a few of the docs to show you where to look for answers um yes is this better yeah
okay okay so um to make integration with uniswap really easy uh uniswap exposes a big chunk of the swap API in a widget so the widget is just for swapping it's not for lping uh you can find the repo at github.com unit swap slash widgets and it's also on npm um there's initial instructions for using it right here in the repo as well as a branch to use it on create react app and next.js it is a react component and then just to show you how simple it is this is a create react app I'm just grabbing the window that
ethereum object if it exists initializing it um initializing it with ethers passing it into the app and then it's really just one line swap widget with the provider um you can add a bunch of other parameters to it you can give it a default token to start on um you can use it as a controlled component instead of an uncontrolled component where you would be able to listen to events like when a token
changed and then update the token appropriately but what that gives you I've lost it it's here what that gives you is this so uh if you have nothing connected it takes care of wallet connection for you just connect connect to that um so there's a metamask connection and then it'll read out to you what looks like I'm on cello get out of that it's gonna mean that 'll give you your bounce and it will let
you trade including giving you the current price when it when it fetches um so outside of this uniswap also has a whole doc site to introduce you to its contracts and the sdks to work with them um I can go over them briefly but does anyone have any questions this is this is really more of an FAQ than a directed I started trying to go through the V3 SDK to prep a demo but really what we do
on the website isn't following this this V3 SDK quick guide sorry the internet's not very fast um what we do in the in the website is we actually mock trades um through a client-side router um which I believe is a public repo that you could use if you wanted to in your project um so we mock those trades and then use that to give you a price that it's going to run at which is where a price like this will come from is anyone planning on using uniswap sdks in their hacker projects today
cool do you guys have any questions about how to use them um I can point you to docs but a lot of the work that I do is around swapping didn't work I would recommend using this guide guide providing liquidity over the V3 quick
start guide which I I haven't looked through so I don't want to I don't want to just read this from the podium um yeah uh so if you have your own project and you wanna if you have your own project and you want to make it easy to trade tokens into whatever erc20 your project is using um you could use the widget for that if you have your own project and you want to encourage lping you would
need to do something more sophisticated use the contracts directly or link out to uniswap to do that foreign yeah so if you want to make it easy to trade a specific token the easiest way to do that would be to grab the widget and just put it on your website and lock it into that one token if you look at
like the Friends with Benefits website um I believe they do something very similar with our widget where they just let you use it directly if you want to do something different like uh just have a little info blurb where it says the current price that it's trading at that would require you to integrate directly with the contracts and pull that yourself so basically like if if you have a need that's not the swap widget as it is we would love to hear it and maybe meet that need over time um but right now the swap widget is just is just this guy and this works cross chain so we're actually using it on the
website itself if you look at tokens this guy on the right side is the widget it's just not too bridging so it can only trade within one chain cool uh this is short and there's not that much else to go over so I'm going to bring up the poap code if you want to grab that before you leave
if it loads what um and I'll be at the unified booth for
today and tomorrow if you have any questions if you have more specific questions about the docs feel free to flag me down I'm happy to go through any of our interface code and talk about how it works
