Skip to main content

IOrderBook Interface

The IOrderBook interface defines the functions available in the OrderBook contract, which manages limit orders for the Satoshi Perps protocol.

Order Creation

Increase Position Orders

Creates a limit order to increase a position when the price reaches the trigger price.

Decrease Position Orders

Creates a limit order to decrease a position when the price reaches the trigger price.

Swap Orders

Creates a limit order to swap tokens when the exchange rate reaches the trigger ratio.

Order Cancellation

Cancels a pending increase position order.
Cancels a pending decrease position order.
Cancels a pending swap order.

Order Execution

Executes an increase position order when the trigger condition is met.
Executes a decrease position order when the trigger condition is met.
Executes a swap order when the trigger condition is met.

Order Access

Returns the details of an increase position order.
Returns the details of a decrease position order.
Returns the details of a swap order.

Configuration

Sets the minimum execution fee required for orders.
Sets the minimum purchase token amount in USD.
Sets the address of the PositionManager contract.

State Access

Returns the number of increase orders for an account.
Returns the number of decrease orders for an account.
Returns the number of swap orders for an account.
Returns the minimum execution fee required for orders.

Usage Notes

  • Orders are triggered when the price or ratio conditions are met.
  • Each order requires an execution fee to incentivize keepers to execute it.
  • For increase orders with token swaps, the path should include the tokens to swap through.
  • The triggerAboveThreshold parameter determines if the order should execute when the price goes above or below the trigger price.

Security Considerations

  • Ensure trigger prices are set appropriately to avoid unexpected execution
  • The execution fee should be sufficient to cover gas costs, otherwise orders may not be executed
  • For increase orders, ensure sufficient tokens are approved or sent with the transaction