> 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/partyb-batch-actions.md).

# PartyB Batch Actions

The PartyB Batch Actions Facet allows PartyB to open multiple positions or fill multiple close requests in a single transaction using one batch Muon signature. Under heavy loads, obtaining individual Muon signatures and sending separate transactions for each quote significantly slows down solver response times. Batch methods address this by processing multiple quotes atomically. The underlying logic is implemented in the `PartyBBatchActionsFacetImpl` library.

***

#### Overview

The PartyB Batch Actions Facet provides:

* **Batch Open Positions:** Opens multiple positions in a single transaction, each with its own filled amount and price.
* **Batch Fill Close Requests:** Fills multiple close requests in a single transaction, each with its own filled amount and close price.

Both functions use a single `PairUpnlAndPricesSig` Muon signature that covers all quotes in the batch, rather than requiring a separate signature per quote.

***

#### openPositions()

Opens positions for multiple quotes in a single transaction. For each quote, PartyB can open with either the full amount requested by the user or a specific fraction of it. The opened position's size cannot be excessively small or large.

**Function Signature:**

```solidity
function openPositions(
    uint256[] memory quoteIds,
    uint256[] memory filledAmounts,
    uint256[] memory openedPrices,
    PairUpnlAndPricesSig memory upnlSig
) external whenNotPartyBOpenPositionsPaused;
```

**Parameters:**

* `quoteIds`: The IDs of the quotes to open positions for.
* `filledAmounts`: The amounts to fill for each quote. Can be the full requested quantity or a partial fill.
* `openedPrices`: The opening prices for each position.
* `upnlSig`: A single Muon `PairUpnlAndPricesSig` covering all quotes in the batch.

**Access:** Only callable by PartyB.

**Events Emitted:**

Events are emitted internally by the implementation for each opened position (e.g., `OpenPosition` per quote).

***

#### fillCloseRequests()

Fills close requests for multiple quotes in a single transaction. For LIMIT orders, PartyB can fill in multiple steps, each at a different price. For MARKET orders, the close must be filled entirely in one step.

**Function Signature:**

```solidity
function fillCloseRequests(
    uint256[] memory quoteIds,
    uint256[] memory filledAmounts,
    uint256[] memory closedPrices,
    PairUpnlAndPricesSig memory upnlSig
) external whenNotPartyBActionsPaused;
```

**Parameters:**

* `quoteIds`: The IDs of the quotes whose close requests should be filled.
* `filledAmounts`: The amounts to fill for each close request. LIMIT orders support partial fills; MARKET orders must be filled fully.
* `closedPrices`: The closing prices for each position.
* `upnlSig`: A single Muon `PairUpnlAndPricesSig` covering all quotes in the batch.

**Access:** Only callable by PartyB.

**Events Emitted (per quote):**

* `FillCloseRequest(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closedPrice, QuoteStatus status, uint256 closeId)` (legacy event)
* `FillCloseRequest(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closedPrice, QuoteStatus status, uint256 closeId, LockedValues lockedValues)` (new event with locked values included)


---

# 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/partyb-batch-actions.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.
