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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.smardex.io/ultimate-synthetic-delta-neutral/the-usdn-protocol/inside-the-protocol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
