Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions contracts/adapters/ParaSwapRepayAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,10 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
uint256 collateralAmount = amounts[0];
uint256 premium = premiums[0];
address initiatorLocal = initiator;

IERC20Detailed collateralAsset = IERC20Detailed(assets[0]);

_swapAndRepay(
params,
premium,
initiatorLocal,
collateralAsset,
collateralAmount
);

_swapAndRepay(params, premium, initiatorLocal, collateralAsset, collateralAmount);

return true;
}
Expand Down Expand Up @@ -110,7 +104,6 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
bytes calldata paraswapData,
PermitSignature calldata permitSignature
) external nonReentrant {

debtRepayAmount = getDebtRepayAmount(
debtAsset,
debtRateMode,
Expand Down Expand Up @@ -162,7 +155,6 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
IERC20Detailed collateralAsset,
uint256 collateralAmount
) private {

(
IERC20Detailed debtAsset,
uint256 debtRepayAmount,
Expand All @@ -180,15 +172,19 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
initiator
);

uint256 amountSold =
_buyOnParaSwap(
buyAllBalanceOffset,
paraswapData,
collateralAsset,
debtAsset,
collateralAmount,
debtRepayAmount
);
uint256 amountSold = debtRepayAmount;

if (collateralAsset != debtAsset) {
uint256 amountSold =
_buyOnParaSwap(
buyAllBalanceOffset,
paraswapData,
collateralAsset,
debtAsset,
collateralAmount,
debtRepayAmount
);
}

// Repay debt. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix.
IERC20(debtAsset).safeApprove(address(LENDING_POOL), 0);
Expand Down