Skip to content

Commit

Permalink
Add check that opened positions are in the Opened state
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Feb 28, 2024
1 parent 628a9b6 commit 789ff2a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use penumbra_proto::StateWriteProto as _;
use crate::{
component::{PositionManager, PositionRead},
event,
lp::action::PositionOpen,
lp::{action::PositionOpen, position},
};

#[async_trait]
Expand All @@ -26,6 +26,9 @@ impl ActionHandler for PositionOpen {
// + the trading function doesn't specify a cyclic pair,
// + the fee is <=50%.
self.position.check_stateless()?;
if self.position.state != position::State::Opened {
anyhow::bail!("attempted to open a position with a state besides `Opened`");
}
Ok(())
}

Expand Down

0 comments on commit 789ff2a

Please sign in to comment.