Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update fuzzing for suzukacastle reward changes #690

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions vega_sim/scenario/common/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3305,6 +3305,7 @@ def __init__(
metric: Optional[str] = None,
market_names: Optional[str] = None,
entity_scope: Optional[vega_protos.EntityScope.Value] = None,
distribution_strategy: Optional[vega_protos.DistributionStrategy.Value] = None,
wallet_name: Optional[str] = None,
stake_key: bool = False,
tag: Optional[str] = None,
Expand All @@ -3319,6 +3320,7 @@ def __init__(
self.market_names = market_names
self.entity_scope = entity_scope
self.stake_key = stake_key
self.distribution_strategy = distribution_strategy

def initialise(
self,
Expand Down Expand Up @@ -3394,12 +3396,37 @@ def initialise(
else None
),
metric=self.metric,
notional_time_weighted_average_position_requirement=(
1
if self.metric
not in [
vega_protos.DISPATCH_METRIC_MARKET_VALUE,
vega_protos.DISPATCH_METRIC_VALIDATOR_RANKING,
]
else None
),
window_length=2,
transfer_interval=2,
entity_scope=self.entity_scope,
n_top_performers=(
0.5 if self.entity_scope == vega_protos.ENTITY_SCOPE_TEAMS else None
),
distribution_strategy=self.distribution_strategy,
rank_table=(
[
vega_protos.Rank(start_rank=1, share_ratio=50),
vega_protos.Rank(start_rank=2, share_ratio=30),
vega_protos.Rank(start_rank=3, share_ratio=10),
vega_protos.Rank(start_rank=4, share_ratio=1),
vega_protos.Rank(start_rank=11, share_ratio=0),
]
if self.distribution_strategy
in [
vega_protos.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK,
vega_protos.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK_LOTTERY,
]
else None
),
)


Expand Down
10 changes: 5 additions & 5 deletions vega_sim/scenario/fuzzed_markets/fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _pick_rank_table():
)
)
if valid(rs, bias):
if distribution_strategy != vega_protos.vega.DISTRIBUTION_STRATEGY_RANK:
if distribution_strategy == vega_protos.vega.DISTRIBUTION_STRATEGY_PRO_RATA:
return None
return val
return None if rs.rand() < 0.5 else val
Expand Down Expand Up @@ -262,9 +262,9 @@ def _pick_to_account_type():
return vega_protos.vega.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES
if (
recurring.dispatch_strategy.metric
== vega_protos.vega.DISPATCH_METRIC_AVERAGE_POSITION
== vega_protos.vega.DISPATCH_METRIC_AVERAGE_NOTIONAL
):
return vega_protos.vega.ACCOUNT_TYPE_REWARD_AVERAGE_POSITION
return vega_protos.vega.ACCOUNT_TYPE_REWARD_AVERAGE_NOTIONAL
if (
recurring.dispatch_strategy.metric
== vega_protos.vega.DISPATCH_METRIC_RELATIVE_RETURN
Expand Down Expand Up @@ -462,9 +462,9 @@ def _pick_destination_type():
return vega_protos.vega.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES
if (
recurring.dispatch_strategy.metric
== vega_protos.vega.DISPATCH_METRIC_AVERAGE_POSITION
== vega_protos.vega.ACCOUNT_TYPE_REWARD_AVERAGE_NOTIONAL
):
return vega_protos.vega.ACCOUNT_TYPE_REWARD_AVERAGE_POSITION
return vega_protos.vega.DISPATCH_METRIC_AVERAGE_NOTIONAL
if (
recurring.dispatch_strategy.metric
== vega_protos.vega.DISPATCH_METRIC_RELATIVE_RETURN
Expand Down
17 changes: 16 additions & 1 deletion vega_sim/scenario/fuzzing/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,43 +198,57 @@ def configure_agents(
asset_names.add(
benchmark_config.market_config.instrument.perpetual.quote_name
)
for i_agent, (account_type, metric) in enumerate(
for i_agent, (account_type, metric, distribution_strategy) in enumerate(
[
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
protos.vega.vega.DISPATCH_METRIC_MAKER_FEES_PAID,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_PRO_RATA,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES,
protos.vega.vega.DISPATCH_METRIC_MAKER_FEES_RECEIVED,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_PRO_RATA,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
protos.vega.vega.DISPATCH_METRIC_LP_FEES_RECEIVED,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_PRO_RATA,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS,
protos.vega.vega.DISPATCH_METRIC_MARKET_VALUE,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_PRO_RATA,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_AVERAGE_NOTIONAL,
protos.vega.vega.DISPATCH_METRIC_AVERAGE_NOTIONAL,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_RELATIVE_RETURN,
protos.vega.vega.DISPATCH_METRIC_RELATIVE_RETURN,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_RETURN_VOLATILITY,
protos.vega.vega.DISPATCH_METRIC_RETURN_VOLATILITY,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_VALIDATOR_RANKING,
protos.vega.vega.DISPATCH_METRIC_VALIDATOR_RANKING,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_REALISED_RETURN,
protos.vega.vega.DISPATCH_METRIC_REALISED_RETURN,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK,
),
(
protos.vega.vega.ACCOUNT_TYPE_REWARD_ELIGIBLE_ENTITIES,
protos.vega.vega.DISPATCH_METRIC_ELIGIBLE_ENTITIES,
protos.vega.vega.DistributionStrategy.DISTRIBUTION_STRATEGY_RANK_LOTTERY,
),
]
):
Expand All @@ -251,6 +265,7 @@ def configure_agents(
market_names=[market_name],
initial_mint=1e9,
entity_scope=entity_scope,
distribution_strategy=distribution_strategy,
tag=(f"{entity_scope}_{asset_for_metric_name}_{metric}"),
)
for asset_for_metric_name, entity_scope in itertools.product(
Expand Down
Loading