Appendix A Simulation Code Example
The following is the code written in Python to generate the simulations used in the document above.
Simulated Transactions Per Second (TPS) Over 24 Hours
```python
import numpy as np
import matplotlib . pyplot as plt
base_tps_phronzero = 100000
base_tps_phronlayer1 = 50000
time_hours = np. arange (0, 24, 1)
network_load_factor_phronzero = 0.5 * np. sin (np .pi * time_hours / 12 - np.pi /2) + 1
network_load_factor_phronlayer1 = 0.5 * np.sin(np .pi * time_hours / 12 - np .pi /2) + 1.5
effective_tps_phronzero = base_tps_phronzero * network_load_factor_phronzero
effective_tps_phronlayer1 = base_tps_phronlayer1 * network_load_factor_phronlayer1
plt.figure ( figsize =(14 , 7))
plt.plot ( time_hours , effective_tps_phronzero , label ='PhronZero TPS', marker ='o')
plt.plot ( time_hours , effective_tps_phronlayer1 , label ='Phron Layer 1 TPS', marker ='x')
plt.title ('Simulated Transactions Per Second ( TPS) Over 24 Hours ')
plt.xlabel ('Time ( Hours )')
plt.ylabel (' Transactions Per Second ( TPS )')
plt.legend ()
plt.grid ( True )
plt.xticks ( time_hours )
plt.ylim (0, max ( effective_tps_phronzero ) + 50000)
plt.show ()
# \ end { verbatim *}
# \ subsection { Simulated Dynamic Gas Fee }
# \ begin { verbatim *}
def calculate_dynamic_gas_fee ( base_fee , tip , epsilon , p_target , p_current , delta_c ,
delta_n ):
"""
Calculate the dynamic gas fee for a transaction based on the provided parameters .
: param base_fee : Base fee of the transaction
: param tip : Optional tip to miners / validators
: param epsilon : Sensitivity parameter for token price stabilization
: param p_target : Target token price
: param p_current : Current token price
: param delta_c : Rate of change in transaction complexity
: param delta_n : Rate of change in network congestion
: return : Calculated dynamic gas fee
"""
price_adjustment = epsilon * ( p_target - p_current ) / p_current
gas_fee = ( base_fee + tip + price_adjustment ) * ( delta_c + delta_n )
return gas_fee
base_fee = 10
tip = 1
epsilon = 0.1
p_target = 1
p_current = 0.65
delta_c = 1
delta_n = 1
```
Gas Fees for Storage Biased L1 with Secondary dApp Support
```python
# Simulate dynamic gas fees over time for a single dApp type
time = np. arange(0, 10, 0.1)
gas_fees = [calculate_dynamic_gas_fee ( base_fee , tip , epsilon , p_target , p_current + t, delta_c , delta_n ) for t in time]
plt.figure( figsize =(10 , 6))
plt.plot(time , gas_fees , label ='Dynamic Gas Fee Over Time')
plt.title('Simulated Dynamic Gas Fee')
plt.xlabel('Time')
plt.ylabel('Gas Fee')
plt.legend()
plt.grid(True)
plt.show()
```
Simulated Gas Fees
```python
import numpy as np
import matplotlib . pyplot as plt
# Setup
t = np. linspace (0, 2 * np.pi , 400)
BaseRate = 10
StorageRate = 0.05
N = 0.5 * np. sin (t) + 1.5 # Network congestion
# Parameters for complexity (C)
A, B, V, M, S = 1.5 , 1, 2, 1.5 , 0.8
omega , eta , kappa , alpha , R,T= 2, 0.05 , 1, 0.1 , 5, 50
i = np. arange (1, int (np. max (t) / T) + 1) * T
# Gaming dApp
C_gaming = A * np.sin( omega * t) + B
D_gaming = np. zeros_like (t)
G_gaming = BaseRate * (1 + C_gaming + N) + StorageRate * D_gaming
# DEX
C_dex = V * np. log (1 + eta * t) + M * np. sin ( kappa * t)
D_dex = np. zeros_like (t)
G_dex = BaseRate * (1 + C_dex + N) + StorageRate * D_dex
# Storage dApp
C_storage = np. full_like (t, S)
D_storage = R * np.sum ([ np. exp(- alpha * (t - iT) **2) for iT in i], axis =0)
G_storage = BaseRate * (1 + C_storage + N) + StorageRate * D_storage
# Plotting
plt.figure( figsize =(12 , 8))
plt.plot(t, G_gaming , label ='Gaming dApp')
plt.plot(t, G_dex , label ='DEX')
plt.plot(t, G_storage , label ='Storage dApp', linestyle ='--')
plt.title('Simulated Gas Fees')
plt.xlabel('Time (in cycles )')
plt.ylabel('Gas Fee (in gui unit )')
plt.legend()
plt.grid(True)
plt.show()
```
Gas Fees for Storage Biased L1 with Secondary dApp Support
```python
import numpy as np
import matplotlib.pyplot as plt
# Setup
t = np. linspace (0, 2 * np.pi , 400)
BaseRate = 10
N = 0.5 * np. sin (t) + 1.5 # Simulated network congestion
C_gaming_primary = 1.5 * np. sin (2 * np .pi * t / max(t))
C_dex_secondary = 0.3 * np. sin (4 * np .pi * t / max(t)) # Reduced influence
C_storage_secondary = 0.2 * np. sin (4 * np .pi * t / max (t)) # Reduced influence
G_gaming = BaseRate * (1 + C_gaming_primary + N)
G_dex = BaseRate * (1 + C_dex_secondary + N)
G_storage = BaseRate * (1 + C_storage_secondary + N)
plt.figure ( figsize =(12 , 8))
plt.plot (t, G_gaming , label ='Gaming dApp - Primary ', color ='blue')
plt.plot (t, G_dex , label ='DEX dApp - Secondary ', color ='orange', linestyle ='--')
plt.plot (t, G_storage , label ='Storage dApp - Secondary ', color ='green', linestyle =':')
plt.title ('Gas Fees for Gaming Biased L1 with Secondary dApp Support ')
plt.xlabel ('Time (in cycles )')
plt.ylabel ('Gas Fee (in gwei )')
plt.legend ()
plt.grid ( True )
plt.show ()
plt.figure ( figsize =(12 , 8))
G_dex_primary = BaseRate * (1 + 2.0 * (np. sin (4 * np .pi * t / max (t)) **2) + N)
G_gaming_supportive = BaseRate * (1 + 0.3 * np.sin (2 * np .pi * t / max (t)) + N)
# Increased presence from Gaming
G_storage_supportive = BaseRate * (1 + 0.2 * np.sin (4 * np .pi * t / max (t)) + N)
plt.plot (t, G_dex_primary , label ='DEX dApp - Primary', color ='orange')
plt.plot (t, G_gaming_supportive , label ='Gaming dApp - Supportive', color ='blue',linestyle ='--')
plt.plot (t, G_storage_supportive , label ='Storage dApp - Supportive', color ='green',
linestyle =':')
plt.title ('Gas Fees for DEX Biased L1 with Secondary dApp Support')
plt.xlabel ('Time (in cycles )')
plt.ylabel ('Gas Fee (in gwei )')
plt.legend ()
plt.grid ( True )
plt.show ()
plt.figure ( figsize =(12 , 8))
G_storage_primary = BaseRate * (1 + 0.8 * np. sum ([ np.exp ( -0.1 * (t - iT) **2) for iT in np. arange (1, int (np. max (t) / 50) + 1) * 50] , axis =0) + N)
G_gaming_supportive = BaseRate * (1 + 0.3 * np.sin (2 * np .pi * t / max (t)) + N)
# Slightly increased presence from Gaming
G_dex_supportive = BaseRate * (1 + 0.2 * np. sin (4 * np .pi * t / max (t)) + N)
plt.plot (t, G_storage_primary , label ='Storage dApp - Primary', color ='green')
plt.plot (t, G_gaming_supportive , label ='Gaming dApp - Supportive', color ='blue', linestyle ='--')
plt.plot (t, G_dex_supportive , label ='DEX dApp - Supportive', color ='orange', linestyle =':')
plt.title ('Gas Fees for Storage Biased L1 with Secondary dApp Support')
plt.xlabel ('Time (in cycles )')
plt.ylabel ('Gas Fee (in gwei )')
plt.legend ()
plt.grid ( True )
plt.show ()
```
Transaction Throughput for Layer 1 Projects and Total Usage on Layer 0 Network
```python
import numpy as np
import matplotlib.pyplot as plt
# Simulation parameters
SIMULATION_DURATION = 100 # Total time for simulation in seconds
LAYER_0_TPS = 31000 # Layer 0's maximum tps
NUM_PROJECTS = 3 # Number of Layer 1 projects
# Assume an even distribution of Layer 0's TPS across Layer 1 projects
tps_distribution = LAYER_0_TPS / NUM_PROJECTS
# Simulating transaction throughput for each Layer 1 project over time
time_steps = np. linspace (0, SIMULATION_DURATION , SIMULATION_DURATION )
throughput_data = {}
# Total throughput at each time step
total_throughput = np. zeros ( SIMULATION_DURATION )
# Create throughput data for each project and calculate total throughput
for i in range ( NUM_PROJECTS ):
# Randomly vary the tps for each project to simulate fluctuating network conditions
tps_variation = np. random.normal (0, 1000 , SIMULATION_DURATION )
throughput_data [f'Project {i +1}'] = tps_distribution + tps_variation
total_throughput += throughput_data [f'Project {i +1}']
# Plotting the multi - line chart for individual projects
plt.figure ( figsize =(14 , 7))
for project , tps in throughput_data.items ():
plt.plot ( time_steps , tps , label = project )
# Adding the total usage curve
plt.plot ( time_steps , total_throughput , label ='Total Usage', color ='black', linewidth =2, linestyle ='--')
# Chart configurations
plt.title (' Transaction Throughput for Layer 1 Projects and Total Usage on Layer 0 Network')
plt.xlabel ('Time ( seconds )')
plt.ylabel (' Transactions per Second ( tps )')
plt.legend ()
plt.grid ( True )
plt.show ()
```
The Annual Percentage Rate (APR)
```python
import numpy as np
import matplotlib . pyplot as plt
def apr_function (x):
base = 15 * 10**15
apr_decimal = -np. log10 (x / 2000 + 0.0001) / np. log10 ( base ) - 0.1
return apr_decimal * 100
x_values = np. linspace (0, 20, 400) # Assuming the time range is 0 to 20 years for illustration
y_values = apr_function ( x_values )
# Plotting the function
plt.figure( figsize =(10 , 5))
plt.plot( x_values , y_values , label ='APR over time')
plt.title('APR as a function of Time ( Percentage )')
plt.xlabel('Time ( years )')
plt.ylabel('APR (%)')
plt.legend()
plt.grid( True )
plt.show()
```