From c87da94839f4437c932a762018ce688309ef3e77 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Tue, 15 Sep 2020 03:35:20 +0530 Subject: [PATCH] Fixed decoding bug --- contracts/flashloan/dydx.sol | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contracts/flashloan/dydx.sol b/contracts/flashloan/dydx.sol index ef641cd..ddcc234 100644 --- a/contracts/flashloan/dydx.sol +++ b/contracts/flashloan/dydx.sol @@ -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 {} } \ No newline at end of file