API ReferenceLOC lifecycleFunction
deriveLetterOfCreditStatus()
function deriveLetterOfCreditStatus(letterOfCredit, evaluatedAtTimestamp): LetterOfCreditStatus;Summarizes a LetterOfCredit as a single status label at a time you choose. It reads only the LOC you pass: no prices, no wallet, no network.
The label follows a fixed precedence, so one LOC can match several facts but shows only the first:
'insolvent' (a full conversion left a shortfall), then 'redeemed' or 'canceled', then
'expired', then 'converted' (fully converted, still open), then 'open'. Read lifecycle on
the LOC for the full record.
Parameters
| Parameter | Type | Description |
|---|---|---|
letterOfCredit | LetterOfCredit | The LOC to summarize, as returned by LOCModule.getLetterOfCredit or LOCModule.getLetterOfCredits. |
letterOfCredit.creationContext | LetterOfCreditCreationContext | For a Dynamic LOC, the pair’s risk terms at creation (collateral factors, liquidator incentive, redeem buffer); kind: 'notApplicable' for a Static LOC. They are history, not the terms that decide current health. |
letterOfCredit.indexedAt | SubgraphIndexPosition | The subgraph block this record was read at, which can trail the latest block. |
letterOfCredit.lifecycle | LetterOfCreditLifecycle | What has happened since creation: redemption (count and total redeemed), liquidation (count, collateral converted, liquidator fees, and any full conversion with its shortfall), and resolution (how and when the LOC was redeemed or canceled, or null while open). |
letterOfCredit.origin | LetterOfCreditOrigin | Facts fixed at creation: creator, beneficiary, creationKind ('static' or 'dynamic'), the Collateral Vault, originalCollateral, credited (the amount promised), initialExpirationTimestamp, the creation transaction (createdIn), and tag. |
letterOfCredit.outstanding | | LetterOfCreditHistoricalSnapshot & Pick<OutstandingLetterOfCredit, "beneficiary" | "creator" | "creationKind" | "reference"> | null | The LOC’s position at the indexed block (remainingCredited, expirationTimestamp, backing, and its parties), or null once it has been redeemed or canceled. For some of the oldest LOCs, backing.reservation can be null; LOCModule.getOutstandingLetterOfCredit always returns it. |
letterOfCredit.reference | LetterOfCreditReference | The LOC’s chain, LetterOfCredit contract address, and numeric id. Store all three to identify a LOC. |
evaluatedAtTimestamp | bigint | The time to evaluate at, in Unix seconds. A LOC whose expiration equals this time counts as expired. |
Returns
LetterOfCreditStatus
displayStatus (the label above), temporalCondition ('expired' or 'unexpired' for an open
LOC, null once it is redeemed or canceled), and evaluatedAtTimestamp (the time you passed).
Throws
No errors for inputs satisfying the declared SDK types; this pure derivation performs no I/O.
Example
const status = deriveLetterOfCreditStatus(letterOfCredit, BigInt(Math.floor(Date.now() / 1000)));// status.displayStatus is a label; inspect lifecycle for coexisting facts.