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

# AccountsService

> Profiles, balances, movements, sub-accounts, trades, and portfolio RPCs

Package: `monaco.api.accounts`

Source: `protos/api/accounts.proto`

Use `AccountsService` for authenticated account state, balances, movements, portfolio analytics, funding payments, and sub-account limits.

```protobuf theme={null}
service AccountsService {
  rpc GetProfile(GetProfileRequest) returns (GetProfileResponse);
  rpc GetBalances(GetBalancesRequest) returns (GetBalancesResponse);
  rpc GetBalanceByAsset(GetBalanceByAssetRequest) returns (GetBalanceByAssetResponse);
  rpc GetMovements(GetMovementsRequest) returns (GetMovementsResponse);
  rpc ListFundingPayments(ListFundingPaymentsRequest) returns (ListFundingPaymentsResponse);
  rpc ListSubAccounts(ListSubAccountsRequest) returns (ListSubAccountsResponse);
  rpc CreateLimit(CreateLimitRequest) returns (CreateLimitResponse);
  rpc UpdateLimit(UpdateLimitRequest) returns (UpdateLimitResponse);
  rpc GetLimits(GetLimitsRequest) returns (GetLimitsResponse);
  rpc GetUserTrades(GetUserTradesRequest) returns (GetUserTradesResponse);
  rpc GetPortfolioStats(GetPortfolioStatsRequest) returns (GetPortfolioStatsResponse);
  rpc GetPortfolioChart(GetPortfolioChartRequest) returns (GetPortfolioChartResponse);
  rpc GetPortfolioSummary(GetPortfolioSummaryRequest) returns (GetPortfolioSummaryResponse);
  rpc GetPortfolioPerformance(GetPortfolioPerformanceRequest) returns (GetPortfolioPerformanceResponse);
  rpc GetPortfolioRealizedPnl(GetPortfolioRealizedPnlRequest) returns (GetPortfolioRealizedPnlResponse);
  rpc GetPortfolioAssets(GetPortfolioAssetsRequest) returns (GetPortfolioAssetsResponse);
  rpc GetPortfolioMargin(GetPortfolioMarginRequest) returns (GetPortfolioMarginResponse);
  rpc DeleteLimit(DeleteLimitRequest) returns (DeleteLimitResponse);
  rpc GetSelfTradePreventionDefault(GetSelfTradePreventionDefaultRequest) returns (SelfTradePreventionDefaultResponse);
  rpc SetSelfTradePreventionDefault(SetSelfTradePreventionDefaultRequest) returns (SelfTradePreventionDefaultResponse);
}
```

## Notes

* Most RPCs are user-authenticated.
* Sub-account limit RPCs are for master/sub-account permission management.
* User trade history is also available through `TradesService.ListUserTrades`.
* `GetUserTradesResponse` carries `total`, `total_pages` and `total_capped` on every page of an unfiltered walk: the number of trades the walk returns (both sides, hot and archived, a self-trade once), exact up to 10,000 and reported as 10,000 with `total_capped` set past that. With `trading_pair_id` set no count runs: `total` and `total_pages` are unset and `total_capped` is false. They are also unset when the count runs out of its server time budget, so treat unset as unknown, not zero. `TradesService.ListUserTrades` carries no count.
* `GetPortfolioMargin` describes the default margin account unless `GetPortfolioMarginRequest.margin_account_id` names another of the caller's margin accounts (a sub-account), in which case `total`, `positions` and `risk_buckets` are that account's own. `GetPortfolioMarginResponse.margin_account_id` names the account described and is absent before the caller has a margin account. With `include_accounts`, the response also carries `accounts` — one `PortfolioMarginAccount` (`margin_account_id`, `subaccount_key`, `total`) per open margin account, the default one first, then sub-accounts by key — and `owner_total`, their sum. A malformed `margin_account_id` is `INVALID_ARGUMENT`; one that is not the caller's is `NOT_FOUND`; past the read budget it is `RESOURCE_EXHAUSTED` with a `RetryInfo` detail, and `UNAVAILABLE` when portfolio data is unavailable.
* `GetUserTrades` returns `UserTrade.fee` as the total fee paid: for a taker, Monaco's taker fee plus the application's builder fee; for a maker, the maker fee (negative for a rebate). `monaco_fee` + `builder_fee` = `fee`, with RAW twins `monaco_fee_raw` and `builder_fee_raw` beside `fee_raw`; `builder_fee` is `"0"` for a maker.
* The self-trade-prevention RPCs read and set one default per **wallet family** — every account sharing a wallet address, across applications — not per `users.id`. `SelfTradePreventionDefaultResponse` carries `mode` and `is_custom`, where `is_custom` is `false` when the platform default `CANCEL_MAKER` is being inherited.
* `SetSelfTradePreventionDefaultRequest.mode` accepts `CANCEL_MAKER`, `CANCEL_TAKER`, `CANCEL_BOTH` or `SKIP`, case-insensitively on the wire. An unknown mode is `INVALID_ARGUMENT`.
* **Both** RPCs also return `INVALID_ARGUMENT` when the authenticated session's wallet is not a canonical EVM address (`0x` + 40 hex). The default is keyed by wallet, so a legacy non-EVM session has no wallet family for it to apply to — the shared handler validates the address before reading or writing.
* **Both** RPCs are denied to delegated-agent sessions with `PERMISSION_DENIED` — an agent can neither read nor set its owner's default.
* `GetSelfTradePreventionDefault` is classified as an authenticated **read**, so it draws the per-account read budget and can return `RESOURCE_EXHAUSTED` with a `RetryInfo` detail once enforcement is enabled. The setter is a write: it draws the per-account settings-write budget it shares with the copy trading lead trader and follow writes (about one write per second, burst 10) and returns `RESOURCE_EXHAUSTED` with a `RetryInfo` detail past it, enforced from the first request. The setter also returns `UNAVAILABLE` when the matching engine is unreachable or the sequenced write fails transiently. That is not proof the setting is unchanged — `DeadlineExceeded` and `Cancelled` map to it too, so the write may have committed before the response was lost. Re-read with the getter, or retry the same `mode`: the call sets an absolute value, so a replay cannot land a different one.
* The setter is sequenced through the matching engine and returns only after the durable append, so the wallet's next order already resolves the new mode. The getter serves an asynchronous projection, so a read issued immediately after a set can briefly lag the setter's own response.
* A per-order `self_trade_prevention_mode` on `OrdersService` always overrides this default.
* `GetBalances`, `GetMovements` and `ListFundingPayments` are cursor-paginated: send an empty `page_token` to start, then each response's `next_page_token` until it comes back empty; `page_size` is 1 to 1000. There is no `page` field: a stub generated from an older proto that still sets it is not rejected (protobuf discards the unknown field) and reads the first page on every call, so regenerate stubs and walk the token.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.