Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ ] = cni( years, ms )
- %% Parameters
- MSupply = 2^64 - 1; % Maximum atomic units
- block_rate = 60; % 30 in BCN, 60 in MRO
- bit_shift = 2^20; % >>18 in BCN, >>20 in MRO
- decimal_shift = 1e12; % 10^8 in BCN, 10^12 in MRO
- minimum_subsidy = ms * decimal_shift; % lower limit of block rewards
- blocks_per_year = 365 * 24 * block_rate; % block generation per year
- height = years * blocks_per_year; % block number at final year
- %% Initialize
- A = zeros(height,1);
- BaseReward = zeros(height,1);
- Daily = zeros(height,1);
- minimum_flag = 1;
- %% Main Loop
- for i = 1:1:height
- BaseReward(i) = (MSupply - A(i)) ./ bit_shift;
- if((BaseReward(i) <= minimum_subsidy) && minimum_flag)
- BaseReward(i) = minimum_subsidy;
- end
- Daily(i) = 24*60*BaseReward(i);
- A(i+1) = A(i) + BaseReward(i);
- end
- %% Plotting
- inflation = 100 .* blocks_per_year .* BaseReward ./ A(1:end-1);
- BaseReward_adjusted = BaseReward./decimal_shift;
- A_adjusted = A./decimal_shift;
- Daily_adjusted = Daily./decimal_shift;
- x_axis = linspace(0,years,height+1);
- figure(1)
- plot(x_axis(1:end-1), BaseReward_adjusted, '-b', 'LineWidth', 2)
- set(gcf, 'PaperPositionMode', 'auto','color','w');
- set(gca, 'FontSize', 20);
- xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
- ylabel('Block Reward','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
- set(get(gca,'YLabel'),'Rotation',90);
- figure(2)
- plot(x_axis, A_adjusted, '-b', 'LineWidth', 2)
- hold on
- plot(x_axis, 18.446e6 .* ones(height+1,1), '--k', 'LineWidth', 2)
- hold off
- set(gcf, 'PaperPositionMode', 'auto','color','w');
- set(gca, 'FontSize', 20);
- xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
- ylabel('Circulation','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
- set(get(gca,'YLabel'),'Rotation',90);
- figure(3)
- plot(x_axis(1:end-1), inflation, '-r', 'LineWidth', 2)
- ylim([0,10])
- xlim([0,years])
- set(gcf, 'PaperPositionMode', 'auto','color','w');
- set(gca, 'FontSize', 20);
- xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
- ylabel('Inflation','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
- set(get(gca,'YLabel'),'Rotation',90);
- figure(4)
- plot(x_axis(1:end-1), Daily_adjusted, '-r', 'LineWidth', 2)
- ylim([0,18*24*60])
- xlim([0,years])
- set(gcf, 'PaperPositionMode', 'auto','color','w');
- set(gca, 'FontSize', 20);
- xlabel('Years', 'FontSize', 20, 'FontWeight', 'bold');
- ylabel('Daily Production','Fontsize', 20, 'FontWeight', 'bold', 'Rotation', 0);
- set(get(gca,'YLabel'),'Rotation',90);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement