Simulation Equations
Last updated
Last updated
The dynamics of the simulation are defined through mathematical equations. Together they form a system that describes the evolution of the token economy simulation from timestep to timestep.
This table contains, at the bottom, a list of all the token exchange flows defined in the "Agents and Token Flows" tab. The objective is to define these token flows mathematically, with an equation that describes the number of tokens exchanged through that flow at each simulation timestep. We can define additional variables with their corresponding equations to help us calculate the token flows as intermediate steps.
The formulas in the equations can use references for other elements defined in previous sections:
Input Parameters:
Static values: Use the reference of the parameter directly.
Time-dependent parameters: Use the reference of the variable from the "Variables" section directly. At each timestep, the value will be that defined for that time for the parameter.
Selector parameters: may be used with the following syntax: {parameter_reference}.case("{option1}": {formula1}, "{option2}": {formula2}...). For instance: SE_mode.case("Linear": X, "Quadratic": X^2).
Agents: Some agent properties may be referenced using the syntax {agent_reference}.{property_name} (for instance, A_users.total_tokens):
total_tokens: full amount owned at this point in the simulation.
liquidity_provided_tokens: total tokens provided as liquidity to the market by the agent at this point in the simulation.
liquidity_flow: change in the amount of tokens provided as liquidity to the market by the agent in the current timestep.
Other Variables: You can reference the result from another equation in this table using the reference of the variable.
Special Variables: There are some special variables always defined and available to reference:
time and timestep: the current time and timestep of the simulation. The units are in seconds by default, but it is possible to use modifiers like time.seconds, time.hours, time.days, time.months, time.years to reference them with different units.
token_price: price of the token in USD.
circulating_supply: current amount of tokens in circulation.
total_supply: total amount of tokens in existence (circulating supply + tokens still locker in vesting schedules).
Additionally, you may use the special modifier .previous to reference the value of a variable from the previous timestep. For example, token_price.previous.
Equations must avoid circular dependencies, such as an equation referencing its own result. Most circular dependencies can be resolved by approximating a variable dependence in a formula by referencing the value from the previous step using .previous.