Skip to content

Commit

Permalink
Merge pull request #200 from osmosis-labs/alpo/swap-step-check
Browse files Browse the repository at this point in the history
[Sumtree]: Add defense in depth check to swap steps
  • Loading branch information
crnbarr93 authored Jul 3, 2024
2 parents 6eb0431 + 25d79fa commit cd637d0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/sumtree-orderbook/src/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ pub(crate) fn run_market_order_internal(
tick_price,
RoundingDirection::Up,
)?;

ensure!(
!input_filled.is_zero(),
ContractError::InvalidSwap {
error: "Input amount for a given swap step cannot be zero".to_string()
}
);

order.quantity = order
.quantity
// Safe conversions as amount filled should never be larger than order quantity which is upper bounded by Uint128::MAX
Expand Down

0 comments on commit cd637d0

Please sign in to comment.