> For the complete documentation index, see [llms.txt](https://docs.symm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.symm.io/exchange-builder-documentation/frontend-builder-technical-guidance/creating-an-account-and-depositing-funds.md).

# Creating an Account and Depositing Funds

In Symmio v0.8.5 a user's trading capital lives in a **SubAccount** created on the **AccountLayer**, a single shared diamond that manages every frontend's accounts. You no longer deploy your own account contract: you register as an affiliate, and users create SubAccounts under your affiliate on the shared AccountLayer.

SubAccounts and the VirtualAccounts beneath them are virtual (CREATE2-style) addresses with no deployed bytecode; the AccountLayer holds their state. For the full account model and the isolation types, see Building a New Frontend.

#### Step 1: Create a SubAccount

`createSubAccounts(affiliate, accountsData[])` creates one or more SubAccounts under your affiliate. The Symmio core, isolation type, name, metadata, and single-VA flag are *fields of the `SubAccountCreationData` struct*, not positional arguments:

```python
# SubAccountCreationData = (name, metadata, symmioCore, isolationType, singleVAMode)
# isolationType uses SubAccountIsolationType: 0=POSITION, 1=MARKET, 2=MARKET_DIRECTION, 3=CUSTOM
sub_account_data = [(
    "TradingAccount",      # name
    b"",                   # metadata
    symmio_core_address,   # symmioCore
    0,                     # isolationType (POSITION)
    False,                 # singleVAMode
)]

account_layer.functions.createSubAccounts(
    affiliate_address,
    sub_account_data,      # array, create several at once if you like
).transact({"from": user})
```

`createSubAccounts` returns the deterministic addresses of the created SubAccounts and emits `SubAccountCreated` for each. To list a user's SubAccounts later, call `getUserSubAccountsAddresses(user, start, size)` on the AccountLayer.

{% hint style="info" %}
Migrating an existing MultiAccount frontend? The **AccountManager** wrapper exposes the old API (`addAccount`, `getAccounts`, `_call`) and creates CUSTOM-isolation SubAccounts that behave like the old model, so you can swap a contract address and migrate fully later. See Upgrading from MultiAccount (0.8.4).
{% endhint %}

#### Step 2: Deposit collateral

Collateral goes into the SubAccount on the AccountLayer. You can deposit alone, or deposit and allocate in a single call:

```python
# Deposit into the SubAccount balance
account_layer.functions.depositForAccount(sub_account, amount).transact({"from": user})

# Or deposit and allocate in one call
account_layer.functions.depositAndAllocateForAccount(sub_account, amount).transact({"from": user})
```

The actual ERC20 `transferFrom` happens inside the Symmio Core diamond, so **Symmio Core** is the address that needs the collateral allowance, not the AccountLayer. Approve it once before the first deposit:

```python
collateral.functions.approve(symmio_core_address, 2**256 - 1).transact({"from": user})
```

`amount` is in the token's native decimals; Symmio converts to 18-decimal fixed-point internally, so the same code works for 6-decimal USDC and 18-decimal stablecoins. Read the collateral token address from `getCollateral()` on the Symmio Core view facet and its decimals from the token's `decimals()`. On success you'll see `DepositForAccount`, plus `AllocateForAccount` if you allocated.

#### Step 3: Fund the VirtualAccount before trading

On a non-CUSTOM SubAccount the margin for a trade lives in a **VirtualAccount (VA)** beneath the SubAccount, not in the SubAccount itself. Before the first trade you fund the *next* VA; the AccountLayer derives which VA that is from the isolation type and symbol, so you don't pass a VA address. The VA isolation type uses `VirtualAccountIsolationType` (`POSITION`, `MARKET`, `MARKET_LONG`, `MARKET_SHORT`):

```python
va_isolation_type = 0  # VirtualAccountIsolationType.POSITION
symbol_id = 1

margin_facet.functions.addMarginToNextVA(
    sub_account, va_isolation_type, symbol_id, amount
).transact({"from": user})
```

To top up a VA that already exists, use `addMargin(virtual_account, amount)`. On a CUSTOM SubAccount there's no automatic VA: trades run directly through the SubAccount, like the old MultiAccount model.

Once the SubAccount is funded and the VA has margin, you're ready to send a quote.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.symm.io/exchange-builder-documentation/frontend-builder-technical-guidance/creating-an-account-and-depositing-funds.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
