Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigz/settle-pnl-with-position-non-active-market #954

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Features
- program: allow user to settle realized pnl in reduce only market status ([#954](https://github.com/drift-labs/protocol-v2/pull/954))

### Fixes

Expand Down
24 changes: 16 additions & 8 deletions programs/drift/src/controller/pnl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,6 @@
}
}

validate!(
perp_market.status == MarketStatus::Active,
ErrorCode::InvalidMarketStatusToSettlePnl,
"Cannot settle pnl under current market = {} status",
market_index
)?;

validate!(
!perp_market.is_operation_paused(PerpOperation::SettlePnl),
ErrorCode::InvalidMarketStatusToSettlePnl,
Expand All @@ -189,7 +182,22 @@
validate!(
!perp_market.is_operation_paused(PerpOperation::SettlePnlWithPosition),
ErrorCode::InvalidMarketStatusToSettlePnl,
"Cannot settle pnl with position under current market = {} status",
"Cannot settle pnl with position under current market = {} operation paused",
market_index
)?;

validate!(

Check warning on line 189 in programs/drift/src/controller/pnl.rs

View check run for this annotation

Codecov / codecov/patch

programs/drift/src/controller/pnl.rs#L189

Added line #L189 was not covered by tests
perp_market.status == MarketStatus::Active,
ErrorCode::InvalidMarketStatusToSettlePnl,

Check warning on line 191 in programs/drift/src/controller/pnl.rs

View check run for this annotation

Codecov / codecov/patch

programs/drift/src/controller/pnl.rs#L191

Added line #L191 was not covered by tests
"Cannot settle pnl with position under non-Active current market = {} status",
market_index
)?;
} else {
validate!(

Check warning on line 196 in programs/drift/src/controller/pnl.rs

View check run for this annotation

Codecov / codecov/patch

programs/drift/src/controller/pnl.rs#L196

Added line #L196 was not covered by tests
perp_market.status == MarketStatus::Active
|| perp_market.status == MarketStatus::ReduceOnly,
ErrorCode::InvalidMarketStatusToSettlePnl,

Check warning on line 199 in programs/drift/src/controller/pnl.rs

View check run for this annotation

Codecov / codecov/patch

programs/drift/src/controller/pnl.rs#L198-L199

Added lines #L198 - L199 were not covered by tests
"Cannot settle pnl under current market = {} status (neither Active or ReduceOnly)",
market_index
)?;
}
Expand Down
Loading