Skip to main content

LTV Validation

Call client.quote.calculateLtv(...) before creating an instant loan. This lets your app reject invalid amount pairs before it asks the protocol to create a loan.

const ltv = client.quote.calculateLtv(
{
collateralPoolId,
borrowPoolId,
collateralAmount,
borrowAmount,
},
pools,
prices
);

if (ltv.validationErrors.length > 0) {
throw new Error(ltv.validationErrors.map((error) => error.message).join(" "));
}

Amounts must use each asset's smallest unit. BTC uses satoshis. USDC and USDT use token base units based on the selected pool decimals.