Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Gas Function Smoother #2301

Open
adamkrellenstein opened this issue Oct 4, 2024 · 0 comments
Open

Make Gas Function Smoother #2301

adamkrellenstein opened this issue Oct 4, 2024 · 0 comments

Comments

@adamkrellenstein
Copy link
Member

adamkrellenstein commented Oct 4, 2024

import matplotlib.pyplot as plt
import numpy as np
import math

k = .2 # Sigmoid Steepness
m = 1.5 # Exponent
n = 100 # Exponential Scaling Factor


def calculate_fee(x, a, b, base_fee):

    def sigmoid(t):
        midpoint = (b - a) / 2 + a
        return base_fee / (1 + math.exp(-k * (t - midpoint)))

    if x <= a:
        return 0
    elif x <= b:
        return sigmoid(x)
    else:
        return base_fee + ((x-b)**(m))/n

# Parameters
a = 3
b = 15
base_fee = 1
k = 1

# Generate values for x
x_values = np.linspace(0, 40, num=5000)
y_values = [calculate_fee(x, a, b, base_fee) for x in x_values]

# Plot the function
plt.plot(x_values, y_values, label='Fee Curve')
plt.axvline(x=a, color='r', linestyle='--', label='Lower Threshold (a)')
plt.axvline(x=b, color='g', linestyle='--', label='Upper Threshold (b)')
plt.xlabel('Number of Transactions per Period (x)')
plt.ylabel('Calculated Fee')
plt.title('Fee Curve for a = 3, b = 15, base_fee = 1, k = 10')
plt.legend()
plt.grid(True)
plt.show()
Screenshot 2024-10-04 at 11 31 38 AM

We should also add some rounding, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant