Skip to content

Commit

Permalink
chore: lower unlocked gas
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Jan 12, 2024
1 parent ba2c961 commit ffe6809
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ balance_of: HashMap[address, uint256]
# ERC20 - owner -> (spender -> amount)
allowance: public(HashMap[address, HashMap[address, uint256]])
# Total amount of shares that are currently minted including those locked.
# NOTE: To get the ERC20 compliant version user totalSupply().
total_supply: public(uint256)
total_supply: uint256
# Total amount of assets that has been deposited in strategies.
total_debt: uint256
# Current assets held in the vault contract. Replacing balanceOf(this) to avoid price_per_share manipulation.
Expand Down Expand Up @@ -419,14 +418,13 @@ def _burn_unlocked_shares():
# Get the amount of shares that have unlocked
unlocked_shares: uint256 = self._unlocked_shares()

# Update last profit time no matter what.
self.last_profit_update = block.timestamp

# IF 0 there's nothing to do.
if unlocked_shares == 0:
return

# Only do an SSTORE if necessary
if self.full_profit_unlock_date > block.timestamp:
self.last_profit_update = block.timestamp

# Burn the shares unlocked.
self._burn_shares(unlocked_shares, self)

Expand Down Expand Up @@ -1300,13 +1298,11 @@ def _process_report(strategy: address) -> (uint256, uint256):
self.profit_unlocking_rate = total_locked_shares * MAX_BPS_EXTENDED / new_profit_locking_period
# Calculate how long until the full amount of shares is unlocked.
self.full_profit_unlock_date = block.timestamp + new_profit_locking_period
# Update the last profitable report timestamp.
self.last_profit_update = block.timestamp

else:
# NOTE: only setting this to 0 will turn in the desired effect, no need
# to update last_profit_update or full_profit_unlock_date
self.profit_unlocking_rate = 0
# NOTE: only setting this to the current timestamp will turn in the desired effect,
# no need to update profit_unlocking_rate
self.full_profit_unlock_date = block.timestamp

# Record the report of profit timestamp.
self.strategies[strategy].last_report = block.timestamp
Expand Down

0 comments on commit ffe6809

Please sign in to comment.