> For the complete documentation index, see [llms.txt](https://docs.symm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.symm.io/contract-documentation/symmio-perps-v0.8.5/account-layer-diamond/view-facet.md).

# View Facet

The Account Layer View Facet provides read-only functions for querying sub-accounts, virtual accounts, affiliates, roles, legacy accounts, and system state within the Account Layer diamond. All functions are `view` and do not modify state.

***

### Sub-Account Queries

| Function                                                                    | Parameters          | Returns                                       |
| --------------------------------------------------------------------------- | ------------------- | --------------------------------------------- |
| `getSubAccount(address account)`                                            | Sub-account address | Full `SubAccountDetail` struct                |
| `getUserSubAccountsAddresses(address owner, uint256 offset, uint256 limit)` | Owner, pagination   | Paginated array of sub-account addresses      |
| `getUserSubAccounts(address owner, uint256 offset, uint256 limit)`          | Owner, pagination   | Paginated array of `SubAccountDetail` structs |
| `getSubAccountsCountOfUser(address owner)`                                  | Owner address       | Total sub-account count                       |

The `SubAccountDetail` struct includes: account address, owner, name, existence flag, singleVAMode, affiliate, Symmio core, metadata, and isolation type.

***

### Virtual Account Queries

| Function                                                                                     | Parameters                  | Returns                                            |
| -------------------------------------------------------------------------------------------- | --------------------------- | -------------------------------------------------- |
| `getVirtualAccount(address account)`                                                         | Virtual account address     | Full `VirtualAccountDetail` struct                 |
| `getVirtualAccountsAddressesOfSubAccount(address subAccount, uint256 offset, uint256 limit)` | Sub-account, pagination     | Paginated virtual account addresses                |
| `getVirtualAccountsOfSubAccount(address subAccount, uint256 offset, uint256 limit)`          | Sub-account, pagination     | Paginated `VirtualAccountDetail` structs           |
| `getVirtualAccountQuoteIds(address account, uint256 offset, uint256 limit)`                  | Virtual account, pagination | Paginated quote IDs tracked by the virtual account |
| `getVirtualAccountsCountOfSubAccount(address subAccount)`                                    | Sub-account address         | Count of active virtual accounts                   |

The `VirtualAccountDetail` struct includes: account address, parent account, symbol ID, metadata, existence flag, and isolation type.

***

### Single VA Mode & Address Prediction

| Function                                                                                                            | Parameters                          | Returns                                                       |
| ------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------- |
| `getActiveVAByKey(address subAccount, VirtualAccountIsolationType isolationType, uint256 symbolId)`                 | Sub-account, isolation type, symbol | Active virtual account address for this key (or `address(0)`) |
| `getSubAccountVirtualNonce(address subAccount)`                                                                     | Sub-account address                 | Current nonce (next VA uses nonce + 1)                        |
| `predictNextVirtualAccountAddress(address subAccount, VirtualAccountIsolationType isolationType, uint256 symbolId)` | Sub-account, isolation type, symbol | Predicted next virtual account address                        |

The prediction function checks the reuse pool first, then singleVAMode, then generates from the next nonce — matching the exact logic used by `_getOrCreateVirtualAccount` in the CoreFacet. This is useful for pre-funding virtual accounts via `addMarginToNextVA`.

***

### AccountManager & Signer

| Function                                                         | Parameters                 | Returns                                                                      |
| ---------------------------------------------------------------- | -------------------------- | ---------------------------------------------------------------------------- |
| `generateAccountManagerAddress(address registrant, string name)` | Registrant, affiliate name | Deterministic AccountManager address                                         |
| `getSigner()`                                                    | —                          | Current effective signer (globalSigner if set, otherwise msg.sender)         |
| `getRelatedCore(address account)`                                | Account address            | Symmio core diamond address for this account                                 |
| `ownerOf(address account)`                                       | Account address            | Owner address (resolves sub-accounts, virtual accounts, and legacy accounts) |
| `globalNonce()`                                                  | —                          | Current global nonce for sub-account address generation                      |
| `accountManagerImplementation()`                                 | —                          | Current AccountManager proxy bytecode                                        |

***

### Affiliate Queries

| Function                                                           | Parameters                    | Returns                                                      |
| ------------------------------------------------------------------ | ----------------------------- | ------------------------------------------------------------ |
| `getAffiliateState(address affiliate)`                             | Affiliate address             | `AffiliateState` (NONE, PENDING, ACTIVE, PAUSED)             |
| `getAffiliateAdmin(address affiliate)`                             | Affiliate address             | Admin address                                                |
| `getAffiliateFeeDistributor(address affiliate)`                    | Affiliate address             | Deterministic fee distributor address                        |
| `getAffiliateSymmioCores(address affiliate)`                       | Affiliate address             | Array of registered Symmio core addresses                    |
| `getAffiliateStakeholders(address affiliate)`                      | Affiliate address             | Array of `Stakeholder` structs (receiver + share)            |
| `getAffiliateSymmioShare(address affiliate)`                       | Affiliate address             | Symmio protocol share (fraction of 1e18)                     |
| `isWhitelistedSymmioCore(address core)`                            | Core address                  | Whether the core is whitelisted                              |
| `getHook(address affiliate, bytes4 selector)`                      | Affiliate, selector           | Hook contract address                                        |
| `isOperator(address affiliate, bytes4 selector, address operator)` | Affiliate, selector, operator | Whether the operator is authorized                           |
| `symmioFeeReceiver()`                                              | —                             | Address receiving Symmio's share of fees                     |
| `dryClaimAllFees(address affiliate, address symmio)`               | Affiliate, Symmio core        | Simulated fee distribution (stakeholder addresses + amounts) |

***

### Legacy Account Queries

| Function                                                     | Parameters         | Returns                                                       |
| ------------------------------------------------------------ | ------------------ | ------------------------------------------------------------- |
| `isLegacyMultiAccount(address account)`                      | Address            | Whether it is a registered legacy MultiAccount contract       |
| `getLegacyMultiAccounts()`                                   | —                  | All registered legacy MultiAccount addresses                  |
| `getLegacyAccountsOfUser(address owner, uint256 maxResults)` | Owner, max results | `LegacyAccountInfo[]` with import status, plus `hasMore` flag |

The `LegacyAccountInfo` struct includes: account address, name, legacy contract address, and `alreadyImported` flag indicating whether the account has been imported into the Account Layer.

***

### Role & Pause Queries

| Function                                  | Parameters | Returns                                     |
| ----------------------------------------- | ---------- | ------------------------------------------- |
| `hasRole(address user, bytes32 role)`     | User, role | Whether the user has the role               |
| `isRoleAdmin(address user, bytes32 role)` | User, role | Whether the user is a role admin            |
| `paused()`                                | —          | Whether the Account Layer diamond is paused |

***

### Constants

| Function            | Returns                                                           |
| ------------------- | ----------------------------------------------------------------- |
| `MAX_NAME_LENGTH()` | Maximum allowed length for account and affiliate names (in bytes) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.symm.io/contract-documentation/symmio-perps-v0.8.5/account-layer-diamond/view-facet.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
