Skip to content

API ReferenceVaults, collateral, and riskFunction

deriveWithdrawableCollateral()

function deriveWithdrawableCollateral(params): WithdrawableCollateral[];

Derives withdrawal previews from available balances and expired reserved LOCs. The calculation preserves vault/account/token namespaces and ignores converted LOCs, foreign identities and duplicate LOC discovery rows. It performs no reads; execution must revalidate current storage before cancelling or withdrawing.

Parameters

ParameterTypeDescription
paramsDeriveWithdrawableCollateralParamsCurrent-state reads, selected account and LOC deployment, and an explicit clock.

Returns

WithdrawableCollateral[]

Positive gross amounts per supplied balance, with the expired LOC IDs that release collateral.

Throws

No errors for inputs satisfying the declared SDK types; this pure derivation performs no I/O.

Example

// Supply current balances and outstanding LOCs for the selected account
// and LOC deployment, plus an explicit Unix-second clock.
const previews = deriveWithdrawableCollateral(params);
for (const { balance, locIDs, totalAmount } of previews) {
console.log(balance.collateralContractAddress, balance.token.address);
console.log(locIDs, totalAmount); // Gross base units, before fees.
}
// Execution revalidates current storage before cancelling/withdrawing.