How to Build Using the 1inch Limit Order Protocol

ETH Vietnam 2022 · November 2022 · 11:23

Nikita Kozlov of 1inch shows developers how to build with the 1inch limit order protocol. The workshop covers creating and filling onchain limit orders and integrating the protocol into decentralized exchange applications. Recorded at ETH Vietnam 2022.

Speakers

Topics

From ETH Vietnam 2022, hosted by ETH Vietnam.

Transcript

first of all I would like to introduce to you our first topic which is how to build using 1H limit order protocol please give a warm welcome for me the Nikita colors backhand engineer lead of one age hi everyone my name is Nick nice to meet everyone of the specific structure after that this user needs to share this limit order through our API basically it just needs to share the structure the conditions of this order to everyone and and the second in the next next you just need to wait until it will be executed until somebody will be okay to execute this order so another party who actually

executes the order is Market taken it's basically someone who wants to earn on this trade who is okay to trade with these conditions the best example it will be actually if let's imagine that there is exchange rate for example like right now for one for one film it's like 100 1200 die let's imagine someone wants to trade funny film for one thousand then die if it's okay for you you could Arbitrage this case it's okay for you to execute this order so basically you could earn some some fees on executing these others and that what Market takers do they basically Arbitrage the market and just get the profit into their own like wallets

so basically what Market taker needs to do basically you just need to search for like basically suitable locating with others we have on each API by using PVP for example a communication after that we need to fuel limit order using a smart contract and actually just it also have some some assets to fill this limit order basically if you need to feel limit order will die you need to have some die on your wallet and have approval for that the basically basically kind of like this so just you need to sign and send an order to the API to the storage

the market taker needs somehow discharge for this for specific order after that we just need to execute the statement order and Mark it to maker will get funds from Market taker we have Smart contract the main idea here is that we execute all limit orders on the smart contract and there are there is a guarantee that specific constraints specific like things for this order will be executed like there is a guarantee for that for these conditions so uh let's talk a bit about image order structure and how it looks like basically there are multiple ways how you can use limit order there are two options the first easy One is using API on JavaScript if you just need to create

or like feeling with others for that case you just can use the JavaScript details Library it's open it's actually available on vanish documentation site I will show the links a bit later it's the first option the second option is you can actually adjust limit orders to build something more on it for example you can build Marketplace of nft based on limit orders as an example basically limit orders allows you to trade any assets not only Arc 20 assets but actually any asset even nft asset or any asset that can have some specific interface like implemented so I just want to tell you more about limit order structure it will be pretty useful for you if you want to go

somehow to change the structures of both the salinity part of limit orders I just want to say that actually it's open source so you can take a look on it you can work it or do anything with it anything you want basically um you just want to pay attention to some some things the first one actually is making amount taking amount taking a data and maker as a data these skills actually allows you to specify how you can exit how the tokens um how what is the rate of your limit order for example sometimes there are cases when you have like near like you have static formula of static rate for your limit order so that doesn't matter how much like you feel this limit order

the rate will be the same but if you will Implement functions using making us a data and Day Care asset data and get making amount and take a taking amount you can actually specify the rate for each type of the for each moment of filling the minimum order that basically means you're gonna build for example auctions like touch option for example on limit order on our limit order protocol permit and interaction Fields basically these three parts are pretty important basically pyramid allows you to actually be to support their needs their means most of the inferior Air Supply tokens so if token support permits you don't

need to use gas to make approvals on this on the smart contract for this token you can just sign a structure for that it's also it's pretty useful if you don't want to pay any gas from user side uh predicate is physical feature that allows you to specify additional conditions we have multiple default conditions like timestamp constraints like like monster I will talk about more about pedicate later and also interaction actually is like a callback you can always use interaction to do some operations with future funds before it will be executed and transferred to the taker um so that's how actually you can feel limited

order basically this is the main function for other execution you just need to call a few other function on the solidity side we do have JavaScript implementation for the field order so basically um what do we need to fill this order is just actually a V4 signature for type science Data before signature for micro address in some cases it can be wallet or in some cases can be another smart contract it depends on it actually doesn't matter you can do you can Execute order on any on any contact but I just want to take pay attention that if you use Smart contract for as a maker you just need to make a implement the signature function to verify the signature from your site

so um making a ticket amount is actually the amount you want to feel uh there are some there are multiple types of limit order in the default one you can feel limit order multiple times it depends on the image on the amount of remaining amount of maker and taker but basically uh you can specify micro ticket amount that you want to kill and we will calculate like the the returns for it and the first hold amount is actually it's a miniature amount basically it means when you use taking amount um let's talk a bit more about busy kids actually it's pretty awesome feature that actually makes limit order not only a limit order but actually more like arbitrary execution our video trades

creating gaza's trading stop because we allow you to actually to build any any custom for your predicate on our limit order so uh you can for example make a predicated access if the if the die price goes below like 1000 I don't want to make a limit order for my trade of link to a few so basically you can use any predicated you just need to implement it on the smart contact level and there are some default ones like uh for the for example like pinning on the market side only limit order and auto time staying below condition that allows you to actually execute trades uh for like during the specific timestamp

um so yeah a bit more about you can take a good take your amount basically uh there are default functions that shows how we calculate the rates of the each of the each like of the each amount but you can actually re-implement it and if you will implementing it basically that means that you can have your own price formula for each type for each type moment when you limit your order will be filling um and a bit more about execution of the limit order basically each time you need to execute each time we execute limit order we use actually this code you need to take a look we need to take a look on it if you will try to use for example um a smart contract you need to implement a specific specific additional

uh call that allows the check signature from your smart counter site yes this is the case basically how we debilitate a signature on the SmartWater side this is like an example of the crawling as well as signature on your on this on your side so each time you each time you you use a Smart contract we need we need to implement this fallback um let's talk a bit more about uh interaction and the use cases for the interaction side uh the best use case for interaction potentially can be a case when you need on the default cases of limit order but you use a limit order you just you don't need you need to have

a funds on the user's side not locked anywhere except payment order basically each time you execute limit order by default you need to have user fans flocked some somewhere but in our case you don't need to do this you can basically for example take some assets on compound or like on the Ave for the for the die and at the moment when all the limit order will be executed you can use interactions to actually withdraw user funds from the die and fill this limit order at the same moment so basically you can do multiple things at the same time you can for example sell something for the die or like buy something using die and also do some API like Farm or stating somewhere this

these tokens you can do you can do everything like in the same moment and for that you basically just need to implement interaction yes so basically there are two options how you can start using limit order there is a quick start with on our documentation portal there are multiple examples how you can use it using JavaScript it's like the first color code and also there is open source part of all our limit order with on the solidity side with tests on the right basically if you want to use limit order using smart Matrix I do recommend you to take a look on on our tests and on the right on the right link of limit order and I also want to say that actually right now

we are working on V3 version it will be available like in the next couple of weeks and it will allow actually to use limit orders in even more gasless way than right now it will be even more efficient but currently uh V2 is the last production version the transition to a victory will be actually pretty painless so thank you if you have any questions you can ask me I will be here [Applause] thank you Mr Nikita for your wonderful sharing