diff --git a/df_py/util/constants.py b/df_py/util/constants.py index edb747700..e66702c97 100644 --- a/df_py/util/constants.py +++ b/df_py/util/constants.py @@ -44,6 +44,7 @@ PREDICTOOR_RELEASE_WEEK = 62 PREDICTOOR_OCEAN_BUDGET = 37_500 PREDICTOOR_DF_FIRST_DATE = datetime(2023, 11, 9) +SAPPHIRE_MAINNET_CHAINID = 23294 # volume # Weekly Percent Yield needs to be 1.5717%., for max APY of 125% diff --git a/df_py/util/dcv_multiplier.py b/df_py/util/dcv_multiplier.py index 340f1bbc6..ec161c969 100644 --- a/df_py/util/dcv_multiplier.py +++ b/df_py/util/dcv_multiplier.py @@ -34,7 +34,9 @@ def calc_dcv_multiplier(DF_week: int, is_predictoor: bool) -> float: DCV_multiplier -- """ if is_predictoor: - return PREDICTOOR_MULTIPLIER + if DF_week < 82: + return PREDICTOOR_MULTIPLIER + return PREDICTOOR_MULTIPLIER * 5 if DF_week < 9: return np.inf diff --git a/df_py/util/dftool_module.py b/df_py/util/dftool_module.py index 908714995..406159396 100644 --- a/df_py/util/dftool_module.py +++ b/df_py/util/dftool_module.py @@ -24,6 +24,7 @@ from df_py.util import blockrange, dispense, get_rate, networkutil, oceantestutil from df_py.util.base18 import from_wei, to_wei from df_py.util.blocktime import get_fin_block, timestr_to_timestamp +from df_py.util.constants import SAPPHIRE_MAINNET_CHAINID from df_py.util.contract_base import ContractBase from df_py.util.dftool_arguments import ( CHAINID_EXAMPLES, @@ -437,12 +438,10 @@ def do_calc(): calc_volume_rewards_from_csvs(csv_dir, start_date, tot_ocean) if arguments.SUBSTREAM == "predictoor_rose": - SAPPHIRE_MAINNET_ID = 23294 - predictoor_data = load_predictoor_data_csv(csv_dir) print("Loaded predictoor data:", predictoor_data) predictoor_rewards = calc_predictoor_rewards( - predictoor_data, arguments.TOT_OCEAN, SAPPHIRE_MAINNET_ID + predictoor_data, arguments.TOT_OCEAN, SAPPHIRE_MAINNET_CHAINID ) print("Calculated rewards:", predictoor_rewards) diff --git a/df_py/util/dispense.py b/df_py/util/dispense.py index ef73a211b..407fb168e 100644 --- a/df_py/util/dispense.py +++ b/df_py/util/dispense.py @@ -7,6 +7,7 @@ from web3.main import Web3 from df_py.util.base18 import to_wei +from df_py.util.constants import SAPPHIRE_MAINNET_CHAINID from df_py.util.contract_base import ContractBase from df_py.util.logger import logger from df_py.util.multisig import send_multisig_tx @@ -63,7 +64,7 @@ def dispense( sts = list(range(N))[::batch_size] # send in batches to avoid gas issues LEGACY_TX = False - if web3.eth.chain_id == 23294: + if web3.eth.chain_id == SAPPHIRE_MAINNET_CHAINID: LEGACY_TX = True def approveAmt(amt): diff --git a/df_py/util/test/test_dcv_multiplier.py b/df_py/util/test/test_dcv_multiplier.py index 74c9bdcc2..e8dbef12a 100644 --- a/df_py/util/test/test_dcv_multiplier.py +++ b/df_py/util/test/test_dcv_multiplier.py @@ -71,7 +71,10 @@ def test_calc_dcv_multiplier(): assert mult(100, False) == 0.001 assert mult(10000, False) == 0.001 + # PREDICTOOR MULTIPLIERS assert mult(-10, True) == 0.201 assert mult(9, True) == 0.201 assert mult(12, True) == 0.201 - assert mult(10000, True) == 0.201 + assert mult(81, True) == 0.201 + assert mult(82, True) == 0.201 * 5 + assert mult(10000, True) == 0.201 * 5 diff --git a/df_py/volume/test/test_calc_rewards.py b/df_py/volume/test/test_calc_rewards.py index e612df506..0299221fc 100644 --- a/df_py/volume/test/test_calc_rewards.py +++ b/df_py/volume/test/test_calc_rewards.py @@ -1,4 +1,5 @@ # pylint: disable=too-many-lines +from datetime import datetime from unittest.mock import MagicMock, patch import numpy as np @@ -6,7 +7,10 @@ from enforce_typing import enforce_types from pytest import approx -from df_py.util.constants import ZERO_ADDRESS +from df_py.util.constants import ( + SAPPHIRE_MAINNET_CHAINID, + ZERO_ADDRESS, +) from df_py.volume import csvs from df_py.volume.calc_rewards import calc_volume_rewards_from_csvs from df_py.volume.reward_calculator import TARGET_WPY, RewardCalculator @@ -752,3 +756,76 @@ def mock_multipliers(DF_week, is_predictoor): # pylint: disable=unused-argument assert rewards_info[C1][NA][LP1] == approx(60.3, abs=1e-5) assert rewards_info[C2][NB][LP2] == 300 assert rewards_info[C2][NB][LP3] == 300 + + +@enforce_types +def test_volume_reward_calculator_pdr_mult_week81(tmp_path): + expected_rewards = 20.1 + _test_volume_reward_calculator_pdr_mult( + tmp_path, DF_week=81, expected_rewards=expected_rewards + ) + + +@enforce_types +def test_volume_reward_calculator_pdr_mult_week82(tmp_path): + expected_rewards = 20.1 * 5 + _test_volume_reward_calculator_pdr_mult( + tmp_path, DF_week=82, expected_rewards=expected_rewards + ) + + +@enforce_types +def _test_volume_reward_calculator_pdr_mult(tmp_path, DF_week, expected_rewards): + chain_id = SAPPHIRE_MAINNET_CHAINID + stakes = { + chain_id: {NA: {LP1: 1e8}}, + } + locked_amts = { + chain_id: {NA: {LP1: 1e8}}, + } + volumes = { + chain_id: { + OCN_ADDR: { + NA: 100, + } + }, + } + owners = {chain_id: {NA: LP2}} + symbols = {chain_id: {OCN_ADDR: OCN_SYMB}} + rates = {OCN_SYMB: 1.0} + + predictoor_contracts = {NA: {}, NB: {}} + + OCEAN_reward = 1e24 + + with patch( + "df_py.volume.allocations.load_stakes", + return_value=(stakes, locked_amts), + ), patch("df_py.volume.csvs.load_nftvols_csvs", return_value=volumes), patch( + "df_py.volume.csvs.load_owners_csvs", return_value=owners + ), patch( + "df_py.volume.csvs.load_symbols_csvs", return_value=symbols + ), patch( + "df_py.volume.csvs.load_rate_csvs", return_value=rates + ), patch( + "df_py.volume.reward_calculator.query_predictoor_contracts", + return_value=predictoor_contracts, + ), patch( + "df_py.volume.reward_calculator.DEPLOYER_ADDRS", + {chain_id: ""}, + ), patch( + "df_py.volume.calc_rewards.get_df_week_number", return_value=DF_week + ), patch( + "df_py.volume.calc_rewards.wait_to_latest_block" + ), patch( + "web3.main.Web3.to_checksum_address" + ) as mock: + mock.side_effect = lambda value: value + + calc_volume_rewards_from_csvs( + tmp_path, datetime.now(), OCEAN_reward, True, False + ) + + rewards_per_lp = csvs.load_volume_rewards_csv(str(tmp_path)) + + assert rewards_per_lp[chain_id][LP1] == approx(expected_rewards, 1e-6)