Merge pull request #7 from Instadapp/flashloan-change

Flashloan change
This commit is contained in:
Samyak Jain 2021-04-15 09:21:48 +10:00 committed by GitHub
commit 3e4b0bb033
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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 {

View File

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