const wageringCalculator = ({ depositAmount, bonusAmount, type, contribution, rtp, rolloverTerms }) => {
  const effectiveContribution = contribution === 0 ? 0 : contribution / 100;
  if (effectiveContribution === 0) return 0;
  const originalAmount = type === 'bonus'
    ? (bonusAmount * rolloverTerms) / effectiveContribution
    : ((bonusAmount + depositAmount) * rolloverTerms) / effectiveContribution;
  const effectiveRTP = rtp ? Number((originalAmount / (rtp / 100)).toFixed(2)) : originalAmount;
  return effectiveRTP;
};

module.exports = wageringCalculator;
