Get Midnight position performance
Performance-only lookup for a single position by (market-id, user-address).
Returns performance analytics inside a data envelope. The position detail endpoint omits these fields to keep state and performance concerns separate. When the position is closed or has never existed for a known market, this endpoint returns type: null and null analytics.
Enterprise API access
For enterprise access, use https://private.api.morpho.org as the base URL and send your API key in the x-api-key header. Request an API key.
Path Parameters
market-id*string
Midnight market id.
user-address*string
User address for the requested position. Lowercase input is checksummed.
Response Body
application/json
application/json
const baseUrl = "https://api.morpho.org";const marketId = "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738";const userAddress = "0xd4F43105098845fFE89B16E7A3DCdd0A31898118";const url = new URL(`${baseUrl}/v0/midnight/markets/${marketId}/users/${userAddress}/position/performance`);const response = await fetch(url, { headers: { accept: "application/json", },});if (!response.ok) throw new Error(await response.text());const body = await response.json();{
"data": {
"chain_id": 8453,
"market_id": "0xcc9418ea594c6e658650aedd205ce4544b266b69493f56fd2adc65c14bd06738",
"user_address": "0xd4F43105098845fFE89B16E7A3DCdd0A31898118",
"type": "borrow",
"accounting_method": "average_cost",
"cost_basis": "1046483736229728000000000000000000",
"effective_rate_wad": "327402597840809",
"last_indexed_block": "48408699"
}
}{
"error": {
"code": "MARKET_NOT_FOUND",
"message": "Market 0x0000000000000000000000000000000000000000000000000000000000000000 not found",
"details": null,
"request_id": "f0e1d2c3-b4a5-4968-8728-1c0d1e2f3a4b"
}
}