  We determine the generating functions of 1/4 BPS dyons in a class of 4d
$\mathcal{N}=4$ string vacua arising as CHL orbifolds of $K3 \times T^2$, a
classification of which has been recently completed. We show that all such
generating functions obey some simple physical consistency conditions that are
very often sufficient to fix them uniquely. The main constraint we impose is
the absence of unphysical walls of marginal stability: discontinuities of 1/4
BPS degeneracies can only occur when 1/4 BPS dyons decay into pairs of 1/2 BPS
states. Formally, these generating functions in spacetime can be described as
multiplicative lifts of certain supersymmetric indices (twining genera) on the
worldsheet of the corresponding nonlinear sigma model on K3. As a consequence,
our procedure also leads to an explicit derivation of almost all of these
twining genera. The worldsheet indices singled out in this way match precisely
a set of functions of interest in moonshine, as predicted by a recent
conjecture.
