Skip to content

Commit

Permalink
chore: self.distribution_time from rewards handler (#36)
Browse files Browse the repository at this point in the history
* refactor: change contracts

* feat: add viewer to rh

* test: fix, shorter integration

* chore: remove comments
  • Loading branch information
heswithme authored Oct 16, 2024
1 parent 309e317 commit 43421b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
20 changes: 11 additions & 9 deletions contracts/RewardsHandler.vy
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ scaling_factor: public(uint256)
# the minimum amount of rewards requested to the FeeSplitter.
minimum_weight: public(uint256)

# the time over which rewards will be distributed mirror of the private
# `profit_max_unlock_time` variable from yearn vaults.
distribution_time: public(uint256)


################################################################
# CONSTRUCTOR #
Expand Down Expand Up @@ -210,7 +206,7 @@ def process_rewards():
# prevent the rewards from being distributed untill the distribution rate
# has been set
assert (
self.distribution_time != 0
staticcall vault.profitMaxUnlockTime() != 0
), "rewards should be distributed over time"

# any crvUSD sent to this contract (usually through the fee splitter, but
Expand Down Expand Up @@ -302,17 +298,23 @@ def set_distribution_time(new_distribution_time: uint256):
"""
access_control._check_role(RATE_MANAGER, msg.sender)

# we mirror the value of new_profit_max_unlock_time from the yearn vault
# since it's not exposed publicly.
self.distribution_time = new_distribution_time

# change the distribution time of the rewards in the vault
extcall vault.setProfitMaxUnlockTime(new_distribution_time)

# enact the changes
extcall vault.process_report(vault.address)


@view
@external
def distribution_time() -> uint256:
"""
@notice Getter for the distribution time of the rewards.
@return uint256 The time over which vault rewards will be distributed.
"""
return staticcall vault.profitMaxUnlockTime()


@external
def set_minimum_weight(new_minimum_weight: uint256):
"""
Expand Down
6 changes: 6 additions & 0 deletions contracts/interfaces/IVault.vyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ def process_report(strategy: address) -> (uint256, uint256):
@external
def totalAssets() -> uint256:
...


@view
@external
def profitMaxUnlockTime() -> uint256:
...
4 changes: 0 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ def rewards_handler(vault, minimum_weight):
)
vault.set_role(rh, 2**11 | 2**5, sender=ab.dao_agent)

# TODO how to enforce this in prod?
time = vault.profitMaxUnlockTime()
rh.eval(f"self.distribution_time = {time}")

return rh


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/curve_pools/test_stableswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import address_book as ab


N_COMBINATIONS = 5 # num of combinations in stableswap tests (>=36 => all combinations)
N_COMBINATIONS = 3 # num of combinations in stableswap tests (>=36 => all combinations)

# produce tokens for stableswap to pair against crvusd
paired_token_combinations = generate_list_combinations(ab.all_stables, [1, 2], randomize=True)
Expand Down

0 comments on commit 43421b3

Please sign in to comment.