> ## 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.

# User Funding Flows

> Query your historical funding settlements per position, with the funding index before and after each settlement for exact reconciliation.

The `userFundingFlows` query returns your account's funding settlement records, **one row per position per settlement**. Each row carries the funding index before and after the settlement, the amount paid or received, and the resulting balance.

It shares its request parameters, pagination contract, and value conventions with [`userFills`](/info/user-fills) and [`orderHistory`](/info/order-history).

## Request

```json theme={null}
{"type": "userFundingFlows", "accountId": "5"}
```

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

<ParamField body="accountId" type="string" required>
  Your account ID. Must be greater than zero. A numeric value is also accepted.
</ParamField>

<ParamField body="contractId" type="int">
  Restrict results to one contract. Use `0` or omit for all contracts.
</ParamField>

<ParamField body="startTime" type="int64">
  Inclusive start of the time window, in Unix milliseconds. `0` or omitted means unbounded.
</ParamField>

<ParamField body="endTime" type="int64">
  Inclusive end of the time window, in Unix milliseconds. `0` or omitted means unbounded. A `startTime` later than `endTime` returns `400 BAD_REQUEST`.
</ParamField>

<ParamField body="limit" type="int">
  Maximum rows in this page. Defaults to **1000**, which is also the maximum; a larger value returns `400 BAD_REQUEST`.
</ParamField>

## Response

```json theme={null}
{
  "type": "userFundingFlows",
  "accountId": "5",
  "contractIdFilter": 0,
  "fundingFlows": [
    {
      "timeMs": 1700000000000,
      "height": 42,
      "seq": 3,
      "contractId": 7,
      "marketDeployerId": 5,
      "settleCoinId": 2,
      "positionSize": "3000",
      "positionSide": "L",
      "fundingIndexBefore": "104900000",
      "fundingIndexAfter": "104950000",
      "amount": "-150",
      "balanceAfter": "987654",
      "fundingRate": "12500",
      "oraclePrice": "50000"
    }
  ],
  "count": 1,
  "truncated": false
}
```

### Envelope fields

<ResponseField name="contractIdFilter" type="int">
  Echoes the `contractId` filter that was applied. `0` means no filter.
</ResponseField>

<ResponseField name="count" type="int">
  Number of rows in this page. When `count` equals your `limit`, another page may be available.
</ResponseField>

<ResponseField name="truncated" type="boolean">
  `true` when the page was cut short at a row boundary because the response reached its byte ceiling.
</ResponseField>

### Funding flow object fields

<ResponseField name="timeMs" type="number">
  Settlement time in Unix milliseconds. This is the field you page on.
</ResponseField>

<ResponseField name="height" type="number">
  Block height at which the settlement was recorded.
</ResponseField>

<ResponseField name="seq" type="number">
  Sequence number within the block.
</ResponseField>

<ResponseField name="contractId" type="number">
  Contract the position belongs to.
</ResponseField>

<ResponseField name="marketDeployerId" type="number">
  Market deployer the contract belongs to.
</ResponseField>

<ResponseField name="settleCoinId" type="number">
  Coin the funding was settled in.
</ResponseField>

<ResponseField name="positionSize" type="string">
  Size of the position at settlement (raw integer string).
</ResponseField>

<ResponseField name="positionSide" type="string">
  `"OneWay"`, `"L"` (long), or `"S"` (short).
</ResponseField>

<ResponseField name="fundingIndexBefore" type="string">
  Cumulative funding index before this settlement.
</ResponseField>

<ResponseField name="fundingIndexAfter" type="string">
  Cumulative funding index after this settlement.
</ResponseField>

<ResponseField name="amount" type="string">
  Funding settled, signed — **negative means you paid**, positive means you received.
</ResponseField>

<ResponseField name="balanceAfter" type="string">
  Balance after the settlement was applied.
</ResponseField>

<ResponseField name="fundingRate" type="string">
  Funding rate of the most recent interval covered by this row.
</ResponseField>

<ResponseField name="oraclePrice" type="string">
  Mark price used for the most recent interval covered by this row, where `ΔIndex = rate × price`.
</ResponseField>

<Warning>
  `fundingRate` and `oraclePrice` describe only the **most recent** interval. When a settlement spans several intervals, `amount` is their cumulative total and multiplying the rate by the price will not reproduce it. For exact reconciliation, use the difference between `fundingIndexBefore` and `fundingIndexAfter` — that is the same source `amount` is derived from.
</Warning>

## Pagination

Rows come back in ascending `timeMs` order, at most `limit` per page. Pass the last row's `timeMs` as the next request's `startTime` and deduplicate the inclusive boundary row. A page with `count` below `limit` is the last one. See [`userFills`](/info/user-fills) for the full walkthrough.
