@rev-net/core-v6 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/REVLoans.sol +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rev-net/core-v6",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@bananapus/721-hook-v6": "^0.0.47",
30
30
  "@bananapus/buyback-hook-v6": "^0.0.39",
31
- "@bananapus/core-v6": "^0.0.44",
31
+ "@bananapus/core-v6": "^0.0.48",
32
32
  "@bananapus/ownable-v6": "^0.0.24",
33
33
  "@bananapus/permission-ids-v6": "^0.0.24",
34
34
  "@bananapus/router-terminal-v6": "^0.0.37",
package/src/REVLoans.sol CHANGED
@@ -62,6 +62,7 @@ contract REVLoans is ERC721, ERC2771Context, JBPermissioned, Ownable, IREVLoans
62
62
  error REVLoans_InvalidTerminal(address terminal, uint256 revnetId);
63
63
  error REVLoans_LoanExpired(uint256 timeSinceLoanCreated, uint256 loanLiquidationDuration);
64
64
  error REVLoans_LoanIdOverflow(uint256 revnetId, uint256 loanNumber, uint256 maxLoanNumber);
65
+ error REVLoans_LoanOwnerChanged(uint256 loanId, address expectedOwner, address actualOwner);
65
66
  error REVLoans_NewBorrowAmountGreaterThanLoanAmount(uint256 newBorrowAmount, uint256 loanAmount);
66
67
  error REVLoans_NoMsgValueAllowed(uint256 msgValue, address token);
67
68
  error REVLoans_NotEnoughCollateral(uint256 collateralCountToRemove, uint256 loanCollateral);
@@ -884,6 +885,16 @@ contract REVLoans is ERC721, ERC2771Context, JBPermissioned, Ownable, IREVLoans
884
885
  maxRepayBorrowAmount =
885
886
  _acceptFundsFor({token: loan.source.token, amount: maxRepayBorrowAmount, allowance: allowance});
886
887
 
888
+ // Re-check ownership: an ERC-777/ERC-1363 source token can reenter during the transfer above and transfer
889
+ // the loan NFT to another account. Without this check, `_repayLoan` would burn the new owner's NFT while
890
+ // returning collateral to the stale cached owner.
891
+ {
892
+ address currentOwner = _ownerOf(loanId);
893
+ if (currentOwner != loanOwner) {
894
+ revert REVLoans_LoanOwnerChanged({loanId: loanId, expectedOwner: loanOwner, actualOwner: currentOwner});
895
+ }
896
+ }
897
+
887
898
  // Make sure the minimum borrow amount is met.
888
899
  if (repayBorrowAmount > maxRepayBorrowAmount) {
889
900
  revert REVLoans_OverMaxRepayBorrowAmount({