Docs

List Midnight offer groups for a user

Cursor-paginated list of a user's offer groups with nested offers. The statuses filter accepts one or more lifecycle states with OR semantics. The deprecated singular status parameter is a single-value alias; requests containing both are rejected. Omitting both defaults to active for backward compatibility.


GET
/v0/midnight/users/{user-address}/offer-groups

Lifecycle is derived from every latest offer revision before market, asset, maturity, type, callback, or listing filters are applied. cancelled has highest priority and requires an explicit SetConsumed(type(uint128).max) event; a Take reaching the same numeric value remains filled. Otherwise, a group is filled when every latest leg has no remaining capacity. It is active when at least one remaining leg has started and is at or before both its expiry and non-zero maturity. It is scheduled when no leg is active but at least one remaining leg starts in the future without having expired or matured. All remaining groups are expired. Active takes remain valid at exact expiry or maturity, matching the onchain inclusive boundary.

Nested offers are lifecycle-targeted for list results: active returns live remaining-capacity legs, scheduled returns future remaining-capacity legs, filled and cancelled return all latest legs, and expired returns terminal expired or matured legs. Active and scheduled group expiry is the maximum not-yet-ended latest-offer horizon; terminal statuses use the complete latest set. Requesting all five statuses returns every indexed group exactly once.

Callbacks. A group has callback.type=blue_buy only when every latest offer considered for the lifecycle has the same callback address and data, contains canonical Blue market parameters with the matching loan token, and the earliest indexed registration from the official factory names the maker as owner at or before the offer's creation block. Registration transaction or log order within the same block is intentionally ignored. The callback is null when any condition fails. Verified callbacks include their address, decoded Blue market parameters, and derived Blue market id.

Types. Group type is derived from the shared buy and reduce_only values across all offers considered for the requested lifecycle. buy and sell mean reduce_only=false; buy_reduce_only and sell_reduce_only mean reduce_only=true. For the portfolio, buy and sell_reduce_only represent lend orders and secondary exits, while sell and buy_reduce_only represent borrow orders and secondary exits. Inconsistent groups return type: null and do not match the types filter. This describes offer intent, not the maker's current position.

Filters. market_ids filters the group page to groups containing at least one offer in the requested lifecycle and any requested market, but does not narrow nested sibling offers. chain_ids and groups filter the group page and nested offers. loan_assets, collateral_assets, exact maturities, and the inclusive unix-second bounds maturity_gte and maturity_lte filter both the group page and returned offers in the requested lifecycle for every status, and combine with other filters using AND semantics. Offers with no maturity deadline have maturity 0: they match any maturity_lte and are excluded by maturity_gte of 1 or more. types accepts comma-separated offer-group types with OR semantics and combines with other filters using AND semantics without narrowing nested offers. callback_type=blue_buy keeps only groups with verified Blue callback metadata. listed=true requires every lifecycle-matching offer in a group to be on a listed market; listed=false requires at least one lifecycle-matching unlisted offer. Address filters match across all chains unless chain_ids also narrows the query; lowercase addresses are checksummed. Group expiry is not narrowed by offer filters; active results use the active-eligible latest offer set, while expired results use the complete latest offer set. created_at_gte and created_at_lte filter by the first matching offer created in each group. market_ids, loan_assets, collateral_assets, maturities, groups, and types are capped at 20 values. Each offer includes both market_id and the immutable market config used to derive it, because uncreated markets cannot be decoded from market_id alone.

Ratifier data. Each nested offer includes the exact per-offer ratifier_data bytes originally submitted, plus parsed_ratifier_data, a structured view discriminated by ratifier_type. The type is identified by matching ratifier against the chain's known Midnight ratifier deployments: rate_v1 exposes rate_per_second_wad and allowed_taker, price_v1 exposes allowed_taker (the offer-level tick is the ratified price), and ecrecover and setter expose only their type. A zero allowed_taker means any taker may take the offer. An unrecognized ratifier address returns unknown; a recognized address whose ratifier_data cannot be decoded returns invalid with expected_ratifier_type.

Pagination. Response follows the list envelope: { cursor, data }. Pagination is over groups; nested offers are not split across pages. Sort groups with sort_by=id|created_at and sort_direction=asc|desc.

Path Parameters

user-address*string

User address whose offer groups should be listed.

Query Parameters

status?string
Deprecated

Deprecated single-value alias for statuses. Omit both status and statuses to return active groups.

Value in

  • "scheduled"
  • "active"
  • "filled"
  • "expired"
  • "cancelled"
statuses?array<>

Filter by one or more offer-group lifecycle states using OR semantics. Combined with other filters using AND semantics. Omit both status and statuses to return active groups.

Items1 <= items <= 5
callback_type?"blue_buy"

Filter by verified group callback type. blue_buy requires canonical Blue market params and an official factory registration owned by the maker at or before offer creation.

Value in

  • "blue_buy"
types?array<>

Filter by group offer intent. Multiple values use OR semantics. buy and sell mean reduce_only=false; buy_reduce_only and sell_reduce_only mean reduce_only=true. Combined with other filters using AND semantics.

Itemsitems <= 20
chain_ids?array<>

Filter by chain ids. Supported chains: Ethereum (1), Base (8453), Arc (5042), and Robinhood Chain (4663).

Itemsitems <= 100
market_ids?array<string>

Filter groups to those containing offers in the requested lifecycle and Midnight markets. Nested offers are not narrowed by this filter.

Itemsitems <= 20
market_family_ids?array<string>

Filter groups to those containing offers in the requested lifecycle and Midnight market families. Combined with market_ids using AND semantics. Nested offers are not narrowed by this filter.

Itemsitems <= 20
loan_assets?array<string>

Filter nested offers in the requested lifecycle by loan token addresses. Combined with market_ids, collateral_assets, maturities, and groups using AND semantics.

Itemsitems <= 20
collateral_assets?array<string>

Filter nested offers in the requested lifecycle by configured collateral token addresses. Combined with market_ids, loan_assets, maturities, and groups using AND semantics; lowercase input is checksummed.

Itemsitems <= 20
maturities?array<|>

Filter nested offers in the requested lifecycle by exact market maturity timestamps, in unix seconds. Combined with market_ids, loan_assets, collateral_assets, and groups using AND semantics.

Itemsitems <= 20
maturity_gte?|

Filter nested offers in the requested lifecycle by market maturity greater than or equal to this unix timestamp. Combined with market_ids, loan_assets, collateral_assets, maturities, and groups using AND semantics. Offers with no maturity deadline have maturity 0, so they match any maturity_lte and are excluded by maturity_gte of 1 or more.

maturity_lte?|

Filter nested offers in the requested lifecycle by market maturity less than or equal to this unix timestamp. Combined with market_ids, loan_assets, collateral_assets, maturities, and groups using AND semantics. Offers with no maturity deadline have maturity 0, so they match any maturity_lte and are excluded by maturity_gte of 1 or more.

groups?array<string>

Filter by offer group ids. Combined with market_ids, loan_assets, collateral_assets, and maturities using AND semantics.

Itemsitems <= 20
created_at_gte?|

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

created_at_lte?|

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

listed?string

Filter by market listing status. When true, returns only groups where every offer in the requested lifecycle is on a listed market; when false, groups with at least one lifecycle-matching offer on an unlisted market. Omit to return both.

Value in

  • "true"
  • "false"
sort_by?string

Sort field for group cursor pagination.

Default"id"

Value in

  • "id"
  • "created_at"
sort_direction?string

Sort direction for group cursor pagination.

Default"asc"

Value in

  • "asc"
  • "desc"
limit?integer

Maximum number of groups to return.

Range1 <= value <= 100
Default100
cursor?string

Opaque cursor from a previous page response.

Length1 <= length <= 4096

Response Body

application/json

application/json

application/json

curl -X GET "https://example.com/v0/midnight/users/0x958eB498a4172EA513c79b09E7f064070C5b1917/offer-groups"

{  "cursor": "eyJzb3J0QnkiOiJpZCIsInNvcnREaXJlY3Rpb24iOiJhc2MiLCJjaGFpbklkIjo4NDUzLCJncm91cCI6IjB4MGJhYjUxZmFiNjQxNTdiYzEwMTFjZTY1YjliZjliMmIxMWYyMDJiOGE3YWI3NmI0MDhjZjQwYjhhZGYwNjlkMyJ9",  "data": [    {      "id": "0x0bab51fab64157bc1011ce65b9bf9b2b11f202b8a7ab76b408cf40b8adf069d3",      "chain_id": 8453,      "status": "active",      "type": "buy",      "created_at": 1783584485,      "expiry": 1784300399,      "max_units": "0",      "max_assets": "80000000000000",      "consumed": "0",      "callback": null,      "offers": [        {          "market_id": "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738",          "market": {            "loan_token": "0x4200000000000000000000000000000000000006",            "maturity": 1784300400,            "rcf_threshold": "0",            "enter_gate": "0x0000000000000000000000000000000000000000",            "liquidator_gate": "0x0000000000000000000000000000000000000000",            "collaterals": [              {                "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",                "lltv": "860000000000000000",                "liquidation_cursor": "300000000000000000",                "oracle": "0xD09048c8B568Dbf5f189302beA26c9edABFC4858"              }            ]          },          "created_at": 1783584485,          "buy": true,          "maker": "0x958eB498a4172EA513c79b09E7f064070C5b1917",          "max_units": "0",          "max_assets": "80000000000000",          "continuous_fee_cap": "115792089237316195423570985008687907853269984665640564039457584007913129639935",          "start": 1783584483,          "expiry": 1784300399,          "tick": 4408,          "callback": "0x0000000000000000000000000000000000000000",          "callback_data": "0x",          "receiver_if_maker_is_seller": "0x0000000000000000000000000000000000000000",          "ratifier": "0xd6e70365C8E8DDa9a4ca662C07bbE663b017755E",          "ratifier_data": "0x000000000000000000000000000000000000000000000000000000000000001b3f4a8c6d2e109b7f5c4d8a1e6b3f7092c5d4e8a7b1c6f3092d5e4a8b7c1f60392a7d5c9e4b1f8036d8c2a5e7f1049b3d6c8e2a5f7b1d4093c6e8a2f5b7d1049c8b2f6d4a1c9e7035f8b2d6a4c1e9073f5b8d2a6c4e1f9037b5d8a2c6e4f1093b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",          "parsed_ratifier_data": {            "ratifier_type": "ecrecover"          },          "reduce_only": false        }      ]    }  ]}

{  "error": {    "code": "VALIDATION_FAILED",    "message": "Validation failed",    "details": [      {        "code": "invalid_type",        "message": "Expected number, received string",        "path": [          "chain_ids",          0        ]      }    ],    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"  }}

{  "error": {    "code": "INTERNAL_ERROR",    "message": "Internal server error",    "details": null,    "request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"  }}