TimeSwap Automated Market Maker: A simple explainer

Jonathan Joestar
Timeswap Chronicles
5 min readFeb 26, 2022

In the crypto market there are a lot of platforms and opportunities to use and gain profits. Due to the nature of crypto assets and its high volatility, the investors need methods to act in an equally fast manner. This lead to the invention of Automated Market Makers to combat the speed and volatility of the market.

What are Automated Market Makers and how do they work?

An Automated Market Maker uses predetermined mathematical functions to evaluate the price of different assets by using smart contracts. I will use a simple formula used by Uniswap ( one of the biggest exchanges in the crypto world) to explain how an AMM calculates prices.

The formula is as followed:

Where x represents the amount of one asset inside a liquidity pool and y the amount of the corresponding asset in the other liquidity pool. What exactly does that mean? For example, you have one pool consisting of 1,000 ETH and a corresponding pool of 1,000 DAI, for simplicity reasons we value ETH and DAI each at $1 ( what a time to be alive, right?).

If we are using the formula above to determine the overall value of the assets in both liquidity pools we are getting the following:

1,000 x 1,000 = 1,000,000

This means, our combined liquidity pool has an overall value of $1,000,000.
This is important, because k is a constant value that’s needed to determine the price of the assets. But how exactly does the constant helps with determining the price of the assets? Due to k always being at the same value, the other assets have to be priced with a new value each time the pools change in amount of the asset. For example, if there’s someone who is interested in trading 200 ETH from the liquidity pool with his 200 DAI, that would result in a higher ETH price. The following example will show you why that happens:

In the first step, the trader adds 200 DAI to the liquidity pool, because he wants to get ETH out of it. This results in a total DAI allocation of 1.200 DAI in the DAI liquidity pool. However, because the total value of k has to have a constant value of $1,000,000, it has to reevaluate the price for the Assets before giving out ETH.

1,000 x 1,200 = 1,200,000
1,000,000/1200 = 833.33
1,000–833.33 = 166.67

This means, the person who added 200 DAI to the DAI liquidity pool, gets 166.67 ETH for it so the constant value of $1,000,000 would not change.

Due to this, the value of the ETH token has risen in price from $1 to $1.20(1,000 /833.33) and the price of DAI has fallen to $0.83 (1,000/1,200).
In simple terms, it reacts exactly like a supply and demand market. When one asset gets added to the pool, its value shrinks and the value of the other asset is rising.

What are AMMs used for?

Now that we understand how an AMM works, let’s talk about the use cases of an AMM.
AMMs are needed in the Crypto market, because they provide very fast liquidity. In addition, as we all know, the crypto market is very volatile and prices change every second. The current problem is, that AMMs are only used for providing liquidity, but there are many other processes in the crypto market that could profit from an AMM.

Why are AMMs better than TradFis?

In the crypto market, speed is everything, mere minutes can dictate of an actual gain or loss in a trade. If we look at TradFis it is obvious that it cannot compete with an AMM. In contrary to an AMM a TradFi is highly centralized and strictly regulated by the government, which for example leads to a teadious KYC (know your customer) process which can take up to weeks until you can use your TradFi platform. AMMs do not need any of that, because they work completely based on code and thus do not need things like a KYC.

Introducing Timeswap

To expand the use cases of an AMM, the team around timeswap expanded the shown formula with an additional variable and two new pools.

This opens up the usage of an AMM not only for “swapping” tokens, but also for lending and borrowing assets.
How does this work with the new formula and how is it possible to use it as an AMM for lending and borrowing?

First, we have to know, that timeswap is an oracle-less protocol, which allows ANYONE to open up different asset pools to lend and borrow without any permission from outside. This makes timeswap the first fully decentralized and COMPLETELY permission less protocol out there.

In theory that means, if you want to open a pool with ETH and DAI you can do that without a problem and without permission from anyone!

Using the new formula of timeswap shown above (x∗y∗z=k)
we can now open up a pool by adding a certain amount of liquidity, let’s say 100 ETH. When opening up a pool you are lending those 100 ETH to the protocol asset pool (A, x in the formula) and you are determining the amount of interest you want to get out of it (y). Let’s say we are opening up the pool with 100ETH and we want an 10% interest rate as a lender. And we are accepting DAI as our collateral. This Pool will be shown to everyone.

It is possible for everyone who has some DAI to borrow ETH from this pool and the formula takes over from here.

However, it is not only possible to borrow from that pool; everyone can jump in on that pool and lend more ETH assets or borrow DAI assets from it with individual interest rates! This is possible due to the formula, which will consider the personal interest.

How does it work from a user perspective?

First of all it is important to understand both possible sides a user can take, the lender and the borrower.

Lender
The lender is giving Assets into a liquidity pool and expects to get his asset back + a set amount of interest in that given asset.

Borrower
The borrower takes out a certain amount of an asset and locking away an amount of the corresponding token of the pool + interest.

For both parties the maturity date is important! This date will be set the moment the pool opens up and can be as long as the one who opens the pool wishes. When you are lending into the pool, you will not get back your lending position before the maturity date, keep that in mind.
On the other hand, the person who borrows from that pool can only repay his debt until the maturity date. If he fails to do that, his collateral will default and given to the lenders.

Conclusion

AMMs are playing a bigger role for the still developing crypto market and are essential to scale the market as well as making it more accessible to the everyday user without needing to rely on different entities, which control prices. They are an essential aspect of the complete Defi market and everything it stands for. In my opinion, true decentralization cannot be achieved without an AMM.

--

--