🌽 Over Collateralized Lending Speed Run Ethereum
BuidlGuidl Talks · 24 Jul 2025 · 8:26
Austin Griffith of BuidlGuidl walks through the over-collateralized lending challenge on Speed Run Ethereum. The tutorial shows how a money market works: a user deposits collateral, borrows another asset against it, and repays later. It explains liquidation when collateral value falls below 120 percent of the borrowed amount. The setup includes a corn token, a simple DEX for price ratios and a lending contract. A closing simulation script adds other borrowers so learners can watch loans, price swings and liquidations play out.
Speakers
Topics
From BuidlGuidl Talks, hosted by BuidlGuidl.
Transcript
Yo, what's up? I'm Austin Griffith from the Build Guild. I'm talking about speedrun Ethereum. Today, if you haven't checked out the overcolateralized lending challenge on speedrun Ethereum, you should do it today. Learn about lending. Learn how lending works. Lending borrowing liquidation key three key mechanics. Here we go. I'm going to share my screen. Check it out. Okay, here is speedrun Ethereum. Uh you can find the uh overcolateralized lending challenge uh as challenge five down toward the bottom. Uh it's also in uh GitHub and you can find it uh in our GitHub and it will be unlocked on speedrun Ethereum. So go to the collateralized lending challenge and
check it out. uh it really shows uh really how a money market works where someone can put in some collateral, get back some other asset and then use that asset however they want and then eventually pay it back. And there's this mechanism of liquidation where if the uh collateral they provided is ever worth less than 120% of what they've withdrawn, then it uh uh gets liquidated. So, uh, let's let's get into it. Uh, in the overcolateralized lending challenge, uh, you'll grab it from GitHub. Uh, you'll run yarn chain, and that will bring up your chain. Uh, you'll yarn deploy, and that will deploy your
contracts. Uh, and it's going to deploy a handful of contracts. So, what's going to happen is there's this corn token and if you think about it like a money market, like someone else has a bunch of corn and they've already loaded it up in this uh uh platform and there's even a DEX. So, there's a DEX that allows you to trade the corn and that's sort of we're not looking at these in USD prices. We're kind of thinking of it just as the ratio between corn and ETH and then there's a a lending contract and a contract to move the price. you you yarn deploy and then you yarn start and you get a really cool front end uh in in scaffold ETH right here. Okay. And then if you get into the dashboard, you
can debug the contracts, but if you get into the dashboard, you get this really nice dashboard. Uh you can see the price of corn uh relative to ETH. You can even change the price of corn relative to ETH by uh you know yoloing a bunch of either of the assets in or out of the decks. Uh, but let's get in and and do basically let's provide some collateral. So, I'm using a burner wallet here. I'm going to go to the faucet and load it up. We've got $7,000. Okay. So, I'm going to put in like a half of an ETH as collateral. And as I add that in, we'll see that show up here. So, I have a collateral of half an ETH. I haven't borrowed any corn yet. Let's go borrow like 250 corn. That's going to put us at
a 200% ratio. Remember, if we get to that 120, we can get liquidated. Uh let's go borrow that. Okay. And then uh what you'll do after you'll write this whole uh contract, but let me go show you the contract real quick. There's this nice lending contract. You'll go through all of these different functions. Uh you'll build how to add collateral, how to withdraw collateral, uh the the calculation of the ratio, right? uh the liquidation and is liquidatable. Uh being able to borrow and repay corn once you see so you put in collateral, withdraw collateral or you borrow corn or repay corn and then there's that liquidation function. So you'll build all of that into the
contract and then you can uh play with it. Here at the dashboard, we can see that I have my half ETH collateral. I've borrowed some corn. So that that 0.5 ETH is locked up, but it's still mine, right? All I got to do is bring back my corn. So, I kind of have two different assets, right? I have the ETH that's locked up and the corn that I can go play with. And this is kind of uh one of the things that set off DeFi summer back in 19. It was a a great time to be alive. Uh I'll tell you about it some other time, Sunny. But let's talk about lending, right? What happens? How does lending work? Well, we have this corn and we can do go do something with this corn. But if something happens and the corn the price of corn actually I think
we want the price of corn to go uh up, right? If the price of corn goes up, we're going to see this go down, right? And if we get to a point where the ratio gets too low, if this corn that I've borrowed gets too valuable versus the ETH that I have locked up or the ETH loses value, all of a sudden my collateral is not worth as much. And then you could liquidate that, right? And the process of liquidating it would be someone needs to have some corn, some other party, right? Let's let's do it. Let's do it. Let's do So, let's let's bring the price all the way down. And then what I'm going to do is is bring up a burner wallet. Okay, this is liquidatable. So, I'm going to bring up a burner wallet. I'll go to localhost 3000. We'll go to the dashboard. Notice
we have like a different wallet over here, right? So, this wallet is is a different dude. And what we want to do is kind of give him a bunch of money. And then we'll go just straight up buy some corn, right? We'll just swap uh you know 2 ETH or like 1.5 ETH straight up for corn, which actually is going to move the price a little bit, I bet. Yeah. Yeah. Okay. But we're good. It's still liquidatable. The ratio of this dude's loan is underwater. And so this this liquidation method um um mechanic kind of keeps the the the whole system safe, right? You never want to get below uh 100% or the actual protocol
like it has bad debt and that's not good. And you'll learn all about this in this challenge. Uh as you go through this, it explains all sorts of stuff here. It's it's uh so well put together. Shout out to the Build Guild team for putting together this challenge. and so many other great challenges on speedrunthereum.com. Uh there's even like flash loans and all sorts of cool side quests here. But let's get back to liquidating this Jabroni. This guy is underwater. Uh he's got 250 corn. He's got.5 ETH locked up.
That's uh at a bad ratio. And if it keeps going, the the whole uh protocol is going to have bad debt. So what you need is to be able to liquidate. Here we go. I'm going to hit the button. Uh, this guy has uh 884 corn. He's going to pay back the corn and and get some of the collateral back. Here we go. Liquidate. There we go. Liquidation successful. You repaid the corn and you received you received 47 ETH, right? So, so I made some money there uh by liquidating that dude and and we made that money here and I still have 634 corn and this dude uh this dude's in trouble. He's he is so that we can see
that the whole uh thing is back to 100% because basically all the corn is returned and it is it is uh there. Uh but this guy uh and this guy still has his corn but he does not have his ETH. All right, he has lost some ETH there. So he got liquidated and that mechanic is what keeps this whole protocol safe and you can build a protocol like this with not that much code. You saw you saw the code there over in cursor. Uh this whole smart contract is I mean there's a lot of there's some solidity here but it's not that bad. And here's a a really fun extra thing you can do if we go here and we run uh yarn simulate. And what this does is it brings in a whole bunch of other actors. It tops up all these
other accounts and then the market is going to uh fluctuate and these other accounts are going to take loans and uh do things with their corn and possibly be liquidatable and even liquidate each other. So there's this really cool like simulation that runs here where people will play around with corn and you can liquidate them if they go underwater and you have the ability to even adjust the the the corn ratio. So, go check it out. The collateralized lending challenge on speedrun Ethereum. Hearts, hearts, hearts. Go get it. Go learn about lending. Go to speedrun Ethereum and learn a bunch more. See you.
Overlaterized lending.
Related talks
- EigenLayer & DevRel Deep Dive with Nader Dabit - EigenLabs
- Compound: Building on the Compound Protocol
- Ethereum Dev Onboarding Session
- DeFi Quant Engineers - Patrick Collins
- 👩💻 Web2 to Web3 🚀 - Week 1 A Developer's Guide to Building on Ethereum - Day 1: 👋 Intro!
- Cyfrin Updraft: Rocket Pool rETH Integration Full Course
- Aave V3 Protocol Development
- Let's code debt! Basic Loan smart contract implementation - by Leonid Logvinov (MakerDAO)
- 7th Ethereum milano Meetup
