> For the complete documentation index, see [llms.txt](https://docs.smardex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smardex.io/ultimate-synthetic-delta-neutral/the-usdn-protocol/inside-the-protocol.md).

# Inside the Protocol

<figure><img src="/files/09x9CxCNdnplI863BKcg" alt=""><figcaption></figcaption></figure>

When you perform one of the four main actions ([minting](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#mint) or [redeeming](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#redeem) the [USDN token](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#the-usdn-token), opening or closing a [long position)](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#long-position), several steps take place behind the scenes. The first of these steps is to obtain a price, as the [protocol](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#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](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#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](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#funding-rate) and transfers assets between the long side and the [vault side](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#vault-side-usdn-side), determining who owes and who receives.
3. **Liquidate positions:** The protocol checks if there are any positions to [liquidate](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#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](/ultimate-synthetic-delta-neutral/the-usdn-protocol/glossary.md#dip-accumulator) will be triggered to safeguard the protocol. Learn more about it [here](/ultimate-synthetic-delta-neutral/the-usdn-protocol/long-side/dip-accumulator.md).
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](/ultimate-synthetic-delta-neutral/the-usdn-protocol/vault-side/rebase-mechanism.md).

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 %}
