Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Nov 16, 2023
1 parent 7ceeb21 commit 0c9a8cb
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion contracts/cosmwasm/order/src/bin/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
fn main() {
use cosmwasm_schema::write_api;
use cw_mantis_order::sv::*;
use cw_mantis_order::*;

write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
Expand Down
6 changes: 3 additions & 3 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ impl OrderContract<'_> {
let spawn = if let Some(execute) = spawn.execute {
let program = Self::traverse_route(execute);
XcInstruction::Spawn {
network_id: spawn.to_chain.into(),
network_id: spawn.to_chain,
salt: b"solution".to_vec(),
assets: <_>::default(), // map spawn.carry to CVM assets
program,
}
} else {
XcInstruction::Spawn {
network_id: spawn.to_chain.into(),
network_id: spawn.to_chain,
salt: b"solution".to_vec(),
assets: <_>::default(), // map spawn.carry to CVM assets
program: XcProgram {
Expand Down Expand Up @@ -620,7 +620,7 @@ fn solves_cows_via_bank(
for order in all_orders.iter() {
let cowed = order.solution.cow_amount;
let amount = Coin {
amount: cowed.into(),
amount: cowed,
..order.given().clone()
};

Expand Down
14 changes: 7 additions & 7 deletions crates/cvm/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,17 @@ impl Amount {
value
} else {
let value = value
.checked_sub(self.intercept.0.into())
.checked_sub(self.intercept.0)
.ok_or(ArithmeticError::Underflow)?;
let value = value
.checked_mul(self.slope.0.into())
.ok_or(ArithmeticError::Underflow)?
.checked_div(Self::MAX_PARTS.into())
.ok_or(ArithmeticError::Overflow)?;
let value = value
.checked_add(self.intercept.0.into())
.ok_or(ArithmeticError::Overflow)?;

value
.checked_add(self.intercept.0)
.ok_or(ArithmeticError::Overflow)?
};
Ok(u128::min(value, amount))
}
Expand Down Expand Up @@ -234,10 +234,10 @@ impl Amount {
.ok_or(ArithmeticError::Overflow)?,
)
.ok_or(ArithmeticError::Overflow)?;
let value = value
.checked_mul(10_u128.pow(decimals as u32))
.ok_or(ArithmeticError::Overflow)?;

value
.checked_mul(10_u128.pow(decimals as u32))
.ok_or(ArithmeticError::Overflow)?
};
Ok(u128::min(value, amount))
}
Expand Down
2 changes: 2 additions & 0 deletions mantis/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name = "mantis-node"
version = "0.1.0"
edition = "2021"



[dependencies]
cw-mantis-order = { path = "../../contracts/cosmwasm/order" }
clap = { workspace = true, features = ["derive"] }
Expand Down
16 changes: 8 additions & 8 deletions mantis/node/src/bin/mantis.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use cosmos_sdk_proto::cosmwasm::wasm::v1::QuerySmartContractStateRequest;
use cosmrs::cosmwasm::*;
use cosmrs::rpc::{Client, HttpClient, HttpClientUrl};


use cw_mantis_order::OrderItem;
use mantis_node::{
mantis::{args::*, cosmos::*},
prelude::*,
};
use std::fmt::Write;


#[tokio::main]
async fn main() {
let args = MantisArgs::parsed();
let mut client = create_wasm_query_client(&args.centauri).await;
let _client = create_wasm_query_client(&args.centauri).await;
let mut write_client = create_wasm_write_client(&args.centauri).await;

while (true) {
loop {
if let Some(assets) = args.simulate.clone() {
simulate_order(&mut write_client, args.order_contract.clone(), assets).await;
};
Expand All @@ -32,7 +32,7 @@ async fn main() {
/// timeout is also randomized starting from 10 to 100 blocks
///
/// Also calls `timeout` so old orders are cleaned.
async fn simulate_order(write_client: &mut WriteClient, order_contract: String, assets: String) {
async fn simulate_order(_write_client: &mut WriteClient, _order_contract: String, _assets: String) {
if std::time::Instant::now().elapsed().as_millis() % 10 == 0 {}
}

Expand All @@ -45,9 +45,9 @@ async fn simulate_order(write_client: &mut WriteClient, order_contract: String,
/// uses cfmm algorithm
async fn solve(
read: &mut ReadClient,
write: WriteClient,
_write: WriteClient,
order_contract: String,
cvm_contract: String,
_cvm_contract: String,
) {
let query = cw_mantis_order::QueryMsg::GetAllOrders {};
let orders_request = QuerySmartContractStateRequest {
Expand Down
2 changes: 1 addition & 1 deletion mantis/node/src/bin/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use itertools::Itertools;

use mantis_node::solver::{orderbook::OrderList, solution::Solution, types::Order};
use mantis_node::{prelude::*, solver::types::Price};

Expand Down
4 changes: 2 additions & 2 deletions mantis/node/src/mantis/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct MantisArgs {
impl MantisArgs {
pub fn parsed() -> Self {
use clap::Parser;
let args = Self::parse();
args

Self::parse()
}
}
8 changes: 4 additions & 4 deletions mantis/node/src/mantis/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::prelude::*;

use cosmos_sdk_proto::cosmwasm::wasm::v1::msg_client::MsgClient;
use cosmos_sdk_proto::cosmwasm::wasm::v1::query_client::QueryClient;
use cosmos_sdk_proto::cosmwasm::wasm::v1::QuerySmartContractStateRequest;
use cosmrs::bip32::secp256k1::elliptic_curve::bigint::modular::constant_mod::ResidueParams;
use cosmrs::cosmwasm::*;
use cosmrs::rpc::{Client, HttpClient, HttpClientUrl};




use tonic::transport::Channel;

pub type WriteClient = MsgClient<Channel>;
Expand Down
2 changes: 1 addition & 1 deletion mantis/node/src/solver/solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<Id: Copy + PartialEq + Debug> Solution<Id> {
.into_iter()
.collect(),
};
let mut solution = Solution::new(matched.filled().value);
let solution = Solution::new(matched.filled().value);

solution.check_constraints();
solution
Expand Down

0 comments on commit 0c9a8cb

Please sign in to comment.