123 lines
4.5 KiB
Python
Executable File
123 lines
4.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Currency Ledger Report Generator
|
|
Creates summary reports for community transparency
|
|
"""
|
|
|
|
import csv
|
|
import yaml
|
|
from datetime import datetime
|
|
import os
|
|
from collections import defaultdict
|
|
|
|
def generate_sc_summary():
|
|
"""Generate SC summary report"""
|
|
print("📊 SMARTUP CREDITS SUMMARY REPORT")
|
|
print("=" * 40)
|
|
|
|
ledger_file = os.path.join(os.path.dirname(__file__), '..', 'ledger', 'smartup-credits', 'transactions.csv')
|
|
|
|
try:
|
|
with open(ledger_file, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
|
|
user_balances = defaultdict(int)
|
|
total_minted = 0
|
|
total_redeemed = 0
|
|
transaction_count = 0
|
|
|
|
for row in reader:
|
|
if row['type'] == 'SC':
|
|
amount = int(row['amount'])
|
|
user_balances[row['to']] += amount
|
|
total_minted += amount
|
|
transaction_count += 1
|
|
elif row['type'] == 'REDEEM':
|
|
amount = int(row['amount'])
|
|
user_balances[row['from']] -= amount
|
|
total_redeemed += amount
|
|
transaction_count += 1
|
|
|
|
print(f"Total SC Minted: {total_minted}")
|
|
print(f"Total SC Redeemed: {total_redeemed}")
|
|
print(f"SC Outstanding: {total_minted - total_redeemed}")
|
|
print(f"Total Transactions: {transaction_count}")
|
|
print(f"Active Contributors: {len([u for u in user_balances if user_balances[u] > 0])}")
|
|
|
|
# Top contributors
|
|
if user_balances:
|
|
print("\n🏆 TOP SC EARNERS:")
|
|
sorted_users = sorted(user_balances.items(), key=lambda x: x[1], reverse=True)
|
|
for i, (user, balance) in enumerate(sorted_users[:5]):
|
|
if balance > 0:
|
|
print(f"{i+1}. {user}: {balance} SC")
|
|
|
|
except FileNotFoundError:
|
|
print("❌ No SC transactions found")
|
|
except Exception as e:
|
|
print(f"❌ Error generating SC report: {e}")
|
|
|
|
def generate_treasury_report():
|
|
"""Generate treasury health report"""
|
|
print("\n💰 TREASURY HEALTH REPORT")
|
|
print("=" * 30)
|
|
|
|
treasury_file = os.path.join(os.path.dirname(__file__), '..', 'ledger', 'treasury', 'balance.csv')
|
|
|
|
try:
|
|
with open(treasury_file, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
rows = list(reader)
|
|
|
|
if rows:
|
|
latest = rows[-1]
|
|
eur_balance = float(latest['total_eur_balance'])
|
|
sc_outstanding = int(latest['sc_outstanding'])
|
|
sc_liability = float(latest['sc_liability_eur'])
|
|
|
|
print(f"💶 EUR Treasury: €{eur_balance:,.2f}")
|
|
print(f"🪙 SC Outstanding: {sc_outstanding:,} SC")
|
|
print(f"💸 SC Liability: €{sc_liability:,.2f}")
|
|
|
|
if eur_balance > 0:
|
|
coverage_ratio = eur_balance / sc_liability if sc_liability > 0 else float('inf')
|
|
print(f"📊 Coverage Ratio: {coverage_ratio:.2f}x")
|
|
|
|
if coverage_ratio >= 1.0:
|
|
print("✅ Full SC redemption possible")
|
|
else:
|
|
redemption_capacity = int(eur_balance)
|
|
print(f"⚠️ Partial redemption: €{redemption_capacity:,} available")
|
|
|
|
# 3x rule check
|
|
max_allowed_sc = eur_balance * 3
|
|
print(f"🛡️ 3x Rule: {sc_outstanding:,} / {max_allowed_sc:,.0f} SC allowed")
|
|
|
|
if sc_outstanding <= max_allowed_sc:
|
|
print("✅ 3x Rule: COMPLIANT")
|
|
else:
|
|
print("🚨 3x Rule: VIOLATION")
|
|
|
|
else:
|
|
print("⚠️ Treasury initialized but no balance records")
|
|
|
|
except FileNotFoundError:
|
|
print("❌ No treasury records found")
|
|
except Exception as e:
|
|
print(f"❌ Error generating treasury report: {e}")
|
|
|
|
def main():
|
|
"""Generate all reports"""
|
|
print("📈 SMARTUP ZERO FINANCIAL REPORTS")
|
|
print(f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
|
print("=" * 50)
|
|
|
|
generate_sc_summary()
|
|
generate_treasury_report()
|
|
|
|
print("\n" + "=" * 50)
|
|
print("💡 All ledger data is public and auditable in git history")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|