Skip to content

Aboudoc/Constant-Sum-AMM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Constant Sum Automated Market Maker

A very simple consant sum AMM
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Product Name Screen Shot

(back to top)

Built With

  • Hardhat
  • Ethers

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

  • npm

    npm install npm@latest -g
  • hardhat

    npm install --save-dev hardhat
    npm install @nomiclabs/hardhat-ethers @nomiclabs/hardhat-waffle

    run:

    npx hardhat

Installation

  1. Clone the repo
    git clone https://github.com/Aboudoc/Constant-Sum-AMM.git
  2. Install NPM packages
    npm install

(back to top)

Usage

If you need testnet funds, use the Alchemy testnet faucet.

This project shows a basic example of Constant Sum AMM

Constant sum AMM

Constant sum AMM (automated market maker) is a decentralized exchange that trades two tokens in the contract.

Users will be able to add liquidity and earn swap fees, swap tokens and remove liquidity

Why is it called constant sum?

The amount of token to come out of the trade is determined by the following equation.

X = amount of token A in the contract
Y = amount of token B in the contract
K = a constant that satisfies the following equation

X + Y = K

X + Y equals some constant K, hence the name constant sum.

This equation X + Y = K must be true before and after every swap.

dx = Amount of token A that came in from the swap
dy = Amount of token B that went out from the swap

# Before the trade
X + Y = K

# After the trade
X + dx + Y - dy = K

Since X + Y = K, replace K in the second equation X + dx + Y - dy = K with X + Y

X + dx + Y - dy = X + Y
dx - dy = 0
dx = dy

In other words, the amount of token coming in from a swap must equal the amount of token going out.

Note

This contract assumes that token0 and token1 both have same decimals

Consider fees = 3%

Further reading

(...soon)

Sources

(back to top)

Roadmap

  • Further reading
  • Deploy script
  • Unit test

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Reda Aboutika - @twitter - reda.aboutika@gmail.com

Project Link: https://github.com/Aboudoc/Constant-Sum-AMM.git

(back to top)

Acknowledgments

(back to top)

About

A basic constant sum automated market maker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published