mirror of
https://github.com/Instadapp/dsa-polygon-migration.git
synced 2024-07-29 22:27:58 +00:00
approval check
This commit is contained in:
parent
2509c04187
commit
7a5817469b
|
@ -82,10 +82,6 @@ abstract contract Helpers is DSMath, Stores, Variables {
|
|||
,,,,,
|
||||
) = aaveData.getUserReserveData(_token, sourceDsa);
|
||||
|
||||
console.log("debts", stableDebt, variableDebt);
|
||||
console.log("token", _token);
|
||||
console.log("stableBorrowAmts", _data.stableBorrowAmts[i]);
|
||||
|
||||
|
||||
stableBorrow[i] = _data.stableBorrowAmts[i] == uint(-1) ? stableDebt : _data.stableBorrowAmts[i]; // Failing here?? 'invalid-opcode'
|
||||
variableBorrow[i] = _data.variableBorrowAmts[i] == uint(-1) ? variableDebt : _data.variableBorrowAmts[i];
|
||||
|
@ -98,9 +94,7 @@ abstract contract Helpers is DSMath, Stores, Variables {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +118,7 @@ abstract contract Helpers is DSMath, Stores, Variables {
|
|||
_finalAmt = supplyAmts[i];
|
||||
}
|
||||
|
||||
aTokenContract.transferFrom(dsa, address(this), finalAmts[i]);
|
||||
require(aTokenContract.transferFrom(dsa, address(this), finalAmts[i]), "transfer-failed");
|
||||
|
||||
_finalAmt = wmul(_finalAmt, fee);
|
||||
finalAmts[i] = _finalAmt;
|
||||
|
|
|
@ -154,8 +154,12 @@ contract MigrateResolver is LiquidityResolver {
|
|||
|
||||
isPositionSafe();
|
||||
|
||||
console.log("here");
|
||||
|
||||
stateSender.syncState(polygonReceiver, abi.encode(data));
|
||||
|
||||
console.log("here2");
|
||||
|
||||
emit LogAaveV2Migrate(
|
||||
sourceDsa,
|
||||
data.targetDsa,
|
||||
|
@ -181,7 +185,9 @@ contract MigrateResolver is LiquidityResolver {
|
|||
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");
|
||||
wethContract.transfer(address(flashloanContract), ethAmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ describe("Migrator", function() {
|
|||
|
||||
const erc20Abi = [
|
||||
"function balanceOf(address) view returns (uint)",
|
||||
"function transfer(address to, uint amount)"
|
||||
"function transfer(address to, uint amount)",
|
||||
"function approve(address spender, uint amount)"
|
||||
]
|
||||
|
||||
const syncStateAbi = [
|
||||
|
@ -25,7 +26,13 @@ describe("Migrator", function() {
|
|||
const aave = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
|
||||
const eth = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
|
||||
const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
|
||||
|
||||
const aweth = '0x030ba81f1c18d280636f32af80b9aad02cf0854e'
|
||||
|
||||
const maxValue = '115792089237316195423570985008687907853269984665640564039457584007913129639935'
|
||||
|
||||
const supportedTokens = [usdc, usdt, dai, wbtc, aave, eth, weth]
|
||||
|
||||
before(async function() {
|
||||
masterAddress = "0xb1DC62EC38E6E3857a887210C38418E4A17Da5B2"
|
||||
await hre.network.provider.request({
|
||||
|
@ -115,11 +122,12 @@ describe("Migrator", function() {
|
|||
|
||||
it("test migrate", async function() {
|
||||
const sourceAddr = '0x42c7788dd1cef71cf04ae4d6bca37d129c27e001'
|
||||
|
||||
const rawData = {
|
||||
targetDsa: sourceAddr,
|
||||
supplyTokens: [weth],
|
||||
borrowTokens: [usdc],
|
||||
supplyAmts: [ethers.utils.parseEther('20')],
|
||||
supplyAmts: [ethers.utils.parseEther('60')],
|
||||
variableBorrowAmts: [ethers.utils.parseUnits('10000', 6)],
|
||||
stableBorrowAmts: [ethers.utils.parseUnits('10000', 6)]
|
||||
}
|
||||
|
@ -130,7 +138,10 @@ describe("Migrator", function() {
|
|||
})
|
||||
const signer = ethers.provider.getSigner(sourceAddr)
|
||||
|
||||
const tx = await migrator.connect(signer).migrateWithFlash(rawData, ethers.utils.parseEther('40'))
|
||||
const awethContract = new ethers.Contract(aweth, erc20Abi, signer)
|
||||
await awethContract.approve(migrator.address, maxValue)
|
||||
|
||||
const tx = await migrator.connect(signer).migrateWithFlash(rawData, ethers.utils.parseEther('80'))
|
||||
const receipt = await tx.wait()
|
||||
|
||||
// console.log(receipt)
|
||||
|
|
Loading…
Reference in New Issue
Block a user