AMM of Timeswap: An Option Magic Spell

Monkeyboi
Timeswap Chronicles
8 min readFeb 25, 2022

0 Preconditions

Before reading, please make sure you have a vague understanding of the AMM and XYZ = K model used by Timeswap, and what these X, Y, Z parameters represent. If not, you may refer to this awesome article.

1 Simple Description of AMM and its Importance

AMM stands for Automated Market Maker, which in essence is just a fancy term for the liquidity providers in a market, except that they are automatic/permissionless. In Traditional Financial (TradFi) markets, one needs to be certified/licensed to become a true market maker, because of the compliance and asset requirements. These factors create barriers for the vast majority of market participants, for they aren’t qualified in general. So, one is unlikely to receive the benefits of a market maker even though he bears his share of the market risk.

In Decentralized Finance (DeFi), however, it’s proven much more practical and convenient to adopt the AMM model over the orderbook model due to a series of reasons, such as low transaction throughput of the network, little to none barrier of entrance. In DeFi, you operate directly with the pools so you automatically become the market maker. Your position in the pool is represented with a certain amount of Liquidity Tokens, which denotes your share of ownership to the pool, proportional to its total liquidity.

2 An Alternative Perspective between Timeswap and Opyn for Option Trading

2.0 Put Option Definition

From Investopedia — A put option (or “put”) is a contract giving the option buyer the right, but not the obligation, to sell — or sell short — a specified amount of an underlying security at a predetermined price within a specified time frame.

From Monkeyboi — Let’s consider an example.

We have this MonKeyCoin (MKC🐒 for short) on the market for $10 each right now. You own 100 of these MKCs and are very concerned about the downside risk, thinking it might be worth only $5 in one month. So intuitively, you wanna sell these MKCs. But Monkeyboi told you not to worry because it might also go up to $15 in one month. So you are reluctant to sell now.

Here is where the put option plugs in. A put option allows the option buyer (you) to sell 100 MKCs at an agreed price, say $8 each to the option seller (some other guy, could be Monkeyboi). All you need to do is to pay some dollars (premium) to maintain the right, so Monkeyboi is willing to prepare some dollars, in this case $800 = 100 * $8/MKC, to ensure your right is protected, this is Monkeyboi’s obligation.

Now in one month, the price of MKC could fluctuate, and there are two scenarios. If the price stays above $8 (the strike price) in one month, you don’t necessarily have to sell the MKCs to Monkeyboi, because the price is better on the market, and you just give up your right to do so. Conversely, if the price goes below $8, to say $5 each. you execute the contract, getting your predetermined $800 protection.

2.1 Timeswap

Here, I’m going to focus on the borrow operation of Timeswap, because sometimes I view it as buying a put option. And for convenience, let’s forget about transaction fees, protocol fees, and slippage for the rest of the work.

In my opinion, the borrowers in the Timeswap protocol can be seen as put option buyers, because they have the actual power of deciding whether to pay back the debt or not before maturity, parallel to the right to execute the put option contract prior to expiry. By design, the borrow action requires a borrower to put forward and lock a certain amount of asset as collateral in exchange for a loan asset, and “promise” to pay back the loan with interest before maturity, very intuitive compared to a traditional loan from a bank. Now, with the borrowed asset, you find your alpha as the borrower.

Finally, when it comes to repaying the debt, there are two cases for any reasonable borrowers. If your required repaying amount (principal + interest, debt) is less valuable than your collateral, you choose to repay the loan asset and get back your more valuable collateral asset. On the contrary, if your debt is more costly than the collateral you locked up before, it makes no economic sense to retrieve the collateral asset. Notice here the borrower must return the borrowed asset before maturity, or else his collateral asset is automatically forfeited due to the Timeswap mechanism.

After we have gone through the exact procedure of borrowing, we may plug in those X, Y, Z parameters to see the magic.

  • In an alternative perspective, the loan asset you immediately receive as a borrower resembles the result of executing the put option, i.e., selling the collateral asset for the loan asset. The exact amount of loan asset you can receive is decided by the collateral factor Z, which is a fair market rate.
  • And before maturity, if you repay the loan asset to redeem the collateral asset, the interest you pay can be viewed as option premium, since the loan you received upfront protects you from the downside risk. And after that, your option contract gets reversed, you redo your position.

Here is a 1 on 1 comparison of concepts between Option and Timeswap.

2.2 Opyn

In comparison, Opyn is a good platform for option trading. It still follows the traditional order book model, and requires partially collateralized option minting and selling. This resembles the traditional option market in many ways. In principle, you just have to remember that Opyn is a vanilla on-chain option trading platform.

In detail, option trading is very complex and the pricing for options is heavily influenced by the market conditions. Namely, there are three main factors, the price difference between strike price and current market price of the underlying asset, the expiration date, and the implied volatility. These factors create the tricky problem of effective pricing, i.e., the traders cannot always have the best and fairest price in time. We all know that the crypto market is a very liquid and dynamic market off-chain, but when it comes to on-chain data updates, it gets laggy because of the network throughput. So when it comes to important and rare market opportunities (instantaneous huge ups and downs), the pricing and order actions of options might be lagging.

Besides, at the time of writing, Opyn only supports a very limited number of assets as underlying assets for option trading, and accepts large minimum assets to collateralize an option. The main underlying assets are USDC and WETH, meaning they have no support for the market of long-tail assets. Thus, the trading volume on Opyn is limited.

2.3 Difference

The major difference is that your opponent of trading in Timeswap is the pool itself, namely the collective lenders on the other side of borrowing, and vice versa. While in Opyn, your opponent is an actual trader who places a bid or ask order on the protocol platform. As a result, you simply don’t need an oracle for price feed, because the market is made in Timeswap. By design, there are arbitrageurs sniping on the pools, waiting for price inefficiencies, or opportunities in their perspectives. More on this in the last part.

Secondly, the intricate design of Timeswap means it’s a fair market itself, relying on no oracles, And there is no risk of liquidation for the borrowers, because they get to decide if they want to repay or default on the debt, depending on the value difference of debt and collateral.

Thirdly, you get to borrow and lend of all common and exotic assets if there is a pool available, And if not, anyone can be the initializer/liquidity provider, and define your own pool. This creates countless opportunities and any extra yield for the exotic asset hodlers.

2.4 Example

Let’s consider MKC🐒 one more time. Notice now the market price is $15 each.

In Timeswap, you are permissionless to do any defined operations, namely providing liquidity, borrowing, and lending. Let’s assume there is a pool with a maturity of 1 year, yearly interest rate of 10%, and collateral factor of 150%. Now if you borrow, you immediately receive 100% / 150% of the principal asset, 100 USDC for example, and lock 150 MKC. During this one year, you may choose to repay the debt [100 * (1 + 10%) USDC] anytime and get back those MKCs if the market goes on a monkey hype. On the other hand, you may also choose to default if MKC is down to less than $10 dollars each, because you have no incentives to pay back, so you get the downside protection of MKC.

In Opyn, suppose we have an MKC trading pair (actually we cannot), you have to accept a bid on the market of an option. And if there is no favorable price, you may not be able to cover your MKC. Plus, if you are partially collateralized with your position, you face the risks of liquidation if you are heavily undercollateralized.

3 AMM Comes into Play

So it finally boils down to one of the core questions in Timeswap. How exactly does Timeswap ditch the oracle? And should we even bother?

In all dynasties where God rules it all, an oracle from a holy man is the most straightforward instruction to follow. But that sounds a little too centralized, actually not fair at all. Oracles in DeFi are prone to manipulation and are notorious for some of the largest liquidations and attacks in history. But in order to get the price of digital assets like ETH off-chain, we need some kind of mechanism, like a price feed from a source? That’s just oracles again.

Here is where AMM comes into play! Timeswap avoids the oracle by eliminating them, and deploys arbitrary AMM pools for the market participants to interact. A permissionless AMM Timeswap pool can be initialized with any pair of ERC20 tokens, and set any arbitrary interest rate (Y), collateral factor (Z), and maturity, making them truly automatic/permissionless.

Now as reasonable market participants as DeFi degens yourselves, you’d trade towards your benefits. That is to say if you believe the interest rate (Y) and collateral factor (Z) is favorable for borrowing/lending, you will be happy to take the risk and earn rewards. And because your opponent of trades is the pool itself in AMM, you are trading and making the market. And by pool itself, I’m referring to the collective lenders/borrowers on the other side of your trade. Specifically, the certain level of balance is achieved/agreed among all pool participants, and manifests itself as the Y and Z parameters of the pool, aka interest rate and collateral factor. The two parameters are traded out and are convincing enough, because it reflects the willingness for risk profiles those market participants take.

And that’s where the AMM plugs in for Timeswap. A permissionless pool is all you need for measuring the market. This design makes oracle attacks, by definition, can never happen.

--

--