Metadata-Version: 2.5
Name: stability-nexus
Version: 3.0.0
Summary: Stability Nexus multi-protocol simulation library.
Project-URL: Homepage, https://stability.nexus
Author-email: Luca D'Angelo <ldgaetano@protonmail.com>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# stability-nexus

Stability Nexus multi-protocol simulation library.

## Installation

```bash
pip install stability-nexus
```

## Quick Start

```python
from stability_nexus.stablecoins.gluon.reactors import GluonWReactor
from stability_nexus.stablecoins.gluon.types import (
    GluonReaction,
    GluonWReactorParameters,
    GluonWReactorState,
)

# Configure reactor parameters
params = GluonWReactorParameters(
    critical_neutron_ratio=0.5,
    fission_fee=0.01,
    fusion_fee=0.01,
    beta_decay_fee_slope=0.1,
    beta_decay_fee_intercept=0.005,
    volume_window=10.0,
)

# Initialize reactor state
state = GluonWReactorState(
    reserves=1000.0,
    neutron_circulating_supply=500.0,
    proton_circulating_supply=500.0,
    beta_decay_history=[],
)

# Create reactor instance
reactor = GluonWReactor(params, state)

# Execute a fission reaction (basecoins -> neutrons + protons)
result = reactor.execute(
    GluonReaction.FISSION,
    balance=100.0,
    neutron_target_price=1.0,
    reaction_time=1.0,
)
print(f"Received: {result.reactor_output}")
print(f"New reserves: {result.reactor_state.reserves}")
```

## The Gluon W Reactor

`GluonWReactor` implements the Gluon W protocol:

- the normalized neutron ratio is capped at the critical ratio (`min(q, q*)`), and
- the beta decay fee is based on the signed sum of beta decay volumes within a sliding time window of length `volume_window`.

A Gluon Z variant (damped ratio, exponentially decaying volume) is planned once its specification is finalized.

## Reactions

The Gluon protocol supports four reaction types:

- **FISSION**: Convert basecoins into neutrons and protons
- **FUSION**: Convert neutrons and protons back into basecoins
- **BETA_DECAY_PLUS**: Convert protons into neutrons
- **BETA_DECAY_MINUS**: Convert neutrons into protons

## Types

The library uses type aliases for documentation:

- `Basecoin` - Reserve currency amounts (`float`)
- `Neutron` - Neutron token amounts (`float`)
- `Proton` - Proton token amounts (`float`)
- `BasecoinPerNeutron` - Price ratio (`float`)
- `BasecoinPerProton` - Price ratio (`float`)
- `Tokeons` - A dataclass containing neutrons and protons

## Contributing

If you encounter bugs, need help, or have feature requests:

- Please open an issue in this repository providing detailed information.
- Describe the problem clearly and include any relevant logs or screenshots.

We appreciate your feedback and contributions!

© 2025 The Stable Order.
