MidnightPositions

List positions

Cursor-paginated list of a user's current Midnight positions.

Position type. type is lend for positions with credit, borrow for positions with debt, or collateral_only for positions with no credit or debt but remaining collateral. Closed positions with no credit, no debt, and no remaining collateral are excluded.

Performance fields. cost_basis uses the average cost method and is returned as a WAD-scaled bigint string in loan-token units. effective_rate_wad is a WAD-scaled annualized effective rate. Either field can be null when there is not enough attributable history.

Filters. chain_ids is required when loan_assets is provided. Range filters exist on credit, debt, cost_basis, and effective_rate_wad. active_only=true excludes matured markets. listed=true keeps only positions on listed markets; listed=false keeps only positions on unlisted markets.

Pagination. Response envelope: { cursor, data }.

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

GET
/v0/midnight/users/{user-address}/positions

Path Parameters

user-address*string

User address to list positions for. Lowercase input is checksummed.

Query Parameters

chain_ids?array<>

Filter by chain ids. Required when loan_assets is provided.

market_ids?array<string>

Filter by Midnight market ids.

types?array<>

Filter by position type.

loan_assets?array<string>

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

maturities?array<|>

Filter by exact maturity timestamps, in unix seconds.

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+$
credit_lte?string

Filter for credit less than or equal to this value.

Match^-?\d+$
pending_fee_gte?string

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

Match^-?\d+$
pending_fee_lte?string

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

Match^-?\d+$
debt_gte?string

Filter for debt greater than or equal to this value.

Match^-?\d+$
debt_lte?string

Filter for debt less than or equal to this value.

Match^-?\d+$
cost_basis_gte?string

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

Match^-?\d+$
cost_basis_lte?string

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

Match^-?\d+$
effective_rate_wad_gte?string

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

Match^-?\d+$
effective_rate_wad_lte?string

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

Match^-?\d+$
sort_by?string

Sort field for cursor pagination.

Default"maturity"
Value in"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
listed?string

Filter by market listing status. When true, returns only positions on listed markets; when false, only positions on unlisted markets. Omit to return both.

Value in"true" | "false"

Response Body

application/json

application/json

curl -X GET "https://api.morpho.org/v0/midnight/users/string/positions"
{
  "cursor": null,
  "data": [
    {
      "chain_id": 8453,
      "collaterals": [],
      "cost_basis": "950000000000000000000000000000000",
      "credit": "1000000000000000",
      "debt": "0",
      "effective_rate_wad": "52000000000000000",
      "last_loss_factor": "0",
      "loan_token": "0x4200000000000000000000000000000000000006",
      "loss_factor": "0",
      "market_id": "0xd92de5e7fbbde5a5e161787426982f7e1b01fb53a7060f95c021236d74447614",
      "maturity": 1781276400,
      "pending_fee": "0",
      "type": "lend",
      "user_address": "0x1111111111111111111111111111111111111111"
    }
  ]
}
{
  "error": {
    "code": "INVALID_CURSOR",
    "details": null,
    "message": "cursor sort/direction does not match request sort/direction",
    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"
  }
}