Server Stock & Crypto Markets
Each Discord server running Yulya has its own sovereign stock and cryptocurrency exchange. Share prices are mathematically determined by an Algorithmic Market Maker (AMM) linear bonding curve tied directly to community chat volume.
📊 How Server Crypto Works
Instead of relying on random numbers or external crypto feeds, Yulya generates an authentic internal market for your server:
Every share bought permanently increases the price of future shares by 0.1 Yulu. Selling shares symmetrically lowers the price curve.
Every 1,000 Yulu generated from chatting members increases the permanent baseline floor price by 1.0 Yulu.
Trades are broadcast in real time across connected web dashboards via /ws/dashboard with zero polling delay.
📐 Mathematical Formulas & AMM Curve
All pricing calculations are verified directly from modules/database.py:
1. Instantaneous Share Price Formula
current_price = max(10.0, 10.0 + (circulating_shares * 0.1) + (chat_earnings * 0.001))
Base Floor Price: 10.0 Yulu.
Circulating Multiplier: Each share in circulation adds +0.1 Yulu to the spot price.
Chat Volume Multiplier: Every 1,000 Yulu earned from chatting adds +1.0 Yulu (chat_earnings * 0.001).
2. Buying Shares: Total Cost Integral
Because purchasing multiple shares moves the spot price upward during the trade, Yulya evaluates the exact discrete integral of the linear bonding curve:
base_price = 10.0 + (chat_earnings * 0.001)
total_cost = (base_price * amount) + (current_shares * amount * 0.1) + (amount * (amount - 1) * 0.05)
3. Selling Shares: Total Liquidation Return
Selling shares consumes the bonding curve in reverse, returning liquidity back to the seller's wallet:
base_price = 10.0 + (chat_earnings * 0.001)
total_return = (base_price * amount) + ((current_shares - 1) * amount * 0.1) - (amount * (amount - 1) * 0.05)
total_return = max(10.0 * amount, total_return) # Guaranteed floor protection
max(10.0 * amount, total_return)).
⚡ Trading Mechanics & Slippage Protection
The /crypto Command
Running /crypto opens the server's interactive dashboard.
It generates a rendered PNG chart showcasing historical candlestick trends, 24-hour volume,
your average buy-in cost, and unrealized profit/loss.
| Parameter / Rule | Limit | Rationale |
|---|---|---|
| Max Trade Size | 100,000 Shares | Prevents extreme single-transaction market manipulation and slippage anomalies. |
| Distributed Trade Locking | Lock per Server ID | Acquires an atomic trade mutex (acquire_trade_lock) to eliminate race conditions between simultaneous trades. |
| Average Buy Price Tracking | Weighted Average | Tracks your cost basis: new_avg = ((old_avg * old_shares) + total_cost) / new_shares. |
🌱 5-Minute Organic Growth Loop
To maintain an active and engaging economic environment even during off-peak hours, Yulya executes a background simulation loop every 5 minutes:
- Simulates micro-fluctuations in trading volume based on the server's historical chat cadence.
- Records official timestamped price points in
crypto_history_collection. - Pushes live chart updates to the web dashboard and Discord server embeds.