Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions contracts/user/UserManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,14 @@ contract UserManager is Controller, IUserManager, ReentrancyGuardUpgradeable {
comptroller.withdrawRewards(msg.sender, stakingToken);

uint256 remaining = IAssetManager(assetManager).withdraw(stakingToken, msg.sender, amount);
if (remaining > amount) {
if (remaining > 0) {
revert AssetManagerWithdrawFailed();
}
uint96 actualAmount = amount - remaining.toUint96();

staker.stakedAmount -= actualAmount;
totalStaked -= actualAmount;
staker.stakedAmount -= amount;
totalStaked -= amount;

emit LogUnstake(msg.sender, actualAmount);
emit LogUnstake(msg.sender, amount);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"detectors_to_exclude": "external-function|naming-convention|similar-names",
"detectors_to_exclude": "external-function|naming-convention|similar-names|solc-version",
"exclude_informational": true,
"exclude_low": true,
"exclude_medium": false,
Expand Down
2 changes: 1 addition & 1 deletion slither.db.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions test/foundry/userManager/TestStake.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ contract TestStakeAndUnstake is TestUserManagerBase {
abi.encodeWithSelector(AssetManager.withdraw.selector, daiMock, MEMBER, amount),
abi.encode(1 ether)
);
vm.expectRevert(UserManager.AssetManagerWithdrawFailed.selector);
userManager.unstake(amount);
uint256 stakeAmount = userManager.getStakerBalance(MEMBER);
assertEq(stakeAmount, 1 ether);
vm.stopPrank();
}
}