Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 committed Sep 4, 2023
1 parent 12bdada commit d35cfa6
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 225 deletions.
6 changes: 6 additions & 0 deletions crates/shared/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,17 @@ pub struct Arguments {
#[clap(long, env, default_value = "ParaSwapPool4", use_value_delimiter = true)]
pub disabled_paraswap_dexs: Vec<String>,

/// The 0x HTTP API URL.
#[clap(long, env)]
pub zeroex_url: Option<String>,

#[clap(long, env)]
pub zeroex_api_key: Option<String>,

/// The 0x Websocket API URL.
#[clap(long, env)]
pub zeroex_ws_url: Option<String>,

/// If solvers should use internal buffers to improve solution quality.
#[clap(long, env, action = clap::ArgAction::Set, default_value = "false")]
pub use_internal_buffers: bool,
Expand Down Expand Up @@ -434,6 +439,7 @@ impl Display for Arguments {
display_list(f, "disabled_paraswap_dexs", &self.disabled_paraswap_dexs)?;
display_option(f, "zeroex_url", &self.zeroex_url)?;
display_secret_option(f, "zeroex_api_key", &self.zeroex_api_key)?;
display_option(f, "zeroex_ws_url", &self.zeroex_ws_url)?;
writeln!(f, "use_internal_buffers: {}", self.use_internal_buffers)?;
writeln!(f, "balancer_factories: {:?}", self.balancer_factories)?;
display_list(
Expand Down
5 changes: 3 additions & 2 deletions crates/shared/src/zeroex_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ pub mod websocket {
// all numbers are at most u128::MAX so none of these operations can overflow
let scaled_maker_amount = U256::from(self.order.maker_amount)
* U256::from(self.metadata.remaining_fillable_taker_amount)
/ U256::from(self.order.taker_amount);
.checked_div(self.order.taker_amount.into())
.context("taker_amount is zero")?;

// `scaled_maker_amount` is at most as big as `maker_amount` which already fits
// in an u128
Expand All @@ -636,7 +637,7 @@ pub mod websocket {
remaining_fillable_taker_amount: order_record
.metadata
.remaining_fillable_taker_amount,
state: Default::default(),
state: OrderState::Added,
},
order: order_record.order,
}
Expand Down
Loading

0 comments on commit d35cfa6

Please sign in to comment.