Skip to content

API ReferenceVaults, collateral, and riskFunction

collateralAmountInCreditedToken()

function collateralAmountInCreditedToken(amount, price): bigint;

Values a collateral amount in credited-token units using the protocol’s integer floor.

Parameters

ParameterTypeDescription
amountbigintCollateral-token amount in smallest units.
pricePick<Price, "price" | "exponent">Directional credited-per-collateral price and decimal exponent.

Returns

bigint

Credited-token value in smallest units, floored before subsequent ratio calculations.

Throws

RangeError if an exponent cannot be represented by bigint exponentiation.

Example

const value = collateralAmountInCreditedToken(123n, { price: 25n, exponent: -1n });
// 307n: the fractional credited unit is discarded.