1- from typing import Dict , Optional , Tuple , Any
1+ from typing import Dict , Optional , Set , Tuple , Any
22import pandas as pd
3+ import requests
34from web3 import Web3
45from .base import BribePlatform
56from bal_tools .safe_tx_builder import SafeContract
67from bal_tools import Web3Rpc
78from pathlib import Path
9+ from fee_allocator .constants import VOTEMARKET_CONFIG_URL
810from fee_allocator .logger import logger
911from bal_addresses import AddrBook
1012from eth_abi import encode
1315
1416
1517class StakeDAOPlatform (BribePlatform ):
16- SUPPORTED_L2_CHAINS = ["arbitrum" , "optimism" , "base" , "polygon" ]
1718 AURA_VEBAL_LOCKER = Web3 .to_checksum_address ("0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2" )
19+ DEFAULT_DESTINATION_CHAIN = "arbitrum"
1820 BASE_GAS_LIMIT = 50000
1921 GAS_BUFFER_MULTIPLIER = 1.25
2022 ABI_DIR = Path (__file__ ).parent .parent / "abi"
@@ -37,9 +39,19 @@ def __init__(self, book: Dict[str, str], run_config: Any):
3739 self .usdc_address = book ["tokens/USDC" ]
3840 self ._gauge_to_chain_cache = {}
3941 self ._build_gauge_to_chain_map ()
42+ self .supported_chains = self ._fetch_supported_chains ()
4043
4144 self .w3 = Web3Rpc ("mainnet" , os .environ .get ("DRPC_KEY" ))
4245
46+ @staticmethod
47+ def _fetch_supported_chains () -> Set [str ]:
48+ response = requests .get (VOTEMARKET_CONFIG_URL )
49+ response .raise_for_status ()
50+ data = response .json ()
51+ chain_id_to_name = {v : k for k , v in AddrBook .chain_ids_by_name .items ()}
52+ chain_ids = {entry ["chainId" ] for entry in data ["data" ] if entry ["protocol" ] == "balancer" }
53+ return {chain_id_to_name [cid ] for cid in chain_ids }
54+
4355 def _build_gauge_to_chain_map (self ):
4456 for chain in self .run_config .all_chains :
4557 for pool in chain .core_pools :
@@ -189,18 +201,12 @@ def process_bribes(self, bribes_df: pd.DataFrame, builder: Any, usdc: Any) -> No
189201
190202 mantissa = round (row ["amount" ] * 1e6 )
191203
192- if chain_name == "mainnet" :
193- destination_chain_name = "arbitrum"
194- destination_chain_id = AddrBook .chain_ids_by_name ["arbitrum" ]
195- elif chain_name == "gnosis" :
196- # Gnosis gauges redirect bribes to Arbitrum (similar to mainnet)
197- destination_chain_name = "arbitrum"
198- destination_chain_id = AddrBook .chain_ids_by_name ["arbitrum" ]
199- elif chain_name in self .SUPPORTED_L2_CHAINS :
204+ if chain_name in self .supported_chains :
200205 destination_chain_name = chain_name
201206 destination_chain_id = chain_id
202207 else :
203- raise ValueError (f"Chain { chain_name } not supported by StakeDAO v2. Supported chains: mainnet, { ', ' .join (self .SUPPORTED_L2_CHAINS )} " )
208+ destination_chain_name = self .DEFAULT_DESTINATION_CHAIN
209+ destination_chain_id = AddrBook .chain_ids_by_name [self .DEFAULT_DESTINATION_CHAIN ]
204210
205211 destination_book = AddrBook (destination_chain_name )
206212 vote_market_v2_address = destination_book .flatbook ["stake_dao/votemarket_v2" ]
0 commit comments