function investmentCalculator() { return { investmentType: 'holder', isTradingActive: false, investmentAmount: 200, tokenPrice: 2.00, tokens: 0, pozoParticipation: 0, stakingPercentage: 0, stakingDuration: '1 mes', tradingVolume: 0, estimatedDividends: 0, totalProjectedEarnings: 0, year: 1, stores: 4, // Fixed at 4 stores for year 1, increment by 4 each subsequent year currentTokenPrice: 0, totalDividendTokens: 0, holderDividendTokens: 0, stakingDividendTokens: 0, tradingDividendTokens: 0, availableForTrade: 0, tradingTokens: 0, yearlyDividends: {}, // To store dividends per year totalDividendsUSD: 0, // Total dividends in USD totalDividendTokensGained: 0, // Total dividend tokens gained over all years scenario: 'moderate', // Default to moderate stakingDividendsUSD: 0, tradingDividendsUSD: 0, showScenarioInfo: false, // Add this line to define showScenarioInfo calculateTokens() { this.tokens = (this.investmentAmount / this.tokenPrice).toFixed(2); }, calculatePozoParticipation() { this.pozoParticipation = ((this.tokens / 1000000) * 100).toFixed(2); }, calculateBaseDividends() { let baseCashFlow = 338812; // Year 1 cash flow per store for moderate scenario switch (this.scenario) { case 'pessimistic': baseCashFlow *= 0.95; // 5% less for pessimistic break; case 'optimistic': baseCashFlow *= 1.05; // 5% more for optimistic break; } let growthFactor = Math.pow(1.08, this.year - 1); // 8% growth per year let totalCashFlow = baseCashFlow * growthFactor * this.stores; // Multiply by the number of stores for this year return totalCashFlow; }, estimateStakingDividends(y) { let baseDividends = this.calculateBaseDividends(y); let stakingTokens = (this.tokens * (this.stakingPercentage / 100)); let bonus = 0; switch (this.stakingDuration) { case '3 meses': bonus = 0.05; break; case '6 meses': bonus = 0.10; break; case '1 año': bonus = 0.20; break; } let stakingDividends = baseDividends * 0.97; // 97% of base dividends go to staking let durationPercentage = { '1 mes': 0.06, '3 meses': 0.07, '6 meses': 0.12, '1 año': 0.14 // Adjusting this value to be more reasonable based on your feedback }[this.stakingDuration]; let dividendValue = (stakingTokens / 1000000) * stakingDividends * durationPercentage * (1 + bonus); this.stakingDividendTokens = (dividendValue / this.dividendTokenValue(y)).toFixed(2); // No acumulamos aquí, solo calculamos el valor para este año return dividendValue.toFixed(2); // Return formatted for display }, estimateTradingDividends() { let baseDividends = this.calculateBaseDividends(); let tradingDividends = baseDividends * 0.02; // 2% for trading this.tradingTokens = (this.availableForTrade * this.tradingVolume / 100).toFixed(2); let userTradingVolume = parseFloat(this.tradingTokens); this.tradingDividendTokens = ((userTradingVolume / 1000000) * tradingDividends / this.dividendTokenValue()).toFixed(2); return (userTradingVolume / 1000000 * tradingDividends).toFixed(2); }, calculateDividends() { this.estimatedDividends = 0; this.tradingDividendsUSD = 0; this.yearlyDividends = {}; this.totalDividendTokensGained = 0; this.stakingDividendsUSD = 0; // Reset this to ensure we start fresh for each calculation for (let y = 1; y <= this.year; y++) { let yearDividends = 0; this.stores = y * 4; // Number of stores for the current year let baseDividends = this.calculateBaseDividends(y) * 0.10; // 10% of cash flow goes to dividends if (this.investmentType === 'holder') { yearDividends = ((this.tokens / 150000) * baseDividends * 0.03).toFixed(2); // 3% for holders this.holderDividendTokens = (parseFloat(yearDividends) / this.dividendTokenValue(y)).toFixed(2); this.stakingDividendTokens = 0; // Reset for holders this.holderDividendsUSD = (parseFloat(yearDividends) - (parseFloat(this.holderDividendTokens) * this.dividendTokenValue(y))).toFixed(2); } else if (this.investmentType === 'staking') { // Calculate staking dividends for this year let stakingDividendsValue = this.estimateStakingDividends(y); // Use only staking dividends for yearDividends in this case yearDividends = stakingDividendsValue; // Update stakingDividendsUSD with only staking dividends this.stakingDividendsUSD += parseFloat(stakingDividendsValue); } // Calculate available tokens for trading after staking this.availableForTrade = (this.tokens - (this.tokens * this.stakingPercentage / 100)).toFixed(2); // Add trading dividends if trading is active if (this.isTradingActive) { let tradingDividends = baseDividends * 0.02; // 2% for trading // Calculate trading volume based on percentage of available tokens this.tradingTokens = (this.availableForTrade * this.tradingVolume / 100).toFixed(2); // Calculate trading dividends based on trading volume let tradingPart = (parseFloat(this.tradingTokens) / 1000000) * tradingDividends; // Sum only trading dividends to tradingDividendsUSD this.tradingDividendsUSD += parseFloat(tradingPart); // Add trading dividends to yearDividends yearDividends = (parseFloat(yearDividends) + tradingPart).toFixed(2); this.tradingDividendTokens = (tradingPart / this.dividendTokenValue(y)).toFixed(2); } else { this.tradingTokens = '0'; this.tradingDividendTokens = '0'; } let tokenValue = this.dividendTokenValue(y); let dividendTokens = (parseFloat(yearDividends) / parseFloat(tokenValue)).toFixed(2); // Include trading data in yearlyDividends, adding a new property for the gain this.yearlyDividends[y] = { usd: parseFloat(yearDividends), tokens: dividendTokens, tokenValue: tokenValue, stores: this.stores, tradingTokens: this.tradingTokens, tradingDividendTokens: this.tradingDividendTokens, tradingDividendGain: parseFloat(this.tradingDividendTokens) * parseFloat(tokenValue) }; // Accumulate the total estimated dividends this.estimatedDividends = (parseFloat(this.estimatedDividends) + parseFloat(yearDividends)).toFixed(2); this.totalDividendTokensGained += parseFloat(dividendTokens); } this.totalDividendTokens = this.totalDividendTokensGained.toFixed(2); this.totalDividendsUSD = parseFloat(this.estimatedDividends); }, calculateTotalEarnings() { let totalCashFlow = this.calculateBaseDividends() / 0.10; // Total cash flow for the year for all shares let expectedDividendYield = 0.6; // 7% yield expected this.currentTokenPrice = (totalCashFlow / 10000000 / expectedDividendYield).toFixed(2); const tokenAppreciation = this.tokens * (parseFloat(this.currentTokenPrice) - this.tokenPrice); this.totalProjectedEarnings = (this.totalDividendsUSD + tokenAppreciation).toFixed(2); }, dividendTokenValue() { // This function calculates the value per dividend token based on the total dividends for the year, // taking into account the scenario selected which changes the base cash flow. let baseDividends = this.calculateBaseDividends() * 0.10; // 10% of cash flow goes to dividends return (baseDividends / 1000000).toFixed(2); // Assuming 2,000,000 tokens per year for dividends }, setTokenPrice(price) { this.tokenPrice = price; this.updateCalculations(); }, setStakingDuration(duration) { this.stakingDuration = duration; this.updateCalculations(); }, toggleTrading() { this.isTradingActive = !this.isTradingActive; this.updateCalculations(); }, updateCalculations() { this.calculateTokens(); this.calculatePozoParticipation(); this.availableForTrade = (this.tokens - (this.tokens * this.stakingPercentage / 100)).toFixed(2); this.calculateDividends(); this.calculateTotalEarnings(); // this.stakingDividendsUSD = parseFloat(this.estimateStakingDividends()); // or explicitly convert to number if there's any doubt if (isNaN(this.stakingDividendsUSD)) { this.stakingDividendsUSD = 0; // Default to 0 if it's not a number } }, init() { this.updateCalculations(); } }; } // Simulación de dividendos por staking fijo a 1 año con 100% de tokens const dividendSimulation = () => { return { simInvestmentAmount: 200, // Monto de inversión inicial, se actualizará dinámicamente simTokenPriceInitial: 2.00, // Precio inicial del token, fijo en $2.00 simTokenPriceFinal: 2.60, // Precio del token al final de 5 años (Preventa 4) simTokens: 0, simBaseCashFlow: 338812, // Flujo de caja base por tienda en el escenario moderado simStoresInitial: 4, // Tiendas iniciales en el año 1 simYears: 5, // Periodo fijo de 5 años simStakingDuration: '1 año', // Staking fijo a 1 año simStakingPercentage: 100, // 100% de los tokens en staking simGrowthRate: 1.08, // Tasa de crecimiento anual del 8% simDividendPercentage: 0.10, // 10% del flujo de caja va a dividendos simStakingBonus: 0.20, // Bonificación por staking de 1 año simStakingDurationPercentage: 0.14, // Porcentaje de duración para 1 año simScenario: 'optimistic', // Escenario optimista fijo simCalculateTokens() { // Usamos el precio inicial del token para calcular la cantidad de tokens this.simTokens = (this.simInvestmentAmount / this.simTokenPriceInitial).toFixed(2); }, simCalculateBaseDividends(year) { let baseCashFlow = this.simBaseCashFlow; // Ajuste para el escenario optimista if (this.simScenario === 'optimistic') { baseCashFlow *= 1.05; // 5% más para el escenario optimista } let growthFactor = Math.pow(this.simGrowthRate, year - 1); let totalStores = this.simStoresInitial + (year - 1) * 4; // Añadiendo 4 tiendas cada año let totalCashFlow = baseCashFlow * growthFactor * totalStores; return totalCashFlow; // Devolvemos solo el flujo de caja total del año }, simEstimateStakingDividends(year) { let baseDividends = this.simCalculateBaseDividends(year); let stakingTokens = (this.simTokens * (this.simStakingPercentage / 100)); let stakingDividends = baseDividends * 0.97; // 97% de los dividendos base van a staking // Ajustamos para reflejar el bono y el porcentaje de duración fijo para 1 año let bonus = 0.20; // Bonificación fija para 1 año de staking let durationPercentage = 0.14; // Porcentaje de duración fijo para 1 año let dividendValue = (stakingTokens / 1000000) * stakingDividends * durationPercentage * (1 + bonus); return dividendValue.toFixed(2); }, simSimulateDividends() { this.simCalculateTokens(); let totalGains = 0; this.simYearlyDividends = {}; this.simTotalDividendTokensGained = 0; for (let y = 1; y <= this.simYears; y++) { let yearDividends = 0; let simStores = this.simStoresInitial + (y - 1) * 4; // Adding 4 stores each year let totalCashFlow = this.simCalculateBaseDividends(y) * this.simDividendPercentage; // Total cash flow before dividends // Calculate staking dividends for this year let stakingDividendsValue = parseFloat(this.simEstimateStakingDividends(y)); yearDividends = stakingDividendsValue; // Value per action token, based on the total annual cash flow let actionTokenValue = (totalCashFlow / 1000000).toFixed(2); // Assuming 1,000,000 total tokens // Calculate the price people would be willing to pay based on an expected yield (example: 6% annual) let expectedDividendYield = 0.06; // 6% yield expected let stockTokenPrice = (actionTokenValue / expectedDividendYield).toFixed(2); // Dividend tokens based on annual dividends and the action token value let dividendTokens = (yearDividends / parseFloat(actionTokenValue)).toFixed(2); // Accumulate gains totalGains += yearDividends; // Store annual data this.simYearlyDividends[y] = { usd: yearDividends, tokens: dividendTokens, actionTokenValue: actionTokenValue, // Value per action token stockTokenPrice: stockTokenPrice, // Estimated price per action token stores: simStores, tradingTokens: 0, // Fixed at 0 since there's no trading tradingDividendTokens: 0, // Fixed at 0 since there's no trading tradingDividendGain: 0 // Fixed at 0 since there's no trading }; let totaltokenUSD = this.simTokens * stockTokenPrice; let totalTokenGains = totaltokenUSD - this.simInvestmentAmount; let totalProjectedGains = totalGains + totalTokenGains; this.simTotalDividendTokensGained += parseFloat(dividendTokens); // Update DOM elements for Year 5 if (y === 5) { document.getElementById('yearTitle').innerText = `Año 5: ${this.getYearTitle(y)}`; document.getElementById('stockTokenPrice').innerText = `Precio Estimado por Token de Acción: $${stockTokenPrice}`; document.getElementById('projectedStockValue').innerText = `Valor proyectado acciones: $${totaltokenUSD.toFixed(2)}`; document.getElementById('tokenAppreciationGain').innerText = `Ganancia por aumento de token: $${totalTokenGains.toFixed(2)}`; document.getElementById('projectedDividendGains').innerText = `Ganancia Dividendos Proyectada: $${totalGains.toFixed(2)}`; document.getElementById('totalProjectedGains').innerText = `Total Ganancias Proyectadas: $${totalProjectedGains.toFixed(2)}`; } } }, getYearTitle(year) { switch(year) { case 1: return 'EL DESPEGUE INICIAL'; case 2: return 'LA EXPANSIÓN'; case 3: return 'INNOVACIÓN DISRUPTIVA'; case 4: return 'CONSOLIDACIÓN DEL ÉXITO'; case 5: return 'EL FUTURO ES AHORA'; default: return 'AÑO ' + year; } }, // Método para actualizar el monto de inversión dinámicamente simUpdateInvestmentAmount(amount) { this.simInvestmentAmount = amount; this.simSimulateDividends(); }, simInit() { this.simSimulateDividends(); } }; }; // Inicializando la simulación let simulation = dividendSimulation(); simulation.simInit(); // Para actualizar el monto de inversión dinámicamente, puedes usar: // simulation.simUpdateInvestmentAmount(nuevoMonto);