Skip to content

Files

Latest commit

51d2171 · Mar 29, 2024

History

History
This branch is 1 commit ahead of, 57 commits behind FuelLabs/sway-applications:master.

AMM

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 1, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024
Mar 29, 2024

README.md

automated market maker logo

Overview

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

    • p r i c e a s s e t   A p r i c e a s s e t   B = t o t a l   l i q u i d i t y
  • Provide a liquidity miner fee of 1 333 0.3

    NOTE The miner fee can be modified per asset pair

Project structure

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

Running the project

User interface

TODO: The user interface does not currently exist therefore its README.md and SPECIFICATION.md are empty.

Project

In order to run the subsequent commands change into the following directory /path/to/AMM/project/<here>.

Program compilation

forc build --locked

Running the tests

Before running the tests the programs must be compiled with the command above.

cargo test --locked
NOTE

The script tests have currently been commented out as they fail randomly.