Skip to content

Commit

Permalink
fix: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Feb 4, 2025
1 parent af673ff commit 634e7ae
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
14 changes: 7 additions & 7 deletions snapshots/BatchRepayBadDebtSteward.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"function batchLiquidate: with 4 users": "1522674",
"function batchLiquidate: with 5 users": "1754574",
"function batchLiquidate: with 6 users": "1976142",
"function batchLiquidateWithMaxCap: with 0 users": "86120",
"function batchLiquidateWithMaxCap: with 1 user": "598549",
"function batchLiquidateWithMaxCap: with 2 users": "877740",
"function batchLiquidateWithMaxCap: with 3 users": "1151748",
"function batchLiquidateWithMaxCap: with 4 users": "1474242",
"function batchLiquidateWithMaxCap: with 5 users": "1697173",
"function batchLiquidateWithMaxCap: with 6 users": "1909644",
"function batchLiquidateWithMaxCap: with 0 users": "86155",
"function batchLiquidateWithMaxCap: with 1 user": "598593",
"function batchLiquidateWithMaxCap: with 2 users": "877784",
"function batchLiquidateWithMaxCap: with 3 users": "1151792",
"function batchLiquidateWithMaxCap: with 4 users": "1474286",
"function batchLiquidateWithMaxCap: with 5 users": "1697217",
"function batchLiquidateWithMaxCap: with 6 users": "1909688",
"function batchRepayBadDebt: with 0 users": "98887",
"function batchRepayBadDebt: with 1 user": "235385",
"function batchRepayBadDebt: with 2 users": "298284",
Expand Down
10 changes: 5 additions & 5 deletions src/maintenance/BatchRepayBadDebtSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ contract BatchRepayBadDebtSteward is
{
(uint256 totalDebtAmount,) = getDebtAmount(debtAsset, users);

batchLiquidateWithMaxCap(debtAsset, totalDebtAmount, collateralAssets, users);
batchLiquidateWithMaxCap(debtAsset, collateralAssets, users, totalDebtAmount);
}

/// @inheritdoc IBatchRepayBadDebtSteward
function batchLiquidateWithMaxCap(
address debtAsset,
uint256 debtTokenAmount,
address[] memory collateralAssets,
address[] memory users
address[] memory users,
uint256 maxDebtTokenAmount
) public override onlyRole(CLEANUP) {
ICollector(COLLECTOR).transfer(IERC20Col(debtAsset), address(this), debtTokenAmount);
IERC20(debtAsset).forceApprove(address(POOL), debtTokenAmount);
ICollector(COLLECTOR).transfer(IERC20Col(debtAsset), address(this), maxDebtTokenAmount);
IERC20(debtAsset).forceApprove(address(POOL), maxDebtTokenAmount);

uint256 length = users.length;
for (uint256 i = 0; i < length; i++) {
Expand Down
7 changes: 4 additions & 3 deletions src/maintenance/interfaces/IBatchRepayBadDebtSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ interface IBatchRepayBadDebtSteward is IRescuableBase, IWithGuardian, IAccessCon

/// @notice Liquidates all the users with a max debt amount to be liquidated
/// @param debtAsset The address of the debt asset
/// @param debtTokenAmount The amount of debt tokens to be liquidated
/// @param collateralAssets The addresses of the collateral assets that will be liquidated
/// @param users The addresses of the users to liquidate
/// @param maxDebtTokenAmount The maximum amount of debt tokens to be liquidated
/// @dev this is the amount being pulled from the collector. The contract will send the surplus back to the collector.
function batchLiquidateWithMaxCap(
address debtAsset,
uint256 debtTokenAmount,
address[] memory collateralAssets,
address[] memory users
address[] memory users,
uint256 maxDebtTokenAmount
) external;

/// @notice Repays all the bad debt of the users
Expand Down
2 changes: 1 addition & 1 deletion tests/gas/maintenance/BatchRepayBadDebtSteward.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,6 @@ contract BatchRepayBadDebtStewardTest is BatchRepayBadDebtStewardBaseTest {
deal(assetUnderlying, collector, mintAmount);

vm.prank(guardian);
steward.batchLiquidateWithMaxCap(assetUnderlying, totalDebtToLiquidate, collaterals, users);
steward.batchLiquidateWithMaxCap(assetUnderlying, collaterals, users, totalDebtToLiquidate);
}
}
4 changes: 2 additions & 2 deletions tests/maintenance/BatchRepayBadDebtSteward.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ contract BatchRepayBadDebtStewardTest is BatchRepayBadDebtStewardBaseTest {

vm.prank(guardian);
steward.batchLiquidateWithMaxCap(
assetUnderlying, passedAmount, collateralsEligibleForLiquidations, usersEligibleForLiquidations
assetUnderlying, collateralsEligibleForLiquidations, usersEligibleForLiquidations, passedAmount
);

uint256 collectorBalanceAfter = IERC20(assetUnderlying).balanceOf(collector);
Expand Down Expand Up @@ -222,7 +222,7 @@ contract BatchRepayBadDebtStewardTest is BatchRepayBadDebtStewardBaseTest {

vm.prank(caller);
steward.batchLiquidateWithMaxCap(
assetUnderlying, 1, collateralsEligibleForLiquidations, usersEligibleForLiquidations
assetUnderlying, collateralsEligibleForLiquidations, usersEligibleForLiquidations, 1
);
}

Expand Down

0 comments on commit 634e7ae

Please sign in to comment.