Skip to content

Commit bc30cac

Browse files
committed
fix: vun Bypass on 30 days lock period
1 parent 87af96c commit bc30cac

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

contracts/talent/TalentVault.sol

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ contract TalentVault is ERC4626, Ownable, ReentrancyGuard {
3737
/// @notice Represents user's balance meta data
3838
/// @param depositedAmount The amount of tokens that were deposited, excluding rewards
3939
/// @param lastRewardCalculation The timestamp (seconds since Epoch) of the last rewards calculation
40+
/// @param firstDepositAt The timestamp of the FIRST deposit (prevents micro-deposit reset)
41+
/// @param lastDepositAt The timestamp of the most recent deposit
4042
struct UserBalanceMeta {
4143
uint256 depositedAmount;
4244
uint256 lastRewardCalculation;
45+
uint256 firstDepositAt;
4346
uint256 lastDepositAt;
4447
}
4548

@@ -242,6 +245,10 @@ contract TalentVault is ERC4626, Ownable, ReentrancyGuard {
242245

243246
balanceMeta.depositedAmount += assets;
244247

248+
if (balanceMeta.firstDepositAt == 0) {
249+
balanceMeta.firstDepositAt = block.timestamp;
250+
}
251+
245252
balanceMeta.lastDepositAt = block.timestamp;
246253

247254
return shares;
@@ -376,13 +383,18 @@ contract TalentVault is ERC4626, Ownable, ReentrancyGuard {
376383
address owner,
377384
uint256 assets,
378385
uint256 shares
379-
) internal virtual override {
380-
UserBalanceMeta storage receiverUserBalanceMeta = userBalanceMeta[receiver];
386+
) internal virtual override {
387+
UserBalanceMeta storage ownerUserBalanceMeta = userBalanceMeta[owner];
381388

382-
if (receiverUserBalanceMeta.lastDepositAt + lockPeriod > block.timestamp) {
389+
if (ownerUserBalanceMeta.firstDepositAt + lockPeriod > block.timestamp) {
383390
revert CantWithdrawWithinTheLockPeriod();
384391
}
385392

386393
super._withdraw(caller, receiver, owner, assets, shares);
394+
395+
if (balanceOf(owner) == 0) {
396+
ownerUserBalanceMeta.firstDepositAt = 0;
397+
ownerUserBalanceMeta.depositedAmount = 0;
398+
}
387399
}
388400
}

0 commit comments

Comments
 (0)