SIP-2011: Perps V2 Updates

ImplementorLeo Massazza (@leomassazza), David (@davidvuong)
ProposalLoading status...

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.


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.


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


Configurable Values (Via SCCP)


Copyright and related rights waived via CC0.