Notation and units
How the Math pages write numbers, and which way every rounding goes.
The pages in this section write down what the contracts compute, formula by formula, with the source line each one comes from and a worked example in both raw integers and human units. The narrative pages — interest rates, liquidations, Earn vault — explain why; these explain exactly how much.
Each formula names the contract that computes it, with its mainnet address — for example
IsHealthy · 0x9259…F9a1. Contracts deployed once per market (LendingPool, LendingPoolRouter)
link to the markets table; a Position is deployed per borrower.
Live values are read from mainnet (chainId 4663), and each names the block it was read at; the parameters page lists them. Mainnet's only debt when these pages were written was about 50 USDG on WETH/USDG, too small to show the rounding, so the worked examples that need a market with debt or a position are illustrative: they use mainnet's parameters and a mainnet price, with round amounts chosen to exercise the formulas. Each says which of its inputs are illustrative.
Scales
| WAD | . Every ratio, rate and percentage is stored as an integer scaled by it: 100% is 1e18, 65% is 650000000000000000, 0.1% is 1e15 |
| USDG | 6 decimals. 1 USDG is 1000000 base units |
| WETH and every Stock Token (NVDA, SPY, SPCX, TSLA, MSFT, AAPL, QQQ, GOOGL, AMD) | 18 decimals |
| Oracle prices | 8 decimals. $250 is 25000000000 |
| USD values | Health checks convert everything to USD scaled by |
peUSDG | The Earn vault's share, 18 decimals |
USDG having 6 decimals, not 18, is the single most common integration mistake — a factor of .
Time
Every annual rate is converted to per-second with this constant
(InterestRateModel · 0x8390…D741). There is no leap-year handling: a year is 365
days exactly.
Symbols
| Symbol | Meaning | Where it lives |
|---|---|---|
| Supply assets: what the Earn vault has in a market | totalSupplyAssets on the router | |
| Borrow assets: total debt, including booked interest | totalBorrowAssets | |
| Total borrow shares | totalBorrowShares | |
| Reserves: the protocol's accrued share of interest | totalReserveAssets | |
The vault's assets: idle USDG plus over its markets (totalAssets() adds pending interest) | vault.utilizationTotals() | |
| Vault-wide utilisation, ; one figure for every market of the vault | vault.utilization() | |
| Borrow rate, an annual rate (APR) in WAD | calculateBorrowRate(router) | |
| Reserve factor | interest rate model | |
| , , | Loan-to-value, liquidation threshold, liquidation bonus | router, IsHealthy |
| Collateral in a Position, in base units | Position.totalCollateral() | |
| A borrower's debt in USDG base units | from their shares | |
| , | Collateral value and borrow value, USD × | IsHealthy |
Rounding
Solidity division rounds down. The pages write that as , and a
round-up (Math.mulDiv(…, Math.Rounding.Ceil)) as . Each rounding moves at
most one base unit, but the direction is fixed, and it is worth knowing who each one favours.
| Operation | Rounds | Who it favours | Source |
|---|---|---|---|
| Utilisation | down | borrowers (rate slightly lower) | PaboxoEarnVault · 0xaF5a…c634 |
| Each slope of the rate curve | down | borrowers | InterestRateModel · 0x8390…D741 |
| Interest per accrual | down, once | borrowers, by under one base unit per booking | InterestRateModel · 0x8390…D741 |
| Reserve share of interest | down | lenders (they take the remainder) | InterestRateModel · 0x8390…D741 |
| Borrow shares minted | down | the borrower (up to one share's worth) | LendingPoolRouter |
| Debt for health checks | down | the borrower | IsHealthy · 0x9259…F9a1 |
| Repay: assets pulled for shares | down | the repayer | LendingPoolRouter |
| Close factor: restoring fraction and share cap | up | the liquidator, by at most one share (the position lands on 1.05, never below) | LendingPoolRouter |
| Liquidation: assets paid for shares | up | lenders | LendingPoolRouter |
| Bad debt written off | up | recorded in full | LendingPoolRouter |
| Seize fraction | down | the borrower | LendingPoolRouter |
| Protocol's cut of the seize | down | the liquidator | LendingPoolRouter |
| Borrow fees | down | the borrower | LendingPoolRouter |
Vault deposit / redeem | down | the vault | ERC-4626 |
Vault mint / withdraw | up | the vault | ERC-4626 |
Vault preview* | as the call it quotes | — previews equal execution | PaboxoEarnVault · 0xaF5a…c634 |
| Fee: assets at the high-water mark | up | depositors (a gain must be real before it is charged) | PaboxoEarnVault · 0xaF5a…c634 |
| Fee: amount and shares | down | depositors | PaboxoEarnVault · 0xaF5a…c634 |
Two asymmetries follow from the table. Repayment rounds in the repayer's favour while liquidation rounds in the lenders'; the repayer's gain is at most one base unit per repayment (under 0.000001 USDG), and it is carried by the remaining borrowers' shares. And a new borrow's shares round down, so the borrower's recorded debt can start up to one share's worth below what they borrowed — again carried by the other borrowers.
APR and APY
Every rate stored or returned on-chain is an APR. Where these pages show an APY it is derived, and they say so — see APR and APY.