switch to u64

This commit is contained in:
Felix
2024-06-05 16:41:41 +00:00
parent 3bed20dc40
commit 55cba72eec
5 changed files with 39 additions and 29 deletions

View File

@ -1,15 +1,14 @@
use std::io::{self, Write};
use anyhow::{anyhow, Result};
use sha2::{Sha256, Digest};
use base91;
#[derive(Debug)]
pub struct Coordinator;
#[derive(Debug)]
pub enum OfferType {
Buy(u32),
Sell(u32),
Buy(u64),
Sell(u64),
}
#[derive(Debug)]

View File

@ -0,0 +1,15 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
pub struct OfferCreationResponse {
pub locking_address: String,
pub locking_amount: u32, // validate
}
#[derive(Serialize)]
pub struct OrderRequest {
pub robohash_base91: String,
pub amount_satoshi: u64,
pub order_type: String, // buy or sell
pub bond_ratio: u8 // [2, 50]
}

View File

@ -1,25 +1,14 @@
use reqwest;
pub mod api;
use anyhow::Result;
use serde::{Deserialize, Serialize};
use crate::cli::{TraderSettings, OfferType};
#[derive(Debug, Deserialize)]
pub struct OfferCreationResponse {
pub locking_address: String,
}
#[derive(Serialize)]
struct OrderRequest {
robohash_base91: String,
amount_satoshi: u32,
order_type: String, // buy or sell
bond_ratio: u8 // [x > 2, 50]
}
use api::{OrderRequest, OfferCreationResponse};
impl OfferCreationResponse {
fn _format_request(trader_setup: &TraderSettings) -> OrderRequest {
let amount: u32;
let amount: u64;
let trade_type = match &trader_setup.trade_type {
OfferType::Buy(val) => {
amount = *val;

View File

@ -6,19 +6,23 @@ mod trading;
use core::panic;
use cli::CliSettings;
use anyhow::Result;
use communication::fetch_offer;
use anyhow::{anyhow, Result};
fn start_trade_pipeline(cli_input: &CliSettings) -> Result<()> {
if let CliSettings::Maker(maker_data) = cli_input {
Ok(trading::run_maker(maker_data)?)
} else if let CliSettings::Taker(taker_data) = cli_input {
Err(anyhow!("not implemented!"))
// trading::taker::run_taker(taker_data)?;
} else {
Err(anyhow!("Wrong mode selected!"))
}
}
fn main() -> Result<()> {
let mode = CliSettings::parse_cli_args()?;
dbg!("CLI input :", &mode);
start_trade_pipeline(&mode)?;
// if let CliSettings::Maker(maker_data) = &mode {
// trading::maker::run_maker(maker_data)?;
// } else if let CliSettings::Taker(taker_data) = &mode {
// trading::taker::run_taker(taker_data)?;
// } else {
// panic!("Wrong mode selected!")
// }
Ok(())
}

View File

@ -3,9 +3,12 @@
// use utils;
use anyhow::Result;
use crate::cli::TraderSettings;
use crate::communication::create_offer;
use crate::communication::api::OfferCreationResponse;
pub fn run_maker(maker_config: &TraderSettings) -> Result<()> {
let offer_conditions = create_offer(maker_config)?;
let offer_conditions = OfferCreationResponse::fetch(maker_config)?;
// maker_utils::maker(offer_conditions, maker_config)
Ok(())
}