Limit Orders on SpicySwap: an Innovation Everybody Missed Out On
On March 20, the decentralized exchange SpicySwap added support for limit orders. We missed the launch because of the war, but now we're catching up.
This post covers how limit orders work on DEX, how much they are in demand in DeFi, and how SpicySwap works with them.
What Is a Limit Order
An exchange order is an order to execute a transaction. There are three types of orders:
- market: make a deal right now at the best price;
- stop: conclude the deal at the best price, but only when the price reaches a certain mark;
- limit order: to make a deal only at a specified price.
The easiest way to picture this is at a bazaar. Sellers in stalls put up their limit orders in the form of ads saying “I sell cabbage for 100 bucks a kilo”. Buyers either take the cabbage immediately at the seller’s price, making a deal at the market, or wait until the seller appears with a price of 90 bucks per kilogram, which, in the world of exchanges, is known as placing stop orders.
Stall sellers are the backbone of any bazaar, and limit orders are the foundation of centralized exchanges. With their help, market makers literally shape the market and provide liquidity for trades. Regular traders also use limit orders to avoid slippage in trades.
Decentralized exchanges do not need limit orders to operate, as liquidity flows into a common pool rather than being allocated to individual price levels.
However, limit orders are useful in the following instances:
- to buy tokens during a decline or sell at a peak;
- for position averaging;
- for trading a grid of orders;
- to exchange equivalent assets at a 1:1 exchange rate if there is no Flat Curve for them.
Although you can use custom bots with direct interaction with DEX contracts for these purposes, a built-in solution with limit orders will always be more convenient.
Are Limit Orders in Demand in DeFi?
We use 1inch, the most popular DEX with limit order support on Ethereum, as an example. The data on trading volumes and the number of users and transactions for the last year is courtesy of Dune Analytics.
The average user of the regular 1inch has traded $141,000 over the year, and the user of the 1inch Limit Order Protocol has traded $170,000. Limit orders are in demand among major traders.
How Limit Orders Work on SpicySwap
SpicySwap, in fact, consists of two parts: a basic SpicySwap with the basic DEX functionality, and SpicyPro featuring limit orders and flash loans.
SpicyPro limit orders can be used to trade in any SpicySwap liquidity pool. Limit orders are handled by a separate smart contract that stores data about active orders and freezes funds for their execution as well as the executor’s rewards.
When an order is created, the user selects a pool and then enters the execution conditions:
- How many tokens they sell (Amount In);
- how many tokens they want to receive (Amount Out) or the execution price of the transaction;
- the reward (Execution Bounty) in WTZ tokens that another user will receive for executing the order.
In the end, the user presses Post and signs the transaction. The order goes to the contract database and is shown in the order book.
To execute a limit order, you need to use a special bot. To do this, download the archive from Github, then install Taquito and Node.js. In the index.js file specify your wallet address, configure tezos-signer and only then run the bot in the terminal.
The bot will cyclically check each order in the limit order contract and simulate its execution. This is how it checks whether the condition of the order, which is to give the owner of the order the necessary amount of tokens, will be met. If the condition is met, the bot will execute the limit order from the wallet connected to tezos-signer.
Putting a limit order on SpicySwap looks easy, but executing other people’s orders does not. In theory, they could be made more convenient with a liquidity router that would compare the profitability of swap execution with the pool and the nearest limit order and then make a decision.
We hope that SpicySwap will continue to develop its features and improve the user experience. In addition to limit orders, this DEX has flash loans through Youves and recipes for batching typical transactions, but few people know about them. SpicySwap and other SalsaDAO projects deserve more attention.
Subscribe and never miss updates from the world of Tezos: