mirror of
https://github.com/Instadapp/dsa-polygon-migration.git
synced 2024-07-29 22:27:58 +00:00
test failing @ callFunction
This commit is contained in:
parent
d4a432d774
commit
7ee03cfdc8
|
@ -262,7 +262,7 @@ interface MigrationInterface {
|
||||||
contract Setup {
|
contract Setup {
|
||||||
address public constant soloAddr = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e;
|
address public constant soloAddr = 0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e;
|
||||||
address public constant wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
|
address public constant wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
|
||||||
MigrationInterface public constant migrationAddr = MigrationInterface(address(0)); // TODO: Migration address
|
MigrationInterface public constant migrationAddr = MigrationInterface(0xE3901a1bb3EefBF6bc90c201076e9068b646C1f3); // TODO: Migration address
|
||||||
|
|
||||||
TokenInterface wethContract = TokenInterface(wethAddr);
|
TokenInterface wethContract = TokenInterface(wethAddr);
|
||||||
ISoloMargin solo = ISoloMargin(soloAddr);
|
ISoloMargin solo = ISoloMargin(soloAddr);
|
||||||
|
@ -288,7 +288,7 @@ contract DydxFlashloaner is Setup, ICallee, DydxFlashloanBase, DSMath {
|
||||||
|
|
||||||
wethContract.transfer(address(migrationAddr), ethAmt);
|
wethContract.transfer(address(migrationAddr), ethAmt);
|
||||||
|
|
||||||
Address.functionCall(address(migrationAddr), callData);
|
Address.functionCall(address(migrationAddr), callData); // Failing here?? `revert Address: low-level call failed`
|
||||||
}
|
}
|
||||||
|
|
||||||
function initiateFlashLoan(bytes memory data, uint ethAmt) external {
|
function initiateFlashLoan(bytes memory data, uint ethAmt) external {
|
||||||
|
|
|
@ -3,6 +3,7 @@ pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
|
import "hardhat/console.sol";
|
||||||
import { TokenInterface } from "../../common/interfaces.sol";
|
import { TokenInterface } from "../../common/interfaces.sol";
|
||||||
import { Helpers } from "./helpers.sol";
|
import { Helpers } from "./helpers.sol";
|
||||||
import { AaveInterface, ATokenInterface, IndexInterface } from "./interfaces.sol";
|
import { AaveInterface, ATokenInterface, IndexInterface } from "./interfaces.sol";
|
||||||
|
@ -172,6 +173,7 @@ contract MigrateResolver is LiquidityResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateFlashCallback(AaveDataRaw calldata _data, address dsa, uint ethAmt) external {
|
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"); // TODO: flash loan contract
|
||||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ contract Variables {
|
||||||
uint16 constant internal referralCode = 3228;
|
uint16 constant internal referralCode = 3228;
|
||||||
|
|
||||||
address constant internal polygonReceiver = address(0); // TODO: Replace this
|
address constant internal polygonReceiver = address(0); // TODO: Replace this
|
||||||
FlashloanInterface constant internal flashloanContract = FlashloanInterface(address(0)); // TODO: Replace this
|
FlashloanInterface constant internal flashloanContract = FlashloanInterface(0x709407B70ce0845996108205aA92aE87B22F7b1a); // TODO: Replace this
|
||||||
address constant internal erc20Predicate = 0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf;
|
address constant internal erc20Predicate = 0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf;
|
||||||
|
|
||||||
// This will be used to have debt/collateral ratio always 20% less than liquidation
|
// This will be used to have debt/collateral ratio always 20% less than liquidation
|
||||||
|
|
|
@ -67,6 +67,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
etherscan: {
|
etherscan: {
|
||||||
apiKey: process.env.ETHERSCAN
|
apiKey: process.env.ETHERSCAN
|
||||||
|
},
|
||||||
|
mocha: {
|
||||||
|
timeout: 50000
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -4,9 +4,10 @@ const { ethers, network, waffle } = hre;
|
||||||
const { provider, deployContract } = waffle
|
const { provider, deployContract } = waffle
|
||||||
|
|
||||||
const Migrator = require("../artifacts/contracts/senders/aave-v2-migrator/main.sol/MigrateResolver.json")
|
const Migrator = require("../artifacts/contracts/senders/aave-v2-migrator/main.sol/MigrateResolver.json")
|
||||||
|
const InstaPool = require("../artifacts/contracts/liquidity.sol/InstaPool.json")
|
||||||
|
|
||||||
describe("Migrator", function() {
|
describe("Migrator", function() {
|
||||||
let accounts, masterAddress, master, migrator, ethereum
|
let accounts, masterAddress, master, migrator, ethereum, instapool
|
||||||
|
|
||||||
const erc20Abi = [
|
const erc20Abi = [
|
||||||
"function balanceOf(address) view returns (uint)",
|
"function balanceOf(address) view returns (uint)",
|
||||||
|
@ -32,8 +33,10 @@ describe("Migrator", function() {
|
||||||
master = ethers.provider.getSigner(masterAddress)
|
master = ethers.provider.getSigner(masterAddress)
|
||||||
|
|
||||||
migrator = await deployContract(master, Migrator, [])
|
migrator = await deployContract(master, Migrator, [])
|
||||||
|
instapool = await deployContract(master, InstaPool, [])
|
||||||
|
|
||||||
console.log("Migrator deployed: ", migrator.address)
|
console.log("Migrator deployed: ", migrator.address)
|
||||||
|
console.log("Instapool deployed: ", instapool.address)
|
||||||
|
|
||||||
const usdcHolderAddr = '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503' // 1,000,000
|
const usdcHolderAddr = '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503' // 1,000,000
|
||||||
await accounts[0].sendTransaction({ to: usdcHolderAddr, value: ethers.utils.parseEther('1') })
|
await accounts[0].sendTransaction({ to: usdcHolderAddr, value: ethers.utils.parseEther('1') })
|
||||||
|
@ -82,6 +85,7 @@ describe("Migrator", function() {
|
||||||
const wethHolder = ethers.provider.getSigner(wethHolderAddr)
|
const wethHolder = ethers.provider.getSigner(wethHolderAddr)
|
||||||
const wethContract = new ethers.Contract(weth, erc20Abi, wethHolder)
|
const wethContract = new ethers.Contract(weth, erc20Abi, wethHolder)
|
||||||
await wethContract.transfer(migrator.address, ethers.utils.parseUnits('500', 18))
|
await wethContract.transfer(migrator.address, ethers.utils.parseUnits('500', 18))
|
||||||
|
await wethContract.transfer(instapool.address, ethers.utils.parseUnits('10', 18))
|
||||||
|
|
||||||
ethereum = network.provider
|
ethereum = network.provider
|
||||||
})
|
})
|
||||||
|
@ -111,7 +115,7 @@ describe("Migrator", function() {
|
||||||
})
|
})
|
||||||
const signer = ethers.provider.getSigner(sourceAddr)
|
const signer = ethers.provider.getSigner(sourceAddr)
|
||||||
|
|
||||||
const tx = await migrator.connect(signer).migrate(rawData)
|
const tx = await migrator.connect(signer).migrateWithFlash(rawData, ethers.utils.parseEther('20'))
|
||||||
const receipt = await tx.wait()
|
const receipt = await tx.wait()
|
||||||
|
|
||||||
console.log(receipt)
|
console.log(receipt)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user