From acc78b69a3d6039b31c644225f457b35dac5a745 Mon Sep 17 00:00:00 2001 From: robcxyz Date: Tue, 13 Aug 2024 01:53:03 -0600 Subject: [PATCH] fix: recalculate bond % with new bond requirment rate --- icon_governance/workers/crons/prep_attributes.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/icon_governance/workers/crons/prep_attributes.py b/icon_governance/workers/crons/prep_attributes.py index b20f3a5..a4bbe94 100644 --- a/icon_governance/workers/crons/prep_attributes.py +++ b/icon_governance/workers/crons/prep_attributes.py @@ -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 @@ -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.") @@ -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