Skip to content

Commit

Permalink
Simplified ensure boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Feb 27, 2024
1 parent 94a43bd commit bf5282a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contracts/orderbook/src/tick_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ use cosmwasm_std::{ensure, Decimal256, Uint256};
// tick_to_price converts a tick index to a price.
// If tick_index is zero, the function returns Decimal256::one().
// Errors if the given tick is outside of the bounds allowed by MIN_TICK and MAX_TICK.
#[allow(clippy::manual_range_contains)]
pub fn tick_to_price(tick_index: i64) -> ContractResult<Decimal256> {
if tick_index == 0 {
return Ok(Decimal256::one());
}

ensure!(
!(tick_index < MIN_TICK) && !(tick_index > MAX_TICK),
tick_index >= MIN_TICK && tick_index <= MAX_TICK,
ContractError::TickOutOfBounds {
tick_id: tick_index
}
Expand Down

0 comments on commit bf5282a

Please sign in to comment.