/** * Fee math and the numeric guards shared by the trading layer. * * Every place that touches money (RiskEngine, Portfolio, the engine's fill * validation, the paper adapters) validates its inputs with the SAME * predicates so the rule cannot drift between call sites. */ /** Smallest quantity difference the portfolio treats as "the same". */ export declare const QTY_EPSILON = 1e-12; /** * Cash comparisons happen at sub-cent precision. Every rendered surface * rounds to cents, and a cash balance that has drifted to 699.6999999999999 * after three fills must still accept an order sized to the displayed * $699.70 — otherwise the agent is refused with a reason that reads * "needs $699.70 but only $699.70 available". */ export declare const CASH_EPSILON_USD = 0.000001; /** * A fill's fee may exceed the approved estimate by at most this much before * it is flagged. Half a cent: enough to absorb a venue that rounds the fee * to the cent when the estimate did not, small enough that a real overcharge * is still caught. */ export declare const FEE_TOLERANCE_USD = 0.005; export declare function isPositiveFinite(n: unknown): n is number; export declare function isNonNegativeFinite(n: unknown): n is number; /** * Return `null` when `value` is a finite number satisfying `min`, else the * reason string every caller renders. Callers that throw wrap it in a * RangeError; callers that return a decision put it in `reason`. */ export declare function invalidNumberReason(label: string, value: unknown, min: 'positive' | 'nonNegative'): string | null; export declare function assertNumber(label: string, value: unknown, min: 'positive' | 'nonNegative'): void; /** Exact fee from order notional and basis points. */ export declare function bpsFee(order: { qty: number; priceUsd: number; }, feeBps: number): number; /** * Fee CEILING for `estimateFee()`: the exact bps fee rounded UP to the cent. * A venue that rounds its fee to the cent (up or to nearest), or computes it * on a cent-rounded notional, still lands at or below this number, so the * engine's fill-fee check is a real invariant rather than a float lottery. */ export declare function bpsFeeCeiling(order: { qty: number; priceUsd: number; }, feeBps: number): number; export declare function roundUpToCent(usd: number): number;