trader implementation

This commit is contained in:
f321x
2024-06-05 11:35:19 +02:00
parent 466bf83be3
commit 2be4586021
8 changed files with 51 additions and 4 deletions

View File

@ -4,7 +4,7 @@
fn index() -> &'static str {
"Hello, world!"
}
j
#[launch]
pub fn webserver() -> Rocket<build> {
rocket::build().mount("/", routes![index])

View File

@ -240,6 +240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
@ -254,6 +255,18 @@ dependencies = [
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "clap_lex"
version = "0.7.0"
@ -497,6 +510,12 @@ version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.3.9"

View File

@ -6,6 +6,6 @@ edition = "2021"
[dependencies]
anyhow = "1.0.86"
bdk = "0.29.0"
clap = "4.5.4"
clap = { version = "4.5.4", features = ["derive", "cargo"] }
reqwest = { version = "0.12.4", features = ["blocking", "json"] }
serde = "1.0.203"

View File

@ -1,9 +1,26 @@
#![allow(unused_variables, unused_imports, dead_code)]
mod cli;
mod communication;
mod trading;
use cli::parse_cli_args;
use core::panic;
fn main() {
use cli::{parse_cli_args, CliSettings};
use anyhow::Result;
use communication::fetch_offer;
fn main() -> Result<()> {
let mode = parse_cli_args();
dbg!(mode);
if let CliSettings::Maker(maker_config) = mode {
trading::maker::run_maker(maker_config)?;
} else if CliSettings::Taker(taker_data) = mode {
trading::taker::run_taker(taker_data)?;
} else {
panic!("Wrong mode selected!")
}
Ok(())
}

View File

@ -0,0 +1,11 @@
// use maker_utils;
// use taker_utils;
// use utils;
use anyhow::Result;
use crate::cli::TraderSettings;
use crate::communication::fetch_offer;
pub fn run_maker(maker_config: &TraderSettings) -> Result<()> {
let offer_conditions = fetch_offer(&maker_config.coordinator_endpoint)?;
// maker_utils::maker(offer_conditions, maker_config)
}