From ee9e1b39d052d1b8b388c6eee91febd7d22fd625 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Mon, 31 Aug 2020 12:54:45 +0530 Subject: [PATCH] Set max if amount higher than max withdraw amount --- contracts/pools/erc20.sol | 3 +-- contracts/pools/eth.sol | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/pools/erc20.sol b/contracts/pools/erc20.sol index e5f71da..00c7e3c 100644 --- a/contracts/pools/erc20.sol +++ b/contracts/pools/erc20.sol @@ -169,11 +169,10 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable { uint _bal = balanceOf(msg.sender); uint _tknBal = wdiv(_bal, exchangeRate); uint _burnAmt; - if (tknAmt == uint(-1)) { + if (tknAmt >= _tknBal) { _burnAmt = _bal; _tknAmt = _tknBal; } else { - require(tknAmt <= _tknBal, "balance-exceeded"); _burnAmt = wmul(tknAmt, exchangeRate); _tknAmt = tknAmt; } diff --git a/contracts/pools/eth.sol b/contracts/pools/eth.sol index d6a8932..b184ccf 100644 --- a/contracts/pools/eth.sol +++ b/contracts/pools/eth.sol @@ -165,11 +165,10 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath { uint _bal = balanceOf(msg.sender); uint _tknBal = wdiv(_bal, exchangeRate); uint _burnAmt; - if (tknAmt == uint(-1)) { + if (tknAmt >= _tknBal) { _burnAmt = _bal; _tknAmt = _tknBal; } else { - require(tknAmt <= _tknBal, "balance-exceeded"); _burnAmt = wmul(tknAmt, exchangeRate); _tknAmt = tknAmt; }