{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Transaction Fees on Nomos" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "\n", "import plotly.express as px\n", "import pandas as pd\n", "pd.options.plotting.backend = \"plotly\"\n", "from simulation import run_simulation\n", "from simulation_parameters import SimulationParameters\n", "from tx_fees_models import PROTOCOL_CONSTANTS" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "days = 1" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "demand = 5000\n", "\n", "std_dev = 0.01/100.\n", "variable_gas_limits = True\n", "below_gas_limit = 0.5" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "params = SimulationParameters(\n", " num_blocks=int(days * 24 * 60 * 60 / 12), # number of blocks in \"days\",\n", " demand_sizes=[demand], # very low, normal, very high demand\n", " demand_probabilities=[1.], # they must sum to 1\n", " fee_cap_range=(0., std_dev), # in percentage, mean and std deviation\n", " max_tip_pct=0, # this only affects the EIP-1559 simulation\n", " scale_block_size=0.05,\n", " probability_stop_below_gas_limit=below_gas_limit,\n", " purge_after=4,\n", " variable_gas_limits=variable_gas_limits\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_stats_merged, df_chain_stats_merged = run_simulation(params)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_stats_merged[[\"price_StableFee\", \"price_EIP\"]].plot(\n", " title=f'''\n", "StableFee vs EIP-1559 - {demand} txs -\n", "{\"variable\" if variable_gas_limits else \"fixed\"} gas/tx -\n", "{std_dev * 100:.2e}% standard deviation - \n", "{below_gas_limit * 100:.2f}% chance to stop below gas limit\n", "''',\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_stats_merged[[\"num_tx_EIP\", \"num_tx_StableFee\"]].plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_stats_merged[[\"tot_paid_EIP\", \"tot_paid_StableFee\"]].plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_stats_merged[[\"demand_size_EIP\"]].plot.bar()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "(df_stats_merged[\"num_tx_EIP\"].sub(df_stats_merged[\"num_tx_StableFee\"]) > 0).value_counts()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df_chain_stats_merged[[\"tot_gas_used_EIP\", \"tot_gas_used_StableFee\"]].plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig = df_chain_stats_merged[\"tot_gas_used_EIP\"].plot.bar()\n", "fig.add_shape(\n", " type=\"line\",\n", " x0=0,\n", " y0=PROTOCOL_CONSTANTS[\"TARGET_GAS_USED\"],\n", " x1=len(df_chain_stats_merged),\n", " y1=PROTOCOL_CONSTANTS[\"TARGET_GAS_USED\"],\n", " line=dict(color=\"red\", width=2)\n", ")\n", "\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "python-3.12-abm", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.0" } }, "nbformat": 4, "nbformat_minor": 2 }