Price Calculation
Detailed breakdown of the bonding curve's quadratic pricing algorithm and dynamic tax computation.
Overview
The bonding curve uses a quadratic integral for pricing. This means each additional lot costs slightly more than the last, creating a smooth price curve rather than discrete price levels.
Algorithm
Given supply_lots (current total lots including deployer's initial 60,000) and delta_lots (number of lots to trade):
## Step 1: Scale to internal units
n = delta_lots × 1000
x = (supply_lots - INITIAL_SUPPLY_LOTS) × 1000
## Step 2: Determine range
if is_buy:
x_start = x
x_end = x + n
else: # sell
x_start = x - n
x_end = x
## Step 3: Quadratic area calculation
quad = PRICE_SLOPE × (x_end² - x_start²) / TWO_TIMES_CAP
linear = P_START × n
base = quad + linear
## Step 4: Dynamic tax
avg_supply = (x_start + x_end) / 2
avg_supply = min(avg_supply, ADDITIONAL_CAP_TOKENS_BASE)
tax_rate_bp = T_START_BP - (TAX_DECREASE_BP × avg_supply / ADDITIONAL_CAP_TOKENS_BASE)
tax_rate_bp = max(tax_rate_bp, T_END_BP)
tax = base × tax_rate_bp / BP_DENOMINATOR
## Step 5: Final price
if is_buy:
total = base + tax # user pays this
else:
total = base - tax # user receives this
Example Calculation (Base chain)
Buying 100 lots when current supply is 100,000 lots (40,000 lots sold beyond initial):
## Inputs
supply_lots = 100,000
delta_lots = 100
P_START = 12,000,000
PRICE_SLOPE = 84,108,108
INITIAL_SUPPLY_LOTS = 60,000
## Step 1
n = 100 × 1000 = 100,000
x = (100,000 - 60,000) × 1000 = 40,000,000
## Step 2 (buy)
x_start = 40,000,000
x_end = 40,100,000
## Step 3
x_start² = 1,600,000,000,000,000
x_end² = 1,608,010,000,000,000
diff = 8,010,000,000,000
quad = 84,108,108 × 8,010,000,000,000 / 1,480,000,000
= 455,129,540,540 (approx)
linear = 12,000,000 × 100,000 = 1,200,000,000,000
base = 455,129,540,540 + 1,200,000,000,000
= 1,655,129,540,540 wei ≈ 0.00000166 ETH
## Step 4
avg_supply = (40,000,000 + 40,100,000) / 2 = 40,050,000
tax_rate_bp = 1200 - (1080 × 40,050,000 / 740,000,000)
= 1200 - 58.4 ≈ 1142 bps (11.42%)
tax = 1,655,129,540,540 × 1142 / 10,000 ≈ 188,995,713,330
## Step 5
total = 1,655,129,540,540 + 188,995,713,330
= 1,844,125,253,870 wei ≈ 0.00000184 ETH
Price Properties
- Monotonically increasing: Each lot costs more than the last
- Deterministic: Same inputs always produce same outputs, no oracle dependency
- Tax spread: Buying at price P and immediately selling yields less than P (spread = 2 × tax)
- Floor protection: Cannot sell below INITIAL_SUPPLY_LOTS (deployer's allocation)
- Tax convergence: Tax rate approaches T_END_BP (1.2%) as supply nears max
Precision Notes
All arithmetic is integer-only (no floating point). The × 1000 scaling in step 1 provides sufficient precision for the quadratic calculation. Results are in wei (10−18 ETH/BNB). The quote_buy_price() and quote_sell_price() view functions return exact values that the buy() and sell() functions expect.