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

# CDP Market Balances

> Balance, debt ceiling and flows in USD for one token in one collateralized debt position (CDP) market, split by balance type (deposit for posted collateral, borrow for minted debt) and subtype. Each series is one market token balance, keyed by protocol, product, chain, market, token, balance type and balance subtype. Sky MCD vaults so far. Many series per market, so name the balances you need.

One row per CDP market balance, the finest grain of the CDP data, keyed by protocol, product, chain, market, token, balance type and balance subtype: the market and token, the parent protocol and product, chain and the mapped protocol, project and network records. The id is the series key of the cdp-market-balances timeseries model.

| | |
| - | - |
| Access | Lending-protocols-dataset |
| Tabular model | `cdp-market-balances`: primary key `id` |
| Timeseries model | `cdp-market-balances`: intervals `1d`, series key `id` (CDP Market Balance ID), series must be named (up to 10 per call) |

## Endpoints

> [card] [List CDP Market Balances](https://docs.blockworks.com/api-reference/data-api/collateralized-debt-positions-cdps/tabular-cdp-market-balances.md)
>
> One page of rows with per-column filters, sorting and pagination.

> [card] [Batch Get CDP Market Balance timeseries](https://docs.blockworks.com/api-reference/data-api/collateralized-debt-positions-cdps/timeseries-cdp-market-balances.md)
>
> Up to 10 series in one request, named by CDP Market Balance ID in `series`.

> [card] [Get CDP Market Balance timeseries](https://docs.blockworks.com/api-reference/data-api/collateralized-debt-positions-cdps/timeseries-cdp-market-balances-by-id.md)
>
> One series over a time window, keyed by its CDP Market Balance ID.

## Metrics

7 metrics. Use the `Field` value in `selections`; every point starts with the timestamp and continues in this order.

| Field | Name | Type | Unit | Description |
| - | - | - | - | - |
| `balanceUSD` | Balance (USD) | float64 | | The balance in USD of the token for this market, balance type and subtype. |
| `balanceCapUSD` | Balance Cap (USD) | float64 | | The balance cap (debt ceiling) in USD; null where the market has none. |
| `balanceCapMaxUSD` | Maximum Balance Cap (USD) | float64 | | The maximum the balance cap can be raised to in USD; null where the market has none. |
| `balanceCapGapUSD` | Balance Cap Gap (USD) | float64 | | The remaining room under the balance cap in USD. |
| `grossInflowUSD` | Gross Inflow (USD) | float64 | | Gross inflow to the balance in USD. |
| `grossOutflowUSD` | Gross Outflow (USD) | float64 | | Gross outflow from the balance in USD. |
| `netFlowUSD` | Net Flow (USD) | float64 | | Net flow in USD, inflow minus outflow. |

## Columns

Use the `Field` value in `selections`, `sortBy`, and as the base of a filter parameter (`Field` plus one of its `Filters` suffixes).

| Field | Type | Filters | Sort | Description |
| - | - | - | - | - |
| `id` | string | `Eq`, `IsOneOf` | | The series key of the cdp-market-balances timeseries model, the parent slug, product slug, chain, market key, token key, balance type and balance subtype, joined with underscores. (primary key) |
| `name` | string | `Eq`, `IsOneOf`, `Contains` | default | The display name of the balance, the market name, token symbol and balance subtype (or type). |
| `slug` | string | `Eq`, `IsOneOf` | yes | The parent protocol's project slug, the slug used for the same protocol across the API. |
| `parentSlug` | string | `Eq`, `IsOneOf` | yes | The parent protocol's short name, for example sky. |
| `productSlug` | string | `Eq`, `IsOneOf` | | The product or version within the parent protocol (sky-mcd-vaults). |
| `chain` | string | `Eq`, `IsOneOf` | | The short name of the chain the market lives on (ethereum, bnb, solana). |
| `marketID` | string | `Eq`, `IsOneOf` | | The market or pool address; null when the protocol does not label markets. |
| `marketName` | string | `Eq`, `IsOneOf`, `Contains` | | The market display name (for Sky, the vault ilk such as ETH-A). |
| `marketType` | string | `Eq`, `IsOneOf` | | The market type where the protocol distinguishes one (for example vault, lp or lockstake); null otherwise. |
| `tokenAddress` | string | `Eq`, `IsOneOf` | | The token contract address (the mint address on Solana); null when unlabeled. |
| `tokenSymbol` | string | `Eq`, `IsOneOf`, `Contains` | yes | The token's ticker symbol. |
| `balanceType` | string | `Eq`, `IsOneOf` | | Whether the balance is a deposit (posted collateral) or a borrow (minted debt). |
| `balanceSubtype` | string | `Eq`, `IsOneOf` | | The finer balance classification (for example collateral or borrow); null for protocols that do not distinguish one. |
| `protocolSlug` | string | `Eq`, `IsOneOf` | | The slug of the protocol record mapped to the product; null when unmapped. |
| `protocolName` | string | `Eq`, `IsOneOf` | | The name of the protocol record mapped to the product; null when unmapped. |
| `projectID` | string | `Eq`, `IsOneOf` | | The identifier of the parent protocol's project record. |
| `networkID` | string | `Eq`, `IsOneOf` | | The chain's networkID in the blockchains model; null when unmapped. |

## Example

```bash curl theme={null}
curl "https://api.blockworks.com/query/timeseries/cdp-market-balances/1d/<id>?timeframe=7d&selections=balanceUSD,balanceCapUSD" \
  -H "X-Blockworks-API-Key: $BLOCKWORKS_API_KEY"
```

See [Get CDP Market Balance timeseries](https://docs.blockworks.com/api-reference/data-api/collateralized-debt-positions-cdps/timeseries-cdp-market-balances-by-id.md) for the response and the errors.


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