@@ -294,6 +294,41 @@ contract Stake is QueryTypeStakingPoolTest {
294294 pool.stake (_amount);
295295 }
296296
297+ function testFuzz_StakesTokensAfterUsersHaveBeenBlacklisted (
298+ uint48 _amount ,
299+ uint128 _capacity ,
300+ address _blockedStaker
301+ ) public {
302+ vm.assume (_blockedStaker != address (0 ));
303+ // Stake greater than staking capacity
304+ // total blocked is greater than the difference
305+ _capacity = uint128 (bound (_capacity, 4 , type (uint128 ).max));
306+ _amount = uint48 (bound (_amount, 2 , _capacity - 2 ));
307+
308+ stakingToken.mint (_blockedStaker, _amount);
309+ vm.prank (_blockedStaker);
310+ stakingToken.approve (address (pool), type (uint256 ).max);
311+
312+ stakingToken.mint (staker, _capacity);
313+ vm.prank (staker);
314+ stakingToken.approve (address (pool), type (uint256 ).max);
315+
316+ pool.setStakingTokenCapacity (_capacity);
317+
318+ vm.prank (staker);
319+ pool.stake (_amount / 2 );
320+
321+ vm.prank (_blockedStaker);
322+ pool.stake (_amount / 2 );
323+
324+ pool.blocklist (_blockedStaker);
325+
326+ vm.expectRevert (QueryTypeStakingPool.QueryTypeStakingPool__CapacityExceeded.selector );
327+ vm.prank (staker);
328+ pool.stake (_capacity);
329+
330+ }
331+
297332 function testFuzz_RevertIf_StakeAmountBelowMinimum (
298333 uint256 _amount ,
299334 uint256 _minimumStake ,
@@ -492,7 +527,7 @@ contract Unstake is QueryTypeStakingPoolTest {
492527 assertEq (remainingStakeAfter.amount, _remainingStake - _unstakeAmt);
493528 assertEq (remainingStakeAfter.capacity, remainingStakeAfter.amount);
494529
495- assertEq (pool.totalCapacityStaked (), _stakeAmount - _unstakeAmt);
530+ assertEq (pool.totalCapacityStaked (), _stakeAmount - _unstakeAmt - (_preDecayStake.amount - _remainingStake) );
496531 }
497532
498533 function testFuzz_UnstakeAfterMultipleStakes (
@@ -536,7 +571,7 @@ contract Unstake is QueryTypeStakingPoolTest {
536571 QueryTypeStakingPool.StakeInfo memory remainingStakeAfter = _getStakeInfo (staker);
537572 assertEq (remainingStakeAfter.amount, _remainingStake - _unstakeAmt);
538573 assertEq (remainingStakeAfter.capacity, remainingStakeAfter.amount);
539- assertEq (pool.totalCapacityStaked (), totalStaked - _unstakeAmt);
574+ assertEq (pool.totalCapacityStaked (), totalStaked - _unstakeAmt - (preDecayStake.amount - _remainingStake) );
540575 }
541576
542577 function testFuzz_RevertIf_TokenTransferFails (
@@ -731,7 +766,7 @@ contract Unstake is QueryTypeStakingPoolTest {
731766
732767 assertEq (
733768 pool.totalCapacityJailed (),
734- _initialTotalJailed - _unstakeAmount,
769+ _initialTotalJailed - _unstakeAmount - (_stakeAmount - _remainingStake) ,
735770 "Total jailed should decrease by unstake amount "
736771 );
737772 assertEq (pool.totalCapacityStaked (), 0 , "Total staked should be zero after jail scenario " );
@@ -1005,7 +1040,7 @@ contract Blocklist is QueryTypeStakingPoolTest {
10051040 assertEq (userBalanceAfter - userBalanceBefore, _unstakeAmount);
10061041
10071042 // Verify capacity accounting is correct after unstake
1008- assertEq (pool.totalCapacityJailed (), _stakeAmount - _unstakeAmount);
1043+ assertEq (pool.totalCapacityJailed (), _stakeAmount - _unstakeAmount - _decayed );
10091044 assertEq (pool.totalCapacityStaked (), 0 );
10101045
10111046 // Verify remaining stake amount
@@ -1032,20 +1067,16 @@ contract Blocklist is QueryTypeStakingPoolTest {
10321067 // Blocklist the user
10331068 pool.blocklist (user);
10341069
1035- // Verify initial state
1036- assertTrue (pool.isBlocklisted (user));
1037- assertEq (pool.totalCapacityJailed (), stakeAmount);
1038- assertEq (pool.totalCapacityStaked (), 0 );
1039-
10401070 // User unstakes full amount
10411071 uint256 userBalanceBefore = stakingToken.balanceOf (user);
1072+ uint256 _decayed = _expectedDecay (user, stakeAmount, pool.lockupPeriod () + 1 );
10421073
10431074 vm.prank (user);
1044- pool.unstake (stakeAmount);
1075+ pool.unstake (stakeAmount - _decayed );
10451076
10461077 // Verify the unstake was successful
10471078 uint256 userBalanceAfter = stakingToken.balanceOf (user);
1048- assertEq (userBalanceAfter - userBalanceBefore, stakeAmount);
1079+ assertEq (userBalanceAfter - userBalanceBefore, stakeAmount - _decayed );
10491080
10501081 // Verify all capacity has been freed
10511082 assertEq (pool.totalCapacityJailed (), 0 );
0 commit comments