/** * Max-affordable-home-price under the standard 28/36 DTI rule. * * Hoisted from every realty cohort MCP — each one (`zillow-mcp`, * `redfin-mcp`, `compass-mcp`, `homes-mcp`, `onehome-mcp`) ships a * `*_calculate_affordability` tool whose math is identical to the * digit. zillow's 240 extra lines are explanation strings and * bucket breakdowns — trivial to layer as a portal-specific wrapper * on top of this pure core. * * The math: invert PMT against two constraints, pick the binding one. * * front-end cap = income * front_end_dti * back-end cap = income * back_end_dti − monthly_debts * max_piti = min(front, back) ← binding constraint * * PITI = P&I + tax + insurance + HOA * = loan * factor + price * (tax/$) + ins + hoa * = loan * factor + (loan + down) * (tax/$) + ins + hoa * * Solve for `loan`: * * max_piti − ins − hoa − down*(tax/$) * ──────────────────────────────────────── = loan * factor + (tax/$) * * max_home_price = loan + down_payment * * where `factor = r(1+r)^n / ((1+r)^n − 1)` is the standard PMT * coefficient for monthly rate `r` and term-months `n`. The `r === 0` * branch falls back to straight-line amortization (`1/n`) to avoid a * 0/0. * * Pure function — no I/O, no portal SDK. Cohort MCPs wrap with their * own `*_calculate_affordability` tool description string. */ export interface AffordabilityInput { /** Borrower's gross monthly income, dollars. Must be > 0. */ monthly_income: number; /** Recurring monthly debt service (car / student / minimum CC). Default 0. */ monthly_debts?: number; /** Cash down, dollars. Must be >= 0. */ down_payment: number; /** Annual interest rate as a percent (e.g. `6.5` for 6.5%). Must be >= 0. */ interest_rate: number; /** Loan term in years. Default 30. */ loan_term_years?: number; /** Annual property tax as a percent of home price (e.g. `1.1`). Default 1.1. */ property_tax_rate?: number; /** Annual homeowners insurance premium, dollars. Default 0. */ insurance_annual?: number; /** Monthly HOA dues, dollars. Default 0. */ hoa_monthly?: number; /** Front-end (housing / income) DTI cap as decimal. Default 0.28. */ front_end_dti?: number; /** Back-end ((housing + debts) / income) DTI cap as decimal. Default 0.36. */ back_end_dti?: number; } export interface AffordabilityResult { max_home_price: number; max_monthly_piti: number; binding_constraint: 'front_end' | 'back_end'; monthly_principal_interest: number; monthly_property_tax: number; monthly_insurance: number; monthly_hoa: number; loan_amount: number; down_payment: number; front_end_dti_used: number; back_end_dti_used: number; } /** * Solve for the maximum home price the borrower can afford under the * 28/36 DTI rule (or custom DTI caps via `front_end_dti` / `back_end_dti`). * * @throws if `monthly_income <= 0`, `down_payment < 0`, or `interest_rate < 0`. */ export declare function calculateAffordability(input: AffordabilityInput): AffordabilityResult;