2024-12-16 22:07:03 +01:00

168 lines
3.7 KiB
Plaintext

{
"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": [
"params = SimulationParameters(\n",
" num_blocks=int(days * 24 * 60 * 60 / 12), # number of blocks in \"days\",\n",
" demand_sizes=[0, 50, 1000, 2000], # very low, normal, very high demand\n",
" demand_probabilities=[0.02, 0.06, 0.86, 0.06], # they must sum to 1\n",
" fee_cap_range=(0.05, 0.1), # in percentage, mean and std deviation\n",
" max_tip_pct=0.1,\n",
" scale_block_size_limits=(0.05, 0.1),\n",
" probability_stop_below_gas_limit=0.5,\n",
" purge_after=2\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_EIP\", \"price_StableFee\"]].plot(\n",
" title=\"EIP-1559 vs StableFee price\",\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
}