LTV validation
Before you create a Simple Loan, call client.quote.calculateLtv(...) to calculate its loan-to-value (LTV) ratio. Your app can then reject invalid amount pairs before it asks the protocol to create the 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. Native ETH and ckETH use wei with 18 decimals. USDC and USDT use token base units based on the selected pool decimals.
The SDK also validates minimum borrow amounts. BTC borrows must be at least 5_100n sats. ETH borrows must be at least 5_000_000_000_000_000n wei (0.005 ETH). USDC and USDT borrows must be at least 1_000_000n base units. To display the same minimum before the user submits, use getMinimumBorrowAmount(asset).
Pools expose sameAssetBorrowing and sameAssetBorrowingDustThreshold. When same-asset borrowing is disabled, same-asset collateral must be strictly below the base-unit dust threshold. The SDK rejects equality. The quote helpers, client.simpleLoans.create(...), and client.lending.prepareBorrow(...) enforce this policy.