-
-
Save dplamenov/8b418e46bc355a51fb7c037722a0e61e to your computer and use it in GitHub Desktop.
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
function repayLoan(ERC20 token_, uint256 amount_) external nonReentrant { | |
if (reserveDebt[token_][msg.sender] == 0) revert TRSRY_NoDebtOutstanding(); | |
// Deposit from caller first (to handle nonstandard token transfers) | |
token_.safeTransferFrom(msg.sender, address(this), amount_); | |
// Subtract debt from caller | |
reserveDebt[token_][msg.sender] -= amount_; | |
totalDebt[token_] -= amount_; | |
emit DebtRepaid(token_, msg.sender, amount_); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment