# updateIsolatedMargin - Adjust Isolated Margin

Add or remove margin from an isolated position. This allows fine-tuning position risk without changing the position size or closing the trade.

## Sample Data

```json
{
  "signature": {
    "r": "0xd14b53f9f6b7cb39e5289f62c453f22d21d46def6f7acbc267cb33f1d2d2668f",
    "s": "0x393d89fcd7835fad35ff2b06e29b6c56bd8034efc5bd9b38848c8ac7dd32fbc3",
    "v": 28
  },
  "action": {
    "type": "updateIsolatedMargin",
    "asset": 0,
    "isBuy": true,
    "ntli": -1000000
  },
  "nonce": 1768146925098
}
```

[View this transaction on Hypurrscan →](https://hypurrscan.io/tx/0xd02fc36287650ca2d1a9043326463302037f004822682b7473f86eb54668e68d)

## Field Reference

### Action Fields

| Field | Type | Description |
|-------|------|-------------|
| `type` | string | Always `"updateIsolatedMargin"` |
| `asset` | number | Asset index (e.g., 0 = BTC) |
| `isBuy` | boolean | Position side: `true` for long, `false` for short |
| `ntli` | number | Margin adjustment in raw units (negative = remove, positive = add) |

## Understanding ntli

The `ntli` field represents the margin change in raw integer units:

- **Positive values**: Add margin to the position (reduce liquidation risk)
- **Negative values**: Remove margin from the position (increase liquidation risk)

The value `-1000000` in the sample represents removing 1 USD of margin (assuming 6 decimal places for USDC).

## Use Cases

### Position Risk Monitoring

Track margin adjustments to understand how traders manage position risk:

```python
def process_updateIsolatedMargin_action(action):
    asset = action.get('asset')
    side = 'LONG' if action.get('isBuy') else 'SHORT'
    margin_change = action.get('ntli') / 1_000_000  # Convert to USD

    direction = 'added' if margin_change > 0 else 'removed'
    print(f"Margin {direction}: {abs(margin_change)} USD on {side} {asset}")
```

### Liquidation Prevention Analysis

Monitor margin additions that may indicate positions approaching liquidation.

### Capital Efficiency Tracking

Track margin removals to understand how traders optimize capital usage.

## Related Action Types

- [updateLeverage](https://www.dwellir.com/docs/hyperliquid/updateLeverage) - Change leverage settings
- [userPortfolioMargin](https://www.dwellir.com/docs/hyperliquid/userPortfolioMargin) - Portfolio margin mode
