diff --git a/contracts/connectors/refinance.sol b/contracts/connectors/refinance.sol index ec3eb7a..7bd3a7e 100644 --- a/contracts/connectors/refinance.sol +++ b/contracts/connectors/refinance.sol @@ -494,10 +494,12 @@ contract Helpers is DSMath { } function transferFees(address token, uint feeAmt) internal { - if (token == getEthAddr()) { - feeCollector.transfer(feeAmt); - } else { - IERC20(token).safeTransfer(feeCollector, feeAmt); + if (feeAmt > 0) { + if (token == getEthAddr()) { + feeCollector.transfer(feeAmt); + } else { + IERC20(token).safeTransfer(feeCollector, feeAmt); + } } } } @@ -992,12 +994,13 @@ contract MakerHelpers is AaveV2Helpers { makerData.daiJoin = getMcdDaiJoin(); makerData.vatContract = VatLike(managerContract.vat()); - transferFees(address(makerData.tokenContract), collateralFeeAmt); - if (address(makerData.tokenContract) == getWethAddr()) { makerData.tokenContract.deposit.value(_collateralAmt)(); } + transferFees(address(makerData.tokenContract), collateralFeeAmt); + transferFees(getMcdDai(), debtFeeAmt); + makerData.tokenContract.approve(address(makerData.colAddr), _collateralAmt); makerData.tokenJoinContract.join(urn, _collateralAmt);