import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import minimize
# Function to simulate a linear bonding curve with derived k
def linear_bonding_curve(supply, initial_price, max_supply, target_price_at_max_supply):
k = (target_price_at_max_supply - initial_price) / max_supply
return initial_price + k * supply
# Function to simulate an exponential bonding curve with derived a and b
def exponential_bonding_curve(supply, initial_price, max_supply, target_price_at_max_supply):
a = target_price_at_max_supply - initial_price
b = np.log(target_price_at_max_supply / initial_price) / max_supply
return initial_price + a * (np.exp(b * supply) - 1) / (np.exp(b * max_supply) - 1)
# Function to simulate a logarithmic bonding curve with derived a and b
def logarithmic_bonding_curve(supply, initial_price, max_supply, target_price_at_max_supply):
a = target_price_at_max_supply - initial_price
b = (np.exp((target_price_at_max_supply - initial_price) / a) - 1) / max_supply
return initial_price + a * np.log(b * supply + 1)
# Parameters
initial_price = 0.0001
max_supply = 1000e6
target_price_at_max_supply = 0.01
# Define the supply range
supply = np.linspace(0, max_supply, 100)
# Calculate the bonding curves
linear_curve = linear_bonding_curve(supply, initial_price, max_supply, target_price_at_max_supply)
exponential_curve = exponential_bonding_curve(supply, initial_price, max_supply, target_price_at_max_supply)
logarithmic_curve = logarithmic_bonding_curve(supply, initial_price, max_supply, target_price_at_max_supply)
# Plot the bonding curves
plt.figure(figsize=(10, 6))
plt.plot(supply, linear_curve, label="Linear", color='blue')
plt.plot(supply, exponential_curve, label="Exponential", color='green')
plt.plot(supply, logarithmic_curve, label="Logarithmic", color='red')
# Add labels and title
plt.title("Bonding Curves")
plt.xlabel("Supply")
plt.ylabel("Price")
plt.legend()
# Show the plot
plt.grid(True)
plt.show()
Click Run or press shift + ENTER to run code