Skip to content

API ReferenceVaults, collateral, and riskFunction

calculateCollateralFactorBasisPoints()

function calculateCollateralFactorBasisPoints(
collateralAmount,
creditedAmount,
creditedPerUnitCollateral,
priceExponent?
): number;

Calculates the collateral factor in basis points, given the collateral and credited assets and the price.

Exact mirror of the deployed contract’s integer arithmetic: the collateral VALUE is floored first, then the factor is derived from the floored value, with type(uint16).max as both the zero-value sentinel and the cap. For a deferred-floor, higher-precision variant (display math, not a contract mirror) use calculateCollateralFactorWithScale.

This mirror is limit-agnostic and takes no threshold argument: the creation and liquidation thresholds are per-pair configuration, read separately with getCollateralFactor.

Parameters

ParameterTypeDefault valueDescription
collateralAmountbigintundefinedThe collateral amount in wei.
creditedAmountbigintundefinedThe credited amount in wei.
creditedPerUnitCollateralbigintundefinedThe price. X, in the equation 1 Collateral = X Credited.
priceExponentnumber0The +/- exponent of the price if it cannot easily be represented without losing precision.

Returns

number

The calculated collateral factor in basis points, in the range 0 - 65535 (values above 10000 mean undercollateralized; 65535 is the contract’s sentinel/cap).