Skip to content

Commit

Permalink
fix: recalculate bond % with new bond requirment rate
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Aug 13, 2024
1 parent be9eabd commit acc78b6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion icon_governance/workers/crons/prep_attributes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from time import sleep

from icon_governance.config import settings
from icon_governance.log import logger
from icon_governance.metrics import prom_metrics
from icon_governance.models.preps import Prep
Expand All @@ -8,12 +9,16 @@
getDelegation,
getPReps,
post_rpc_json,
get_network_info,
)


def run_prep_attributes(session):
logger.info(f"Starting {__name__} cron")

network_info = get_network_info()
bond_requirement_rate = int(network_info["bondRequirementRate"], 0) / 10_000

preps_rpc = post_rpc_json(getPReps())
if preps_rpc is None:
logger.info("No preps found from rpc.")
Expand Down Expand Up @@ -42,7 +47,12 @@ def run_prep_attributes(session):
prep.delegated = convert_hex_int(p["delegated"]) / 1e18

if prep.delegated != 0:
prep.bond_percent = 20 * prep.bonded / prep.delegated / 1e18
if settings.NETWORK_NAME in ["lisbon", "berlin"]:
prep.bond_percent = (
prep.bonded / bond_requirement_rate / prep.delegated / 1e18
)
else:
prep.bond_percent = 20 * prep.bonded / prep.delegated / 1e18
else:
prep.bond_percent = 0

Expand Down

0 comments on commit acc78b6

Please sign in to comment.