Last active
November 13, 2020 23:24
-
-
Save iphelix/20afcf7a67d9bf6ac2cd287ab5c44080 to your computer and use it in GitHub Desktop.
Damn Vulnerable DeFi - Unstoppable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IERC20 public damnValuableToken; | |
uint256 public poolBalance; | |
constructor(address tokenAddress) public { | |
require(tokenAddress != address(0), "Token address cannot be zero"); | |
damnValuableToken = IERC20(tokenAddress); | |
} | |
function depositTokens(uint256 amount) external nonReentrant { | |
require(amount > 0, "Must deposit at least one token"); | |
// Transfer token from sender. Sender must have first approved them. | |
damnValuableToken.transferFrom(msg.sender, address(this), amount); | |
poolBalance = poolBalance.add(amount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment