mirror of
				https://github.com/Instadapp/yield-contract.git
				synced 2024-07-29 21:47:29 +00:00 
			
		
		
		
	withdraw insurance amount function
This commit is contained in:
		
							parent
							
								
									f8c117c513
								
							
						
					
					
						commit
						bb675975ce
					
				|  | @ -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(); | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Samyak Jain
						Samyak Jain