protocol-v2 icon indicating copy to clipboard operation
protocol-v2 copied to clipboard

feat: support same asset repay

Open defispartan opened this issue 3 years ago • 0 comments

Extension of https://github.com/aave/protocol-v2/pull/222 which is the version currently deployed to the Aave interface

Adds condition to allow for repay with collateral when aToken and debtToken have the same underlying asset:

Old

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

New

   uint256 amountSold = debtRepayAmount;

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

defispartan avatar Oct 10 '22 02:10 defispartan