-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
120 lines (104 loc) · 5.9 KB
/
config.py
File metadata and controls
120 lines (104 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""
config.py
=========
Central configuration file for the DeFi Risk Simulation Lab.
All magic numbers live here — agents, model, and protocol all import
from this file so there is exactly one place to tune the simulation.
"""
import os
from pathlib import Path
# Load .env file FIRST so os.getenv() can read it.
# python-dotenv is optional — if not installed, env vars must be set manually.
try:
from dotenv import load_dotenv
_env_path = Path(__file__).parent / ".env"
load_dotenv(dotenv_path=_env_path, override=False)
except ImportError:
pass # python-dotenv not installed; rely on OS environment
# ------------------------------------------------------------------ #
# AMM POOL — INITIAL STATE #
# ------------------------------------------------------------------ #
# Constant-product AMM: reserve_usdc * reserve_eth = k
# Starting price = 100_000 / 100 = 1,000 USDC per ETH
INITIAL_RESERVE_USDC: float = 100_000.0 # USDC in the pool
INITIAL_RESERVE_ETH: float = 100.0 # ETH in the pool
# ------------------------------------------------------------------ #
# AGENT WALLET BALANCES (each agent starts with these) #
# ------------------------------------------------------------------ #
BALANCE_RANGE_RETAIL = (100.0, 2000.0)
BALANCE_RANGE_MID_TIER = (2000.0, 20000.0)
BALANCE_RANGE_WHALE = (50000.0, 500000.0)
BALANCE_RANGE_ARBITRAGE = (20000.0, 250000.0)
BALANCE_RANGE_MEV = (10000.0, 200000.0)
BALANCE_RANGE_MARKET_MAKER = (50000.0, 500000.0)
BALANCE_RANGE_INSTITUTIONAL = (250000.0, 1000000.0)
# ------------------------------------------------------------------ #
# AGENT ACCOUNT ALLOCATION (100 Accounts Total) #
# ------------------------------------------------------------------ #
ACCOUNTS_RETAIL: int = 80
ACCOUNTS_MID_TIER: int = 10
ACCOUNTS_WHALE: int = 2
ACCOUNTS_ARBITRAGE: int = 3
ACCOUNTS_MEV: int = 1
ACCOUNTS_MARKET_MAKER: int = 1
ACCOUNTS_INSTITUTIONAL: int = 1
TOTAL_ACCOUNTS: int = 100
# ------------------------------------------------------------------ #
# PRE-SEEDED BORROWERS #
# These are virtual addresses (not Mesa agents) that already have #
# active loan positions. The Liquidator scans these each step. #
# ------------------------------------------------------------------ #
NUM_BORROWERS: int = 5 # addresses pre-seeded with debt
# How close to insolvency are the pre-seeded borrowers?
# 1.0 = on the edge; 1.2 = 20% buffer; < 1.0 = already liquidatable
BORROWER_START_HEALTH_FACTOR: float = 1.05 # very close to liquidation
# ------------------------------------------------------------------ #
# ORACLE PRICE PARAMETERS #
# ------------------------------------------------------------------ #
ORACLE_INITIAL_PRICE: float = 1_000.0 # USD per ETH
ORACLE_VOLATILITY: float = 0.02 # ±2% random walk per step
ORACLE_DRIFT: float = 0.0 # net directional drift per step
# ------------------------------------------------------------------ #
# AGENT BEHAVIOUR PARAMETERS #
# ------------------------------------------------------------------ #
# Arbitrageur
ARB_THRESHOLD: float = 0.01 # trigger at > 1% price diff
ARB_SWAP_FRACTION: float = 0.10 # swap up to 10% of pool reserve
# Whale
WHALE_TRIGGER_PROB: float = 0.05 # 5% chance of market move per step
WHALE_SWAP_FRACTION: float = 0.30 # swaps ≥ 30% of the pool reserve
# Retail Trader Parameters (Now using BALANCE_RANGE_RETAIL for funding)
# Liquidator
LIQUIDATION_LTV_RATIO: float = 0.80 # max 80% loan-to-value
LIQUIDATION_THRESHOLD: float = 0.85 # 85% before liquidation
LIQUIDATION_BONUS: float = 0.05 # 5% bonus for liquidators
# ------------------------------------------------------------------ #
# SIMULATION #
# ------------------------------------------------------------------ #
SIMULATION_STEPS: int = 50
RANDOM_SEED: int = 42
# ------------------------------------------------------------------ #
# DATA PIPELINE #
# ------------------------------------------------------------------ #
DB_PATH: str = "defi_simulation.db"
CSV_PATH: str = "simulation_log.csv"
# ------------------------------------------------------------------ #
# GROQ — WILDCARD AGENT #
# ------------------------------------------------------------------ #
GROQ_API_KEY: str = os.getenv("GROQ_API_KEY", "")
GROQ_MODEL: str = "llama-3.1-8b-instant" # Groq hosted Llama-3.1 8B (replaces decommissioned llama3-8b-8192)
GROQ_TIMEOUT: int = 10 # seconds before fallback
# ------------------------------------------------------------------ #
# BLOCKCHAIN — HARDHAT INTEGRATION #
# ------------------------------------------------------------------ #
# Set BLOCKCHAIN_ENABLED=true in .env to enable on-chain audit trails.
# When disabled (default), everything runs as pure Python mock.
BLOCKCHAIN_ENABLED: bool = os.getenv("BLOCKCHAIN_ENABLED", "false").lower() == "true"
HARDHAT_RPC_URL: str = os.getenv("HARDHAT_RPC_URL", "http://127.0.0.1:8545")
# deploy_output.json is written here by `npx hardhat run scripts/deploy.js`
DEPLOY_OUTPUT_PATH: str = str(__import__('pathlib').Path(__file__).parent / "deploy_output.json")
# ------------------------------------------------------------------ #
# SUPABASE — AUTH & STORAGE #
# ------------------------------------------------------------------ #
SUPABASE_URL: str = os.getenv("SUPABASE_URL", "https://luntofzfrggwjlvjirsi.supabase.co")
SUPABASE_KEY: str = os.getenv("SUPABASE_KEY", "")