> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsidemax.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# userAccount: Query Account Balances and Open Positions

> Query your account equity, collateral balances, open positions, and margin availability for a specific market deployer or across all deployers.

The `userAccount` query returns your account's complete financial state for a given market deployer: cross equity, margin availability, collateral balances, and all open positions. Pass `marketDeployerId: 0` for an account-wide overview that also includes portfolio groups, chain-level balances, and per-contract settings across all deployers.

<Note>
  All numeric values are raw integers. Use `priceScale` and `qtyScale` from the [`configs`](/info/configs) response to convert prices and quantities to display values.
</Note>

## Request

```json theme={"system"}
{"type": "userAccount", "accountId": "5", "marketDeployerId": 1}
```

<ParamField body="type" type="string" required>
  Must be `"userAccount"`.
</ParamField>

<ParamField body="accountId" type="string" required>
  Your account ID, obtained from the `registerAccount` action.
</ParamField>

<ParamField body="marketDeployerId" type="integer" required>
  Market deployer to query. Use `0` to get a global account overview that includes all deployers, portfolio groups, and chain-level balances.
</ParamField>

## Response

```json theme={"system"}
{
  "type": "userAccount",
  "accountId": "1",
  "marketDeployerId": 1,
  "crossEquity": "1000000000000",
  "orderFrozen": "0",
  "orderLoss": "0",
  "marginAvailable": "1000000000000",
  "marginAvailableForOrder": "1000000000000",
  "totalPositionIM": "0",
  "crossPositionMM": "0",
  "crossCollaterals": [{"coinId": 1, "amount": "1000000000000"}],
  "isolatedCollaterals": [],
  "positions": [
    {
      "contractId": 1,
      "positionSide": "OneWay",
      "size": "5",
      "openValue": "500",
      "isLongPosition": false,
      "fundingIndex": "0",
      "leverage": "10",
      "isIsolated": false,
      "unrealizedPnl": "0",
      "mm": "0"
    }
  ]
}
```

### Margin Fields

<ResponseField name="crossEquity" type="string">
  Total cross margin equity: the sum of your cross collateral and unrealized PnL across all cross positions (raw integer string).
</ResponseField>

<ResponseField name="orderFrozen" type="string">
  Margin currently reserved to cover the worst-case cost of your open orders (raw integer string).
</ResponseField>

<ResponseField name="orderLoss" type="string">
  Adverse price difference between your open order prices and the current mark price, representing potential additional margin consumption (raw integer string).
</ResponseField>

<ResponseField name="marginAvailable" type="string">
  Free cross margin: `crossEquity - orderFrozen - orderLoss` (raw integer string).
</ResponseField>

<ResponseField name="marginAvailableForOrder" type="string">
  Margin available to open new positions: `marginAvailable - totalPositionIM` (raw integer string).
</ResponseField>

<ResponseField name="totalPositionIM" type="string">
  Sum of initial margin allocated to all open cross positions (raw integer string).
</ResponseField>

<ResponseField name="crossPositionMM" type="string">
  Total maintenance margin across all cross positions. Liquidation is triggered when `crossEquity` falls below this value (raw integer string).
</ResponseField>

<ResponseField name="crossCollaterals" type="Collateral[]">
  List of collateral balances in the cross margin pool. Each entry contains `coinId` and `amount` (raw integer string).
</ResponseField>

<ResponseField name="isolatedCollaterals" type="Collateral[]">
  List of collateral balances allocated to isolated margin positions. Each entry contains `posKey` (string, the position composite key = `contractId` + side), `coinId`, and `amount`.
</ResponseField>

### Position Fields

<ResponseField name="contractId" type="integer">
  The contract this position belongs to. Cross-reference with `configs` to get the contract name and scales.
</ResponseField>

<ResponseField name="positionSide" type="string">
  Position mode: `"OneWay"` for one-way mode, `"L"` for hedge-mode long, or `"S"` for hedge-mode short.
</ResponseField>

<ResponseField name="size" type="string">
  Absolute position quantity (raw integer string). Divide by `10^qtyScale` from `configs` to get the display value.
</ResponseField>

<ResponseField name="openValue" type="string">
  Notional value at which the position was opened (raw integer string). Divide by `10^priceScale` from `configs` to get the display value.
</ResponseField>

<ResponseField name="isLongPosition" type="boolean">
  `true` if the position is long (net buyer); `false` if short (net seller).
</ResponseField>

<ResponseField name="leverage" type="string">
  Current leverage applied to this position.
</ResponseField>

<ResponseField name="isIsolated" type="boolean">
  `true` if this position uses isolated margin; `false` if it draws from the cross margin pool.
</ResponseField>

<ResponseField name="fundingIndex" type="string">
  The cumulative funding index recorded when this position was last settled. Used to compute accrued-but-unpaid funding: `(currentFundingIndex - fundingIndex) × size`.
</ResponseField>

<ResponseField name="unrealizedPnl" type="string">
  Mark-price unrealized profit or loss (raw integer string). Negative values represent a loss.
</ResponseField>

<ResponseField name="mm" type="string">
  Maintenance margin allocated to this individual position (raw integer string).
</ResponseField>

### Account-Level Fields

These fields are always returned regardless of the `marketDeployerId` value you pass.

<ResponseField name="marginShareType" type="string">
  Account margin model: `"Unified"` for standard cross margin, or `"Portfolio"` for portfolio margin with share groups.
</ResponseField>

<ResponseField name="depositNonce" type="string">
  Account-level monotonic deposit nonce — the value the next deposit should carry. Use this to verify deposit sequencing and detect missing or replayed deposit events.
</ResponseField>

<ResponseField name="takerOverrideBps" type="integer">
  Per-user taker fee-rate override under this market deployer. `-32768` = unset (falls back to owner/contract fee); `0` = explicit 0%.
</ResponseField>

<ResponseField name="makerOverrideBps" type="integer">
  Per-user maker fee-rate override under this market deployer. `-32768` = unset (falls back to owner/contract fee); `0` = explicit 0%.
</ResponseField>

<ResponseField name="chainBalances" type="ChainBalance[]">
  Chain-level available balances: `{coinId, amount}`. These reflect funds available for deposit into the exchange.
</ResponseField>

<ResponseField name="contractSettings" type="ContractSetting[]">
  Per-contract trading settings: `{contractId, marginMode, positionMode, leverage}`. Reflects your current configuration for each contract.
</ResponseField>

<ResponseField name="portfolioGroups" type="PortfolioGroup[]">
  Share group views for PORTFOLIO margin mode accounts. Each entry reflects the combined equity and margin state of a portfolio group. Only populated when `marginShareType` is `"Portfolio"`.
</ResponseField>
