From dd01e5592f2273ff9b8b47f9994e9b9e19f89fa8 Mon Sep 17 00:00:00 2001 From: Mubaris NK Date: Sun, 4 Apr 2021 11:06:01 +0530 Subject: [PATCH] Transfer debt to receiver upon migration --- contracts/implementations/aave-v2-migrator/main.sol | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contracts/implementations/aave-v2-migrator/main.sol b/contracts/implementations/aave-v2-migrator/main.sol index 46d57ec..e8264f8 100644 --- a/contracts/implementations/aave-v2-migrator/main.sol +++ b/contracts/implementations/aave-v2-migrator/main.sol @@ -1,12 +1,17 @@ pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; +import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + import { TokenInterface, AccountInterface } from "../../common/interfaces.sol"; import { AaveInterface, ReceiverInterface, AaveData } from "./interfaces.sol"; import { Helpers } from "./helpers.sol"; import { Events } from "./events.sol"; contract AaveMigratorResolver is Helpers, Events { + using SafeERC20 for IERC20; + ReceiverInterface public immutable receiver; constructor(address _receiver) { @@ -42,6 +47,9 @@ contract AaveMigratorResolver is Helpers, Events { if (stableAmt > 0) { aave.borrow(token, stableAmt, 1, referralCode, address(this)); } + + uint totalAmt = add(variableAmt, stableAmt); + IERC20(token).safeTransfer(address(receiver), totalAmt); } } } \ No newline at end of file