Simulation

Struct Simulation 

Source
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

Source

pub fn builder() -> SimulationBuilder

Create a new simulation with the given token and options.

§Returns

New simulation builder.

Source

pub fn options_builder() -> SimulationOptionsBuilder

Create a new simulation options builder to configure the simulation.

§Returns

New simulation options builder.

Source

pub fn token_builder() -> TokenBuilder

Create a new token builder to configure the token used in the simulation.

§Returns

New token builder.

Source

pub fn update_status(&mut self, status: SimulationStatus)

Update the status of the simulation.

§Arguments
  • status - The new status of the simulation.
Source

pub fn simulate_adoption( &self, current_users: u64, ) -> Result<u64, SimulationError>

Simulate user adoption based on the current number of users and the adoption rate. If the adoption rate is not set, the current number of users is returned.

§Arguments
  • current_users - The current number of users.
§Returns

The new number of users after adoption.

Source

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.

Source

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.

Source

pub fn process_interval( &self, users: &mut [User], interval: u64, ) -> Result<SimulationReport, SimulationError>

Simulate trades for a given interval. This will simulate trades for each user in the list and generate a report for the interval.

§Arguments
  • users - A list of users.
  • interval - Duration of the interval.
§Returns

A report of the simulation results for the interval.

Source

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.
Source

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.
Source

pub fn get_interval(&self) -> u64

Get the interval for the simulation.

§Returns

The duration of the simulation interval.

Trait Implementations§

Source§

impl Debug for Simulation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V