diff --git a/contracts/cosmwasm/order/model.py b/contracts/cosmwasm/order/model.py deleted file mode 100644 index 677a83b8..00000000 --- a/contracts/cosmwasm/order/model.py +++ /dev/null @@ -1 +0,0 @@ -# model of CoW+CVM protocol \ No newline at end of file diff --git a/contracts/cosmwasm/order/src/errors.rs b/contracts/cosmwasm/order/src/errors.rs index 0e398cca..ce0243a3 100644 --- a/contracts/cosmwasm/order/src/errors.rs +++ b/contracts/cosmwasm/order/src/errors.rs @@ -12,3 +12,10 @@ pub fn filled_order_cannot_be_cross_chain_routed() -> StdError { StdError::generic_err("Filled order cannot be cross chain routed") } + + +pub fn partial_cross_chain_not_implemented() -> StdError { + StdError::generic_err("Partial cross chain not implemented") +} + + diff --git a/contracts/cosmwasm/order/src/events.rs b/contracts/cosmwasm/order/src/events.rs index 55d27969..f680d26d 100644 --- a/contracts/cosmwasm/order/src/events.rs +++ b/contracts/cosmwasm/order/src/events.rs @@ -38,6 +38,15 @@ pub mod order { .add_attribute("solver_address", solver_address.clone()) .add_attribute("solution_block_added", solution_block_added.to_string()) } + + pub fn mantis_order_routed_full( + order: &OrderItem, + solver_address: &String, + ) -> Event { + Event::new("mantis-order-routed-full") + .add_attribute("order_id", order.order_id.to_string()) + .add_attribute("solver_address", solver_address.clone()) + } } pub mod solution { diff --git a/contracts/cosmwasm/order/src/lib.rs b/contracts/cosmwasm/order/src/lib.rs index aa17ef1a..7e6efdb6 100644 --- a/contracts/cosmwasm/order/src/lib.rs +++ b/contracts/cosmwasm/order/src/lib.rs @@ -468,7 +468,9 @@ impl OrderContract<'_> { fn pre_fill_remotely<'a>( &self, ctx: ExecCtx<'a>, + storage: &mut dyn Storage, optimal_price: Ratio, + solver_address: String, solution_id: SolutionHash, solver_orders: Vec, pair: DenomPair, @@ -478,10 +480,22 @@ impl OrderContract<'_> { for order in solver_orders.iter() { if let Some(cross_chain_part) = order.solution.cross_chain_part { match cross_chain_part { - OrderAmount::All => todo!(), - OrderAmount::Part(_, _) => return Err(errors::partial_cross_chain_not_implemented()) + OrderAmount::Part(_, _) => return Err(errors::partial_cross_chain_not_implemented()), + OrderAmount::All => { + if order.given().denom == pair.0 { + routed_a_amount += order.given().amount.u128(); + } else { + routed_b_amount += order.given().amount.u128(); + } + self.orders.remove(storage, order.order.order_id.u128()); + ( + mantis_order_routed_full(&order, &solver_address), + false, + ) + } } } + let order_id = order.order.order_id.u128(); let mut item: OrderItem = self.orders.load(ctx.deps.storage, order_id)?; diff --git a/contracts/cosmwasm/order/src/types.rs b/contracts/cosmwasm/order/src/types.rs index 16297e71..4ff2cc9c 100644 --- a/contracts/cosmwasm/order/src/types.rs +++ b/contracts/cosmwasm/order/src/types.rs @@ -395,6 +395,23 @@ pub struct CowFillResult { pub event: Event, } +pub struct CvmFillResult { + pub tracking: TrackedOrderItem, + pub remaining: Option, + pub event: Event, +} + +impl CvmFillResult { + pub fn new(tracking: TrackedOrderItem, event: Event) -> Self { + Self { + tracking, + remaining : None, + event, + } + } +} + + pub type Denom = String; pub type DenomPair = (Denom, Denom); pub type SolverAddress = String;