How it works
Supplying, borrowing, health, and the two addresses every market has.
Each market is an isolated pair: one collateral asset, one borrow asset. Borrowers and liquidations are isolated per market — a position in NVDA/USDG is priced and liquidated on NVDA alone, whatever happens in SPY/USDG. Lenders are not: every market's only lender is the same Earn vault, so bad debt in one market lowers the value of every Earn depositor's shares. What bounds it is the vault's exposure to that market, which a per-market cap can limit (the caps are currently unlimited).
Supplying
You do not supply to a market. Every market has exactly one lender: the
Earn vault. LendingPool.supplyLiquidity and withdrawLiquidity revert with
SupplyIsThroughAVault for any caller other than the market's vault (or the factory, for the
liquidity a market is seeded with at creation, which also comes out of the vault).
So there are no per-market supply shares. You deposit USDG into the vault and receive peUSDG, the
vault's share token. The number of shares does not change; what each one is worth grows as
borrowers in the markets the vault lends to pay interest. Withdrawing from the vault reads no price,
so — unlike borrowing — it is not blocked while the equity market is closed.
What you can withdraw is bounded by what is not lent out: the vault's idle USDG plus the cash each market holds beyond its borrowers' debt. If the markets are fully borrowed, a withdrawal waits until someone repays. That is normal for a lending market and is why the interest rate curve rises steeply near the top: the rate is what pulls liquidity back.
Borrowing
- Deposit collateral — a Stock Token or WETH, or in an LP market a Uniswap liquidity position.
- Borrow USDG, up to the market's LTV against the value of that collateral.
- Pay interest continuously, accrued into your debt.
- Repay in USDG, from your wallet.
Your collateral lives in a Position contract that belongs to you alone. It is not pooled with other borrowers' collateral.
Every borrow pays two fees up front, deducted from what you receive while your debt is the full amount: a protocol fee (0.1% of the amount, set per borrow token) and a creator fee (set per market). The creator fee is switched off on every market, so borrowing 1,000 USDG delivers 999.00 and records 1,000 of debt. Each fee is capped at 10%, and neither can be stored as zero: a stored zero restores its default (0.01% for the creator fee), so "off" is a fee of 1 wei-WAD, which rounds to nothing on any real borrow. See borrow shares and fees.
Health
Two thresholds, and the gap between them is deliberate:
- LTV — the most you may borrow when you open or increase a position.
- Liquidation threshold — the point at which the position becomes liquidatable.
Borrowing at exactly the LTV leaves you a small distance from liquidation, not zero distance. For NVDA/USDG that distance is 60% to 65%: a 7.7% fall in the collateral price closes it. On SPCX/USDG and TSLA/USDG it is 45% to 50%, a 10% fall.
A position is liquidatable when
borrowed value > collateral value × liquidation thresholdBoth values come from the oracle, and neither can be read while the feed is in a state the contracts refuse to price on.
Repaying
You repay in the borrow token — USDG — from your wallet. The function is still called
repayWithSelectedToken, but the pool accepts only the borrow token (anything else reverts
RepayTokenMustBeBorrowToken) and pulls it from the caller. There is no DEX in the path and no way
to repay with the collateral itself.
Repayment is sized in debt shares, not in USDG: you pass the number of borrow shares to burn,
and the pool pulls what they are worth after accruing interest. Asking for more shares than you
hold repays all of them instead of reverting, so type(uint256).max repays the whole debt, whatever
interest accrued before the transaction landed. Approve enough USDG to cover it. InsufficientShares
reverts only when you have no debt in the market. RepayByPosition carries the shares actually
burned.
The app does this for you. Its MAX is the smaller of your wallet balance and your debt projected forward to cover the interest that accrues before the transaction lands. When that covers the debt, it sends exactly your shares, so no dust is left behind to block withdrawing your collateral.
Anyone can repay a position with their own funds; it can only reduce the borrower's debt.
The two addresses
Every market has two contracts, and the difference matters for anyone integrating:
| what it is | what you use it for | |
|---|---|---|
| LendingPool | the contract you transact with | supply collateral, borrow, repay, withdraw collateral — every write |
| LendingPoolRouter | the accounting and configuration | totals, rates, caps, windDown — every read |
Getting this backwards does not revert. It returns zeroes, or writes a parameter against an address nothing will ever match. The contracts page lists both for each market.