# Timeswap AMM

A Timeswap pool uses the Duration Weighted Constant Product automated market maker (AMM) similar to Uniswap.
Let's assume a Timeswap pool of Token A-Token B ; order doesn't matter for asset and collateral token which means the following two pairs can exist : (Token A - Token B) - (Asset - Collateral) or (Token A - Token B)- (Collateral - Asset).

## Pool Terminology: • Token Pair: Every pool is denominated by the pair of tokens being lent and borrowed for eg. Token A- Token B (ETH/DAI in the image shown above) where if one of them is the asset to be lent/borrowed then the other is collateral to be locked
• Maturity Time: Every pool has a maturity time before which all the lending/borrowing positions open and settle.
• Transition Price / Strike Price (K): The price at which a borrower decides whether or not he wants to exercise his right to sell the locked collateral to the lenders is what we are calling the transition price, which in the context of the options is simply the strike price. It is the ratio of debt to collateral for transactions. So for every borrower his debt is fixed which is equivalent to collateral locked times transition price. ## Timeswap's Constant Product automated market maker (AMM)

Timeswap V2 functions on a three-variable AMM, a hybrid of both constant sum and constant product. The AMM helps discover the Interest Rate (APR) and CDP (collateral factor) of the pool. Timeswap pool mechanics are designed in a way such that the pools are always over-collateralised via a rebalancing mechanism. ### Terminologies of the Timeswap V2 AMM equation

In the above AMM equation, x+y is the amount of Collateral Claim Tokens (CCT) in the pool, where,
x is the reserves of CCT Token A in the pool
y is the reserves of CCT Token B in the pool
z is the reserves of Bond Tokens(BT) per second in the pool (for the duration of the pool)
K is the Constant Product Invariant
$K=L^2$
I is the marginal interest rate per second of the BT per CCT
$I = z/(x+y)$ Let d be the remaining duration of the pool, thus d*z is the total number of bond tokens (BT) in the pool. While z remains unchanged, d*z keeps decreasing as d reduces with time. For a detailed explanation of the simplification of the AMM below, please refer to the "Different Scenarios for lending and for borrowing " section in "How it Works" page

### Simplification of the AMM

Let us assume a pool where Token A is ETH and Token B is USDC in the following examples. If x is the reserves of CCT ETH tokens in the pool and y is the reserves of CCT USDC tokens in the pool
​ When x=0 i.e. when pool has only CCT USDC
$yz=L^2$
When y=0 i.e. when the pool has only CCT ETH
$xz=L^2$ 