Skip to content

Commit

Permalink
fix: handleClaimOfRepossessed gas optimization (c4 #66)
Browse files Browse the repository at this point in the history
  • Loading branch information
deluca-mike committed Dec 12, 2021
1 parent b97df8a commit 4a4c954
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions contracts/DebtLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxied {
// Funds recovered from liquidation and any unclaimed previous payment amounts
uint256 recoveredFunds = IERC20Like(fundsAsset).balanceOf(address(this)) - fundsCaptured;

uint256 totalClaimed = recoveredFunds + fundsCaptured;

// If `recoveredFunds` is greater than `principalToCover`, the remaining amount is treated as interest in the context of the pool.
// If `recoveredFunds` is less than `principalToCover`, the difference is registered as a shortfall.
details_[0] = recoveredFunds + fundsCaptured;
details_[0] = totalClaimed;
details_[1] = recoveredFunds > principalToCover ? recoveredFunds - principalToCover : 0;
details_[2] = fundsCaptured;
details_[5] = recoveredFunds > principalToCover ? principalToCover : recoveredFunds;
Expand All @@ -210,7 +212,7 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxied {
_fundsToCapture = uint256(0);
_repossessed = false;

require(ERC20Helper.transfer(fundsAsset, _pool, recoveredFunds + fundsCaptured), "DL:HCOR:TRANSFER");
require(ERC20Helper.transfer(fundsAsset, _pool, totalClaimed), "DL:HCOR:TRANSFER");
}

/**********************/
Expand Down

0 comments on commit 4a4c954

Please sign in to comment.