API ReferenceVaults, collateral, and riskFunction
calculateRiskFactorBasisPoints()
function calculateRiskFactorBasisPoints( collateralAmount, creditedAmount, collateralFactorBasisPoints, creditedPerUnitCollateral, priceExponent?, maxOneHundredPercent?): number;Calculates the risk factor in basis points, given the collateral and credited assets, the price, and the Liquidation Collateral Factor.
Risk Factor = Current Collateral Factor / Liquidation Collateral Factor, represented in basis points.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collateralAmount | bigint | undefined | The collateral amount in wei. |
creditedAmount | bigint | undefined | The credited amount in wei. |
collateralFactorBasisPoints | number | undefined | The liquidation collateral factor. A value of 0 (e.g. a disabled or unconfigured asset pair — see checkCreditedTokenValidity) is a divide-by-zero input, not “no risk”: with maxOneHundredPercent: false it returns UINT16_MAX_BASIS_POINTS (see isInsufficientSentinel), the same sentinel calculateCollateralFactorBasisPoints uses for its zero-value case; the default capped path returns 10_000 instead, so the position reads as maximally risky rather than risk-free either way. |
creditedPerUnitCollateral | bigint | undefined | The price. X, in the equation 1 Collateral = X Credited. |
priceExponent | number | 0 | The +/- exponent of the price if it cannot easily be represented without losing precision. |
maxOneHundredPercent | boolean | true | Whether the returned amount should be capped at 10000 basis points. |
Returns
number
The risk factor in basis points. Risk factors above 10000 are possible but will be listed as 10000 if maxOneHundredPercent is true. A zero liquidation factor uses that cap for display results and preserves the contract’s uint16 sentinel for uncapped results.