PNL Settlement

DerivaDEX settles all traders' PNLs periodically. Settlement occurs approximately every 8 hours worth of blocks (mainnet = 1920 blocks; kovan = 7200 blocks. This difference is due to the roughly 15 second block time on mainnet vs roughly 4 second block time on kovan). The settlement frequency can be modified via DerivaDAO governance.

PNL settlement takes place for every open position a trader has with the following two steps:

  1. All unrealized PNL becomes realized PNL: at all points in time, users have a strategy collateral value, which are tokens they rightfully possess (on the exchange, but noncustodially in their, and only their, possession). Open positions also have an unrealized PNL with respect to the mark price that can be thought of as paper profits or losses. When PNL settlement occurs, this unrealized PNL realizes, thereby crediting/debiting your strategy collateral accordingly. Net-net, in some sense, nothing has really changed as your strategy value is unchanged. Moreover, how the exchange considers your strategy when assessing liquidations is also unchanged since margin fraction looks at your strategy value, which as mentioned, is unchanged.

  2. The open position's average entry price resets to the current mark price: Given that DerivaDEX realizes unrealized PNL relative to a given mark price, in order to ensure that the strategy value proceeds as it would have even if PNL settlement were to not have taken place, the average entry price must now be set to the current mark price.

Example

Let's take a look at an example to illustrate. Imagine Alice has deposited 1000 USDC as collateral on DerivaDEX and goes long 5 ETHPERP at a price of 2000 USD. Imagine 8 hours from now, at the time of PNL settlement, the mark price of ETHPERP has risen to 3000 USD.

The following two scenarios demonstrate how PNL settlement works - please take note that scenario 1 is NOT how DerivaDEX handles things. DerivaDEX uses scenario 2. Both are presented, however, to more clearly describe what happens:

  • Scenario 1 (no PNL settlement): Alice has an unrealized PNL of 5000 USD given that she is long 5 ETHPERP contracts and the price has risen by 1000 USD each relative to her average entry price of 2000 USDC. If she were to withdraw, she could withdraw (imagine an unrealistic no-liquidation paradigm for a second where you don't need any collateral to support open positions) a maximum of 1000 USDC since that is her strategy collateral despite her strategy value of 6000 USDC. She could then choose to close her long position to realize the additional 5000 USDC unrealized profit, and then withdraw that amount, reaching the total of 6000 USDC that her strategy was worth.

  • Scenario 2 (PNL settlement): Once again, Alice has an unrealized PNL of 5000 USD given that she is long 5 ETHPERP contracts and the price has risen by 1000 USD each. This unrealized PNL is realized upon PNL settlement, thus her strategy collateral will now actually be 6000 USDC, matching her strategy value of 6000 USDC (although the unrealized component of this is now 0 USDC since the average entry price was just set to the current mark price of 3000 USD). If she were to withdraw, she could withdraw (imagine an unrealistic no-liquidation paradigm for a second where you don't need any collateral to support open positions) a maximum of 6000 USDC since that is her strategy collateral. She could then choose to close her long position that she still has, but this would actually realize 0 USDC of unrealized PNL. In the end, she was able to withdraw the same amount of collateral as in scenario 1, but this approach is much more desirable for traders and versatile, hence is adopted by DerivaDEX.

Last updated