PositionManager
The PositionManager contract extends BasePositionManager with user-facing functionality for position management. It includes role-based access control for position execution and liquidation.Contract Overview
The PositionManager handles:- Direct creation, modification, and liquidation of positions
- Execution of orders from the OrderBook
- Role-based access control for different operations
- Integration with the OrderBook for limit orders
The PositionManager provides direct position execution functionality, as opposed to the queue-based approach of the PositionRouter.
Key Functions
Position Management
Liquidation
Order Execution
Access Control
The PositionManager implements several access control mechanisms:Validation
Integration with OrderBook
The PositionManager is tightly integrated with the OrderBook contract:Security Considerations
The PositionManager implements several security features:- Role-Based Access Control: Different roles for order execution and liquidation
- Price Validation: Ensures that positions are executed at reasonable prices
- Integration Validation: Validates interaction with other contracts
- Error Handling: Comprehensive error handling for various failure scenarios
Example Usage
1
Increasing a Position
A trader wants to open a 5x long ETH position with 1 ETH as collateral.
2
Decreasing a Position
Later, the trader wants to close half of the position.
3
Executing an Order
An order keeper notices a pending increase order that meets its execution conditions.