pub const fn default_surplus_for(threshold: u8) -> u8Expand description
Shares to emit per polynomial beyond threshold, to absorb losses.
A ratio, evaluated at the threshold actually configured — see
SURPLUS_LOSS_TOLERANCE_DIVISOR for why a ratio is the physically meaningful shape.
This used to be a bare constant, DEFAULT_POLY_THRESHOLD / 2, evaluated once at the default
threshold and then applied whatever the configured one was. Deployments run thresholds from 16
to 64, so a single absolute surplus means wildly different insurance across that range: a flat
20 covers 24 % loss at threshold 64 but 56 % at threshold 16, where it exceeds the shares it
insures. Since H5 the surplus is billed on purchase rather than on claim, so that over-insurance
is quota an Entry pays for in every deposit.
Rounds up. The result is a guarantee of at least the documented tolerance, not an
approximation of it: shares are indivisible, so a threshold that is not a multiple of
SURPLUS_LOSS_TOLERANCE_DIVISOR has to land on one side of 20 % or the other, and covering
less than the documented rate is the failure this function exists to prevent. Rounding down
undershot for every such threshold — 33 received 8 surplus shares and covered 19.51 % — and gave
thresholds 2 and 3 a surplus of zero, i.e. no loss tolerance at all, at and just above
MIN_POLY_THRESHOLD. Rounding up over-covers by less than one share, which is most visible at
the smallest thresholds (2 → 1 surplus → 33 %) and vanishes as the threshold grows (63 → 16 →
20.3 %).
The deployed value is unaffected: DEFAULT_POLY_THRESHOLD is 64, a multiple of the divisor, so
this returns 16 either way and no negotiated quota moves.