Fixed decoding bug

This commit is contained in:
Thrilok Kumar 2020-09-15 03:35:20 +05:30
parent 6f8767a505
commit c87da94839

View File

@ -31,12 +31,16 @@ contract DydxFlashloaner is ICallee, DydxFlashloanBase {
bytes memory data
) public {
require(sender == address(this), "not-same-sender");
CastData memory cd = abi.decode(data, (CastData));
CastData memory cd;
(cd.dsa, cd.token, cd.amount, cd.targets, cd.data) = abi.decode(
data,
(address, address, uint256, address[], bytes[])
);
IERC20 tokenContract;
if (cd.token == ethAddr) {
tokenContract = IERC20(wethAddr);
tokenContract.approve(getAddressWETH(), cd.amount);
tokenContract.approve(wethAddr, cd.amount);
tokenContract.withdraw(cd.amount);
payable(cd.dsa).transfer(cd.amount);
} else {
@ -77,5 +81,9 @@ contract DydxFlashloaner is ICallee, DydxFlashloanBase {
require(sub(iniBal, finBal) < 5, "amount-paid-less");
}
}
contract InstaDydxFlashLoan is DydxFlashloaner {
receive() external payable {}
}