Skip to main content

IPositionRouter Interface

The IPositionRouter interface defines the functions available in the PositionRouter contract, which manages the queuing and execution of position requests in the Satoshi Perps protocol.

Position Creation

Increase Positions

Creates a request to increase a position.
Creates a request to increase a position using ETH as the input token.

Decrease Positions

Creates a request to decrease a position.

Position Execution

Executes a queued increase position request.
Executes a queued decrease position request.
Executes multiple increase position requests in a single transaction.
Executes multiple decrease position requests in a single transaction.

Request Cancellation

Cancels a pending increase position request.
Cancels a pending decrease position request.

Request Query

Returns the lengths of the request queues (increase queue, decrease queue, already processed increase requests, already processed decrease requests).
Returns the token path for an increase position request.
Returns the token path for a decrease position request.

Configuration

Sets or removes a position keeper who can execute position requests.
Sets the minimum execution fee required for position requests.
Sets whether leverage trading is enabled.
Sets the delay values for position execution.
Sets the starting values for request keys.

Callback System

Callback function called after a position is executed or fails to execute.

State Access

Returns details about an increase position request.
Returns details about a decrease position request.

Usage Notes

  • Position requests are added to a queue and executed by keepers or the public after a delay.
  • Each request requires an execution fee to incentivize keepers to execute it.
  • The PositionRouter uses a callback system to notify external contracts when positions are executed.
  • Requests have a maximum execution time window, after which they can be cancelled.

Security Considerations

  • Ensure acceptable price parameters are set appropriately to avoid unexpected execution at unfavorable prices
  • The execution fee should be sufficient to cover gas costs, otherwise requests may not be executed
  • Consider the delay between request creation and execution when setting acceptable prices