# Loan pricing

A collateralized loan model for the pool we consider has the following specifications:

* The loan has an infinite lifetime (no maturity)
* At time 0, the user borrows amount Q (Q > 0) USD from the pool using 1 unit of an asset (e.g., ETH) as collateral.
* The continuously compounding loan interest rate is r. The client may regain the asset by repaying the Q\*exp(rt) amount to the pool at any time t ≥ 0.
* User may default (not obliged to return the loan)

The task may be regarded as a user buying an American option at the price of (asset price - Q) with the following payoff function:

$$
Y\_t = max (0; P^{ETH}\_t - Qe^{rt}); t \geq0
$$

This time-dependent strike price option is evaluated, for example, in [Xia and Zhou](https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1467-9965.2006.00305.x). Since in our setup, we know the exact position user wants to take (the leverage), and thus the effective option value, we can rearrange final equations to solve for the interest rate r: *Marginly* calculates interest rate as proportional to the asset volatility and the leverage of the pool’s position:

$$
r {\sim L\frac{\sigma^{2}}{2}}
$$

*Marginly* keeps track of the total long leverage and the total short leverage in the pool and scales interest rates proportionally for each side. This way, every time any user performs any action in the system, it recalculates how much interest has accrued since the last time and updates collateral and debt coefficients accordingly.


---

# 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-architecture/loan-pricing.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.
