Skip to main content

How To Manage the Global Position

On Denaria, each user has one global position per market and every new trade is automatically netted against the existing exposure.

This means:

  • Long trades increase long exposure.
  • Short trades reduce long exposure.
  • If a short trade is larger than the current long, the global position flips to short.

Is important to notice that the protocol does not track trades separately at the smart contract level. It always tracks the net exposure and the total collateral.


A practical Example​

Let’s use a practical example to understand how a trader can manage is global position. The starting point is the following:

  • Collateral: $10
  • Global Exposure: Long $50
  • Leverage: 5Γ—

The formula for calculating the leverage for the global position is the following:

Global Leverage = Total Collateral / Net Exposure

From this state, three outcomes are possible.


Scenario 1 β€” Increase the Long​

New action executed by the trader:

+ margin $50 @ 3x β†’ +$150 exposure

The trader opens another long position.

What happens​

  • The new trade adds $150 of additional long exposure.
  • The trader adds $50 (3x leverage) of new collateral.
  • The protocol sums everything.

Result​

  • New Global Exposure: Long $200
  • New Collateral: $60
  • New Leverage: 3.3Γ—

New state of the global position​

The position remains long, but larger.

Leverage is recalculated using total exposure and total collateral.


Scenario 2 β€” Reduce the Long​

New action executed by the trader:

+ margin $10 @ 2x β†’ βˆ’$20 exposure

The trader opens a short smaller than the current long.

What happens​

  • The short introduces **20βˆ—βˆ—ofshortexposure(1020** of short exposure (10 at 2x leverage)
  • This partially offsets the existing $50 long.
  • The position remains net long.

Result​

  • New Global Exposure: Long $30
  • Collateral: $10
  • New Leverage: 3Γ—

New state of the global position​

The short acts like a partial close of the long. No new collateral is required.

The trader is still long, but with smaller exposure and smaller leverage.


Scenario 3 β€” Flip to Short​

New action executed by the trader:

+ margin $50 @ 3x β†’ βˆ’$150 exposure

The trader opens a short larger than the existing long.

What happens​

  • The 150shortmorethanoffsetsthe150 short more than offsets the 50 long.
  • The net exposure crosses zero.
  • The position becomes short.

Result​

  • New Global Exposure: Short $100
  • New Collateral: $60
  • New Leverage: 1.7Γ—

New state of the global position​

The original long is fully neutralized.

The excess short becomes the new global position.