# 3 variable AMM

Timeswap works on a unique 3 variable constant product equation where interest rates & collateral factors are all market-driven and there is no dependency on oracles & liquidators. This makes us a complete self-sufficient protocol that is fully permissionless & oracle-less. Anybody can create a pool with any ERC20 token as collateral & any other ERC20 token as an asset being lent/borrowed.
Inspired from Uniswap's constant product equation, Timeswap works on a 3 variable constant product formula-

### $X\times Y\times Z=K$ $X=$
Principal Pool is a virtual pool and is equal to the amount of assets in the pool that can be borrowed. It's equal to the sum of the assets deposited by the lenders
$Y=$
Interest Rate Pool is a virtual pool that determines the interest amount per second of the pool, such that ratio
$\frac{Y}{X}$
is the per second average interest rate for the duration of the transaction to the maturity of the pool.
$Z=$
Collateral Factor Pool is a virtual pool that determines the collateral to be locked by the borrowers such that ratio
$\frac{X}{Z}$
is the average collateral factor. It's used to calculate the expected average loan to value at the time of the transaction
$K=$
Invariance Constant product
Additionally, there are two other pools :
$C=$
Collateral Locked Pool and is equal to the amount of ERC20 collateral tokens locked in the pool by borrowers
$A =$
Asset Pool and is equal to the amount of ERC20 asset tokens locked in the pool. It is the sum of assets lent by lenders & the debt paid by the borrowers
While interacting with the pools, Lenders & Borrowers change the variables such that constant product is always maintained. Lending more assets into the asset pool decreases the interest & Collateral value to be locked, whereas, borrowing more assets from the asset pool increases the interest & Collateral value to be locked.