mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
Merge pull request #2 from InstaDApp/fix-pausable
fixed ERC20Pausable and added ReentrancyGuard
This commit is contained in:
commit
8bde5a5d0f
|
@ -1,3 +1,4 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
interface IProxy {
|
interface IProxy {
|
||||||
|
@ -64,4 +65,4 @@ contract Deployer {
|
||||||
bytes15 c = bytes15(0x5af43d82803e903d91602b57fd5bf3);
|
bytes15 c = bytes15(0x5af43d82803e903d91602b57fd5bf3);
|
||||||
return abi.encodePacked(a, b, c);
|
return abi.encodePacked(a, b, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
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 "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||||
|
|
||||||
import { DSMath } from "./libs/safeMath.sol";
|
import { DSMath } from "./libs/safeMath.sol";
|
||||||
|
|
||||||
// TODO - Add ReentrancyGuard lib
|
|
||||||
|
|
||||||
interface AccountInterface {
|
interface AccountInterface {
|
||||||
function enable(address authority) external;
|
function enable(address authority) external;
|
||||||
function cast(address[] calldata _targets, bytes[] calldata _datas, address _origin) external payable;
|
function cast(address[] calldata _targets, bytes[] calldata _datas, address _origin) external payable;
|
||||||
|
@ -30,126 +29,121 @@ interface RateInterface {
|
||||||
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract PoolToken is ERC20, DSMath {
|
contract PoolToken is ReentrancyGuard, 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);
|
||||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||||
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt);
|
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt);
|
||||||
event LogAddInsurance(uint amount);
|
event LogAddInsurance(uint amount);
|
||||||
event LogPausePool(bool);
|
event LogPausePool(bool);
|
||||||
|
|
||||||
// IERC20 public immutable baseToken;
|
RegistryInterface public immutable registry; // Pool Registry
|
||||||
RegistryInterface public immutable registry; // Pool Registry
|
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
||||||
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
AccountInterface public immutable dsa; // Pool's DSA account
|
||||||
AccountInterface public immutable dsa; // Pool's DSA account
|
|
||||||
|
|
||||||
IERC20 public immutable baseToken; // Base token. Eg:- DAI, USDC, etc.
|
IERC20 public immutable baseToken; // Base token.
|
||||||
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,
|
||||||
string memory _name,
|
string memory _name,
|
||||||
string memory _symbol,
|
string memory _symbol,
|
||||||
address _baseToken,
|
address _baseToken,
|
||||||
address _origin
|
address _origin
|
||||||
) public ERC20(_name, _symbol) {
|
) public ERC20(_name, _symbol) {
|
||||||
baseToken = IERC20(_baseToken);
|
baseToken = IERC20(_baseToken);
|
||||||
registry = RegistryInterface(_registry);
|
registry = RegistryInterface(_registry);
|
||||||
address _dsa = instaIndex.build(address(this), 1, _origin);
|
address _dsa = instaIndex.build(address(this), 1, _origin);
|
||||||
dsa = AccountInterface(_dsa);
|
dsa = AccountInterface(_dsa);
|
||||||
|
}
|
||||||
|
|
||||||
|
modifier isChief() {
|
||||||
|
require(registry.chief(msg.sender) || msg.sender == instaIndex.master(), "not-chief");
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deploy(uint amount) external isChief {
|
||||||
|
payable(address(dsa)).transfer(amount);
|
||||||
|
emit LogDeploy(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setExchangeRate() public isChief {
|
||||||
|
uint _previousRate = exchangeRate;
|
||||||
|
uint _totalToken = RateInterface(registry.poolLogic(address(this))).getTotalToken();
|
||||||
|
uint _currentRate = wdiv(_totalToken, totalSupply());
|
||||||
|
if (_currentRate < _previousRate) {
|
||||||
|
uint difRate = _previousRate - _currentRate;
|
||||||
|
uint difTkn = wmul(_totalToken, difRate);
|
||||||
|
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||||
|
_currentRate = _previousRate;
|
||||||
|
} else {
|
||||||
|
uint difRate = _currentRate - _previousRate;
|
||||||
|
uint insureFee = wmul(difRate, registry.insureFee(address(this)));
|
||||||
|
uint insureFeeAmt = wmul(_totalToken, insureFee);
|
||||||
|
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||||
|
_currentRate = sub(_currentRate, insureFee);
|
||||||
|
tokenBalance = sub(_totalToken, insuranceAmt);
|
||||||
|
}
|
||||||
|
exchangeRate = _currentRate;
|
||||||
|
emit LogExchangeRate(exchangeRate, tokenBalance, insuranceAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
function settle(address[] calldata _targets, bytes[] calldata _datas, address _origin) external isChief {
|
||||||
|
if (_targets.length > 0 && _datas.length > 0) {
|
||||||
|
dsa.cast(_targets, _datas, _origin);
|
||||||
|
}
|
||||||
|
setExchangeRate();
|
||||||
|
|
||||||
|
emit LogSettle(block.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deposit(uint tknAmt) public whenNotPaused payable returns(uint) {
|
||||||
|
require(tknAmt == msg.value, "unmatched-amount");
|
||||||
|
uint _newTokenBal = add(tokenBalance, msg.value);
|
||||||
|
require(_newTokenBal <= registry.poolCap(address(this)), "deposit-cap-reached");
|
||||||
|
|
||||||
|
uint _mintAmt = wdiv(msg.value, exchangeRate);
|
||||||
|
_mint(msg.sender, _mintAmt);
|
||||||
|
|
||||||
|
emit LogDeposit(tknAmt, _mintAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
uint _tknBal = wmul(_bal, exchangeRate);
|
||||||
|
uint _burnAmt;
|
||||||
|
if (tknAmt == uint(-1)) {
|
||||||
|
_burnAmt = _bal;
|
||||||
|
_tknAmt = wmul(_burnAmt, exchangeRate);
|
||||||
|
} else {
|
||||||
|
require(tknAmt <= _tknBal, "balance-exceeded");
|
||||||
|
_burnAmt = wdiv(tknAmt, exchangeRate);
|
||||||
|
_tknAmt = tknAmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier isChief() {
|
_burn(msg.sender, _burnAmt);
|
||||||
require(registry.chief(msg.sender) || msg.sender == instaIndex.master(), "not-chief");
|
|
||||||
_;
|
|
||||||
}
|
|
||||||
|
|
||||||
function deploy(uint amount) external isChief {
|
payable(to).transfer(_tknAmt);
|
||||||
payable(address(dsa)).transfer(amount);
|
|
||||||
emit LogDeploy(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setExchangeRate() public isChief {
|
emit LogWithdraw(tknAmt, _burnAmt);
|
||||||
uint _previousRate = exchangeRate;
|
}
|
||||||
uint _totalToken = RateInterface(registry.poolLogic(address(this))).getTotalToken();
|
|
||||||
uint _currentRate = wdiv(_totalToken, totalSupply());
|
|
||||||
if (_currentRate < _previousRate) {
|
|
||||||
uint difRate = _previousRate - _currentRate;
|
|
||||||
uint difTkn = wmul(_totalToken, difRate);
|
|
||||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
|
||||||
_currentRate = _previousRate;
|
|
||||||
} else {
|
|
||||||
uint difRate = _currentRate - _previousRate;
|
|
||||||
uint insureFee = wmul(difRate, registry.insureFee(address(this)));
|
|
||||||
uint insureFeeAmt = wmul(_totalToken, insureFee);
|
|
||||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
|
||||||
_currentRate = sub(_currentRate, insureFee);
|
|
||||||
tokenBalance = sub(_totalToken, insuranceAmt);
|
|
||||||
}
|
|
||||||
exchangeRate = _currentRate;
|
|
||||||
emit LogExchangeRate(exchangeRate, tokenBalance, insuranceAmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function settle(address[] calldata _targets, bytes[] calldata _datas, address _origin) external isChief {
|
function addInsurance(uint tknAmt) external payable {
|
||||||
if (_targets.length > 0 && _datas.length > 0) {
|
require(tknAmt == msg.value, "unmatched-amount");
|
||||||
dsa.cast(_targets, _datas, _origin);
|
insuranceAmt += tknAmt;
|
||||||
}
|
emit LogAddInsurance(tknAmt);
|
||||||
setExchangeRate();
|
}
|
||||||
|
|
||||||
emit LogSettle(block.timestamp);
|
function shutdown() external {
|
||||||
}
|
require(msg.sender == instaIndex.master(), "not-master");
|
||||||
|
paused() ? _unpause() : _pause();
|
||||||
|
}
|
||||||
|
|
||||||
function deposit(uint tknAmt) public payable returns(uint) {
|
receive() external payable {}
|
||||||
require(!pausePool, "pool-shut");
|
|
||||||
require(tknAmt == msg.value, "unmatched-amount");
|
|
||||||
uint _newTokenBal = add(tokenBalance, msg.value);
|
|
||||||
require(_newTokenBal <= registry.poolCap(address(this)), "deposit-cap-reached");
|
|
||||||
|
|
||||||
uint _mintAmt = wdiv(msg.value, exchangeRate);
|
|
||||||
_mint(msg.sender, _mintAmt);
|
|
||||||
|
|
||||||
emit LogDeposit(tknAmt, _mintAmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function withdraw(uint tknAmt, address to) external returns (uint _tknAmt) {
|
|
||||||
require(!pausePool, "pool-shut");
|
|
||||||
uint poolBal = address(this).balance;
|
|
||||||
require(tknAmt <= poolBal, "not-enough-liquidity-available");
|
|
||||||
uint _bal = balanceOf(msg.sender);
|
|
||||||
uint _tknBal = wmul(_bal, exchangeRate);
|
|
||||||
uint _burnAmt;
|
|
||||||
if (tknAmt == uint(-1)) {
|
|
||||||
_burnAmt = _bal;
|
|
||||||
_tknAmt = wmul(_burnAmt, exchangeRate);
|
|
||||||
} else {
|
|
||||||
require(tknAmt <= _tknBal, "balance-exceeded");
|
|
||||||
_burnAmt = wdiv(tknAmt, exchangeRate);
|
|
||||||
_tknAmt = tknAmt;
|
|
||||||
}
|
|
||||||
|
|
||||||
_burn(msg.sender, _burnAmt);
|
|
||||||
|
|
||||||
payable(to).transfer(_tknAmt); // TODO - if this is also Reentrancy prone attack or not.
|
|
||||||
|
|
||||||
emit LogWithdraw(tknAmt, _burnAmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addInsurance(uint tknAmt) external payable {
|
|
||||||
require(tknAmt == msg.value, "unmatched-amount");
|
|
||||||
insuranceAmt += tknAmt;
|
|
||||||
emit LogAddInsurance(tknAmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function shutdown() external {
|
|
||||||
require(msg.sender == instaIndex.master(), "not-master");
|
|
||||||
pausePool = !pausePool;
|
|
||||||
emit LogPausePool(pausePool);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -155,4 +156,4 @@ contract Flusher {
|
||||||
|
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
pragma solidity ^0.6.8;
|
pragma solidity ^0.6.8;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
||||||
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||||
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
|
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
|
||||||
|
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||||
|
|
||||||
import { DSMath } from "./libs/safeMath.sol";
|
import { DSMath } from "./libs/safeMath.sol";
|
||||||
|
|
||||||
|
@ -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 ReentrancyGuard, 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,
|
||||||
|
@ -69,82 +68,80 @@ contract PoolToken is DSMath, ERC20, ERC20Pausable {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deploy(uint amount) public isChief {
|
function deploy(uint amount) public isChief {
|
||||||
baseToken.safeTransfer(address(dsa), amount);
|
baseToken.safeTransfer(address(dsa), amount);
|
||||||
emit LogDeploy(amount);
|
emit LogDeploy(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setExchangeRate() public isChief {
|
function setExchangeRate() public isChief {
|
||||||
uint _previousRate = exchangeRate;
|
uint _previousRate = exchangeRate;
|
||||||
uint _totalToken = RateInterface(registry.poolLogic(address(this))).getTotalToken();
|
uint _totalToken = RateInterface(registry.poolLogic(address(this))).getTotalToken();
|
||||||
uint _currentRate = wdiv(_totalToken, totalSupply());
|
uint _currentRate = wdiv(_totalToken, totalSupply());
|
||||||
if (_currentRate < _previousRate) {
|
if (_currentRate < _previousRate) {
|
||||||
uint difRate = _previousRate - _currentRate;
|
uint difRate = _previousRate - _currentRate;
|
||||||
uint difTkn = wmul(_totalToken, difRate);
|
uint difTkn = wmul(_totalToken, difRate);
|
||||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||||
_currentRate = _previousRate;
|
_currentRate = _previousRate;
|
||||||
} else {
|
} else {
|
||||||
uint difRate = _currentRate - _previousRate;
|
uint difRate = _currentRate - _previousRate;
|
||||||
uint insureFee = wmul(difRate, registry.insureFee(address(this)));
|
uint insureFee = wmul(difRate, registry.insureFee(address(this)));
|
||||||
uint insureFeeAmt = wmul(_totalToken, insureFee);
|
uint insureFeeAmt = wmul(_totalToken, insureFee);
|
||||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||||
_currentRate = sub(_currentRate, insureFee);
|
_currentRate = sub(_currentRate, insureFee);
|
||||||
tokenBalance = sub(_totalToken, insuranceAmt);
|
tokenBalance = sub(_totalToken, insuranceAmt);
|
||||||
}
|
}
|
||||||
exchangeRate = _currentRate;
|
exchangeRate = _currentRate;
|
||||||
emit LogExchangeRate(exchangeRate, tokenBalance, insuranceAmt);
|
emit LogExchangeRate(exchangeRate, tokenBalance, insuranceAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function settle(address[] calldata _targets, bytes[] calldata _datas, address _origin) external isChief {
|
function settle(address[] calldata _targets, bytes[] calldata _datas, address _origin) external isChief {
|
||||||
if (_targets.length > 0 && _datas.length > 0) {
|
if (_targets.length > 0 && _datas.length > 0) {
|
||||||
dsa.cast(_targets, _datas, _origin);
|
dsa.cast(_targets, _datas, _origin);
|
||||||
}
|
}
|
||||||
setExchangeRate();
|
setExchangeRate();
|
||||||
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");
|
|
||||||
|
|
||||||
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
||||||
uint _mintAmt = wdiv(tknAmt, exchangeRate);
|
uint _mintAmt = wdiv(tknAmt, exchangeRate);
|
||||||
_mint(msg.sender, _mintAmt);
|
_mint(msg.sender, _mintAmt);
|
||||||
|
|
||||||
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 nonReentrant 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);
|
uint _tknBal = wmul(_bal, exchangeRate);
|
||||||
uint _tknBal = wmul(_bal, exchangeRate);
|
uint _burnAmt;
|
||||||
uint _burnAmt;
|
if (tknAmt == uint(-1)) {
|
||||||
if (tknAmt == uint(-1)) {
|
_burnAmt = _bal;
|
||||||
_burnAmt = _bal;
|
_tknAmt = wmul(_burnAmt, exchangeRate);
|
||||||
_tknAmt = wmul(_burnAmt, exchangeRate);
|
} else {
|
||||||
} else {
|
require(tknAmt <= _tknBal, "balance-exceeded");
|
||||||
require(tknAmt <= _tknBal, "balance-exceeded");
|
_burnAmt = wdiv(tknAmt, exchangeRate);
|
||||||
_burnAmt = wdiv(tknAmt, exchangeRate);
|
_tknAmt = tknAmt;
|
||||||
_tknAmt = tknAmt;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_burn(msg.sender, _burnAmt);
|
_burn(msg.sender, _burnAmt);
|
||||||
|
|
||||||
baseToken.safeTransfer(to, _tknAmt);
|
baseToken.safeTransfer(to, _tknAmt);
|
||||||
|
|
||||||
emit LogWithdraw(tknAmt, _burnAmt);
|
emit LogWithdraw(tknAmt, _burnAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addInsurance(uint tknAmt) external payable {
|
function addInsurance(uint tknAmt) external payable {
|
||||||
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
||||||
insuranceAmt += tknAmt;
|
insuranceAmt += tknAmt;
|
||||||
emit LogAddInsurance(tknAmt);
|
emit LogAddInsurance(tknAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdown() external {
|
function shutdown() external {
|
||||||
require(msg.sender == instaIndex.master(), "not-master");
|
require(msg.sender == instaIndex.master(), "not-master");
|
||||||
paused() ? _unpause() : _pause();
|
paused() ? _unpause() : _pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user