> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nilemarkets.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Position Reduction

> Reduce a position's notional via reducePositionNotional() while keeping it open — settled at current forward price, minimum remaining notional of 100 USDC, margin released proportionally.

Position reduction allows a trader to decrease the notional size of an open position without fully closing it. This partially realizes PnL on the reduced portion, frees up proportional margin, and keeps the remaining position active with its original entry strike. It is a powerful tool for incremental risk management.

## How It Works

**Function**: `SettlementEngine.reducePosition(uint256 positionId, uint256 reductionNotional)`

When reducing a position, the protocol splits it conceptually into two parts: the portion being closed (the `reductionNotional`) and the portion remaining open. The closed portion is settled at the current forward price, and the remaining portion continues as an open position with proportionally reduced margin and MM threshold.

<Note>
  If `reductionNotional` equals the position's full notional, the reduction is treated as a full close with `CloseReason.EARLY_TERMINATION`. There is no separate "reduce to zero" path -- it seamlessly converts to early termination.
</Note>

## Preconditions

| Condition                                                       | Error on Failure             |
| --------------------------------------------------------------- | ---------------------------- |
| Position status is `OPEN`                                       | `PositionNotOpen`            |
| Position is **not liquidatable**                                | `EarlyTerminationNotAllowed` |
| Caller is the position owner                                    | `NotPositionOwner`           |
| `reductionNotional > 0`                                         | `ZeroAmount`                 |
| Remaining notional >= `minPositionNotional` (unless full close) | `NotionalTooSmall`           |

<Warning>
  If a reduction would leave the position with less than the minimum notional (default 100 USDC), the transaction reverts. The trader must either reduce to a valid amount or close the position entirely. This prevents the creation of dust positions that would be uneconomical to settle.
</Warning>

## Reduction Mechanics

<Steps>
  <Step title="Calculate Proportional Margin at Risk">
    The margin at risk is the proportional share of the position's locked margin:

    ```
    marginAtRisk = (imLocked * reductionNotional) / notional
    ```

    For example, reducing 40% of a position with 20 USDC locked margin puts 8 USDC at risk for the reduction.
  </Step>

  <Step title="Get Forward Price">
    The current forward price for the position's fixing timestamp is fetched from the OracleModule. An oracle fee is collected from the trader's collateral.
  </Step>

  <Step title="Compute PnL on Reduced Portion">
    PnL is calculated only on the `reductionNotional`, not the full position:

    * **LONG**: `pnl = reductionNotional * (forwardPrice - entryStrike) / PRICE_PRECISION`
    * **SHORT**: `pnl = reductionNotional * (entryStrike - forwardPrice) / PRICE_PRECISION`

    Losses are capped at `marginAtRisk - actualFee` (isolated margin guarantee, applied after the fee waterfall below).
  </Step>

  <Step title="Compute Fee on Reduction">
    The trading fee is calculated on the reduction amount only:

    ```
    fee = reductionNotional * snapshotTradingFeeBps / 10000
    ```

    No liquidation penalty is applied. The settlement waterfall is fee-first: `actualFee = min(fee, marginAtRisk)`, and the loss is then capped at the remaining `marginAtRisk - actualFee` (see [Fees](/protocol/fees) for the full waterfall).
  </Step>

  <Step title="Update Remaining Position">
    If this is a partial reduction (not full close), the position is updated:

    * `notional` decreases by `reductionNotional`
    * `imLocked` decreases by `marginAtRisk`
    * `mmThreshold` is reduced proportionally
    * Position remains `OPEN` with the same entry strike, fixing timestamp, and all other parameters unchanged
    * Pool exposure counters are updated to reflect the reduced notional
  </Step>

  <Step title="Emit Events">
    A `PositionReduced` event is emitted with the reduction details: `positionId`, `account`, `reductionNotional`, `remainingNotional`, `settledPnl`, and `fee`.
  </Step>
</Steps>

## Worked Example

<Accordion title="Partial reduction walkthrough">
  **Initial position:**

  * Side: LONG
  * Notional: 1,000 USDC
  * Entry strike: 1.0800
  * IM locked: 20 USDC (2%)
  * MM threshold: 10 USDC (1%)
  * Snapshotted trading fee: 5 bps

  **Reduction: close 400 USDC of the 1,000 USDC notional**

  Current forward price: 1.0850

  **Step 1 -- Margin at risk:**

  ```
  marginAtRisk = (20 * 400) / 1,000 = 8 USDC
  ```

  **Step 2 -- PnL on reduced portion:**

  ```
  pnl = 400 * (1.0850 - 1.0800) / 1 = 400 * 0.005 = 2 USDC profit
  ```

  **Step 3 -- Fee:**

  ```
  fee = 400 * 5 / 10,000 = 0.20 USDC
  ```

  **Step 4 -- Settlement of reduced portion:**

  * Margin at risk: 8 USDC
  * Profit: 2 USDC (paid by pool)
  * Fee: 0.20 USDC (from margin)
  * Net to trader: 8 + 2 - 0.20 = 9.80 USDC returned to free collateral

  **Remaining position:**

  * Notional: 600 USDC
  * Entry strike: 1.0800 (unchanged)
  * IM locked: 12 USDC (20 - 8)
  * MM threshold: 6 USDC (proportionally reduced)
  * Status: OPEN
</Accordion>

## Use Cases

<Columns cols={2}>
  <Card title="Take Partial Profits" icon="chart-line-up">
    Close a portion of a winning position to realize gains while keeping the remainder open for further upside. Useful when you want to de-risk but maintain exposure.
  </Card>

  <Card title="Reduce Exposure" icon="shield-halved">
    Decrease your position size in response to changing market conditions without fully exiting. This reduces your notional risk while preserving the original entry price.
  </Card>

  <Card title="Free Up Margin" icon="wallet">
    Reduction returns proportional margin to your free collateral, which can then be used to open new positions, add margin elsewhere, or withdraw.
  </Card>

  <Card title="Incremental Risk Management" icon="sliders">
    Scale out of a position gradually over time rather than making a single all-or-nothing close decision.
  </Card>
</Columns>

## Reduction vs Full Close

| Aspect                | Partial Reduction                   | Full Close (Early Termination) |
| --------------------- | ----------------------------------- | ------------------------------ |
| Notional after        | Reduced (must be `>= min notional`) | Zero                           |
| Position status after | OPEN                                | CLOSED                         |
| Entry strike          | Unchanged                           | N/A                            |
| CloseReason           | N/A (position stays open)           | `EARLY_TERMINATION`            |
| Fee                   | On reduction amount only            | On full notional               |
| PnL realized          | On reduced portion only             | On full notional               |

<Tip>
  If you call `reducePosition` with `reductionNotional` equal to the position's full notional, it is treated as a full early termination. There is no need to use a different function for closing entirely -- the reduction function handles both cases seamlessly.
</Tip>

## Mode Restrictions

Like early termination, position reduction is allowed in NORMAL, DEGRADED, and REDUCE\_ONLY modes. It is only blocked in PAUSED mode:

| Mode         | Position Reduction |
| ------------ | ------------------ |
| NORMAL       | Allowed            |
| DEGRADED     | Allowed            |
| REDUCE\_ONLY | Allowed            |
| PAUSED       | Blocked            |

This ensures traders can always reduce their risk exposure even when the protocol is in a restricted operating mode.
