# Delegate Management

## Overview of Delegation Mechanism

In the earlier Smart Margin (SM) versions (v1/v2), delegation was controlled at the SM account level. However, in SMv3, delegation is streamlined through Synthetix account permissions. Users can delegate control to another address by granting it the "commit async order" permission, which is executed directly through the Synthetix proxy. A programmatic example of this process can be found [here](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/Authentication.t.sol#L63).

## Permissions in SMv3

The core functionality of SMv3 hinges on account permissions. Granting Kwenta's Engine administrative authority over a user's Synthetix v3 account enables the Engine to carry out trades on the user’s behalf. This arrangement also empowers the Engine to offer specialized trading features, such as conditional orders, which are currently not available in the Synthetix protocol itself.

## Management of Delegates

Delegates are defined as addresses granted the "commit async order" permission for a specific account. Users can add or revoke these permissions through the Synthetix v3 Perps market proxy. The referenced example illustrates how to apply the `grantPermission` function to assign permissions, while the `revokePermission` function is used for their removal.

It’s important to note that as accounts are NFTs, their ownership can be transferred. In such instances, all pre-existing permissions are automatically **revoked**.

## Decentralization Considerations

The Engine checks the permission status of each incoming call with Synthetix v3 before proceeding. This means that assigning admin or "commit async order" permissions to the Engine is a secure process. However, it's crucial to remember that the strength of decentralization depends on its most vulnerable point. For instance, the Synthetix protocol is upgradeable, and therefore, there's a reliance on the trustworthiness of the Synthetix-owned multisig to avoid malicious actions.


---

# 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.v3.kwenta.io/infrastructure-overview/delegate-management.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.
