# Substrates

> What substrates are and how they scope which assets and markets a fuse is allowed to touch.

In IPOR Fusion, the Atomist defines the "walled garden" in which the strategy logic (Alpha) can operate. While Fuses define _how_ to interact with a protocol (e.g., "supply to Aave"), Substrates define _where_ and with _what_ specifically those Fuses are allowed to interact.

#### What are Substrates?

Substrates are specific identifiers or permissioned parameters granted to a Market within a Fusion Vault. They act as the granular configuration that tells the vault which underlying components of an external protocol are "visible" and "authorized."

Think of a Market (like Aave V3) as a building. The Fuse is the door you use to enter. Substrates are the specific rooms inside that building that the Atomist has unlocked for the Alpha.

Common examples of Substrates include:

- Asset Addresses: Specific ERC20 tokens allowed for supply/borrow.
- Sub-Market IDs: Specific pool IDs or market identifiers within a larger protocol (e.g., a specific Morpho Blue market).
- Target Limits: Constraints on asset amounts or specific function selectors allowed for execution.

#### Why are Substrates necessary?

Substrates serve two primary purposes:

1. Security: They prevent an Alpha from interacting with unauthorized, risky, or unverified pools within a protocol.
2. Accounting: The Plasma Vault uses Substrates to know which balances it needs to track. If a Substrate isn't configured, the vault won't "see" the assets held in that sub-market, ensuring the vault's Net Asset Value (NAV) and share price remain accurate and protected.

#### Configuration Step-by-Step

As an Atomist, you configure Substrates after adding a Fuse to your vault. This is done via the `grantMarketSubstrates` method.

**1. Identify the Market ID**

Every external protocol integration in Fusion has a unique `uint256` Market ID defined in the `IporFusionMarkets` library.

- _Example:_ `AAVE_V3 = 1`, `COMPOUND_V3_USDC = 2`, `MORPHO_BLUE = 5`.

**2. Define the Substrate Data**

The data required for a substrate varies depending on the Market type.

- For Lending Markets (Aave, Spark, etc.): The substrate is typically the address of the underlying asset (e.g., the USDC token address).
- For Complex Markets (Morpho Blue, Uniswap V3): The substrate might be a specific Market ID or a pool address.
- For Async Actions: Substrates can include encoded limits (`ALLOWED_AMOUNT_TO_OUTSIDE`) or permitted function selectors (`ALLOWED_TARGETS`).

**3. Grant Permissions**

Using the Vault's management interface (or directly via the `PlasmaVault` contract), the Atomist calls:

`grantMarketSubstrates(uint256 marketId, bytes[] calldata substrates)`

This registers the list of authorized IDs for that specific market.

#### Technical Example: Morpho Blue

If you are setting up a vault to supply USDC to a specific Morpho Blue market, you wouldn't just grant access to "Morpho." You would:

1. Identify the Morpho Market ID (the unique hash for the specific collateral/loan pair).
2. Add this ID as a Substrate to the Morpho Blue Market in your vault.
3. The vault now knows to track the balance of the `Id` and allows the Alpha to call `enter` or `exit` for that specific pool.

#### Summary for Atomists

- Fuses = Actions (Supply, Withdraw, Swap).
- Markets = Protocols (Aave, Morpho, Gearbox).
- Substrates = Specifics (USDC, Market ID `0x123...`, Function selectors).

Without the correct Substrates, your Alpha will not be able to execute trades, even if the Fuse is correctly installed.

---

#### Related Resources

- [Video: Explaining Substrates (YouTube)](https://www.google.com/search?q=https://youtube.com/watch%3Fv%3DzYXwfeUp7Og)
