Vega 101 - Learn How to Build on Web3’s Native Derivatives Layer - Christian Moores
Ethereum Denver·Sun, Oct 9, 2022, 12:00 AM
Transcript
all right sorry about that technical difficulties eh hopefully yes [Applause] [Music] [Applause] i was worried there apparently it's the dongle always have a backup on your backup so hi everybody i'm chris i'm a developer advocate at vega you might have seen us around it's hard to miss we've got these bright yellow hoodies awesome swag don't worry there'll be plenty of opportunities to get some more of that at the end of this session they very kindly extended it for me the end of this session there'll be a bit of a q a if there's time and anybody who wants to come get some swag you can come talk to one of the people in the bright yellow hoodies and they will give you a coaster and you can take that to the uh the booth on p20 to select some awesome swag so very quickly um the agenda for today was supposed to be a little bit about vega all the core technical aspects as uh the mc said one-on-one on vega i'm a little bit pushed for time but hopefully i'll get through all of this quite quickly so what is vega vega is a scaling layer or a hybrid deck built on a proof of state protocol that bridges to all major blockchains starting with ethereum it's a great conference i'm loving it so far and ethereum and vega are really really close because you get the power of ethereum and the store of value and all the ecosystem and you can bridge that over into vega and uh deploy those assets and trade in leveraged products such as future swaps etc uh very easily it's the world's first open protocol for creating flexible derivatives and includes a list of impressive features such as anti-front running permission must market creation and fast limp decentralized limit order books today network wise you can start hacking on the official vega test net called fairground right away especially if you're thinking of competing in one of our four different bounties the fairground is bridged to roxton or erc20 assets as we mentioned before we love ethereum it provides a safe place for experimentation and building whilst learning about the protocol most of the things i talk about today will be all about fairground but in a second i'll talk to you a little bit about the progress of the project and where we are with the community so on fairground all trading features are enabled and there are several markets and bots trading that will hopefully get you into the place where you want to be without having to risk a lot of collateral december 2021 a group of community elected validators launched a restricted mainnet the purpose of this phase is to secure the network before trading is enabled in the near future the vegas network architecture it's a little bit uh different um but we came up with this protocol in a way that we wanted to tailor our solution for trading derivatives not creating a general purpose blockchain and then trying to fit that in we wanted to create this solution that was just fine tuned for this so vega has a decentralized network architecture and each node contains a full stack of engines in the trading core which includes matching settlement risk collateral banking transfers everything you need to run a dex on each of the nodes so even if one of the validators or one of the data nodes gets taken out all of the other nodes they have the full stack i mean you can think about this if you know if we took the consensus layer off the top you could just use one of these nodes as a sex it'd be worth millions in itself maybe vega uses cqrs so right commands such as placing an order are submitted on the blockchain and they take part in consensus along with other commands when the block is formed this guaranteed ordered set of commands are sent to each trading core and processed deterministically so every node gets a batch of transactions and processes them in exactly the same order all code will eventually be open source and that hopefully the community can benefit from all of our research most of our code is open source but some of this is still proprietary research but it's all going to be out in the community over the next year or so one of the talented teams at vega are building a trading app that gives a really rich visual ui for all the trading data that's on vega and we're calling this console i mean you can create your own but we've built this to get you speeded up pretty quickly i'll give you a little demo right now so fairground console as shown is a helpful tool from developing against the vega apis you'll be able to see your orders positions and margin changes right here in the browser the other super useful feature is that it actually includes the features to load up your vega wallet with the bridge drc 20 test assets we've set up such as tdi tusd etc and you can just connect them straight into your fairground test net wallet using something like metamask it's very familiar now this is the bit i'm super interested in as a developer advocate got a build on vega we've got these four amazing bounties worth up to 30 000 usdc and um i'm really hoping that some people have already started hacking on this i've had lots of interest so far we're going to go through really really quickly some of the key features but there's so much more so so much more so do come and see me chat to me on discord telegram wherever you'd like if after this i've got so much time for anybody wanting to hack on this and dream up some new solutions one of the first things that you need to think about on vega because it's a scaling solution or l1 hybrid um is that we have our own command line wallet so this has been available for a long time now and super easy to use if you're used to using the terminal etc you need this to sign transactions on vega but when you lock up assets in the bridge they're available within your wallet and they're assigned to your public key as i said you can do that in console it's super easy there are other ways to do that the community have built some tools so that if you have other wallets you can connect in through some portals do ask me about that afterwards um it's so inside the vega wallet it's a rest based api service it can be used to connect third-party apps locally or if you want in a private environment in the cloud and it allows people to really easily connect and sign any transactions or commands like i showed in cqrs just for east denver here on the screen i've teased a little bit of something that the community is desperate for which is uh we're almost ready for pride time it's our desktop wallet so those that aren't familiar with the command line aren't wanting to just run simple commands or whatever they can just run a gui app on all top level operating systems and this little preview of how nice it looks and again fits in with our branding one of the experiences you get with vega is that you can code almost like a cex if you're used to connecting to big cx's or even some dexes you can connect to vega in data nodes in various different ways there's three different types of api we have grpc superfast bi-directional streaming etc graphql building a web app a dashboard something like that or even just trying to build a mobile app and be expressive that's a really great one to do that includes streaming or if you just want to fire up a curl or just do something really quick and easy and get some data out there and mash it up with something else we have rest as well and all nodes support all data nodes support all three of these you if you're running your own data node you can turn them off or on depending on your memory usage so my advice for this would be if you're running something like a bot or writing something that needs very high performance grpc is the top level if you're writing something that's similarly performant but is maybe web-based it might be easier at the current point with the tooling to use graphql that's not to do with vega that's just the way that grpc works you have to run a proxy etc but obviously there's just rest you know everybody knows rest and they like that disadvantage with rest is that you probably have to do some kind of shoe horning in web sockets to connect to the graphql subscriptions in the past i've just devised user an apollo subscriptions client or something like that as you can see here we've got different um different data sets so things like trades candles orders positions within vega everything is transparent so this is just you might have seen our free the markets thing everything is is completely open and free so you don't have a disadvantage in some respects to other people this data is all available and there's several references for fairground available on the screen um there's plenty of options if you go to vega.xyz it'll link you straight through to that you can go directly to the docs link shown on the screen and that will take you to a list of really helpful api guides and other tools that you can do there so i want to show you some code i'm not going to live code i'm just going to show you how it works um it's pretty good thing given my technical problems i'm going to show how easy it is to create orders as commands how fast the blockchain is and how to amend them and how to cancel them in a really super easy script so if you go to this repo you can get access to this and lots more so here's a visual studio code i'm just showing different things about the code itself first is connecting to the wallet service that i mentioned earlier you sign in you get a token find a market you're looking for one of the markets on testnet we get the blockchain time so that was synced with the time available and then we create this command which is pretty succinct submit an order you give it your own unique reference you sign it and send it to the blockchain for consensus and inclusion in the next block we're going to wait for the blockchain just to make sure it's included and then in this simple script we amend it we change the size to 25 less and let the price down to 2. we wait again we confirm that it pass and then there are various options for cancellation but we just take the easy route which is just to cancel that order that we passed in with a reference and then that's it that's that's as simple as a script there's a lot of comments in there but you can you can probably do a submit order in three or four lines that simple and this is python might be even more succinct in another language so here's me running the script i've got a little sleep in here so you can see what's happening that's a submission that's an amendment and that's a cancellation and that's how quick it is that's that's literally all three operations all through consensus all taking place and if i'd have actually matched on that top order i wouldn't have been able to amend it and i wouldn't have been able to cancel it because it would have already been matched in the matching engine and that can happen obviously in the immediate first block in this case it did all three so finally what would be the use of running a trading platform or a dex without having real-time data i use all the time and as i said grpc is pretty good but a lot of people working on our bounties they're probably going to want to use graphql because it's just really easy and really succinct and i'm going to show off something called the vega graphql playground some of you might have seen this as well for other projects but we've got this all booted up ready to go it's a great place to explore not only the schema not only the data types and how they actually interact with each other because you've got autocomplete but when you're building a tool or a bot you can play with the queries in here ahead of time and make sure that what you're expecting comes back or if you've written something or you debug something in your application you can paste that query back into here and just sanity check that data there are other ways to do it but this is in my opinion very very easy to do this is the graphical playground the url was on screen i can share that with you again and this is real time data coming straight out of the data node so this is a list of all parties and on the right hand side you've got access to all the docs and you can drill down into all the descriptions and all the fields and includes all of the descriptions of what they actually do within vega so you almost don't need the reference docs this is even better and if you want to download the schema for your app you can do it on the top right i'm going to show you markets getting all market data that's something that's very common and if you want to remove one of the fields and just get something back it's very easy to do you can just go in here and it gives you auto complete and you can just pick a field and you can graph query out from there as i mentioned you can subscribe to data in here so i'm doing a trade subscription this also updates every uh second or so and the same for orders uh there is one limitation with using the playground there is a hard cutoff of any subscription of 30 seconds so if you're using this to test data and you're noticing your queries are ending within 30 seconds for a subscription don't worry it's not a bug in in vega it's just a limitation of this ui if you do that query in your console app or on your uh your own code it will just keep streaming until you close the websockets so i've mentioned it already we've got some really awesome bounties this year um the top one which i think a few people have already expressed interest in starting on but still plenty of opportunities to build a block explorer we've already built a pretty standard block explorer example but we want to see you know how far you can take it what can you think about uh showing the blocks and visualization in our ethereum there was a train station with people um little people going on train carriages that would be pretty cool um but there's so many things you could do there the next one is very similar visualizing staking and delegation we're a proof of stake network with around about 50 of our tokens already staked on the mainnet but we would love people to try and think of novel ways perhaps to visualize that and educate people about making sure the network is secure and not centralized because proof of stake can become centralized if people don't be careful with who they delegate to liquidity bots we did a workshop yesterday which went really well so one of the key things that i haven't gone into but i'd love to explain to you later in another session or after this is around how we incentivize liquidity so if you create a market on vega you need to provide liquidity and you actually incentivize financially to do that which is really really one of the core aspects of trading dexes and how we can get these things off the ground and then the last thing is who doesn't love spreadsheets we'd love you just to plug in google sheets or microsoft excel as an add-in and be able to just drive around your data and visualize your data pull up pie charts all that sort of stuff your positions your orders etc right there in your um your spreadsheet so that's it there's a qr code on the screen to go to a launch pad which i've put together which has really in deep information and criteria as well as links to videos to give you everything you need to get started as i've mentioned we want you to build on vega as if it's a centralized exchange no solidity none of this stuff you just plug into an api sign transactions and away you go and you get the power the speed and transparency of this next-gen technology so without further ado that's it i might have a minute for questions again apologies for the technicals okay no questions that's pretty good so there's some free swag at booth p20 which we're downstairs on uh level three uh opposite the dj till room so see me after if you've got any questions we'd love to give you some coasters you can exchange that for some swag uh thank you for your time happy building
Automatic transcript — names and jargon may be misspelled.