How more convoluted can this explanation be?
The question is equivalent to just "Find the maximum of nb_conversion × (cost_per_conversion - margin_per_conversion)", and the only interesting question is the relationship between the cost per conversion and the number of conversions, which is not a matter of math but of practical statistics.