> For the complete documentation index, see [llms.txt](https://docs.looputo.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.looputo.xyz/mechanism/shared-pool-architecture.md).

# Shared Pool Architecture

Looputo's unique accounting system to track per-user positions.

Looputo runs **one pool per market**. The pool tracks its two legs, collateral and debt, with ERC-4626-style share accounting, so a single pooled position can be automated on behalf of all users while keeping track of each user's own leverage and net equity.

Each market has a single pool to deposit into. A user deposits an asset, the pool opens the loop at the chosen leverage, and the position is represented by two share balances, issued together at deposit:

* **Collateral shares**: a claim on the pool's aggregate supplied collateral. Grow as the collateral earns yield.
* **Debt shares**: a claim on the pool's aggregate borrowed debt. Grow with the borrow rate.

Each share balance accrues like an ERC-4626 vault's price per share, so nothing is recomputed per user; the two share indices carry all accrual.

<figure><img src="https://1517612113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyPrXoSfRikirWhKbEx7%2Fuploads%2Fgit-blob-359ada5c3ce9e998374dfce52990dd56826e49ad%2Flooputo-pool.jpg?alt=media" alt="Users A, B, and C at 3x, 7x, and 14x leverage deposit into one Looputo pool. The pool tracks collateral shares and debt shares, and the lending market (Aave, Morpho, or SparkLend) sees a single aggregate position."><figcaption></figcaption></figure>

### How a Position Is Tracked

A user's position is captured by two numbers: collateral shares and debt shares. Each is a proportional claim on its side of the pool. For a user $$A$$:

$$C\_A = \frac{s^{c}*{A}}{S^{c}} \cdot C \qquad\qquad D\_A = \frac{s^{d}*{A}}{S^{d}} \cdot D \qquad\qquad E\_A = C\_A - D\_A$$

where:

* $$s^{c}*{A}$$, $$s^{d}*{A}$$: the collateral shares and debt shares held by user $$A$$
* $$S^{c}$$, $$S^{d}$$: the total collateral shares and total debt shares issued by the pool
* $$C$$, $$D$$: the pool's total supplied collateral and total borrowed debt
* $$C\_A$$, $$D\_A$$, $$E\_A$$: user $$A$$'s collateral, debt, and equity

As yield and interest accrue, the two pool totals move and every user's claim moves proportionally with them, so no per-user bookkeeping is required.
