aave / protocol-v2

Aave Protocol V2
https://aave.com
Other
668 stars 755 forks source link

feat: support same asset repay #314

Open defispartan opened 2 years ago

defispartan commented 2 years 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
      );
    }