# System Overview

## Smart Margin v3 Overview

Smart Margin v3 (SMv3) continues the legacy of its predecessors, aiming to elevate the trading experience on Kwenta by offering advanced tools for trading Synthetix derivatives.

### Architectural Evolution

SMv3 marks a departure from the previous versions’ account proxy approach. It introduces a monolithic "Engine" contract. This Engine is the hub for managing various components, including collateral, async orders, and conditional orders. It's designed to seamlessly integrate future features, consolidating them into a single, efficient contract.

### Streamlined Authentication Process

The shift to an account-based architecture in Synthetix v3 represents a significant leap forward regarding user authentication. This development simplifies how trader calls are transmitted from SM to Synthetix v3, enhancing security and efficiency.

For users to interact with SMv3, setting up a Synthetix v3 account via the Synthetix proxy is mandatory. Those who already have Synthetix accounts can integrate with Kwenta's Engine by granting it administrative permissions. This permission is flexible and can be revoked by the user at their discretion, providing an additional layer of control and security.

### Upgradability in Smart Margin v3

> <https://gov.kwenta.eth.limo/kips/kip-116/>

Smart Margin v3 (SMv3) retains the upgradability feature characteristic of its predecessors. The system's upgradability is enabled through the integration of [OpenZeppelin's UUPSUpgradeable utility](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable). Although the initial intention was to avoid upgradability, it remains a necessary feature. This is primarily due to the dynamic nature of the Synthetix v3 protocol, which SMv3 interfaces with. Aligning with Synthetix v3’s upgradability ensures that Kwenta and its traders can adapt to evolving needs and changes in the ecosystem.

The process of upgrading SMv3 is structured and secure. Upgrades are implemented using specific scripts, available [here](https://github.com/Kwenta/smart-margin-v3/blob/main/script/Upgrade.s.sol). To ensure safety and prevent any storage conflicts during upgrades, comprehensive [internal tests](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/Upgrade.t.sol#L15) have been developed using Foundry.

It’s important to highlight that upgrade decisions and executions are under strict governance. These actions are exclusively authorized and carried out only if initiated by Kwenta's ProtocolDAO (pDAO), a multisig owner entity. This governance layer reinforces the security and integrity of the SMv3 system, ensuring that upgrades align with the community's best interests and the platform's strategic vision.


---

# 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/system-overview.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.
