written by Levx ( Sushiswap contributor)

Typically AMMs only settle orders with market price, which represents a significant limitation compared to orderbook driven exchanges. SushiSwap addresses this critical AMM pain point with the release of the limit order feature.

How do SushiSwap limit orders work?

Limit orders on SushiSwap work in a completely decentralized manner, without the need of any centralized authority. The system consists of two contracts: OrderBook and Settlement.

OrderBook

OrderBook keeps limit orders that users have submitted. Anyone can call and create a limit order with the amount to sell and a minimum price.

As an interesting aside, OrderBook isn’t deployed on the mainnet but on kovan testnet, which means users don’t need to pay for gas to create an order :)

Settlement

Settlement is in charge of swapping tokens for orders. Anyone can call and fill an order taken from OrderBook. Functionally, we’ll call “anyone” a relayer. Relayers need to fill an order with the proper parameters to meet the minimum price requirement set in the order. If the attempt is successful, 0.2% fee goes to the relayer and xSUSHI holders.

It is possible to fill only a certain amount of tokens without necessitating to fill the entire order. In most cases, submitted orders will reside on OrderBook and their amount will be filled by different callers in different blocks.

Who are relayers?

Since orders are kept on a different chain, someone needs to pick up those orders and settle them the moment market prices meet the requirements of those orders. Without relayers, orders won’t be executed.

Becoming a relayer is permissionless. What you need is a server that runs a relayer bot program. This SushiSwap bot code will be open sourced and released soon.

0.2% fee on every amount you fill goes to the relayer and xSUSHI holders. The fee is deducted before the swap is executed. Out of 0.2% fee, 80% goes to the relayer while 20% to xSUSHI holders.

Bug Bounty

The contracts for limit orders have not been audited yet so you may encounter bugs in various scenarios. Use at your own risk! That being said, SushiSwap is opening up a bug bounty for everyone. FYI, Contracts are scheduled to be audited by QuantStamp.

All contracts in our /contracts in the repo https://github.com/sushiswap/sushiswap-settlement are eligible for the bounty.

  • Critical: up to 10000 SUSHI

For details: https://forum.sushiswapclassic.org/t/limit-order-bug-bounty/943

Try it now!

Limit orders are now supported on SushiSwap Lite. (As mentioned above, contracts are not audited yet so use it at your own risk.)

Image for post
Image for post

SushiSwap 🍣, a community-led AMM part of the Yearn ecosystem

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store