Skip to content

API ReferenceLOC lifecycleType Alias

CreateDynamicLOCParams

type CreateDynamicLOCParams = object;

Parameters for creating a dynamic LOC — collateral in one token backing a face value in another, priced by the Pyth oracle and subject to the asset pair’s collateral factor and liquidator incentive. Pass to sdk.loc.validateCreateDynamic to pre-check, then to sdk.loc.buildCreateDynamicWorkflow for a wallet workflow that deposits and approves collateral as needed before the creation transaction.

Remarks

Supply priceUpdate from sdk.pricing.getOraclePriceUpdate so creation does not depend on the on-chain price being fresh; its fee is attached as the transaction value. Creation reverts unless the credited token is enabled, the amount is within its per-LOC and global limits, and the collateral’s oracle value satisfies the pair’s creation collateral factor (CollateralFactor); getRequiredCollateralForDynamicLOC computes the minimum collateral.

Example

// WETH is any registered collateral token address, e.g. one listed
// by `sdk.loc.getCollateralTokens()`.
const USDC = testnetProfile.contracts.USDC.address;
// A fresh Pyth price so creation does not depend on the on-chain price
// being recent; its fee is attached to the transaction automatically.
const priceUpdate = await sdk.pricing.getOraclePriceUpdate({
inputToken: WETH,
outputToken: USDC,
});
const params: CreateDynamicLOCParams = {
beneficiary: '0x1111111111111111111111111111111111111111',
// 1,000 USDC face value backed by 0.5 WETH of collateral.
creditedTokenAmount: { tokenAddress: USDC, amount: 1_000_000_000n },
collateralTokenAmount: { tokenAddress: WETH, amount: 5n * 10n ** 17n },
expirationTimestampSeconds: dateToEthereumTimestamp(
await sdk.loc.getMaxDate()
),
priceUpdate,
};
const issues = await sdk.loc.validateCreateDynamic(params);
if (issues.length > 0) throw new Error(JSON.stringify(issues));
const workflow = await sdk.loc.buildCreateDynamicWorkflow(params);
await workflow.execute();

Properties

beneficiary

beneficiary: Address;

Account entitled to redeem the credited value before expiration, and the only party (besides a caller holding its signed authorization) that can cancel the LOC before it expires. If LOCConfig.locBeneficiaryAllowList is configured, must be one of its entries.


collateralTokenAmount

collateralTokenAmount: TokenAmount;

Collateral the creator locks in the CollateralVault to back the LOC, in the collateral token’s smallest unit. Must be a different token than the credited token, and its oracle value must satisfy the pair’s creation collateral factor; the workflow deposits and approves any shortfall.


creator?

optional creator?: Address;

The LOC’s creator. Defaults to the connected signer’s address if empty. If set, must equal the connected signer’s address — the contract binds the creator to msg.sender, so a mismatched value is rejected rather than threaded through.


creditedTokenAmount

creditedTokenAmount: TokenAmount;

The LOC’s face value: the token and amount the beneficiary is entitled to redeem, in the credited token’s smallest unit. The credited token must be enabled by the deployment (CreditedToken) and the amount must fall within its per-LOC minimum/maximum and the global cap on dynamic use.


expirationTimestampSeconds

expirationTimestampSeconds: bigint;

Unix-seconds instant at which the LOC expires — expired at, not after, this second. Must be in the future and no further out than the deployment’s maximum duration; getMinLOCDate and getMaxLOCDate give the SDK’s padded bounds.


locAllowanceSignature?

optional locAllowanceSignature?: Bytes;

Signature to modify the LOC contract’s allowance within the CollateralVault to allow for this LOC’s creation.


priceUpdate?

optional priceUpdate?: OraclePriceUpdateSource;

Oracle update used to validate collateral sufficiency. Supply a non-empty update to pass it through unchanged, pass 'auto' to resolve one when the final transaction is built, or pass null/omit the field to deliberately rely on the current on-chain price. Omission remains network-free and value-free for compatibility with existing direct builder callers. Automatic resolution falls back to an empty update only when the on-chain pair price is proven fresh.


tag?

optional tag?: Bytes;

Optional off-chain reference (e.g. an invoice or document hash) recorded in the creation event and surfaced by the subgraph as LetterOfCreditOrigin.tag; never stored in contract state. 0x-prefixed hex of at most 512 bytes.