# Inside the Protocol

<figure><img src="https://2849728541-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjYp8YSP5khO4s6xn05rx%2Fuploads%2FVlC5w6qkKuT2akPzBS3j%2FCapture%20d%E2%80%99e%CC%81cran%202025-01-24%20a%CC%80%2015.40.37.png?alt=media&#x26;token=6719d50e-5dc3-4df3-97a3-573acc7de16f" alt=""><figcaption></figcaption></figure>

When you perform one of the four main actions ([minting](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#mint) or [redeeming](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#redeem) the [USDN token](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#the-usdn-token), opening or closing a [long position)](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#long-position), several steps take place behind the scenes. The first of these steps is to obtain a price, as the [protocol](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#usdn-protocol), operating on the blockchain, does not inherently know market prices. This is why, for every action, the user must provide a price.

Once the price is submitted, the protocol can carry out the necessary calculations to update each position. Here is an overview of the steps the protocol executes:

1. **Calculate long PnLs**: The protocol begins by calculating the profit or loss (PnL) of long positions. The [collaterals](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#collateral) of these positions are adjusted accordingly: if a long bet succeeds, its collateral increases.
2. **Apply fundings**: The protocol calculates the amount owed based on the [funding rate](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#funding-rate) and transfers assets between the long side and the [vault side](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#vault-side-usdn-side), determining who owes and who receives.
3. **Liquidate positions:** The protocol checks if there are any positions to [liquidate](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#liquidation). Insolvent positions are automatically liquidated to ensure the system's stability and security.
4. **Trigger the dip accumulator:** If the protocol is heavily imbalanced, the [dip accumulator](https://docs.smardex.io/ultimate-synthetic-delta-neutral/glossary#dip-accumulator) will be triggered to safeguard the protocol. Learn more about it [here](https://docs.smardex.io/ultimate-synthetic-delta-neutral/the-usdn-protocol/long-side/dip-accumulator).
5. **Rebasing the USDN token:** If all of the above pushed the price of the USDN token higher than necessary, it will inflate the holders' balance to compensate. Learn more about it [here](https://docs.smardex.io/ultimate-synthetic-delta-neutral/the-usdn-protocol/vault-side/rebase-mechanism).

In the following sections, we will detail each of these steps to give you a deeper understanding of the protocol's inner workings.

{% hint style="info" %}
To avoid duplicating information, only the first 3 steps will be explained in the following sections.
{% endhint %}
