Building on Sui DeFi and DeepBook I Aslan Tashtanov
ETHGlobal·Mon, Feb 9, 2026, 12:00 AM
Join Aslan Tashtanov for a workshop titled "Building on Sui DeFi and DeepBook", live at HackMoney 2026! _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ *HackMoney 2026* This workshop is part of HackMoney 2026, an online hackathon held from January 30 to February 11. This async hackathon brings together the world’s most talented Web3 developers, designers, and product builders to advance the Ethereum ecosystem! Watch the full HackMoney 2026 playlist here: https://www.youtube.com/playlist?list=PLXzKMXK2aHh5VGyDLG69W0jUqNAu4xWAG _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ *Follow Sui* X: https://x.com/SuiNetwork ✅ *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
Hi everybody. I'm Aslan. I uh lead DeFi at Miston Labs. I lead the Deepbook project as well. And I'm going to do a workshop on Deepbook and how you can get started um with the Deepbook SDK and a little bit about how SUI works and um you know the differences between SUI and EVM the uh architectural differences and kind of how how you guys can start wrapping your mind around u building on suite.
I will say one thing I I believe that we has probably the best Devx ever. It's it's very simple. It's very nice. is convenient. But um the the thing that we I I'll start with is briefly the main difference between um EVM like the accountbased uh model of blockchains and the object ccentric model of SUI right um on SUI there is there are no blocks where you know you compete for transaction inclusion instead everything is an object.
The state is just a bunch of different objects living in a in a various a bunch of different places and your transaction just takes um you know some input and it mutates objects in the state. Uh so to kind of get started with with deep uh I have three um files that I'm I'm going to run through. The first one is just uh you know getting started with the Deepbook SDK and we're going to read uh the order book for SWDC. So before I get started, Deepbook is a fully onchain central limit order book. Um it has time and price matching for orders within the order book.
Now what's unique here is remember how I said each object is uh everything is an object. Well, for Deepbook, for example, the SUSDC pool is its own object. So, if you want to trade in the SUSDC pool, uh you only mutate one shared object. We call it a shared object because everybody has access to uh that object. Uh and owned objects are objects that you have access to um in your wallet and nobody else has access to it.
So the sweet USDC shared object um is what you use to trade and the best part is if you are trading in for example the deep USDC pool your transactions do not compete whatsoever with the transactions that are trading on the SW USDC pool and this is uh how we unlock parallelism and uh scalability. So uh if you think about it, you know, traditionally, for example, on Ethereum, everybody competes for one block space regardless of what you're doing uh on chain or suite. If you are mutating objects that are that don't touch each other in any way, then your transactions can be sequenced in parallel without any restrictions. Okay, so um that is a brief on how sweet and deep work here. Uh I'm going to run through u three examples and we're going to probably spend the most time on the swap one because I will go into the details of how Deepbook works um specifically the balance manager.
There's some how how that um gets set up. But first let's start with um just the uh an example where we look at the state of SUSDC. Here we will uh get the by the way workshop client is let me go into this one real quick. This is just a wrapper of the Deepbook SDK. I just added a few extra things and then I added um some functions to call the SDK underneath and then send some extra log statements.
But this client is just a wrapper of the Deepbook SDK. And uh let me double check the script here. Okay, one read. So let's see what's going to happen there. So okay, so what we did here.
Oh, by the way, I saw some people asking things in the chat. I think I'm supposed to be monitoring it. Um if I don't answer any questions like you know please I'll also have my telegram at the end so you guys can like DM me async if you uh want to okay this is all just AI conversations never mind okay so what did we do here we got the price of according to the SDK it's uh on the on the central limit order book on on chain right now it is $1.13 we also got the order book itself. So this is what the order book currently looks like.
Looks like we got you know the best ask is at 1.1313. Best is at 1.1309. So the difference is like4 cents which is which is about like like three basis points uh of spread here.
Okay. Vault balance. So the vault is the sweet USDC object itself. This is all the money that is held inside of this shared object. So all the participants that have placed orders.
So whatever is making up this order book is uh uh is is what's in this uh vault essentially. And trade params are this is the taker fee. This is the maker fee. And this is the stake required. stake required is is is um a deep book native feature where if you stake deep you get reduced taker fees as well as uh you know maker rebates.
But this is a uh a quick example of how you query the chain. Uh let me go into the workshop client to see to to actually show you guys what ends up happening. So mid price it simply goes into the inner deepbook client and gets the mid price. Now, print book what we have is get level two ticks from mid and what we put in here is 10 ticks and it essentially got the mid price and then text 10 ticks above and below. You can modify this to you know increase the depth that you want to see and we simply just printed it uh out.
vault balances similarly we're just calling the inner client and um yeah that is all for now and and the trade params it's probably actually we might have just done a direct call for trade par never mind it's right here and that's that's also a direct call okay so that's a simple you know read the chain read what's going on uh in on deep on chain right now let's go to swap before I go to swap I'm going Just quickly see if anybody has asked the question. Okay, this same order book is also used by the deep margin 2, right? Yes, exactly. So, Deepbook core is completely isolated from everything else. Okay.
It is pure is it is completely independent. Same with margin. Margin is an an independent package and uh when you borrow from the margin pools to place orders on Deepbook, you are placing orders uh the same way everybody else is including users that are using Deepbook Core directly for spot trading or aggregators that route through Deepbook. Um everybody's kind of orders are all in one place. Margin does not have its own order book or anything like that.
This is uh that's the that's the um main thing about how how Deepbook works. It is very composable and and is designed to be very modular. Uh let me see if there are any other questions. Okay, I don't I think that's all the other ones are seem like they're AI. So, let's go to swap.
Okay, this one's going to be the bigger one first. I'm going to go through So, here's what's going to happen. So, I'm going to go through the code and then we're going to run it and then we're going to uh look onchain. Uh I'm going to switch the screen share to Chrome so we'll see exactly what transactions were produced and then we'll do a little bit of a sui vision uh thing to understand how the explorer works. So I have uh my private key in the end file and we're setting everything to mainet and we're setting up the private key.
Uh and the first thing that we're going to do is check the balances of my address. Like what money do I have in my wallet generally right now? Here's the second step to actually interact with Deepbook. What you need to do is create a a an object called a balance manager. Okay?
And I I think of this as like an account that you create on you know like a different exchange like on hyperlquid you create an account and then you deposit money into that account and then you go trade right this is not the same as unis swap where you don't create any account it just you know you just swap directly uh but in this one you do create an account but the key here is the account is super composable so actually if you want the direct swap experience you can generate a balance manager on the fly deposit money swap and then destroy the balance manager on your way out. So the full unis swap experience is also uh maintained here. But for this example, we're going to create a balance manager and then we do a little bit of u you know parsing of the transaction outputs here because what we're looking for is uh create results.object changes.find.
Okay, so we're looking for in the results in the transaction that's returned, we're looking for an object that was mutated and it has a tag of created. So a new object is being created on the blockchain. And if it's the type of balance manager, go ahead and extract the ID of that object that was created. Now when this balance manager gets created, it becomes a shared object. So everybody has access to it.
But the uh you know for for on suite what you can do is just incorporate uh you know gating for specific actions uh within the balance manager. So if you submit funds into this balance manager, anybody can query and see how much money you have in there, but nobody can actually use your balance manager because there's a capability that restricts only the uh creator of this balance manager balance manager to actually place orders with it. So we create the balance manager and what we have to do then is uh recreate the client with the balance manager as uh one of the um inputs. And then we're going to go into depositing money into the balance manager. And once we have money in the balance manager, we can actually place a market order, which is what we're going to do right here.
We're going to buy one sweep with USDC and that's going to be all. Okay, so we're going to run through um I know there was a a lot covered there, but just again real quick, we're going to check how much money we have in our wallet. We're going to create a balance manager. We're going to deposit 5 USDC and 10 deep into the balance manager. And then we're going to execute a market order.
Now I'm going to show you actually. Okay. So let's let's do this sequentially here. First I'm going to run swap and let's see what happens and check my wallet. Created a balance manager.
Okay. I think I might have deposited too much money into the previous balance managers. Let's go ahead and drop. Let me actually check how much money is in the wallet. We might have been uh going too quickly here.
Okay, what we're going to do is set this one to five and Okay, let's try it again. In practice, you would just create one balance manager. You don't have to recreate new ones every single time, but I I'm just trying to run this example end to end here. Okay, there we go. We deposited 5 USDC and 10 deep and uh our balance after is now 5 USDC and 10 deep.
And then we swapped and our balance after becomes 1 USDC and uh once week 3.87 USDC and 9.996D. Okay. Uh we're going to go into this uh transaction digest in a bit to look at what actually happened uh on chain.
But before we do that, let's just uh do a quick recap. So these are raw numbers. Um I should have uh put them in in decimal form. But what we ended up doing here is okay, we created the balance manager. We and then we recreated the client with this balance manager.
We deposited 5 USDC and 10 deep. Now the 10de deposit here is simply because the uh Deepbook protocol takes trading fees in two forms. either the input token or deep. So you can actually use deep to pay for your trading fees and there is a uh uh an incentive to do that. So you you pay less trading fees when you use deep and uh slightly more when you use the input token.
So we didn't necessarily have to deposit the 10 deep here. Um, and it could have just used the 5 USDC directly uh and it would just like charge us a little bit more USDC uh to to do the swap. And finally, yeah, the uh the trans transaction digest has been produced. And what I'm going to do now is I'm going to share my Chrome screen. Okay.
Question. Can you explain the difference between deep and sweet? Are both of them coin type T? Yes, all coins are of type T. The type T is like a generic.
Uh so if you have a function in your move smart contract that takes in a type T, actually I can show you an example. Then that smart contract can take any coin type. Okay? But you'll have to do a little some smart things with it. Let me show you an example of what I mean.
Let's go to Deepbook sources balance manager. Okay. So, this is a smart contract for the balance manager itself, right? Uh and what what what we'll notice is let me go to the deposit function. Okay, this is new.
This is what we actually call to create a balance manager and the where's the deposit? Okay, and this is balance. This is what we actually use to query the balance. See like this it we're using type T here to to query balances. And if we just pass in the type of the coin that we want to query, it'll figure out on its own what number to return.
Uh let me just show you guys the supply. Okay, deposit. Okay, there we go. Deposit. We're depositing any coin.
So see there is no distinction here between is are we depositing deposit depositing sweet deep USDC. We take any coin with any type and all that we do is just dreference the type and just create a new key in the in the bag object within the balance manager and just have that point to the balance itself. So the balance manager is totally generic. It it has no restriction on what kind of coins you can deposit or or or what you can do. So that is um how how this works.
If you have coded in Rust then this will feel very familiar. Great. Let's go ahead and jump to the Chrome browser. Okay. Hopefully this is Hang.
Let me zoom in a little bit. Okay. So, this was that swap from earlier where we swapped USDC to Suite. And uh what I do when I'm on Sweet Vision is the first thing that I do, I just go and look at the events. And there's a few events that are emitted here.
The important ones are this order info object and this has all the details about you know what happened during the full entire process of uh this action. Then there's this order filled event that has like some details on the fill itself. This is what we that this is probably the most important event. This is what we use to actually populate a lot of the dashboards and and charts and this is what we use for data tracking. Um and there there actually two order fill events interestingly right because um we ended up filling multiple orders that were available.
So there there were two makers that we ended up trading trading against. Um cool there's this EWMA thing but like that is more for uh an an unrelated feature that Deepbook has. And um here the transaction inputs. These actually um this show what happened under the hood. When we use this SDK, it combines two transactions into one.
When we for example when we place this order, yes, you can use sweet vision on testn net. Um, and if you actually set the, let me see here. Let me show you. If you set the trader, if you set the environment to test net, it'll interact with the test net contracts. So, you'll be able to see what's happening on testn net uh instead of mainet.
Um, I just did mainet because it's more reliable and and and less hiccups u this situation. But let me let me point out something interesting here. Under the hood, the SDK actually combines two transactions into one. This is what we call uh a PTB what what did PTB stand for? Anyways, uh PTB is basically one atomic transaction that you uh you just concatenate a bunch of different transactions into one.
In the EVM world, this exists, but what you have to do is you actually have to develop your own custom smart contract that does the different calls. So, let's say you want to, you know, swap on unis swap take the output or or let me let me give a better example. Actually, I'm going to uh show this by going to uh example three here. Hold on one second. Programmable transaction block.
Thank you. I'm going to go into the the flash loan example to uh show you guys how the PTBS work. So flash loans is is a feature that Deepbook has and it is designed in a very interesting way. So you guys remember in how in the first example we had this vault balances. So you would see all of the money that's inside of a one pool.
What flash loans does is if let's say the SUSDC pool has let's say you know 10 million sui then what you can do is go in and flash borrow let's say a th000 sui do whatever you want with it within your transaction but at the end you return the flash loan before the transaction completes. So, it has to be atomic. Now, what's really cool about how flash loans work, I'm going to kind of uh go into details here for a second. Let's see here. Okay.
Borrow flash loan base. Check out what happens. So, you go into the vault. Uh you you specify the quantity that you want to borrow and we just give you that coin. Here's the coin that you wanted.
This is like real money. Here's that money. Um, and you can do whatever you want with it. The other thing that we give you is this thing called a flash loan object. Now, the thing with this object is, uh, you'll notice that this uh, oh, sorry, the flash loan borrowed object.
Uh, this is actually just for the event. Forget about that one. This is what what's important. Notice how these other strcts have attributes. This one has store.
This one has copy, drop, um the there's also one that's that has key. Balance manager has key. Those attributes tell the uh object what it is capable of and what it can do. When an object has no attributes, then that object cannot be alive on its own. It has to be consumed.
Okay. Um, so what ends up happening is this flash loan object that we return from the borrow flash loan base call this becomes a hot potato. Okay. If the return flash loan base is not called with the with that hot potato as input, then the whole transaction fails because this hot potato cannot exist on its own. It has to be destroyed by the end of the transaction.
And you'll see that we're destroying it here. So what ends up happening is the only way you can call borrow flash loan base is if at the end of your transaction you also call return flash loan base and the flash loan itself also has you know exactly like what pool did you borrow from how much and the type of the thing that you borrowed and then there's a validation that the coin that you're returning is matches this exactly and that's the only way that you can then destroy the flash loan uh object here. Okay, so I am just going to run through the third example and actually we're not really going to see any interesting results but what's more important is what what's here. Uh, and let me just I know I know we're at time here, but here's the example of how we are combining different transactions in a PTB without um having to write any smart custom smart contracts. We can do this directly through the uh suite client SDK.
We take a transaction, we do tx.add and we append this transaction to borrow. So, we're borrowing some deep. In this case, we're going to borrow one deep from the deep sweep poolool. And then we're concatenating that with another transaction where we return that.
And and you'll see that we're returning the same flash loan object here. And then uh we're doing some transfer objects. And then that's it. We are done. And if we look at the PX digest, I'm going to switch over to Chrome one last time here.
We've got the uh flash loan event here, but more importantly, check this out. So, we have we have four transactions that we combined that we concatenated into one atomic transaction. And what's very cool here and and I don't have an example of this right now. What you can do is with the CLI directly, with the client directly, you can uh create one transaction that places 10 orders on the ask side and 10 orders on the bid side automically with with just one snapshot. Like it's just one transaction and you don't pay them uh increased gas fees.
And this is the reason why deepbook uh a fully on chain central limit order work order book actually works on suite because of these capabilities parallelization with the shared objects uh PTB so you can so you don't have to like place and cancel orders one by one um and just low gas fees and high uh uh very fast finality and and all that good stuff. But yeah, that's it on my side. I know we're at time. Let's see here. Yeah, we have we can we can take a few minutes.
Okay. Lauren, if anyone has any final questions.
Yes, please. Um, if anybody has any other questions, let me know. Also, I I'll I'll drop my Telegram here. So, you can hit me up on Telegram as well um for any questions. Uh but yeah, I I'll I'll I'll give it a little bit.
Yeah. And also um remember everyone that this um is recorded and it'll be on the YouTube, the East Global YouTube.
Ah, there's questions from
of course. Yes,
all questions are allowed. anything deep book or su or defi you know all what kind of apps are we expecting for the hack okay uh a super it's easy one is like a front end for example like a mobile trading front end would be cool um anything that integrates margin would be cool something that's that's a maybe a little bit harder is like a marketmaking bot For example, if you if you figure out how to, you know, reduce the barrier to entry to market making, that would be interesting. Something that would be uh a little bit new potentially is if uh anybody figures out how to make it so, you know, how to skillify the Deepbook stuff and make it so I can access, you know, do trades on Deepbook directly through like my claw terminal or something through like a skill. That would be something interesting to explore. I don't even know if that's like a if that's a real thing.
Um, but uh yeah, ideas like that. I I don't know if that that's like too vague, but happy to like hash out and brainstorm uh if you guys want to do that more. So the the whole leverage thing. Okay. So for margin we have isolated margin.
So you have to borrow for example you borrow USDC from a USDC pool to place long orders in the sui deep or wall markets and then you borrow sui from the sui pool to place short orders uh on on in the USDC market for example. So when you say are all these done in on the same pool underneath, I'm not sure if you're asking about the actual liquidity pool where there are trades happening, but yes, like if you borrow USDC, you end up just placing an order in the regular order book uh that deep book has. You don't place it in a different order book. Oh, how how to pass arbitrary data between EVM chains. This is a hard one and uh I'll have to pull in some other folks to answer answer that question like Zcashbot is on sweet.
There's not really anything uh like that yet there. I know there's some work being done on on on that topic but I think that would be a cool one to have. anything related to privacy, anything uh that you want to build related to like private transactions or swaps or anything like that would be um uh awesome to see. But we can actually leverage some of the other infrastructure like uh Nautilus and Seal to uh to do some of the stuff if we need to hide uh certain operations. Yeah.
So porno the actual liquidity pool is just one pool. One pool powers everything. Spot trading and margin trading uh and everything. Yes.
Automatic transcript — names and jargon may be misspelled.