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
| Parameter | Type | Default value | Description |
|---|---|---|---|
collateralAmount | bigint | undefined | The collateral amount in wei. |
creditedAmount | bigint | undefined | The credited amount in wei. |
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. |
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).