Skip to content

Commit

Permalink
bug: move transfer only at the end to prevent reentrancy
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMist committed Mar 21, 2024
1 parent 919b164 commit 236a1d3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/VaultTest#Vault.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7068
7075
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56136
56176
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36474
36514
3 changes: 2 additions & 1 deletion src/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ contract Vault is IVault, VaultToken, Ownable {
// msg.sender owes vault but paid more than than whats owed
refund = paid - currentDelta.toUint256();
paid = currentDelta.toUint256();
currency.transfer(to, refund);
}

reservesOfVault[currency] += paid;
SettlementGuard.accountDelta(msg.sender, currency, -(paid.toInt128()));

if (refund > 0) currency.transfer(to, refund);
}

/// @inheritdoc IVault
Expand Down

0 comments on commit 236a1d3

Please sign in to comment.