Aave Labs 🛠️ Analyzing GHO Data
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join Matt Cole from Aave Labs for a workshop titled, "Analyzing GHO Data." This workshop will cover how developers can access and use GHO data in their projects. We will learn about basic ERC20 data as well as GHO facilitator data to power rich GHO-based applications. With a week of open learning, hacking, and workshops on all things stablecoin, as well as $75,000+ USD in prizes, LFGHO is a great way to connect with the community from around the world, and help shape the future of Ethereum and DeFi! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com
Transcript
[Music] hello everyone and welcome to the LFO a Labs Workshop analyzing go data joining us today is Matt Cole who will be taking us through this session and with that I'll pass over to Matt to get the session started awesome thanks so much so hey everyone um today we're g to be talking about analyzing go data my name is Matt I am a data scientist at avara and welcome to the lfg agathon so without further Ado what are we going to talk about today so we're going to really quickly just you know intro go and talk about what is blockchain data how can we access it the two types of data we're going to talk about is um query and contract State and using logs for go and then we're going to get into how go is not just you know a single contract it's not an island there's a whole ecosystem in you know facilitators that are you know contributing to um to go and how we can use data from all of these other different contracts I think it's worth taking a minute to talk about what we're not going to cover um we're going to be connecting to a blockchain node to query some data here and we're not going to necessarily talk about how to you know select a node provider and how to connect to them necessarily um if this is all news to you if if you know you haven't done this before um don't worry I've put together a couple Links at the end of how you can you know connect to a node and kind of get started so we're going to keep this pretty high level so even if this is completely new to you I think that you can still you know absorb it and then later you know you can use some of these links to um you know get yourself up to speed um likewise we're not going to be talking about specific libraries of how to connect to nodes again this is going to be pretty high level so don't worry if um you really want to use JavaScript and we're using something else or you really want to use web 3py and or web3.js or something like that and we're using you know something else um don't stress high level and a lot of this information or all this information will translate from one to another and then you know also we're not going to be getting too much into like exact syntax or anything like that so what is go right uh I have the pleasure of being I think the first um Workshop so you know we should talk about what is go so go is the a St a native stable coin and what's exciting about us all being here today is that you know from my perspective at least go is in a lot of ways what you make it um because go you know is it the stable coin that's powering you know a really cool payments app is it a stable coin that's powering some sort of Sav uh protocol is it something else that I've never even thought about um that's up to you right you guys are building you know the future of go I think that's really cool and I think what could really augment and elevate a lot of these applications is using data in a you know clear and coherent way to help um you know create the best product possible so what is blockchain data like what is go data where can we get it you know all these questions um I think are really important and I think there's two types of really important blockchain data that we're going to be talking about today the first is contract State data so this is any data that's stored you know within a smart contract on ethereum on our blockchain and um you know we have up here on the top right here we zoom in um you know this is just an ether scan UI of us quer imping the balance of a particular user so I think this is like a very common um way to collect data for a particular um you know smart contract and another type of data that we're going to be talking about a lot is event logs so a lot of um smart contract developers they'll add logs to their smart contract so when certain important events are occurring little pieces of data will be emitted saying hey this is what's happening here you know a deposit is being made a swap is being made here's who's making it here are the assets and and here's what's going on so we're going to dive into both of these too there's other types of blockchain data too um but we're not really gonna get too much into those today I think um contract State and event logs is is already a lot so we're gonna we're going to really get into it so what can we do with go how can we query go data so I think it's important to right off the bat note that go is an erc20 token so an erc20 token is a token that follows a particular set of standards that make it really easy for blockchain developers to interact with you know erc20 tokens generally so go is an erc20 token you know other tokens that are well known like usdc are also erc20 tokens and that means that you know applications data applications um protocol can all interact with them in in a similar way because they have a similar set or the same set of of functions so go is a superet of an erc20 token right it has a lot more functionality than a basic erc20 token but it does also have this kind of common set of functions that we can use to query data from so right here I actually included all six of the um ERC 20 specified view functions so these are functions that just return data from the contract and these are functions these six functions are you know ones that are included in all compliant erc20 tokens so we see them right here this is how we can get the name symbol decimals the total supply of go as well as you know the balance of a particular user so you know let's see that in action like what might that look like we could kind of easily query you know just using this one call right the total supply of go which is you know might be pretty important to know um and I think even more relevant might be we can query the balance of a particular user so that's that's it over here we have this particular user we might want to query you know how much does this person have or this address have right now um and that's great because we'll always you know update if we call this function in two hours maybe they've sent some go to their their friends or something like that this will always um change and reflect the current current state of this user um so we have that and that's a really powerful way kind of table Stakes really to um to have like you know an application we should probably know how much um go a particular user has the other type of data that I want to talk about is event locks so as we kind of mentioned before event logs are put into contracts by developers to um flag when certain big kind of events are happening things that typically things that change the state um are accompanied by a log so the logs will be emitted and they will kind of give almost like a minimum sufficient amount of information to describe what's happening so a very common um you know event for tokens might be the transfer event so the transfer event is emitted when we have um you know a transfer occurring when basically tokens are moving from one address to another and what's cool about logs that is a little bit different than just quering state is that they're emitted at particular time so we could actually construct like histories and actually see um yeah basically just see the whole history we're not seeing like the the cumulative sum of all the transactions which would be the current balance but we can actually see discreetly all of the little things that have led up to a current balance and right and there's events for you know many different um types of events right like we have um you know if you consider you know an application like Unis swap that might be swapping go we can see that there might be swap events and things like that but just as an example we can look at you know how might we find the historical balance of a particular user using events so as we kind of talked about whenever there's a transfer ER so whenever go moves from one address to another a transfer event gets emitted and this transfer event has a couple pieces of information I kind of think about it as like the minimum sufficient amount of information to kind of describe what's happening um and that's it has the from field which is where the tokens are coming from the to field where the tokens are going to and the value field how many tokens are we dealing with here so this is kind of like um if you look at your bank account or something like that or a credit card statement right it's all the the money maybe flowing in or out um and that's each transaction in in the credit card world right is kind of each transfer event here so how might we get historical balance well we can grab all of the transfer events that relate to a particular user and we could kind of compute you know a rolling sum so whenever there's a transfer event from that user we know that they're you know losing tokens because they're transferring them to someone and whenever they are transferring to we know that they're going to be you know gaining balance they're going to be increasing their balance so we'll go grab these events and then compute the rolling balance and then we can you know do whatever we want with it so let's look at how we actually do that so there's a lot of ways to query um event data in in blockchain actually some people are very passionate about a particular way of creating uh you know event data I think for me the the easiest way to um communicate uh how to do it is using event filters so basically we could kind of think about this as ethereum has you know our ethereum node has many many events and we kind of want to we only want to look at the ones that were we're interested in right we don't necessarily care about some random event that has occurred you know a long time ago that has nothing to do with go right we just want go transfer events so we could filter to do that so if we look here um a lot of these uh you know libraries that interact with with our blockchain nodes uh you know have this functionality to to Define an event filter and they usually require a couple different things so one thing is it requires the address so we only want go transfer events right so we'll specify that hey the address we're interested in is go so only look for the uh you know events that were emitted by the go contract and then we also only want to look at transfer events right now so we could also add in here this is like a little bit um a little bit maybe strange the first time you're exposed to it but we only want to find transfer events we have to find the transfer event signature which is a hash of the name of the event as well as the uh data types of the um of the event basically um it doesn't we don't really need to get it into it too much but I link to a really great blog post um at the end that if you're interested in this uh you know you read you could read and it really dives into all these different intricacies of of events um but Yep this will basically tell us this transfer event signature is basically the the fingerprint of a transfer event so we say hey we only want to look for go events or yeah go events and we only want to look for um transfer events so that's these two right here and then just you know to kind of speed things up we can actually tell the node hey only look between these two blocks so we could say hey only look from you know between um when go was deployed because there wouldn't be any um you know events that were emitted by go before it was deployed to the current block so we kind of say Hey you know we don't really need to worry about blocks that were produced in 2019 because go wasn't deployed then we could kind of skip that and and only look at the most um re and PLS so if we do this we could get um our big list of of locks and we kind of turn them into you know I don't want this to be like a a python lesson or anything like that but we basically get these three Fields right we get the from the two and then the value so this is all transfer events that were sent to and from um you know anyone all all go users so we could basically filter this down to the um user that we're interested in and I just picked a um it's not even a user I picked a Unis swap V3 pool so we can look at how much go is in this pool and we could do exactly what we said before right we could say hey um increase the balance when there's a transfer to our address and then decrease the balance when there's a transfer from um this address so we can get something like this so this is pretty interesting right this is a a much more Rich way to kind of see the token balance right because we can see historical um balances through time and this is pretty interesting right because if we are building an application you know maybe this isn't something that we we need but maybe it is something we need right it all depends of course on on what we're building um but this could be a really good view to you know good way to view maybe you know go held by an address over time or things like that we could also Imagine you know these these um transfer events we could also Imagine you know if we're building something like a payment protocol or something like that or a payment app like you know it might be important to know hey you know this address that the user is trying to send to have they sent to them before because if they have right then maybe they know that person and it's okay but maybe if it's a new address we need to be a little bit you know more careful that they're not being um scammed or something like that you know so like this historical information about you know who these tokens were sent to and who they were received from can be very valuable depending on you know what the the application is so I think that that's something definitely uh that's pretty pretty neat so we just talked about like creating State data to get um you know the balance of a particular user and then using logs to do pretty much the same thing to get the balance of a user and and it might be you know a case where you're wondering like which one should we use um you know what's better and a lot of web 3 uis use the State they query the contract State and that's because you know for a single user it could be very fast to look up um the state of that particular user and also it you know you're pretty you're assured it's it's real time and it's actually very literally what the contract says the balances right like if the in some ways the contract is the truth right so if the contract says hey um the balance of this user is you know X like you can be pretty sure that it's it's that it's X but the thing about querying the contract state is we don't you know get anything historical right we're just very much you know point in time right now what's the balance of this user so if it is important to you know look at um you know historical data you know that's sometimes where logs can be of use and not just historical balance data right like I was saying before maybe we're interested in you know knowing the history of like who a particular address has sent to and who they've received from if that's important too you know we can use logs to kind of get that that data as well um maybe you know a bit out of the scope of this presentation but you know if we're if we're storing logs you know it doesn't necessarily make sense to always be quering our nodes you know these are things that we can you know store in a in a tabular table and you know a database or something like that for easier retrieval but um I definitely wanted to expose you to um logs and quering state data as uh as both different different options so everything we talked about so far has been just querying the go contract which is great and I think that there's a lot of really good data there but the truth is you know go is not a single contract the go token is but go you know the go ecosystem which when I hear go I think the go ecosystem really is so much more than that right so go is you know a big part of defi it's you know in a lot of different decentralized exchange pools you know it's being used for payments people are holding it right it's being used outside of the ecosystem and then there's this entire you know facilitator you know very interesting um mechanisms where facilitators are creating go um and really controlling the supply and I think that you know to really understand go is to kind of really understand how all these pieces play together and I think you'll be getting exposed to you know the facilitators like much more um in the near future so I'm not going to go into them too much but I think the important thing you know right here we're going to talk about them a little bit of course but uh the important thing here is right that the facilitators are the um the contracts that actually you know can you can create go with right so you can actually you know if you want go you could actually mint go using the aav3 ethereum facilitator and this facilitator has a lot of different parts right it's part of a which is um very elegant protocol very very elegant but there's you know a few pieces to it too it's not just a very you know extremely simple protocol too right we have um pool contracts debt tokens oracles you know even governance is all a very very important part of the a protocol and of this facilitator too right so we want to know you know what facil ators are available to go right and and that's a function as well that we have within go right so we can you know figure out what facilitators there are for go and then we could actually see a very important part of the go kind of RI risk mechanism is understanding how much go each of these facilitators are allowed to Mint or create so we actually see here on this bottom screenshot that the av3 ethereum pool has a bucket capacity of 100 million so that means that go is saying the go contract says hey um we permit you to Mint up to a 100 million and currently there's about 34.7 million which is the same number that we saw before right when we queried um the total supply of go so we'll spend a quick um a minute or two on the a V3 ethereum facilitator so what is this facilitator so the very very short version of the av3 ethereum facilitator is we can mint go using this facilitator in an over over collateralized manner so that means that we can supply assets to uh to a and then we could mint against that collateral so typically maybe we can supply you know $2 worth of eth and then maybe we can borrow you know1 do worth of go one go um and right now it's actually the only way I think why it's so important is it's the only way to obtain um persistent go so go that you could actually have in your wallet is through the iv3 ethereum facilitat so if we're building any protocol or any you know interface that kind of gives information about go or maybe is informing a user on you know if they want to borrow go or otherwise obtain it it might actually be pretty important to really understand you know av3 just as a whole but also the AV V3 data because there's a lot of you know moving Parts with a and it might be important to kind of inform like is this a good financial decision uh for a user uh you know to understand you know how much yield are you know if I deposit T how much yield am I going to get what's the borrow rate or what's the um the fee to maybe mint go and hold on to that debt these are all questions that are very important so you know I put down here you know some that I was just thinking of but there's there's many more like part of this whole thing right I think is to understand what is important for your you know application what data you might need for your application um but here's a couple that you know I could imagine might be important like what assets can be used as collateral right you can't necessarily use any token as collateral um so what assets can be used as collateral how much go can be borrowed right there might be um a cap on the amount of go go that can be borrowed it might also be important to know that you know what's the go rate um and how much interest is the protocol offering for the collateral right these are all things that might be you know pretty important to make an informed decision so this is the a V3 ethereum front end right and we'll actually notice that they did you know this is a great UI has all of the information that like you that were I don't know that we were just talking about right it has um you know the supply rates for different collaterals it's a list you know I cut it off of course but there's a list of all the collaterals that you could Supply um so this is like a really great way to you know see see how you know all the information we need to make a decision on if mint and go is is right for us so in order to get all this data though right there's a lot of contracts we might be needing to interact with right we might need to interact with the ethereum uh V3 ethereum um pool contract to get some data on you know uh the rates of all these you know assets and and what assets are allowed we might need to you know hook into oracles to see you know the price of all these assets right there's a lot of things kind of going on but luckily the um a you know interface um is actually using a really nice helper contract that I just think uh could be really good for some of your projects maybe because it collects all of this data into one spot so maybe this is like um you know a way to kind of you know if you need extra data you know of course you can grab it but maybe you can you can take a look at this if you're building a UI with some of your AA data I think this might be like the um the 820 of the presentation is like hey like here's a you know a contract that has a lot of relevant data for you so if we go on over here there's two key functions and again um I know we're going pretty fast but this data or this information um it's in the documentation and I have some links to it in um in the uh the repo that I'm going to share at the end so definitely take a look at that if you're interested in using more but we have two great functions one gets really detailed Reserve data and the other gets really detailed um user position data basically we call them user Reserve data so we could see here again it's not you know it's not a a python class or anything like that but if we just call git user or git reserves data we get a ton of data on all of the reserves and we could really use this to you know for a ton of different use cases but you know we can easily get you know if we're curious you know how much of an asset can I Supply how much can I borrow against a particular asset you know it's all kind of collected here um you know the team did a great job putting this together so this is a really great way to see you know the list of assets and a lot of information about them including the the current rates and um you know how much is available to borrow so I definitely recommend taking a look at this um and again don't worry all this um you know code and everything like that is also in the in the link so um I hope no one's like you know trying to write this down or anything like that so in summary we can get a ton of data from the state of our contracts like just in that example right there um it's a very powerful way to get you know the current current data from from uh go and then events could help us understand a little bit more in context a little bit more data right we can get historical data and we can see the little pieces that maybe we lose and we just look at these almost like summarized versions on on the contract and then maybe this is the the main point right like go is more than just an erc20 token go is so much more than just one token right go is an entire ecosystem and of course so is go data so I think it's um you know really important to to keep all of that in mind as we're um you know building our project I think you know uh the facilitators and The Wider defi ecosystem is just a key part of go um so yeah thanks so much so that was the the presentation um here is this link uh you'll find I think two main files in this repo one is just a read me um that has some links in it if you're interested in in learning more um and then the other one is just a Jupiter notebook with um some of the codes you should be able to run that and do everything we did um today if you if you want to um and yeah and here here's where you can find me on xen lens and I'm happy to I know we have a couple minutes I'm happy to answer any oh my gosh we have the chat here okay let's see yeah it's a there was a there was one question earlier on that was already addressed and then um uh Tomy had asked is there a way to query the historical borrows lens lens of an address yes we want to query the historical borrows um that's a great question um yeah so that we can use with um events as well um the a pool contract has an event called borrow and that will actually give us um you know who borrowed it's actually a bit more uh complicated of an event there's many more Fields but basically will tell us who um borrowed what asset was borrowed and um how much that asset was borrowed right so that gives us pretty pretty good information awesome and then Vincent had asked uh can we get a proper documentation most documentation on E Global is empty um I think this might be referring to maybe some of the uh resources I think the team was updating so Vincent if you probably go back and check on the on the um on the website then all those resources should be updated but I don't know if you have anything else to add to that although I'm not really sure it's kind of kind of a broad question the link is oh you know uh maybe I did type it should be L LF okay here it is so if you I don't know if I maybe did a type out but it should be L FG okay cool and then um the other question was I see something cross chain bridging um there's no um like a like uh cross chain bridging for um for go yet but you know that could be something um that maybe you look into for the project there's a nandy b asked about multi- blockchain with implementation on multiple blockchain chain and governance contract uh go is currently on ethereum but does it was created as a to have multiple input impementation they share the same orchestrator contract um if I understand this question correctly this might be about like multi-chain go which is um something that you know go right now is only on um you know ethereum basically but yeah I mean I could imagine right um a facilitator is Av V3 ethereum is a facilitator um it might not be that hard to imagine that maybe you know arbitrum V3 um could be a facilitator in the future future right um and that would be you know a different maybe contract I'm not actually sure how that would work but you know that could be something that that happens and then is quering event similar as creating a state on a blockchain um so they're actually different so like actually uh logs event logs are not stored like literally on the blockchain usually the nodes kind of store them so they are actually a bit different um they are a bit different if you're interested in logs I definitely recommend um the blog post I put it in in the notes um that could be yeah a really great read for you um bridged asset uh you know I don't know the rules uh but you know um a crossbridge go sounds pretty cool to me uh yeah that's that's totally that's that's fair game I if you can do it go for it yeah yeah that sounds that sounds good to me too um is test go uh maybe someone else can answer what test net but I think maybe that is [Music] true um okay awesome I think that's all the the questions uh for creating a new facilitator um I don't yeah I don't maybe the test net has different governance uh I'm not sure how that would work for creating a new facilitator but I think that there might be yourr this is a long one and yeah we'll probably maybe end it in about two minutes so this might be the last question okay perfect and for folks if you have other questions definitely uh once this ends you can always drop them into the partner Discord Channel as well and uh some of the mentors will be able to address them too if you have a question that we weren't able to address in time yes so this question about um borrowing yeah basically um it it might sound a little bit strange but yeah if you borrow 100 go and say you're the only person that borrows go um at the end of one year right you would owe more go than you borrowed um and there actually wouldn't be um that much go in existence right um that might sound weird and maybe concerning but the idea would be that if if that were the case right um which which it isn't then um the price of go would probably go up and then people would borrow go to kind of Arbitrage that difference right and then there would be much more go like I think it's um you know Inova this sounds very very strange but um you know the the go Peg would kind of facilitate U minting more go so I think uh that's a good question that maybe deserves a lot more of an answer than um than I gave but yeah um and yeah a V3 is the only facilitator as well as the a um The Flash mint facilitator oh awesome well thanks everybody for attending and thank you Matt for the great presentation and yeah like I said if if you have questions still please um you know send them into the uh the partner channels on Discord and if you haven't done so already connect your hacker dashboard to Discord too um but uh yeah we look forward to you know contining rest of the day don't forget opening ceremony and Summit it starts in a couple of hours and there will be more workshops uh throughout the day as well so cheers all thank you everybody thanks Matt thank you [Music]
Automatic transcript — names and jargon may be misspelled.