mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Updated flashloans to transferFrom the receiver instead of checking that the funds where sent back
This commit is contained in:
parent
9377a137f1
commit
d833157cf4
|
@ -8,7 +8,7 @@ usePlugin('buidler-typechain');
|
|||
usePlugin('solidity-coverage');
|
||||
usePlugin('@nomiclabs/buidler-waffle');
|
||||
usePlugin('@nomiclabs/buidler-etherscan');
|
||||
//usePlugin('buidler-gas-reporter');
|
||||
usePlugin('buidler-gas-reporter');
|
||||
|
||||
const DEFAULT_BLOCK_GAS_LIMIT = 10000000;
|
||||
const DEFAULT_GAS_PRICE = 10;
|
||||
|
|
|
@ -12,27 +12,12 @@ abstract contract FlashLoanReceiverBase is IFlashLoanReceiver {
|
|||
using SafeERC20 for IERC20;
|
||||
using SafeMath for uint256;
|
||||
|
||||
ILendingPoolAddressesProvider public addressesProvider;
|
||||
ILendingPoolAddressesProvider internal _addressesProvider;
|
||||
|
||||
constructor(ILendingPoolAddressesProvider provider) public {
|
||||
addressesProvider = provider;
|
||||
_addressesProvider = provider;
|
||||
}
|
||||
|
||||
receive() external payable {}
|
||||
|
||||
function _transferFundsBack(
|
||||
address reserve,
|
||||
address destination,
|
||||
uint256 amount
|
||||
) internal {
|
||||
transferInternal(destination, reserve, amount);
|
||||
}
|
||||
|
||||
function transferInternal(
|
||||
address destination,
|
||||
address reserve,
|
||||
uint256 amount
|
||||
) internal {
|
||||
IERC20(reserve).safeTransfer(destination, amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ pragma solidity ^0.6.8;
|
|||
interface IFlashLoanReceiver {
|
||||
function executeOperation(
|
||||
address reserve,
|
||||
address destination,
|
||||
uint256 amount,
|
||||
uint256 fee,
|
||||
bytes calldata params
|
||||
|
|
|
@ -471,16 +471,16 @@ contract LendingPool is VersionedInitializable, ILendingPool {
|
|||
IAToken(aTokenAddress).transferUnderlyingTo(receiverAddress, amount);
|
||||
|
||||
//execute action of the receiver
|
||||
receiver.executeOperation(asset, aTokenAddress, amount, amountFee, params);
|
||||
receiver.executeOperation(asset, amount, amountFee, params);
|
||||
|
||||
//transfer from the receiver the amount plus the fee
|
||||
IERC20(asset).safeTransferFrom(receiver, aTokenAddress, amount.add(amountFee));
|
||||
IERC20(asset).safeTransferFrom(receiverAddress, aTokenAddress, amount.add(amountFee));
|
||||
|
||||
//compounding the cumulated interest
|
||||
reserve.updateCumulativeIndexesAndTimestamp();
|
||||
|
||||
//compounding the received fee into the reserve
|
||||
reserve.cumulateToLiquidityIndex(totalLiquidityBefore, amountFee);
|
||||
reserve.cumulateToLiquidityIndex(IERC20(aTokenAddress).totalSupply(), amountFee);
|
||||
|
||||
//refresh interest rates
|
||||
reserve.updateInterestRates(asset, amountFee, 0);
|
||||
|
|
|
@ -13,46 +13,46 @@ contract MockFlashLoanReceiver is FlashLoanReceiverBase {
|
|||
using SafeMath for uint256;
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
ILendingPoolAddressesProvider internal _provider;
|
||||
|
||||
event ExecutedWithFail(address _reserve, uint256 _amount, uint256 _fee);
|
||||
event ExecutedWithSuccess(address _reserve, uint256 _amount, uint256 _fee);
|
||||
|
||||
bool failExecution = false;
|
||||
|
||||
constructor(ILendingPoolAddressesProvider _provider) public FlashLoanReceiverBase(_provider) {}
|
||||
constructor(ILendingPoolAddressesProvider provider) public FlashLoanReceiverBase(provider) {}
|
||||
|
||||
function setFailExecutionTransfer(bool _fail) public {
|
||||
failExecution = _fail;
|
||||
}
|
||||
|
||||
function executeOperation(
|
||||
address _reserve,
|
||||
address _destination,
|
||||
uint256 _amount,
|
||||
uint256 _fee,
|
||||
bytes memory _params
|
||||
address reserve,
|
||||
uint256 amount,
|
||||
uint256 fee,
|
||||
bytes memory params
|
||||
) public override {
|
||||
//mint to this contract the specific amount
|
||||
MintableERC20 token = MintableERC20(_reserve);
|
||||
MintableERC20 token = MintableERC20(reserve);
|
||||
|
||||
//check the contract has the specified balance
|
||||
require(
|
||||
_amount <= IERC20(_reserve).balanceOf(address(this)),
|
||||
amount <= IERC20(reserve).balanceOf(address(this)),
|
||||
'Invalid balance for the contract'
|
||||
);
|
||||
|
||||
if (failExecution) {
|
||||
emit ExecutedWithFail(_reserve, _amount, _fee);
|
||||
emit ExecutedWithFail(reserve, amount, fee);
|
||||
return;
|
||||
}
|
||||
|
||||
//execution does not fail - mint tokens and return them to the _destination
|
||||
//note: if the reserve is eth, the mock contract must receive at least _fee ETH before calling executeOperation
|
||||
|
||||
token.mint(_fee);
|
||||
token.mint(fee);
|
||||
|
||||
//returning amount + fee to the destination
|
||||
_transferFundsBack(_reserve, _destination, _amount.add(_fee));
|
||||
IERC20(reserve).approve(_addressesProvider.getLendingPool(), amount.add(fee));
|
||||
|
||||
emit ExecutedWithSuccess(_reserve, _amount, _fee);
|
||||
emit ExecutedWithSuccess(reserve, amount, fee);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22",
|
||||
"address": "0xf8c6eB390cDc5C08717bC2268aa0c1169A9B5deE",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -15,7 +15,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xa4bcDF64Cdd5451b6ac3743B414124A6299B65FF",
|
||||
"address": "0x4a716924Dad0c0d0E558844F304548814e7089F1",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -25,7 +25,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x5A0773Ff307Bf7C71a832dBB5312237fD3437f9F",
|
||||
"address": "0x798c5b4b62b1eA9D64955D6751B03075A003F123",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -53,7 +53,7 @@
|
|||
"address": "0x6642B57e4265BAD868C17Fc1d1F4F88DBBA04Aa8"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x9EC0480CF106d6dc1c7849BA141a56F874170F97"
|
||||
"address": "0x193101EA4C68eb894aeb922D4aC9C612a464c735"
|
||||
}
|
||||
},
|
||||
"LendingPoolDataProvider": {
|
||||
|
@ -66,7 +66,7 @@
|
|||
"address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x6642B57e4265BAD868C17Fc1d1F4F88DBBA04Aa8"
|
||||
"address": "0xf9cD0476CFC1E983e9feA9366A2C08e10eFc9e25"
|
||||
}
|
||||
},
|
||||
"PriceOracle": {
|
||||
|
@ -75,7 +75,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x099d9fF8F818290C8b5B7Db5bFca84CEebd2714c",
|
||||
"address": "0x18C3df59BEb7babb81BC20f61c5C175D0Cb7603d",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -85,7 +85,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xAF6BA11790D1942625C0c2dA07da19AB63845cfF",
|
||||
"address": "0x39ed2aE701B56AD229A19E628Bf5A515795F0AA3",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -95,7 +95,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E",
|
||||
"address": "0x9434029990cF00118c28a06E014F0d7d879f28CE",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -105,7 +105,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xf91aC1098F3b154671Ce83290114aaE45ac0225f",
|
||||
"address": "0xccd7A2534fd4FD5119De8E368615b226e23F8F37",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -115,7 +115,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x830bceA96E56DBC1F8578f75fBaC0AF16B32A07d",
|
||||
"address": "0x4c010BA8A40e5c13Acc1E32c025c2b2aea405Dbb",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -169,7 +169,7 @@
|
|||
"address": "0x2B681757d757fbB80cc51c6094cEF5eE75bF55aA"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x3bDA11B584dDff7F66E0cFe1da1562c92B45db60"
|
||||
"address": "0x2aE520a05B31f170a18C425a1e8626aB7Ef71984"
|
||||
}
|
||||
},
|
||||
"WalletBalanceProvider": {
|
||||
|
@ -178,7 +178,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x392E5355a0e88Bd394F717227c752670fb3a8020",
|
||||
"address": "0xBD2244f43f7BA73eB35A64302A6D8DBf17BdF2F1",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -188,7 +188,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x7c2C195CD6D34B8F845992d380aADB2730bB9C6F",
|
||||
"address": "0x11df1AF606b85226Ab9a8B1FDa90395298e7494F",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -198,7 +198,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x8858eeB3DfffA017D4BCE9801D340D36Cf895CCf",
|
||||
"address": "0x8f9A92c125FFEb83d8eC808Cd9f8cb80084c1E37",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -208,7 +208,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x0078371BDeDE8aAc7DeBfFf451B74c5EDB385Af7",
|
||||
"address": "0xc4007844AE6bBe168cE8D692C86a7A4414FBcD26",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -218,7 +218,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xf4e77E5Da47AC3125140c470c71cBca77B5c638c",
|
||||
"address": "0xAb768C858C33DfcB6651d1174AFb750433a87Be0",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -228,7 +228,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5",
|
||||
"address": "0xA089557D64DAE4b4FcB65aB7C8A520AABb213e37",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -238,7 +238,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x038B86d9d8FAFdd0a02ebd1A476432877b0107C8",
|
||||
"address": "0x20FAE2042b362E3FaB2806820b9A43CC116e2846",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -248,7 +248,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x1A1FEe7EeD918BD762173e4dc5EfDB8a78C924A8",
|
||||
"address": "0x8880F314112f15C2AfF674c3B27f9a44Ca86e4d0",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -258,7 +258,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e",
|
||||
"address": "0xDcb10C2e15110Db4B02C0a1df459768E680ce245",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -268,7 +268,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xc4905364b78a742ccce7B890A89514061E47068D",
|
||||
"address": "0xfD408ec64Da574b1859814F810564f73ea2Ff003",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -278,7 +278,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe",
|
||||
"address": "0x0006F7c3542BEE76Dd887f54eD22405Ac4ae905a",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -288,7 +288,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x8B5B7a6055E54a36fF574bbE40cf2eA68d5554b3",
|
||||
"address": "0x6ca94a51c644eca3F9CA315bcC41CbA6940A66Eb",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -298,7 +298,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xEcc0a6dbC0bb4D51E4F84A315a9e5B0438cAD4f0",
|
||||
"address": "0x6765291Cab755B980F377445eFd0F9F945CDA6C4",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -308,7 +308,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x20Ce94F404343aD2752A2D01b43fa407db9E0D00",
|
||||
"address": "0xa7dB4d25Fc525d19Fbda4E74AAF447B88420FbcB",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -318,7 +318,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x1d80315fac6aBd3EfeEbE97dEc44461ba7556160",
|
||||
"address": "0x273D60904A8DBa3Ae6B20505c59902644124fF0E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -328,7 +328,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x2D8553F9ddA85A9B3259F6Bf26911364B85556F5",
|
||||
"address": "0xfc37dE87C1Ee39cc856782BF96fEdcB6FA5c5A7f",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -338,7 +338,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x52d3b94181f8654db2530b0fEe1B19173f519C52",
|
||||
"address": "0x049228dFFEdf91ff224e9F96247aEBA700e3590c",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -348,7 +348,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xd15468525c35BDBC1eD8F2e09A00F8a173437f2f",
|
||||
"address": "0xA410D1f3fEAF300842142Cd7AA1709D84944DCb7",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -358,7 +358,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x7e35Eaf7e8FBd7887ad538D4A38Df5BbD073814a",
|
||||
"address": "0x835973768750b3ED2D5c3EF5AdcD5eDb44d12aD4",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -368,7 +368,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x5bcb88A0d20426e451332eE6C4324b0e663c50E0",
|
||||
"address": "0x1181FC27dbF04B5105243E60BB1936c002e9d5C8",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -378,7 +378,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x3521eF8AaB0323004A6dD8b03CE890F4Ea3A13f5",
|
||||
"address": "0x6F96975e2a0e1380b6e2e406BB33Ae96e4b6DB65",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -388,7 +388,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x53369fd4680FfE3DfF39Fc6DDa9CfbfD43daeA2E",
|
||||
"address": "0xc032930653da193EDE295B4DcE3DD093a695c3b3",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -398,7 +398,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xB00cC45B4a7d3e1FEE684cFc4417998A1c183e6d",
|
||||
"address": "0xb3363f4349b1160DbA55ec4D82fDe874A4123A2a",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -408,7 +408,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22",
|
||||
"address": "0xf8c6eB390cDc5C08717bC2268aa0c1169A9B5deE",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -417,7 +417,7 @@
|
|||
"address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x3b050AFb4ac4ACE646b31fF3639C1CD43aC31460"
|
||||
"address": "0x18c3e48a45839B3BbC998c70A2fD41fB8D93a35D"
|
||||
}
|
||||
},
|
||||
"StableDebtToken": {
|
||||
|
@ -426,7 +426,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E",
|
||||
"address": "0x2ca7Aa6CcCdb5D77F1c1d3E6a21fF0F7ac24C825",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -436,13 +436,13 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x5f7134cd38C826a7649f9Cc47dda24d834DD2967",
|
||||
"address": "0x527a346011Cd6c71973f653426Ce609fa53dd59E",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
"AToken": {
|
||||
"localhost": {
|
||||
"address": "0xE91bBe8ee03560E3dda2786f95335F5399813Ca0",
|
||||
"address": "0x3035D5D127487Ee5Df5FD951D9624a8b877A8497",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"buidlerevm": {
|
||||
|
@ -456,7 +456,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x7f23223A2FAf869962B38f5eC4aAB7f37454A45e",
|
||||
"address": "0xAA6DfC2A802857Fadb75726B6166484e2c011cf5",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -466,7 +466,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0xf784709d2317D872237C4bC22f867d1BAe2913AB",
|
||||
"address": "0x2cc20bE530F92865c2ed8CeD0b020a11bFe62Fe7",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -476,7 +476,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x1203D1b97BF6E546c00C45Cda035D3010ACe1180",
|
||||
"address": "0xFd23fD3d937ae73a7b545B8Bfeb218395bDe9b8f",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
},
|
||||
|
@ -486,7 +486,7 @@
|
|||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
},
|
||||
"localhost": {
|
||||
"address": "0x8733AfE8174BA7c04c6CD694bD673294079b7E10",
|
||||
"address": "0xEe821582b591CE5e4a9B7fFc4E2DAD47D3759C08",
|
||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export enum ProtocolErrors {
|
|||
INVALID_REDIRECTION_ADDRESS = 'Invalid redirection address',
|
||||
TRANSFERRED_AMOUNT_GT_ZERO = 'Transferred amount needs to be greater than zero',
|
||||
ZERO_COLLATERAL = 'The collateral balance is 0',
|
||||
INCONSISTENT_PROTOCOL_BALANCE = 'The actual balance of the protocol is inconsistent',
|
||||
TRANSFER_AMOUNT_EXCEEDS_BALANCE = 'ERC20: transfer amount exceeds balance',
|
||||
TOO_SMALL_FLASH_LOAN = 'The requested amount is too small for a FlashLoan.',
|
||||
NOT_ENOUGH_LIQUIDITY_TO_BORROW = 'There is not enough liquidity available to borrow',
|
||||
HF_IS_NOT_BELLOW_THRESHOLD = 'Health factor is not below the threshold',
|
||||
|
|
|
@ -11,9 +11,8 @@ const {expect} = require('chai');
|
|||
makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||
let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver;
|
||||
const {
|
||||
INCONSISTENT_PROTOCOL_BALANCE,
|
||||
TRANSFER_AMOUNT_EXCEEDS_BALANCE,
|
||||
TOO_SMALL_FLASH_LOAN,
|
||||
NOT_ENOUGH_LIQUIDITY_TO_BORROW,
|
||||
} = ProtocolErrors;
|
||||
|
||||
before(async () => {
|
||||
|
@ -99,7 +98,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
ethers.utils.parseEther('0.8'),
|
||||
'0x10'
|
||||
)
|
||||
).to.be.revertedWith(INCONSISTENT_PROTOCOL_BALANCE);
|
||||
).to.be.revertedWith(TRANSFER_AMOUNT_EXCEEDS_BALANCE);
|
||||
});
|
||||
|
||||
it('tries to take a very small flashloan, which would result in 0 fees (revert expected)', async () => {
|
||||
|
@ -125,8 +124,8 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
'1004415000000000000', //slightly higher than the available liquidity
|
||||
'0x10'
|
||||
),
|
||||
NOT_ENOUGH_LIQUIDITY_TO_BORROW
|
||||
).to.be.revertedWith(NOT_ENOUGH_LIQUIDITY_TO_BORROW);
|
||||
TRANSFER_AMOUNT_EXCEEDS_BALANCE
|
||||
).to.be.revertedWith(TRANSFER_AMOUNT_EXCEEDS_BALANCE);
|
||||
});
|
||||
|
||||
it('tries to take a flashloan using a non contract address as receiver (revert expected)', async () => {
|
||||
|
@ -194,7 +193,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
|||
ethers.utils.parseEther('500'),
|
||||
'0x10'
|
||||
),
|
||||
INCONSISTENT_PROTOCOL_BALANCE
|
||||
).to.be.revertedWith(INCONSISTENT_PROTOCOL_BALANCE);
|
||||
TRANSFER_AMOUNT_EXCEEDS_BALANCE
|
||||
).to.be.revertedWith(TRANSFER_AMOUNT_EXCEEDS_BALANCE);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user