Skip to content

Commit

Permalink
♻️ lastHarvestTimestamp -> lastHarvest
Browse files Browse the repository at this point in the history
  • Loading branch information
transmissions11 committed Oct 6, 2021
1 parent 0bbef1a commit ce4383a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ contract Vault is ERC20, Auth {
HARVEST STORAGE
//////////////////////////////////////////////////////////////*/

/// @notice The most recent timestamp where a harvest occurred.
uint256 public lastHarvestTimestamp;
/// @notice A timestamp representing when the last harvest occurred.
uint256 public lastHarvest;

/// @notice The amount of locked profit at the end of the last harvest.
/// @dev Does not change between harvests, instead unlocked profit is computed and subtracted from on the fly.
uint256 public maxLockedProfit;

/// @notice The approximate period in seconds over which locked profits are unlocked.
Expand Down Expand Up @@ -345,9 +344,9 @@ contract Vault is ERC20, Auth {
function lockedProfit() public view returns (uint256) {
// TODO: Cache SLOADs?
return
block.timestamp >= lastHarvestTimestamp + profitUnlockDelay
block.timestamp >= lastHarvest + profitUnlockDelay
? 0 // If profit unlock delay has passed, there is no locked profit.
: maxLockedProfit - (maxLockedProfit * (block.timestamp - lastHarvestTimestamp)) / profitUnlockDelay;
: maxLockedProfit - (maxLockedProfit * (block.timestamp - lastHarvest)) / profitUnlockDelay;
}

/// @notice Returns the amount of underlying tokens that idly sit in the Vault.
Expand Down Expand Up @@ -386,8 +385,8 @@ contract Vault is ERC20, Auth {
: 0 // If the strategy registered a net loss we don't have any new profit to lock.
);

// Set the lastHarvestTimestamp to the current timestamp, as a harvest was just completed.
lastHarvestTimestamp = block.timestamp;
// Set lastHarvest to the current timestamp.
lastHarvest = block.timestamp;

// TODO: Cache SLOAD here?
emit Harvest(strategy, maxLockedProfit);
Expand Down

0 comments on commit ce4383a

Please sign in to comment.