mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
fixed warning messages;
fixed indentation; fixed ERC20Pausable compile issue;
This commit is contained in:
parent
3176c358ba
commit
850da87ca3
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
interface IProxy {
|
interface IProxy {
|
||||||
|
|
|
@ -4,6 +4,7 @@ pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
|
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
|
||||||
|
|
||||||
import { DSMath } from "./libs/safeMath.sol";
|
import { DSMath } from "./libs/safeMath.sol";
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ interface RateInterface {
|
||||||
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract PoolToken is ERC20, DSMath {
|
contract PoolToken is ERC20Pausable, DSMath {
|
||||||
event LogDeploy(uint amount);
|
event LogDeploy(uint amount);
|
||||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||||
event LogSettle(uint settleTime);
|
event LogSettle(uint settleTime);
|
||||||
|
@ -48,7 +49,6 @@ contract PoolToken is ERC20, DSMath {
|
||||||
uint private tokenBalance; // total token balance since last rebalancing
|
uint private tokenBalance; // total token balance since last rebalancing
|
||||||
uint public exchangeRate = 10 ** 18; // initial 1 token = 1
|
uint public exchangeRate = 10 ** 18; // initial 1 token = 1
|
||||||
uint public insuranceAmt; // insurance amount to keep pool safe
|
uint public insuranceAmt; // insurance amount to keep pool safe
|
||||||
bool public pausePool; // shutdown deposits and withdrawals
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address _registry,
|
address _registry,
|
||||||
|
@ -103,8 +103,7 @@ contract PoolToken is ERC20, DSMath {
|
||||||
emit LogSettle(block.timestamp);
|
emit LogSettle(block.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deposit(uint tknAmt) public payable returns(uint) {
|
function deposit(uint tknAmt) public whenNotPaused payable returns(uint) {
|
||||||
require(!pausePool, "pool-shut");
|
|
||||||
require(tknAmt == msg.value, "unmatched-amount");
|
require(tknAmt == msg.value, "unmatched-amount");
|
||||||
uint _newTokenBal = add(tokenBalance, msg.value);
|
uint _newTokenBal = add(tokenBalance, msg.value);
|
||||||
require(_newTokenBal <= registry.poolCap(address(this)), "deposit-cap-reached");
|
require(_newTokenBal <= registry.poolCap(address(this)), "deposit-cap-reached");
|
||||||
|
@ -115,8 +114,7 @@ contract PoolToken is ERC20, DSMath {
|
||||||
emit LogDeposit(tknAmt, _mintAmt);
|
emit LogDeposit(tknAmt, _mintAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function withdraw(uint tknAmt, address to) external returns (uint _tknAmt) {
|
function withdraw(uint tknAmt, address to) external whenNotPaused returns (uint _tknAmt) {
|
||||||
require(!pausePool, "pool-shut");
|
|
||||||
uint poolBal = address(this).balance;
|
uint poolBal = address(this).balance;
|
||||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
||||||
uint _bal = balanceOf(msg.sender);
|
uint _bal = balanceOf(msg.sender);
|
||||||
|
@ -146,8 +144,7 @@ contract PoolToken is ERC20, DSMath {
|
||||||
|
|
||||||
function shutdown() external {
|
function shutdown() external {
|
||||||
require(msg.sender == instaIndex.master(), "not-master");
|
require(msg.sender == instaIndex.master(), "not-master");
|
||||||
pausePool = !pausePool;
|
paused() ? _unpause() : _pause();
|
||||||
emit LogPausePool(pausePool);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ interface RateInterface {
|
||||||
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract PoolToken is DSMath, ERC20, ERC20Pausable {
|
contract PoolToken is DSMath, ERC20Pausable {
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
event LogDeploy(uint amount);
|
event LogDeploy(uint amount);
|
||||||
|
@ -48,7 +48,6 @@ contract PoolToken is DSMath, ERC20, ERC20Pausable {
|
||||||
uint private tokenBalance; // total token balance since last rebalancing
|
uint private tokenBalance; // total token balance since last rebalancing
|
||||||
uint public exchangeRate = 10 ** 18; // initial 1 token = 1
|
uint public exchangeRate = 10 ** 18; // initial 1 token = 1
|
||||||
uint public insuranceAmt; // insurance amount to keep pool safe
|
uint public insuranceAmt; // insurance amount to keep pool safe
|
||||||
bool public pausePool; // shutdown deposits and withdrawals
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address _registry,
|
address _registry,
|
||||||
|
@ -102,8 +101,7 @@ contract PoolToken is DSMath, ERC20, ERC20Pausable {
|
||||||
emit LogSettle(block.timestamp);
|
emit LogSettle(block.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deposit(uint tknAmt) external payable returns(uint) {
|
function deposit(uint tknAmt) external whenNotPaused payable returns(uint) {
|
||||||
require(!pausePool, "pool-shut");
|
|
||||||
uint _newTokenBal = add(tokenBalance, tknAmt);
|
uint _newTokenBal = add(tokenBalance, tknAmt);
|
||||||
require(_newTokenBal <= registry.poolCap(address(this)), "deposit-cap-reached");
|
require(_newTokenBal <= registry.poolCap(address(this)), "deposit-cap-reached");
|
||||||
|
|
||||||
|
@ -114,8 +112,7 @@ contract PoolToken is DSMath, ERC20, ERC20Pausable {
|
||||||
emit LogDeposit(tknAmt, _mintAmt);
|
emit LogDeposit(tknAmt, _mintAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function withdraw(uint tknAmt, address to) external returns (uint _tknAmt) {
|
function withdraw(uint tknAmt, address to) external whenNotPaused returns (uint _tknAmt) {
|
||||||
require(!pausePool, "pool-shut");
|
|
||||||
uint poolBal = baseToken.balanceOf(address(this));
|
uint poolBal = baseToken.balanceOf(address(this));
|
||||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
||||||
uint _bal = balanceOf(msg.sender);
|
uint _bal = balanceOf(msg.sender);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user