From f83e27345c3532e67f410af7ec8e0ba42bdd1ce6 Mon Sep 17 00:00:00 2001 From: alexey Date: Tue, 9 Apr 2024 16:47:09 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=E2=99=BB=20=EF=B8=8Frenamed=20folders=20re?= =?UTF-8?q?moved=20old=20stuff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- market-contract/Cargo.toml | 2 +- .../tests/functions/core/cancel_order.rs | 2 +- {spark-market => spark-market-sdk}/Cargo.toml | 0 {spark-market => spark-market-sdk}/src/lib.rs | 0 src/constants.rs | 13 -- src/lib.rs | 29 --- src/orderbook_utils.rs | 209 ------------------ 7 files changed, 2 insertions(+), 253 deletions(-) rename {spark-market => spark-market-sdk}/Cargo.toml (100%) rename {spark-market => spark-market-sdk}/src/lib.rs (100%) delete mode 100644 src/constants.rs delete mode 100644 src/lib.rs delete mode 100644 src/orderbook_utils.rs diff --git a/market-contract/Cargo.toml b/market-contract/Cargo.toml index 7b835ea..b2f52d1 100644 --- a/market-contract/Cargo.toml +++ b/market-contract/Cargo.toml @@ -1,5 +1,5 @@ [project] -name = "contract" +name = "market-contract" version = "0.0.0" authors = ["Compo Labs"] edition = "2021" diff --git a/market-contract/tests/functions/core/cancel_order.rs b/market-contract/tests/functions/core/cancel_order.rs index 226ded4..f62a5c8 100644 --- a/market-contract/tests/functions/core/cancel_order.rs +++ b/market-contract/tests/functions/core/cancel_order.rs @@ -2,7 +2,7 @@ use crate::utils::{ interface::core::{cancel_order, deposit, open_order}, setup::{setup, Defaults, OrderType}, }; - + mod success { use super::*; diff --git a/spark-market/Cargo.toml b/spark-market-sdk/Cargo.toml similarity index 100% rename from spark-market/Cargo.toml rename to spark-market-sdk/Cargo.toml diff --git a/spark-market/src/lib.rs b/spark-market-sdk/src/lib.rs similarity index 100% rename from spark-market/src/lib.rs rename to spark-market-sdk/src/lib.rs diff --git a/src/constants.rs b/src/constants.rs deleted file mode 100644 index 0f0692e..0000000 --- a/src/constants.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub const RPC: &str = "beta-5.fuel.network"; - -pub const ORDERBOOK_CONTRACT_ID: &str = - "1ad65e67c522dc0355f17792417aeb3269b5adc84ba13549b94b98b2db34c1e0"; - -pub const TOKEN_CONTRACT_ID: &str = - "0x6bd9643c9279204b474a778dea7f923226060cb94a4c61c5aae015cf96b5aad2"; -pub const USDC_ASSET_ID_STR: &str = - "0x0450e4d385cbd2914f74505f18f01587cc4f4ad1fdef4b80cbde2a8155a86d72"; -pub const BTC_ASSET_ID_STR: &str = - "0x593b117a05f5ea64b39ba1f9bc3fb7e7a791c9be130e28376ad552eacdb3b746"; -pub const UNI_ASSET_ID_STR: &str = - "0xae37bc0feb66e60a89e301d450bb4640aa9bd7cedd856e253e23989eae536e92"; diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 54ed73e..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,29 +0,0 @@ -pub mod constants; -pub mod orderbook_utils; - -pub fn print_title(title: &str) { - println!( - r#" - - ██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗██╗ ██╗████████╗██╗ ██╗ -██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗██╔════╝██╔══██╗██╔══██╗██║██║ ██║╚══██╔══╝╚██╗ ██╔╝ -██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║███████╗███████║██████╔╝██║██║ ██║ ██║ ╚████╔╝ -██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║╚════██║██╔══██║██╔══██╗██║██║ ██║ ██║ ╚██╔╝ -╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝███████║██║ ██║██████╔╝██║███████╗██║ ██║ ██║ - ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ - -██╗ █████╗ ██████╗ ███████╗ -██║ ██╔══██╗██╔══██╗██╔════╝ -██║ ███████║██████╔╝███████╗ -██║ ██╔══██║██╔══██╗╚════██║ -███████╗██║ ██║██████╔╝███████║ -╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝ - - -Predicate based orderbook - -🏁 {title} 🏁 - -"# - ); -} diff --git a/src/orderbook_utils.rs b/src/orderbook_utils.rs deleted file mode 100644 index 0057a44..0000000 --- a/src/orderbook_utils.rs +++ /dev/null @@ -1,209 +0,0 @@ -use std::str::FromStr; - -use fuels::{ - accounts::wallet::WalletUnlocked, - macros::abigen, - programs::{ - call_response::FuelCallResponse, - call_utils::TxDependencyExtension, - contract::{CallParameters, Contract, LoadConfiguration}, - }, - types::{bech32::Bech32Address, transaction::TxPolicies, AssetId, Bits256, ContractId}, -}; -use rand::Rng; - -use self::abigen_bindings::orderbook_contract_mod; - -abigen!(Contract( - name = "OrderbookContract", - abi = "contract/out/debug/orderbook-abi.json" -)); - -pub struct Orderbook { - pub instance: OrderbookContract, - pub quote_token: AssetId, - pub quote_token_decimals: u64, - pub price_decimals: u64, -} - -impl Orderbook { - pub async fn _create_market( - &self, - asset_id: AssetId, - decimal: u32, - ) -> Result, fuels::types::errors::Error> { - self.instance - .methods() - .create_market(asset_id, decimal) - .call() - .await - } - - pub async fn get_market_by_id( - &self, - asset_id: AssetId, - ) -> Result, fuels::types::errors::Error> { - self.instance - .methods() - .get_market_by_id(asset_id) - .simulate() - .await - } - - pub async fn market_exists( - &self, - asset_id: AssetId, - ) -> Result, fuels::types::errors::Error> { - self.instance - .methods() - .market_exists(asset_id) - .simulate() - .await - } - - pub async fn order_by_id( - &self, - id: &Bits256, - ) -> Result>, fuels::types::errors::Error> { - self.instance.methods().order_by_id(*id).simulate().await - } - - pub async fn orders_by_trader( - &self, - trader: &Bech32Address, - ) -> Result>, fuels::types::errors::Error> { - self.instance - .methods() - .orders_by_trader(trader) - .simulate() - .await - } - - pub async fn open_order( - &self, - base_token: AssetId, - base_size: i64, - base_price: u64, - ) -> Result, fuels::types::errors::Error> { - let call_params: CallParameters = if base_size.is_negative() { - CallParameters::default() - .with_asset_id(base_token) - .with_amount(base_size.abs() as u64) - } else { - let market = self.get_market_by_id(base_token).await.unwrap().value; - let quote_size = base_size.abs() as u128 * base_price as u128 - / 10u128.pow( - self.price_decimals as u32 + market.asset_decimals - - self.quote_token_decimals as u32, - ); - CallParameters::default() - .with_asset_id(self.quote_token) - .with_amount(quote_size as u64) - }; - - self.instance - .methods() - .open_order( - base_token, - I64::new(base_size.unsigned_abs(), base_size < 0), - base_price, - ) - .append_variable_outputs(2) - .call_params(call_params) - .unwrap() - .call() - .await - } - - pub async fn cancel_order( - &self, - order_id: &Bits256, - ) -> Result, fuels::types::errors::Error> { - self.instance - .methods() - .cancel_order(*order_id) - .append_variable_outputs(1) - .call() - .await - } - - pub async fn match_orders( - &self, - sell_order_id: &Bits256, - buy_order_id: &Bits256, - ) -> Result, fuels::types::errors::Error> { - self.instance - .methods() - .match_orders(*sell_order_id, *buy_order_id) - .append_variable_outputs(2) - .call() - .await - } - - pub fn with_account(&self, account: &WalletUnlocked) -> Self { - Self { - instance: self.instance.with_account(account.clone()).unwrap(), - quote_token: self.quote_token, - quote_token_decimals: self.quote_token_decimals, - price_decimals: self.price_decimals, - } - } - - pub async fn new(wallet: &WalletUnlocked, contract_id: &str) -> Self { - let instance = OrderbookContract::new( - &ContractId::from_str(contract_id).unwrap().into(), - wallet.clone(), - ); - let (quote_token, quote_token_decimals, price_decimals) = instance - .methods() - .get_configurables() - .simulate() - .await - .unwrap() - .value; - Orderbook { - instance, - quote_token, - quote_token_decimals: quote_token_decimals as u64, - price_decimals: price_decimals as u64, - } - } - - pub async fn deploy( - wallet: &WalletUnlocked, - quote_token: AssetId, - quote_token_decimals: u64, - price_decimals: u64, - ) -> Self { - let mut rng = rand::thread_rng(); - let salt = rng.gen::<[u8; 32]>(); - - let configurables = OrderbookContractConfigurables::default() - .with_QUOTE_TOKEN(quote_token) - .with_QUOTE_TOKEN_DECIMALS(quote_token_decimals.try_into().unwrap()) - .with_PRICE_DECIMALS(price_decimals.try_into().unwrap()); - let config = LoadConfiguration::default().with_configurables(configurables); - - let id = Contract::load_from("contract/out/debug/orderbook.bin", config) - .unwrap() - .with_salt(salt) - .deploy(wallet, TxPolicies::default().with_gas_price(1)) - .await - .unwrap(); - - let instance = OrderbookContract::new(id, wallet.clone()); - - Orderbook { - instance, - quote_token, - quote_token_decimals, - price_decimals, - } - } -} - -impl I64 { - pub fn as_i64(self) -> i64 { - self.value as i64 * if self.negative { -1 } else { 1 } - } -} From 4482a26c8629535d40f885767c8b6f12ab13a8c7 Mon Sep 17 00:00:00 2001 From: alexey Date: Tue, 9 Apr 2024 17:08:13 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=E2=99=BB=20=EF=B8=8Frenamed=20folders=20re?= =?UTF-8?q?moved=20old=20stuff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 886 +++++++++++++++--- Cargo.toml | 31 +- _src/constants.rs | 13 + _src/lib.rs | 29 + _src/orderbook_utils.rs | 209 +++++ {tests => _tests}/common_test_cases/mod.rs | 0 .../open_base_token_order_cancel.rs | 0 ...ote_token_order_cancel_by_reverse_order.rs | 0 {tests => _tests}/harness.rs | 0 .../match_test/match_orders_cases.rs | 2 +- {tests => _tests}/match_test/match_test.rs | 0 {tests => _tests}/match_test/mod.rs | 0 {tests => _tests}/utils/check_balance.rs | 0 .../utils/match_orders_case_utils.rs | 0 {tests => _tests}/utils/mint_tokens.rs | 0 {tests => _tests}/utils/mod.rs | 0 {tests => _tests}/utils/setup.rs | 0 scripts/cancel_order.rs | 32 - scripts/create_market.rs | 42 - scripts/create_order.rs | 70 -- scripts/deploy.rs | 36 - scripts/match_orders.rs | 71 -- {spark => spark-cli}/Cargo.lock | 0 {spark => spark-cli}/Cargo.toml | 4 +- {spark => spark-cli}/README.md | 0 {spark => spark-cli}/src/commands/cli.rs | 0 .../src/commands/core/batch_fulfill.rs | 0 {spark => spark-cli}/src/commands/core/cli.rs | 0 .../src/commands/core/close_order.rs | 0 .../src/commands/core/deploy.rs | 0 .../src/commands/core/deposit.rs | 0 {spark => spark-cli}/src/commands/core/mod.rs | 0 .../src/commands/core/open_order.rs | 0 .../src/commands/core/set_fee.rs | 0 .../src/commands/core/withdraw.rs | 0 .../src/commands/info/account.rs | 0 {spark => spark-cli}/src/commands/info/cli.rs | 0 .../src/commands/info/config.rs | 0 {spark => spark-cli}/src/commands/info/fee.rs | 0 {spark => spark-cli}/src/commands/info/mod.rs | 0 .../src/commands/info/order.rs | 0 .../src/commands/info/order_id.rs | 0 .../src/commands/info/user_orders.rs | 0 {spark => spark-cli}/src/commands/mod.rs | 0 {spark => spark-cli}/src/main.rs | 0 {spark => spark-cli}/src/utils.rs | 0 spark-market-sdk/Cargo.toml | 2 +- 47 files changed, 1033 insertions(+), 394 deletions(-) create mode 100644 _src/constants.rs create mode 100644 _src/lib.rs create mode 100644 _src/orderbook_utils.rs rename {tests => _tests}/common_test_cases/mod.rs (100%) rename {tests => _tests}/common_test_cases/open_base_token_order_cancel.rs (100%) rename {tests => _tests}/common_test_cases/open_quote_token_order_cancel_by_reverse_order.rs (100%) rename {tests => _tests}/harness.rs (100%) rename {tests => _tests}/match_test/match_orders_cases.rs (99%) rename {tests => _tests}/match_test/match_test.rs (100%) rename {tests => _tests}/match_test/mod.rs (100%) rename {tests => _tests}/utils/check_balance.rs (100%) rename {tests => _tests}/utils/match_orders_case_utils.rs (100%) rename {tests => _tests}/utils/mint_tokens.rs (100%) rename {tests => _tests}/utils/mod.rs (100%) rename {tests => _tests}/utils/setup.rs (100%) delete mode 100644 scripts/cancel_order.rs delete mode 100644 scripts/create_market.rs delete mode 100644 scripts/create_order.rs delete mode 100644 scripts/deploy.rs delete mode 100644 scripts/match_orders.rs rename {spark => spark-cli}/Cargo.lock (100%) rename {spark => spark-cli}/Cargo.toml (83%) rename {spark => spark-cli}/README.md (100%) rename {spark => spark-cli}/src/commands/cli.rs (100%) rename {spark => spark-cli}/src/commands/core/batch_fulfill.rs (100%) rename {spark => spark-cli}/src/commands/core/cli.rs (100%) rename {spark => spark-cli}/src/commands/core/close_order.rs (100%) rename {spark => spark-cli}/src/commands/core/deploy.rs (100%) rename {spark => spark-cli}/src/commands/core/deposit.rs (100%) rename {spark => spark-cli}/src/commands/core/mod.rs (100%) rename {spark => spark-cli}/src/commands/core/open_order.rs (100%) rename {spark => spark-cli}/src/commands/core/set_fee.rs (100%) rename {spark => spark-cli}/src/commands/core/withdraw.rs (100%) rename {spark => spark-cli}/src/commands/info/account.rs (100%) rename {spark => spark-cli}/src/commands/info/cli.rs (100%) rename {spark => spark-cli}/src/commands/info/config.rs (100%) rename {spark => spark-cli}/src/commands/info/fee.rs (100%) rename {spark => spark-cli}/src/commands/info/mod.rs (100%) rename {spark => spark-cli}/src/commands/info/order.rs (100%) rename {spark => spark-cli}/src/commands/info/order_id.rs (100%) rename {spark => spark-cli}/src/commands/info/user_orders.rs (100%) rename {spark => spark-cli}/src/commands/mod.rs (100%) rename {spark => spark-cli}/src/main.rs (100%) rename {spark => spark-cli}/src/utils.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index bfff0db..f28bc53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1152,6 +1152,23 @@ dependencies = [ "thiserror", ] +[[package]] +name = "fuel-abi-types" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2351bb0b743c23ac13ac2559756b3929502cd6e29091f2e5302fb9a1bdddaf35" +dependencies = [ + "itertools 0.10.5", + "lazy_static", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "syn 2.0.50", + "thiserror", +] + [[package]] name = "fuel-asm" version = "0.43.2" @@ -1159,9 +1176,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ea884860261efdc7300b63db7972cb0e08e8f5379495ad7cdd2bdb7c0cc4623" dependencies = [ "bitflags 2.4.2", - "fuel-types", + "fuel-types 0.43.2", "serde", - "strum", + "strum 0.24.1", +] + +[[package]] +name = "fuel-asm" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1b088ac4762d59736b90803db239f96c66f2a1a2c616715ef0a9c196b58edc9" +dependencies = [ + "bitflags 2.4.2", + "fuel-types 0.47.1", + "serde", + "strum 0.24.1", ] [[package]] @@ -1177,18 +1206,18 @@ dependencies = [ "clap", "derive_more", "enum-iterator", - "fuel-core-chain-config", - "fuel-core-consensus-module", - "fuel-core-database", - "fuel-core-executor", - "fuel-core-importer", - "fuel-core-metrics", - "fuel-core-poa", - "fuel-core-producer", - "fuel-core-services", - "fuel-core-storage", - "fuel-core-txpool", - "fuel-core-types", + "fuel-core-chain-config 0.22.1", + "fuel-core-consensus-module 0.22.1", + "fuel-core-database 0.22.1", + "fuel-core-executor 0.22.1", + "fuel-core-importer 0.22.1", + "fuel-core-metrics 0.22.1", + "fuel-core-poa 0.22.1", + "fuel-core-producer 0.22.1", + "fuel-core-services 0.22.1", + "fuel-core-storage 0.22.1", + "fuel-core-txpool 0.22.1", + "fuel-core-types 0.22.1", "futures", "hex", "hyper", @@ -1197,8 +1226,50 @@ dependencies = [ "rand", "serde", "serde_json", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", + "thiserror", + "tokio", + "tokio-stream", + "tower-http", + "tracing", + "uuid 1.7.0", +] + +[[package]] +name = "fuel-core" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2a66b67d7733617be157290da963f58be8a3152eaba839ad437f488860b60de" +dependencies = [ + "anyhow", + "async-graphql", + "async-trait", + "axum", + "clap", + "derive_more", + "enum-iterator", + "fuel-core-chain-config 0.23.0", + "fuel-core-consensus-module 0.23.0", + "fuel-core-database 0.23.0", + "fuel-core-executor 0.23.0", + "fuel-core-importer 0.23.0", + "fuel-core-metrics 0.23.0", + "fuel-core-poa 0.23.0", + "fuel-core-producer 0.23.0", + "fuel-core-services 0.23.0", + "fuel-core-storage 0.23.0", + "fuel-core-txpool 0.23.0", + "fuel-core-types 0.23.0", + "futures", + "hex", + "hyper", + "itertools 0.10.5", + "rand", + "serde", + "serde_json", + "strum 0.25.0", + "strum_macros 0.25.3", "thiserror", "tokio", "tokio-stream", @@ -1215,8 +1286,27 @@ checksum = "8c4002461d438755868c4fd849b31c86ce96d8dbb8c3d2dc373fca2798807c9f" dependencies = [ "anyhow", "bech32", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", + "hex", + "itertools 0.10.5", + "postcard", + "serde", + "serde_json", + "serde_with 1.14.0", + "tracing", +] + +[[package]] +name = "fuel-core-chain-config" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc2032184b86cd7e54d0ca6f7c7db7419552048484e2cfa6d7dc346eefb4907" +dependencies = [ + "anyhow", + "bech32", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", "hex", "itertools 0.10.5", "postcard", @@ -1236,7 +1326,31 @@ dependencies = [ "cynic", "derive_more", "eventsource-client", - "fuel-core-types", + "fuel-core-types 0.22.1", + "futures", + "hex", + "hyper-rustls 0.24.2", + "itertools 0.10.5", + "reqwest", + "schemafy_lib", + "serde", + "serde_json", + "tai64", + "thiserror", + "tracing", +] + +[[package]] +name = "fuel-core-client" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19e4fe4535372749e5b38d58c29a7904b3bc95e0429e6ae2544cfa8417a39c4" +dependencies = [ + "anyhow", + "cynic", + "derive_more", + "eventsource-client", + "fuel-core-types 0.23.0", "futures", "hex", "hyper-rustls 0.24.2", @@ -1257,12 +1371,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae7d7e15deb74b573a23446c25309b0e249bf9ba819911e4a3b805f738ad1c75" dependencies = [ "anyhow", - "fuel-core-chain-config", - "fuel-core-poa", - "fuel-core-types", + "fuel-core-chain-config 0.22.1", + "fuel-core-poa 0.22.1", + "fuel-core-types 0.22.1", "tokio", ] +[[package]] +name = "fuel-core-consensus-module" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8d697f23683e342c58e5caf1858a19a8d247d882da3d5eb46be4358def0e01" +dependencies = [ + "anyhow", + "fuel-core-chain-config 0.23.0", + "fuel-core-poa 0.23.0", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", +] + [[package]] name = "fuel-core-database" version = "0.22.1" @@ -1271,8 +1398,20 @@ checksum = "de6c935d61a94e982eaa5a1741ec33fa9a0287b99740c0e91896dea2b14fbf87" dependencies = [ "anyhow", "derive_more", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", +] + +[[package]] +name = "fuel-core-database" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b15c8836700abafd371d8cccc25139654e75d909fb1569eed9225fc435e8022" +dependencies = [ + "anyhow", + "derive_more", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", ] [[package]] @@ -1282,9 +1421,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05e9fbe27d5e1e74fc9931d987d391af2112276e8dcf0395d26ecbcb496f90af" dependencies = [ "anyhow", - "fuel-core-chain-config", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-chain-config 0.22.1", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", + "hex", + "parking_lot", + "tracing", +] + +[[package]] +name = "fuel-core-executor" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a995d40aee2a9799b73e59307628beb486e649e368ca1431fd35262276c7648" +dependencies = [ + "anyhow", + "fuel-core-chain-config 0.23.0", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", "hex", "parking_lot", "tracing", @@ -1298,13 +1452,30 @@ checksum = "820a579cc9842536b82a85fa214c85d73bb947dc9833ff7c814f4f7995bfc696" dependencies = [ "anyhow", "derive_more", - "fuel-core-metrics", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-metrics 0.22.1", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", "tokio", "tracing", ] +[[package]] +name = "fuel-core-importer" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0dc2073d2dc420b82eb16bc2187b76daf2725bcccca3a40ebb3e443194897d" +dependencies = [ + "anyhow", + "derive_more", + "fuel-core-chain-config 0.23.0", + "fuel-core-metrics 0.23.0", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", + "tokio", + "tokio-rayon", + "tracing", +] + [[package]] name = "fuel-core-metrics" version = "0.22.1" @@ -1320,6 +1491,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "fuel-core-metrics" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b5f5336984cdbb3f7f8b3cf2d3ac0928d4b058dcdca061c49563764a5366be4" +dependencies = [ + "axum", + "once_cell", + "pin-project-lite", + "prometheus-client 0.22.2", + "regex", + "tracing", +] + [[package]] name = "fuel-core-poa" version = "0.22.1" @@ -1328,10 +1513,27 @@ checksum = "bd1704cab002c336b345d8146aca54e5a1a02b603f0ece86090795c21ae797b1" dependencies = [ "anyhow", "async-trait", - "fuel-core-chain-config", - "fuel-core-services", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-chain-config 0.22.1", + "fuel-core-services 0.22.1", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", + "tokio", + "tokio-stream", + "tracing", +] + +[[package]] +name = "fuel-core-poa" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bb6af0c9289fc3273c5c45fa4d5894a914acbc175c0001f5b6bbb336546e1e" +dependencies = [ + "anyhow", + "async-trait", + "fuel-core-chain-config 0.23.0", + "fuel-core-services 0.23.0", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", "tokio", "tokio-stream", "tracing", @@ -1346,8 +1548,24 @@ dependencies = [ "anyhow", "async-trait", "derive_more", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", + "tokio", + "tokio-rayon", + "tracing", +] + +[[package]] +name = "fuel-core-producer" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9195aaa56e2880ffb1ad88d92bfc40e0b6685994a8a584016b984b88f037b6e" +dependencies = [ + "anyhow", + "async-trait", + "derive_more", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", "tokio", "tokio-rayon", "tracing", @@ -1361,7 +1579,22 @@ checksum = "4111fb590d80e761163612f2af67e9992c70a736e65414f355dac46d4926f6ba" dependencies = [ "anyhow", "async-trait", - "fuel-core-metrics", + "fuel-core-metrics 0.22.1", + "futures", + "parking_lot", + "tokio", + "tracing", +] + +[[package]] +name = "fuel-core-services" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66cbc7c3958d00f28578a7f8343b1344fe7e866643f16cdfe280e5d90bc4541" +dependencies = [ + "anyhow", + "async-trait", + "fuel-core-metrics 0.23.0", "futures", "parking_lot", "tokio", @@ -1376,9 +1609,30 @@ checksum = "f3a98d3f35a3714556cd484b49e63510086fd99630caf558a1ac583594476b0a" dependencies = [ "anyhow", "derive_more", - "fuel-core-types", - "fuel-vm", + "fuel-core-types 0.22.1", + "fuel-vm 0.43.2", + "primitive-types", +] + +[[package]] +name = "fuel-core-storage" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "481343e6501f5205f742fae3b745402dc7f7c3a5038e64c598ba5217dcf17033" +dependencies = [ + "anyhow", + "derive_more", + "enum-iterator", + "fuel-core-types 0.23.0", + "fuel-vm 0.47.1", + "impl-tools", + "itertools 0.10.5", + "paste", + "postcard", "primitive-types", + "serde", + "strum 0.25.0", + "strum_macros 0.25.3", ] [[package]] @@ -1389,11 +1643,32 @@ checksum = "b08cbcd7c8843a8bb5ee9eca4fd204455e4cefff498d6ce4e2be9a463f57e93c" dependencies = [ "anyhow", "async-trait", - "fuel-core-chain-config", - "fuel-core-metrics", - "fuel-core-services", - "fuel-core-storage", - "fuel-core-types", + "fuel-core-chain-config 0.22.1", + "fuel-core-metrics 0.22.1", + "fuel-core-services 0.22.1", + "fuel-core-storage 0.22.1", + "fuel-core-types 0.22.1", + "futures", + "parking_lot", + "tokio", + "tokio-rayon", + "tokio-stream", + "tracing", +] + +[[package]] +name = "fuel-core-txpool" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "285ed2582d5a8bdc5419a5cc4d6198a78a9f0a7a9ba57441633de2973c814f74" +dependencies = [ + "anyhow", + "async-trait", + "fuel-core-chain-config 0.23.0", + "fuel-core-metrics 0.23.0", + "fuel-core-services 0.23.0", + "fuel-core-storage 0.23.0", + "fuel-core-types 0.23.0", "futures", "parking_lot", "tokio", @@ -1411,7 +1686,25 @@ dependencies = [ "anyhow", "bs58", "derive_more", - "fuel-vm", + "fuel-vm 0.43.2", + "secrecy", + "serde", + "tai64", + "thiserror", + "zeroize", +] + +[[package]] +name = "fuel-core-types" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e855f688cf9a6f61f60663f03e217d821c4ade7a08d15ce21b54348612c873" +dependencies = [ + "anyhow", + "bs58", + "derivative", + "derive_more", + "fuel-vm 0.47.1", "secrecy", "serde", "tai64", @@ -1429,7 +1722,28 @@ dependencies = [ "coins-bip39", "ecdsa", "ed25519-dalek", - "fuel-types", + "fuel-types 0.43.2", + "k256", + "lazy_static", + "p256", + "rand", + "secp256k1", + "serde", + "sha2", + "zeroize", +] + +[[package]] +name = "fuel-crypto" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f00ba92f0e13a0dd06a7ad4e9a61221dc43d665519b50bfdb18755aebfdcf0" +dependencies = [ + "coins-bip32", + "coins-bip39", + "ecdsa", + "ed25519-dalek", + "fuel-types 0.47.1", "k256", "lazy_static", "p256", @@ -1452,6 +1766,18 @@ dependencies = [ "synstructure", ] +[[package]] +name = "fuel-derive" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9b265467fe9d3d613a5bae9b8d3005d558d3e830dc416c9836bc16609a000f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", + "synstructure", +] + [[package]] name = "fuel-merkle" version = "0.43.2" @@ -1460,7 +1786,22 @@ checksum = "89143dd80b29dda305fbb033bc7f868834445ef6b361bf920f0077938fb6c0bc" dependencies = [ "derive_more", "digest", - "fuel-storage", + "fuel-storage 0.43.2", + "hashbrown 0.13.2", + "hex", + "serde", + "sha2", +] + +[[package]] +name = "fuel-merkle" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b21ea035ff06a28791c862496c3b03cfb2d87778476c419724796e945e282ad" +dependencies = [ + "derive_more", + "digest", + "fuel-storage 0.47.1", "hashbrown 0.13.2", "hex", "serde", @@ -1473,6 +1814,12 @@ version = "0.43.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "901aee4b46684e483d2c04d40e5ac1b8ccda737ac5a363507b44b9eb23b0fdaa" +[[package]] +name = "fuel-storage" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1048957b744e448840eb9a09cb58c4647dec32e1cf49c0029e5445cbdc86f6d2" + [[package]] name = "fuel-tx" version = "0.43.2" @@ -1482,17 +1829,39 @@ dependencies = [ "bitflags 2.4.2", "derivative", "derive_more", - "fuel-asm", - "fuel-crypto", - "fuel-merkle", - "fuel-types", + "fuel-asm 0.43.2", + "fuel-crypto 0.43.2", + "fuel-merkle 0.43.2", + "fuel-types 0.43.2", "hashbrown 0.14.3", "itertools 0.10.5", "rand", "serde", "serde_json", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", +] + +[[package]] +name = "fuel-tx" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc917bb2d1892ef6792624782bed7cee5670f3f836b344f06c4233bb1124aff" +dependencies = [ + "bitflags 2.4.2", + "derivative", + "derive_more", + "fuel-asm 0.47.1", + "fuel-crypto 0.47.1", + "fuel-merkle 0.47.1", + "fuel-types 0.47.1", + "hashbrown 0.14.3", + "itertools 0.10.5", + "rand", + "serde", + "serde_json", + "strum 0.24.1", + "strum_macros 0.24.3", ] [[package]] @@ -1501,7 +1870,19 @@ version = "0.43.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "148b59be5c54bafff692310663cbce3f097a2a7ff5533224dcfdf387578a72b0" dependencies = [ - "fuel-derive", + "fuel-derive 0.43.2", + "hex", + "rand", + "serde", +] + +[[package]] +name = "fuel-types" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2444c92791b02016aa1cbab6cfa38e34920e61ec61d564f7bdb3ad8ddfae35de" +dependencies = [ + "fuel-derive 0.47.1", "hex", "rand", "serde", @@ -1519,12 +1900,12 @@ dependencies = [ "derivative", "derive_more", "ethnum", - "fuel-asm", - "fuel-crypto", - "fuel-merkle", - "fuel-storage", - "fuel-tx", - "fuel-types", + "fuel-asm 0.43.2", + "fuel-crypto 0.43.2", + "fuel-merkle 0.43.2", + "fuel-storage 0.43.2", + "fuel-tx 0.43.2", + "fuel-types 0.43.2", "hashbrown 0.14.3", "itertools 0.10.5", "libm", @@ -1534,7 +1915,38 @@ dependencies = [ "serde", "sha3", "static_assertions", - "strum", + "strum 0.24.1", + "tai64", +] + +[[package]] +name = "fuel-vm" +version = "0.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e29c2333edbf3c55906b92a5f3dfb9639e2b0eabc7fd754e7a8e18d67ded3c2" +dependencies = [ + "async-trait", + "backtrace", + "bitflags 2.4.2", + "derivative", + "derive_more", + "ethnum", + "fuel-asm 0.47.1", + "fuel-crypto 0.47.1", + "fuel-merkle 0.47.1", + "fuel-storage 0.47.1", + "fuel-tx 0.47.1", + "fuel-types 0.47.1", + "hashbrown 0.14.3", + "itertools 0.10.5", + "libm", + "paste", + "percent-encoding", + "primitive-types", + "serde", + "sha3", + "static_assertions", + "strum 0.24.1", "tai64", ] @@ -1544,15 +1956,32 @@ version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d0761be35fa13d61c0220aa4535d3cc990542032abfc006bef709121a402637" dependencies = [ - "fuel-core", - "fuel-core-client", - "fuel-crypto", - "fuel-tx", - "fuels-accounts", - "fuels-core", - "fuels-macros", - "fuels-programs", - "fuels-test-helpers", + "fuel-core 0.22.1", + "fuel-core-client 0.22.1", + "fuel-crypto 0.43.2", + "fuel-tx 0.43.2", + "fuels-accounts 0.55.0", + "fuels-core 0.55.0", + "fuels-macros 0.55.0", + "fuels-programs 0.55.0", + "fuels-test-helpers 0.55.0", +] + +[[package]] +name = "fuels" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b21f3e84f5aa46e69a6415daf717e572dfacaf1540243e6458d033d35a6f9fe0" +dependencies = [ + "fuel-core 0.23.0", + "fuel-core-client 0.23.0", + "fuel-crypto 0.47.1", + "fuel-tx 0.47.1", + "fuels-accounts 0.56.0", + "fuels-core 0.56.0", + "fuels-macros 0.56.0", + "fuels-programs 0.56.0", + "fuels-test-helpers 0.56.0", ] [[package]] @@ -1565,11 +1994,11 @@ dependencies = [ "chrono", "elliptic-curve", "eth-keystore", - "fuel-core-client", - "fuel-crypto", - "fuel-tx", - "fuel-types", - "fuels-core", + "fuel-core-client 0.22.1", + "fuel-crypto 0.43.2", + "fuel-tx 0.43.2", + "fuel-types 0.43.2", + "fuels-core 0.55.0", "hex", "rand", "semver", @@ -1580,6 +2009,31 @@ dependencies = [ "zeroize", ] +[[package]] +name = "fuels-accounts" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e3eff2a1756fa81aa7e218b8ecefe4c70d44b38011db73d3181c99f3388259" +dependencies = [ + "async-trait", + "chrono", + "elliptic-curve", + "eth-keystore", + "fuel-core-client 0.23.0", + "fuel-core-types 0.23.0", + "fuel-crypto 0.47.1", + "fuel-tx 0.47.1", + "fuel-types 0.47.1", + "fuels-core 0.56.0", + "rand", + "semver", + "tai64", + "thiserror", + "tokio", + "tracing", + "zeroize", +] + [[package]] name = "fuels-code-gen" version = "0.55.0" @@ -1587,7 +2041,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19daefd4e70d4b6998b6650dea23d982360650f8710e5c7bc6e8a5b91228814d" dependencies = [ "Inflector", - "fuel-abi-types", + "fuel-abi-types 0.3.0", + "itertools 0.12.1", + "proc-macro2", + "quote", + "regex", + "serde_json", + "syn 2.0.50", +] + +[[package]] +name = "fuels-code-gen" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cf2c8670901a44f89a983a27b2fa831e1af19f6788cea1186c9b48514cc2a4" +dependencies = [ + "Inflector", + "fuel-abi-types 0.4.0", "itertools 0.12.1", "proc-macro2", "quote", @@ -1605,15 +2075,42 @@ dependencies = [ "async-trait", "bech32", "chrono", - "fuel-abi-types", - "fuel-asm", - "fuel-core-chain-config", - "fuel-core-client", - "fuel-crypto", - "fuel-tx", - "fuel-types", - "fuel-vm", - "fuels-macros", + "fuel-abi-types 0.3.0", + "fuel-asm 0.43.2", + "fuel-core-chain-config 0.22.1", + "fuel-core-client 0.22.1", + "fuel-crypto 0.43.2", + "fuel-tx 0.43.2", + "fuel-types 0.43.2", + "fuel-vm 0.43.2", + "fuels-macros 0.55.0", + "hex", + "itertools 0.12.1", + "serde", + "serde_json", + "sha2", + "thiserror", + "uint", +] + +[[package]] +name = "fuels-core" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5af00939974c1796cc05f44f20b0e31b8d6a03e9aeb1195fb2a9b68cef59920" +dependencies = [ + "async-trait", + "bech32", + "chrono", + "fuel-abi-types 0.4.0", + "fuel-asm 0.47.1", + "fuel-core-chain-config 0.23.0", + "fuel-core-client 0.23.0", + "fuel-crypto 0.47.1", + "fuel-tx 0.47.1", + "fuel-types 0.47.1", + "fuel-vm 0.47.1", + "fuels-macros 0.56.0", "hex", "itertools 0.12.1", "serde", @@ -1629,7 +2126,21 @@ version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ce17afcb07246c221da0d5a55d4ffc748d4b49a0fd7058a90b1ad1c6f0023a7" dependencies = [ - "fuels-code-gen", + "fuels-code-gen 0.55.0", + "itertools 0.12.1", + "proc-macro2", + "quote", + "rand", + "syn 2.0.50", +] + +[[package]] +name = "fuels-macros" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "652003ee5a73e3674c818d9175e61c17311593e40d8281e00f08e64d7d29a076" +dependencies = [ + "fuels-code-gen 0.56.0", "itertools 0.12.1", "proc-macro2", "quote", @@ -1645,12 +2156,32 @@ checksum = "b7898f4e9f3b438de60b55644806bf2718e1c09e0605180c19fb44a8ca0a1165" dependencies = [ "async-trait", "bytes", - "fuel-abi-types", - "fuel-asm", - "fuel-tx", - "fuel-types", - "fuels-accounts", - "fuels-core", + "fuel-abi-types 0.3.0", + "fuel-asm 0.43.2", + "fuel-tx 0.43.2", + "fuel-types 0.43.2", + "fuels-accounts 0.55.0", + "fuels-core 0.55.0", + "itertools 0.12.1", + "rand", + "serde_json", + "tokio", +] + +[[package]] +name = "fuels-programs" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d779783fc8c194864a596bfca82fda107a425398b49ad330de7b41f2622fd4" +dependencies = [ + "async-trait", + "bytes", + "fuel-abi-types 0.4.0", + "fuel-asm 0.47.1", + "fuel-tx 0.47.1", + "fuel-types 0.47.1", + "fuels-accounts 0.56.0", + "fuels-core 0.56.0", "itertools 0.12.1", "rand", "serde_json", @@ -1663,16 +2194,44 @@ version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7620c418f9501713c2cd976f216b9d46ff847a4d681af56e36af17ad26dac14e" dependencies = [ - "fuel-core", - "fuel-core-chain-config", - "fuel-core-client", - "fuel-core-poa", - "fuel-core-services", - "fuel-crypto", - "fuel-tx", - "fuel-types", - "fuels-accounts", - "fuels-core", + "fuel-core 0.22.1", + "fuel-core-chain-config 0.22.1", + "fuel-core-client 0.22.1", + "fuel-core-poa 0.22.1", + "fuel-core-services 0.22.1", + "fuel-crypto 0.43.2", + "fuel-tx 0.43.2", + "fuel-types 0.43.2", + "fuels-accounts 0.55.0", + "fuels-core 0.55.0", + "futures", + "hex", + "portpicker", + "rand", + "serde", + "serde_json", + "serde_with 3.6.1", + "tempfile", + "tokio", + "which 5.0.0", +] + +[[package]] +name = "fuels-test-helpers" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e1a8ed34d466df259afb3c210270fca59c8d66be77c00f428c49e61f35baeb" +dependencies = [ + "fuel-core 0.23.0", + "fuel-core-chain-config 0.23.0", + "fuel-core-client 0.23.0", + "fuel-core-poa 0.23.0", + "fuel-core-services 0.23.0", + "fuel-crypto 0.47.1", + "fuel-tx 0.47.1", + "fuel-types 0.47.1", + "fuels-accounts 0.56.0", + "fuels-core 0.56.0", "futures", "hex", "portpicker", @@ -1682,7 +2241,7 @@ dependencies = [ "serde_with 3.6.1", "tempfile", "tokio", - "which", + "which 6.0.1", ] [[package]] @@ -2101,6 +2660,30 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "impl-tools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82c305b1081f1a99fda262883c788e50ab57d36c00830bdd7e0a82894ad965c" +dependencies = [ + "autocfg", + "impl-tools-lib", + "proc-macro-error", + "syn 2.0.50", +] + +[[package]] +name = "impl-tools-lib" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85d3946d886eaab0702fa0c6585adcced581513223fa9df7ccfabbd9fa331a88" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.50", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -2233,6 +2816,14 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "market-contract" +version = "0.0.0" +dependencies = [ + "fuels 0.56.0", + "tokio", +] + [[package]] name = "matchit" version = "0.5.0" @@ -2339,8 +2930,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" name = "orderbook" version = "0.1.0" dependencies = [ + "anyhow", "dotenv", - "fuels", + "fuels 0.55.0", "pretty_assertions", "rand", "src20_sdk", @@ -2544,6 +3136,29 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.78" @@ -2577,6 +3192,18 @@ dependencies = [ "prometheus-client-derive-encode", ] +[[package]] +name = "prometheus-client" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ca959da22a332509f2a73ae9e5f23f9dcfc31fd3a54d71f159495bd5909baa" +dependencies = [ + "dtoa", + "itoa", + "parking_lot", + "prometheus-client-derive-encode", +] + [[package]] name = "prometheus-client-derive-encode" version = "0.4.2" @@ -3212,23 +3839,23 @@ dependencies = [ ] [[package]] -name = "spark" +name = "spark-cli" version = "0.1.0" dependencies = [ "anyhow", "clap", "dotenv", - "fuels", - "spark-market", + "fuels 0.55.0", + "spark-market-sdk", "tokio", ] [[package]] -name = "spark-market" +name = "spark-market-sdk" version = "0.1.0" dependencies = [ "anyhow", - "fuels", + "fuels 0.55.0", "rand", "tokio", ] @@ -3264,7 +3891,7 @@ version = "0.0.3" source = "git+https://github.com/compolabs/src-20.git?branch=master#d05776384daab572e16f54038db1d266ba908883" dependencies = [ "dotenv", - "fuels", + "fuels 0.55.0", "rand", "serde", "serde_json", @@ -3303,9 +3930,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -3319,6 +3952,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.50", +] + [[package]] name = "subtle" version = "2.5.0" @@ -3925,6 +4571,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "which" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +dependencies = [ + "either", + "home", + "rustix", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4107,6 +4765,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index e5b55f6..d532e86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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-market-sdk" description = "A cargo-generate template for Rust + Sway integration testing." version = "0.1.0" edition = "2021" @@ -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" diff --git a/_src/constants.rs b/_src/constants.rs new file mode 100644 index 0000000..0f0692e --- /dev/null +++ b/_src/constants.rs @@ -0,0 +1,13 @@ +pub const RPC: &str = "beta-5.fuel.network"; + +pub const ORDERBOOK_CONTRACT_ID: &str = + "1ad65e67c522dc0355f17792417aeb3269b5adc84ba13549b94b98b2db34c1e0"; + +pub const TOKEN_CONTRACT_ID: &str = + "0x6bd9643c9279204b474a778dea7f923226060cb94a4c61c5aae015cf96b5aad2"; +pub const USDC_ASSET_ID_STR: &str = + "0x0450e4d385cbd2914f74505f18f01587cc4f4ad1fdef4b80cbde2a8155a86d72"; +pub const BTC_ASSET_ID_STR: &str = + "0x593b117a05f5ea64b39ba1f9bc3fb7e7a791c9be130e28376ad552eacdb3b746"; +pub const UNI_ASSET_ID_STR: &str = + "0xae37bc0feb66e60a89e301d450bb4640aa9bd7cedd856e253e23989eae536e92"; diff --git a/_src/lib.rs b/_src/lib.rs new file mode 100644 index 0000000..54ed73e --- /dev/null +++ b/_src/lib.rs @@ -0,0 +1,29 @@ +pub mod constants; +pub mod orderbook_utils; + +pub fn print_title(title: &str) { + println!( + r#" + + ██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗██╗ ██╗████████╗██╗ ██╗ +██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗██╔════╝██╔══██╗██╔══██╗██║██║ ██║╚══██╔══╝╚██╗ ██╔╝ +██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║███████╗███████║██████╔╝██║██║ ██║ ██║ ╚████╔╝ +██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║╚════██║██╔══██║██╔══██╗██║██║ ██║ ██║ ╚██╔╝ +╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝███████║██║ ██║██████╔╝██║███████╗██║ ██║ ██║ + ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ + +██╗ █████╗ ██████╗ ███████╗ +██║ ██╔══██╗██╔══██╗██╔════╝ +██║ ███████║██████╔╝███████╗ +██║ ██╔══██║██╔══██╗╚════██║ +███████╗██║ ██║██████╔╝███████║ +╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝ + + +Predicate based orderbook + +🏁 {title} 🏁 + +"# + ); +} diff --git a/_src/orderbook_utils.rs b/_src/orderbook_utils.rs new file mode 100644 index 0000000..0057a44 --- /dev/null +++ b/_src/orderbook_utils.rs @@ -0,0 +1,209 @@ +use std::str::FromStr; + +use fuels::{ + accounts::wallet::WalletUnlocked, + macros::abigen, + programs::{ + call_response::FuelCallResponse, + call_utils::TxDependencyExtension, + contract::{CallParameters, Contract, LoadConfiguration}, + }, + types::{bech32::Bech32Address, transaction::TxPolicies, AssetId, Bits256, ContractId}, +}; +use rand::Rng; + +use self::abigen_bindings::orderbook_contract_mod; + +abigen!(Contract( + name = "OrderbookContract", + abi = "contract/out/debug/orderbook-abi.json" +)); + +pub struct Orderbook { + pub instance: OrderbookContract, + pub quote_token: AssetId, + pub quote_token_decimals: u64, + pub price_decimals: u64, +} + +impl Orderbook { + pub async fn _create_market( + &self, + asset_id: AssetId, + decimal: u32, + ) -> Result, fuels::types::errors::Error> { + self.instance + .methods() + .create_market(asset_id, decimal) + .call() + .await + } + + pub async fn get_market_by_id( + &self, + asset_id: AssetId, + ) -> Result, fuels::types::errors::Error> { + self.instance + .methods() + .get_market_by_id(asset_id) + .simulate() + .await + } + + pub async fn market_exists( + &self, + asset_id: AssetId, + ) -> Result, fuels::types::errors::Error> { + self.instance + .methods() + .market_exists(asset_id) + .simulate() + .await + } + + pub async fn order_by_id( + &self, + id: &Bits256, + ) -> Result>, fuels::types::errors::Error> { + self.instance.methods().order_by_id(*id).simulate().await + } + + pub async fn orders_by_trader( + &self, + trader: &Bech32Address, + ) -> Result>, fuels::types::errors::Error> { + self.instance + .methods() + .orders_by_trader(trader) + .simulate() + .await + } + + pub async fn open_order( + &self, + base_token: AssetId, + base_size: i64, + base_price: u64, + ) -> Result, fuels::types::errors::Error> { + let call_params: CallParameters = if base_size.is_negative() { + CallParameters::default() + .with_asset_id(base_token) + .with_amount(base_size.abs() as u64) + } else { + let market = self.get_market_by_id(base_token).await.unwrap().value; + let quote_size = base_size.abs() as u128 * base_price as u128 + / 10u128.pow( + self.price_decimals as u32 + market.asset_decimals + - self.quote_token_decimals as u32, + ); + CallParameters::default() + .with_asset_id(self.quote_token) + .with_amount(quote_size as u64) + }; + + self.instance + .methods() + .open_order( + base_token, + I64::new(base_size.unsigned_abs(), base_size < 0), + base_price, + ) + .append_variable_outputs(2) + .call_params(call_params) + .unwrap() + .call() + .await + } + + pub async fn cancel_order( + &self, + order_id: &Bits256, + ) -> Result, fuels::types::errors::Error> { + self.instance + .methods() + .cancel_order(*order_id) + .append_variable_outputs(1) + .call() + .await + } + + pub async fn match_orders( + &self, + sell_order_id: &Bits256, + buy_order_id: &Bits256, + ) -> Result, fuels::types::errors::Error> { + self.instance + .methods() + .match_orders(*sell_order_id, *buy_order_id) + .append_variable_outputs(2) + .call() + .await + } + + pub fn with_account(&self, account: &WalletUnlocked) -> Self { + Self { + instance: self.instance.with_account(account.clone()).unwrap(), + quote_token: self.quote_token, + quote_token_decimals: self.quote_token_decimals, + price_decimals: self.price_decimals, + } + } + + pub async fn new(wallet: &WalletUnlocked, contract_id: &str) -> Self { + let instance = OrderbookContract::new( + &ContractId::from_str(contract_id).unwrap().into(), + wallet.clone(), + ); + let (quote_token, quote_token_decimals, price_decimals) = instance + .methods() + .get_configurables() + .simulate() + .await + .unwrap() + .value; + Orderbook { + instance, + quote_token, + quote_token_decimals: quote_token_decimals as u64, + price_decimals: price_decimals as u64, + } + } + + pub async fn deploy( + wallet: &WalletUnlocked, + quote_token: AssetId, + quote_token_decimals: u64, + price_decimals: u64, + ) -> Self { + let mut rng = rand::thread_rng(); + let salt = rng.gen::<[u8; 32]>(); + + let configurables = OrderbookContractConfigurables::default() + .with_QUOTE_TOKEN(quote_token) + .with_QUOTE_TOKEN_DECIMALS(quote_token_decimals.try_into().unwrap()) + .with_PRICE_DECIMALS(price_decimals.try_into().unwrap()); + let config = LoadConfiguration::default().with_configurables(configurables); + + let id = Contract::load_from("contract/out/debug/orderbook.bin", config) + .unwrap() + .with_salt(salt) + .deploy(wallet, TxPolicies::default().with_gas_price(1)) + .await + .unwrap(); + + let instance = OrderbookContract::new(id, wallet.clone()); + + Orderbook { + instance, + quote_token, + quote_token_decimals, + price_decimals, + } + } +} + +impl I64 { + pub fn as_i64(self) -> i64 { + self.value as i64 * if self.negative { -1 } else { 1 } + } +} diff --git a/tests/common_test_cases/mod.rs b/_tests/common_test_cases/mod.rs similarity index 100% rename from tests/common_test_cases/mod.rs rename to _tests/common_test_cases/mod.rs diff --git a/tests/common_test_cases/open_base_token_order_cancel.rs b/_tests/common_test_cases/open_base_token_order_cancel.rs similarity index 100% rename from tests/common_test_cases/open_base_token_order_cancel.rs rename to _tests/common_test_cases/open_base_token_order_cancel.rs diff --git a/tests/common_test_cases/open_quote_token_order_cancel_by_reverse_order.rs b/_tests/common_test_cases/open_quote_token_order_cancel_by_reverse_order.rs similarity index 100% rename from tests/common_test_cases/open_quote_token_order_cancel_by_reverse_order.rs rename to _tests/common_test_cases/open_quote_token_order_cancel_by_reverse_order.rs diff --git a/tests/harness.rs b/_tests/harness.rs similarity index 100% rename from tests/harness.rs rename to _tests/harness.rs diff --git a/tests/match_test/match_orders_cases.rs b/_tests/match_test/match_orders_cases.rs similarity index 99% rename from tests/match_test/match_orders_cases.rs rename to _tests/match_test/match_orders_cases.rs index 4162a5c..ec67434 100644 --- a/tests/match_test/match_orders_cases.rs +++ b/_tests/match_test/match_orders_cases.rs @@ -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; diff --git a/tests/match_test/match_test.rs b/_tests/match_test/match_test.rs similarity index 100% rename from tests/match_test/match_test.rs rename to _tests/match_test/match_test.rs diff --git a/tests/match_test/mod.rs b/_tests/match_test/mod.rs similarity index 100% rename from tests/match_test/mod.rs rename to _tests/match_test/mod.rs diff --git a/tests/utils/check_balance.rs b/_tests/utils/check_balance.rs similarity index 100% rename from tests/utils/check_balance.rs rename to _tests/utils/check_balance.rs diff --git a/tests/utils/match_orders_case_utils.rs b/_tests/utils/match_orders_case_utils.rs similarity index 100% rename from tests/utils/match_orders_case_utils.rs rename to _tests/utils/match_orders_case_utils.rs diff --git a/tests/utils/mint_tokens.rs b/_tests/utils/mint_tokens.rs similarity index 100% rename from tests/utils/mint_tokens.rs rename to _tests/utils/mint_tokens.rs diff --git a/tests/utils/mod.rs b/_tests/utils/mod.rs similarity index 100% rename from tests/utils/mod.rs rename to _tests/utils/mod.rs diff --git a/tests/utils/setup.rs b/_tests/utils/setup.rs similarity index 100% rename from tests/utils/setup.rs rename to _tests/utils/setup.rs diff --git a/scripts/cancel_order.rs b/scripts/cancel_order.rs deleted file mode 100644 index 3aab4f9..0000000 --- a/scripts/cancel_order.rs +++ /dev/null @@ -1,32 +0,0 @@ -use dotenv::dotenv; -use fuels::{ - prelude::{Provider, WalletUnlocked}, - types::Bits256, -}; -use orderbook::{constants::ORDERBOOK_CONTRACT_ID, orderbook_utils::Orderbook, print_title}; -use src20_sdk::constants::RPC; - -const ORDER_ID: &str = "0x72a6ade704246cac5699b2016cb8bbcaa91ad254678efb4c4ffc12c3777db2f9"; - -#[tokio::main] -async fn main() { - print_title("Cancel order"); - dotenv().ok(); - let provider = Provider::connect(RPC).await.unwrap(); - let secret = std::env::var("ADMIN").unwrap(); - let wallet = - WalletUnlocked::new_from_private_key(secret.parse().unwrap(), Some(provider.clone())); - - let orderbook = Orderbook::new(&wallet, ORDERBOOK_CONTRACT_ID).await; - - let id = &Bits256::from_hex_str(ORDER_ID).unwrap(); - - let order = orderbook.order_by_id(id).await.unwrap().value; - - assert!(order.is_some()); - - orderbook - .cancel_order(id) //fixme TransferZeroCoins - .await - .unwrap(); -} diff --git a/scripts/create_market.rs b/scripts/create_market.rs deleted file mode 100644 index 3fe5b50..0000000 --- a/scripts/create_market.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::str::FromStr; - -use dotenv::dotenv; -use fuels::{ - prelude::{Provider, WalletUnlocked}, - types::ContractId, -}; -use orderbook::{constants::ORDERBOOK_CONTRACT_ID, orderbook_utils::Orderbook, print_title}; -use src20_sdk::{ - constants::{RPC, TOKEN_CONTRACT_ID}, - token_utils::{Asset, TokenContract}, -}; - -const MARKET_SYMBOL: &str = "UNI"; - -#[tokio::main] -async fn main() { - print_title("Create market"); - dotenv().ok(); - let provider = Provider::connect(RPC).await.unwrap(); - let secret = std::env::var("ADMIN").unwrap(); - let wallet = - WalletUnlocked::new_from_private_key(secret.parse().unwrap(), Some(provider.clone())); - - let token_contarct = TokenContract::new( - &ContractId::from_str(TOKEN_CONTRACT_ID).unwrap().into(), - wallet.clone(), - ); - - let asset = Asset::new( - wallet.clone(), - token_contarct.contract_id().into(), - MARKET_SYMBOL, - ); - - let orderbook = Orderbook::new(&wallet, ORDERBOOK_CONTRACT_ID).await; - - orderbook - ._create_market(asset.asset_id, asset.decimals as u32) - .await - .unwrap(); -} diff --git a/scripts/create_order.rs b/scripts/create_order.rs deleted file mode 100644 index 0ee8d78..0000000 --- a/scripts/create_order.rs +++ /dev/null @@ -1,70 +0,0 @@ -use dotenv::dotenv; -use fuels::{ - prelude::{Provider, WalletUnlocked}, - types::{Address, ContractId}, -}; -use orderbook::{constants::ORDERBOOK_CONTRACT_ID, orderbook_utils::Orderbook, print_title}; -use src20_sdk::{ - constants::{RPC, TOKEN_CONTRACT_ID}, - token_utils::{Asset, TokenContract}, -}; -use std::str::FromStr; - -const MARKET_SYMBOL: &str = "UNI"; -const BASE_SIZE: i64 = -100; //units -const BASE_PRICE: u64 = 10; //units - -#[tokio::main] -async fn main() { - print_title("Create Order"); - dotenv().ok(); - let provider = Provider::connect(RPC).await.unwrap(); - let secret = std::env::var("ADMIN").unwrap(); - let wallet = - WalletUnlocked::new_from_private_key(secret.parse().unwrap(), Some(provider.clone())); - - let token_contract = TokenContract::new( - &ContractId::from_str(TOKEN_CONTRACT_ID).unwrap().into(), - wallet.clone(), - ); - - let token_contract_id = token_contract.contract_id().into(); - let base_asset = Asset::new(wallet.clone(), token_contract_id, MARKET_SYMBOL); - let quote_asset = Asset::new(wallet.clone(), token_contract_id, "USDC"); - - let orderbook = Orderbook::new(&wallet, ORDERBOOK_CONTRACT_ID).await; - - if BASE_SIZE > 0 { - let quote_size = quote_asset.parse_units(BASE_SIZE as f64 * BASE_PRICE as f64); - quote_asset - .mint(wallet.address().into(), quote_size as u64) - .await - .unwrap(); - } else { - let base_size = base_asset.parse_units(BASE_SIZE.abs() as f64) as u64; - base_asset - .mint(wallet.address().into(), base_size) - .await - .unwrap(); - } - let price = BASE_PRICE * 10u64.pow(orderbook.price_decimals as u32); - let result = orderbook - .open_order(base_asset.asset_id, BASE_SIZE, price) - .await; - - //todo прикладывать ссылку на задачу в случае todo и на топик в случае fixme - //fixme https://forum.fuel.network/t/error-ioerror-custom-kind-other-error-response-errors-running-open-order-function/4725 - match result { - Ok(response) => { - let id = Address::from(response.value.0).to_string(); - println!("Order opened successfully. OrderId: 0x{id}"); - // println!("Value: {:?}", response.value); - // println!("Receipts: {:?}", response.receipts); - println!("Gas Used: {:?}", response.gas_used); - println!("Transaction ID: {:?}", response.tx_id.unwrap()); - } - Err(error) => { - eprintln!("Failed to open order: {:?}", error); - } - } -} diff --git a/scripts/deploy.rs b/scripts/deploy.rs deleted file mode 100644 index f113cb3..0000000 --- a/scripts/deploy.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::str::FromStr; - -use dotenv::dotenv; -use fuels::{ - prelude::{Provider, WalletUnlocked}, - types::ContractId, -}; -use orderbook::{constants::TOKEN_CONTRACT_ID, orderbook_utils::Orderbook}; -use src20_sdk::{ - constants::RPC, - print_title, - token_utils::{Asset, TokenContract}, -}; - -#[tokio::main] -async fn main() { - print_title("Deploy"); - - dotenv().ok(); - let provider = Provider::connect(RPC).await.unwrap(); - let secret = std::env::var("ADMIN").unwrap(); - let wallet = - WalletUnlocked::new_from_private_key(secret.parse().unwrap(), Some(provider.clone())); - println!("admin address = {:?}", wallet.address().to_string()); - - let token_contarct = TokenContract::new( - &ContractId::from_str(TOKEN_CONTRACT_ID).unwrap().into(), - wallet.clone(), - ); - let usdc = Asset::new(wallet.clone(), token_contarct.contract_id().into(), "USDC"); - let contract = Orderbook::deploy(&wallet, usdc.asset_id, usdc.decimals, 9).await; - println!( - "The orderbook contract has been deployed {}\n", - contract.instance.contract_id().hash - ); -} diff --git a/scripts/match_orders.rs b/scripts/match_orders.rs deleted file mode 100644 index fdb27a2..0000000 --- a/scripts/match_orders.rs +++ /dev/null @@ -1,71 +0,0 @@ -use dotenv::dotenv; -use fuels::{ - prelude::{Provider, WalletUnlocked}, - types::ContractId, -}; -use orderbook::{constants::ORDERBOOK_CONTRACT_ID, orderbook_utils::Orderbook, print_title}; -use src20_sdk::{ - constants::{RPC, TOKEN_CONTRACT_ID}, - token_utils::{Asset, TokenContract}, -}; -use std::str::FromStr; - -const MARKET_SYMBOL: &str = "UNI"; -const BASE_SIZE: u64 = 100; //units -const BASE_PRICE: u64 = 10; //units - -#[tokio::main] -async fn main() { - print_title("Match Orders"); - dotenv().ok(); - let provider = Provider::connect(RPC).await.unwrap(); - let secret = std::env::var("ADMIN").unwrap(); - let wallet = - WalletUnlocked::new_from_private_key(secret.parse().unwrap(), Some(provider.clone())); - - let token_contract = TokenContract::new( - &ContractId::from_str(TOKEN_CONTRACT_ID).unwrap().into(), - wallet.clone(), - ); - - let token_contract_id = token_contract.contract_id().into(); - let base_asset = Asset::new(wallet.clone(), token_contract_id, MARKET_SYMBOL); - let quote_asset = Asset::new(wallet.clone(), token_contract_id, "USDC"); - - let orderbook = Orderbook::new(&wallet, ORDERBOOK_CONTRACT_ID).await; - let price = BASE_PRICE * 10u64.pow(orderbook.price_decimals as u32); - - //mint base asset to sell - let base_size = base_asset.parse_units(BASE_SIZE as f64) as u64; - base_asset - .mint(wallet.address().into(), base_size) - .await - .unwrap(); - - // sell - let sell_order_id = orderbook - .open_order(base_asset.asset_id, -1 * base_size as i64, price) //fixme Response errors; Validity(InsufficientFeeAmount { expected: 326087, provided: 0 })" }) - .await - .unwrap() - .value; - - //mint quote asset to buy - let quote_size = quote_asset.parse_units(BASE_SIZE as f64 * BASE_PRICE as f64); - quote_asset - .mint(wallet.address().into(), quote_size as u64) - .await - .unwrap(); - - //buy - let buy_order_id = orderbook - .open_order(base_asset.asset_id, base_size as i64, price) - .await - .unwrap() - .value; - - //todo match orders - orderbook - .match_orders(&sell_order_id, &buy_order_id) - .await - .unwrap(); -} diff --git a/spark/Cargo.lock b/spark-cli/Cargo.lock similarity index 100% rename from spark/Cargo.lock rename to spark-cli/Cargo.lock diff --git a/spark/Cargo.toml b/spark-cli/Cargo.toml similarity index 83% rename from spark/Cargo.toml rename to spark-cli/Cargo.toml index 3d1e978..1fa3b9f 100644 --- a/spark/Cargo.toml +++ b/spark-cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "spark" +name = "spark-cli" version = "0.1.0" edition = "2021" @@ -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"] } diff --git a/spark/README.md b/spark-cli/README.md similarity index 100% rename from spark/README.md rename to spark-cli/README.md diff --git a/spark/src/commands/cli.rs b/spark-cli/src/commands/cli.rs similarity index 100% rename from spark/src/commands/cli.rs rename to spark-cli/src/commands/cli.rs diff --git a/spark/src/commands/core/batch_fulfill.rs b/spark-cli/src/commands/core/batch_fulfill.rs similarity index 100% rename from spark/src/commands/core/batch_fulfill.rs rename to spark-cli/src/commands/core/batch_fulfill.rs diff --git a/spark/src/commands/core/cli.rs b/spark-cli/src/commands/core/cli.rs similarity index 100% rename from spark/src/commands/core/cli.rs rename to spark-cli/src/commands/core/cli.rs diff --git a/spark/src/commands/core/close_order.rs b/spark-cli/src/commands/core/close_order.rs similarity index 100% rename from spark/src/commands/core/close_order.rs rename to spark-cli/src/commands/core/close_order.rs diff --git a/spark/src/commands/core/deploy.rs b/spark-cli/src/commands/core/deploy.rs similarity index 100% rename from spark/src/commands/core/deploy.rs rename to spark-cli/src/commands/core/deploy.rs diff --git a/spark/src/commands/core/deposit.rs b/spark-cli/src/commands/core/deposit.rs similarity index 100% rename from spark/src/commands/core/deposit.rs rename to spark-cli/src/commands/core/deposit.rs diff --git a/spark/src/commands/core/mod.rs b/spark-cli/src/commands/core/mod.rs similarity index 100% rename from spark/src/commands/core/mod.rs rename to spark-cli/src/commands/core/mod.rs diff --git a/spark/src/commands/core/open_order.rs b/spark-cli/src/commands/core/open_order.rs similarity index 100% rename from spark/src/commands/core/open_order.rs rename to spark-cli/src/commands/core/open_order.rs diff --git a/spark/src/commands/core/set_fee.rs b/spark-cli/src/commands/core/set_fee.rs similarity index 100% rename from spark/src/commands/core/set_fee.rs rename to spark-cli/src/commands/core/set_fee.rs diff --git a/spark/src/commands/core/withdraw.rs b/spark-cli/src/commands/core/withdraw.rs similarity index 100% rename from spark/src/commands/core/withdraw.rs rename to spark-cli/src/commands/core/withdraw.rs diff --git a/spark/src/commands/info/account.rs b/spark-cli/src/commands/info/account.rs similarity index 100% rename from spark/src/commands/info/account.rs rename to spark-cli/src/commands/info/account.rs diff --git a/spark/src/commands/info/cli.rs b/spark-cli/src/commands/info/cli.rs similarity index 100% rename from spark/src/commands/info/cli.rs rename to spark-cli/src/commands/info/cli.rs diff --git a/spark/src/commands/info/config.rs b/spark-cli/src/commands/info/config.rs similarity index 100% rename from spark/src/commands/info/config.rs rename to spark-cli/src/commands/info/config.rs diff --git a/spark/src/commands/info/fee.rs b/spark-cli/src/commands/info/fee.rs similarity index 100% rename from spark/src/commands/info/fee.rs rename to spark-cli/src/commands/info/fee.rs diff --git a/spark/src/commands/info/mod.rs b/spark-cli/src/commands/info/mod.rs similarity index 100% rename from spark/src/commands/info/mod.rs rename to spark-cli/src/commands/info/mod.rs diff --git a/spark/src/commands/info/order.rs b/spark-cli/src/commands/info/order.rs similarity index 100% rename from spark/src/commands/info/order.rs rename to spark-cli/src/commands/info/order.rs diff --git a/spark/src/commands/info/order_id.rs b/spark-cli/src/commands/info/order_id.rs similarity index 100% rename from spark/src/commands/info/order_id.rs rename to spark-cli/src/commands/info/order_id.rs diff --git a/spark/src/commands/info/user_orders.rs b/spark-cli/src/commands/info/user_orders.rs similarity index 100% rename from spark/src/commands/info/user_orders.rs rename to spark-cli/src/commands/info/user_orders.rs diff --git a/spark/src/commands/mod.rs b/spark-cli/src/commands/mod.rs similarity index 100% rename from spark/src/commands/mod.rs rename to spark-cli/src/commands/mod.rs diff --git a/spark/src/main.rs b/spark-cli/src/main.rs similarity index 100% rename from spark/src/main.rs rename to spark-cli/src/main.rs diff --git a/spark/src/utils.rs b/spark-cli/src/utils.rs similarity index 100% rename from spark/src/utils.rs rename to spark-cli/src/utils.rs diff --git a/spark-market-sdk/Cargo.toml b/spark-market-sdk/Cargo.toml index e643f57..632e28d 100644 --- a/spark-market-sdk/Cargo.toml +++ b/spark-market-sdk/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "spark-market" +name = "spark-market-sdk" version = "0.1.0" edition = "2021" From 41f383fa9e580ce1348e3846d758756f06a206a9 Mon Sep 17 00:00:00 2001 From: alexey Date: Tue, 9 Apr 2024 17:24:25 +0100 Subject: [PATCH 3/4] updated spark_market_sdk name --- Cargo.lock | 26 +++++++++++----------- Cargo.toml | 2 +- market-contract/Cargo.toml | 2 +- market-contract/tests/utils/setup.rs | 9 ++++---- spark-cli/src/commands/core/deploy.rs | 2 +- spark-cli/src/commands/core/deposit.rs | 2 +- spark-cli/src/commands/core/set_fee.rs | 2 +- spark-cli/src/commands/core/withdraw.rs | 2 +- spark-cli/src/commands/info/account.rs | 2 +- spark-cli/src/commands/info/config.rs | 2 +- spark-cli/src/commands/info/fee.rs | 2 +- spark-cli/src/commands/info/order.rs | 2 +- spark-cli/src/commands/info/order_id.rs | 2 +- spark-cli/src/commands/info/user_orders.rs | 2 +- src/lib.rs | 0 15 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index f28bc53..f6429fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2926,19 +2926,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "orderbook" -version = "0.1.0" -dependencies = [ - "anyhow", - "dotenv", - "fuels 0.55.0", - "pretty_assertions", - "rand", - "src20_sdk", - "tokio", -] - [[package]] name = "p256" version = "0.13.2" @@ -3850,6 +3837,19 @@ dependencies = [ "tokio", ] +[[package]] +name = "spark-clob" +version = "0.1.0" +dependencies = [ + "anyhow", + "dotenv", + "fuels 0.55.0", + "pretty_assertions", + "rand", + "src20_sdk", + "tokio", +] + [[package]] name = "spark-market-sdk" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d532e86..4e984af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ # TODO: this has to be changed into a workspace workspace = { members = ["spark-cli", "spark-market-sdk", "market-contract"] } [package] -name = "spark-market-sdk" +name = "spark-clob" description = "A cargo-generate template for Rust + Sway integration testing." version = "0.1.0" edition = "2021" diff --git a/market-contract/Cargo.toml b/market-contract/Cargo.toml index b2f52d1..580083c 100644 --- a/market-contract/Cargo.toml +++ b/market-contract/Cargo.toml @@ -1,4 +1,4 @@ -[project] +[package] name = "market-contract" version = "0.0.0" authors = ["Compo Labs"] diff --git a/market-contract/tests/utils/setup.rs b/market-contract/tests/utils/setup.rs index 3aa915e..8e607e4 100644 --- a/market-contract/tests/utils/setup.rs +++ b/market-contract/tests/utils/setup.rs @@ -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, diff --git a/spark-cli/src/commands/core/deploy.rs b/spark-cli/src/commands/core/deploy.rs index 4233356..0583f84 100644 --- a/spark-cli/src/commands/core/deploy.rs +++ b/spark-cli/src/commands/core/deploy.rs @@ -1,7 +1,7 @@ use crate::utils::setup; use clap::Args; use fuels::{accounts::ViewOnlyAccount, types::AssetId}; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/core/deposit.rs b/spark-cli/src/commands/core/deposit.rs index 7a81fe1..6053054 100644 --- a/spark-cli/src/commands/core/deposit.rs +++ b/spark-cli/src/commands/core/deposit.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id}; use clap::Args; use fuels::{accounts::ViewOnlyAccount, types::AssetId}; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/core/set_fee.rs b/spark-cli/src/commands/core/set_fee.rs index 5da5c04..e7678bc 100644 --- a/spark-cli/src/commands/core/set_fee.rs +++ b/spark-cli/src/commands/core/set_fee.rs @@ -4,7 +4,7 @@ use fuels::{ accounts::ViewOnlyAccount, types::{Address, AssetId, ContractId, Identity}, }; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/core/withdraw.rs b/spark-cli/src/commands/core/withdraw.rs index 4f16821..b8af6e6 100644 --- a/spark-cli/src/commands/core/withdraw.rs +++ b/spark-cli/src/commands/core/withdraw.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id}; use clap::Args; use fuels::{accounts::ViewOnlyAccount, types::AssetId}; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/info/account.rs b/spark-cli/src/commands/info/account.rs index c062c62..76c9210 100644 --- a/spark-cli/src/commands/info/account.rs +++ b/spark-cli/src/commands/info/account.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id, AccountType}; use clap::Args; use fuels::types::{Address, ContractId, Identity}; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/info/config.rs b/spark-cli/src/commands/info/config.rs index f412280..d5ba8d9 100644 --- a/spark-cli/src/commands/info/config.rs +++ b/spark-cli/src/commands/info/config.rs @@ -1,6 +1,6 @@ use crate::utils::{setup, validate_contract_id}; use clap::Args; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; #[derive(Args, Clone)] #[command(about = "Query the market for its configurable variables")] diff --git a/spark-cli/src/commands/info/fee.rs b/spark-cli/src/commands/info/fee.rs index ac9ff30..9a20cfc 100644 --- a/spark-cli/src/commands/info/fee.rs +++ b/spark-cli/src/commands/info/fee.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id, AccountType}; use clap::Args; use fuels::types::{Address, ContractId, Identity}; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/info/order.rs b/spark-cli/src/commands/info/order.rs index 3a09894..8d30aa6 100644 --- a/spark-cli/src/commands/info/order.rs +++ b/spark-cli/src/commands/info/order.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id}; use clap::Args; use fuels::types::Bits256; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; #[derive(Args, Clone)] #[command(about = "Query the market for information about a specific open order")] diff --git a/spark-cli/src/commands/info/order_id.rs b/spark-cli/src/commands/info/order_id.rs index 1b4b62c..6e74105 100644 --- a/spark-cli/src/commands/info/order_id.rs +++ b/spark-cli/src/commands/info/order_id.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id, AccountType, OrderType}; use clap::Args; use fuels::types::{Address, AssetId, ContractId, Identity}; -use spark_market::{MarketContract, OrderType as ContractOrderType}; +use spark_market_sdk::{MarketContract, OrderType as ContractOrderType}; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/spark-cli/src/commands/info/user_orders.rs b/spark-cli/src/commands/info/user_orders.rs index 930c9b1..5b3d03b 100644 --- a/spark-cli/src/commands/info/user_orders.rs +++ b/spark-cli/src/commands/info/user_orders.rs @@ -1,7 +1,7 @@ use crate::utils::{setup, validate_contract_id, AccountType}; use clap::Args; use fuels::types::{Address, ContractId, Identity}; -use spark_market::MarketContract; +use spark_market_sdk::MarketContract; use std::str::FromStr; #[derive(Args, Clone)] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e69de29 From f19c3d256e3e08b0806c55059e73a06938eefc7b Mon Sep 17 00:00:00 2001 From: Alexey Nagorny <35231749+chlenc@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:58:53 +0100 Subject: [PATCH 4/4] Update market-contract/tests/utils/setup.rs Co-authored-by: Braqzen <103777923+Braqzen@users.noreply.github.com> --- market-contract/tests/utils/setup.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/market-contract/tests/utils/setup.rs b/market-contract/tests/utils/setup.rs index 8e607e4..445f2f0 100644 --- a/market-contract/tests/utils/setup.rs +++ b/market-contract/tests/utils/setup.rs @@ -8,9 +8,9 @@ use fuels::{ }; // 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_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"; + "../market-contract/out/debug/market-contract-storage_slots.json"; abigen!(Contract( name = "Market", abi = "./market-contract/out/debug/market-contract-abi.json"