Skip to content

Commit 789f9b3

Browse files
authored
Predictoor 5X Boost (#824)
1 parent 83b7eb1 commit 789f9b3

File tree

6 files changed

+90
-7
lines changed

6 files changed

+90
-7
lines changed

df_py/util/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
PREDICTOOR_RELEASE_WEEK = 62
4545
PREDICTOOR_OCEAN_BUDGET = 37_500
4646
PREDICTOOR_DF_FIRST_DATE = datetime(2023, 11, 9)
47+
SAPPHIRE_MAINNET_CHAINID = 23294
4748

4849
# volume
4950
# Weekly Percent Yield needs to be 1.5717%., for max APY of 125%

df_py/util/dcv_multiplier.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def calc_dcv_multiplier(DF_week: int, is_predictoor: bool) -> float:
3434
DCV_multiplier --
3535
"""
3636
if is_predictoor:
37-
return PREDICTOOR_MULTIPLIER
37+
if DF_week < 82:
38+
return PREDICTOOR_MULTIPLIER
39+
return PREDICTOOR_MULTIPLIER * 5
3840

3941
if DF_week < 9:
4042
return np.inf

df_py/util/dftool_module.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from df_py.util import blockrange, dispense, get_rate, networkutil, oceantestutil
2525
from df_py.util.base18 import from_wei, to_wei
2626
from df_py.util.blocktime import get_fin_block, timestr_to_timestamp
27+
from df_py.util.constants import SAPPHIRE_MAINNET_CHAINID
2728
from df_py.util.contract_base import ContractBase
2829
from df_py.util.dftool_arguments import (
2930
CHAINID_EXAMPLES,
@@ -437,12 +438,10 @@ def do_calc():
437438
calc_volume_rewards_from_csvs(csv_dir, start_date, tot_ocean)
438439

439440
if arguments.SUBSTREAM == "predictoor_rose":
440-
SAPPHIRE_MAINNET_ID = 23294
441-
442441
predictoor_data = load_predictoor_data_csv(csv_dir)
443442
print("Loaded predictoor data:", predictoor_data)
444443
predictoor_rewards = calc_predictoor_rewards(
445-
predictoor_data, arguments.TOT_OCEAN, SAPPHIRE_MAINNET_ID
444+
predictoor_data, arguments.TOT_OCEAN, SAPPHIRE_MAINNET_CHAINID
446445
)
447446
print("Calculated rewards:", predictoor_rewards)
448447

df_py/util/dispense.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from web3.main import Web3
88

99
from df_py.util.base18 import to_wei
10+
from df_py.util.constants import SAPPHIRE_MAINNET_CHAINID
1011
from df_py.util.contract_base import ContractBase
1112
from df_py.util.logger import logger
1213
from df_py.util.multisig import send_multisig_tx
@@ -63,7 +64,7 @@ def dispense(
6364
sts = list(range(N))[::batch_size] # send in batches to avoid gas issues
6465

6566
LEGACY_TX = False
66-
if web3.eth.chain_id == 23294:
67+
if web3.eth.chain_id == SAPPHIRE_MAINNET_CHAINID:
6768
LEGACY_TX = True
6869

6970
def approveAmt(amt):

df_py/util/test/test_dcv_multiplier.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def test_calc_dcv_multiplier():
7171
assert mult(100, False) == 0.001
7272
assert mult(10000, False) == 0.001
7373

74+
# PREDICTOOR MULTIPLIERS
7475
assert mult(-10, True) == 0.201
7576
assert mult(9, True) == 0.201
7677
assert mult(12, True) == 0.201
77-
assert mult(10000, True) == 0.201
78+
assert mult(81, True) == 0.201
79+
assert mult(82, True) == 0.201 * 5
80+
assert mult(10000, True) == 0.201 * 5

df_py/volume/test/test_calc_rewards.py

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# pylint: disable=too-many-lines
2+
from datetime import datetime
23
from unittest.mock import MagicMock, patch
34

45
import numpy as np
56
import pytest
67
from enforce_typing import enforce_types
78
from pytest import approx
89

9-
from df_py.util.constants import ZERO_ADDRESS
10+
from df_py.util.constants import (
11+
SAPPHIRE_MAINNET_CHAINID,
12+
ZERO_ADDRESS,
13+
)
1014
from df_py.volume import csvs
1115
from df_py.volume.calc_rewards import calc_volume_rewards_from_csvs
1216
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
752756
assert rewards_info[C1][NA][LP1] == approx(60.3, abs=1e-5)
753757
assert rewards_info[C2][NB][LP2] == 300
754758
assert rewards_info[C2][NB][LP3] == 300
759+
760+
761+
@enforce_types
762+
def test_volume_reward_calculator_pdr_mult_week81(tmp_path):
763+
expected_rewards = 20.1
764+
_test_volume_reward_calculator_pdr_mult(
765+
tmp_path, DF_week=81, expected_rewards=expected_rewards
766+
)
767+
768+
769+
@enforce_types
770+
def test_volume_reward_calculator_pdr_mult_week82(tmp_path):
771+
expected_rewards = 20.1 * 5
772+
_test_volume_reward_calculator_pdr_mult(
773+
tmp_path, DF_week=82, expected_rewards=expected_rewards
774+
)
775+
776+
777+
@enforce_types
778+
def _test_volume_reward_calculator_pdr_mult(tmp_path, DF_week, expected_rewards):
779+
chain_id = SAPPHIRE_MAINNET_CHAINID
780+
stakes = {
781+
chain_id: {NA: {LP1: 1e8}},
782+
}
783+
locked_amts = {
784+
chain_id: {NA: {LP1: 1e8}},
785+
}
786+
volumes = {
787+
chain_id: {
788+
OCN_ADDR: {
789+
NA: 100,
790+
}
791+
},
792+
}
793+
owners = {chain_id: {NA: LP2}}
794+
symbols = {chain_id: {OCN_ADDR: OCN_SYMB}}
795+
rates = {OCN_SYMB: 1.0}
796+
797+
predictoor_contracts = {NA: {}, NB: {}}
798+
799+
OCEAN_reward = 1e24
800+
801+
with patch(
802+
"df_py.volume.allocations.load_stakes",
803+
return_value=(stakes, locked_amts),
804+
), patch("df_py.volume.csvs.load_nftvols_csvs", return_value=volumes), patch(
805+
"df_py.volume.csvs.load_owners_csvs", return_value=owners
806+
), patch(
807+
"df_py.volume.csvs.load_symbols_csvs", return_value=symbols
808+
), patch(
809+
"df_py.volume.csvs.load_rate_csvs", return_value=rates
810+
), patch(
811+
"df_py.volume.reward_calculator.query_predictoor_contracts",
812+
return_value=predictoor_contracts,
813+
), patch(
814+
"df_py.volume.reward_calculator.DEPLOYER_ADDRS",
815+
{chain_id: ""},
816+
), patch(
817+
"df_py.volume.calc_rewards.get_df_week_number", return_value=DF_week
818+
), patch(
819+
"df_py.volume.calc_rewards.wait_to_latest_block"
820+
), patch(
821+
"web3.main.Web3.to_checksum_address"
822+
) as mock:
823+
mock.side_effect = lambda value: value
824+
825+
calc_volume_rewards_from_csvs(
826+
tmp_path, datetime.now(), OCEAN_reward, True, False
827+
)
828+
829+
rewards_per_lp = csvs.load_volume_rewards_csv(str(tmp_path))
830+
831+
assert rewards_per_lp[chain_id][LP1] == approx(expected_rewards, 1e-6)

0 commit comments

Comments
 (0)