> 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/diamond-core-facets/view-facet-quote.md).

# View Facet Quote

The ViewFacet Quote provides read-only functions for querying quote and position data. It exposes individual quote lookups, paginated position lists for both PartyA and PartyB, pending quote arrays, bitmap-based batch retrieval, and per-quote funding debt calculations. All functions are `view` and do not modify state.

***

### Overview

The ViewFacet Quote is organized into the following categories:

* **Individual Quote Lookups:** Retrieve a single quote by ID, follow the parent chain for partial fills, and get close IDs.
* **PartyA Queries:** Quote IDs, quotes, open positions, pending quotes, and position counts for a PartyA.
* **PartyB Queries:** Open positions per PartyA, filtered positions by PartyB, pending quotes, and position counts.
* **Bitmap Retrieval:** Gas-aware batch retrieval of quotes using a bitmap selector.
* **Funding Debt:** Per-quote and summed accumulated funding debt calculations.

***

### Individual Quote Lookups

| Function                                           | Parameters                   | Returns                                                                  |
| -------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------ |
| `getQuote(uint256 quoteId)`                        | Quote ID                     | Full `Quote` struct                                                      |
| `getQuotesByParent(uint256 quoteId, uint256 size)` | Starting quote ID, max count | Array of quotes following the `parentId` chain (partial fill remainders) |
| `getQuoteCloseId(uint256 quoteId)`                 | Quote ID                     | The current close ID for the quote                                       |
| `getNextQuoteId()`                                 | —                            | The next quote ID that will be assigned                                  |

***

### PartyA Queries

| Function                                                              | Parameters         | Returns                                                                   |
| --------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------- |
| `quoteIdsOf(address partyA, uint256 start, uint256 size)`             | PartyA, pagination | Paginated array of quote IDs associated with PartyA                       |
| `getQuotes(address partyA, uint256 start, uint256 size)`              | PartyA, pagination | Paginated array of `Quote` structs for PartyA                             |
| `quotesLength(address user)`                                          | User address       | Total number of quotes associated with the user                           |
| `getPartyAOpenPositions(address partyA, uint256 start, uint256 size)` | PartyA, pagination | Paginated open positions (OPENED, CLOSE\_PENDING, CANCEL\_CLOSE\_PENDING) |
| `partyAPositionsCount(address partyA)`                                | PartyA address     | Number of open positions                                                  |
| `getPartyAPendingQuotes(address partyA)`                              | PartyA address     | Array of pending quote IDs                                                |

***

### PartyB Queries

| Function                                                                              | Parameters                 | Returns                                                                                     |
| ------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------- |
| `getPartyBOpenPositions(address partyB, address partyA, uint256 start, uint256 size)` | PartyB, PartyA, pagination | Paginated open positions for this PartyB-PartyA pair                                        |
| `partyBPositionsCount(address partyB, address partyA)`                                | PartyB, PartyA             | Number of open positions for this pair                                                      |
| `getPartyBPendingQuotes(address partyB, address partyA)`                              | PartyB, PartyA             | Array of pending quote IDs for this pair                                                    |
| `getPositionsFilteredByPartyB(address partyB, uint256 start, uint256 size)`           | PartyB, range              | All positions (any status) where PartyB matches, scanned over a quote ID range              |
| `getOpenPositionsFilteredByPartyB(address partyB, uint256 start, uint256 size)`       | PartyB, range              | Only open positions (OPENED, CLOSE\_PENDING, CANCEL\_CLOSE\_PENDING) for this PartyB        |
| `getActivePositionsFilteredByPartyB(address partyB, uint256 start, uint256 size)`     | PartyB, range              | All non-terminal positions (excludes CANCELED, CLOSED, EXPIRED, LIQUIDATED) for this PartyB |

**Note:** The `FilteredByPartyB` functions scan over a raw quote ID range (not indexed arrays), so `start` and `size` refer to quote IDs, not array indices. These are useful for broad scans but less efficient than the indexed `getPartyBOpenPositions`.

***

### Bitmap Retrieval

#### getQuotesWithBitmap()

Retrieves a filtered set of quotes using a bitmap structure. This allows callers to specify exactly which quote IDs to fetch using a compact bit representation. The function is gas-aware — it stops retrieval if remaining gas drops below the specified threshold.

**Function Signature:**

```solidity
function getQuotesWithBitmap(Bitmap calldata bitmap, uint256 gasNeededForReturn) external view returns (Quote[] memory);
```

**Parameters:**

* `bitmap`: A structured bitmap with elements, each containing an `offset` (starting quote ID) and a 256-bit integer where each set bit indicates a quote to retrieve.
* `gasNeededForReturn`: Minimum gas required to complete execution and return data. Prevents starting retrieval that can't be completed.

**Returns:** Array of `Quote` structs corresponding to the set bits in the bitmap.

***

### Funding Debt

These functions calculate the accumulated funding debt for individual quotes using the new accumulated funding system. Positive values indicate the quote owes funding; negative values indicate it is owed funding.

| Function                                      | Parameters         | Returns                                             |
| --------------------------------------------- | ------------------ | --------------------------------------------------- |
| `getQuoteFundingDebts(uint256[] quoteIds)`    | Array of quote IDs | Array of funding debts (one per quote, same order)  |
| `getSumQuoteFundingDebts(uint256[] quoteIds)` | Array of quote IDs | Sum of all funding debts across the provided quotes |


---

# 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/diamond-core-facets/view-facet-quote.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.
