-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.py
More file actions
141 lines (111 loc) · 4.7 KB
/
Copy pathenv.py
File metadata and controls
141 lines (111 loc) · 4.7 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
import logging
import os
from typing import Optional
from pydantic import Field, model_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
logger = logging.getLogger(__name__)
class Settings(BaseSettings):
algo_network: str
algo_mnemonic: str
rekeyed_mnemonic: Optional[str] = None
algod_address: str
algod_token: str
algo_indexer_address: str
outbound_asset_transfer_max_fee_microalgos: int = Field(
default=1_000,
ge=1_000,
le=1_000_000,
)
server_port: int
workers_num: int
api_password: str
mongodb_host: str
mongodb_port: int
mongodb_username: Optional[str] = None
mongodb_password: Optional[str] = None
new_db_name: str = "cometa-updated"
logging_level: str = "INFO"
logging_format: str = "[%(asctime)s][%(levelname)s][%(filename)s] %(message)s"
logging_date_format: str = "%I:%M:%S"
return_all_user_pools: bool = False
# List of pool IDs that should always be returned
always_return_pool_ids: list[int] = [
1705298492,
1713659453,
1846754940,
1911323813,
1911383471,
3470204961,
3470209137,
]
return_all_cometa_pools_to_addresses: list[str] = []
# Special addresses that should receive all pools
special_addresses: list[str] = ["DLO6VI4XJJWZOYUHSEKP3MVQZXGEOKDJUTTL5NJIS7UMXAPETOYLX3KNVE", "native.algo"]
# Beneficiary address for contract verification
beneficiary_address: str = "METAFG5UBD74CKQFIIABWMMQXR45J7BAP3KV6BVR3V7LDPNAEKNEVLMBRE"
# Uvicorn log level
uvicorn_log_level: str = "info"
background_user_pools_update: bool = False
background_pools_update: bool = False
background_asset_prices_update: bool = True # Enable background update of asset prices
# Retained only so existing deployments can roll forward. The raw-balance
# publisher has been removed and this flag cannot enable LP pricing.
background_lp_prices_update: bool = False
asset_price_update_batch_size: int = Field(default=10, gt=0)
asset_price_api_call_delay: float = Field(default=1, ge=0)
asset_price_batch_delay: float = Field(default=2.0, ge=0)
sync_new_pools: bool = True
sync_liquidity_pools: bool = False
# Legacy stake projection does not yet validate complete application groups.
# Keep it fail-closed until the authoritative event classifier lands.
sync_staking_pools: bool = False
update_contract_caches: bool = True
update_contracts_chunk_size: int = Field(default=10, ge=1, le=100)
telegram_bot_api_token: str
telegram_channel_id: int
discord_notify_webhook_url: Optional[str] = None
block_time: float = 2.7
old_pool_end_date_days_ago: int = 30
sync_lag_max_rounds: int = 1000 # 1 hour
sync_behind_seconds_threshold: int = 60
sync_round_max_attempts: int = Field(default=5, ge=1, le=100)
sync_retry_max_seconds: float = Field(default=30, gt=0, le=300)
reset_and_resync_pool_states: bool = False
contracts_cache_ttl: int = 120
algo_price_ttl: int = 3
asset_prices_ttl: int = Field(default=120, gt=0) # 2 minutes.
asset_prices_max_stale: int = Field(default=3600, gt=0)
asset_prices_update_interval: int = 60 # Run the background update every 60 seconds
lp_token_prices_ttl: int = 30
total_tvl_ttl: int = 30
lp_state_ttl_rounds: int = 10 # 30s
farm_creation_fee: int
farm_flat_algo_creation_fee: int
# Accepted as no-op compatibility keys for existing deployment env files.
migrate: bool = False
enable_js: bool = False
reach_no_warn: bool = False
reach_connector_mode: str = "ALGO"
sync_humble_pools: int = 0
redis_host: str = ""
redis_port: int = 6379
asset_default_logo_svg_url: str = (
"https://app.cometa.farm/static/media/tokenPlaceholder.b822bbf7d312b67292cf97f3d22194ed.svg"
)
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
@model_validator(mode="after")
def validate_price_freshness_windows(self) -> "Settings":
if self.asset_prices_max_stale < self.asset_prices_ttl:
raise ValueError("asset_prices_max_stale must be at least asset_prices_ttl")
return self
def is_mainnet(self):
return self.algo_network == "mainnet"
@property
def db_name(self):
return self.algo_network.upper()
settings = Settings()
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
logger.info("Algo network: %s", settings.algo_network)
logger.info("Mongo endpoint: %s:%s", settings.mongodb_host, settings.mongodb_port)
logger.info("Always-return pool IDs: %s", settings.always_return_pool_ids)
logger.info("Return-all Cometa pool addresses: %s", settings.return_all_cometa_pools_to_addresses)