LOC lifecycle
Discover letters of credit and prepare the workflows that create, extend, modify, convert, redeem, or cancel them.
A letter of credit is created by one account and drawn down by another, and it leaves contract storage the moment it is fully redeemed or cancelled. There is no stored status field: what a LOC can do next follows from its remaining amounts and its expiration timestamp. Each change of state is a workflow — built from a params object, validated before a wallet is involved, then executed as however many transactions the change really takes, so an approve-deposit-create sequence arrives as one object instead of a script you assemble.
Each workflow builder is a method on sdk.loc:
| Change | Who | Workflow |
|---|---|---|
| Create a static LOC | Any account | buildCreateStaticWorkflow |
| Create a dynamic LOC | Any account | buildCreateDynamicWorkflow |
| Extend | The creator | buildExtendWorkflow |
| Adjust collateral | The creator, for a dynamic LOC | buildModifyCollateralWorkflow |
| Redeem | The beneficiary, or an account it authorized | buildRedeemWorkflow |
| Convert collateral | Any account, once a dynamic LOC is unhealthy | buildConvertWorkflow |
| Cancel | Before expiration, the same as redeem; after it, any account | buildCancelWorkflow |
Extending and adjusting apply only while the LOC is live. Redemption can be partial and repeated; redeeming in full or cancelling removes the LOC. Converting leaves it open, now backed by the credited token.
| To read | Start from |
|---|---|
| Origin, lifecycle, and resolution | sdk.loc.getLetterOfCredit, sdk.loc.getLetterOfCredits |
| Transaction evidence | sdk.loc.getLetterOfCreditHistory |
| Current contract state | sdk.loc.getOutstandingLetterOfCredit, sdk.loc.getOutstandingLetterOfCredits |
Every operation above is documented on LOCModule. Each
also exists as a standalone function that takes the SDK context explicitly — same behaviour, listed
with this group in the sidebar — but reach for those only when you are composing without an
AnvilSDK instance.
LOCModule also owns the collateral-pairing reads
(getCollateralFactor,
getRequiredCollateralForDynamic, and their siblings) documented in
Vaults and collateral.
What conversion, redemption, and expiration do and do not do is in Redeem, convert, and delegate; collateral factors are in Collateral and risk.
Creating a static LOC, end to end:
const params: CreateStaticLOCParams = { beneficiary: '0x1111111111111111111111111111111111111111', // 1,000 USDC (6 decimals): face value and, for a static LOC, // collateral. tokenAmount: { tokenAddress: testnetProfile.contracts.USDC.address, amount: 1_000_000_000n, }, expirationTimestampSeconds: dateToEthereumTimestamp( await sdk.loc.getMaxDate() ),};
// Validate before touching the wallet; an empty array means valid// params.const issues = await sdk.loc.validateCreateStatic(params);if (issues.length > 0) throw new Error(JSON.stringify(issues));
// Deposit, approve, and allowance steps appear only if the vault is// short.const workflow = await sdk.loc.buildCreateStaticWorkflow(params);await workflow.execute(operations => { console.log(operations.map(operation => operation.status));});Primary APIs
Functions
assessLetterOfCreditRisk— Assesses V3 risk from explicitly sourced SDK price and current pair-configuration reads.deriveLetterOfCreditDirectCapabilities— Describes V3 lifecycle and direct-caller gates for the msg.sender the LOC contract will actually see.deriveLetterOfCreditStatus— Derives the current display summary without fetching prices or inspecting a wallet.
Interfaces
LetterOfCredit— Canonical indexed LOC, including terminal entities.LOCModule— LOC (letter of credit) operations: queries, workflow builders, and pre-flight validation.OutstandingLetterOfCredit— Contract-resident LOC state.
Type aliases
CancelLOCsParams— Parameters for cancelling several LOCs atomically through Multicall.ConvertLOCParams— Parameters for permissionlessly converting an unexpired, unhealthy dynamic LOC into its credited token.CreateDynamicLOCParams— Parameters for creating a dynamic LOC — collateral in one token backing a face value in another, priced by the Pyth oracle and subject…CreateStaticLOCParams— Parameters for creating a static LOC — one collateralized 1:1 in the same token it credits, so it needs no oracle price and can never…RedeemLOCsParams— Parameters for redeeming one or more LOCs as the beneficiary, or with the beneficiary’s signed authorization.
Supporting types and functions in this group are not listed here; each has its own page, listed with the group in the sidebar.