Skip to content

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:

ChangeWhoWorkflow
Create a static LOCAny accountbuildCreateStaticWorkflow
Create a dynamic LOCAny accountbuildCreateDynamicWorkflow
ExtendThe creatorbuildExtendWorkflow
Adjust collateralThe creator, for a dynamic LOCbuildModifyCollateralWorkflow
RedeemThe beneficiary, or an account it authorizedbuildRedeemWorkflow
Convert collateralAny account, once a dynamic LOC is unhealthybuildConvertWorkflow
CancelBefore expiration, the same as redeem; after it, any accountbuildCancelWorkflow

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 readStart from
Origin, lifecycle, and resolutionsdk.loc.getLetterOfCredit, sdk.loc.getLetterOfCredits
Transaction evidencesdk.loc.getLetterOfCreditHistory
Current contract statesdk.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

Interfaces

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.