Skip to content

Commit

Permalink
Merge pull request #24 from compolabs/spark-repo-file-refactor
Browse files Browse the repository at this point in the history
♻ ️renamed folders removed old stuff
  • Loading branch information
chlenc authored Apr 9, 2024
2 parents 72a7f75 + f19c3d2 commit 39944c8
Show file tree
Hide file tree
Showing 52 changed files with 840 additions and 451 deletions.
908 changes: 786 additions & 122 deletions Cargo.lock

Large diffs are not rendered by default.

31 changes: 3 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TODO: this has to be changed into a workspace
workspace = { members = [ "spark","spark-market"] }
workspace = { members = ["spark-cli", "spark-market-sdk", "market-contract"] }
[package]
name = "orderbook"
name = "spark-clob"
description = "A cargo-generate template for Rust + Sway integration testing."
version = "0.1.0"
edition = "2021"
Expand All @@ -14,32 +14,7 @@ rand = "0.8.5"
tokio = { version = "1.12", features = ["rt", "macros"] }
src20_sdk = { git = "https://github.com/compolabs/src-20.git", branch = "master" }
dotenv = "0.15.0"
anyhow = "1.0.81"

[dev-dependencies]
pretty_assertions = "1"

[[test]]
harness = true
name = "integration_tests"
path = "tests/harness.rs"


[[bin]]
name = "create_market"
path = "scripts/create_market.rs"

[[bin]]
name = "create_order"
path = "scripts/create_order.rs"

[[bin]]
name = "cancel_order"
path = "scripts/cancel_order.rs"

[[bin]]
name = "deploy"
path = "scripts/deploy.rs"

[[bin]]
name = "match_orders"
path = "scripts/match_orders.rs"
File renamed without changes.
29 changes: 29 additions & 0 deletions _src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pub mod constants;
pub mod orderbook_utils;

pub fn print_title(title: &str) {
println!(
r#"
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗██╗ ██╗████████╗██╗ ██╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗██╔════╝██╔══██╗██╔══██╗██║██║ ██║╚══██╔══╝╚██╗ ██╔╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║███████╗███████║██████╔╝██║██║ ██║ ██║ ╚████╔╝
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║╚════██║██╔══██║██╔══██╗██║██║ ██║ ██║ ╚██╔╝
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝███████║██║ ██║██████╔╝██║███████╗██║ ██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝
██╗ █████╗ ██████╗ ███████╗
██║ ██╔══██╗██╔══██╗██╔════╝
██║ ███████║██████╔╝███████╗
██║ ██╔══██║██╔══██╗╚════██║
███████╗██║ ██║██████╔╝███████║
╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝
Predicate based orderbook
🏁 {title} 🏁
"#
);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod success {

// ✅ buyOrder.orderPrice > sellOrder.orderPrice & buyOrder.baseSize > sellOrder.baseSize
#[tokio::test]
async fn match1() {
async fn greater_buy_price_and_greater_buy_amount() {
let buy_price = 46_000_f64;
let sell_price = 45_000_f64;
let buy_size = 2_f64;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions market-contract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "contract"
[package]
name = "market-contract"
version = "0.0.0"
authors = ["Compo Labs"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion market-contract/tests/functions/core/cancel_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::{
interface::core::{cancel_order, deposit, open_order},
setup::{setup, Defaults, OrderType},
};

mod success {

use super::*;
Expand Down
9 changes: 5 additions & 4 deletions market-contract/tests/utils/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ use fuels::{
types::Identity,
};

// PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("market-contract/out/debug/market-contract.bin");
const MARKET_CONTRACT_BINARY_PATH: &str = "../market-contract/out/debug/market-contract.bin";
const MARKET_CONTRACT_STORAGE_PATH: &str =
"../market-contract/out/debug/market-contract-storage_slots.json";
abigen!(Contract(
name = "Market",
abi = "./out/debug/market-contract-abi.json"
abi = "./market-contract/out/debug/market-contract-abi.json"
));

const MARKET_CONTRACT_BINARY_PATH: &str = "./out/debug/market-contract.bin";
const MARKET_CONTRACT_STORAGE_PATH: &str = "./out/debug/market-contract-storage_slots.json";

pub(crate) struct Assets {
pub(crate) base: Asset,
pub(crate) quote: Asset,
Expand Down
32 changes: 0 additions & 32 deletions scripts/cancel_order.rs

This file was deleted.

42 changes: 0 additions & 42 deletions scripts/create_market.rs

This file was deleted.

70 changes: 0 additions & 70 deletions scripts/create_order.rs

This file was deleted.

36 changes: 0 additions & 36 deletions scripts/deploy.rs

This file was deleted.

71 changes: 0 additions & 71 deletions scripts/match_orders.rs

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions spark/Cargo.toml → spark-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "spark"
name = "spark-cli"
version = "0.1.0"
edition = "2021"

Expand All @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0.81"
clap = { version = "4.5.4", features = ["derive"] }
spark-market = { path = "../spark-market" }
spark-market-sdk = { path = "../spark-market-sdk" }
fuels = { version = "0.55.0", features = ["fuel-core-lib"] }
dotenv = "0.15.0"
tokio = { version = "1.12", features = ["rt", "macros"] }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 39944c8

Please sign in to comment.