mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
Fixed max withdrawal bug
This commit is contained in:
parent
ee9e1b39d0
commit
d383ec4e3a
|
@ -165,7 +165,6 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||||
function withdraw(uint tknAmt, address to) external nonReentrant whenNotPaused returns (uint _tknAmt) {
|
function withdraw(uint tknAmt, address to) external nonReentrant whenNotPaused returns (uint _tknAmt) {
|
||||||
uint poolBal = baseToken.balanceOf(address(this));
|
uint poolBal = baseToken.balanceOf(address(this));
|
||||||
require(to != address(0), "to-address-not-vaild");
|
require(to != address(0), "to-address-not-vaild");
|
||||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
|
||||||
uint _bal = balanceOf(msg.sender);
|
uint _bal = balanceOf(msg.sender);
|
||||||
uint _tknBal = wdiv(_bal, exchangeRate);
|
uint _tknBal = wdiv(_bal, exchangeRate);
|
||||||
uint _burnAmt;
|
uint _burnAmt;
|
||||||
|
@ -176,6 +175,7 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||||
_burnAmt = wmul(tknAmt, exchangeRate);
|
_burnAmt = wmul(tknAmt, exchangeRate);
|
||||||
_tknAmt = tknAmt;
|
_tknAmt = tknAmt;
|
||||||
}
|
}
|
||||||
|
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
||||||
|
|
||||||
tokenBalance = sub(tokenBalance, _tknAmt);
|
tokenBalance = sub(tokenBalance, _tknAmt);
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,6 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
function withdraw(uint tknAmt, address to) external nonReentrant whenNotPaused returns (uint _tknAmt) {
|
function withdraw(uint tknAmt, address to) external nonReentrant whenNotPaused returns (uint _tknAmt) {
|
||||||
uint poolBal = address(this).balance;
|
uint poolBal = address(this).balance;
|
||||||
require(to != address(0), "to-address-not-vaild");
|
require(to != address(0), "to-address-not-vaild");
|
||||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
|
||||||
uint _bal = balanceOf(msg.sender);
|
uint _bal = balanceOf(msg.sender);
|
||||||
uint _tknBal = wdiv(_bal, exchangeRate);
|
uint _tknBal = wdiv(_bal, exchangeRate);
|
||||||
uint _burnAmt;
|
uint _burnAmt;
|
||||||
|
@ -172,6 +171,7 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
_burnAmt = wmul(tknAmt, exchangeRate);
|
_burnAmt = wmul(tknAmt, exchangeRate);
|
||||||
_tknAmt = tknAmt;
|
_tknAmt = tknAmt;
|
||||||
}
|
}
|
||||||
|
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
||||||
|
|
||||||
tokenBalance = sub(tokenBalance, _tknAmt);
|
tokenBalance = sub(tokenBalance, _tknAmt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user