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
| Parameter | Type | Description |
|---|---|---|
amount | bigint | Collateral-token amount in smallest units. |
price | Pick<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.