# MIMOProxyGuard

As previously mentioned, the management of MIMOProxy's permissions has been delegated to the `MIMOProxyGuard`, which is deployed through the Openzeppelin Clones library in the `MIMOProxyFactory` for each `MIMOProxy`.

Having the permission management outside the `MIMOProxy` reduces the risk of storage collision, and having a separate contract for it enables easy permission clearing. In the event of an ownership transfer of the `MIMOProxy`, a new owner will likely want to clear existing permissions for security reasons (e.g., malicious action contracts may have been granted permissions before the transfer). However, due to the granularity of permissions, it would be difficult and expensive to remove them one by one. With the `MIMOProxyGuard`, a user can simply clone a new `MIMOProxyGuard`, which will not have any permissions set.

### Write Methods

#### `initialize(address proxyFactory, address proxy)`

Initializer function to set state variables upon cloning.

| Param Name     | Type    | Description                                       |
| -------------- | ------- | ------------------------------------------------- |
| `proxyFactory` | address | `MIMOProxyFactory` address                        |
| `proxy`        | address | Address of the `MIMOProxy` linked to the contract |

#### `setPermission(address envoy, address target, bytes4 selector, bool permission)`

Gives or takes a permission from an envoy to call the given target contract and function selector on behalf of the owner.

Requirements :&#x20;

* Caller must the owner of the set `MIMOProxy` or the `MIMOProxy`

| Param Name   | Type    | Description                                          |
| ------------ | ------- | ---------------------------------------------------- |
| `envoy`      | address | The address of the envoy account                     |
| `target`     | address | The address of the target contract                   |
| `selector`   | bytes4  | The 4 bytes function selector on the target contract |
| `permission` | bool    | The boolean permission to set                        |

### View Methods

#### `getPermission(address envoy, address target, bytes4 selector)`

Returns the permission for specific `envoy`, `target` and `selector`.

**Call Params**

| Name       | Type     | Description                                          |
| ---------- | -------- | ---------------------------------------------------- |
| `envoy`    | address  | The address of the envoy account                     |
| `target`   | target   | The address of the target contract                   |
| `selector` | selector | The 4 bytes function selector on the target contract |

**Return Values**

| Name         | Type | Description                                                        |
| ------------ | ---- | ------------------------------------------------------------------ |
| `permission` | bool | `true` if envoys is allowed to perform the call and `false` if not |

#### `getProxy()`

Returns the address of the MIMOProxy associated with the `MIMOProxyGuard` contract.


---

# Agent Instructions: 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:

```
GET https://docs.parallel.best/developers-hub/parallel-v2/super-vault-sv/proxy-design/mimoproxyguard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
