Skip to content

Commit

Permalink
feat: fixed some potential attack for the fee token manager (#133)
Browse files Browse the repository at this point in the history
* Fixed some potential attack for the fee token manager

* Update contracts/token-manager/implementations/TokenManagerLockUnlockFee.sol

---------

Co-authored-by: Milap Sheth <[email protected]>
  • Loading branch information
Foivos and milapsheth authored Oct 31, 2023
1 parent ed9856a commit 1e4e02b
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ contract TokenManagerLockUnlockFee is TokenManager, NoReEntrancy, ITokenManagerL

token.safeTransferFrom(from, address(this), amount);

return token.balanceOf(address(this)) - balanceBefore;
uint256 diff = token.balanceOf(address(this)) - balanceBefore;
if (diff < amount) {
amount = diff;
}

return amount;
}

/**
Expand All @@ -67,7 +72,12 @@ contract TokenManagerLockUnlockFee is TokenManager, NoReEntrancy, ITokenManagerL

token.safeTransfer(to, amount);

return token.balanceOf(to) - balanceBefore;
uint256 diff = token.balanceOf(to) - balanceBefore;
if (diff < amount) {
amount = diff;
}

return amount;
}

/**
Expand Down

0 comments on commit 1e4e02b

Please sign in to comment.