From 22d6161d71965bcf73a3dc16c049247939764f51 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Sat, 14 Dec 2024 02:57:09 +0100 Subject: [PATCH] Enable slippage on all chains (#454) This PR enables slippage computations on all chains. It extends #447 to also pass the blockchain parameter to the slippage query and log some results. At the moment it uses query 4379621 instead of 3427730. This change can be reverted once https://github.com/cowprotocol/dune-queries/pull/87 is merged. --------- Co-authored-by: Haris Angelidakis <64154020+harisang@users.noreply.github.com> --- src/config.py | 4 +--- src/fetch/dune.py | 2 +- src/fetch/payouts.py | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/config.py b/src/config.py index f0faeb71..b0796709 100644 --- a/src/config.py +++ b/src/config.py @@ -138,10 +138,8 @@ class BufferAccountingConfig: def from_network(network: Network) -> BufferAccountingConfig: """Initialize buffer accounting config for a given network.""" match network: - case Network.MAINNET: + case Network.MAINNET | Network.GNOSIS | Network.ARBITRUM_ONE: include_slippage = True - case Network.GNOSIS | Network.ARBITRUM_ONE: - include_slippage = False case _: raise ValueError( f"No buffer accounting config set up for network {network}." diff --git a/src/fetch/dune.py b/src/fetch/dune.py index 880c2de8..c68e0d1f 100644 --- a/src/fetch/dune.py +++ b/src/fetch/dune.py @@ -115,7 +115,7 @@ def get_period_slippage(self, job_id: Optional[str] = None) -> list[DuneRecord]: return self._get_query_results( self._parameterized_query( - QUERIES["PERIOD_SLIPPAGE"], params=self._period_params() + QUERIES["PERIOD_SLIPPAGE"], params=self._network_and_period_params() ), job_id, ) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index d83874f4..1d5ca753 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -586,6 +586,9 @@ def construct_payouts( for _, payment in complete_payout_df.iterrows() ) + total_slippage = slippage_df["eth_slippage_wei"].sum() + total_network_fees = batch_rewards_df["network_fee_eth"].sum() + log_saver.print( "Payment breakdown (ignoring service fees):\n" f"Performance Reward: {performance_reward / 10 ** 18:.4f}\n" @@ -594,6 +597,8 @@ def construct_payouts( f"Partner Fees Tax: {partner_fee_tax_wei / 10 ** 18:.4f}\n" f"Partner Fees: {total_partner_fee_wei_taxed / 10 ** 18:.4f}\n" f"COW DAO Service Fees: {service_fee / 10 ** 18:.4f}\n\n" + f"Network Fees: {total_network_fees / 10**18:.4f}\n" + f"Slippage: {total_slippage / 10**18:.4f}\n\n" f"Exchange rate native token to COW: {exchange_rate_native_to_cow:.4f} COW/native token\n" f"Exchange rate native token to ETH: {exchange_rate_native_to_eth:.4f} ETH/native token\n", category=Category.TOTALS,