Facet Architecture
3. Facet Architecture (Grouped by Responsibility)
The facets are split into two main groups:
- Base facets – the core of the Diamond.
- Feature facets – index & integration features.
3.1 Base Facets (Core)
These live under:
src/garden/facets/baseFacets/
They exist to keep non‑business‑logic concerns modular and upgradeable.
Ownership Facet
Key components:
OwnershipFacet.sol- Main facet contract implementing ERC-173 ownership interfaceOwnershipBase.sol- Base contract containing core ownership logicOwnershipStorage.sol- Storage layout for ownership state
What it controls:
- Who owns the Garden (the Diamond contract).
- Who is allowed to perform diamond cuts and change protocol configuration.
- Owner transfer functionality: Current owner can transfer ownership to a new address or renounce ownership.
Cut Facet (Upgrade Facet)
Key components:
IDiamondCut.sol- Interface defining the diamondCut functionDiamondCutFacet.sol- Main facet contractDiamondCutBase.sol- Core diamond cut logicDiamondCutStorage.sol- Storage layout for facet mappings
What it controls:
- Which facets are registered with the Diamond.
- What function selectors each facet exposes.
- How upgrades are authorized and executed.
Upgrade Facet
Key components:
IUpgrade.sol- Interface for high-level upgrade operationsUpgradeFacet.sol- Main facet contractUpgradeBase.sol- Core upgrade logicUpgradeStorage.sol- Version tracking
What it controls:
- Synchronization with external FacetRegistry to pull approved upgrades.
- Version tracking to ensure Diamonds are up to date.
- Hash verification for upgrade data integrity.
Introspection (Loupe) Facet
Key components:
IDiamondLoupe.sol- Interface for introspectionDiamondLoupeFacet.sol- ImplementationDiamondLoupeBase.sol- Core logicDiamondLoupeStorage.sol- Supported interfaces (ERC-165)
What it controls:
- Reflection / introspection:
- Which facets exist and what function selectors they implement.
- Which interfaces the Diamond supports.
3.2 Feature / Domain Facets
These implement protocol‑level behavior which users actually care about.
Index facets (Index Feature)
Key components:
IIndex.sol,IndexFacet.sol,IndexBase.sol,IndexStorage.sol
What problem they solve:
- Provide index‑related capabilities directly on the Garden:
connectToIndex(address indexAddress)disconnectFromIndex()rebalance()isConnectedToIndex()
Utility / Protocol‑Integration facets (DeFi Integrations)
Key components:
- Uniswap V3:
UniswapV3Base.sol,IUniswapV3.sol - Camelot V3:
CamelotV3Base.sol,ICamelotV3.sol - GMX V2:
GmxV2Base.sol,IGmxV2.sol,GmxV2Storage.sol - Aave V3:
AaveV3Base.sol,IAaveV3.sol - Pendle V2:
PendleV2Base.sol,IPendleV2.sol
What problem they solve:
- Turn abstract operations like rebalancing into concrete swaps or position management.
- Provide reusable adapters around external protocols.