# IDiamondStorage

*Based on EIP-2535: Diamonds (<https://eips.ethereum.org/EIPS/eip-2535>) Follows diamond-3 implementation (<https://github.com/mudgen/diamond-3-hardhat/>) Contains the types used in the diamond management contracts.*

## DiamondStorage

```solidity
struct DiamondStorage {
  mapping(bytes4 => struct IDiamondStorage.FacetAddressAndPosition) selectorToFacetAndPosition;
  mapping(address => struct IDiamondStorage.FacetFunctionSelectors) facetFunctionSelectors;
  address[] facetAddresses;
  address[47] __gap;
}
```

## FacetAddressAndPosition

```solidity
struct FacetAddressAndPosition {
  address facetAddress;
  uint96 functionSelectorPosition;
}
```

## FacetFunctionSelectors

```solidity
struct FacetFunctionSelectors {
  bytes4[] functionSelectors;
  uint256 facetAddressPosition;
}
```

## FacetCutAction

```solidity
enum FacetCutAction {
  ADD,
  REPLACE,
  REMOVE,
  NOP
}
```

## FacetCut

```solidity
struct FacetCut {
  address facetAddress;
  enum IDiamondStorage.FacetCutAction action;
  bytes4[] functionSelectors;
}
```


---

# 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.gains.trade/developer/technical-reference/contracts/interfaces/types/idiamondstorage.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.
