#28. A new kind of decentralize exchange.

July 24, 2023 Tarun, Matt Season 3 Episode 28
#28. A new kind of decentralize exchange.
More Info
#28. A new kind of decentralize exchange.
Jul 24, 2023 Season 3 Episode 28
Tarun, Matt

Imagine stepping into a world where the intricate dance of token swaps and liquidity provisions comes alive, all within the innovative sphere of the Chia blockchain. That's precisely what Yak, the mastermind and architect of TibetSwap, introduces us to. Get ready to have your mind expanded as we discuss the uniqueness of TibetSwap's approach to decentralized exchanges, highlighting how it capitalizes on Chia's UTXO-based system to introduce new possibilities for token exchanges and liquidity - a true game-changer for the Chia community and a nod to the future of finance.

Support the Show.

Buidl +
Help us continue making great content for listeners everywhere.
Starting at $3/month
Show Notes Transcript Chapter Markers

Imagine stepping into a world where the intricate dance of token swaps and liquidity provisions comes alive, all within the innovative sphere of the Chia blockchain. That's precisely what Yak, the mastermind and architect of TibetSwap, introduces us to. Get ready to have your mind expanded as we discuss the uniqueness of TibetSwap's approach to decentralized exchanges, highlighting how it capitalizes on Chia's UTXO-based system to introduce new possibilities for token exchanges and liquidity - a true game-changer for the Chia community and a nod to the future of finance.

Support the Show.

Host 00:14
Hello friends, welcome to the season 3 of Biddle Podcast. I am your host, tarun. Today we have a young prodigy by the name of Yak. So Yak has built something really cool called Tibet Swap. Tibet Swap is the first automated market maker, kind of like Uniswap, but for Chia blockchain. We will get into the details of that in a bit after these messages.

Podcasting might look easy, but it is a tremendous amount of work behind the screens, from scripting to recording to editing, publishing, not to mention promoting each episode and also all the coordination involved. We need the support of our listeners and community to keep going. If you enjoy listening to this episode and our previous episodes, one of the best ways to support the show is to become our monthly Patreon member. There are many ways you can support Biddle Crypto Podcast Beyond becoming a Patreon member. The best way to help us grow is also to share among friends, write a review on Apple, spotify or Google Podcast. We also have plans in the future to have a merch store, a merchandise store coming soon for some cool Biddle Crypto swag. Your support will enable us to continue putting in the hours, keep the show honest and authentic. And now let's go talk to Yag from TibetSwap. Enjoy. 

Yak  02:37
Thank you for having me here. 

Host 02:41
Welcome to TibetSwap. Before we go into more detail, tell me about yourself. How did you get into this ecosystem and what is TibetSwap all about? 

Yak 02:57
A little bit about myself. I just finished my first year at Minerva University. I've studied in San Francisco in the past year, although I'm from Romania. Tibetswap is basically an AMM for the CHAP blockchain. It's a kind of decentralized exchange where basically, you have a program that's trading assets, some users give to it according to some rules, and TibetSwap's main assumption is that it basically functions on pairs. So you have, let's say, a chia pepe pear, and its assumption is that its reserves are always equal in value. So if you want to put in some pepe to keep the rule, which is the coradoc formula equal, you put something in and you get the other asset out. And because this program is running on chain on its own, we don't have servers running it in the background. It's an on chain program. Other people can verify the code and also give more assets to it in a process called providing liquidity, and for that they receive exchange fees in return. 

Host 04:14
Okay, so you mentioned this is a program that's on chain, so from my understanding, is Uniswap, which is the decentralized exchange for Ethereum. Is that something similar, or here you have done something different? 

Yak 04:32
Yes, so it's very similar in logic to Uniswap on run ahead because, for example, the formula Uniswap implemented for 20 to him, uniswap is also running on chain and decentralized. But then you get into how the chia blockchain works, because Ethereum is based on the account model and you have chia where you have smart coins, programable coins. 

Host 04:58
It's super interesting. So, yes, so in in chia. From my previous understanding it's it's a UTXO based model, like Bitcoin, and everything is a coin inside of chia, right? So what kind of powers that give you, these primitives gives you to creating this decentralized network, like if everything is a coin. What does that even mean? What expressiveness that gives you as a programmer. 

Yak  05:26
Yeah. So on a QEM, you basically have two kinds of accounts. It's user accounts and then you have smart contracts that run by code deployed to them. On QEM, you only have coins logged by puzzles. So, for example, you don't really own a coin. There's a coin on the blockchain that can only be spent with your signature. So this little completely new design of even an AMM, right. So on a QEM, you have a contract you can have, like you saw before, shows you can have unlimited pools in a contract. Well, on Chia, just to have that pair, right, if you want the Chia Dutch coin pair and Dutch coin is assuming Dutch coin is an asset you have the way I designed it. You have a coin that's linked to the coin that's linked to logic and then to other coins that are handling the reserves. So it's not a contract, it's a bunch of coins being linked together and spent together to make a swap happen. 

Host 06:33
Oh, that's amazing. I'm still trying to grow it and get my mind around it. So, okay, Yak, that's great. Can you also walk me through like a use case, like how people outside of Chia community and in Chia community could use Tibet Swap? And right now we do need these sort of decentralized solutions exchanges with all the, I would say, the buzz around all the centralized exchanges. So, yeah, could you explain me, elaborate a bit more on how would somebody go about using these decentralized exchanges? 

Yak 07:19
Yeah. So, as the name suggests, they have one main purpose, which is exchanging tokens. So you go to Tibet Swap if you want to change, say, chia to a token, and that's something you can. If you go to Tibet Swap to swap a token to Chia or Chia to token, and that is main purpose. Again, if it's fully on chain, you choose the rules at the start and then you just release it. So for the, I launched it because it's decentralized and trustless. I don't have any extra privileges that the user doesn't have. The protocol is launched. No one can modify it more than anyone else you can. It follows a set rule of procedures and that's why people trust us with their money. There's, I think, $80,000 currently in the protocol. It could be much more. Uniswap has billions, if not trillions, and it's only because anyone can audit In terms of accessing it. 

The main application lives on chain, but there needs to be a wrapper, and how I build this is there's a CLI, which is a Python program. By connecting to your local full node and your local wallet, you can interact with the best of directly on chain, no need to visit any site. You just input something and the swap will happen. And also for users that don't that want a better user experience. We also have a site. It's tbatsupio. You can go there. Choose from a list of tokens. You can see the name of the token, for example, which the CLI doesn't show you. The CLI is for advanced users. Yeah, you can connect most wallets. We have Chia wallet integration coming soon. You can connect Gobi and Hugi. We plan to support all wallets that allow the apps to connect to them and you can also upload offers made by a wallet. That's not just it. 

Host 09:36
Okay, so by Chia wallet you meant the native wallet that's in the Chia GUI, basically what users when they run their full nodes or run their wallets right. So you will see some integration in the future for Chia native wallet as well. So that's interesting. 

Yak 09:54
Yeah, so we are in the process of testing it and releasing it hopefully this week. But the thing is that with QBAT, with the UI and with the CLI, you just create an offer and then the AMM will accept it. So you can basically use any wallet capable of supporting offers. It's just that if they don't support a way of our site telling it what amounts the offer needs to have, then you have to create the offer manually. So, for example, I want to swap one Chia to Dutchcoin. The site would show me the amount and say, hey, paste in an offer giving one Chia and requesting to Dutchcoin. Well, once the Chia wallet integration is complete, you'll be able to connect your Chia wallet and you'll just approve a request to create the offer. So you'll be able to more easily create a trade and it will also be way faster Fantastic. 

Host 10:52
Switching gears. First of all, I want to know since what age did you start coding? Actually, I have no idea of how young developer you are. I think you are still like a seems like a child prodigy for learning Chia Lisp and coding all of that. So how did you get into Chia and Chia Lisp? 

Yak 11:17
Thanks, so I think I started coding let me think, years ago. I started by trying out competitive programming. I did that through middle school, but it wasn't really for me. So when I started high school, I also found cybersecurity. There are these contests called Capture the Flag and basically what you learn in there is learning things very quickly and learning all aspects of a system, because to break into it you need to know it as better than it's creator. 

Yak 11:59
And yeah, near the end of high school I found Chia, just because it was actually very random. Like I saw this news article about the crypto you mine with spare hardware space. My dad had a lot of spare hardware space, so I just gave it a try. And then and I remember seeing the serious labs hackathon I knew that you could interior exchange currencies between blockchains in a trustless way. So I said, hey, why don't I do that for Chia and this forks? Because a lot of forks are bring at that time. And then I even expanded the project to Ethereum and that was Yakuswap, my first Chia project. It helped to change Chia with his forks and with Ethereum, much like offers do, except it's crossed and trustless. What else? Yeah. 

Yak 13:02
So after that, the unfortunate incident with the serious labs hackathon happened. We got second place, but they didn't want to offer the first prize. It was a strange situation, but anyway, I knew that I couldn't like. The project couldn't be sustained just by myself, unfortunately, because there are a lot of technical and non-technical problems to solving things cross-chain. So instead, what I set out to do was to make the development experience better for Chia, because I built this app but it had to be a standalone executable and it could connect to the local node. But it couldn't really, because if you run an executable on the local machine, then it has access to your private keys, which you don't want. 

Yak 14:02
So all these things led to something called GreenWab, which was an equivalent for Web3.js. It's basically a JavaScript library that would allow you to do basic stuff like sending transactions in Chia and helping the apps do things easier, like providing lots of utilities that the app might need. And just as I was releasing it, I built the whole thing in Nodejs and I tested it in Nodejs. So, just like one day before releasing it, I test in a browser console. I don't know why I waited so long, but I discovered that actually it couldn't connect to a node from the browser and I remember even contacting some people from Chia and after another week of trying we just realized it wasn't possible from the browser, unfortunately. 

Yak 15:03
So that led to another release, another creation before the release of GreenWab, which was called Leaflet. And what this was? It was just a wrapper around the Chia full node that would allow browsers to connect to it. And yeah, so this led to Far Academy, because my thoughts were well, chia is very decentralized, like there were tens of thousands of nodes already online, but if you have to install this wrapper then you don't have access to those nodes. 

Yak 15:42
You only have access to those that install the wrapper. So people will need a service to connect to, and this led to Far Academy, as I said, which is an inferior for Chia. So you have an RPC request, you create a free account, get an API key and then you can make RPC requests. I came here and in my first week of university it was actually orientation week or something, I'm not really sure because I skipped basically everything to attend the DeFi Security Summit and the Stanford Blockchain Conference. 

Yak 16:21
I was I don't know how to say this I was clueless. I just left home, I was in America, I didn't even have a SIM card with internet and somehow I managed to take a call friend to Stanford, actually find Stanford, which is not straightforward without internet If you are someone who had internet all his life. Yeah, I met Breman Jean, which was amazing. I co-organized a meetup there with Dimitri from Gobi Wallet, and it was also when I said it was also when I found out that Chia was working on Wallet SDK. So I stopped working on the web just because if they're handling it, there's no reason to have competition. They're way more capable than I am. So then I just laid back and concentrated on Far Academy for a while. I basically optimized it a lot because I knew it would be the backbone of most, most chaps. 

Yak 17:27
And, yeah, after a while, I started Tibet and actually Far Academy is powering Tibet right now, which is just amazing that I just know that if something goes wrong, I'll get a phone call or an alert from the platform. And, honestly, the scale we've seen with Tibet swap I think at some point we had 30 requests per second and Far Academy just handled that. So now we are here, far Academy is still set from Tibet. I kept them as separate as possible. Tibet's team has grown since launch. There was V1 and I'm not a front-ended developer. I would say I'm more of a back-end developer. The UI for V1 was just very bad and thankfully I've met Toukan on Twitter, so he's now mainly doing the front-end and all the interface the interface you've probably interacted with and the interface everyone's interacted with, the wallet migration, he's coded it and, yeah, we're basically team. So it's nice that it's not just one person making decisions now. It's more people taking in all the feedback and establishing their own map for us to come. 

Host 18:54
Oh, that's fantastic. And my next question is are you still in high school? No, I'm just joking, but that's amazing man. What are you doing there in this ecosystem? And I'm seeing the evolution of Tibet Swap and other products that you build. So thanks for that context. There are Well, I have read a little bit about how decentralized exchanges still are prone to some attacks which are based more on the social engineering sort of aspect of things. Right, like more on the liquidity side. Like you would say, if there's one token, there is more access of that, it would be flooded with some amount of tokens, and then, if there is low liquidity, then the price imbalance happens, and in the past there has been a lot of hackers who had taken advantage of that sort of imbalance, as to say, high level. What are your thoughts around that? 

Yak 20:03
Yeah, I think there are a few problems. So the first one would be that on Uniswap you submit a trade, you sign, and because of how ATM is designed, you might get a different price, which here that's not possible because basically Uniswap is a series of spending coins. So our server, tibet Swap server, or the CLI, if you're using it, that's exactly the price you're going to trade at before submitting the transaction to the network. 

Host 20:36
It's also yeah, it's more deterministic, right in that way. 

Yak 20:44
Yeah, exactly. And also when you are using the UI, what you're really sending is an offer. So you either generated your offer yourself or accepted seeing the price. 

Host 20:54
Can you explain to our audience offer? You and me interact with the ecosystem so we kind of know, just on starting from the high level, what generally a QIA offer is, and it's a very interesting unique idea to QIA that, if you could explain, I'd like to hear from you. 

Yak 21:16
So it's two different things it's what you see and what's behind, which is an incomplete transaction. So an offer is basically an incomplete transaction. So you are going to say I'm going to give an FT to someone. That's one part that's incomplete. You don't know who you are giving it to and instead I'm going to receive to QIA. But again, this is not complete. You don't know who you are going to receive QIA from. And then this you sign this incomplete transaction and you get a short string this is the offer. You can publish this offer anywhere, knowing that you won't. No one will be able to get that NFT without giving it to QIA, and this is basically atomic. So you give the NFT you receive to QIA. 

Host 22:13
By posting the offer everywhere, you mean anybody can say create this partial transaction or incomplete transaction, as you mentioned, and then say post it on Twitter and say hey, there is my offer, you want to accept it? Post it on Reddit, send it through email, something like that. Asynchronously, they can say okay, this is an open offer and once they accept it, they get the stuff they want, something along those lines. 

Yak 22:43
Yeah, so when you generate an offer, you don't really interact with blockchain. You just read from it and then you have this piece of string. I've seen people post it on Twitter. I've seen people encoded in a QR and drop it in cities. There's also this marketplace called taxi, where people came for offers. Yeah, so basically anywhere you can post a string, you can post an offer. I've seen Nostra integrations and also there were plenty of Discord channels where people would just post offers. 

Host 23:22
Oh, so it's already happening, so I got to check that out. Nostra has an integration and you can say, say you can post, like a use case would be hey, I have an NFT and I want to create an offer for that wonderful NFT, and it generates this string and now I can copy that string and post it, say, on Nostra or Twitter, anywhere any communication on threads these days, if any of you have an account there and then people will see that and they say, okay, I want to accept this offer. And boom, it takes them to whatever the NFT and they acquire. 

Yak 24:00
That's amazing, man, that's wonderful and sorry, I think we got sidetracked, but you had mentioned offers, so I wanted to go in a little more depth there. 

Yak 24:11
One more thing about offers is that if you ever change your mind maybe your NFT is suddenly more expensive for stuff you can cancel them on chain, like that's already happening. People can just make a transaction on chain and all the offers involved in those assets are canceled. And what's coming very soon is offer suite exploration. So you can say create an offer and say this is only valid for the next five minutes. After five minutes, this will expire and haven't touched the blockchain to create or cancel it. The only instance where a blockchain transaction will be created would be if someone accepted your offer. 

Host 24:54
So, switching back to the previous conversation you mentioned in relation to Tibet swap, how offers? That's where the conversation went, so we can come back to that thread that we were talking about. So please carry on. 

Yak 25:11
Yeah, so the first attack would be that. The first attack would be if you what happens in Ethereum? Right, you send a transaction and you have some slippage, but the price might change dramatically. And in Chia this is way better handled because you have offers. So the CLI or site will ask you for an offer and that requires you to either put the amounts in yourself or accept the offer via, say, wallet Connect. You would get the dialogue saying hey, do you want to change to Chia, to five Dutch coin, and that way you validated the price beforehand and you see the price Now. 

Yak 25:56
There are vulnerabilities to ANMs. There's always rugs which mean someone had a little bit too much access to the protocol and they've stolen all funds available. Again, our code is open source. You can edit yourself. Make sure I don't have any bad thoughts in it. Yeah, the code has also been reviewed by amazing members of community in their spare time. I want to use this chance to mention that there are two members in the team, but there are countless community members that help to batch up in a way. Someone shared an ANM design with us, someone reviewed the code. A lot of people proposed optimizations or features. Some people tested the code out while we were on testnet, so it's truly a community effort. 

Host 27:03
Interesting that you mentioned the vulnerability that could be exploited in offers. Right, if it's not reviewed, there could be some sort of access to your protocol or some spoofing or something in the offer that's generated. Right, do typically like is there some way to you know, like that lint program that would check the format for, say, javascript, like something along those lines that you know, before an offer goes out it goes through a pipeline of like checks and balances to check out if there is some sort of how should we say it? Not suspicious code or some sort of stuff that shouldn't be there. Is there something automation that could be done? 

Yak 28:01
Yeah, so offers are super secure by default. If you put in the right amounts, you know that they won't go through unless you were given what you asked for. And on Tibet shop, for example, we checked the price three times before we submitted the transaction to Boxing, making sure that it didn't change too much. 

Host 28:25
But like a preview of the offer, like in dynamic mode, like this is the price and then it's changing constantly. Right, right now offers are very static and there is no. Like you know, when you post a link, like a hyperlink, in a chat session, you get some kind of snippet, basically right, you see snippet of a news that sometimes I post on channels, right. But I was wondering what if the offers are dynamic like that? Is that a possibility, like where in the UI, like some sort of dynamic, it just shows? 

Yak 29:03
Right now offers are very static and that's one reason you'd prefer an AMM because the price can change. Because if you post a static offer on Backseat and the price changes and so on, except for they just made profit and you lost some money and the AMM is able. As more people buy, you know the price increases as more people say, the price decreases because of the formula. But what is totally possible and I expected to be built sometime in the future is that you could have an Oracle saying this is the price and then you could make technically new offers. This would be new code running, but it is possible saying, hey, I want to sell five chia and buy this meme coin at the current price. 

Yak 29:50
Those are basically market orders, yeah, so right now I am a little bit reserved about talking in the future, just because before the AMM was launched a lot of people thought it wasn't really possible and now we are working on things that might be possible, like they're 95% likely to be possible. But we might also stumble upon some roadblock we haven't thought about and we might discover they were not as easy or as efficient or maybe they have a flaw. So I'm not really talking about the bets of victory and its features, because I don't know if stuff we're planning is completely possible, but we'll announce it once we have some basic tests working showing that this can be done. 

Host 30:42
So I appreciate that honesty, man. Thank you, I'll be looking out for those updates and I will actually look out for actually the wallet connect for the native wallet. 

Yak 30:53
That would be one more thing. So there are two main ways in chia of trading assets. You can do that based on offers with Dexie or using Tibet swap, and they both have advantages and disadvantages. But as someone wanted to provide liquidity, you watch, you see the things in another way. With Tibet swap, you basically give some assets. This means that Tibet swap now have more assets to enable trading and in exchange you get a share of the fees. However, there's this opportunity cost of providing liquidity. 

Yak 31:37
You gave me five chia and 10 dollars coin. You could have held them in your wallet and it turns out that as the price fluctuates, if there were no big fees, you'd actually lose money because of how Tibet swap works internally and that's called impermanent loss. That's basically a theoretical loss. With that, I want to emphasize how trading fees can actually overcome this loss. If you look at graphs for Unisop, which has a 0.3% trading fee, you'll see that most of the time, lps have made more in fees than they have theoretically lost because of impermanent loss. 

Yak 32:24
Tibet swap has a fee of 0.7%, that's more than double, and we have yet to see long-term gains of these, because giving assets to the protocol is basically a long-term gain. Anyway, back to the comparison With Tibet swap. The price is always moving following the market because of arbitrage bots and you are occurring those fees and you're basically the amount you invest into. Tibet swap grows without you doing anything. You can stop it anytime by withdrawing your assets, but they continue to grow and you always have 50% one asset, 50% of value in the other Because they are basically they're more like traditional exchanges. 

Yak 33:20
You put bids. They're exact amounts. You have 2 GIA for 5 Dogecoin but you can do 1 GIA for 2.5 Dogecoin only if you post 2 offers. And the problem is that if someone accepts your offer, you have to be online, react and post another offer and the price may be changed. But you have to check that for yourself. You have to fetch the price, cancel your offers that are at an old price before someone makes an arbitrage. So I do think that AMMs are better for trading assets, but when it comes to, say, nfts or something that's non-fungible, I think offers are a true game changer. 

Host 34:07
Yeah, totally makes sense. Like usually, the NFT price is not. Unless it's an auction, it's kind of is very steady, so in that regard, offers serve as a perfect solution. So I totally agree with what you're saying here. All right, and before I go, I want to know your broad term vision in terms of do you see any? There's a lot of talk about AI these days and blockchain combined with it. Do you see any kind of intersection of these two technologies somewhere? And what is your advice to youngsters like you who want to come into this space, and why should they come to Chialisp? 

Yak 35:00
Yeah, I don't see a lot of intersection between blockchain and AI. I think that it's better to enter some area of technology because you believe in it, not because it's the current buzzword. Like we see in AI, you put AI in something and investors are already willing to give you more money. But the case for Chia is that it's truly revolutionary and, yes, it's kind of hard to get started at the moment. But I wouldn't be here after such a long time I think it's more than two years continuing to build on this chain If I didn't truly live. It will change. 

Yak 35:44
For me, this is like the opportunity of being there in the early Bitcoin days and building stuff, but the thing is you can't build AMMs on Chia. Sorry, you can't build AMMs on Bitcoin. You can't do a lot of things on Bitcoin because it's not true in complete it's creators. It disappeared. For me, chia is the Bitcoin we never had. It's like you had a lot of very smart people just thinking about assets, about offers Offers are not a thing on Ethereum and it's a chain that's being improved constantly. It has a company behind it with a lot of incredible minds and it's just yeah, it's definitely worth looking into. And, to circle back. I'm not a big fan of Ethereum because I went, as I said, to the Stanford auction conference and there was a talk about Vitalik and the new proof of stake consensus, and he there before us and told us that, yeah, this proof of stake thing, it might require some manual initial, which is not what you want to hear about a consensus mechanism. 

Host 37:06
So he said what? Some manual intervention. 

Yak 37:09
he said that yes in case of some attacks. Validators might need to coordinate off chain. Maybe they solve that. But after working year on this upgrade, saying that and behaving like it's okay to have to need manual intervention for the consensus of chain. That's not what I'm a fan of, and the team certainly innovated a lot of things. It enabled decentralized apps. But yeah, I think there's a lot of value in how, in the mentality behind the blockchain, and I think Chia is way better. It's all about decentralization, which really matters in crypto. 

Host 37:57
With that, thank you so much again. Yak and wonderful, and I'm great to be in presence of such a great mind and budding mind who's? We need young programmers like you. Chia needs all the inspiration they need from people like you and would love to have you on the show again. Thank you. 

Yak 38:22
Thank you for having me. 

Evolution of Chia and Web3 Projects
Decentralized Exchange on the Chia Blockchain
Future of Blockchain Trading Technology
Debating Ethereum's Proof of Stake