Skip to content

Commit d4b95e5

Browse files
committed
chore: upgrade VaultV3 deployment
1 parent 7871532 commit d4b95e5

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

contracts/yearn/VaultV3.vy

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ event RoleSet:
112112
role: indexed(Roles)
113113

114114
# STORAGE MANAGEMENT EVENTS
115+
event UpdateFutureRoleManager:
116+
future_role_manager: indexed(address)
117+
115118
event UpdateRoleManager:
116119
role_manager: indexed(address)
117120

@@ -861,7 +864,7 @@ def _redeem(
861864

862865
# NOTE: strategy's debt decreases by the full amount but the total idle increases
863866
# by the actual amount only (as the difference is considered lost).
864-
current_total_idle += (assets_to_withdraw - loss)
867+
current_total_idle += (unsafe_sub(assets_to_withdraw, loss))
865868
requested_assets -= loss
866869
current_total_debt -= assets_to_withdraw
867870

@@ -928,14 +931,11 @@ def _add_strategy(new_strategy: address, add_to_queue: bool):
928931
@internal
929932
def _revoke_strategy(strategy: address, force: bool=False):
930933
assert self.strategies[strategy].activation != 0, "strategy not active"
931-
932-
# If force revoking a strategy, it will cause a loss.
933-
loss: uint256 = 0
934934

935935
if self.strategies[strategy].current_debt != 0:
936936
assert force, "strategy has debt"
937937
# Vault realizes the full loss of outstanding debt.
938-
loss = self.strategies[strategy].current_debt
938+
loss: uint256 = self.strategies[strategy].current_debt
939939
# Adjust total vault debt.
940940
self.total_debt -= loss
941941

@@ -1031,7 +1031,7 @@ def _update_debt(strategy: address, target_debt: uint256, max_loss: uint256) ->
10311031
# If we didn't get the amount we asked for and there is a max loss.
10321032
if withdrawn < assets_to_withdraw and max_loss < MAX_BPS:
10331033
# Make sure the loss is within the allowed range.
1034-
assert assets_to_withdraw - withdrawn <= assets_to_withdraw * max_loss / MAX_BPS, "too much loss"
1034+
assert unsafe_sub(assets_to_withdraw, withdrawn) <= assets_to_withdraw * max_loss / MAX_BPS, "too much loss"
10351035

10361036
# If we got too much make sure not to increase PPS.
10371037
elif withdrawn > assets_to_withdraw:
@@ -1257,16 +1257,20 @@ def _process_report(strategy: address) -> (uint256, uint256):
12571257
self.strategies[strategy].current_debt = current_debt
12581258
self.total_debt += gain
12591259
else:
1260-
self.total_idle = total_assets
1261-
1260+
# Add in any refunds since it is now idle.
1261+
current_debt = unsafe_add(current_debt, total_refunds)
1262+
self.total_idle = current_debt
1263+
12621264
# Or record any reported loss
12631265
elif loss > 0:
12641266
current_debt = unsafe_sub(current_debt, loss)
12651267
if strategy != self:
12661268
self.strategies[strategy].current_debt = current_debt
12671269
self.total_debt -= loss
12681270
else:
1269-
self.total_idle = total_assets
1271+
# Add in any refunds since it is now idle.
1272+
current_debt = unsafe_add(current_debt, total_refunds)
1273+
self.total_idle = current_debt
12701274

12711275
# Issue shares for fees that were calculated above if applicable.
12721276
if total_fees_shares > 0:
@@ -1537,30 +1541,32 @@ def set_role(account: address, role: Roles):
15371541
@external
15381542
def add_role(account: address, role: Roles):
15391543
"""
1540-
@notice Add a new role to an address.
1541-
@dev This will add a new role to the account
1544+
@notice Add a new role/s to an address.
1545+
@dev This will add a new role/s to the account
15421546
without effecting any of the previously held roles.
15431547
@param account The account to add a role to.
1544-
@param role The new role to add to account.
1548+
@param role The new role/s to add to account.
15451549
"""
15461550
assert msg.sender == self.role_manager
1547-
self.roles[account] = self.roles[account] | role
1551+
new_roles: Roles = self.roles[account] | role
1552+
self.roles[account] = new_roles
15481553

1549-
log RoleSet(account, self.roles[account])
1554+
log RoleSet(account, new_roles)
15501555

15511556
@external
15521557
def remove_role(account: address, role: Roles):
15531558
"""
1554-
@notice Remove a single role from an account.
1559+
@notice Remove a role/s from an account.
15551560
@dev This will leave all other roles for the
15561561
account unchanged.
1557-
@param account The account to remove a Role from.
1558-
@param role The Role to remove.
1562+
@param account The account to remove a Role/s from.
1563+
@param role The Role/s to remove.
15591564
"""
15601565
assert msg.sender == self.role_manager
1561-
self.roles[account] = self.roles[account] & ~role
1566+
new_roles: Roles = self.roles[account] & ~role
1567+
self.roles[account] = new_roles
15621568

1563-
log RoleSet(account, self.roles[account])
1569+
log RoleSet(account, new_roles)
15641570

15651571
@external
15661572
def transfer_role_manager(role_manager: address):
@@ -1574,6 +1580,8 @@ def transfer_role_manager(role_manager: address):
15741580
assert msg.sender == self.role_manager
15751581
self.future_role_manager = role_manager
15761582

1583+
log UpdateFutureRoleManager(role_manager)
1584+
15771585
@external
15781586
def accept_role_manager():
15791587
"""
@@ -1671,15 +1679,16 @@ def buy_debt(strategy: address, amount: uint256):
16711679

16721680
self._erc20_safe_transfer_from(self.asset, msg.sender, self, _amount)
16731681

1674-
# Lower strategy debt
1675-
self.strategies[strategy].current_debt -= _amount
1682+
# Lower strategy debt
1683+
new_debt: uint256 = unsafe_sub(current_debt, _amount)
1684+
self.strategies[strategy].current_debt = new_debt
16761685
# lower total debt
16771686
self.total_debt -= _amount
16781687
# Increase total idle
16791688
self.total_idle += _amount
16801689

16811690
# log debt change
1682-
log DebtUpdated(strategy, current_debt, current_debt - _amount)
1691+
log DebtUpdated(strategy, current_debt, new_debt)
16831692

16841693
# Transfer the strategies shares out.
16851694
self._erc20_safe_transfer(strategy, msg.sender, shares)
@@ -1746,7 +1755,7 @@ def update_debt(
17461755
@param strategy The strategy to update the debt for.
17471756
@param target_debt The target debt for the strategy.
17481757
@param max_loss Optional to check realized losses on debt decreases.
1749-
@return The amount of debt added or removed.
1758+
@return The new current debt of the strategy.
17501759
"""
17511760
self._enforce_role(msg.sender, Roles.DEBT_MANAGER)
17521761
return self._update_debt(strategy, target_debt, max_loss)
@@ -1772,7 +1781,10 @@ def shutdown_vault():
17721781
self.deposit_limit = 0
17731782
log UpdateDepositLimit(0)
17741783

1775-
self.roles[msg.sender] = self.roles[msg.sender] | Roles.DEBT_MANAGER
1784+
new_roles: Roles = self.roles[msg.sender] | Roles.DEBT_MANAGER
1785+
self.roles[msg.sender] = new_roles
1786+
log RoleSet(msg.sender, new_roles)
1787+
17761788
log Shutdown()
17771789

17781790

@@ -2099,7 +2111,7 @@ def FACTORY() -> address:
20992111
"""
21002112
return self.factory
21012113

2102-
@view
2114+
@pure
21032115
@external
21042116
def apiVersion() -> String[28]:
21052117
"""

tests/integration/address_book.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yearn vaults 3.0.3 factory
2-
yearn_vault_factory = "0x5577EdcB8A856582297CdBbB07055E6a6E38eb5f"
3-
vault_original = "0xcA78AF7443f3F8FA0148b746Cb18FF67383CDF3f"
2+
yearn_vault_factory = "0x770D0d1Fb036483Ed4AbB6d53c1C88fb277D812F"
3+
vault_original = "0xd8063123BBA3B480569244AE66BFE72B6c84b00d"
44

55
crvusd = "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E"
66
crvusd_controller_factory = "0xC9332fdCB1C491Dcc683bAe86Fe3cb70360738BC"

0 commit comments

Comments
 (0)