|
1 | 1 | # pylint: disable=too-many-lines |
| 2 | +from datetime import datetime |
2 | 3 | from unittest.mock import MagicMock, patch |
3 | 4 |
|
4 | 5 | import numpy as np |
5 | 6 | import pytest |
6 | 7 | from enforce_typing import enforce_types |
7 | 8 | from pytest import approx |
8 | 9 |
|
9 | | -from df_py.util.constants import ZERO_ADDRESS |
| 10 | +from df_py.util.constants import ( |
| 11 | + SAPPHIRE_MAINNET_CHAINID, |
| 12 | + ZERO_ADDRESS, |
| 13 | +) |
10 | 14 | from df_py.volume import csvs |
11 | 15 | from df_py.volume.calc_rewards import calc_volume_rewards_from_csvs |
12 | 16 | 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 |
752 | 756 | assert rewards_info[C1][NA][LP1] == approx(60.3, abs=1e-5) |
753 | 757 | assert rewards_info[C2][NB][LP2] == 300 |
754 | 758 | 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