Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#797 - DCV_J should be in OCEAN #798

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion df_py/util/constants.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
28: 0.0,
80: 150000.0, # weekly 150k from weeks 29 to 79
106: 300000.0,
132: 600000.0
132: 600000.0,
# we use the halflife formula after week 132
}

7 changes: 4 additions & 3 deletions df_py/volume/reward_calculator.py
Original file line number Diff line number Diff line change
@@ -175,8 +175,8 @@ def _calc_rewards_usd(self) -> np.ndarray:
for j in range(N_j):
stake_j = sum(S[:, j])
multiplier = self.M[j]
DCV_j = self.V_USD[j]
if stake_j == 0.0 or DCV_j == 0.0:
DCV_OCEAN_j = self.V_USD[j] / self.rates["OCEAN"]
if stake_j == 0.0 or DCV_OCEAN_j == 0.0:
continue

for i in range(N_i):
@@ -186,10 +186,11 @@ def _calc_rewards_usd(self) -> np.ndarray:
perc_at_ij = stake_ij / stake_j

# main formula!
# reward amount in OCEAN
R[i, j] = min(
perc_at_j * perc_at_ij * self.OCEAN_avail,
stake_ij * TARGET_WPY, # bound rewards by max APY
DCV_j * multiplier, # bound rewards by DCV
DCV_OCEAN_j * multiplier, # bound rewards by DCV
)

# filter negligible values
8 changes: 4 additions & 4 deletions df_py/volume/test/test_calcrewards.py
Original file line number Diff line number Diff line change
@@ -500,10 +500,9 @@ def test_bound_APY_two_nfts__high_stake__one_nft_dominates_DCV():
@enforce_types
def test_bound_by_DCV_one_nft():
DCV_OCEAN = 100.0
DCV_USD = DCV_OCEAN / RATES["OCEAN"]

stakes = {C1: {NA: {LP1: 1e6}}}
nftvols = {C1: {OCN_ADDR: {NA: DCV_USD}}}
nftvols = {C1: {OCN_ADDR: {NA: DCV_OCEAN}}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Reward calculator expects volumes to be in the token used to purchase the asset and later converts it to USD.

OCEAN_avail = 10000.0

# df week = 9 -> DCV multiplier = 1.0
@@ -523,10 +522,9 @@ def test_bound_by_DCV_one_nft():
@enforce_types
def test_custom_multipliers():
DCV_OCEAN = 100.0
DCV_USD = DCV_OCEAN / RATES["OCEAN"]

stakes = {C1: {NA: {LP1: 1e6}}}
nftvols = {C1: {OCN_ADDR: {NA: DCV_USD}}}
nftvols = {C1: {OCN_ADDR: {NA: DCV_OCEAN}}}
OCEAN_avail = 10000.0

with patch(
@@ -1111,6 +1109,7 @@ def test_volume_reward_calculator(tmp_path):
},
"rates": {
"basetoken_symbol1": 1.0,
"OCEAN": 1.0,
},
"multiplier": 1.0,
}
@@ -1175,6 +1174,7 @@ def test_volume_reward_calculator_predictoor_mul(tmp_path):
},
"rates": {
"basetoken_symbol1": 1.0,
"OCEAN": 1.0,
},
"predictoor_contracts": {"0xnft_addr1": {}},
}