Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 42 - prevent re-entrancy on repay #81

Open
wants to merge 1 commit into
base: merge-train-r5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/contracts/contracts/TellerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,15 @@ contract TellerV2 is
emit LoanRepayment(_bidId);
}

_sendOrEscrowFunds(_bidId, _payment); //send or escrow the funds


// update our mappings
bid.loanDetails.totalRepaid.principal += _payment.principal;
bid.loanDetails.totalRepaid.interest += _payment.interest;
bid.loanDetails.lastRepaidTimestamp = uint32(block.timestamp);

//perform this after state change to mitigate re-entrancy
_sendOrEscrowFunds(_bidId, _payment); //send or escrow the funds

// If the loan is paid in full and has a mark, we should update the current reputation
if (mark != RepMark.Good) {
Expand Down
Loading