# Technical Details

This section provides a deeper technical understanding of how Oasis works. While not necessary for using the platform, these details offer insights into the mathematical foundations and mechanisms that ensure the protocol's security and efficiency.

### Core Mathematical Framework

#### Position Value Calculations

When you provide liquidity, several key values are calculated:

**Initial Position Setup**

For a deposit amount `D_token`:

```
HTR_matched = D_token / P_htr_i
```

Where:

* `D_token`: Initial token deposit amount
* `P_htr_i`: Initial HTR price
* `HTR_matched`: Amount of HTR matched by Oasis

**Bonus Calculation**

```
HTR_bonus = (D_token × Bonus_rate) / P_htr_i
```

Where:

* `Bonus_rate`: Set by lock duration (10%, 15%, or 20%)
* `HTR_bonus`: Amount of bonus HTR tokens received

### Protection Mathematics

#### Value Preservation Model

The protocol maintains constant product AMM mathematics:

```
x × y = K
```

Where:

* x: Token amount in pool
* y: HTR amount in pool
* K: Constant product

#### Price Ratio Calculations

```
R = P_htr_f / P_token_f
```

Where:

* `P_htr_f`: Final HTR price
* `P_token_f`: Final token price
* `R`: Price ratio

#### Protection Calculations

**Value Deficit Calculation**

```
Token_deficit = max(0, D_token - x_f)
```

Where:

* `x_f`: Final token balance
* `Token_deficit`: Amount requiring protection

**Protection Payment**

When protection applies:

```
HTR_protection = Token_deficit / P_htr_f
```

### Liquidity Pool Mechanics

#### Pool Balance Adjustments

For any new price ratio R, new pool balances are calculated as:

```
y/x = R
x × y = K
```

Therefore:

```
x = sqrt(K/R)
y = x × R
```

#### Pool Value Protection

Protection ensures that for any price movement within 4x:

```
withdrawal_value ≥ initial_deposit_value
```

Where withdrawal\_value includes:

* Original token amount (or equivalent)
* Protection compensation in HTR
* Accumulated trading fees

### Return Calculations

#### Total Position Value

For positions with held bonus:

```
V_total_hold = LP_value + (B_htr × P_htr_f)
```

For positions with sold bonus:

```
V_total_sell = LP_value + (B_htr × P_htr_i)
```

Where:

* `LP_value`: Liquidity position value
* `B_htr`: Bonus HTR amount
* `P_htr_f`: Final HTR price
* `P_htr_i`: Initial HTR price

#### Return Metrics

Percentage return calculation:

```
Return_% = ((V_total / D_token) - 1) × 100
```

### Risk Management

#### Protection Boundaries

Full Protection Range:

* Up to 4x price divergence
* Complete value preservation
* Automatic calculation

#### Reserve Management

The protocol maintains:

* HTR reserve for each pool
* Automated matching system
* Protection reserve allocation
* Dynamic capacity management (new HTR deposits can be made to increase the reserve available)

### Market Simulation Model

#### Return Scenario Calculations

The simulation tool models returns using:

1. Price movement inputs:
   * HTR price change
   * Token price change (for hBTC)
2. Strategy comparisons:
   * Hold bonus path
   * Immediate sell path
   * Protection impacts
   * Fee accumulation

### Performance Characteristics

#### Operational Parameters

1. Transaction Processing:
   * Instant matching
   * Automatic protection
   * Real-time calculations
2. Value Tracking:
   * Continuous monitoring
   * Price feed integration
   * Protection threshold checks

### Additional Resources

* [Oasis RFC](https://github.com/Dozer-Protocol/hathor-rfcs/blob/oasis/text/oasis.md)
* [Oasis Blueprint](https://github.com/hBulldozer/dozer/blob/oasis/contracts/oasis.py)
