Token Economy Simulation with Bonding Curves and Affiliate Dynamics

Token Economy Simulation with Bonding Curves and Affiliate Dynamics

Overview

This project simulates a dynamic token economy with multiple cryptocurrencies, bonding curve mechanisms, and affiliate marketing dynamics. It demonstrates how token prices evolve based on supply/demand through different bonding curves, while affiliates earn commissions and adapt their strategies in real-time.

Key Features

Installation

  1. Requirements
  2. Python 3.8+
  3. NumPy

  4. Setup bash pip install numpy

Usage

Run the simulation with default parameters:

python main.py

Customize the simulation:

python main.py \
  --num_simulation_steps 500 \
  --num_tokens 8 \
  --num_affiliates 10 \
  --initial_price 2.0 \
  --initial_commission_rate 0.15

Configuration Options

Command Line Arguments

Parameter Description Default
--num_simulation_steps Total steps to simulate 100
--num_tokens Number of distinct tokens 5
--num_affiliates Number of affiliates 5
--initial_price Starting price for all tokens 1.0
--initial_commission_rate Base affiliate commission rate 0.10

Key Constants (constants.py)

INITIAL_SUPPLY = 10000        # Starting token supply
TRANSACTION_FEE_RATE = 0.0025 # 0.25% per trade
BURN_RATE = 0.0002            # 0.02% token burn
COMMISSION_DYNAMICS_STEP = 10 # Commission adjustment interval
WHALE_INVESTMENT_RANGE = (5000, 10000) # Whale capacity bounds

Simulation Mechanics

Token Dynamics

  1. Price Calculation python # Example exponential curve price = a * e^(k * supply)
  2. Supply Changes
  3. Buys increase supply, sells decrease supply
  4. Automatic fee deduction and token burns

  5. Bonding Curve Evolution

  6. Random curve selection every 500-1000 steps
  7. Parameter adjustments every 20 steps

Affiliate Behavior

  1. Commission Adjustments
  2. Rates adjusted every 10 steps based on: python avg_investment > 50 ? rate += 0.0005 : rate -= 0.0005
  3. Trading Strategies
  4. Regular affiliates: 1-2 trades/step
  5. Whale affiliates: Large bulk trades (5,000-10,000 base currency)
  6. Automatic portfolio rebalancing (5% sell probability/step)

  7. Wallet Management

  8. Track multiple token balances
  9. Base currency accounting
  10. Historical earnings tracking

Output Example

--- Token Summary ---

Token: Token_3
  Final Price: 4.72
  Final Supply: 14256.32
  Final Bonding Curve: exponential_bonding_curve

--- Affiliate Summary ---

Affiliate: 4
  Final Base Currency: 3842.15
  Final Commission Rate: 0.1125
  Total Earned: 642.78

Source Code

Browse the source repository