-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: rename vault to Savings crvUSD (#34)
* refactor: staking -> saving * ci: remove parallel pytest to avoid hitting rate limits * feat: we can now cache in boa if we reject n=auto * chore: comments cleanup
- Loading branch information
Showing
9 changed files
with
57 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,24 @@ | |
|
||
""" | ||
@title Rewards Handler | ||
@notice A contract that helps distributing rewards for st-crvUSD, an ERC4626 | ||
vault for crvUSD (yearn's vault v3 multi-vault implementaiton is used). Any | ||
crvUSD token sent to this contract is considered donated as rewards for staker | ||
and will not be recoverable. This contract can receive funds to be distributed | ||
from the FeeSplitter (crvUSD borrow rates revenues) and potentially other | ||
sources as well. The amount of funds that this contract should receive from the | ||
fee splitter is determined by computing the time-weighted average of the vault | ||
@notice A contract that helps distributing rewards for scrvUSD, an ERC4626 vault | ||
for crvUSD (yearn's vault v3 multi-vault implementaiton is used). Any crvUSD | ||
token sent to this contract is considered donated as rewards for depositors and | ||
will not be recoverable. This contract can receive funds to be distributed from | ||
the FeeSplitter (crvUSD borrow rates revenues) and potentially other sources as | ||
well. The amount of funds that this contract should receive from the fee | ||
splitter is determined by computing the time-weighted average of the vault | ||
balance over crvUSD circulating supply ratio. The contract handles the rewards | ||
in a permissionless manner, anyone can take snapshots of the TVL and distribute | ||
rewards. In case of manipulation of the time-weighted average, the contract | ||
allows trusted contracts given the role of `RATE_MANGER` to correct the | ||
distribution rate of the rewards. | ||
@license Copyright (c) Curve.Fi, 2020-2024 - all rights reserved | ||
@author curve.fi | ||
@custom:security [email protected] | ||
""" | ||
|
||
|
@@ -113,7 +117,7 @@ _SUPPORTED_INTERFACES: constant(bytes4[3]) = [ | |
stablecoin: immutable(IERC20) | ||
vault: public(immutable(IVault)) | ||
|
||
# scaling factor for the staked token / circulating supply ratio. | ||
# scaling factor for the deposited token / circulating supply ratio. | ||
scaling_factor: public(uint256) | ||
|
||
# the minimum amount of rewards requested to the FeeSplitter. | ||
|
@@ -152,7 +156,7 @@ def __init__( | |
|
||
twa.__init__( | ||
WEEK, # twa_window = 1 week | ||
1, # min_snapshot_dt_seconds = 1 second (if 0, then spam is possible) | ||
1, # min_snapshot_dt_seconds = 1 second | ||
) | ||
|
||
self._set_minimum_weight(minimum_weight) | ||
|
@@ -166,12 +170,14 @@ def __init__( | |
# PERMISSIONLESS FUNCTIONS # | ||
################################################################ | ||
|
||
|
||
@external | ||
def take_snapshot(): | ||
""" | ||
@notice Function that anyone can call to take a snapshot of the current staked | ||
supply ratio in the vault. This is used to compute the time-weighted average of | ||
the TVL to decide on the amount of rewards to ask for (weight). | ||
@notice Function that anyone can call to take a snapshot of the current | ||
deposited supply ratio in the vault. This is used to compute the time-weighted | ||
average of the TVL to decide on the amount of rewards to ask for (weight). | ||
@dev There's no point in MEVing this snapshot as the rewards distribution rate | ||
can always be reduced (if a malicious actor inflates the value of the snapshot) | ||
or the minimum amount of rewards can always be increased (if a malicious actor | ||
|
@@ -208,8 +214,8 @@ def process_rewards(): | |
), "rewards should be distributed over time" | ||
|
||
# any crvUSD sent to this contract (usually through the fee splitter, but | ||
# could also come from other sources) will be used as a reward for crvUSD | ||
# stakers in the vault. | ||
# could also come from other sources) will be used as a reward for scrvUSD | ||
# vault depositors. | ||
available_balance: uint256 = staticcall stablecoin.balanceOf(self) | ||
|
||
assert available_balance > 0, "no rewards to distribute" | ||
|
@@ -245,9 +251,9 @@ def weight() -> uint256: | |
""" | ||
@notice this function is part of the dynamic weight interface expected by the | ||
FeeSplitter to know what percentage of funds should be sent for rewards | ||
distribution to crvUSD stakers. | ||
distribution to scrvUSD vault depositors. | ||
@dev `minimum_weight` acts as a lower bound for the percentage of rewards that | ||
should be distributed to stakers. This is useful to bootstrapping TVL by asking | ||
should be distributed to depositors. This is useful to bootstrapping TVL by asking | ||
for more at the beginning and can also be increased in the future if someone | ||
tries to manipulate the time-weighted average of the tvl ratio. | ||
""" | ||
|
@@ -289,6 +295,7 @@ def set_distribution_time(new_distribution_time: uint256): | |
this value lower will reduce the time it takes to stream the rewards, making it | ||
longer will do the opposite. Setting it to 0 will immediately distribute all the | ||
rewards. | ||
@dev This function can be used to prevent the rewards distribution from being | ||
manipulated (i.e. MEV twa snapshots to obtain higher APR for the vault). Setting | ||
this value to zero can be used to pause `process_rewards`. | ||
|
@@ -310,10 +317,11 @@ def set_distribution_time(new_distribution_time: uint256): | |
def set_minimum_weight(new_minimum_weight: uint256): | ||
""" | ||
@notice Update the minimum weight that the the vault will ask for. | ||
@dev This function can be used to prevent the rewards requested from being | ||
manipulated (i.e. MEV twa snapshots to obtain lower APR for the vault). Setting | ||
this value to zero makes the amount of rewards requested fully determined by the | ||
twa of the staked supply ratio. | ||
twa of the deposited supply ratio. | ||
""" | ||
access_control._check_role(RATE_MANAGER, msg.sender) | ||
self._set_minimum_weight(new_minimum_weight) | ||
|
@@ -354,7 +362,7 @@ def recover_erc20(token: IERC20, receiver: address): | |
access_control._check_role(RECOVERY_MANAGER, msg.sender) | ||
|
||
# if crvUSD was sent by accident to the contract the funds are lost and will | ||
# be distributed as staking rewards on the next `process_rewards` call. | ||
# be distributed as rewards on the next `process_rewards` call. | ||
assert token != stablecoin, "can't recover crvusd" | ||
# when funds are recovered the whole balanced is sent to a trusted address. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters