# 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.91840386,"math_prob":0.9957847,"size":1836,"snap":"2023-14-2023-23","text_gpt3_token_len":384,"char_repetition_ratio":0.139738,"word_repetition_ratio":0.091803275,"special_character_ratio":0.1949891,"punctuation_ratio":0.049079753,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99752283,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-05-28T23:26:04Z\",\"WARC-Record-ID\":\"<urn:uuid:1f8cb092-4c25-4d21-bc9e-676ce70c5b22>\",\"Content-Length\":\"179456\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:25ddfc83-818a-4ec4-97f0-7799db5770c0>\",\"WARC-Concurrent-To\":\"<urn:uuid:cf0ae2ea-2236-42f8-8b6b-4c4f053b273a>\",\"WARC-IP-Address\":\"104.18.3.117\",\"WARC-Target-URI\":\"https://timeswap.gitbook.io/timeswap/getting-started/amm\",\"WARC-Payload-Digest\":\"sha1:KF3TJVU7VHGM37BABHZMACY4QYGMITOV\",\"WARC-Block-Digest\":\"sha1:5P3EZQLQS5U3OLB5RNKHZ7VROAWZDYDK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224644571.22_warc_CC-MAIN-20230528214404-20230529004404-00243.warc.gz\"}"}