-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
142 lines (130 loc) · 3.93 KB
/
config.py
File metadata and controls
142 lines (130 loc) · 3.93 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
"""
AddressTrackerBot v3 - Centralized configuration and chain definitions.
"""
import os
from dotenv import load_dotenv
# Load .env from script directory
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
load_dotenv(os.path.join(BASE_DIR, '.env'))
# Telegram
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN', '')
# Infura
INFURA_PROJECT_ID = os.getenv('INFURA_PROJECT_ID', '')
# Database
DB_PATH = os.path.join(BASE_DIR, 'tracker.db')
# Monitoring
POLL_INTERVAL = 60 # seconds between monitoring cycles
MAX_BLOCK_RANGE = 50 # max blocks to scan per cycle per address
# Rate limiting
RATE_LIMIT_COMMANDS = 30 # max commands per window
RATE_LIMIT_WINDOW = 60 # window in seconds
# Price cache
PRICE_CACHE_TTL = 300 # 5 minutes
# Pagination
HISTORY_PAGE_SIZE = 10
# Chain definitions
# Each chain has: name, chain_id, rpc_url_template (uses INFURA_PROJECT_ID),
# native_symbol, coingecko_id, coingecko_platform, explorer_url, icon
CHAINS = {
1: {
'name': 'Ethereum',
'chain_id': 1,
'rpc_url': os.getenv(
'RPC_ETHEREUM',
f'https://mainnet.infura.io/v3/{INFURA_PROJECT_ID}'
),
'ws_url': os.getenv(
'WS_ETHEREUM',
f'wss://mainnet.infura.io/ws/v3/{INFURA_PROJECT_ID}'
),
'native_symbol': 'ETH',
'coingecko_id': 'ethereum',
'coingecko_platform': 'ethereum',
'explorer_url': 'https://etherscan.io',
'icon': '\u25C6',
},
137: {
'name': 'Polygon',
'chain_id': 137,
'rpc_url': os.getenv(
'RPC_POLYGON',
f'https://polygon-mainnet.infura.io/v3/{INFURA_PROJECT_ID}'
),
'ws_url': os.getenv(
'WS_POLYGON',
f'wss://polygon-mainnet.infura.io/ws/v3/{INFURA_PROJECT_ID}'
),
'native_symbol': 'MATIC',
'coingecko_id': 'matic-network',
'coingecko_platform': 'polygon-pos',
'explorer_url': 'https://polygonscan.com',
'icon': '\u25B3',
},
42161: {
'name': 'Arbitrum',
'chain_id': 42161,
'rpc_url': os.getenv(
'RPC_ARBITRUM',
f'https://arbitrum-mainnet.infura.io/v3/{INFURA_PROJECT_ID}'
),
'ws_url': os.getenv(
'WS_ARBITRUM',
f'wss://arbitrum-mainnet.infura.io/ws/v3/{INFURA_PROJECT_ID}'
),
'native_symbol': 'ETH',
'coingecko_id': 'ethereum',
'coingecko_platform': 'arbitrum-one',
'explorer_url': 'https://arbiscan.io',
'icon': '\u2B21',
},
8453: {
'name': 'Base',
'chain_id': 8453,
'rpc_url': os.getenv(
'RPC_BASE',
f'https://base-mainnet.infura.io/v3/{INFURA_PROJECT_ID}'
),
'ws_url': os.getenv(
'WS_BASE',
f'wss://base-mainnet.infura.io/ws/v3/{INFURA_PROJECT_ID}'
),
'native_symbol': 'ETH',
'coingecko_id': 'ethereum',
'coingecko_platform': 'base',
'explorer_url': 'https://basescan.org',
'icon': '\u25CF',
},
}
# ERC-20 Transfer event topic
ERC20_TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
# Minimal ERC-20 ABI for balanceOf, name, symbol, decimals
ERC20_ABI = [
{
"constant": True,
"inputs": [{"name": "_owner", "type": "address"}],
"name": "balanceOf",
"outputs": [{"name": "balance", "type": "uint256"}],
"type": "function"
},
{
"constant": True,
"inputs": [],
"name": "name",
"outputs": [{"name": "", "type": "string"}],
"type": "function"
},
{
"constant": True,
"inputs": [],
"name": "symbol",
"outputs": [{"name": "", "type": "string"}],
"type": "function"
},
{
"constant": True,
"inputs": [],
"name": "decimals",
"outputs": [{"name": "", "type": "uint8"}],
"type": "function"
},
]