# KittenSwap Preview (2): Effective Swaps + Options + Loans with Limit Orders

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

# 1. Limit Order is All You Need

Capital efficiency has been the talk of the town, and famous projects are trying to combine Swaps + Options + Loans into a capital efficient single contract.

Here I will show how to achieve Swaps + Options + Loans with simple Limit Orders.

Moreover, my solution is market-driven, and eliminates the need for some magic numbers (such as the various liquidation thresholds for pairs in a lending market).

# 2. Money Left On the Table

Assume ETH is trading at 1 ETH = 1000 USD.

When trader Adam creates a limit order of “Buy 10 ETH @ 700 USD”, he will lock 7000 USD inside the order. And we probably will take this whole process for granted.

However, veteran traders will know there are money left on the table:

1. The 7000 USD is sitting there doing nothing.
2. Adam is actually writing (creating) a put option of 10 ETH @ 700 USD, even though he might not realize it.
3. Hence, there is hidden time value for this order, which is wasted.

The target of KittenSwap is to extract more \$ for you.

# 3. You are Writing Options But You Don’t Know It

Let me explain the option part, as it might be new for some.

Adam is writing a put option, because he is providing a method for other traders to sell 10 ETH @ 700 USD.

Consider the case in which Adam would like to “Buy 10 ETH @ 700 USD valid till Feb-1-2021”. This kind of scenario happens a lot.

In this case, Adam is creating a “put option of 10 ETH @ 700 USD valid till Feb-1–2021” for other traders.

Because now other traders can sell 10 ETH @ 700 USD to Adam before Feb-1–2021.

Hence, potential option writers are abundant. As long as you know how to create limit orders, you can write options.

We haven’t seen many such options yet, because currently there is no way for traders to express their views and collect time values for their orders.

That is, if the limit order is valid for a longer period, its time value shall be higher, but currently there is no way to collect this value.

So, currently most traders will create short-lived limit orders and modify its price all the time, which is unfortunate.

KittenSwap will be the first exchange in which you can collect more \$ for your limit orders because of their time values.

Moreover, there is an elegant method to achieve this.

We will begin by an examination of a loan market.

# 4. Examining a Loan Market

Recall what happens when we borrow in a loan market.

Assume ETH is trading at 1 ETH = 1000 USD, and the liquidation threshold for ETH is 70%.

1. Trader Betty deposits 10 ETH to a lending market, and borrows 6000 USD.
2. If the price of ETH goes below 700, Betty’s position will be liquidated. Her 10 ETH will be taken by someone, and she is left with 6000 USD.
3. Otherwise, Betty can pay back 6000 USD + interest, and get back her 10 ETH.

There are some important problems here:

• Who determines the 70% threshold? This parameter shall be determined by the market instead.
• Who determines “the price of ETH goes below 700”? This is a tricky question. It is usually determined by an external oracle, but we have seen attacks (such as Compound’s DAI liquidation event).

You may also feel there is some option or limit order stuff going on here.

Indeed, I have two explanations.

# 5. Liquidations are Stop Orders

Firstly, the reason why the second question is tricky, is because Betty actually creates a Stop Order.

You may have heard about stop orders. They are more tricky than limit orders, therefore only some of the exchanges offer it.

Betty actually creates a stop order of “Sell stop 10 ETH @ 700 USD”.

It can be executed only when the price of ETH goes below 700 USD.

And the punchline:

Whenever you create a “Sell stop x ETH at y USD”, you deposit x ETH, and you shall be able to lend or mint approximately x*y USD.

The reason is, your stop order guarantees the value of your x ETH is higher than approximately x*y USD (in real life we have liquidity issues when ETH drops, so the USD amt will always be smaller than x*y).

Both limit orders and stop orders will be supported on KittenSwap. However, stop orders are tricky for DEXs to handle. Usually an external oracle is required (be aware of flash loan attacks!).

I have a “proof-of-liquidity” idea to solve it, which will be discussed later.

So, can we create loan markets with limit orders? The answer is yes.

# 6. From Limit Orders to Loans

Let us ponder on the above example.

Betty is able to borrow 6000 USD, because her “Sell stop 10 ETH @ 700 USD” order guarantees the value of her 10 ETH is higher than approximately 7000 USD.

However, we can also guarantees the value of assets using put options.

If Betty owns a “put option of 10 ETH @ 700 USD valid till Feb-1–2021”, then the value of her 10 ETH + put option, is higher than 7000 USD before Feb-1–2021. So she shall be able to borrow 7000 USD.

Therefore, if Betty purchases the put option created by Adam (as we mentioned in section 3), then the full circle is completed.

More interestingly, note Adam deposited exactly 7000 USD to the contract.

# 7. Finishing the Circle

Now I will show how to achieve Swaps + Options + Loans with simple Limit Orders.

Assume ETH is trading at 1 ETH = 1000 USD.

1. Adam deposits 7000 USD to the contract.
2. Adam creates a limit order of “Buy 10 ETH @ 700 USD valid till Feb-1–2021”. Now Adam is locking 7000 USD, but it will create \$ for Adam.
3. Because Adam actually created a “put option of 10 ETH @ 700 USD valid till Feb-1–2021”, and it has time value.
4. Betty pays 10 ETH + some \$ to Adam for “purchasing the put option”.
5. Betty is now able to lend 7000 USD, exactly from Adam. She can pay back it before Feb-1–2021.

If ETH stays above 700 USD:

• Betty pays back 7000 USD to Adam, and gets back 10 ETH. Betty can sell the put option on the market to get more \$ back.
• Adam gets \$ from the time value paid by Betty, which is otherwise wasted on other exchanges.

If ETH goes below 700 USD:

• For Adam, he gets 10 ETH from his limit order as expected, and its time value from Betty.
• Betty is left with 7000 USD, which is great. However remember she paid some \$ to Adam too. So, her end result is less than 7000 USD, but still likely higher than what current loan markets can offer.

Conclusion:

• Everyone is better off and happy. We are extracting all \$ from the table.
• Everything can be determined by market forces, from the price of the option, to liquidation thresholds.

Thus we can achieve Swaps + Options + Loans with simple Limit Orders.

KittenSwap v0.0 is at https://www.kittenswap.org/ and we will test our designs step by step.

## More from Kitten Finance

https://www.kitten.finance/

## What Are Nodes? — Nodes In a Nutshell

Get the Medium app