# View Facet Symbol

The ViewFacet Symbol provides read-only functions for querying symbol configuration, symbol type information, PartyA-PartyB connections, allowed symbol lists, and funding fee structures. All functions are `view` and do not modify state.

***

### Overview

The ViewFacet Symbol is organized into the following categories:

* **Symbol Lookups:** Retrieve individual symbols or paginated lists, with or without type information.
* **Allowed Symbols for PartyA:** Filtered symbol lists based on the PartyA's connected PartyBs and their whitelisted symbols.
* **Symbol Lookups by Quote:** Resolve symbols from quote IDs.
* **PartyA-PartyB Connections:** Query which PartyBs are connected to a PartyA, with optional active symbol counts.
* **PartyB Symbol Whitelisting:** Check whether a symbol type is whitelisted for a PartyB.
* **Funding & Force Close:** Funding fee structures per (symbol, PartyB) and force close gap ratios.

***

### Symbol Lookups

| Function                                          | Parameters | Returns                                                  |
| ------------------------------------------------- | ---------- | -------------------------------------------------------- |
| `getSymbol(uint256 symbolId)`                     | Symbol ID  | Full `Symbol` struct                                     |
| `getSymbolWithType(uint256 symbolId)`             | Symbol ID  | `SymbolWithType` struct (symbol details + category type) |
| `getSymbols(uint256 start, uint256 size)`         | Pagination | Paginated array of `Symbol` structs                      |
| `getSymbolsWithType(uint256 start, uint256 size)` | Pagination | Paginated array of `SymbolWithType` structs              |

***

### Allowed Symbols for PartyA

These functions return symbols that a PartyA is permitted to trade, based on the PartyBs they are connected to and those PartyBs' whitelisted symbols. Only valid (`isValid = true`) symbols are included.

| Function                                                                          | Parameters         | Returns                                                    |
| --------------------------------------------------------------------------------- | ------------------ | ---------------------------------------------------------- |
| `getAllowedSymbolsForPartyA(address partyA, uint256 start, uint256 size)`         | PartyA, pagination | Paginated `Symbol[]` of allowed symbols                    |
| `getAllowedSymbolsWithTypeForPartyA(address partyA, uint256 start, uint256 size)` | PartyA, pagination | Paginated `SymbolWithType[]` of allowed symbols with types |

**Note:** These scan over the full symbol ID range, so entries where the symbol is not allowed for the PartyA will be empty (zero-initialized structs) in the returned array.

***

### Symbol Lookups by Quote

| Function                                  | Parameters          | Returns                                   |
| ----------------------------------------- | ------------------- | ----------------------------------------- |
| `symbolsByQuoteId(uint256[] quoteIds)`    | Array of quote IDs  | Array of `Symbol` structs (one per quote) |
| `symbolNameByQuoteId(uint256[] quoteIds)` | Array of quote IDs  | Array of symbol name strings              |
| `symbolNameById(uint256[] symbolIds)`     | Array of symbol IDs | Array of symbol name strings              |

***

### PartyA-PartyB Connections

| Function                                              | Parameters     | Returns                                                                                                        |
| ----------------------------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------- |
| `getConnectedPartyBs(address partyA)`                 | PartyA address | Array of connected PartyB addresses                                                                            |
| `isConnectedPartyB(address partyA, address partyB)`   | PartyA, PartyB | Whether this PartyB is connected to the PartyA                                                                 |
| `getConnectedPartyBsWithSymbolCounts(address partyA)` | PartyA address | Array of `PartyBSymbolCount` structs — each PartyB with the count of unique symbols that have active positions |

The `PartyBSymbolCount` struct:

```solidity
struct PartyBSymbolCount {
    address partyB;
    uint256 symbolCount;  // Number of unique active symbols for this PartyA-PartyB pair
}
```

This is useful for frontends that need to know the scope of each PartyB relationship (e.g., to paginate aggregate position queries).

***

### PartyB Symbol Whitelisting

| Function                                                      | Parameters          | Returns                                                    |
| ------------------------------------------------------------- | ------------------- | ---------------------------------------------------------- |
| `isWhitelistedSymbolType(address partyB, uint256 symbolType)` | PartyB, symbol type | Whether the symbol category is whitelisted for this PartyB |

***

### Funding & Force Close

| Function                                                   | Parameters        | Returns                                                                     |
| ---------------------------------------------------------- | ----------------- | --------------------------------------------------------------------------- |
| `getFundingFeesOfPartyB(uint256 symbolId, address partyB)` | Symbol ID, PartyB | `FundingFee` struct containing current rates, accumulated rates, epoch info |
| `forceCloseGapRatio(uint256 symbolId)`                     | Symbol ID         | The force close gap ratio for this symbol                                   |

The `FundingFee` struct contains:

```solidity
struct FundingFee {
    int256 currentLongRate;
    int256 currentShortRate;
    int256 accumulatedLongRate;
    int256 accumulatedShortRate;
    uint256 lastUpdatedEpoch;
    uint256 startEpoch;
    uint256 epochDuration;
}
```
