# Marginly MAX leverage specifics

In Marginly, we specifically invoke a margin call before every user action: If your position happens to be the riskiest in the system, it will liquidate automatically on ANY action of ANY user.&#x20;

Unfortunately, this means that when you close your position, and it's the riskiest one, instead of closure, you will get liquidated. Why not add leverage checks, you ask? This additional “if” logic increases contract size and requires complete refactoring by splitting the smart contract into many parts.&#x20;

We will eventually have to do that as we envision some changes/improvements for Marginly’s protocol, including this particular one related to the riskiest position management.&#x20;

\
Additionally, I would like to talk about the[ TWAP oracle](https://docs.marginly.com/protocol-mechanics/risk-management#twap-oracle) we use to value user positions. Take a look at the following picture:

<figure><img src="https://lh7-us.googleusercontent.com/40AWwGLhRUd-Pjp524vNlU9xoWS52zWRkv06n2T2xrZg52dQQ7i6ALh5jB0BJEBw_8l0VGNyL3Ivy_lRvfwRpXpItWeUJzihOjgGj4NKhh66ox4TNblUskLojZRlfZFUdMVkQFHWpkeMdcK2OAhkyl0" alt=""><figcaption></figcaption></figure>

It is an ETH/USDC 1-minute chart. The red line is the average over 30 minutes - our 30-minute TWAP price. Now imagine that you went long 20x in the shaded area. Even though the price temporarily goes up, the TWAP price, at which Marginly values your position, continues to decline as the moving average is lagging current data. If you use max leverage, you will get liquidated. This behavior could be somewhat misleading when looking solely at the charts.\
\
The same happens to shorts, by the way, Imagine you shorted at 1880 with 20x, but the system will value your position at \~1882.5 (the TWAP price). This is an instant liquidation.&#x20;

One of the things we’re currently working on within our UX is a warning on position openings, so people understand the implications when they use max leverage.


---

# 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.marginly.com/protocol-mechanics/marginly-max-leverage-specifics.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.
