# How to add new token mechanics

We might encounter cases where we need to add a token mechanic that is not at all available through the Basic editor. In such cases, we can add it through the advanced editor.

For example, suppose we want to add an expenditure of the treasury related to the number of users on the platform, to represent infrastructure costs. Let’s assume the treasury is selling tokens to cover this cost.

#### Step 1: Changes in Agents and Token Flows

Since the Treasury agent is already in the simulation, we do not need to create a new one, simply add a new mechanic in which this agent participates. We need to create a new flow representing the action we want the treasury to take.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfPokg5dXgyP3QXFqhHUhEkzNK6EeG8izksIii1lj97RxlYmm5Hnlt89kE6WXrHQp1Yr0O2I93L0vAarzUOlGaWw4XG2bEUjA7Fsy-NUGjTzHYZOy14Pmc71UV7DJnFR6MfvaTt5HtgqKFHrHmsp2bY7ww?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

This new flow represents the treasury selling tokens to the market, so its Source is “Treasury” and its destination is the “Market”.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfqQ6FDqkQ79MEWXopVYJX2Pi-tMuT99ozCR-AlVru7lLDaj807aZFAEQBA3jvXSprv7Zhzp2A7fKm6l-3w-ObPypVANKtBmkklb1S5-vJecbl8UnymekMYSO9DpTyepWdnRTxwgT4pJlu9dhVvG2XEO4Ia?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

#### Step 2: Changes the equations&#x20;

Next, we need to fill in the equation for the new token flow. The appropriate row in the equations table was created automatically with a default value of 0 when we added the new token flow in the previous section.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeJ1aFG9P5CI5pC3zDxggnOgge9BJYOnZIEwmOUh6zs3O8KwwRJqggpcDpGQ5LflqxSPcGpXKZ7CrdBnnqvLo2gKpPB1UgQRjuOMWddfmn37tYHC8s4nKklSUHUd0vxkGY9QxH74QZanaznTYenlYZfgqE?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

We want this selling flow to increase with the usage of the platform, since it’s meant to cover infrastructure costs.. We can do this by adding a multiplier on TDP\_vp\_1\_growth\_param to calculate the total infrastructure expenses. Let’s consider that we spend $0.01 USD for each dollar lent, which we will introduce as a new parameter, SP\_vp\_expense\_operations. Additionally, since token flows are always defined as token units per time step, and the infrastructure expenses are in dollars per month, we need to multiply by the time step in months and divide by the token price or, in this case, an average of it.&#x20;

Now, the system will look like this:

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd57FPOuSf26xg7FjNLVCLcFuaA0Dc5oEXYxU-f-VUl9u3h3zbKLzdjxI7mb_dFtMyA-TbjoQyCRWxDTjOztespQjAV_CY9ucxV2ijuNtmU3lWExptmSoe1IfeqIYYAm-8fz75tLkv5FvlKOAgOiOdQ_XX-?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

Note that the platform indicates that there is an error in the new equation we wrote. This is because we introduced a new static parameter (SP\_vp\_expense\_operations) that we have not yet defined in the “Input Parameters'' section. We will do that next in order to fix this error.

#### Step 3: Changes in the input parameters

We simply need to introduce a new static parameter for the parameter we defined in the equation, and give it a default value.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd1Bv89kYarfpd4WsDNAH7YCpKFlF0eq_JSpKMJP6UtHjJUqs3Tfxp2n0c0ccpL6pIhTRy3lOT-hDo4RNtIkuE28ONHFdPCCVDpM2I15PRMc1EEgzVoFeu84ElFdUIsGxHVJk2f-aq_IrzMytjRrSHvLxhs?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

Remember that to let the user change a static parameter and test it, we will need to add it into the sidebar section.&#x20;

#### Step 4: Equations debugging&#x20;

Now we can go to the simulation preview and check whether the numbers make sense.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdUWM8JlE6niDVsUnCPQBNcLqS0uUo_S6nb1fZ9rMHt3XSm75Ox-0a1XYqCNrcj3Ulf5AXCzKM0vqZdq0zJsJNLSpWiPsAloj6CNzTTRZmAFdGRfs-UmLnj-mC4bsUPCEmUEzQmUWh9kN7ywn2m4DGcSj3f?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

In this example, we see that there is a moment when the treasury runs out of tokens, meaning the protocol does not have enough tokens to pay the expenses we introduced.

There are two possibilities:

1. The simulation is well configured, indicating a problem with the treasury expenditure, which will run out of tokens quickly. This insight would mean we need to rethink the treasury expenditure.
2. The simulation is ill-formed: Here, we realize that spending 0.01 USD in infrastructure for each dollar exchanged makes no sense, and that we actually meant 0.0001 USD.

After applying the change, the simulation runs normally.

We can now confirm the impact on the economy by looking at the buying and selling pressure charts ("Treasury sales to cover infrastructure", highlighted in red in the chart below).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdpulvc4nZRxyevj9CE2Inu143NUp6j4FQsTN5hXGbKPpM_VrEDp-_Q0ndQlrvNigKSyIru_32UctH-VYCaobmcAQauOhXqBhcRVgANDewYj390tYVm0skbr_Ds8AQLG-ir1GtWgRtROyonskMryJl_tOo?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

\


Alternatively, we could create a custom metric and graph to visualize it. We will do that next.

#### Step 5: Configuration of reports&#x20;

We can configure a report to provide a specific insight to the end user, or for internal consumption. This time, we will create a new graph for the report to understand treasury expenditure.

On the metrics screen, we introduce the flow that represents the token sale. We want to report this sale monthly, so we use the appropriate groupby function. Additionally, we need to represent the amount in USD, so we convert the tokens to USD.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXexJTUCiwloGXHQ0aoXXrIJkVj8-qa8MqYy4AfBwEtfbB3gi7SxxyorF3K0Arst842DBbzzQEwCJu4fI8cVMRtBvHLb0im5sH9PT5TaWmnCJI8dGXU7qYvETDqxIhea-1xQyg11GDws0hEGHctf2EICAQs?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

Now that we have the metric ready, we can open the “Results Graph Configuration” and create the new graph.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXefs1r2rF3wG8JVG8TOhEOyzyvd-3Vo3zu7it_6WxLRH3hbijT_1WhgISkDaYVYnswAfNOc9sedMuykRip1Lb_ncJl7igoW6lMmyUi5_IWtj26wZnhoo-13Qdz7YSWAngnKaR0YrW7LXMEA10MfWsl5hEp1?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

We add our newly created metric as the variable to plot.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXekglGiwKztbAgMLJTXFz-WjrPPN7U3QBcLfQex2FZLnKzsDh56xQwnwuOi1EE4RoPyniZA0g8n6_JKIwPyHmKQOBRP_859xEdmtmUL-NRypoXQNbI1tgnVYtR1XY0OC0cJuDEg-TftyacKlwTc7FaLVbwv?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

And then we add it in the “Results Graphs Configuration”

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf_LsdEF9LFAn1RVgr2ECoxqsEiI8t_fMCJu_ou-MC9XMWWcsvo__TACepXX3Dty87oz7SeX847w4q5uwYT5Oxs-5sLlU_mMcHNjpNmbIOXuoxXR-uvC4vbaEyey03g4VmGGfgfFHdwMiQ2sccws406Wpeu?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

Finally, we are ready to “Go to results preview”.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfoYnSJ_NLKC8OSb_CY6XW3lQ1mX6HQeS4Qrdea-TbMd-rTmjaM0SYa4uO_VGBN8Ysg1FU6h7El14c2qNdwx-4kHQmA_BCfzlPXL33ybrAugJqJ9qwyBU2sDK4qIhfgI6p9LSNpxu0fOEqOaiYTP4T8xiJI?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

Once we verify the impact is as expected, we should add the newly created input parameter in the “Sidebar Configuration” to let the user test it, since by default, the input parameters created in the setup are not visible from the dashboard. In this case, we can add it into the “User behavior” section.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXejg3GREAA0uwVpKZLwFvtgkLHqo3nPM92O-fWu0w9BU2oTiNeA0LTsBhXu7yEzxJUqoB4jDht0w-yHTMn30jPqn3yaUgiY11w2jqHy6ics5lKLvIUFat1r_6PnUgcM1wXG3acryTsRq9uOZuPYgNu5bgyf?key=gBdoBauPQRHBeCJCAQCSUw" alt=""><figcaption></figcaption></figure>

With that, we will have completed a full iteration of the token economy.
