Skip to content

Commit

Permalink
feat: emit BadDebtRecovered event
Browse files Browse the repository at this point in the history
  • Loading branch information
kkirka committed Dec 16, 2022
1 parent cb8922e commit 7fbe7fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 10 additions & 4 deletions contracts/VToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1312,13 +1312,19 @@ contract VToken is Ownable2StepUpgradeable, VTokenInterface, ExponentialNoError,
/**
* @notice Updates bad debt
* @dev Called only when bad debt is recovered from auction
* @param badDebt_ The amount of bad debt recovered
* @param recoveredAmount_ The amount of bad debt recovered
* @custom:events Emits BadDebtRecovered event
* @custom:access Only Shortfall contract
*/
function badDebtRecovered(uint256 badDebt_) external {
function badDebtRecovered(uint256 recoveredAmount_) external {
require(msg.sender == shortfall, "only shortfall contract can update bad debt");
require(badDebt_ <= badDebt, "more than bad debt recovered from auction");
require(recoveredAmount_ <= badDebt, "more than bad debt recovered from auction");

badDebt = badDebt - badDebt_;
uint256 badDebtOld = badDebt;
uint256 badDebtNew = badDebtOld - recoveredAmount_;
badDebt = badDebtNew;

emit BadDebtRecovered(badDebtOld, badDebtNew);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions contracts/VTokenInterfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,19 @@ abstract contract VTokenInterface is VTokenStorage {
/**
* @notice Event emitted when bad debt is accumulated on a market
* @param borrower borrower to "forgive"
* @param badDebtDelta amount of new bad debt recorded
* @param badDebtOld previous bad debt value
* @param badDebtNew new bad debt value
*/
event BadDebtIncreased(address borrower, uint256 badDebtDelta, uint256 badDebtOld, uint256 badDebtNew);

/**
* @notice Event emitted when bad debt is recovered via an auction
* @param badDebtOld previous bad debt value
* @param badDebtNew new bad debt value
*/
event BadDebtRecovered(uint256 badDebtOld, uint256 badDebtNew);

/**
* @notice Event emitted when a borrow is liquidated
*/
Expand Down

0 comments on commit 7fbe7fc

Please sign in to comment.