  Recently, an exact description of instanton corrections to the moduli spaces
of 4d N=2 supersymmetric gauge theories compactified on a circle and Calabi-Yau
compactifications of Type II superstring theories was found. The equations
determining the instanton contributions turn out to have the form of
Thermodynamic Bethe Ansatz. We explore further this relation and, in
particular, we identify the contact potential of quaternionic string moduli
space with the free energy of the integrable system and the Kahler potential of
the gauge theory moduli space with the Yang-Yang functional. We also show that
the corresponding S-matrix satisfies all usual constraints of 2d integrable
models, including crossing and bootstrap, and derive the associated Y-system.
Surprisingly, in the simplest case the Y-system is described by the MacMahon
function relevant for crystal melting and topological strings.
