Skip to content

Commit

Permalink
split simulate vs solve
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Mar 11, 2024
1 parent cc8b704 commit 7c84e46
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
5 changes: 5 additions & 0 deletions mantis/node/src/mantis/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct MantisArgs {
pub enum MantisCommands {
Solve(SolverArgs),
Id(IdArgs),
Simulate(SimulateArgs),
}

#[derive(Debug, Parser)]
Expand All @@ -37,6 +38,7 @@ pub enum AssetCommands {

#[derive(clap::Parser, Debug)]
pub struct SolverArgs {

/// the node hosting order contract
#[arg(long)]
pub rpc_centauri: String,
Expand Down Expand Up @@ -72,6 +74,9 @@ pub struct SolverArgs {

#[arg(long, default_value_t = 1_000_000_000)]
pub gas: Gas,

#[arg(long, default_value_t = 100_000)]
pub
}

impl MantisArgs {
Expand Down
39 changes: 25 additions & 14 deletions mantis/node/src/mantis/blackbox/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use blackbox_rs::{prelude::*, types::*, Client};
/// Given total amount it, order owners and desired out, produce CVM program from and by requesting route
use cvm_runtime::{
outpost::GetConfigResponse, shared::{CvmInstruction, Displayed, XcAddr, CvmProgram}, Amount, AssetId, ExchangeId
outpost::GetConfigResponse, proto::cvm, shared::{CvmInstruction, CvmProgram, Displayed, XcAddr}, Amount, AssetId, ExchangeId
};


Expand Down Expand Up @@ -29,6 +29,27 @@ impl BankInput {
}
}

/// given route and CVM stub with amount, build it to the end
fn build_next(current: &mut CvmProgram, next: &mut [NextItem]) -> CvmInstruction {
match next.split_first_mut() {
Some((head, rest)) => {
match head {
NextItem::Exchange(exchange) => {
let exchange = new_exchange(exchange);
current.instructions.push(CvmInstruction::Exchange(exchange));
build_next(current, rest)
},
NextItem::Spawn(spawn) => {
let spawn = new_spawn(spawn);
current.instructions.push(CvmInstruction::Spawn(spawn));
build_next(spawn.program, rest)
},
}
}
None => info!("no more routes"),
}
}

/// `order_accounts` - account of order where to dispatch amounts (part of whole)
async fn route(
server: &str,
Expand All @@ -49,17 +70,7 @@ async fn route(
.into_inner()
.get(0).expect("at least one route");

fn build_next(current: CvmProgram, next: &mut [NextItem]) -> CvmInstruction {
match next.split_first_mut() {
Some((head, rest) => {
match head {
NextItem::Exchange(_) => todo!(),
NextItem::Spawn(_) => todo!(),
}
}
None => info!("no more routes"),
}
}
}
CvmInstruction::Spawn { network_id: (), salt: (), assets: (), program: () }
let mut program = CvmProgram::new();
build_next(&mut current, &mut route.next);
return program;
}

0 comments on commit 7c84e46

Please sign in to comment.