Uniswap V3 SDK and GraphQL Walkthrough
Вставка
- Опубліковано 11 гру 2024
- Whilst exploring the possibility of triangular arbitrage on Uniswap V3, working with the SDK can be somewhat daunting or feel complex. Wanted to put this video together to show actual code behind the scenes on how to a) get GraphQl price data and b) price information for a Swap directly to the smart contract with depth.
In this video, we do not show triangular arbitrage itself, but the first building blocks to get there. Feel confident that many programmers will be looking to connect to price information on Uniswap V3. The aim of this video is to be able to use the V3 SDK and understand how to query data.
cryptowizards.net
I've been looking for this type of content for months, keep it coming
Thanks so much brother. Really appreciate the encouragement.
one thing to make sure of when talking about price differences is making sure the sources you are comparing are from the same block; sometimes the graph indexers might not be "caught up" to the current block, therefore giving you stale data
Well spotted. I need to work on this!
More behind the scenes please! Great video!
Finally, something that really clear. Please keep it up! Thanks!
Awesome feedback, thank you!
Your research are so interesting and nice to see your videos
Oh sh*t! The Wizard has returned from his quest and dropping some hot new content! Always worth the wait. Cheers
LOL! Thank you brother. Appreciated that.
This tip might save a lot of people a lot of time: There are two reasons your output amount might deviate from the one on Uniswap's page.
1) You have to consider price impact in your calculations. The more you swap, the less you get with AMMs.
2) You also have to subtract the swap fee from the output.
If your output is not the same (I mean every decimal place), then you are missing 1) and/or 2).
I hope this helps ♡
Fantastic thanks Rafael!
This was a great video I’m attempting to create a multi DEX price oracle in Python and gave up on integrating uniswap v3!!
Awesome initiative - keep going brother!
Extremely helpful content. Thanks for making this video. Subscribed.
Awesome brother, welcome!!
I believe the price difference is because of the time delay between querying the indexed data from Graph QL versus directly querying from the blockchain itself. So in essence, theGraph data might just be one or two blocks behind the present
Aaaahhhh - you know your stuff. Thank you for the contribution!
Awesome stuff, more behind the scenes please
Good to know, thank you!
This was extremely helpful thank you very much.
Awesome, good to know.
yes! More behind the scenes, please. You have good content. I'm getting more confident with your videos.
Great content man
Hey mr Wizard! Could you help me on how to calculate the unclaimed fees for a running LP position?
whats the unit of the liquidity value
great video! thanks for the content. Were you able to preform a triangular arbitrage? Also, thoughts on how to take this data and compare it to other dexs for more arbitrage?
No, I really just research this right now. The feedback from those acting on it is that Polygon is the way to go right now.
@@CryptoWizards Ok. Is there a video going over the code for the triangular arbitrage? I'm interested in how this is done, even though it is not very profitable on Uniswap
Hey, thanks for tutorial. Do you know how to change liquidity format to USD? Like there are wierd big numbers such as "75097587164108417545395" under field of "liquidity" by any chance what does that number mean? Can it be transformed to USD?
Great content, but how to do actual swap with V3 SDK?
You just need to follow their documentation "Uniswap V3 SDK docs" - then search for placing a trade. We also cover this in the Trading Execution course.
Hi.
did you have problems with the function quoteExactInputSingle?
For me it works 50/50.
But for some pools it failed with 'call revert exception' error .
Yes for sure. One other method is to use the reserves calculation approach. However, the best way is to just fork the mainnet. Will do a video on this shortly.
@@CryptoWizards Thank you sir. it would be very interesting to watch this video
Awesome stuff - but I do admit this is way beyond my paygrade! :>)
Nah - I'm just a total nerd buddy!
@@CryptoWizards True that 😝
great video!
Thanks Unai!
thanks, keep it up bro
Thanks brother!
that's strange that the price varies. should you just scrape the string directly off the webpage then? lol
Haha. Its not a bad idea, but for scanning so many currencies the price would change by the time you get to do the calculation. Also, I reckon there are multiple pools for the same swap pair...could be wrong but will find out.
BTC to 69+ by EOY. No doubt
Behind the scenes, more please...
Thanks for feedback - next one just got published.
Love the vid. I've been playing with the v3 sandbox and I'm trying to find a way to match the 24h and 7d volume figures shown on the pools info page
as an example I use
pool(id:"0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"){
totalValueLockedUSD
poolDayData{
date
volumeUSD
}
}
which gives me the right TVL but it only gives me data from dates from last year. Any idea how to get current data? I would be most grateful for any input
Thanks Philip. Another approach is to get the prices direction from the smart contract (that would be the most accurate).
behind the scenes
maybe try 1inch they have an API and they already get the best price for a pair between all dexs
Nice recommendation, thank you!
Excellent content, I appreciate the behind the scenes. Have you thought about adjusting the price yourself by using the same AMM formula used by Uniswap, just to see if it matches what's displayed on their page?
What a cool idea. I hadn't thought of that!
@@CryptoWizards they all use the formula uniswap uses, we'll... not all of them but most of them
@@CryptoWizards I made a simplified version for node.js and one for rust, what's your bot written in?
I think it was python, I've watched si many vids since then 😆