Skip to content

Commit

Permalink
fixed compile time errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Mar 26, 2024
1 parent d4d1830 commit 36dde3b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
13 changes: 7 additions & 6 deletions mantis/node/src/bin/mantis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use cosmrs::{
use cw_mantis_order::{Amount, OrderItem, OrderSolution, OrderSubMsg, SolutionSubMsg};
use mantis_node::{
mantis::{
args::*,
cosmos::{
args::*, autopilot, cosmos::{
client::*,
cosmwasm::{smart_query, to_exec_signed, to_exec_signed_with_fund},
*,
},
}, indexer::{get_all_orders, get_cvm_glt}, simulate
},
prelude::*,
solver::{orderbook::OrderList, solution::Solution},
Expand Down Expand Up @@ -58,7 +57,7 @@ async fn main() {
&signer,
)
.await;
simulate_order(
simulate::simulate_order(
&mut write_client,
&mut cosmos_query_client,
args.order_contract.clone(),
Expand All @@ -79,7 +78,7 @@ async fn main() {
&signer,
)
.await;
cleanup(
autopilot::cleanup(
&mut write_client,
&mut cosmos_query_client,
args.order_contract.clone(),
Expand Down Expand Up @@ -138,6 +137,8 @@ async fn main() {
async fn solve(
write_client: &mut CosmWasmWriteClient,
cosmos_query_client: &mut CosmWasmReadClient,
// really this should query Python Blackbox
cvm_contact: &String,
order_contract: &String,
signing_key: &cosmrs::crypto::secp256k1::SigningKey,
rpc: &str,
Expand All @@ -149,7 +150,7 @@ async fn solve(
if !all_orders.is_empty() {
let cows_per_pair = mantis_node::mantis::solve::do_cows(all_orders);
let cows_cvm = route(cows_per_pair, all_orders);
let cvm_rest = mantis_node::mantis::cosmos::client::get_cvm_routing_data(rpc).await;
let cvm_rest = get_cvm_glt(cvm_contact, rpc).await;
for (cows, optimal_price) in cows_per_pair {
send_solution(
cows,
Expand Down
9 changes: 7 additions & 2 deletions mantis/node/src/mantis/autopilot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use cosmrs::{tx::Msg, Gas};

async fn cleanup(
use crate::{mantis::cosmos::{client::{simulate_and_set_fee, tx_broadcast_single_signed_msg}, cosmwasm::to_exec_signed}, prelude::*};

use super::cosmos::client::{CosmWasmWriteClient, CosmosQueryClient, Tip};

pub async fn cleanup(
write_client: &mut CosmWasmWriteClient,
cosmos_query_client: &mut CosmosQueryClient,
order_contract: String,
Expand All @@ -26,6 +31,6 @@ async fn cleanup(
}

/// move protocol forwards, cranks auctions ending and also cleans up old orders
async fn move(){
async fn _move(){

}
2 changes: 1 addition & 1 deletion mantis/node/src/mantis/blackbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn new_exchange(exchange: &Exchange) -> CvmInstruction {
}

/// `order_accounts` - account of order where to dispatch amounts (part of whole)
async fn route(server: &str, input: BankInput, glt: &GetConfigResponse, salt: &[u8]) -> CvmProgram {
pub async fn route(server: &str, input: BankInput, glt: &GetConfigResponse, salt: &[u8]) -> CvmProgram {
let blackbox: Client = Client::new(server);
let mut route = blackbox
.simulator_router_simulator_router_get(
Expand Down
11 changes: 11 additions & 0 deletions mantis/node/src/mantis/indexer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use cvm_runtime::outpost::GetConfigResponse;
use cw_mantis_order::OrderItem;

use crate::mantis::cosmos::cosmwasm::smart_query;

use super::cosmos::client::{CosmWasmReadClient, Tip};


Expand All @@ -17,3 +20,11 @@ pub async fn get_all_orders(
println!("all_orders: {:?}", all_orders);
all_orders
}

pub async fn get_cvm_glt(contract: &String, cosmos_query_client: &mut CosmWasmReadClient,
) -> GetConfigResponse {
let query = cvm_runtime::outpost::QueryMsg::GetConfig {};
let cvm_glt = smart_query::<_, GetConfigResponse>(contract, query, cosmos_query_client)
.await;
cvm_glt
}
5 changes: 4 additions & 1 deletion mantis/node/src/mantis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pub mod args;
pub mod cosmos;
pub mod solve;
pub mod blackbox;
pub mod blackbox;
pub mod indexer;
pub mod autopilot;
pub mod simulate;
10 changes: 5 additions & 5 deletions mantis/node/src/mantis/simulate.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use cosmrs::tendermint::block::Height;
use cosmrs::{tendermint::block::Height, tx::Msg, Gas};
use cw_mantis_order::{OrderItem, OrderSolution, OrderSubMsg};

use crate::{
prelude::*,
solver::{orderbook::OrderList, solution::Solution, types::OrderType},
mantis::cosmos::{client::{simulate_and_set_fee, tx_broadcast_single_signed_msg}, cosmwasm::to_exec_signed_with_fund}, prelude::*, solver::{orderbook::OrderList, solution::Solution, types::OrderType}
};

use super::cosmos::client::timeout;
use super::cosmos::client::{timeout, CosmWasmWriteClient, CosmosQueryClient, Tip};

pub fn randomize_order(
coins_pair: String,
Expand Down Expand Up @@ -62,7 +61,7 @@ fn randomize_coin(coin_0_amount: u128) -> u128 {
/// timeout is also randomized starting from 10 to 100 blocks
///
/// Also calls `timeout` so old orders are cleaned.
async fn simulate_order(
pub async fn simulate_order(
write_client: &mut CosmWasmWriteClient,
cosmos_query_client: &mut CosmosQueryClient,
order_contract: String,
Expand All @@ -79,6 +78,7 @@ async fn simulate_order(

let auth_info = simulate_and_set_fee(signing_key, &tip.account, gas).await;


let msg = to_exec_signed_with_fund(signing_key, order_contract, msg, fund);

let result = tx_broadcast_single_signed_msg(
Expand Down

0 comments on commit 36dde3b

Please sign in to comment.