Skip to content

Commit b2b9ab6

Browse files
committed
feat: Add gamma param for the calculation of total stake threshold.
1 parent 1bdacb3 commit b2b9ab6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/catalyst-toolbox/catalyst-toolbox/scripts/python/proposers_rewards.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from rich import print
2222
from asyncio import run as aiorun
2323
from copy import deepcopy
24+
from fractions import Fraction
2425

2526

2627
# VIT servicing station models
@@ -584,13 +585,13 @@ def filter_excluded_proposals(
584585

585586

586587
def calculate_total_stake_from_block0_configuration(
587-
block0_config: Dict[str, Dict], committee_keys: List[str]
588+
block0_config: Dict[str, Dict], committee_keys: List[str], gamma: Fraction
588589
):
589590
funds = (
590591
initial["fund"] for initial in block0_config["initial"] if "fund" in initial
591592
)
592593
return sum(
593-
fund["value"]
594+
fund["value"] ** gamma
594595
for fund in itertools.chain.from_iterable(funds)
595596
if fund["address"] not in [key for key in committee_keys]
596597
)
@@ -698,6 +699,12 @@ def save_results(output_path: str, title: str, output_format: OutputFormat, resu
698699
def calculate_rewards(
699700
output_file: str = typer.Option(...),
700701
block0_path: str = typer.Option(...),
702+
gamma: str = typer.Option(
703+
1,
704+
help="""
705+
The gamma value applied for the calculation of the total stake threshold. It is applied to every single voting value before the sum is executed.
706+
"""
707+
),
701708
total_stake_threshold: float = typer.Option(
702709
0.01,
703710
help="""
@@ -785,7 +792,7 @@ def calculate_rewards(
785792
load_json_from_file(committee_keys_path) if committee_keys_path else []
786793
)
787794
total_stake = calculate_total_stake_from_block0_configuration(
788-
block0_config, committee_keys
795+
block0_config, committee_keys, gamma
789796
)
790797
# minimum amount of stake needed for a proposal to be accepted
791798
total_stake_approval_threshold = float(total_stake_threshold) * float(total_stake)

0 commit comments

Comments
 (0)