@@ -112,6 +112,9 @@ event RoleSet:
112
112
role: indexed (Roles)
113
113
114
114
# STORAGE MANAGEMENT EVENTS
115
+ event UpdateFutureRoleManager:
116
+ future_role_manager: indexed (address )
117
+
115
118
event UpdateRoleManager:
116
119
role_manager: indexed (address )
117
120
@@ -861,7 +864,7 @@ def _redeem(
861
864
862
865
# NOTE: strategy's debt decreases by the full amount but the total idle increases
863
866
# 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) )
865
868
requested_assets -= loss
866
869
current_total_debt -= assets_to_withdraw
867
870
@@ -928,14 +931,11 @@ def _add_strategy(new_strategy: address, add_to_queue: bool):
928
931
@internal
929
932
def _revoke_strategy (strategy: address , force: bool = False ):
930
933
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
934
934
935
935
if self .strategies[strategy].current_debt != 0 :
936
936
assert force, "strategy has debt "
937
937
# Vault realizes the full loss of outstanding debt.
938
- loss = self .strategies[strategy].current_debt
938
+ loss: uint256 = self .strategies[strategy].current_debt
939
939
# Adjust total vault debt.
940
940
self .total_debt -= loss
941
941
@@ -1031,7 +1031,7 @@ def _update_debt(strategy: address, target_debt: uint256, max_loss: uint256) ->
1031
1031
# If we didn't get the amount we asked for and there is a max loss.
1032
1032
if withdrawn < assets_to_withdraw and max_loss < MAX_BPS:
1033
1033
# 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 "
1035
1035
1036
1036
# If we got too much make sure not to increase PPS.
1037
1037
elif withdrawn > assets_to_withdraw:
@@ -1257,16 +1257,20 @@ def _process_report(strategy: address) -> (uint256, uint256):
1257
1257
self .strategies[strategy].current_debt = current_debt
1258
1258
self .total_debt += gain
1259
1259
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
+
1262
1264
# Or record any reported loss
1263
1265
elif loss > 0 :
1264
1266
current_debt = unsafe_sub (current_debt, loss)
1265
1267
if strategy != self :
1266
1268
self .strategies[strategy].current_debt = current_debt
1267
1269
self .total_debt -= loss
1268
1270
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
1270
1274
1271
1275
# Issue shares for fees that were calculated above if applicable.
1272
1276
if total_fees_shares > 0 :
@@ -1537,30 +1541,32 @@ def set_role(account: address, role: Roles):
1537
1541
@external
1538
1542
def add_role (account: address , role: Roles):
1539
1543
"""
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
1542
1546
without effecting any of the previously held roles.
1543
1547
@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.
1545
1549
"""
1546
1550
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
1548
1553
1549
- log RoleSet (account, self .roles[account] )
1554
+ log RoleSet (account, new_roles )
1550
1555
1551
1556
@external
1552
1557
def remove_role (account: address , role: Roles):
1553
1558
"""
1554
- @notice Remove a single role from an account.
1559
+ @notice Remove a role/s from an account.
1555
1560
@dev This will leave all other roles for the
1556
1561
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.
1559
1564
"""
1560
1565
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
1562
1568
1563
- log RoleSet (account, self .roles[account] )
1569
+ log RoleSet (account, new_roles )
1564
1570
1565
1571
@external
1566
1572
def transfer_role_manager (role_manager: address ):
@@ -1574,6 +1580,8 @@ def transfer_role_manager(role_manager: address):
1574
1580
assert msg .sender == self .role_manager
1575
1581
self .future_role_manager = role_manager
1576
1582
1583
+ log UpdateFutureRoleManager (role_manager)
1584
+
1577
1585
@external
1578
1586
def accept_role_manager ():
1579
1587
"""
@@ -1671,15 +1679,16 @@ def buy_debt(strategy: address, amount: uint256):
1671
1679
1672
1680
self ._erc20_safe_transfer_from (self .asset, msg .sender , self , _amount)
1673
1681
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
1676
1685
# lower total debt
1677
1686
self .total_debt -= _amount
1678
1687
# Increase total idle
1679
1688
self .total_idle += _amount
1680
1689
1681
1690
# log debt change
1682
- log DebtUpdated (strategy, current_debt, current_debt - _amount )
1691
+ log DebtUpdated (strategy, current_debt, new_debt )
1683
1692
1684
1693
# Transfer the strategies shares out.
1685
1694
self ._erc20_safe_transfer (strategy, msg .sender , shares)
@@ -1746,7 +1755,7 @@ def update_debt(
1746
1755
@param strategy The strategy to update the debt for.
1747
1756
@param target_debt The target debt for the strategy.
1748
1757
@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 .
1750
1759
"""
1751
1760
self ._enforce_role (msg .sender , Roles.DEBT_MANAGER)
1752
1761
return self ._update_debt (strategy, target_debt, max_loss)
@@ -1772,7 +1781,10 @@ def shutdown_vault():
1772
1781
self .deposit_limit = 0
1773
1782
log UpdateDepositLimit (0 )
1774
1783
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
+
1776
1788
log Shutdown ()
1777
1789
1778
1790
@@ -2099,7 +2111,7 @@ def FACTORY() -> address:
2099
2111
"""
2100
2112
return self .factory
2101
2113
2102
- @view
2114
+ @pure
2103
2115
@external
2104
2116
def apiVersion () -> String[28 ]:
2105
2117
"""
0 commit comments