DELV 🛠0 to Hyperdrive in 30 minutes - ETHGlobal San Francisco
ETHGlobal·Thu, Oct 9, 2025, 12:00 AM
Join DELV team in this workshop and learn all about Hyperdrive in 3 different ways! Smart contracts, front-end, and python cli. Delv into the the next gen Fixed Rate AMM at your own pace. This workshop anticipates ETHGlobal San Francisco, a 3-day hackathon happening from October 18 to 20, 2024, 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! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com DELV: https://delv.tech/
Transcript
hey EF um this is Alex tol um I'm the lead protocol engineer at delve and I'm here today to talk to about hyperdrive and also walk you through um our solidity starter repo so um hyperdrive is the product that we've been spending the last two years working on at delve um it's an automated Market maker that enables fixed rates to be built on top of arbitrary yield sources so I realize that's a lot of buzzwords um but just to break it down a little bit um what hyperdrive basically enables you to do is it enables you to uh provide liquidity just like with other amm uh and then by providing liquidity you allow traders to open Longs and shorts uh a long position is basically the same as just purchasing a fixed rate of return for a certain amount of time so when you buy a uh really you're just getting locked into a particular fixed rate so what this might look like is spending a dollar to get a15 six months from now uh buying a short is the opposite so when you purchase a short you're paying a fixed rate of return to the market uh and you're receiving uh a concentrated variable rate position uh in return um and so as Longs and shorts open uh and close positions it moves the fixed rate in the market uh and LPS earned fees um for providing the liquidity that facilitates this volume um unlike other fixed rate amms hyperdrive supports uh terms on demand which means that whenever you come to hyperdrive and open a position um you actually receive the full uh full position duration so if you come to hyperdrive today and open along uh you'll get the full six-month term uh if you come back in six months and open another long you'll get full six months as well so in the past most other uh fixed rate protocols would only give you um the amount of time remaining in their term so you know what might start as a six-month pool becomes a three-month pool and then a zero month pool um so that's basically the gist of hyperdrive um to kind of help you get acquainted with how to build on hyperdrive we also created a solidity starter repo um which I'll show you how to use so um you can find this just by looking up our hyperdrive solidity starter repo um we'll we'll share this um you know as part of the notes for this virtual Workshop um and we're also going to be at the hackathon so if you have any questions feel free to Ping the delve team uh or also um feel free to speak with us in person again my name is Alex so you can always ask for me um but our hyperdrive solidity starter repo um it's pretty simple so here's the read me basically it shows you how to start building on top of the hyperdrive protocol uh and it includes like a hello world example that just shows you the the most basic way to interact with hyperdrive um so it's a pretty normal uh Foundry repo so the first thing that you're going to do once you uh get clone this is you're going to do a forge install so this is going to download all the dependencies um it won't look like this for you because um I've already run this before um so for you it's actually going to download some dependencies and you can see those dependencies if you go into the uh lib directory so you can see that we have Forge STD hyperdrive and the opens Upland contracts um if you look in The Foundry toml you can see the remappings that we've used so um the most important one to to point out is that we're remapping hyperdrive to lib hyperdrive um you can look inside the hyperdrive repo just to find files and and look around um just by going into lib hyperdrive and here you can see that most of our contracts live in the contracts directory and all of our production contracts live in contracts SRC we also have some helpful Tools in test utils that you might want to play around with so um using these dependencies um we built a hello world contract which you can find in the SRC directory um so what this hello world contract basically does is it just opens a long position on an existing hyperdrive pool um so you can see that we're importing the I hyperdrive interface right here um from hyperdrive contracts SRC uh so the first thing that you know this contract does is it has a Constructor which sets up the hyperdrive immutable um and this is going to be used to actually open the long then it has one function called hello World um which will actually open this long so whenever you open a long on hyperdrive uh you need to actually send money to hyperdrive so hyperdrive has both a a base token which is basically like the the the base asset um so this could be usdc or D or eth or a different kind of asset um but this is specified by hyperdrives based token um so you can call this getter to get That Base token um it also has a vault shares token so that would be like hyperdrive Vault shares token uh and so for example if the yield Source underlying hyperdrive is a UR Vault uh and the UR Vault accepts usdc usdc would be the base token and the UR Vault token would be the Vault shares token so different hyperdrive pools accept uh different assets and you can look at that on a Case by case base um but in this case we're just going to kind of assume that this is a this is a usdc yield source so our base amount is going to be $100 um it's it's E18 because there's 18 decimals for this base token um and then because this contract is going to be opening the long we're going to transfer fun funds from the message. sender into this contract uh and then we're going to approve hyperdrive to spend the funds that we just transferred into this contract now we're going to open the long um so if you if you read through the I hyperdrive interface um you'll see what these different parameters do um you can also ask me I'm happy to elaborate um over the course of the the hackthon but the gist is um the first entry this is like the amount of money that you're going to be paying so could also say this is like the you know base paid um this is the minimum output that you expect so you know if hyperdrive prices out your purchase and you end up with less than this amount um it's going to revert so this is a slippage c um and then these other parameters are specifying things like the minimum Vault share price um which asset you want to use when you're depositing where you want the to go uh and any extra data that should be submitted so like I said um feel free to ask me questions if you have um if you have any about the details with this um but this hello world should get you set up for how to use um you know pools like the S di pool uh and then finally once we've opened the long we're going to log some data about maturity time the long amount and the realized rate okay so uh in addition to this hello world contract we've also written a hello world test which is in test world. T.O um this test sets up a main net fork and actually just calls hello world so um you know if you want to get a repo setup with a main net Fork you can use this as just an example of how to do that um in order for this to work you're going to need to supply the main net RPC URL so um in the readme it talks about how you need to fill out this env. template and copy this into aend file um so make sure you do that first before running the test or else it won't run but yeah once you've done all of that you can run Forge test and I like to do a-v which is going to make sure that your console output is actually loged and then we can run it and then you'll see that this is the maturity time of our long so this is basically when the long actually matures and when uh the user can claim their funds uh the long amount is 102 bonds 10293 uh and then this was their realized rate of return um so thanks for following along and uh I'm going to pass it to Danny doot our lead front end engineer to talk about um how you can get started building with um our frontend tools hi everyone my name is Danny I am the lead front-end developer here at delve and today I'm going to walk you through the hyperdrive starter monor repo this is a boilerplate project that we've created for you to Kickstart your project uh you're not obligated to use it but uh this could maybe give you a head start on building on top of hyperdrive this is a turbo repo project um so inside you'll find that there's an apps and a packages folder and we've gone ahead and created a very basic front end and an empty typescript package in case you want to build uh some tooling or an SDK on top of hyperdrive um there's a space in there for you to do that so to walk you through the repo um I've gone ahead and cloned it down and I've run yarn in order to install all the uh dependencies and to walk you through through the packages real quick we have this core package um and like I mentioned this is an empty typescript package where you can uh add any sort of features or functions that you might want to export and then use in your front end um so as it states here um you can use this package for any shared logic you might want to use across the monor repo or if you want to deploy something to npm um here's a a simple basic typescript project for you uh to start with um the other uh area in this monor repo is under the apps folder um and here we've got a very simple front end um that I can show you right now what that looks like so when you spin up the monor repo front end uh this is the app that we've got created for you uh it shows a couple of little areas of our uh SDK and app config putting them on the screen you can see that we're showing you the number of pools that hyperdrive has deployed um telling you how many chains and which chains uh hyperdrive is deployed to um also you know pointing out the uh current tvl of the first pool on hyperdrive which is a main net Lio Ste pool as well as uh what the dollar value is of the tvl um so this is just a simple example um let's go ahead and jump back into the code and I'll walk you through this front end and if I bump the size up here maybe you'll be able to see that a little bit better um so here in the front end uh we'll start with the package Json just a uh take a look at some of the dependencies that we've got um the first one here is a math library that we'll see uh in the code here momentarily and then you'll see some stuff that should look pretty familiar if you've worked with other boilerplate repos like scaffold e so react query is a common dependency that you'll find uh in any project that uses wagi um as well as a rainbow kit for a wallet uh a wallet Library uh we use Daisy UI um here at delve uh this is a very simple Tailwind based component library of course you're not obligated to use it uh you could swap that out for any other component Library you choose as well as uh the recent versions of VM and wagm just to get you going uh with some standard tooling beyond that um because this is a Vite project or vit um uh it does not come with its own router so we went ahead and added tanack router uh as the routing library in this uh monor repo um of again you're welcome to swap that out for any other router that you prefer um so let's go ahead and take a look at the source folder here and we can jump into the UI folder and talk a little bit about the structure of this front end um we have a single route here uh under the root um where we uh create the root route here's our little Outlet so any of the uh additional routes you make can be rendered through there uh the index route uh being the first and only route in the project at the moment which renders the home view component um and uh above all of the routing we have our main.
TSX where you'll see some pretty common uh wag me uh query client from react query as well as rainbow kit which wrap the app component um the math library that I talked about earlier also uh is built on wum so we go ahead and instantiate that and then anywhere we want to use this math Library we can import the uh the dependencies we need um knowing that it's already been initialized so let's go ahead and take a look at the home view real quick uh the home view is the only route like I mentioned uh which is going to render uh all of the stuff you saw in the browser just a second ago um and I want to talk a little bit now about the app config package and our hyperdrive SDK package um so real quickly the app conf big package uh as just sort of a standard practice in web 3 anytime you have a bunch of static uh information like metadata about tokens like decimal name symbol icon URL those types of things um we've gone ahead and capture those in a package that we call app config so if you're looking for any sort of information that's uh static you'll be able to grab it off of the app config and you won't need to call the smart contract to get those things um again this is just another thing available to you you don't have to use it in your project uh but I wanted to just U make this available uh for for folks who are interested so um you can read the comments above each of these lines uh when you clone the repo uh it'll uh it'll be here for you um but as you can see we go ahead and import the mainnet app config and then uh we pull off the hyper drives uh however there's a bunch of other goodies in here that you could explore like the tokens um uh so this would be things like eth and usdc and all the other uh tokens uh available in hyperdrive along with their static metadata um so for the hyperdrives that we've got uh we can then uh loop over the hyperdrives and grab the chain that it's deployed to and then using a simple JavaScript set we can use that to just get the list of unique chains um and uh just continue parsing data out of the app config as we need it um so going off of the first hyperdrive in the list we can extract the base token for this hyperdrive um using this find base token selector and again this comes uh from the app config package um and we've got a couple of other selectors available to you um that you can explore uh that are also documented in this package um so this is on npm if you don't want to use this boilerplate you're welcome to install this as a package in your own project um and in the readme we document what uh what all is in here um so that's the base token uh and then any other realtime information that you might want to get from the smart contract uh you can grab that using uh use Query as well as the hyperdrive SDK so we've got one example here of grabbing the tvl of the very first hyperdrive in the list um and let's go ahead and take a look real quick at what this hook looks like um so here under hyperdrive we have used tvl and this is a really simple hook the uh read hyperdrive is our SDK instance and we have hooks for read hyperdrive and read write hyperdrive in the event that you want to make a transaction you'll use read write hyperdrive if you just want to grab some uh some readon data you can simply use the read hyperdrive and this means you'll be able to build a front end that doesn't require you to have your wallet connected in order to Simply read from the chain um so in this example the read hyperdrive that we get is an instance of read hyperdrive and then we e we can easily just use use Query from react query to make this call and get back a promise of in this case the total value present in the pool um and so this will return a promise of a bigant and using the use Query hook the data and the status Fields um can be returned from the hook and then used in our react component so if we come back here to our home view uh that's how you can interact with the SDK um um and then other stuff we've got here is a used token Fiat price again this is just for an example um and if we go to definition on this one you'll see that it's simply another use Query hook where the query function is making a call to uh defi llama to get a token price um so let's go ahead and go back to our home view here and just to summarize um one last thing to point out that I mentioned with the math library is if you get uh if you get to the point where you're using big and then you need to do different math operators on them that's where this fix Point Library really shines so in this example we're using the fixo library to take our big in which is just a tvl number um knowing that the first hyperdrive here is the Ste hyperdrive then we know that the tvl here is priced in terms of eth and eth is an 18 decimal number however if we wanted to show the price of eth uh as you can see here we have this formatted to only four decimal places um just for the sake of display purposes and so our our uh app config when we grabbed the base token one of the bits of metadata on this base token is a places field and this will tell you how many places are relevant to show for display purposes so using our fixo library we can simply call format and say we want to display uh a certain number of decimals after the decimal point uh and that'll be uh we can find that by looking it up in the app config uh for what the number of display places is relevant for this token uh if you were to take a look at other hyperdrives like for example a usdc hyperdrive the base tokens places value would probably be like two places so you can use this to kind of show a better display uh better rounding and better display value for different uh amounts um the other thing that this math Library can do for you is of course uh standard math operations so in order to show the Fiat value of how much e is in this pool um you can take your tvl number wrap it and fixed multiply it by the Fiat price and then call your formatter to format it in this case to Dollars although of course we also have format currency options in case you want to expand to other currencies um so to summarize here just with what we've got in the jsx now we have our connect button which is simply a rainbow kit uh dependency and then you can see here we are console log or not console logging we are rendering the hyperdrives list to tell you how many pools have been deployed we can extract the unique chains and look at the number of unique chains that are on this set to get the uh definitive number of chains we've deployed to um we can also join the unique chains by name and uh display that and then uh just kind of standard react uh react pattern here um we can display uh the first pool the name of the first pool we grab the metadata from that uh and display it we can grab the chain uh of that hyperdrive looking up the chain metadata which is this chain config and grab the name off of that to display and then we can also display our formatted tvl base token symbol and that formatted Fiat value that we calculated above um so that's it uh we look forward to seeing what you build uh again my name is Danny come find us at the booth and happy hacking hey y'all my name is Dylan and I'm going to help you get started with using Agent Zero to programmatically execute hyperdrive trades on using python agent AG Z is a free open source package that we've developed uh my team at delve uh to facilitate automated trading and data science uh on hyperdrive markets uh so here we're just going to run through the code to install it just to show you that it can be installed easily via pip we're using UV but you can feel free to use whatever you want uh and then I already have a file in here demo. py um so I'm just going to open that up in vs code and I've preloaded some of the Imports uh the primary endpoints are chain and hyperdrive there are local versions of these uh that you can use if you want to do simulated markets but we want to connect remotely I already have my RPC URI set up this is pointing to a local chain uh that's running on my computer but you can point it to your Anvil instance or whatever um so we need to instantiate the chain in hyperdrive objects that's pretty straightforward uh so this is now a chain object it has some things like block time and block number uh it's pointing to that remote chain and then the hyperdrive object uh has a whole bunch of different functions you can call um that you can see in our docs um we also need to make an agent um and in order to do that we need to make them a private key um so we can do Agent Zero equals chain init agent uh and you can see here the first argument is private key I'm just going to make a private key real quick uh and then pool we want it to be hyperdrive and then let's give a name um okay uh and then we want to give them some money so agent z. add funds we use uh fix Point arithmetic for this we also wrote this fixo library that you can check out uh that emulates the fixo used in solidity um and then uh yeah let's execute some trades so I'm going to separate this and then set max approval we'll just do that right at the bat let it approve everything and then let's open a long and open a short so open long event equals agent 0. open long uh you can see it needs a base amount let's do 100 uh open short event equals agent z. open short this wants a bond amount right how many bonds are you opening of short for let's do 10 uh and then the last thing we want to do is just see all of our trades that exist um so we can do agent positions equals agent z.
git positions um then we can tell that to do pool filter is the hyperdrive pool uh and that's it now let's run these so right now it's connecting and setting up a database it fills that database automatically with uh information from the chain now we have our agent positions uh which is this nice little table it's a panda data comes out as a pandas data frame uh that has uh the name and address and the trade type and the amount and the maturity time everything you need if you're interested in doing more stuff I recommend you check out our readme um so this is just from the piy page you can also see it on our GitHub repo um we have a bit of a preamble there explaining what Agent Zero and hyperdrive are install instructions there's also more advanced install instructions in install. MD uh and then some cool examples uh here's how you can execute trades in a stimulated blockchain environment you can also do this with custom policies that automatically choose trade actions you can query all of your existing positions uh so you can get all that locally uh if you want to do some data science on that you can also do things like automating with drawing mature positions once they've matured you can just pull the money out automatically okay well that's all for now uh please let us know if you have any questions you can reach out on our Discord and happy hacking
Automatic transcript — names and jargon may be misspelled.