mirror of
https://github.com/RoboSats/taptrade-core.git
synced 2025-07-19 01:03:30 +00:00
switch to u64
This commit is contained in:
@ -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)]
|
||||
|
15
taptrade-cli-demo/trader/src/communication/api.rs
Normal file
15
taptrade-cli-demo/trader/src/communication/api.rs
Normal 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]
|
||||
}
|
@ -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;
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user