Skip to content

API ReferenceLOC lifecycleType Alias

RedeemLOCsParams

type RedeemLOCsParams = object;

Parameters for redeeming one or more LOCs as the beneficiary, or with the beneficiary’s signed authorization. One entry is a direct redeemLOC call; several same-token (static or already converted) LOCs are batched atomically through the Multicall contract. Dynamic LOCs must be redeemed one at a time because Multicall cannot supply the self-liquidation assets. Build with sdk.loc.buildRedeemWorkflow.

Examples

// The connected wallet is the LOC's beneficiary.
const loc = await sdk.loc.getOutstandingLetterOfCredit({ id: 42n });
if (!loc) throw new Error('LOC 42 is no longer outstanding');
// One entry, full remaining face value, paid to the signer.
const params: RedeemLOCsParams = {
redemptions: [{ id: loc.reference.id, amount: loc.remainingCredited.amount }],
};
const issues = await sdk.loc.validateRedeem(params);
if (issues.length > 0) throw new Error(JSON.stringify(issues));
const workflow = await sdk.loc.buildRedeemWorkflow(params);
await workflow.execute();
const loc = await sdk.loc.getOutstandingLetterOfCredit({ id: 42n });
if (!loc) throw new Error('LOC 42 is no longer outstanding');
// Beneficiary's wallet: authorize a third party to redeem half to
// itself.
const destinationAddress = '0x2222222222222222222222222222222222222222';
const authWorkflow = await sdk.loc.buildRedeemAuthorizationWorkflow({
id: loc.reference.id,
redeemAmount: loc.remainingCredited.amount / 2n,
locCreditedAmount: loc.remainingCredited.amount,
destinationAddress,
});
console.log(authWorkflow.operations[0]?.authorization?.typedData);
const authorizationExecution = await authWorkflow.execute();
if (authorizationExecution.status !== 'executed') {
throw new Error(`authorization preflight ended as ${authorizationExecution.status}`);
}
const [authorization] = authorizationExecution.operations;
if (authorization?.status !== WalletOperationStatus.Signed || !authorization.signature) {
throw new Error('beneficiary declined to sign');
}
// Third party's wallet: the same id, amount, and destination the
// beneficiary signed, plus the signature.
const workflow = await sdk.loc.buildRedeemWorkflow({
redemptions: [
{
id: loc.reference.id,
amount: loc.remainingCredited.amount / 2n,
destinationAddress,
beneficiaryAuthorization: authorization.signature,
},
],
});
await workflow.execute();

Properties

redemptions

redemptions: RedeemLOCParams[];

One entry per LOC to redeem. Two or more entries are batched atomically through Multicall, so the contract sees Multicall rather than the beneficiary as the caller and every entry needs a beneficiaryAuthorization; nonces are consumed per beneficiary in array order. Every actionable LOC in a batch must already have matching collateral and credited tokens; dynamic LOCs are rejected before calldata is built.