Skip to content

Commit

Permalink
why
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Nov 22, 2023
1 parent 8acc22b commit ba00814
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
13 changes: 8 additions & 5 deletions contracts/cosmwasm/order/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ cw-storage-plus = { version = "^1.2.0", features = [
itertools = { workspace = true, features = [
"use_std",
], default-features = false }
num-rational = { version = "0.4.1", default-features = false, features = [
"num-bigint-std",
"std",
] }

num-integer = { version = "^0.1.45", default-features = false, features = [
"std",
] }
Expand All @@ -35,4 +32,10 @@ cvm = { path = "../../../crates/cvm", default-features = false, features = [
"json-schema",
] }

tuples ={ workspace = true }
tuples ={ workspace = true }

[dev-dependencies]
num-rational = { version = "0.4.1", default-features = false, features = [
"num-bigint-std",
"std",
] }
4 changes: 2 additions & 2 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,15 @@ fn solves_cows_via_bank(
if order.pair().0 == filled_wanted.denom {
a_total_in = a_total_in.checked_sub(cowed.u128()).ok_or_else(|| {
StdError::generic_err(format!(
"a underflow: {} - {}",
"a underflow: {} {}",
a_total_in,
cowed.u128().to_string()
))
})?;
} else {
b_total_in = b_total_in.checked_sub(cowed.u128()).ok_or_else(|| {
StdError::generic_err(format!(
"b underflow: {} - {}",
"b underflow: {} {}",
b_total_in,
cowed.u128().to_string()
))
Expand Down
5 changes: 3 additions & 2 deletions contracts/cosmwasm/order/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ impl OrderItem {
self.given.amount = <_>::default();
self.msg.wants.amount = <_>::default();
} else {
self.msg.wants.amount = self.msg.wants.amount - wanted_transfer;
self.msg.wants.amount = self.msg.wants.amount.checked_sub(wanted_transfer).expect("proven above via comparison");
let given_reduction = wanted_transfer * self.given.amount / self.msg.wants.amount;
self.given.amount = self.given.amount - given_reduction;

self.given.amount = self.given.amount.checked_sub(given_reduction).expect("proven above via ratio");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mainnet.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
RUST_BACKTRACE=1 RUST_TRACE=trace cargo run --bin mantis -- --rpc-centauri "https://composable-rpc.polkachu.com:443" --grpc-centauri "https://composable-grpc.polkachu.com:22290" --osmosis "todo" --neutron "todo" --cvm-contract "centauri1wpf2szs4uazej8pe7g8vlck34u24cvxx7ys0esfq6tuw8yxygzuqpjsn0d" --wallet "$WALLET" --order-contract "centauri1p2fj89ncs8gulm2trwuaz7yz9r5nujd9azrx5mxn5pah8dy8cl0qgg90ec" --simulate "200000ppica,3ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0"
RUST_BACKTRACE=1 RUST_TRACE=trace cargo run --bin mantis -- --rpc-centauri "https://composable-rpc.polkachu.com:443" --grpc-centauri "https://composable-grpc.polkachu.com:22290" --osmosis "todo" --neutron "todo" --cvm-contract "centauri1wpf2szs4uazej8pe7g8vlck34u24cvxx7ys0esfq6tuw8yxygzuqpjsn0d" --wallet "$WALLET" --order-contract "centauri1a2jkcrgrrk5te4uwz4derw5704sj5pvnfencgy7f0y3uc7kugrzsxf9dfd" --simulate "200000ppica,3ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0"

0 comments on commit ba00814

Please sign in to comment.