# Getting Started

## SMv3 Step-by-Step Guide

### Quick Start Overview

This simplified guide provides a streamlined approach for interacting with SMv3. Note that "Proxy" refers to the Synthetix Perps v3 market proxy.

**Initial Setup**

1. **Account Creation:** Initiate a Synthetix v3 Account using `Proxy.createAccount`.
2. **Permission Granting:** Assign admin permission to Kwenta's Engine via `Proxy.grantPermission`.
   * *Efficiency Tip:* Steps 1 and 2 can be combined into a single transaction using Synthetix v3's [TrustedMulticallForwarder](https://github.com/Synthetixio/synthetix-v3/blob/main/auxiliary/TrustedMulticallForwarder/src/TrustedMulticallForwarder.sol), a feature co-developed by Kwenta.

**Trading Preparation**

3. **Collateral Approval:** Approve the Engine to manage your trading collateral (e.g., `$USDC`, `$snxUSD`, `$snxBTC`, `$snxETH`) using `IERC20.approve`.
4. **Collateral Deposit:** Deposit your trading collateral with `Engine.modifyCollateral`.

**Trading Execution**

5. **Commit Async Order:** Execute trades (one at a time, as per Synthetix restrictions) using `Engine.commitOrder`.
   * *Batching Capability:* Steps 4 and 5 can be processed together, thanks to the multicall functionality of the Kwenta Engine.

#### Programmatic Interaction Guide

For those looking to interact programmatically, here are detailed steps with corresponding code examples:

1. [Creating a Synthetix v3 Account](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/utils/Bootstrap.sol#L89)
2. [Granting Kwenta's Engine Admin Permission](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/utils/Bootstrap.sol#L90)
3. [Approving Engine for Collateral Spend](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/Collateral.t.sol#L19)
4. [Depositing Supported Collateral](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/Collateral.t.sol#L21)
5. [Opening a Position via Async Order](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/AsyncOrder.t.sol#L32)
6. [Credit Funding for Conditional Order Execution](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/Credit.t.sol#L46)
7. [Debiting Account to Return Credited Funds](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/Credit.t.sol#L132)
8. [Defining a Conditional Order](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/ConditionalOrder.t.sol#L60)
9. [Executing a Valid Conditional Order](https://github.com/Kwenta/smart-margin-v3/blob/b479bc5847bc1040c716fc8fbfc2e474c6e6307b/test/ConditionalOrder.t.sol#L495)

This guide aims to facilitate a clear and efficient journey through SMv3’s setup and trading processes.


---

# 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/getting-started.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.
