# Holding Trades

## **Dynamic User interactions**

Users can update certain aspects of their open trades:

* **Update Take Profit:** Traders can update the value of or add a Take Profit order.&#x20;
* **Update Stop Loss:** Traders can update the value of or add a Stop Loss order.&#x20;
* **Add Collateral:** Traders can top up collateral on their position to reduce leverage and minimize liquidation risk.
* **Remove Collateral**: Traders can withdraw collateral on their position; however, the liquidation risk increases. A <mark style="background-color:yellow;">0.10 USDC</mark> fee is deducted from collateral when this action is performed.

In all cases, **no additional fee** is charged by the protocol because no price is requested.

## **Monitoring of Trade State**

* Ostium uses Gelato Functions to continuously track price changes and determine the need for automated order execution (liquidations, stop losses, take profit orders).&#x20;
* Trade state simulation runs frequenlty, radically minimizing the risk of would-be liquidations or other automated orders from being executed outside of an acceptable time frame or of bad debt accruing for the liquidity buffer.

## **Rollover Fees**

Ostium applies **rollover fees** to open positions to reflect the evolving market dynamics and the cost of holding positions over time. These fees are **synthetically applied** to the entire position size, compounding per block, and are realized upon closing a position.&#x20;

Rollover fees reflect **underlying market swap/funding/carry costs**. A **Gelato** automation updates the on-chain rate **daily (T+1)** by polling from underlying market data sources.

### Pricing

```
Long Rollover  = lastPureLong + brokerPremium
Short Rollover = - lastPureLong + brokerPremium
```

* **lastPureLong** = “pure market” rate inferred off-chain (term structure or interest rate).
* **brokerPremium** = platform premium (leverage costs).

{% hint style="info" %}
**UI note (signs & colors):**

* If the **effective rate > 0**, the **user pays** (shown as **negative/red** on Front-End)
* If the **effective rate < 0**, the **user receives** (shown as **positive/green**), **only if** negative rollover payouts are enabled (see below)
  {% endhint %}

### Negative Rollover Setting

* **`isNegativeRolloverAllowed = false` (default, initial phase)**\
  Rates are **floored at 0** to users (users don't receive rollover).
  * If **effective rate** < 0 → **users receive 0%**, not the negative (credit) amount.
  * If **effective rate** > 0 → **users pay** the positive rate.
* **`isNegativeRolloverAllowed = true` (future phase)**\
  Ostium **mirrors the underlying**: one side **pays**, the other might **receive**.

### Example (Crude Oil, WTI)

* Underlying market rate (roll yield) = **−7%** (backwardation → longs receive / shorts pay).
* Broker premium = **+1%**.

Computed:

* **Longs:** `−7% + 1% = −6%` → longs **receive 6%**.
* **Shorts:** `+7% + 2% = +9%` → shorts **pay 9%**.

With `isNegativeRolloverAllowed = false`:

* **Longs:** **0%**
* **Shorts:** **+9%** pay

### How Ostium Computes `lastPureLong` (Off-chain)

Ostium computes the “pure” market component **per asset**, then pushes it on-chain daily.

#### 1. Term Structure (Commodities & FX)

* **Idea:** Use the **futures curve** to estimate **roll yield** (contango/backwardation).
* **Inputs:** list of `[expiry, price]` contracts (end-of-market data, T+1).
* **Method:** compute annualized slope(s) between consecutive contracts and take a **Gaussian-weighted** average (more weight to nearer expiries).
* **Sign logic:**
  * **Contango (positive slope)** → **longs pay**, shorts receive. (e.g., **gold** often)
  * **Backwardation (negative slope)** → **longs receive**, shorts pay. (e.g., **oil** often)

> The resulting annualized %, after weighting, is the **`lastPureLong`** for that asset.

#### 2. Interest Rates (Stocks & Indices)

* Use **live SOFR** (USD policy rate proxy) to set **`lastPureLong`** for equity indices and single-stocks.

### Daily Update Workflow

On **each weekday**:

1. Download settlement data (T+1).
2. For each contract/asset, compute the **underlying market rate**\
   – **Term structure** (commodities/FX) or **SOFR** (stocks/indices).
3. **Keepers (Gelato)** update **rollover fee** on Ostium smart contracts.
