Core concepts

Interest & APR

The exact simple-interest formula, in basis points, with a worked example.

Interest is simple, not compounding, and it's computed once — from the full duration and aprBps fixed at listing creation — regardless of when repayment actually happens. Repaying on day 1 of a 90-day term still owes the full 90 days of interest; there's no accrual-based discount for repaying early.

The formula

math.ts
uint256 constant BPS = 10_000;
uint256 constant YEAR = 365 days;

function interestOwed(uint256 loanAmount, uint16 aprBps, uint32 duration) returns (uint256) {
  if (loanAmount == 0 || aprBps == 0 || duration == 0) return 0;
  return (loanAmount * aprBps * duration) / (BPS * YEAR);
}

In plain terms: interest = loanAmount × (aprBps ÷ 10,000) × (duration ÷ 31,536,000 seconds). A year is always treated as exactly 365 days — there's no leap-year adjustment.

Worked example

InputValue
loanAmount1,000 USDG
aprBps800 (8.00% APR)
duration2,592,000 seconds (30 days)
interestOwed1,000 × 800 × 2,592,000 ÷ (10,000 × 31,536,000) ≈ 6.575 USDG

At repay, the borrower owes loanAmount + interestOwed(id) — in this example, 1,006.575 USDG — transferred to the lender in a single call. There's no protocol cut taken from that transfer; the lender receives the full amount.

Where aprBps comes from in the UI

The Create listing form takes a plain percentage (e.g. 8) and converts it with Math.round(Number(apr) * 100). Entering 8.25 produces aprBps = 825. uint16 caps aprBps at 65,535 — an APR above 655.35% can't be represented.