From dd1e529b10891b650f73050d122ec627a6cdf349 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:01:05 +0400 Subject: [PATCH] Update script to include OUSD as well --- .../scripts/compute_boost_multiplier.py | 21 +++++++++++++++ .../scripts/recompute_oeth_supplysnapshot.py | 27 ------------------- 2 files changed, 21 insertions(+), 27 deletions(-) create mode 100644 eagleproject/scripts/compute_boost_multiplier.py delete mode 100644 eagleproject/scripts/recompute_oeth_supplysnapshot.py diff --git a/eagleproject/scripts/compute_boost_multiplier.py b/eagleproject/scripts/compute_boost_multiplier.py new file mode 100644 index 0000000..27397df --- /dev/null +++ b/eagleproject/scripts/compute_boost_multiplier.py @@ -0,0 +1,21 @@ +import datetime + +from decimal import Decimal +from core.models import OriginTokens, SupplySnapshot +from core.blockchain.rpc import OETHCurveAMOStrategy, OUSDMetaStrategy + +def run(*script_args): + snapshots = SupplySnapshot.objects.filter(non_rebasing_boost_multiplier=0).order_by('-block_number').all() + + print("Found {} Supply snapshots".format(len(snapshots))) + for s in snapshots: + if s.project == OriginTokens.OETH: + print("Computing OETH Boost multiplier at block {}".format(s.block_number)) + amo_supply = OETHCurveAMOStrategy.get_underlying_balance(s.block_number).get("OETH", Decimal(0)) + elif s.project == OriginTokens.OUSD: + print("Computing OUSD Boost multiplier at block {}".format(s.block_number)) + amo_supply = OUSDMetaStrategy.get_underlying_balance(s.block_number).get("OUSD", Decimal(0)) + s.non_rebasing_boost_multiplier = (s.computed_supply - amo_supply) / (s.computed_supply - s.non_rebasing_supply) + s.save() + + print("Done.") diff --git a/eagleproject/scripts/recompute_oeth_supplysnapshot.py b/eagleproject/scripts/recompute_oeth_supplysnapshot.py deleted file mode 100644 index 008635b..0000000 --- a/eagleproject/scripts/recompute_oeth_supplysnapshot.py +++ /dev/null @@ -1,27 +0,0 @@ -import datetime - -from decimal import Decimal - -from core.blockchain.addresses import OETH -from core.blockchain.const import START_OF_OETH -from core.blockchain.harvest.snapshots import ensure_supply_snapshot, ensure_asset -from core.models import OriginTokens, SupplySnapshot - -from core.blockchain.rpc import origin_token_rebasing_credits, totalSupply, origin_token_non_rebasing_supply, rebasing_credits_per_token, OETHCurveAMOStrategy - -def run(*script_args): - start_block = int(script_args[0]) if len(script_args) > 0 else START_OF_OETH - - snapshots = SupplySnapshot.objects.filter( - block_number__gte=start_block, - project=OriginTokens.OETH - ).order_by('-block_number').all() - - print("Found {} OETH Supply snapshots".format(len(snapshots))) - for s in snapshots: - print("Recomputing supply at block {}".format(s.block_number)) - oeth_amo_supply = OETHCurveAMOStrategy.get_underlying_balance(s.block_number).get("OETH", Decimal(0)) - s.non_rebasing_boost_multiplier = (s.computed_supply - oeth_amo_supply) / (s.computed_supply - s.non_rebasing_supply) - s.save() - - print("Done.")