KittenSwap (5): Dynamic Limit Orders Using AMM Information

This is part 5 of the KittenSwap series, in which we gradually present our design for the next-generation swap.

KittenSwap is at https://www.kittenswap.org/ and you can trade our first IKO (Initial KittenSwap Offering) token $LIQUID there.

In this article, we discuss a simple method to improve limit orders using AMM information.

1. The Problem with Usual Limit Orders

It is well-known that there are arbitrage opportunities in an OrderBook DEX. As an example:

  • Assume the current uniswap price is 1 TOKEN = 0.1 ETH.
  • Assume there is a limit order of BUY 1 TOKEN @ 0.08 ETH.
  • Assume there is a limit order of SELL 1 TOKEN @ 0.12 ETH.

If the uniswap price moves to 1 TOKEN = 0.13 ETH, then the limit SELL order becomes an arbitrage opportunity, because its price is fixed despite market condition changes.

And this can stop people from creating limit orders, because you may get a worse fill than uniswap. Namely, you may sell your 1 TOKEN @ 0.12 ETH, instead of 0.13 ETH.

2. Our Solution

In our new design, you will be able to create dynamic limit orders such as:

  • BUY 1 TOKEN @ MIN(0.08 ETH, PriceUniswap).
  • SELL 1 TOKEN @ MAX(0.12 ETH, PriceUniswap).

And then you can always get a good fill (at least as good as uniswap).

  • If PriceUniswap goes lower to 0.05 ETH, then the BUY order will automatically become lower: BUY 1 TOKEN @ 0.05 ETH.
  • If PriceUniswap goes higher to 0.15 ETH, then the SELL order will automatically become higher: SELL 1 TOKEN @ 0.15 ETH.

Moreover we can do more than this. For example, consider this order:

You may wonder why anyone will trade this order (i.e. buy from it), if its price is always at least higher than 1.1 * PriceUniswap.

And that’s because directly buying 300 TOKEN from uniswap may be even more expensive, because we know large orders can significantly move uniswap prices.

Note it is not safe to create simpler orders such as:

Because PriceUniswap can be moved using flash loans. So we’d like to always put in another price as a safeguard. A better method is to use TWAP as well.

3. More Benefits

Our method here has more benefits.

Firstly, no more fat fingers.

If PriceUniswap is 0.1 ETH and you create an order of “BUY 1 TOKEN @ 10 ETH” by mistake, it will be automatically corrected to “BUY 1 TOKEN @ 0.1 ETH”.

(Note a sophisticated bot can still use flash loan to push the uniswap price to 10 ETH and then execute your order @ 10 ETH. So we shall use TWAP too if we want to be extra safe.)

Secondly, no more bid-ask arbitrage opportunities.

Because bids will always be lower than PriceUniswap, and asks will always be higher than PriceUniswap, they will never cross each other.

**********************

Join our Telegram and Discord ( on https://www.kitten.finance/ ) for updates of KittenSwap.

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