Docs

List market positions

Cursor-paginated list of current Midnight positions for a market.

:market-id is the stable Midnight market id and is globally unique across supported chains.

The response uses the same public position item shape as GET /v0/midnight/users/{user-address}/positions: { cursor, data }, with type, state fields, collateral balances, and performance analytics.

Filters. Range filters exist on created_at, credit, debt, cost_basis, and effective_rate_wad. active_only=true excludes matured markets. The path market id is always enforced.

Pagination. Pass back cursor verbatim on the next call. Positions are ordered newest-first by created_at by default.

Cache. public, max-age=2, stale-while-revalidate=1.

Path Parameters

market-id*string

Midnight market id.

Query Parameters

chain_ids?array<>

Filter by chain ids. Supported chains: Base (8453). Required when loan_assets is provided.

Itemsitems <= 100
types?array<>

Filter by position type.

Itemsitems <= 100
loan_assets?array<string>

Filter by loan token addresses. Combine with chain_ids; lowercase input is checksummed.

Itemsitems <= 100
maturities?array<|>

Filter by exact maturity timestamps, in unix seconds.

Itemsitems <= 100
active_only?string

When true, keep only positions whose market has not matured yet.

Value in"true" | "false"
maturity_gte?|

Filter for maturities greater than or equal to this unix timestamp.

maturity_lte?|

Filter for maturities less than or equal to this unix timestamp.

credit_gte?string

Filter for credit greater than or equal to this value.

Match^\d{1,78}$
credit_lte?string

Filter for credit less than or equal to this value.

Match^\d{1,78}$
pending_fee_gte?string

Filter for pending fee greater than or equal to this value.

Match^\d{1,78}$
pending_fee_lte?string

Filter for pending fee less than or equal to this value.

Match^\d{1,78}$
debt_gte?string

Filter for debt greater than or equal to this value.

Match^\d{1,78}$
debt_lte?string

Filter for debt less than or equal to this value.

Match^\d{1,78}$
cost_basis_gte?string

Filter for cost basis greater than or equal to this value.

Match^\d{1,78}$
cost_basis_lte?string

Filter for cost basis less than or equal to this value.

Match^\d{1,78}$
effective_rate_wad_gte?string

Filter for effective rate WAD greater than or equal to this value.

Match^-?\d{1,78}$
effective_rate_wad_lte?string

Filter for effective rate WAD less than or equal to this value.

Match^-?\d{1,78}$
created_at_gte?|

Filter for position created_at greater than or equal to this unix timestamp.

created_at_lte?|

Filter for position created_at less than or equal to this unix timestamp.

sort_by?string

Sort field for cursor pagination.

Default"created_at"
Value in"created_at" | "credit" | "debt" | "maturity" | "cost_basis" | "effective_rate_wad"
sort_direction?string

Sort direction for cursor pagination.

Default"desc"
Value in"asc" | "desc"
limit?integer

Maximum number of items to return.

Default100
Range1 <= value <= 100
cursor?string

Opaque cursor from a previous page response.

Length1 <= length <= 4096

Response Body

application/json

application/json

const baseUrl = "https://api.morpho.org";const marketId = "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738";const url = new URL(`${baseUrl}/v0/midnight/markets/${marketId}/positions`);url.searchParams.set("chain_ids", "8453");const response = await fetch(url, {  headers: {    accept: "application/json",  },});if (!response.ok) throw new Error(await response.text());const body = await response.json();
{
  "cursor": "eyJzIjoiY3JlYXRlZEF0IiwiZCI6ImRlc2MiLCJ2IjoiMTc4MzU0NjA5MyIsInZOdWxsIjpmYWxzZSwiaSI6eyJjaGFpbklkIjo4NDUzLCJtYXJrZXRJZCI6IjB4Y2M5NDE4ZWE1OTRjNmU2NTg2NTBhZWRkMjA1Y2U0NTQ0YjI2NmI2OTQ5M2Y1NmZkMmFkYzY1YzE0YmQwNjczOCIsInVzZXJBZGRyZXNzIjoiMHg1MzU2OTBDQjEzMzAyMzJkZDRmMmFjNUI3MjQwNDA3NTFiZEY0QzkxIn0sImYiOiJCcVJWSnR0WEdkeFY1UG1kMlp1VFFFIn0",
  "data": [
    {
      "chain_id": 8453,
      "market_id": "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738",
      "user_address": "0xd4F43105098845fFE89B16E7A3DCdd0A31898118",
      "loan_token": "0x4200000000000000000000000000000000000006",
      "maturity": 1784300400,
      "type": "borrow",
      "credit": "0",
      "pending_fee": "0",
      "last_loss_factor": "0",
      "loss_factor": "0",
      "debt": "1046492040981691",
      "collaterals": [
        {
          "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "amount": "4000000"
        }
      ],
      "created_at": 1783606647,
      "cost_basis": "1046483736229728000000000000000000",
      "effective_rate_wad": "327402597840809"
    },
    {
      "chain_id": 8453,
      "market_id": "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738",
      "user_address": "0x958eB498a4172EA513c79b09E7f064070C5b1917",
      "loan_token": "0x4200000000000000000000000000000000000006",
      "maturity": 1784300400,
      "created_at": 1783584485,
      "type": "lend",
      "credit": "1481439992020013",
      "pending_fee": "0",
      "last_loss_factor": "0",
      "loss_factor": "0",
      "debt": "0",
      "cost_basis": "1480000000000000000000000000000000",
      "effective_rate_wad": "41189691462004744",
      "collaterals": []
    },
    {
      "chain_id": 8453,
      "market_id": "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738",
      "user_address": "0x535690CB1330232dd4f2ac5B724040751bdF4C91",
      "loan_token": "0x4200000000000000000000000000000000000006",
      "maturity": 1784300400,
      "created_at": 1783546093,
      "type": "borrow",
      "credit": "0",
      "pending_fee": "0",
      "last_loss_factor": "0",
      "loss_factor": "0",
      "debt": "80001344022580",
      "cost_basis": "80000000000000000000000000000000",
      "effective_rate_wad": "763977389592662",
      "collaterals": [
        {
          "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "amount": "1000000"
        }
      ]
    }
  ]
}
{
  "error": {
    "code": "INVALID_CURSOR",
    "message": "cursor sort/direction does not match request sort/direction",
    "details": null,
    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"
  }
}