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
onchain 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);
LOCModule.getRequiredCollateralForDynamic
computes the collateral needed.
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;The Beneficiary: the 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, it must be one of its entries.
collateralTokenAmount
collateralTokenAmount: TokenAmount;Collateral the Creator reserves in the Collateral Vault 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 set, it must equal the connected signer’s address, because the contract records the transaction sender as the Creator; a different value is rejected.
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 for Dynamic LOCs (LOCModule.getCreditedToken) 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; LOCModule.getMinDate and LOCModule.getMaxDate give the SDK’s padded bounds.
locAllowanceSignature?
optional locAllowanceSignature?: Bytes;Vault allowance signature letting the LetterOfCredit contract reserve this LOC’s collateral, from VaultModule.buildModifyAllowanceAuthorizationWorkflow. When it is omitted and the allowance is short, the workflow asks the wallet to sign one.
priceUpdate?
optional priceUpdate?: OraclePriceUpdateSource;Oracle price update the contract uses to check the collateral. Supply an update from
PricingModule.getOraclePriceUpdate to pass it
through unchanged (its fee becomes the transaction value), pass 'auto' to fetch one when the
final transaction is built, or pass null or omit the field to rely on the current onchain price,
with no fetch and no fee. With 'auto', if the fetch fails the SDK uses the onchain price only when
it can prove that price is still fresh.
tag?
optional tag?: Bytes;Optional reference data (for example an invoice number or document hash) recorded in the creation
event and returned as origin.tag on LetterOfCredit; it is not
stored in contract state. 0x-prefixed hex of at most 512 bytes
(LOCModule.getCreateTagByteLimit).