Skip to content

Commit

Permalink
fucke yeah coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Mar 14, 2024
1 parent e87c44a commit 5fb59a9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
1 change: 0 additions & 1 deletion contracts/cosmwasm/order/model.py

This file was deleted.

7 changes: 7 additions & 0 deletions contracts/cosmwasm/order/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}


9 changes: 9 additions & 0 deletions contracts/cosmwasm/order/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 16 additions & 2 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SolvedOrder>,
pair: DenomPair,
Expand All @@ -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)?;
Expand Down
17 changes: 17 additions & 0 deletions contracts/cosmwasm/order/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,23 @@ pub struct CowFillResult {
pub event: Event,
}

pub struct CvmFillResult {
pub tracking: TrackedOrderItem,
pub remaining: Option<OrderItem>,
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;
Expand Down

0 comments on commit 5fb59a9

Please sign in to comment.