mirror of
https://github.com/Instadapp/dsa-polygon-migration.git
synced 2024-07-29 22:27:58 +00:00
removed flash loan on L2
This commit is contained in:
parent
e31032a3d3
commit
777a98ef56
|
@ -23,9 +23,7 @@ abstract contract Helpers is Stores, DSMath, Variables {
|
|||
address atoken;
|
||||
uint atokenBal;
|
||||
uint supplyAmt;
|
||||
uint flashAmt;
|
||||
uint tokenLiq;
|
||||
bool isFlash;
|
||||
}
|
||||
|
||||
struct SpellHelperData {
|
||||
|
@ -33,8 +31,6 @@ abstract contract Helpers is Stores, DSMath, Variables {
|
|||
address atoken;
|
||||
uint tokenLiq;
|
||||
uint borrowAmt;
|
||||
uint flashAmt;
|
||||
bool isFlash;
|
||||
}
|
||||
|
||||
function remapTokens(AaveData memory data) internal view returns (AaveData memory) {
|
||||
|
@ -71,16 +67,6 @@ abstract contract Helpers is Stores, DSMath, Variables {
|
|||
|
||||
if (data.atokenBal < data.supplyAmt) {
|
||||
uint _reqAmt = data.supplyAmt - data.atokenBal;
|
||||
if (data.tokenLiq < _reqAmt) {
|
||||
data.flashAmt = flashAmts[data.token];
|
||||
if (data.flashAmt > 0) {
|
||||
_tokenContract.approve(address(aave), data.flashAmt);
|
||||
aave.deposit(data.token, data.flashAmt, address(this), 3288); // TODO: what is our ID on Polygon?
|
||||
data.tokenLiq += data.flashAmt;
|
||||
data.isFlash = true;
|
||||
}
|
||||
}
|
||||
|
||||
uint num = _reqAmt/data.tokenLiq + 1; // TODO: Is this right
|
||||
uint splitAmt = _reqAmt/num; // TODO: Check decimal
|
||||
uint finalSplit = _reqAmt - (splitAmt * (num - 1)); // TODO: to resolve upper decimal error
|
||||
|
@ -97,10 +83,6 @@ abstract contract Helpers is Stores, DSMath, Variables {
|
|||
}
|
||||
}
|
||||
|
||||
if (data.isFlash) {
|
||||
aave.withdraw(data.token, data.flashAmt, address(this));
|
||||
}
|
||||
|
||||
_atokenContract.safeTransfer(dsa, data.supplyAmt);
|
||||
}
|
||||
}
|
||||
|
@ -113,12 +95,6 @@ abstract contract Helpers is Stores, DSMath, Variables {
|
|||
(data.tokenLiq,,,,,,,,,) = aaveData.getReserveData(data.token);
|
||||
data.borrowAmt = borrowAmts[i];
|
||||
|
||||
if (data.tokenLiq < data.borrowAmt) {
|
||||
data.flashAmt = flashAmts[data.token];
|
||||
aave.deposit(data.token, data.flashAmt, address(this), 3288); // TODO: what is our ID on Polygon?
|
||||
data.isFlash = true;
|
||||
data.tokenLiq += data.flashAmt;
|
||||
}
|
||||
// TODO: Check number of loops needed. Borrow and supply on user's account.
|
||||
uint num = data.borrowAmt/data.tokenLiq + 1; // TODO: Is this right
|
||||
uint splitAmt = data.borrowAmt/num; // TODO: Check decimal
|
||||
|
@ -142,10 +118,6 @@ abstract contract Helpers is Stores, DSMath, Variables {
|
|||
}
|
||||
}
|
||||
|
||||
if (data.isFlash) {
|
||||
aave.withdraw(data.token, data.flashAmt, address(this));
|
||||
}
|
||||
|
||||
targets[spellsAmt] = "BASIC-A"; // TODO: right spell?
|
||||
castData[spellsAmt] = abi.encode("withdraw(address,uint256,address,uint256,uint256)", data.atoken, data.borrowAmt, address(this), 0, 0); // encode the data of atoken withdrawal
|
||||
AccountInterface(dsa).castMigrate(targets, castData, address(this));
|
||||
|
|
|
@ -70,11 +70,11 @@ contract MigrateResolver is Helpers, Events {
|
|||
) = aaveData.getUserReserveData(_token, address(this));
|
||||
if (supplyBal != 0 && borrowBal != 0) {
|
||||
if (supplyBal > borrowBal) {
|
||||
aave.withdraw(_token, (borrowBal + flashAmts[_token]), address(this)); // TODO: fail because of not enough withdrawing capacity?
|
||||
aave.withdraw(_token, borrowBal, address(this)); // TODO: fail because of not enough withdrawing capacity?
|
||||
IERC20(_token).approve(address(aave), borrowBal);
|
||||
aave.repay(_token, borrowBal, 2, address(this));
|
||||
} else {
|
||||
aave.withdraw(_token, (supplyBal + flashAmts[_token]), address(this)); // TODO: fail because of not enough withdrawing capacity?
|
||||
aave.withdraw(_token, supplyBal, address(this)); // TODO: fail because of not enough withdrawing capacity?
|
||||
IERC20(_token).approve(address(aave), supplyBal);
|
||||
aave.repay(_token, supplyBal, 2, address(this));
|
||||
}
|
||||
|
|
|
@ -13,10 +13,6 @@ contract Variables {
|
|||
// TODO: Is this number correct for it?
|
||||
uint public safeRatioGap = 800000000000000000; // 20%? 2e17
|
||||
|
||||
// TODO: Add function for flash deposits and withdraw
|
||||
mapping(address => mapping(address => uint)) flashDeposits; // Flash deposits of particular token
|
||||
mapping(address => uint) flashAmts; // token amount for flashloan usage (these token will always stay raw in this contract)
|
||||
|
||||
// TODO: Replace this
|
||||
TokenMappingInterface tokenMapping = TokenMappingInterface(address(2));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user