> For the complete documentation index, see [llms.txt](https://docs.world.inc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.world.inc/details/atlas-math-risk-based-valuation.md).

# ATLAS Math: Risk Based Valuation

## General

The **risk based portfolio valuation** provides a conservative estimate of portfolio value under adverse conditions.

* Market participants must maintain a **positive risk based valuation** at all times.
* If the valuation becomes negative, the account is subject to **liquidation**.
* The exchange operator defines two risk parameters per token:
  * **Risk Price**
  * **Risk Slippage**

## Adjusted Token Balance

For each token, define the **adjusted balance**:

$$
\text{Adjusted Balance(token)} = \text{Token Balance} - \text{Borrowed Quantity with Interest} + \text{Lent Quantity with Haircut}
$$

where:

$$
\text{Lent Quantity with Haircut} = \text{Lend Quantity} \times 0.98
$$

* `tokenBalance` = user’s holdings of the token
* `borrowedQuantityWithInterest` = borrowed amount **plus 10 days of interest**
* `lendQuantity` = total amount lent to others

📌 For efficiency, lending values are aggregated as the **sum of all borrowed positions with the maximum 10-day interest rate**.

## Margin & Portfolio Valuation

The **risk-based valuation** of the portfolio is:

$$
\text{Risk Based Valuation} = \text{Adjusted Bal(BaseToken)} + \sum\_{\text{Non-base tokens}} \text{Token Value}
$$

### Token Value

For each non-base token:

$$
\text{tokenValue} = \min(\text{tokenValue}*{high}, \text{tokenValue}*{low})
$$

where:

$$
\text{tokenValue}*{high} = \text{adjustedBal(token)} \times \text{adjustedTokenPrice}*{high} + \text{aggregatePerpValue}\_{high}
$$

$$
\text{tokenValue}*{low} = \text{adjustedBal(token)} \times \text{adjustedTokenPrice}*{low} + \text{aggregatePerpValue}\_{low}
$$

### Adjusted Token Prices

The adjusted token prices are computed as:

$$
\text{adjustedTokenPrice}*{high} = \text{price}*{mark} \times \Big(1 + \text{riskPrice} - \text{riskSlippage} \times \text{sign}(\text{adjustedBal(token)})\Big)
$$

$$
\text{adjustedTokenPrice}*{low} = \text{price}*{mark} \times \Big(1 - \text{riskPrice} - \text{riskSlippage} \times \text{sign}(\text{adjustedBal(token)})\Big)
$$

### Adjusted Perp Values

For perpetual positions, we compute high and low valuations:

$$
\text{aggregatePerpValue}*{high} = \sum*{\text{perp positions}} \text{perpValue}(\text{markPrice} \times (1 + \text{riskPrice}))
$$

$$
\text{aggregatePerpValue}*{low} = \sum*{\text{perp positions}} \text{perpValue}(\text{markPrice} \times (1 - \text{riskPrice}))
$$

### Perpetual Position Valuation

The **perp value** at a given price is:

$$
\text{Perp Value(price)} = \text{PNL from price movement + Funding Fees at that price}
$$

## SDKs & Optimization

[#sdks](#sdks "mention") have the above formulas built in, so you can test and simulate margin requirements for different position sets.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.world.inc/details/atlas-math-risk-based-valuation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
