Skip to content

easyhat/AMM-algo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Automated Market Maker (AMM) Simulator

A Python implementation of an Automated Market Maker (AMM) using the constant product formula (( x \cdot y = k )) to simulate decentralized trading.

Features

  • Trade two assets: apples and potatoes.
  • Dynamic # based on the constant product formula.
  • Tracks liquidity pool state and price changes.

Usage

  1. Clone the repository and run the script:

    git clone https://github.com/easyhat/AMM-algo.git
    cd AMM-algo
    python amm.py
  2. Example output:

    Initial Pool: Apples: 100.00, Potatoes: 100.00
    Traded 10 apples for 9.09 potatoes.
    Updated Pool: Apples: 110.00, Potatoes: 90.91
    

API

  • trade_apples_for_potatoes(amount): Trade apples to get potatoes.
  • trade_potatoes_for_apples(amount): Trade potatoes to get apples.
  • get_price(): Get the current price of apples in potatoes.

Future Enhancements

  • Add fees for trades.
  • Support liquidity management.
  • Extend to multi-token pools.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages