Skip to content

Get Balance Updates

Retrieve historical deposit and withdrawal transactions for a subaccount. This endpoint returns balance changes from on-chain deposits and withdrawals, excluding funding payments.

Endpoint

POST https://papi.synthetix.io/v1/trade

Request

Request Format

{
  "params": {
    "action": "getBalanceUpdates",
    "subAccountId": "1867542890123456789",
    "actionFilter": "DEPOSIT",
    "limit": 50,
    "offset": 0
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704153600000,
  "signature": {
    "v": 28,
    "r": "0x19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef",
    "s": "0xabcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600"
  }
}

Request Parameters

ParameterTypeRequiredDescription
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "getBalanceUpdates"
params.subAccountIdstringYesSubaccount ID to retrieve balance updates for
params.actionFilterstringNoFilter by action type: "DEPOSIT", "WITHDRAWAL", or comma-separated "DEPOSIT,WITHDRAWAL". Defaults to both
params.limitintegerNoMaximum number of results to return (default: 50, max: 1000)
params.offsetintegerNoPagination offset (default: 0)
ParameterTypeRequiredDescription
nonceuint64YesUnix milliseconds timestamp (must be monotonically increasing)
signatureobjectYesEIP-712 signature object
expiresAfteruint64NoUnix milliseconds expiration timestamp (5x rate limit on stale cancels)

Response

Response Structure

FieldTypeDescription
statusstringAlways "ok" for successful requests or "error" for failures
responseobjectResponse object containing balance updates (omitted when status is "error")
errorobjectError details (only present when status is "error")
request_idstringRequest tracking identifier

Success Response

{
  "status": "ok",
  "response": {
    "balanceUpdates": [
      {
        "id": 12345,
        "subAccountId": 1867542890123456789,
        "action": "DEPOSIT",
        "status": 1,
        "amount": "1000.00",
        "collateral": "USDT",
        "timestamp": 1704067200000,
        "txHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
      },
      {
        "id": 12346,
        "subAccountId": 1867542890123456789,
        "action": "WITHDRAWAL",
        "status": 1,
        "amount": "-500.00",
        "collateral": "USDT",
        "timestamp": 1704153600000,
        "destinationAddress": "0xabcdef1234567890abcdef1234567890abcdef12",
        "txHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
      }
    ]
  },
  "request_id": "5ccf215d37e3ae6d"
}

Empty Result

{
  "status": "ok",
  "response": {
    "balanceUpdates": []
  },
  "request_id": "5ccf215d37e3ae6f"
}

Balance Update Object

FieldTypeDescription
idintegerUnique transaction ID
subAccountIdintegerSubaccount ID associated with the transaction
actionstringAction type: "DEPOSIT" or "WITHDRAWAL"
statusintegerTransaction status (1 = success)
amountstringAmount changed (positive for deposits, negative for withdrawals)
collateralstringCollateral symbol (e.g., "USDT", "WETH")
timestampintegerUnix timestamp in milliseconds when the transaction was created
destinationAddressstringDestination address for withdrawals (optional, only for withdrawals)
txHashstringOn-chain transaction hash (optional)
toSubAccountIdintegerTarget subaccount ID for internal transfers (optional)

Error Response

{
  "status": "error",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "limit cannot exceed 1000"
  },
  "timestamp": "2025-01-01T00:00:00Z",
  "request_id": "5ccf215d37e3ae6d"
}

Usage Examples

Get All Balance Updates

{
  "params": {
    "action": "getBalanceUpdates",
    "subAccountId": "1867542890123456789"
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704153600000,
  "signature": { "v": 28, "r": "0x...", "s": "0x..." }
}

Get Deposits Only

{
  "params": {
    "action": "getBalanceUpdates",
    "subAccountId": "1867542890123456789",
    "actionFilter": "DEPOSIT"
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704153600000,
  "signature": { "v": 28, "r": "0x...", "s": "0x..." }
}

Get Withdrawals Only

{
  "params": {
    "action": "getBalanceUpdates",
    "subAccountId": "1867542890123456789",
    "actionFilter": "WITHDRAWAL"
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704153600000,
  "signature": { "v": 28, "r": "0x...", "s": "0x..." }
}

Paginated Request

{
  "params": {
    "action": "getBalanceUpdates",
    "subAccountId": "1867542890123456789",
    "limit": 100,
    "offset": 100
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704153600000,
  "signature": { "v": 28, "r": "0x...", "s": "0x..." }
}

Implementation Notes

  • Returns deposit and withdrawal transactions only (excludes funding payments)
  • Results are ordered by timestamp (most recent first)
  • Default limit is 50 results per request, maximum is 1000
  • Use pagination with limit and offset for large result sets
  • For funding payment history, use Get Funding Payments
  • Authentication requires signature by account owner

Signing

All trading methods are signed using EIP-712. Each successful trading request will contain:

  • A piece of structured data that includes the sender address
  • A signature of the hash of that structured data, signed by the sender

For detailed information on EIP-712 signing, see EIP-712 Signing.

Nonce Management

The nonce system prevents replay attacks and ensures order uniqueness:

  • Use current timestamp in milliseconds as nonce
  • Each nonce must be greater than the previous one
  • Recommended: Use Date.now() or equivalent
  • If nonce conflicts occur, increment by 1 and retry

Error Handling

Common error scenarios:

ErrorDescription
Invalid signatureEIP-712 signature validation failed
Invalid market symbolMarket symbol not recognized
Nonce already usedNonce must be greater than previous value
Rate limit exceededToo many requests in time window
Request expiredexpiresAfter timestamp has passed
Error CodeMessageDescription
VALIDATION_ERRORsubAccountId is requiredNo subaccount ID was provided
VALIDATION_ERRORlimit cannot exceed 1000Limit parameter exceeds maximum
VALIDATION_ERRORlimit must be non-negativeNegative limit value provided
VALIDATION_ERRORoffset must be non-negativeNegative offset value provided
VALIDATION_ERRORactionFilter must be 'DEPOSIT', 'WITHDRAWAL', or comma-separated combinationInvalid action filter value
INTERNAL_ERRORFailed to retrieve balance updatesServer error retrieving data

Related Endpoints