```\nif (BBTotSupply == 0) {\n  // if there are no BB holders, all gain to AA\n  AAGain = gain;\n} else if (AATotSupply == 0) {\n  // if there are no AA holders, all gain to BB\n  BBGain = gain;\n} else {\n  // split the gain between AA and BB holders according to trancheAPRSplitRatio\n  AAGain = gain \* trancheAPRSplitRatio / FULL\_ALLOC;\n  BBGain = gain - AAGain;\n}\n```\n