diff --git a/tests/vega_sim/api/test_data.py b/tests/vega_sim/api/test_data.py index 2c02e3a2c..f11293df3 100644 --- a/tests/vega_sim/api/test_data.py +++ b/tests/vega_sim/api/test_data.py @@ -28,6 +28,7 @@ ReferralSetStats, PartyAmount, ReferrerRewardsGenerated, + MakerFeesGenerated, FeesStats, Team, TeamReferee, @@ -1064,7 +1065,7 @@ def GetFeesStats(self, request, context): market=request.market_id, asset=request.asset_id, epoch_seq=1, - total_rewards_paid=[ + total_rewards_received=[ vega_protos.events.v1.events.PartyAmount( party="referrer1", amount="1000" ) @@ -1089,6 +1090,21 @@ def GetFeesStats(self, request, context): party="referrer1", amount="1000" ) ], + total_maker_fees_received=[ + vega_protos.events.v1.events.PartyAmount( + party="referrer1", amount="1000" + ) + ], + maker_fees_generated=[ + vega_protos.events.v1.events.MakerFeesGenerated( + taker="taker1", + maker_fees_paid=[ + vega_protos.events.v1.events.PartyAmount( + party="referrer1", amount="1000" + ) + ], + ) + ], ) ) @@ -1106,7 +1122,7 @@ def GetFeesStats(self, request, context): market="market_id", asset="", epoch_seq=1, - total_rewards_paid=[PartyAmount(party="referrer1", amount=100.0)], + total_rewards_received=[PartyAmount(party="referrer1", amount=100.0)], referrer_rewards_generated=[ ReferrerRewardsGenerated( referrer="referrer1", @@ -1115,6 +1131,13 @@ def GetFeesStats(self, request, context): ], referees_discount_applied=[PartyAmount(party="referrer1", amount=100.0)], volume_discount_applied=[PartyAmount(party="referrer1", amount=100.0)], + total_maker_fees_received=[PartyAmount(party="referrer1", amount=100.0)], + maker_fees_generated=[ + MakerFeesGenerated( + taker="taker1", + maker_fees_paid=[PartyAmount(party="referrer1", amount=100.0)], + ) + ], ) assert get_fees_stats( data_client=data_client, @@ -1124,7 +1147,7 @@ def GetFeesStats(self, request, context): market="", asset="asset", epoch_seq=1, - total_rewards_paid=[PartyAmount(party="referrer1", amount=100.0)], + total_rewards_received=[PartyAmount(party="referrer1", amount=100.0)], referrer_rewards_generated=[ ReferrerRewardsGenerated( referrer="referrer1", @@ -1133,6 +1156,13 @@ def GetFeesStats(self, request, context): ], referees_discount_applied=[PartyAmount(party="referrer1", amount=100.0)], volume_discount_applied=[PartyAmount(party="referrer1", amount=100.0)], + total_maker_fees_received=[PartyAmount(party="referrer1", amount=100.0)], + maker_fees_generated=[ + MakerFeesGenerated( + taker="taker1", + maker_fees_paid=[PartyAmount(party="referrer1", amount=100.0)], + ) + ], ) diff --git a/vega_sim/api/data.py b/vega_sim/api/data.py index 23f7adb67..b88f5eb0b 100644 --- a/vega_sim/api/data.py +++ b/vega_sim/api/data.py @@ -310,15 +310,36 @@ class ReferrerRewardsGenerated: generated_reward: List[PartyAmount] +@dataclass(frozen=True) +class MakerFeesGenerated: + taker: float + maker_fees_paid: List[PartyAmount] + + +def _maker_fees_generated_from_proto( + maker_fees_generated: vega_protos.events.v1.events.MakerFeesGenerated, + decimal_spec: DecimalSpec, +): + return MakerFeesGenerated( + taker=maker_fees_generated.taker, + maker_fees_paid=[ + _party_amount_from_proto(party_amount, decimal_spec) + for party_amount in maker_fees_generated.maker_fees_paid + ], + ) + + @dataclass(frozen=True) class FeesStats: market: str asset: str epoch_seq: int - total_rewards_paid: List[PartyAmount] + total_rewards_received: List[PartyAmount] referrer_rewards_generated: List[ReferrerRewardsGenerated] referees_discount_applied: List[PartyAmount] volume_discount_applied: List[PartyAmount] + total_maker_fees_received: List[PartyAmount] + maker_fees_generated: List[MakerFeesGenerated] @dataclass(frozen=True) @@ -1114,11 +1135,11 @@ def _fees_stats_from_proto( market=fee_stats.market, asset=fee_stats.asset, epoch_seq=fee_stats.epoch_seq, - total_rewards_paid=[ + total_rewards_received=[ _party_amount_from_proto( party_amount=party_amount, decimal_spec=decimal_spec ) - for party_amount in fee_stats.total_rewards_paid + for party_amount in fee_stats.total_rewards_received ], referrer_rewards_generated=[ _referrer_rewards_generated_from_proto( @@ -1139,6 +1160,19 @@ def _fees_stats_from_proto( ) for party_amount in fee_stats.volume_discount_applied ], + total_maker_fees_received=[ + _party_amount_from_proto( + party_amount=party_amount, decimal_spec=decimal_spec + ) + for party_amount in fee_stats.total_maker_fees_received + ], + maker_fees_generated=[ + _maker_fees_generated_from_proto( + maker_fees_generated=maker_fees_generated, + decimal_spec=decimal_spec, + ) + for maker_fees_generated in fee_stats.maker_fees_generated + ], ) @@ -2304,8 +2338,7 @@ def get_fees_stats( market_id: Optional[str] = None, asset_id: Optional[str] = None, epoch_seq: Optional[int] = None, - referrer: Optional[str] = None, - referee: Optional[str] = None, + party_id: Optional[str] = None, asset_decimals: Optional[Dict[str, int]] = {}, ) -> List[FeesStats]: response = data_raw.get_fees_stats( @@ -2313,8 +2346,7 @@ def get_fees_stats( market_id=market_id, asset_id=asset_id, epoch_seq=epoch_seq, - referrer=referrer, - referee=referee, + party_id=party_id, ) return _fees_stats_from_proto( fee_stats=response, diff --git a/vega_sim/api/data_raw.py b/vega_sim/api/data_raw.py index 2673b822e..a62248a17 100644 --- a/vega_sim/api/data_raw.py +++ b/vega_sim/api/data_raw.py @@ -759,8 +759,7 @@ def get_fees_stats( market_id: Optional[str] = None, asset_id: Optional[str] = None, epoch_seq: Optional[int] = None, - referrer: Optional[str] = None, - referee: Optional[str] = None, + party_id: Optional[str] = None, ): base_request = data_node_protos_v2.trading_data.GetFeesStatsRequest() if market_id is not None: @@ -769,10 +768,8 @@ def get_fees_stats( setattr(base_request, "asset_id", asset_id) if epoch_seq is not None: setattr(base_request, "epoch_seq", epoch_seq) - if referrer is not None: - setattr(base_request, "referrer", referrer) - if referee is not None: - setattr(base_request, "referee", referee) + if party_id is not None: + setattr(base_request, "referrer", party_id) return data_client.GetFeesStats(base_request).fees_stats diff --git a/vega_sim/service.py b/vega_sim/service.py index 8b19b1aa0..2458c7844 100644 --- a/vega_sim/service.py +++ b/vega_sim/service.py @@ -2858,12 +2858,17 @@ def get_fees_stats( market_id: Optional[str] = None, asset_id: Optional[str] = None, epoch_seq: Optional[int] = None, + key_name: Optional[str] = None, + wallet_name: Optional[str] = None, ) -> List[data.FeesStats]: return data.get_fees_stats( data_client=self.trading_data_client_v2, market_id=market_id, asset_id=asset_id, epoch_seq=epoch_seq, + party_id=self.wallet.public_key(key_name, wallet_name) + if key_name is not None + else None, asset_decimals=self.asset_decimals, )