pub struct Simulation {
pub id: Uuid,
pub name: String,
pub token: Token,
pub description: Option<String>,
pub status: SimulationStatus,
pub options: SimulationOptions,
pub interval_reports: Vec<SimulationReport>,
pub report: SimulationReport,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
Expand description
Simulation.
Fields§
§id: Uuid
ID of the simulation.
name: String
Name of the simulation. This is used to identify the simulation.
token: Token
Token used in the simulation. This token is used to simulate the tokenomics.
description: Option<String>
Description of the simulation. This is used to provide additional information about the simulation.
status: SimulationStatus
Status of the simulation.
Default is SimulationStatus::Pending
.
options: SimulationOptions
Input parameters for the simulation. These parameters are used to configure the simulation.
interval_reports: Vec<SimulationReport>
Report of the results for each interval of the simulation. This is used to track the progress of the simulation.
report: SimulationReport
Report of the total results of the simulation. This is used to provide a summary of the simulation.
created_at: DateTime<Utc>
Date and time the simulation was created.
updated_at: DateTime<Utc>
Date and time the simulation was last updated.
Implementations§
Source§impl Simulation
impl Simulation
Sourcepub fn builder() -> SimulationBuilder
pub fn builder() -> SimulationBuilder
Sourcepub fn options_builder() -> SimulationOptionsBuilder
pub fn options_builder() -> SimulationOptionsBuilder
Create a new simulation options builder to configure the simulation.
§Returns
New simulation options builder.
Sourcepub fn token_builder() -> TokenBuilder
pub fn token_builder() -> TokenBuilder
Create a new token builder to configure the token used in the simulation.
§Returns
New token builder.
Sourcepub fn update_status(&mut self, status: SimulationStatus)
pub fn update_status(&mut self, status: SimulationStatus)
Sourcepub fn simulate_adoption(
&self,
current_users: u64,
) -> Result<u64, SimulationError>
pub fn simulate_adoption( &self, current_users: u64, ) -> Result<u64, SimulationError>
Sourcepub fn calculate_valuation(&self, token: &Token, users: u64) -> Decimal
pub fn calculate_valuation(&self, token: &Token, users: u64) -> Decimal
Calculate the valuation of the token based on the number of users and the initial price. The valuation model is used to determine how the valuation is calculated. If the valuation model is not set, the default valuation is returned.
§Arguments
token
- The token used in the simulation.users
- The current number of users.
§Returns
The calculated token valuation.
Sourcepub fn run(&mut self) -> Result<(), SimulationError>
pub fn run(&mut self) -> Result<(), SimulationError>
Run the simulation. This will simulate the tokenomics based on the input parameters. The simulation will run for the specified duration and generate reports for each interval. The final report will be generated at the end of the simulation.
§Returns
Result of the simulation.
Sourcepub fn process_interval(
&self,
users: &mut [User],
interval: u64,
) -> Result<SimulationReport, SimulationError>
pub fn process_interval( &self, users: &mut [User], interval: u64, ) -> Result<SimulationReport, SimulationError>
Sourcepub fn generate_interval_report(
&self,
users: &[User],
report: &mut SimulationReport,
interval: u64,
)
pub fn generate_interval_report( &self, users: &[User], report: &mut SimulationReport, interval: u64, )
Generate the interval report for the simulation.
§Arguments
users
- A list of users.report
- The simulation report for the interval.interval
- Duration of the interval.
Sourcepub fn generate_final_report(&mut self, users: Vec<User>)
pub fn generate_final_report(&mut self, users: Vec<User>)
Calculate the final report for the simulation. This will generate a summary of the simulation results based on the interval reports.
§Arguments
users
- A list of users.