Skip to main content
GET
amount, currentAmount, deliverableAmount and every amount in changes are integer strings in the collateral token’s base units, exactly as the adapter emitted or answered them. Divide by ten to the power of the token’s decimals before you put a figure in a register entry. The decimals are decimals() on the token, or collateralDecimals on Get Market for an instance that holds the market.
index.historyTruncatedBeforeBlock is reported once, on the response to the request that ran the market’s first scan. Every later response reads null, and index.complete can read true, although the locks created before that block stay missing. Record the value the first time you see it. See Reading the index.
Returns every pledge the market’s collateral adapter has recorded against the collateral token, oldest first. Each record carries the holder, the pledgee, the amount, the transaction that created the lock, and how the pledge ended if it has. The records are rebuilt from the adapter’s own events, so the response describes the chain rather than a Trusset ledger. deliverableAmount is the one figure read live from the adapter on each call. Reading this endpoint advances the scan, which is why a first call on a market with long history can return a partial list. index says how far the scan has reached. This endpoint takes the market’s contract address, not its market ID.

Who can read a market

The address is first checked against the v2 lending factory this instance deploys to. Any other address is refused with MARKET_NOT_V2, before the query is validated and before access is considered. Access is then decided per market, not per key. A market opens to an instance that holds an active record of it. The issuer instance that deployed it holds one, and so does the lender of record’s instance once its adoption is confirmed. A market also opens to an instance whose verified wallet is nominated on it. A market open to any lender of record, while it is still seeking one, also opens to an account Trusset approved to act as a lender of record. That instance needs a verified wallet. Every other caller is refused.

Path Parameters

string
required
The market contract address, as 40 hex characters with a 0x prefix. Send it lowercased or correctly checksummed: a mixed-case address whose checksum fails is refused with MARKET_NOT_V2.

Query Parameters

integer
default:"0"
Records to skip. Minimum 0.
integer
default:"50"
Records to return. Between 1 and 200.
string
default:"true"
Accepts true or false. Set it to false to leave out pledges with an endedAt. Any other value is a validation error. total follows the same filter.
includeEnded=false still returns a pledge whose whole amount was withdrawn or split away, because the adapter emits no ending for that. Such a pledge reads currentAmount: "0", active: false and endedAt: null. Filter on active for the pledges that stand.

Response Fields

object

Change kinds

A split is bookkeeping inside the adapter, used to isolate collateral going to auction from the rest of the loan. Both sides carry the same holder and the same pledgee. A FREEZE_SHORTFALL means another agent on the token had already unfrozen part of the market-frozen balance before the market released or seized it. amount is the difference between requested and unfrozen. The holder held that part unencumbered before the market let go of it, which is worth knowing when the register entry is reconciled. The change does not reduce currentAmount.

How a pledge ends

endedAt.kind is RELEASED when the adapter returned what was left to the holder: the loan closed, or a liquidation sent the remainder home. A liquidation that seizes part of the collateral and returns the rest in the same transaction shows an ENFORCED change followed by a RELEASED ending. The restriction is gone and the register entry can come off. It is ENFORCED when a seizure took the last of the collateral. endedAt.to is where it went. A partial seizure without a release is not an ending: it lands in changes and the pledge keeps standing for the remainder. In a CUSTODY market a return the token refuses is escrowed in the adapter for the holder to claim later. The pledge still reads RELEASED.

Tie a pledge to a loan

ref is derived from the market, the loan ID and a counter, and no endpoint maps it back to a loan. Join on lockedAt.txHash against List Transactions, which records the same hash for the loan that created the lock. List Transactions takes the market ID, so the join is open only to an instance that holds the market’s record. holder is the borrower.

Reading the index

The scan reads at most 200,000 blocks per request, in chunks of 10,000, and stops three blocks behind the head. A market with long history takes several calls to catch up. The scan is throttled to once a minute per market. A call inside that minute returns the stored records with synced: false and reason of THROTTLED, which is a normal answer rather than a failure. Records already in the index are returned in all six cases. The first scan starts at the market’s deployment block when a platform record of the deployment transaction exists. Without one it starts 200,000 blocks back from the head, and that one response carries historyTruncatedBeforeBlock. Nothing stores the value, so the next response reads null again.

What complete: false actually means

complete is synced, and no truncated history reported on this response, and no unparsed logs. The last of those three is the one to read carefully. The index models seven adapter events: Locked, Increased, Decreased, Released, Enforced, RefSplit and FreezeShortfall. The custody adapter also emits events that are not about a pledge: CollateralEscrowed and EscrowedCollateralClaimed, when a return to the borrower was blocked on compliance and held instead. Any of those in the scanned window is counted in unparsedLogsThisScan and turns complete to false. So read the parts rather than the flag alone:
  • historyTruncatedBeforeBlock is the one that means pledges are genuinely missing, and they stay missing. It appears on one response only.
  • scannedToBlock well behind the chain head means the scan has not caught up. Call again.
  • unparsedLogsThisScan on its own is informational. The pledges returned for the blocks scanned are complete.
The count covers only the blocks this request scanned. A false caused by unparsed logs clears on the next scan whose window holds none of them, and it says nothing about the pledges already indexed.

Error Codes

VALIDATION_ERROR, MARKET_NOT_V2 and MARKET_VERIFICATION_UNAVAILABLE are answered by the platform’s shared error handler. Their body has no data member, carries a top-level statusCode, and its metadata.requestId does not match the X-Request-Id header. A validation failure reads Input validation failed, with error.details listing each offending field. A 403 or 412 is a statement about this instance’s access to this market. A 503 is a statement about a read that failed, and says nothing about the market or the caller.