diff --git a/contracts/maker/src/contract.rs b/contracts/maker/src/contract.rs index 4441f52f..0afedba8 100644 --- a/contracts/maker/src/contract.rs +++ b/contracts/maker/src/contract.rs @@ -41,7 +41,10 @@ pub fn instantiate(deps: DepsMut, _env: Env, info: Messag #[entry_point] pub fn execute( - deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg, + deps: DepsMut, + env: Env, + info: MessageInfo, + msg: ExecuteMsg, ) -> Result, ContractError> { match msg { ExecuteMsg::Subscribe { subaccount_id, amount } => subscribe(deps, env, info.sender, subaccount_id, amount), @@ -49,7 +52,11 @@ pub fn execute( } pub fn subscribe( - _deps: DepsMut, env: Env, sender: Addr, subaccount_id: String, amount: Coin, + _deps: DepsMut, + env: Env, + sender: Addr, + subaccount_id: String, + amount: Coin, ) -> Result, ContractError> { let contract = env.contract.address; @@ -91,8 +98,14 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Std } fn get_action( - deps: Deps, is_deriv: bool, open_orders: Vec, position: Option, inv_base_val: String, - inv_val: String, std_dev: String, mid_price: String, + deps: Deps, + is_deriv: bool, + open_orders: Vec, + position: Option, + inv_base_val: String, + inv_val: String, + std_dev: String, + mid_price: String, ) -> StdResult { // Wrap everything let open_orders: Vec = open_orders.into_iter().map(|o| o.wrap(deps).unwrap()).collect(); @@ -193,7 +206,11 @@ fn get_action( } } fn orders_to_cancel( - open_orders: Vec, new_head: Decimal, new_tail: Decimal, is_buy: bool, is_deriv: bool, + open_orders: Vec, + new_head: Decimal, + new_tail: Decimal, + is_buy: bool, + is_deriv: bool, ) -> (Vec, Vec, Decimal, bool) { if is_deriv { orders_to_cancel_deriv(open_orders, new_head, new_tail, is_buy) @@ -203,8 +220,17 @@ fn orders_to_cancel( } fn create_orders( - new_head: Decimal, new_tail: Decimal, inv_val: Decimal, orders_to_keep: Vec, orders_remaining_val: Decimal, - position: Option, append_to_new_head: bool, hashes_to_cancel: &mut Vec, is_deriv: bool, is_buy: bool, state: &State, + new_head: Decimal, + new_tail: Decimal, + inv_val: Decimal, + orders_to_keep: Vec, + orders_remaining_val: Decimal, + position: Option, + append_to_new_head: bool, + hashes_to_cancel: &mut Vec, + is_deriv: bool, + is_buy: bool, + state: &State, ) -> Vec { if is_deriv { let position_qty = match position { @@ -256,7 +282,12 @@ fn create_orders( } fn reservation_price( - mid_price: Decimal, inv_imbal: Decimal, varience: Decimal, risk_aversion: Decimal, manual_offset_perct: Decimal, imbal_is_long: bool, + mid_price: Decimal, + inv_imbal: Decimal, + varience: Decimal, + risk_aversion: Decimal, + manual_offset_perct: Decimal, + imbal_is_long: bool, ) -> Decimal { if inv_imbal == Decimal::zero() { mid_price diff --git a/contracts/maker/src/derivative.rs b/contracts/maker/src/derivative.rs index 8f0ad571..f45a0021 100644 --- a/contracts/maker/src/derivative.rs +++ b/contracts/maker/src/derivative.rs @@ -30,7 +30,10 @@ pub fn inv_imbalance_deriv(position: &Option, inv_val: Decimal) /// * `append_to_new_head` - An indication of whether we should append new orders to the new head /// or to the back of the orders_to_keep block pub fn orders_to_cancel_deriv( - open_orders: Vec, new_head: Decimal, new_tail: Decimal, is_buy: bool, + open_orders: Vec, + new_head: Decimal, + new_tail: Decimal, + is_buy: bool, ) -> (Vec, Vec, Decimal, bool) { let mut orders_remaining_val = Decimal::zero(); let mut hashes_to_cancel: Vec = Vec::new(); @@ -61,8 +64,15 @@ pub fn orders_to_cancel_deriv( } pub fn base_deriv( - new_head: Decimal, new_tail: Decimal, inv_val: Decimal, orders_to_keep: Vec, orders_remaining_val: Decimal, - mut position_qty: Decimal, touch_head: bool, is_buy: bool, state: &State, + new_head: Decimal, + new_tail: Decimal, + inv_val: Decimal, + orders_to_keep: Vec, + orders_remaining_val: Decimal, + mut position_qty: Decimal, + touch_head: bool, + is_buy: bool, + state: &State, ) -> (Vec, Decimal) { let num_open_orders = Uint256::from_str(&orders_to_keep.len().to_string()).unwrap(); let mut orders_to_open: Vec = Vec::new(); @@ -117,7 +127,12 @@ pub fn base_deriv( } pub fn tail_to_head_deriv( - new_head: Decimal, inv_val: Decimal, orders_to_keep: Vec, orders_remaining_val: Decimal, position_qty: Decimal, is_buy: bool, + new_head: Decimal, + inv_val: Decimal, + orders_to_keep: Vec, + orders_remaining_val: Decimal, + position_qty: Decimal, + is_buy: bool, state: &State, ) -> (Vec, Vec) { let (mut orders_to_open, mut position_qty) = base_deriv( @@ -165,8 +180,13 @@ pub fn tail_to_head_deriv( } pub fn head_to_tail_deriv( - new_tail: Decimal, inv_val: Decimal, orders_to_keep: Vec, orders_remaining_val: Decimal, mut position_qty: Decimal, - is_buy: bool, state: &State, + new_tail: Decimal, + inv_val: Decimal, + orders_to_keep: Vec, + orders_remaining_val: Decimal, + mut position_qty: Decimal, + is_buy: bool, + state: &State, ) -> (Vec, Vec) { let mut orders_to_open: Vec = Vec::new(); let mut additional_hashes_to_cancel: Vec = Vec::new(); diff --git a/contracts/maker/src/spot.rs b/contracts/maker/src/spot.rs index 6d29e1d5..041bb392 100644 --- a/contracts/maker/src/spot.rs +++ b/contracts/maker/src/spot.rs @@ -32,7 +32,10 @@ pub fn inv_imbalance_spot(inv_base_val: Decimal, inv_val: Decimal) -> (Decimal, /// * `append_to_new_head` - An indication of whether we should append new orders to the new head /// or to the back of the orders_to_keep block pub fn orders_to_cancel_spot( - open_orders: Vec, new_head: Decimal, new_tail: Decimal, is_buy: bool, + open_orders: Vec, + new_head: Decimal, + new_tail: Decimal, + is_buy: bool, ) -> (Vec, Vec, Decimal, bool) { let mut orders_remaining_val = Decimal::zero(); let mut hashes_to_cancel: Vec = Vec::new(); @@ -76,8 +79,14 @@ pub fn orders_to_cancel_spot( /// # Returns /// * `orders_to_open` - A list of all the new orders that we would like to place pub fn create_new_orders_spot( - new_head: Decimal, new_tail: Decimal, inv_val: Decimal, orders_to_keep: Vec, orders_remaining_val: Decimal, - append_to_new_head: bool, is_buy: bool, state: &State, + new_head: Decimal, + new_tail: Decimal, + inv_val: Decimal, + orders_to_keep: Vec, + orders_remaining_val: Decimal, + append_to_new_head: bool, + is_buy: bool, + state: &State, ) -> Vec { let num_open_orders = Uint256::from_str(&orders_to_keep.len().to_string()).unwrap(); let mut orders_to_open: Vec = Vec::new(); diff --git a/packages/bindings/src/msg.rs b/packages/bindings/src/msg.rs index d92b7a6c..67e5c670 100644 --- a/packages/bindings/src/msg.rs +++ b/packages/bindings/src/msg.rs @@ -34,7 +34,10 @@ pub enum InjectiveMsg { } pub fn create_subaccount_transfer_msg( - sender: Addr, source_subaccount_id: String, destination_subaccount_id: String, amount: Coin, + sender: Addr, + source_subaccount_id: String, + destination_subaccount_id: String, + amount: Coin, ) -> CosmosMsg { InjectiveMsgWrapper { route: InjectiveRoute::Exchange, diff --git a/rustfmt.toml b/rustfmt.toml index e1314753..5b7fdc01 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,7 +2,6 @@ newline_style = "unix" hard_tabs = false tab_spaces = 4 -fn_args_layout = "Compressed" max_width = 150 # unstable... should we require `rustup run nightly cargo fmt` ?