# Dependency Graphs

Dependency graphs in IPOR Fusion are a mechanism that defines relationships between markets where one market's balance calculation depends on another market's balance. They ensure accurate asset valuation and prevent double-counting when markets have nested or interconnected positions.

### Purpose

Dependency graphs serve three critical purposes in Fusion:

1. **Prevent Asset Double-Counting**: When a market holds assets that are themselves tracked in another market (e.g., LP tokens staked in a gauge), dependency graphs ensure the underlying assets aren't counted twice in `totalAssets()` .
2. **Ensure Atomic Balance Updates**: When a market balance changes, all dependent markets are automatically updated to maintain consistency across the vault's accounting system.
3. **Support Complex Market Relationships**: Enable sophisticated DeFi strategies where positions span multiple protocols (e.g., lending markets depending on underlying asset markets, or LP token markets depending on constituent tokens).

### Implementation

The dependency graph system is implemented through:

* **Storage Structure**: A mapping from each market ID to an array of dependent market IDs.
* **Configuration Functions**: `updateDependencyBalanceGraphs()` for setting up relationships.
* **Query Functions**: `getDependencyBalanceGraph()` for retrieving dependencies.


---

# 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.ipor.io/build-on-fusion/atomists/curating-a-fusion-vault/dependency-graphs.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.
