diff --git a/.github/workflows/comment_payload_report.yaml b/.github/workflows/comment_payload_report.yaml index 702da5a..eff0d8d 100644 --- a/.github/workflows/comment_payload_report.yaml +++ b/.github/workflows/comment_payload_report.yaml @@ -9,10 +9,6 @@ on: end_date: required: true type: string - pull_request_target: - types: [opened, synchronize] - paths: - - "fee_allocator/payloads/*.json" jobs: comment-report: diff --git a/.github/workflows/trigger_fee_collection.yaml b/.github/workflows/trigger_fee_collection.yaml index cefb24d..e4ac52b 100644 --- a/.github/workflows/trigger_fee_collection.yaml +++ b/.github/workflows/trigger_fee_collection.yaml @@ -13,6 +13,11 @@ on: paths: - "fee_allocator/fees_collected/*.json" +permissions: + contents: write + pull-requests: write + issues: write + jobs: process_fees: runs-on: ubuntu-latest diff --git a/fee_allocator/accounting/chains.py b/fee_allocator/accounting/chains.py index 53960d1..c2005f6 100644 --- a/fee_allocator/accounting/chains.py +++ b/fee_allocator/accounting/chains.py @@ -414,10 +414,10 @@ def _fetch_and_process_pool_fee_data(self) -> list[PoolFeeData]: end_snaps = None if self.chains.protocol_version == "v2": start_snaps = self.subgraph.get_balancer_pool_snapshots( - block=self.block_range[0], pools_per_req=1000, limit=5000 + block=self.block_range[0], pools_per_req=1000, limit=5000, use_full_subgraph=True ) end_snaps = self.subgraph.get_balancer_pool_snapshots( - block=self.block_range[1], pools_per_req=1000, limit=5000 + block=self.block_range[1], pools_per_req=1000, limit=5000, use_full_subgraph=True ) pools = self.subgraph.fetch_all_pools_info() diff --git a/fee_allocator/bribe_platforms/stakedao.py b/fee_allocator/bribe_platforms/stakedao.py index cef9ba0..de77130 100644 --- a/fee_allocator/bribe_platforms/stakedao.py +++ b/fee_allocator/bribe_platforms/stakedao.py @@ -1,10 +1,12 @@ -from typing import Dict, Optional, Tuple, Any +from typing import Dict, Optional, Set, Tuple, Any import pandas as pd +import requests from web3 import Web3 from .base import BribePlatform from bal_tools.safe_tx_builder import SafeContract from bal_tools import Web3Rpc from pathlib import Path +from fee_allocator.constants import VOTEMARKET_CONFIG_URL from fee_allocator.logger import logger from bal_addresses import AddrBook from eth_abi import encode @@ -13,8 +15,8 @@ class StakeDAOPlatform(BribePlatform): - SUPPORTED_L2_CHAINS = ["arbitrum", "optimism", "base", "polygon"] AURA_VEBAL_LOCKER = Web3.to_checksum_address("0xaF52695E1bB01A16D33D7194C28C42b10e0Dbec2") + DEFAULT_DESTINATION_CHAIN = "arbitrum" BASE_GAS_LIMIT = 50000 GAS_BUFFER_MULTIPLIER = 1.25 ABI_DIR = Path(__file__).parent.parent / "abi" @@ -37,9 +39,19 @@ def __init__(self, book: Dict[str, str], run_config: Any): self.usdc_address = book["tokens/USDC"] self._gauge_to_chain_cache = {} self._build_gauge_to_chain_map() + self.supported_chains = self._fetch_supported_chains() self.w3 = Web3Rpc("mainnet", os.environ.get("DRPC_KEY")) + @staticmethod + def _fetch_supported_chains() -> Set[str]: + response = requests.get(VOTEMARKET_CONFIG_URL) + response.raise_for_status() + data = response.json() + chain_id_to_name = {v: k for k, v in AddrBook.chain_ids_by_name.items()} + chain_ids = {entry["chainId"] for entry in data["data"] if entry["protocol"] == "balancer"} + return {chain_id_to_name[cid] for cid in chain_ids} + def _build_gauge_to_chain_map(self): for chain in self.run_config.all_chains: for pool in chain.core_pools: @@ -189,18 +201,12 @@ def process_bribes(self, bribes_df: pd.DataFrame, builder: Any, usdc: Any) -> No mantissa = round(row["amount"] * 1e6) - if chain_name == "mainnet": - destination_chain_name = "arbitrum" - destination_chain_id = AddrBook.chain_ids_by_name["arbitrum"] - elif chain_name == "gnosis": - # Gnosis gauges redirect bribes to Arbitrum (similar to mainnet) - destination_chain_name = "arbitrum" - destination_chain_id = AddrBook.chain_ids_by_name["arbitrum"] - elif chain_name in self.SUPPORTED_L2_CHAINS: + if chain_name in self.supported_chains: destination_chain_name = chain_name destination_chain_id = chain_id else: - raise ValueError(f"Chain {chain_name} not supported by StakeDAO v2. Supported chains: mainnet, {', '.join(self.SUPPORTED_L2_CHAINS)}") + destination_chain_name = self.DEFAULT_DESTINATION_CHAIN + destination_chain_id = AddrBook.chain_ids_by_name[self.DEFAULT_DESTINATION_CHAIN] destination_book = AddrBook(destination_chain_name) vote_market_v2_address = destination_book.flatbook["stake_dao/votemarket_v2"] diff --git a/fee_allocator/constants.py b/fee_allocator/constants.py index 1058ca2..911d333 100644 --- a/fee_allocator/constants.py +++ b/fee_allocator/constants.py @@ -3,3 +3,4 @@ PARTNER_CONFIG_URL = "https://raw.githubusercontent.com/BalancerMaxis/multisig-ops/main/config/partner_fee_share.json" EZKL_POOLS_URL = "https://raw.githubusercontent.com/BalancerMaxis/bal_addresses/main/outputs/ezkl_pools.json" POOL_OVERRIDES_URL = "https://raw.githubusercontent.com/BalancerMaxis/multisig-ops/main/config/pool_incentives_overrides.json" +VOTEMARKET_CONFIG_URL = "https://raw.githubusercontent.com/stake-dao/contracts-monorepo/main/packages/votemarket/data/votemarkets.json" diff --git a/fee_allocator/summaries/v2_recon.json b/fee_allocator/summaries/v2_recon.json index c38ea26..164efca 100644 --- a/fee_allocator/summaries/v2_recon.json +++ b/fee_allocator/summaries/v2_recon.json @@ -35,17 +35,17 @@ }, { "feesCollected": 207130.84, - "incentivesDistributed": 1979911.77, - "feesNotDistributed": -1772780.93, + "incentivesDistributed": 207130.84, + "feesNotDistributed": 0.0, "auraIncentives": 34157.8, "balIncentives": 18703.18, - "feesToDao": 337233.89, - "feesToVebal": 1589816.9, + "feesToDao": 36247.9, + "feesToVebal": 118021.96, "auravebalShare": 0.65, - "auraIncentivesPct": 0.0173, - "balIncentivesPct": 0.0094, - "feesToDaoPct": 0.1703, - "feesToVebalPct": 0.803, + "auraIncentivesPct": 0.1649, + "balIncentivesPct": 0.0903, + "feesToDaoPct": 0.175, + "feesToVebalPct": 0.5698, "createdAt": 1748012323, "periodStart": 1746662400, "periodEnd": 1747872000 @@ -452,27 +452,6 @@ "periodEnd": 1769644800, "bribeThreshold": 490 }, - { - "feesCollected": 31650.06, - "totalDistributed": 31650.06, - "feesNotDistributed": -0.0, - "coreFees": 989.49, - "noncoreFees": 30660.57, - "totalIncentives": 410.32, - "feesToDao": 5412.22, - "feesToVebal": 24841.46, - "feesToPartners": 827.93, - "feesToBeets": 158.14, - "incentivesPct": 0.013, - "feesToDaoPct": 0.171, - "feesToVebalPct": 0.7849, - "feesToPartnersPct": 0.0262, - "feesToBeetsPct": 0.005, - "createdAt": 1770982245, - "periodStart": 1769644800, - "periodEnd": 1770854400, - "bribeThreshold": 390 - }, { "feesCollected": 31650.06, "totalDistributed": 31650.06, diff --git a/fee_allocator/summaries/v3_recon.json b/fee_allocator/summaries/v3_recon.json index 34e5bec..fdd3771 100644 --- a/fee_allocator/summaries/v3_recon.json +++ b/fee_allocator/summaries/v3_recon.json @@ -35,17 +35,17 @@ }, { "feesCollected": 74626.13, - "incentivesDistributed": 480510.51, - "feesNotDistributed": -405884.38, + "incentivesDistributed": 74626.13, + "feesNotDistributed": 0.0, "auraIncentives": 8021.13, "balIncentives": 4175.51, - "feesToDao": 81954.93, - "feesToVebal": 386358.95, + "feesToDao": 13059.57, + "feesToVebal": 49369.92, "auravebalShare": 0.66, - "auraIncentivesPct": 0.0167, - "balIncentivesPct": 0.0087, - "feesToDaoPct": 0.1706, - "feesToVebalPct": 0.8041, + "auraIncentivesPct": 0.1075, + "balIncentivesPct": 0.056, + "feesToDaoPct": 0.175, + "feesToVebalPct": 0.6616, "createdAt": 1748012455, "periodStart": 1746662400, "periodEnd": 1747872000 @@ -452,27 +452,6 @@ "periodEnd": 1769644800, "bribeThreshold": 490 }, - { - "feesCollected": 42204.24, - "totalDistributed": 42204.24, - "feesNotDistributed": -0.0, - "coreFees": 27049.07, - "noncoreFees": 15155.17, - "totalIncentives": 18486.29, - "feesToDao": 7430.29, - "feesToVebal": 15069.78, - "feesToPartners": 1217.88, - "feesToBeets": 0.0, - "incentivesPct": 0.438, - "feesToDaoPct": 0.1761, - "feesToVebalPct": 0.3571, - "feesToPartnersPct": 0.0289, - "feesToBeetsPct": 0.0, - "createdAt": 1770982291, - "periodStart": 1769644800, - "periodEnd": 1770854400, - "bribeThreshold": 390 - }, { "feesCollected": 42204.24, "totalDistributed": 42204.24,