quoteBorrow
Quote a non-recourse USDC advance against pledged AVM collateral.
Increases position debt by amount. Net USDC out is amount minus the 3% advance fee. Spot does not move, so priceImpact is null (not zero).
Local math refuses over-capacity even if an on-chain quoter still returns a struct. Capacity is borrowCapacity: floor value of collateral minus existing debt.
The position has no interest and no due date. Locked tokens stay pledged until repay, shrink, or quoteSurrender.
Import
import { quoteBorrow } from "@repo/contract-client/math";
Usage
import { parseUsdc } from "@repo/contract-client";
import { quoteBorrow } from "@repo/contract-client/math";
const quote = quoteBorrow(snapshot, position, parseUsdc("10"));
quote.grossDebtIncreaseRaw;
quote.netReserveOutRaw;
quote.borrowCapacityRaw;
quote.fees.totalRaw; // 3% of gross
quote.position.debtRaw; // previous + amount
quote.priceImpact; // null
Load position from getAccountContext. Size the slider with getMaxActions.
Return Value
BorrowQuote
| Field | Meaning |
|---|---|
kind | 'borrow' |
grossDebtIncreaseRaw | Debt added (the amount you passed) |
netReserveOutRaw | USDC the wallet receives |
borrowCapacityRaw | Capacity before this borrow |
fees | 3% split (protocol / creator / floor) |
position | Resulting collateral (unchanged) and debt |
priceImpact | null |
Parameters
snapshot
- Type:
MarketSnapshot
Needs floorPriceWad and balances.liquidReserveRaw. The liquid reserve must cover net out plus withdrawable fee legs.
quoteBorrow(snapshot, position, parseUsdc("10"));
position
- Type:
PersonalPosition
{ owner, collateralAvm, debtRaw }.
quoteBorrow(snapshot, account.position, parseUsdc("10"));
amount
- Type:
UsdcRaw
Gross debt increase. ≥ 100 raw and ≤ remaining capacity.
quoteBorrow(snapshot, position, asUsdcRaw(10_000_000n));
Error
| Error | When |
|---|---|
ProtocolRevertError BelowMinimum | amount < 100 |
ProtocolRevertError BorrowCapacityExceeded | amount > capacity |
ProtocolRevertError InsufficientBacking | Liquid reserve cannot pay net + fees |
Tips
- Borrow does not mint. Collateral must already sit in the position (from a buy-and-pledge / expand, or a prior deposit).
- Fee surplus from the 3% still goes toward future floor raises, same as trade fees.