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

Change governance distribution #14

Merged
merged 1 commit into from
Jun 3, 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
30 changes: 24 additions & 6 deletions indy_rewards/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
LiquidityPool,
LiquidityPoolReward,
)
from indy_rewards.sp.distribution import sp_epoch_emission
from indy_rewards.sp.distribution import gov_epoch_emission, sp_epoch_emission


@click.group()
Expand Down Expand Up @@ -52,6 +52,19 @@ def decorator(function: Callable):
return decorator


def gov_indy_option(name="--indy", help="INDY to distribute per epoch."):
def decorator(function: Callable):
return click.option(
name,
default=-1,
type=click.FLOAT,
help=help,
show_default=True,
)(function)

return decorator


def sp_indy_option(name="--indy", help="INDY to distribute per epoch."):
def decorator(function: Callable):
return click.option(
Expand Down Expand Up @@ -176,7 +189,7 @@ def lp_summary(indy: float, start_date: datetime.datetime, end_date: datetime.da


@rewards.command()
@indy_option(config.GOV_EPOCH_INDY)
@gov_indy_option()
@pkh_option
@outfile_option
@click.argument("epoch", type=int)
Expand All @@ -186,6 +199,8 @@ def gov(indy: float, pkh: tuple[str], outfile: str, epoch: int):
EPOCH: Epoch to get rewards for. Technically it's the epoch end snapshot that
counts.
"""
if indy == -1:
indy = gov_epoch_emission(epoch)
rewards = gov_module.get_epoch_rewards_per_staker(epoch, indy)
rewards = _pkh_filter(rewards, pkh)
_output(rewards, outfile)
Expand Down Expand Up @@ -249,14 +264,14 @@ def all(pkh: tuple[str], outfile: str, epoch_or_date: int | datetime.date):
epoch_or_date,
sp_epoch_emission(epoch_or_date),
config.LP_EPOCH_INDY,
config.GOV_EPOCH_INDY,
gov_epoch_emission(epoch_or_date),
)
else:
rewards = summary.get_day_all_rewards(
epoch_or_date,
sp_epoch_emission(time_utils.date_to_epoch(epoch_or_date)),
config.LP_EPOCH_INDY,
config.GOV_EPOCH_INDY,
gov_epoch_emission(time_utils.date_to_epoch(epoch_or_date)),
)

rewards = _pkh_filter(rewards, pkh)
Expand All @@ -273,8 +288,7 @@ def all(pkh: tuple[str], outfile: str, epoch_or_date: int | datetime.date):
"--lp-indy",
"INDY to distribute to LP token stakers per epoch.",
)
@indy_option(
config.GOV_EPOCH_INDY,
@gov_indy_option(
"--gov-indy",
"INDY to distribute to INDY governance stakers per epoch.",
)
Expand All @@ -293,6 +307,8 @@ def summary_command(
if isinstance(epoch_or_date, int):
if sp_indy == -1:
sp_indy = sp_epoch_emission(epoch_or_date)
if gov_indy == -1:
gov_indy = gov_epoch_emission(epoch_or_date)
epoch_rewards = summary.get_epoch_all_rewards(
epoch_or_date,
sp_indy,
Expand All @@ -304,6 +320,8 @@ def summary_command(
else:
if sp_indy == -1:
sp_indy = sp_epoch_emission(time_utils.date_to_epoch(epoch_or_date))
if gov_indy == -1:
gov_indy = gov_epoch_emission(time_utils.date_to_epoch(epoch_or_date))
day_rewards = summary.get_day_all_rewards(
epoch_or_date, sp_indy, lp_indy, gov_indy
)
Expand Down
1 change: 0 additions & 1 deletion indy_rewards/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from .time_utils import date_to_epoch

LP_EPOCH_INDY: Final[int] = 4795
GOV_EPOCH_INDY: Final[int] = 2398

IASSET_LAUNCH_DATES = {
IAsset.iUSD: datetime.date(2022, 11, 21), # Epoch 377's first day.
Expand Down
10 changes: 10 additions & 0 deletions indy_rewards/sp/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,13 @@ def sp_epoch_emission(epoch: int) -> float:
return 22431

return 28768


def gov_epoch_emission(epoch: int) -> float:
if epoch >= 524:
return 5315

if epoch >= 488:
return 6046.11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw. it should be 6046.33 according to the proposals https://app.indigoprotocol.io/governance/polls/49 and https://app.indigoprotocol.io/governance/polls/48

i.e. 5315 + 731.33 = 6046.33


return 2398
Loading