# SymmioPartyB Contract

The `SymmioPartyB` contract is the core **execution proxy** for Party B actors. It provides **secure routing**, **multi-call support**, and **fine-grained permissioning** for interactions with the Symmio core contracts.

This contract allows Party B to batch trade operations, authorize token flows, and interface with both internal and whitelisted external contracts.

## **Core Functions**

### 🔹 **Symmio Call Dispatcher**

```solidity
function _call(bytes[] calldata callDatas) external;
```

Forwards multiple encoded calls to the Symmio core (e.g., opening or closing trades). Enforces selector-level permissions:

* `restrictedSelectors[sel] == true`: requires `MANAGER_ROLE`
* otherwise: `TRUSTED_ROLE` or `InstantLayer` delegate is sufficient

Reverts if any call fails.

### 🔹 **Multicast Executor**

```solidity
function _multicastCall(
    address[] calldata dests,
    bytes[] calldata datas
) external;
```

Sends parallel external calls to approved targets. All destination contracts must be whitelisted. Requires `TRUSTED_ROLE`.

### 🔹 **Token Management**

```solidity
function _approve(address token, uint256 amount) external;
```

Sets Symmio token allowances. Callable by `TRUSTED_ROLE`.

```solidity
function withdrawERC20(address token, uint256 amount) external;
```

Withdraws tokens to the caller. Restricted to `MANAGER_ROLE`.

### 🔹 **Configuration Functions**

```solidity
function setRestrictedSelector(bytes4 sel, bool state) external;
```

Marks a core selector as restricted to `MANAGER_ROLE`.

```solidity
function setMulticastWhitelist(address addr, bool state) external;
```

Controls which external contracts can be called via `_multicastCall`.

```solidity
function setSigner(address newSigner) external;
```

Updates the ERC-1271 signer address used for off-chain validation.

### 🔹 **Signature Verification**

```solidity
function isValidSignature(
    bytes32 hash,
    bytes calldata sig
) external view returns (bytes4);
```

Returns `0x1626ba7e` if signature is valid; otherwise `0xffffffff`.

### 🔹 **Emergency Controls**

```solidity
function pause() external;
function unpause() external;
```

Enables or disables contract functions under emergency conditions. Controlled via `PAUSER_ROLE` / `UNPAUSER_ROLE`.

Once the cooldown period has elapsed, the withdrawal can be finalized:

```solidity
function completeWithdraw(uint256 id)
```
