Skip to content

Commit

Permalink
Enable slippage on all chains (#454)
Browse files Browse the repository at this point in the history
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 cowprotocol/dune-queries#87 is
merged.

---------

Co-authored-by: Haris Angelidakis <[email protected]>
  • Loading branch information
fhenneke and harisang authored Dec 14, 2024
1 parent 7fc0851 commit 22d6161
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}."
Expand Down
2 changes: 1 addition & 1 deletion src/fetch/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
5 changes: 5 additions & 0 deletions src/fetch/payouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down

0 comments on commit 22d6161

Please sign in to comment.