mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
adding ReentrancyGuard
This commit is contained in:
parent
850da87ca3
commit
f96e3199cf
|
@ -5,6 +5,7 @@ pragma experimental ABIEncoderV2;
|
|||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
|
||||
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||
|
||||
import { DSMath } from "./libs/safeMath.sol";
|
||||
|
||||
|
@ -31,7 +32,7 @@ interface RateInterface {
|
|||
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
||||
}
|
||||
|
||||
contract PoolToken is ERC20Pausable, DSMath {
|
||||
contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||
event LogDeploy(uint amount);
|
||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||
event LogSettle(uint settleTime);
|
||||
|
@ -114,7 +115,7 @@ contract PoolToken is ERC20Pausable, DSMath {
|
|||
emit LogDeposit(tknAmt, _mintAmt);
|
||||
}
|
||||
|
||||
function withdraw(uint tknAmt, address to) external whenNotPaused returns (uint _tknAmt) {
|
||||
function withdraw(uint tknAmt, address to) external nonReentrant whenNotPaused returns (uint _tknAmt) {
|
||||
uint poolBal = address(this).balance;
|
||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
||||
uint _bal = balanceOf(msg.sender);
|
||||
|
|
|
@ -5,6 +5,7 @@ pragma experimental ABIEncoderV2;
|
|||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
|
||||
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||
|
||||
import { DSMath } from "./libs/safeMath.sol";
|
||||
|
||||
|
@ -29,7 +30,7 @@ interface RateInterface {
|
|||
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
||||
}
|
||||
|
||||
contract PoolToken is DSMath, ERC20Pausable {
|
||||
contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
event LogDeploy(uint amount);
|
||||
|
@ -112,7 +113,7 @@ contract PoolToken is DSMath, ERC20Pausable {
|
|||
emit LogDeposit(tknAmt, _mintAmt);
|
||||
}
|
||||
|
||||
function withdraw(uint tknAmt, address to) external whenNotPaused returns (uint _tknAmt) {
|
||||
function withdraw(uint tknAmt, address to) external nonReentrant whenNotPaused returns (uint _tknAmt) {
|
||||
uint poolBal = baseToken.balanceOf(address(this));
|
||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
||||
uint _bal = balanceOf(msg.sender);
|
||||
|
|
Loading…
Reference in New Issue
Block a user