New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Kevin Jones I Beginner's Track, Lending & Stablecoins I ETHGlobal Prague 2025

ETHGlobalThu, Oct 9, 2025, 12:00 AM

Speaker

Kevin Jones

Kevin Jones from The Graph and Build Guild dives into overcollateralized lending and stablecoins in this ETHGlobal Prague 2025 workshop. Learn how decentralized stablecoins like DAI work, explore key DeFi mechanisms (oracles, collateralization ratios, liquidation), and see a live demo of a simulated stablecoin system using Scaffold-ETH. Discover how to adjust borrow/savings rates to maintain peg stability and get a sneak peek at Speedrun Ethereum’s upcoming lending challenge. Perfect for developers interested in DeFi, smart contracts, and algorithmic monetary policy. 00:00 - Introduction to Stablecoins & Lending Challenge 00:37 - Scaffold-ETH Recap for Beginners 01:34 - Types of Stablecoins: Fiat-Backed vs Algorithmic 02:36 - Overcollateralization Explained 03:40 - Oracles, DEXs & Stablecoin Engine Contracts 05:08 - Stablecoin ERC20 Modifications (Mint/Burn Controls) 07:08 - Economics of Overcollateralized Stablecoins 08:44 - Scaffold-ETH Setup: Chain, Frontend & Deployment 10:06 - Live Demo: Depositing ETH & Minting Stablecoins 12:10 - Adjusting Collateralization Ratios 13:54 - Simulating Market Activity with Bots 15:35 - Manipulating Borrow Rates for Peg Stability 17:28 - Savings Rates & Incentivizing Holders 19:29 - Liquidation Mechanics in Action 21:40 - PEG Stability Modules (MakerDAO Comparison) 22:49 - Q&A: Oracle Integration & Hackathon Ideas _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇨🇿 *ETHGlobal Prague* This workshop is specifically for ETHGlobal Prague, a 3-day hackathon held May 30 - June 1 2025, bringing together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! Watch the full ETHGlobal Prague 2025 playlist here: https://youtube.com/playlist?list=PLXzKMXK2aHh5Vv-ZobDU2YMWekDFYvOqd&si=SoQ5O2TOAK8RkYf- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ Follow Kevin Jones X: https://x.com/cryptomastery_ ✅ Follow Buidl Guidl Website: https://buidlguidl.com ✅ *Follow ETHGlobal* X: https://x.com/ETHGlobal​ Warpcast: https://warpcast.com/ethglobal Website: https://ethglobal.com YouTube: https://www.youtube.com/c/ETHGlobal _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Are you interested in Ethereum development and entrepreneurship?_ 👉 Sign up for the next ETHGlobal event: https://ethglobal.com/events 🎁 Get exclusive access and perks with ETHGlobal Plus! https://ethglobal.com/plus 📣 Want us to throw an event in your city? Tell us where! https://ethglobal.com/city _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Transcript

[Music] Uh my name is Kevin Jones. I am a developer relations engineer working for the graph. I also am a core member of the build guild uh supporting scaffold ETH. And uh today I'm going to be talking about uh an upandcoming challenge that is kind of in the process of being built. Uh, so I'm kind of giving you guys a sneak peek of like the mechanisms.

You guys are going to kind of have like a little bit of an edge when you want to take that challenge. Uh, it's going to be one of the later challenges. I think it's like number six or seven on the list. And so you do need to do the challenges in chronological order. Uh, as Austin kind of explained earlier, um, I'll try to kind of uh, recap a little bit of the stuff that Austin already talked about so that you guys can anybody that's new here can kind of understand scaffold.

I guess show of hands. Who here has actually used Scaffold ETH here? And who was here for the Austin's previous talk? Who's new? Okay, cool.

All right, so half of the room. So we'll kind of assume that like scaffold ETH is kind of like new to some people. Um, so again, the repo for the the stable crunch challenge is not public. Um, but I've created this kind of like read me which will be a good kind of like guide for you if you want to understand these in like more deeper concept and imple implement this on your own. Um, so you guys can stay on that if you want.

Uh but basically the the general idea is to understand like stable coins, you need to kind of understand like the different kinds of stable coins and you also need to understand uh a little bit about lending like lending protocols and how they work. Um and so we know there's like lots of different stable coins that are available. Some of the the more I guess popular and like stable stable coins would be ones that are like onetoone collaterized with fiat, right? Like fiatbacked. So USDC uh or Tether, right?

Tether. these these companies when you buy when you get a USD USDC it's minted you have to back it with an actual like um uh T bill like an actual like dollar and so they're backed one to one right and then you have like the underolaterized like kind of uh algorithmic stable coins which we know those are kind of sketchy and you probably don't want to really touch those uh and then we have like these this overolaterized and more of decentralized aspect of stable coins right and so that's what we're going to be talking about today so it's good to kind of like make that um differentiation. And when we say like overcolateralized, what we mean is that in order to mint new die or new uh overcolateralized stable coins, something like go or some other uh similar mechanism, you need to be able to provide some percentage of capital into that as a backing, right? And so this is through a a way where you actually are like staking something into u um like a contract and you're able to kind of borrow uh some kind of collateral on that contract. And so uh the general the general system is that you you need a way to uh have like a price feed for the actual stable coin as well.

So you need uh like an oracle, right? So you might might be familiar with like chain link price feeds. Um, you also might be familiar with like like D like makerdo they have their own kind of like oracle system and the the challenge actually doesn't really get too much into the oracle aspect and we're not going to cover too much of that but you can imagine that you do need to have some kind of way for the smart contracts to know and understand what the price of uh ETH is right if you're going to be taking in ETH as collateral u you need some kind of way to understand what that is in the contract so just keep that as kind of like in your back of your mind when you're building something uh in terms of overcolateralization uh and you're using a price feed, you need an oracle. You also need a DEX. And the DEX that we're going to kind of show off is uh a little bit of a dummy DEX.

It's like a very basic example of what a DEX would look like that's going to allow you to like do automatic automatic market making with your liquidity. Um and then the the the actual backing of the system is done through really these two contracts on the top. Uh well actually it's like three three contracts. You have a staking contract where you actually can like earn some kind of yield on the uh token that you that you want to yield. So like in this case we're going to be talking about a myusd.

So our that's what our stable coin is going to be called. Um and then you also have a engine which is kind of responsible for like controlling the the amount of minting that happens and the burning that that needs to happen as the collateral goes in and out of the contract. Um, and so it's it's a complicated system. I feel like, you know, there's that like meme of like the guy from Always Sunny where he's like pointing at all the stuff. It's kind of how I feel right now because it's like very much all over the place, but hopefully by the end of this you guys have a a decent understanding of uh DeFi over over collateralized lending stable coins.

Okay. So, um, this guide that I that I kind of created, by the way, I created all of this guide with AI, which is awesome because it goes through each particular contract and kind of explains all of the functions in there. But this is like a massive document. So, this is something you guys I'm going to glaze over like with some important things and then we're going to do a demo. I only have about 20 minutes.

So, I think what I'll do is I'll kind of focus on like uh a couple of the contracts and we won't really look at all the contracts, but I'll I'll point out the ones that are really important. So the first thing to understand is that the stable coin itself um I don't know why that keeps cutting out but the stable coin itself is a standard ERC20 with a little bit of a modification. Uh the main thing is is that we don't want uh like normal um ERC20s when you mint tokens or you burn tokens the total supply is kind of calculated based off the mint minus the burn. And you also might have like the contract owner be able to mint and burn tokens in certain scenarios. In this case, we we want the engine, right?

We want the DeFi or we want the stable coin engine to be the only one that can mint new tokens because it's going to always make sure that the that the uh user has put in the right amount of collateral. Um you might have a situation where you want the owner of the contract to be able to burn the tokens and we'll get to that and that why that might be. Um, but for the most part it's like kind of like access control so that only the engine contract can mint new tokens. And so we have this very basic thing where we ingest, right? Like with solidity, you can basically take a contract and you can uh load it in as kind of like a proxy contract, right?

Um, and that's what we do here. And you have this these two mechanisms, right? You have like the burn from and you have the mint. So let's look at the mint first. So, if we want to mint more of the stable coin, we make sure that uh the person that's calling the mint function is the engine contract, right?

Because we don't want any BundyB to be able to print money out of thin air because that would be like you're the Federal Reserve and we don't want that, right? That's why we're all here. We're trying to get rid of that. So, we have that and then we have the burn function, which also the engine contract is the only one that can burn assets. And then we also, like I said, in an emergency, we might have to this issue where we have like too much dye.

And uh I'll try to get into like why that is. And I'll try to give you a a quick economics uh lesson on why that would be. Um but generally speaking, the idea is that we want, you know, when stable coins became a thing, it was that there was a lot of ETH holders. They were very bullish on ETH. They knew that the ETH price was going to go up over time and they needed a way to put that that asset into a contract and get back something that is stable.

U just like we use dollars pretty much all around the world like the most I guess stable uh thing you can think about is the US dollar. And so that's kind of how how stable coins were born. Um, and so we have some things here where we like calculate total supply a little differently because we also need to consider, you know, I'm going to do something here. I'm just going to wipe this out. Put this in here because I have HDMI and see if it's better because that's really annoying.

It keeps cutting out. Okay, let's try that. Okay. So, um, so we also have to like account for like not only like the total supply of like circulating stable coins, but we also have this mechanism where people are going to be staking and getting shares. And so there's this kind of special total supply thing that you also need to consider.

Um, and so that's good to understand. Um, but really the the the meat and potatoes of the challenge that you will have to do in the challenge is to figure out how the engine should properly deal with the collateral and how they should deal with liquidations. And we'll get to that in a sec. Um, and how you should calculate um uh the precision of of the values. And so a lot of this stuff uh is hardcoded in like consistent variables that are like private and stored inside of the the engine.

Um, and let's let's actually just kind of show it off. I think that's going to be the best thing. So, we're using Scaffold ETH, obviously. So, it's uh if you haven't used Scaffold ETH before, you need a couple windows open. You need a window for your chain.

You need a window for your front end. And you also need a window to do your deploys. And if you have any scripts you want to run, uh there's also another window we're going to use for simulating some kind of like lending and borrowing and staking. And so what I'm going to do is first spin up our chain, right? So this is going to spin up uh whatever chain you you selected when you start the challenge.

So you can use hard hat or foundry. And that's just like this kind of play money that we can kind of like test out with, right? Got a bunch of ETH in there. And then in this next window, we spin up scaffold ETH right on the on the React with Nex.js.

So scaffold ETH is a starter kit. So it comes with uh a front end. It comes with a bunch of TypeScript already written for you. The challenge has a lot of UI stuff already written for you that will teach you kind of like the essence of what you're trying to do. And then this very last window is where we need to do a deploy of the contracts.

So we we'll look at the contracts in a second, but first I want to show you kind of like what they look like visually. And by the way, again, this is going to be a contract that's in a complete state. And so it's really a good example of like how you would implement this in a real kind of stable coin scenario. So we can see the contract deployed successfully. We can see that our front end is up on port 3000.

And we'll get over here later. We're going to do some simulation to show some traffic, but let's go ahead and and spin up scaffold. So scaffoldeth runs on port 3000. We'll get that up and running. Okay.

So what what we get here is this kind of like really cool dashboard. So we still have this kind of and let me just go ahead and disconnect. I'll be on the So if you're ever used scaffold ETH before, you'll know that we have this burner wallet functionality. So when you first load up the app, it's like an in browser wallet. So I just was connected with my ENS, my MetaMask.

I just disconnected and it automatically connects to your burner wallet. And what's nice about this is you can just kind of test here and you can also load up an incognito window, right? Where you can come and go to the same port. Oh, 3000. And you can have this kind of new identity, right?

So if you're kind of trying to test this functionality, we we might use this other kind of identity here in a sec to do something similar. So let's first focus on this. So if we if we think about uh overcolateralization, right? I've talked about it a little bit already, but the idea is you have a bunch of ETH, right? ETH is at a certain price, right?

And what you want to do is basically let people come in, deposit their ETH, and get back a stable coin, right? You want to give them uh something that's value at the time that they staked it, but the price of ETH will go up and will go down, right? And that's going to affect the percentage rate. And so in order to be uh I don't I forget what the word is, but in order to be like good with the system, you always have to maintain $150 of your reserves. So if you put in $1,000 of ETH, you can withdraw $500 of a stable coin and that puts you at this ratio, right?

And so um if we do this, let's go ahead and just take some money from the faucet. So I'm just going to get a lot of ETH so we just have like a decent amount. Uh, sure. Let's get 11 ETH. So, I'm a little bit of a active DeFi trader here and I'm like, well, maybe I want to do something more interesting with my ETH.

I really believe ETH is going to go up. So, I'm going to come in here and I'm going to say um I'm going to go to collateral and I'm going to add some collateral. So, I'm going to add 10 of my ETH to the to the to the collateral. So, I'm going to put in ETH and I'm at that point I'm like putting in this ETH into the contract and I want to take out and mint some USD from that value. So, if I mint uh well, we could do the math, but let's just mint let's take out $10,000 uh here.

And it's going to show you what your ratio would be, right? So, if I put in 10 ETH, I can get out 10,000 and it's going to put me at 80%. Now if if this contract if I fall below 150% there is a liquidate function right because we need to keep the we need to keep the system whole like we never want our amount that we're giving out in debt to be um less than what our uh well higher than what our reserves are worth right so if the price of ETH is crashing right and going down this is going to slowly go down as well and my ratio is going to be off and in order for for me to not get liquidated, I need to deposit more ETH into the contract to raise that percentage, right? So, um, that's what we're doing here. We have this.

So, let me get the the $10,000, right? 10,000 going to put me at 180%. You guys a little buggy, so this is still work in process. Okay, there we go. Mint.

So, now I've put in 10 ETH. I've gotten back $10,000 in in my USD. And you can see now we have minted supply. So, here we get the minted supply. Um, and then if I was to come in a little bit more, maybe I want to grab a thousand more, it's going to tell me, oh, I'm at 163.

Boom. Whatever. Now, what happens is if we were to start to bring in some players to this system, right? We're going to see what happens at like a larger scale. And what what we're going to do to simulate that is we're going to run a yarn simulate command.

So, what this is going to do is it's going to spin up five bots basically that are going to start activating in the protocol. And there's some DeFi stuff in there that you can look go through the script and see exactly how it's doing it. But we're going to start simulating some borrowing and lending, right? We're we're going to simulate deposits, some borrowing, and then we're going to see what happens as we kind of start to do that. So we can see here that we start to get active players that are starting to deposit large amounts of ETH, right?

And we can see that the price of the MyUSD is falling, right? Because there uh is too much demand essentially for uh the stable coin, right? The market's doing awesome. Like it's DeFi summer again and everyone is just trying to put all their ETH in and get as much US dollars. And so we have to correct that.

And so if you know economics, you'll know and understand that you have two levers to do that. One is you increase the borrow rate. So right now the borrow rate is 0%. Like of course every all the bots are just trying to get as much uh my us possible. So what you do is you increase the borrow rate.

So we take the borrow rate and let's go ahead and just hike it up to 10%. So we're now we're like more expensive than the bank, right? you can go to the bank today and probably get a loan for 5% maybe 6% I don't know what the the federal funds rate is and you'll see the bots reacted right the bots are like oh okay you guys are now charging me 10% on my my stable coin or my ETH uh maybe it's time that I kind of recalculate my position right and that's going to for that's basically forcing the players in the market to convert back and pay back their debt uh and give back some of those those coins to negotiate based on the on the borrow rate now if we were to do it a little higher. Let's take it all the way up to 20%. Right?

So now we're really like pushing pushing the envelope here. We're like saying, "Well, yeah, you can deposit your ETH, but we're going to charge you a 20% APR on your uh on your your borrow." And so at this point, the bots should be like, "Well, this is really not worth it." And you're going to see that the price we're what we're trying to do is we're trying to get the stable coin stable, right? And and this is all done like if you look at like makerdo or like a these these toggles are done usually through governance, right?

You have this kind of like thing where you want the stable coin to be stable, right? You don't want like you don't want to go to the bank and give them I don't know some gold and get back $100 and then know that like in a week from now that gold's going to be worth 50%, right? you want it to stay the same as much as possible. That's why we use stable coins. And the same goes for if it's too high.

So you can see here now we're starting to see the bots like kind of like fall in. And what you'll also see is they're getting liquidated. So here we can see that they're they have been liquidated from the system. So the bots will also go through and just liquidate themselves, I believe. Um or maybe they've just completely like pulled out, right?

They've said like, well, it's not worth it. 20% is not worth it. And so, uh, we can actually like, um, let's let me just restart this simulate script one more time because I want to show that now it's at 20%. Um, we we're probably going to see a spike that it's going to die is going to get more expensive or my USD is going to get more expensive. And so, as we do this, um, well, it should be.

That's kind of weird. It's acting up a little bit. I might have to redeploy it. Not borrowing rate to life. So, you can kind of see some of the stuff that's going on here and you can see what their collateral is and what their debt is.

Um, we can see that one of the players came in, but these ones are not really still interested in in in doing that. So, it could be because I actually set it at zero. Let's let's set it at zero again. Yeah. So, you can see when I set it to zero, then people started borrowing again.

It's dropping the price. And so, you can see that it's a sensitive kind of thing, right? Um, and in a in like a real world scenario, like the DAO has control to like control these percentages, right? And they can like have these little levers and it's probably a little out of scope of the the the the challenge that you're going to do because in the challenge, you're going to create these mechanisms and and basically learn how to do this with this engine contract. But there's always a chance that you increase the borrow rate up as much as you can, 20%.

And you also want to assume that people maybe you want to incentivize people to um stake their um tokens. You can also stake. So I when I first started, right, I had 10 ETH and then I did uh 10,ou did I get liquidated yet? I don't think so. No, I'm still good.

I'm at 163%. But if I wanted to actually earn some yield, like you want to incentivize people to um store their USD at a longer rate, um you might do what's called a savings rate. So we want to incentivize people to hold die. And so you might come in here and say, "Okay, I want to adjust the die savings rate to 4%." Like similar to what a bank would give you, or probably better than what a bank would give you.

Bank's going to give you like half a percent. And so then I can come over here and then stake some of that money. So I had $10,000, I believe. So I could do 5,000. So now I'm staking 5,000 of it.

But then I could also just go ahead and buy some more ETH as well. So, oh yeah, actually that should be good. So, now that I have this uh thing, add collateral, withdraw collateral, I could add some more of my ETH that I got. Um, actually, is there I thought there was a swap command. I guess it's not on here.

I wanted to kind of show you what the liquidation looks like, but I don't know if I'm going to be able to see it because the bots might be doing it. I think these ones were liquidated. But again, you'll see this percentage, right? You see here that we have this user and he's got this much uh total debt and he's very very much coming close. So, in a second, I might be able to liquidate him.

Okay. Anyways, let me try to lower this a little bit. When you see when the when the rate's already at 20%, it's hard to like rate it high. I guess I could just shoot it up a little bit more. Let's try that.

30%'s really high. I'm surprised I'm not getting liquidated actually. But anyway, so you'll start to use mechanisms, but you'll understand that like even this like was not enough. Like at some point when over collateralized stable coins became popular, there needed to be other mechanisms. So initially it was just ETH, right?

You would deposit ETH and you would get back a US dollar stable coin and then you would use that to like participate. Maybe you want to buy more ETH or you want to buy another token or something like that. And then eventually what they tried to do is they tried to add other tokens. So maybe you could stake uh GRT and get back uh or you could like lend GRT and that would like incentivize the network. And then that wasn't enough.

And that led to um I don't know if you guys have ever heard of the PEG stability module which is in Maker Dow which uh basically is kind of similar to what uh actual stable. So you can see finally we got the price going back up stable, right? because we were able to kind of like t toggle these levers enough and get it back to a dollar and now it's getting too high, right? It's going over. And so it's this constant game of adjusting the borrow rate, adjusting the savings rate, and kind of watching.

Now, if we since the saving rate rate is going over a dollar, we might need to bring this back down. So maybe we bring this down to 1%. And we should see that because we dropped the percent to 1%, the bots are less likely to stake their their USD. and that's going to go ahead and drop the price of of of the stable coin. Okay, so I know that was kind of a fast one and this is definitely a very complicated talk topic.

I could probably talk for like an hour and a half about this and be much more thorough. Um, but please if you can read this document if you have questions, I'm happy to answer questions now or I can answer them after. Um, and yeah, thank you so much. Yeah, question the show based on some AI or No, that would be super cool if they're AI based, but right now there's just a script in here. So, if we go to scripts and I think it's market simulator is the script.

So, it's basically like a TypeScript uh script that kind of like does some things to and by the way, that's the other thing that I forgot to mention is that the price of ETH is static at 1,800 in this scenario because we don't have like a real oracle setup. And so, you can imagine like if the price of ETH is crashing, that would drastically also change these kind of things. Um, but yeah, this is just a TypeScript script that is just simulating. And so we're saying like, oh, like five borrowers, five stakers, what the interval is, what the refresh rate is, and what the price of ETH is. That'd be a cool hackathon project.

You should do it. Yeah. I mean, yeah, I guess so. You could what you could do is you could make this uh turn this into like a Node.js server and then you could just basically like uh use the agent to call the server or something cool like that, like an API.

That would be really neat actually. Yeah. Um, but yeah, right now it's just a script. Uh, but yeah, you can see that it's it's pretty cool example. I wonder if anyone else got liquidated.

Kind of curious. Yeah, everyone got liquidated. So, but I didn't. I'm good. So, uh, any other questions?

Yeah. So, how come this is probably just me not being an expert, but how come when more people I guess more demand the USDC there's more people who want to get it? How come that causes the price to go down? Because there's too much dye in the system, right? So, it's it's like the ETH is in the maybe the ETH price is uh going up.

So, it's a bull market. So, everyone's pulling out dye and so there's this over supply of dye. It's not really like I guess they're not buying they're not buying USC, right? Well, they might be actually they might be swapping right like other tokens on a normal exchange as well. But the fact is there's just too much die in the system and that's what's causing the instability.

Yeah. Usually it's like in relation to like the price of ETH's going up. So everyone's just dropping their ETH in and then minting more. Yep. Cool.

Yeah. One more question then I gota go. Well, we do have a stable uh well, we have an overcoliz overcolaterized lending challenge that isn't necessarily public yet, but I think the GitHub is there. It's live. Yeah, I would do that challenge and that will teach you most about what like everything minus the stable coin part and then um but other than that, let me think about it and I'll get back to you.

But that's what I that's what I would suggest your first action. Yeah. Yeah. [Music]

Automatic transcript — names and jargon may be misspelled.