diff --git a/contracts/liquidity.sol b/contracts/liquidity.sol index 6d85ae5..991df3a 100644 --- a/contracts/liquidity.sol +++ b/contracts/liquidity.sol @@ -3,6 +3,7 @@ pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; +import "@openzeppelin/contracts/utils/Address.sol"; import { DSMath } from "./common/math.sol"; interface Account { @@ -280,14 +281,14 @@ contract DydxFlashloaner is Setup, ICallee, DydxFlashloanBase, DSMath { require(sender == address(this), "not-same-sender"); require(msg.sender == soloAddr, "not-solo-dydx-sender"); - (AaveDataRaw memory _data, address dsa, uint ethAmt) = abi.decode( + (bytes memory callData, uint ethAmt) = abi.decode( data, - (AaveDataRaw, address, uint) + (bytes, uint) ); wethContract.transfer(address(migrationAddr), ethAmt); - migrationAddr.migrateFlashCallback(_data, dsa, ethAmt); + Address.functionCall(address(migrationAddr), callData); } function initiateFlashLoan(bytes memory data, uint ethAmt) external { diff --git a/contracts/senders/aave-v2-migrator/main.sol b/contracts/senders/aave-v2-migrator/main.sol index 0a6ee1e..be8a752 100644 --- a/contracts/senders/aave-v2-migrator/main.sol +++ b/contracts/senders/aave-v2-migrator/main.sol @@ -184,7 +184,8 @@ contract MigrateResolver is LiquidityResolver { } function migrateWithFlash(AaveDataRaw calldata _data, uint ethAmt) external { - bytes memory data = abi.encode(_data, msg.sender, ethAmt); + bytes memory callbackData = abi.encodeWithSelector(bytes4(this.migrateFlashCallback.selector), _data, msg.sender, ethAmt); + bytes memory data = abi.encode(callbackData, ethAmt); flashloanContract.initiateFlashLoan(data, ethAmt); }