aave / protocol-v2

Aave Protocol V2
https://aave.com
Other
658 stars 744 forks source link

feat: support same asset repay #314

Open defispartan opened 1 year ago

defispartan commented 1 year ago

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
      );
    }