mirror of
				https://github.com/Instadapp/dsa-polygon-migration.git
				synced 2024-07-29 22:27:58 +00:00 
			
		
		
		
	Update testcases and remove console messages
This commit is contained in:
		
							parent
							
								
									168479f90b
								
							
						
					
					
						commit
						b3b289bddf
					
				|  | @ -5,7 +5,6 @@ import { DSMath } from "../../common/math.sol"; | |||
| import { Stores } from "../../common/stores-mainnet.sol"; | ||||
| import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; | ||||
| import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||||
| import "hardhat/console.sol"; | ||||
| 
 | ||||
| import { Variables } from "./variables.sol"; | ||||
| 
 | ||||
|  | @ -83,20 +82,15 @@ abstract contract Helpers is DSMath, Stores, Variables { | |||
|             ) = aaveData.getUserReserveData(_token, sourceDsa); | ||||
| 
 | ||||
| 
 | ||||
|             stableBorrow[i] = _data.stableBorrowAmts[i] == uint(-1) ? stableDebt : _data.stableBorrowAmts[i]; // Failing here?? 'invalid-opcode' | ||||
|             stableBorrow[i] = _data.stableBorrowAmts[i] == uint(-1) ? stableDebt : _data.stableBorrowAmts[i]; | ||||
|             variableBorrow[i] = _data.variableBorrowAmts[i] == uint(-1) ? variableDebt : _data.variableBorrowAmts[i]; | ||||
|             // console.log("stableBorrow", stableBorrow[i]); | ||||
|             // console.log("variableBorrow", variableBorrow[i]); | ||||
| 
 | ||||
|             totalBorrow[i] = add(stableBorrow[i], variableBorrow[i]); | ||||
|             // console.log("totalBorrow", totalBorrow[i]); | ||||
| 
 | ||||
|             if (totalBorrow[i] > 0) { | ||||
|                 IERC20(_token).safeApprove(address(aave), totalBorrow[i]); | ||||
|             } | ||||
|             // console.log("approved", IERC20(_token).allowance(address(this), address(aave))); | ||||
|             aave.borrow(_token, totalBorrow[i], 2, 3288, address(this)); // Failing over here /// | ||||
|             console.log("balanceOf", IERC20(_token).balanceOf(address(this))); | ||||
|             aave.borrow(_token, totalBorrow[i], 2, 3288, address(this)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -119,12 +113,7 @@ abstract contract Helpers is DSMath, Stores, Variables { | |||
|             } else { | ||||
|                 _finalAmt = supplyAmts[i]; | ||||
|             } | ||||
|             console.log("balanceOf inital this", aTokenContract.balanceOf(address(this))); | ||||
|             console.log("balanceOf inital dsa", aTokenContract.balanceOf(dsa)); | ||||
|             console.log("_finalAmt", _finalAmt); | ||||
|             console.log("allownace", IERC20(_aToken).allowance(dsa, address(this))); | ||||
|             require(aTokenContract.transferFrom(dsa, address(this), _finalAmt), "_getAtokens: atokens transfer failed"); | ||||
|             console.log("balanceOf final", aTokenContract.balanceOf(address(this))); | ||||
| 
 | ||||
|             _finalAmt = wmul(_finalAmt, fee); | ||||
|             finalAmts[i] = _finalAmt; | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ pragma experimental ABIEncoderV2; | |||
| 
 | ||||
| import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; | ||||
| import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||||
| import "hardhat/console.sol"; | ||||
| import { TokenInterface } from "../../common/interfaces.sol"; | ||||
| import { Helpers } from "./helpers.sol"; | ||||
| import { AaveInterface, ATokenInterface, IndexInterface } from "./interfaces.sol"; | ||||
|  | @ -154,12 +153,8 @@ contract MigrateResolver is LiquidityResolver { | |||
| 
 | ||||
|         isPositionSafe(); | ||||
| 
 | ||||
|         console.log("here"); | ||||
| 
 | ||||
|         stateSender.syncState(polygonReceiver, abi.encode(data)); | ||||
| 
 | ||||
|         console.log("here2"); | ||||
| 
 | ||||
|         emit LogAaveV2Migrate( | ||||
|             sourceDsa, | ||||
|             data.targetDsa, | ||||
|  | @ -177,19 +172,15 @@ contract MigrateResolver is LiquidityResolver { | |||
|     } | ||||
| 
 | ||||
|     function migrateFlashCallback(AaveDataRaw calldata _data, address dsa, uint ethAmt) external { | ||||
|         console.log("msg.sender", msg.sender); | ||||
|         require(msg.sender == address(flashloanContract), "not-flashloan-contract"); // TODO: flash loan contract | ||||
|         require(msg.sender == address(flashloanContract), "not-flashloan-contract"); | ||||
|         AaveInterface aave = AaveInterface(aaveProvider.getLendingPool()); | ||||
| 
 | ||||
|         TokenInterface wethContract = TokenInterface(wethAddr); | ||||
|         wethContract.approve(address(aave), ethAmt); | ||||
|         aave.deposit(wethAddr, ethAmt, address(this), 3288); | ||||
|         _migrate(aave, _data, dsa); | ||||
|         console.log("here3"); | ||||
|         aave.withdraw(wethAddr, ethAmt, address(this)); | ||||
|         console.log("here4", ethAmt); | ||||
|         require(wethContract.transfer(address(flashloanContract), ethAmt), "migrateFlashCallback: weth transfer failed to Instapool"); | ||||
|         console.log("here5"); | ||||
|     } | ||||
| 
 | ||||
|     function migrateWithFlash(AaveDataRaw calldata _data, uint ethAmt) external { | ||||
|  |  | |||
|  | @ -149,7 +149,17 @@ describe("Migrator", function() { | |||
| 
 | ||||
|   it("test settle", async function() { | ||||
|     const tokens = [weth] | ||||
|     const amts = [ethers.utils.parseEther('10')] | ||||
|     const amts = [ethers.utils.parseEther('60')] | ||||
| 
 | ||||
|     const tx = await migrator.settle(tokens, amts) | ||||
|     const receipt = await tx.wait() | ||||
| 
 | ||||
|     // console.log(receipt)
 | ||||
|   }) | ||||
| 
 | ||||
|   it("test settle 2", async function() { | ||||
|     const tokens = [usdc] | ||||
|     const amts = [ethers.utils.parseUnits('20000', 6)] | ||||
| 
 | ||||
|     const tx = await migrator.settle(tokens, amts) | ||||
|     const receipt = await tx.wait() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Mubaris NK
						Mubaris NK