Skip to content
 
 

Repository files navigation

ZoroSwap

built for Miden Chat on Telegram Chat on Twitter

This repository contains an Oracle-informed AMM for the Miden blockchain.

You can find our testnet deployment here: https://zoroswap.com.

Table of Contents

Curve Setup

Zoro uses a pluggable curve implementation for AMM calculations. By default, it uses a simple linear curve (DummyCurve) to demonstrate its functionality.

Curve Feature Flag Repository Use Case
DummyCurve default (always available) Public in zoro_primitives Development, testing, reference
ZoroCurve --features zoro-curve-local Private Production, proprietary algorithm

Using the Default Curve

The default build uses the DummyCurve implementation:

# Make sure that there is a placeholder crate in the folder above
# the clone of this repository.
#
# We need this folder structure:
# zoroswap/
# ├── Cargo.toml
# └── ...
# zoro-curve/
# ├── Cargo.toml
# └── ...
cargo new --name zoro_curve ../zoro-curve

cargo build

Using the Proprietary Curve

Requires a folder structure where both repositories (zoroswap and zoro-curve) are checked out on the same level:

zoroswap/
├── Cargo.toml
└── ...
zoro-curve/
├── Cargo.toml
└── ...
cargo run --bin server --features zoro-curve-local
cargo test --features zoro-curve-local
cargo install --features zoro-curve-local

ZoroSwap Setup

Make sure you have followed the above instructions for setting up the curve!

1. Copy environment and app configs

cp .env-example .env
cp config-example.toml config.toml
cp faucets-example.toml faucets.toml

2. Spawn faucets

cargo run --release --bin spawn_faucets

It will print out 2 faucet ids. Put them in corresponding entries faucet_id under [[liquidity_pools]] section in config.toml file.

3. Spawn pool

cargo run --release --bin spawn_pools

It will print out pool id (at the start of program output). Put it into corresponding entry pool_account_id section in config.toml file.

4. Run the server

cargo run --release --bin server

End-to-End Tests

1. Copy store to testing store

cp store.sqlite3 testing_store.sqlite3

This is required so client on server and client on test do not share the same store as then notes commited in test would go into output_notes but the server expects notes in input_notes.

2. Run the e2e test

Via public note:

cargo test --release e2e_public_note -- --exact --nocapture

Private note via endpoint:

cargo test --release e2e_private_note -- --exact --nocapture
  1. Create an account with a basic wallet component (user).
  2. Mint some token from faucets we created at setup.
  3. Create a ZOROSWAP note requesting a swap of minted assets in line with current oracle prices and send it as a public note to testnet or via endpoint.
  4. Server should pick up the emitted note, consume it and execute against the pool we created earlier and emit new P2ID targeted at the user with swapped assets.
  5. Consume the P2ID emitted by the server concluding the test.

About

ZoroSwap is an Oracle-informed AMM for the Miden blockchain.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages