An automated market maker (AMM) is a type of decentralized exchange protocol that determines asset prices algorithmically through a conservation function. Trades on an AMM take place between the user and the contract, rather than between two users. The liquidity pool of assets in an AMM is supplied by the users. Providing liquidity is incentivized via liquidity miner rewards.
This application supports
- Depositing assets
- Withdrawing assets
- Adding liquidity using deposited assets
- Removing liquidity
- Swapping assets
The contracts are designed to
-
Support liquidity pools that consist of two assets
-
Use a conservation function which keeps the total liquidity at a constant ratio
$price_{asset\ A} * price_{asset\ B} = total\ liquidity$
-
Provide a liquidity miner fee of
$\frac1{333} \approx 0.3%$ NOTE The miner fee can be modified per asset pair
AMM
├── AMM-contract
├── exchange-contract
├── libraries
│ └── src/interface.sw
├── atomic-add-liquidity
├── swap-exact-input
└── swap-exact-output
├── test-utils
└── src/lib.rs
├── README.md
└── SPECIFICATION.md
All contracts and scripts have the structure:
contract or script/
├── src/main.sw
└── tests/harness.rs
TODO: The user interface does not currently exist therefore its README.md and SPECIFICATION.md are empty.
In order to run the subsequent commands change into the following directory /path/to/AMM/project/<here>
.
forc build --locked
Before running the tests the programs must be compiled with the command above.
cargo test --locked
The script tests have currently been commented out as they fail randomly.