From 51fee50e505f961fb9a713fa19ce1ed834ac86ca Mon Sep 17 00:00:00 2001 From: The3D Date: Fri, 26 Jun 2020 14:34:44 +0200 Subject: [PATCH] Fixed setup --- contracts/misc/AaveProtocolTestHelpers.sol | 12 +++- data.txt | 51 ++++++++++++++++ deployed-contracts.json | 26 ++++----- helpers/contracts-helpers.ts | 68 ++++++++++++++-------- test/__setup.spec.ts | 16 +++-- test/helpers/make-suite.ts | 15 +++++ 6 files changed, 144 insertions(+), 44 deletions(-) create mode 100644 data.txt diff --git a/contracts/misc/AaveProtocolTestHelpers.sol b/contracts/misc/AaveProtocolTestHelpers.sol index 41d965a8..cfea4434 100644 --- a/contracts/misc/AaveProtocolTestHelpers.sol +++ b/contracts/misc/AaveProtocolTestHelpers.sol @@ -5,6 +5,7 @@ import {ILendingPoolAddressesProvider} from "../interfaces/ILendingPoolAddresses import {IERC20Detailed} from "../interfaces/IERC20Detailed.sol"; import {LendingPool} from "../lendingpool/LendingPool.sol"; import {AToken} from "../tokenization/AToken.sol"; +import "@nomiclabs/buidler/console.sol"; contract AaveProtocolTestHelpers { struct TokenData { @@ -20,7 +21,11 @@ contract AaveProtocolTestHelpers { function getAllReservesTokens() external view returns(TokenData[] memory) { LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool())); + console.log("Getting reserves..."); + address[] memory reserves = pool.getReserves(); + console.log("Reserves retrivied"); + TokenData[] memory reservesTokens = new TokenData[](reserves.length); for (uint256 i = 0; i < reserves.length; i++) { reservesTokens[i] = TokenData({ @@ -33,10 +38,15 @@ contract AaveProtocolTestHelpers { function getAllATokens() external view returns(TokenData[] memory) { LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool())); + + console.log("Getting all the tokens..."); address[] memory reserves = pool.getReserves(); + + console.log("Reserves retrivied"); TokenData[] memory aTokens = new TokenData[](reserves.length); for (uint256 i = 0; i < reserves.length; i++) { - (,,,address aTokenAddress,,,,,) = pool.getReserveConfigurationData(reserves[i]); + console.log("Getting configuration for reserve %s", i); + (,,,,address aTokenAddress,,,,) = pool.getReserveConfigurationData(reserves[i]); aTokens[i] = TokenData({ symbol: AToken(aTokenAddress).symbol(), tokenAddress: aTokenAddress diff --git a/data.txt b/data.txt new file mode 100644 index 00000000..47455f74 --- /dev/null +++ b/data.txt @@ -0,0 +1,51 @@ + +> protocol-v2@1.0.0 test /src +> buidler test + +All contracts have already been compiled, skipping compilation. + + +-> Deploying test environment... +Deployed user logic and reserve logic, addresses: 0x5F6CaC05CDF893f029b29F44d368eAeD40e573B6 0x92cfBAB5A86631e9F1A6126b42E01A74eadA61Df +Deployed generic logic, addresses: 0x78Aeff0658Fa67735fBF99Ce7CDB01Fe5D520259 +Deployed validation logic, address: 0x0C6c3C47A1f650809B0D1048FDf9603e09473D7E +Deployed lending pool, address: 0x06bA8d8af0dF898D0712DffFb0f862cC51AF45c2 +Added pool to addresses provider +Address is 0xA10958a24032283FbE2D23cedf264d6eC9411CBA +Deployed user logic and reserve logic, addresses: 0xE4C10Db67595aF2Cb4166c8C274e0140f7E43059 0x099d9fF8F818290C8b5B7Db5bFca84CEebd2714c +Deployed generic logic, addresses: 0x85bdE212E66e2BAE510E44Ed59116c1eC712795b +Deployed validation logic, address: 0xe1B3b8F6b298b52bCd15357ED29e65e66a4045fF +implementation set, address: 0xA10958a24032283FbE2D23cedf264d6eC9411CBA +Initialize configuration +Reserve initialization for DAI failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for TUSD failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for USDC failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for USDT failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for SUSD failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for LEND failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for BAT failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for ETH failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for LINK failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for WBTC failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for KNC failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for REP failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for MKR failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for MANA failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for ZRX failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for SNX failed with error Error: unknown transaction override 0. Skipped. +Reserve initialization for BUSD failed with error Error: unknown transaction override 0. Skipped. + 1) "before all" hook in "{root}" + + 0 passing (4s) + 1 failing + + 1) "before all" hook in "{root}": + Error: bytecode must be a valid hex string (arg="bytecode", value="0x6080604052600060015534801561001557600080fd5b506000805460ff1916600117905561178d806100326000396000f3fe6080604052600436106100335760003560e01c8062a718a9146100385780634fe7a6e5146100fb578063c72c4d1014610141575b600080fd5b61007c600480360360a081101561004e57600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013590608001351515610156565b6040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156100bf5781810151838201526020016100a7565b50505050905090810190601f1680156100ec5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b34801561010757600080fd5b506101256004803603602081101561011e57600080fd5b5035610b8d565b604080516001600160a01b039092168252519081900360200190f35b34801561014d57600080fd5b50610125610bb4565b6001600160a01b038481166000818152603760209081526040808320948a1680845281842033855260388452828520958552949092528083209183528220919360609390929091906101a661155c565b73__$7347ff53b2b46c21e26a37164ae7f6739f$__63901d711433603760386039603560009054906101000a90046001600160a01b03166001600160a01b031663fca513a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561021557600080fd5b505afa158015610229573d6000803e3d6000fd5b505050506040513d602081101561023f57600080fd5b50516040516001600160e01b031960e088901b1681526001600160a01b03808716600483019081526024830187905260448301869052908316608483015260a060648301908152845460a484018190529192909160c490910190859080156102d057602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116102b2575b5050965050505050505060c06040518083038186803b1580156102f257600080fd5b505af4158015610306573d6000803e3d6000fd5b505050506040513d60c081101561031c57600080fd5b5060a001511515610200820181905261035857600460405180606001604052806028815260200161170660289139965096505050505050610b83565b8b6001600160a01b03166370a082318b6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156103ae57600080fd5b505afa1580156103c2573d6000803e3d6000fd5b505050506040513d60208110156103d857600080fd5b50518082526104275760016040518060400160405280601f81526020017f496e76616c696420636f6c6c61746572616c20746f206c697175696461746500815250965096505050505050610b83565b600d840154600160d01b900460ff16801561044f5750600482015465010000000000900460ff165b15156101e082018190526104865760026040518060600160405280602a81526020016116b2602a9139965096505050505050610b83565b6040805163258b852d60e11b81526004810185905260248101879052905173__$259b519ec4c35fa58681035973c79c801a$__91634b170a5a916044808301926060929190829003018186803b1580156104df57600080fd5b505af41580156104f3573d6000803e3d6000fd5b505050506040513d606081101561050957600080fd5b5060208082015160409283015192840192909252820181905261054f5760036040518060600160405280602a815260200161172e602a9139965096505050505050610b83565b610578606461056c60328460200151610bc390919063ffffffff16565b9063ffffffff610c2516565b60608201819052891161058b5788610591565b80606001515b8160800181815250506105b084868e8e85608001518660000151610c67565b6101a0830152610180820152600283015460e0820181905215610607576105fa84868e8e8560e001516105f58761018001518860000151610ee590919063ffffffff16565b610c67565b6101008301526101208201525b8060800151816101a001511015610624576101a081015160808201525b8761067f5760006106446001600160a01b038e163063ffffffff610f2716565b905081610180015181101561067d57600560405180606001604052806033815260200161167f6033913997509750505050505050610b83565b505b6080810151604080830151815163dc778c1560e01b815260048101899052602481018790526001600160a01b038f166044820152606481019390935260848301525173__$5e6137a1b5a0a366e2874209b5abf71c10$__9163dc778c159160a4808301926000929190829003018186803b1580156106fc57600080fd5b505af4158015610710573d6000803e3d6000fd5b505050508373__$5e6137a1b5a0a366e2874209b5abf71c10$__634ef73b6590918e8461018001518561012001518d6040518663ffffffff1660e01b815260040180868152602001856001600160a01b03166001600160a01b03168152602001848152602001838152602001821515151581526020019550505050505060006040518083038186803b1580156107a557600080fd5b505af41580156107b9573d6000803e3d6000fd5b505050600c8501546001600160a01b03166101c0830152508715610859576101c08101516101808201516040805163f866c31960e01b81526001600160a01b038e8116600483015233602483015260448201939093529051919092169163f866c31991606480830192600092919082900301818387803b15801561083c57600080fd5b505af1158015610850573d6000803e3d6000fd5b505050506108fd565b806101c001516001600160a01b0316633edb7cb88b8361018001516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156108c357600080fd5b505af11580156108d7573d6000803e3d6000fd5b5050506101808201516108fd91506001600160a01b038e1690339063ffffffff610fd116565b608081015161091e906001600160a01b038d1690600163ffffffff6110af16565b61010081015115610ab557806101c001516001600160a01b0316633edb7cb88b8361012001516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561099357600080fd5b505af11580156109a7573d6000803e3d6000fd5b50505050610a45603560009054906101000a90046001600160a01b03166001600160a01b031663ee8912966040518163ffffffff1660e01b815260040160206040518083038186803b1580156109fc57600080fd5b505afa158015610a10573d6000803e3d6000fd5b505050506040513d6020811015610a2657600080fd5b50516101208301516001600160a01b038f16919063ffffffff610fd116565b896001600160a01b03168b6001600160a01b03168d6001600160a01b03167f36ca8b16d61dc13b1062adff83e3778ab92d14f9e35bfe9fd1283e02b13fb0a18461010001518561012001514260405180848152602001838152602001828152602001935050505060405180910390a45b896001600160a01b03168b6001600160a01b03168d6001600160a01b03167f56864757fd5b1fc9f38f5f3a981cd8ae512ce41b902cf73fc506ee369c6bc23784608001518561018001518660400151338f4260405180878152602001868152602001858152602001846001600160a01b03166001600160a01b0316815260200183151515158152602001828152602001965050505050505060405180910390a46000604051806040016040528060098152602001684e6f206572726f727360b81b8152509650965050505050505b9550959350505050565b60398181548110610b9a57fe5b6000918252602090912001546001600160a01b0316905081565b6035546001600160a01b031681565b600082610bd257506000610c1f565b82820282848281610bdf57fe5b0414610c1c5760405162461bcd60e51b815260040180806020018281038252602181526020018061165e6021913960400191505060405180910390fd5b90505b92915050565b6000610c1c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611181565b60355460408051631f94a27560e31b81529051600092839283926001600160a01b039092169163fca513a891600480820192602092909190829003018186803b158015610cb357600080fd5b505afa158015610cc7573d6000803e3d6000fd5b505050506040513d6020811015610cdd57600080fd5b50519050610ce96115eb565b816001600160a01b031663b3596f07896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610d3f57600080fd5b505afa158015610d53573d6000803e3d6000fd5b505050506040513d6020811015610d6957600080fd5b5051604080830191909152805163b3596f0760e01b81526001600160a01b03898116600483015291519184169163b3596f0791602480820192602092909190829003018186803b158015610dbc57600080fd5b505afa158015610dd0573d6000803e3d6000fd5b505050506040513d6020811015610de657600080fd5b50516060820152600a808b015460208301819052600b808c015460a08501819052908d015460c08501526040840151610e659360649361056c939092610e5992610e3792900a63ffffffff610bc316565b61056c8760c00151600a0a610e598e8a60600151610bc390919063ffffffff16565b9063ffffffff610bc316565b60808201819052851015610ecd57849350610ec6816020015161056c6064610e59610ea48660c00151600a0a8760600151610bc390919063ffffffff16565b61056c8760a00151600a0a610e598c8a60400151610bc390919063ffffffff16565b9250610ed8565b806080015193508592505b5050965096945050505050565b6000610c1c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611223565b6000610f328361127d565b15610f4857506001600160a01b03811631610c1f565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610f9e57600080fd5b505afa158015610fb2573d6000803e3d6000fd5b505050506040513d6020811015610fc857600080fd5b50519050610c1f565b80610fdb576110aa565b610fe48361127d565b15611090576040516000906001600160a01b0384169061c35090849084818181858888f193505050503d8060008114611039576040519150601f19603f3d011682016040523d82523d6000602084013e61103e565b606091505b505090508061108a576040805162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b604482015290519081900360640190fd5b506110aa565b6110aa6001600160a01b038416838363ffffffff6112b616565b505050565b816110b9576110aa565b6110c28361127d565b1561116657813410156111065760405162461bcd60e51b81526004018080602001828103825260358152602001806116296035913960400191505060405180910390fd5b80156111615760003361111f348563ffffffff610ee516565b60405161c35091906000818181858888f193505050503d8060008114611039576040519150601f19603f3d011682016040523d82523d6000602084013e61103e565b6110aa565b6110aa6001600160a01b03841633308563ffffffff61130816565b6000818361120d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156111d25781810151838201526020016111ba565b50505050905090810190601f1680156111ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161121957fe5b0495945050505050565b600081848411156112755760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156111d25781810151838201526020016111ba565b505050900390565b60006001600160a01b0382161580610c1f57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526110aa908490611368565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611362908590611368565b50505050565b61137a826001600160a01b0316611520565b6113cb576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106114095780518252601f1990920191602091820191016113ea565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461146b576040519150601f19603f3d011682016040523d82523d6000602084013e611470565b606091505b5091509150816114c7576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115611362578080602001905160208110156114e357600080fd5b50516113625760405162461bcd60e51b815260040180806020018281038252602a8152602001806116dc602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061155457508115155b949350505050565b60405180610220016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600060028111156115bb57fe5b815260006020820181905260408201819052606082018190526080820181905260a0820181905260c09091015290565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152509056fe54686520616d6f756e7420616e64207468652076616c75652073656e7420746f206465706f73697420646f206e6f74206d61746368536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7754686572652069736e277420656e6f756768206c697175696469747920617661696c61626c6520746f206c697175696461746554686520636f6c6c61746572616c2063686f73656e2063616e6e6f74206265206c6971756964617465645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565644865616c746820666163746f72206973206e6f742062656c6f7720746865207468726573686f6c645573657220646964206e6f7420626f72726f7720746865207370656369666965642063757272656e6379a26469706673582212201ebbae40019eacd6d83c1c6930693340adedd02a7e364045eecd87607ec39da364736f6c63430006080033", version=4.0.47) + at Object.throwError (node_modules/ethers/errors.js:76:17) + at new ContractFactory (node_modules/ethers/contract.js:629:20) + at getContractFactoryByAbiAndBytecode (node_modules/@nomiclabs/buidler-ethers/src/helpers.ts:81:10) + at runMicrotasks () + at processTicksAndRejections (internal/process/task_queues.js:97:5) + + + diff --git a/deployed-contracts.json b/deployed-contracts.json index 62bf6bb4..b21e586f 100644 --- a/deployed-contracts.json +++ b/deployed-contracts.json @@ -44,36 +44,36 @@ }, "LendingPool": { "buidlerevm": { - "address": "0x820ED3d0675676203514f5fd76E5Ac40c9F0c4Bd" + "address": "0xA10958a24032283FbE2D23cedf264d6eC9411CBA" } }, "PriceOracle": { "buidlerevm": { - "address": "0xe1B3b8F6b298b52bCd15357ED29e65e66a4045fF", + "address": "0x8731324a6C09a1745bD15009Dc8FcceF11c05F4a", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "MockAggregator": { "buidlerevm": { - "address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E", + "address": "0x474d9b0D5F1Bb1602711F9346743a7a7478d6f52", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "ChainlinkProxyPriceProvider": { "buidlerevm": { - "address": "0x474d9b0D5F1Bb1602711F9346743a7a7478d6f52", + "address": "0xf91aC1098F3b154671Ce83290114aaE45ac0225f", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "LendingRateOracle": { "buidlerevm": { - "address": "0xFc01AF83D78742DfD42631a352e33f8098e7274B", + "address": "0xf4830d6b1D70C8595d3BD8A63f9ed9F636DB9ef2", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "DefaultReserveInterestRateStrategy": { "buidlerevm": { - "address": "0x603A373A1571783bD82b708C20a5A4b019BAB78F", + "address": "0xFf130817Aa9863B3D809A2A11617c05646245d80", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, @@ -85,35 +85,35 @@ }, "MockOneSplit": { "buidlerevm": { - "address": "0xd44937448A9f229bfae84e7d256810Ba4C4a93cC", + "address": "0xe5a5a5b78F165C875EE2264a8743570176eA39d9", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "OneSplitAdapter": { "buidlerevm": { - "address": "0x70c5a4348710Fa80eE8f2bD2eD5243d1bAB90752", + "address": "0x828C9C41Fae6113C1DEA9056Dcd9C85A19002d52", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "TokenDistributor": { "buidlerevm": { - "address": "0xbCf57D16d9d63aDDea3c2056A1de2A33ebD353F0" + "address": "0x7d40dD74d3aE1a7e4A7dd08eaE899e85940563cd" } }, "InitializableAdminUpgradeabilityProxy": { "buidlerevm": { - "address": "0xbCf57D16d9d63aDDea3c2056A1de2A33ebD353F0", + "address": "0x7d40dD74d3aE1a7e4A7dd08eaE899e85940563cd", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "MockFlashLoanReceiver": { "buidlerevm": { - "address": "0xe5a5a5b78F165C875EE2264a8743570176eA39d9" + "address": "0xB660Fdd109a95718cB9d20E3A89EE6cE342aDcB6" } }, "WalletBalanceProvider": { "buidlerevm": { - "address": "0x828C9C41Fae6113C1DEA9056Dcd9C85A19002d52", + "address": "0x830bceA96E56DBC1F8578f75fBaC0AF16B32A07d", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, @@ -257,7 +257,7 @@ }, "AaveProtocolTestHelpers": { "buidlerevm": { - "address": "0xAb35dEf6f863FC1e91dE4c20A3596b388eB1CFb4" + "address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E" } } } \ No newline at end of file diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index 24c210c8..ae866d98 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -145,13 +145,12 @@ const deployLibrary = async(libraryId: eContractid) => { return library } -export const deployLendingPool = async () => { +export const linkLibrariesToArtifact = async(artifact: Artifact) => { const coreLibrary = await deployLibrary(eContractid.CoreLibrary); const userLogic = await deployLibrary(eContractid.UserLogic); const reserveLogic = await deployLibrary(eContractid.ReserveLogic); - console.log("Deployed user logic and reserve logic, addresses:", userLogic.address, reserveLogic.address) const genericLogicArtifact = await readArtifact( BRE.config.paths.artifacts, eContractid.GenericLogic @@ -168,8 +167,6 @@ export const deployLendingPool = async () => { ); const genericLogic = await (await genericLogicFactory.deploy()).deployed(); - console.log("Deployed generic logic, addresses:", genericLogic.address) - const validationLogicArtifact = await readArtifact( BRE.config.paths.artifacts, @@ -189,25 +186,33 @@ export const deployLendingPool = async () => { const validationLogic = await (await validationLogicFactory.deploy()).deployed(); - console.log("Deployed validation logic, address:", validationLogic.address) - - const lendingPoolArtifact = await readArtifact( - BRE.config.paths.artifacts, - eContractid.LendingPool - ); - const linkedBytecode = linkBytecode(lendingPoolArtifact, { + + + const linkedBytecode = linkBytecode(artifact, { [eContractid.CoreLibrary]: coreLibrary.address, [eContractid.UserLogic]: userLogic.address, [eContractid.ReserveLogic] : reserveLogic.address, [eContractid.GenericLogic] : genericLogic.address, [eContractid.ValidationLogic] : validationLogic.address }); - const LendingPoolFactory = await BRE.ethers.getContractFactory( - lendingPoolArtifact.abi, + const factory = await BRE.ethers.getContractFactory( + artifact.abi, linkedBytecode ); - - const lendingPool = await LendingPoolFactory.deploy(); + + return factory; +} + +export const deployLendingPool = async () => { + + const lendingPoolArtifact = await readArtifact( + BRE.config.paths.artifacts, + eContractid.LendingPool + ); + + const factory = await linkLibrariesToArtifact(lendingPoolArtifact); + + const lendingPool = await factory.deploy(); return (await lendingPool.deployed()) as LendingPool; } @@ -232,11 +237,19 @@ export const deployChainlinkProxyPriceProvider = async ([ export const deployLendingRateOracle = async () => await deployContract(eContractid.LendingRateOracle, []); -export const deployLendingPoolLiquidationManager = async () => - await deployContract( - eContractid.LendingPoolLiquidationManager, - [] +export const deployLendingPoolLiquidationManager = async () => { + const liquidationManagerArtifact = await readArtifact( + BRE.config.paths.artifacts, + eContractid.LendingPoolLiquidationManager ); + + const factory = await linkLibrariesToArtifact(liquidationManagerArtifact); + + const liquidationManager = await factory.deploy(); + return (await liquidationManager.deployed()) as LendingPoolLiquidationManager; + + +} export const deployTokenDistributor = async () => await deployContract(eContractid.TokenDistributor, []); @@ -289,7 +302,6 @@ export const deployMintableErc20 = async ([name, symbol, decimals]: [ ]); export const deployDefaultReserveInterestRateStrategy = async ([ - reserve, addressesProvider, baseVariableBorrowRate, variableSlope1, @@ -297,7 +309,6 @@ export const deployDefaultReserveInterestRateStrategy = async ([ stableSlope1, stableSlope2, ]: [ - tEthereumAddress, tEthereumAddress, string, string, @@ -308,7 +319,6 @@ export const deployDefaultReserveInterestRateStrategy = async ([ await deployContract( eContractid.DefaultReserveInterestRateStrategy, [ - reserve, addressesProvider, baseVariableBorrowRate, variableSlope1, @@ -349,15 +359,23 @@ export const getLendingPoolConfiguratorProxy = async ( }; export const getLendingPool = async (address?: tEthereumAddress) => { - return await getContract( - eContractid.LendingPool, + + const lendingPoolArtifact = await readArtifact( + BRE.config.paths.artifacts, + eContractid.LendingPool + ); + + + const factory = await linkLibrariesToArtifact(lendingPoolArtifact); + + return (await factory.attach( address || ( await getDb() .get(`${eContractid.LendingPool}.${BRE.network.name}`) .value() ).address - ); + )); }; export const getFeeProvider = async (address?: tEthereumAddress) => { diff --git a/test/__setup.spec.ts b/test/__setup.spec.ts index 3e3d4006..83d41b8a 100644 --- a/test/__setup.spec.ts +++ b/test/__setup.spec.ts @@ -194,9 +194,14 @@ const initReserves = async ( string, string ][])[assetAddressIndex]; - const reserveInitialized = await lendingPool.getReserveIsActive( + + console.log("Getting active flag for reserve ", tokenAddress); + const {isActive: reserveInitialized} = await lendingPool.getReserveConfigurationData( tokenAddress ); + console.log("Result ",reserveInitialized); + + if (reserveInitialized) { console.log( @@ -223,7 +228,6 @@ const initReserves = async ( ]; const rateStrategyContract = await deployDefaultReserveInterestRateStrategy( [ - tokenAddress, lendingPoolAddressesProvider.address, baseVariableBorrowRate, variableRateSlope1, @@ -233,6 +237,8 @@ const initReserves = async ( ] ); + console.log("Interest rate strategy deployed"); + if (process.env.POOL === AavePools.secondary) { if (assetSymbol.search("UNI") === -1) { assetSymbol = `Uni${assetSymbol}`; @@ -275,7 +281,7 @@ const enableReservesToBorrow = async ( string, string ][])[assetAddressIndex]; - const borrowingAlreadyEnabled = await lendingPool.isReserveBorrowingEnabled( + const {borrowingEnabled: borrowingAlreadyEnabled} = await lendingPool.getReserveConfigurationData( tokenAddress ); @@ -317,7 +323,7 @@ const enableReservesAsCollateral = async ( string, string ][])[assetAddressIndex]; - const alreadyEnabled = await lendingPool.isReserveUsageAsCollateralEnabled( + const {usageAsCollateralEnabled: alreadyEnabled} = await lendingPool.getReserveConfigurationData( tokenAddress ); @@ -406,7 +412,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { address ); - console.log("implementation set, address:", lendingPoolProxy) + console.log("implementation set, address:", lendingPoolProxy.address) await insertContractAddressInDb( eContractid.LendingPool, diff --git a/test/helpers/make-suite.ts b/test/helpers/make-suite.ts index 6507b45c..1f78b7c2 100644 --- a/test/helpers/make-suite.ts +++ b/test/helpers/make-suite.ts @@ -75,15 +75,30 @@ export async function initializeMakeSuite() { } testEnv.deployer = deployer; testEnv.pool = await getLendingPool(); + console.log("Pool loaded"); + testEnv.configurator = await getLendingPoolConfiguratorProxy(); + console.log("Configurator loaded"); + testEnv.oracle = await getPriceOracle(); + console.log("oracle loaded"); testEnv.addressesProvider = await getLendingPoolAddressesProvider(); + console.log("addresses provider loaded"); + testEnv.helpersContract = await getAaveProtocolTestHelpers(); + + console.log("helpers loaded"); + const aDaiAddress = (await testEnv.helpersContract.getAllATokens()).find( (aToken) => aToken.symbol === "aDAI" )?.tokenAddress; + console.log("getting reserves"); + const reservesTokens = await testEnv.helpersContract.getAllReservesTokens(); + + console.log("reserve tokens loaded"); + const daiAddress = reservesTokens.find(token => token.symbol === "DAI")?.tokenAddress; const usdcAddress = reservesTokens.find(token => token.symbol === "USDC")?.tokenAddress; if (!aDaiAddress) {