SIP-2011: Perps V2 Updates

Author
StatusImplemented
TypeGovernance
NetworkOptimism
ImplementorLeo Massazza (@leomassazza), David (@davidvuong)
ReleaseTBD
ProposalLoading status...
Created2023-04-24

Simple Summary

The sip proposes to implement the following:

  • allMarketSummaries function, provides an overview of all markets, however, the introduction of funding rate velocity resulted in allMarketSummaries calls to revert, as legacy markets don't have this concept of velocity.
  • Removal of the ability of accounts to interact with their position and margin, if there are pending orders that are yet to be executed.
  • Immediate cancellation of pending orders when an account is flagged for liquidation.

Motivation

The motivation as as follows:

  • allMarketSummaries is necessary as it provides an overview of all markets, both legacy & v2 markets in a single contract call.
  • Margin & positions should not be allowed to be changed, if an order committed to is yet to be executed, in order to protect against abuse.
  • In order to ensure that liquidations take place without delay, this sips incorporates the ability to immediately cancel pending orders upon flag.

Specification

All Market Summaries Fix

Legacy markets would be assigned a value of 0 for funding rate velocity under allMarketSummaries().

Modifier For Delayed Orders

A modifier is incorporated into the _transferMargin_, _modifyPosition_ and _closePosition, checking if pending orders are yet to be executed on a given account before applying the change:

    modifier onlyIfNotPendingOrder() {
        require(marketState.delayedOrders(messageSender).sizeDelta == 0, "Pending order exists");
        _;
    }

Cancellation of Pending Orders On Flag

When an account is flagged, pending orders are cancelled and the minKeeperFee set aside for execution/cancellation of the order is paid to the account flagging.

Test Cases

N/A

Configurable Values (Via SCCP)

N/A

Copyright and related rights waived via CC0.