withdraw insurance amount function

This commit is contained in:
Samyak Jain 2020-08-30 01:24:21 +10:00
parent f8c117c513
commit bb675975ce
2 changed files with 26 additions and 0 deletions

View File

@ -155,6 +155,19 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
emit LogAddInsurance(tknAmt);
}
function withdrawInsurance(uint tknAmt) external payable {
require(msg.sender == instaIndex.master(), "not-master");
require(tknAmt <= insuranceAmt || tknAmt == uint(-1), "not-enough-insurance");
if (tknAmt == uint(-1)) {
baseToken.safeTransfer(msg.sender, insuranceAmt);
insuranceAmt = 0;
} else {
baseToken.safeTransfer(msg.sender, tknAmt);
insuranceAmt = sub(insuranceAmt, tknAmt);
}
emit LogAddInsurance(tknAmt);
}
function shutdown() external {
require(msg.sender == instaIndex.master(), "not-master");
paused() ? _unpause() : _pause();

View File

@ -148,6 +148,19 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
emit LogAddInsurance(tknAmt);
}
function withdrawInsurance(uint tknAmt) external payable {
require(msg.sender == instaIndex.master(), "not-master");
require(tknAmt <= insuranceAmt || tknAmt == uint(-1), "not-enough-insurance");
if (tknAmt == uint(-1)) {
msg.sender.transfer(insuranceAmt);
insuranceAmt = 0;
} else {
msg.sender.transfer(tknAmt);
insuranceAmt = sub(insuranceAmt, tknAmt);
}
emit LogAddInsurance(tknAmt);
}
function shutdown() external {
require(msg.sender == instaIndex.master(), "not-master");
paused() ? _unpause() : _pause();