diff --git a/README.md b/README.md index ca1124e..10c06b5 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,6 @@ function setUnderlyingToProtocolWrapped(address _underlying, bytes32 _protocol, | Protocol | Key | Address | |----------|--------------------------------------------------------------------|--------------------------------------------| | Compound | 0x561ca898cce9f021c15a441ef41899706e923541cee724530075d1a1144761c7 | 0xB9a13E1D9c5dad1557C3B9B20ab99fb0FB16cCA7 | -| Aave | 0xa9699be9874dcc3e11474d7d87b44bb314eb412a1960f1478100f7e2ccd4a6eb | 0x1708BC3AAAAcE29fB1Cf78AB917d135957317583 | +| Aave | 0xa9699be9874dcc3e11474d7d87b44bb314eb412a1960f1478100f7e2ccd4a6eb | 0x6Eb123bbd02324600AcF8a53575547EEB0a43135 | Lending logic contracts return the calls needed to lend or unlend from a protocol. \ No newline at end of file diff --git a/buidler.config.ts b/buidler.config.ts index 677d044..dd4d19d 100644 --- a/buidler.config.ts +++ b/buidler.config.ts @@ -22,6 +22,7 @@ import { LendingLogicCompoundFactory } from "./typechain/LendingLogicCompoundFac import { LendingRegistry } from "./typechain/LendingRegistry"; import { LendingRegistryFactory } from "./typechain/LendingRegistryFactory"; import { LendingLogicAaveFactory } from "./typechain/LendingLogicAaveFactory"; +import { LendingManagerFactory } from "./typechain/LendingManagerFactory"; usePlugin("@nomiclabs/buidler-ethers"); usePlugin('solidity-coverage'); @@ -250,6 +251,16 @@ task("deploy-pie-factory") }); +task("deploy-lending-manager") + .addParam("lendingRegistry", "address of the lending registry") + .addParam("pie", "address of the pie to manage") + .setAction(async(taskArgs, {ethers}) => { + const signers = await ethers.getSigners(); + const lendingManager = await (new LendingManagerFactory(signers[0])).deploy(taskArgs.lendingRegistry, taskArgs.pie); + + console.log(`lendingManager deployed at: ${lendingManager.address}`); +}); + task("deploy-lending-registry") .setAction(async(taskArgs, {ethers}) => { const signers = await ethers.getSigners(); diff --git a/contracts/callManagers/LendingManager/LendingLogicAave.sol b/contracts/callManagers/LendingManager/LendingLogicAave.sol index 5a51346..3b3f59d 100644 --- a/contracts/callManagers/LendingManager/LendingLogicAave.sol +++ b/contracts/callManagers/LendingManager/LendingLogicAave.sol @@ -20,16 +20,18 @@ contract LendingLogicAave is ILendingLogic { function lend(address _underlying, uint256 _amount) external view override returns(address[] memory targets, bytes[] memory data) { IERC20 underlying = IERC20(_underlying); + address core = lendingPool.core(); + targets = new address[](3); data = new bytes[](3); // zero out approval to be sure targets[0] = _underlying; - data[0] = abi.encodeWithSelector(underlying.approve.selector, address(lendingPool), 0); + data[0] = abi.encodeWithSelector(underlying.approve.selector, address(core), 0); // Set approval targets[1] = _underlying; - data[1] = abi.encodeWithSelector(underlying.approve.selector, address(lendingPool), _amount); + data[1] = abi.encodeWithSelector(underlying.approve.selector, address(core), _amount); // Deposit into Aave targets[2] = address(lendingPool); diff --git a/contracts/interfaces/IAaveLendingPool.sol b/contracts/interfaces/IAaveLendingPool.sol index a5ee67c..bb9e700 100644 --- a/contracts/interfaces/IAaveLendingPool.sol +++ b/contracts/interfaces/IAaveLendingPool.sol @@ -4,4 +4,5 @@ pragma solidity ^0.7.1; interface IAaveLendingPool { function deposit(address _reserve, uint256 _amount, uint16 _referralCode) external; + function core() external view returns(address); } \ No newline at end of file diff --git a/contracts/test/MockAaveLendingPool.sol b/contracts/test/MockAaveLendingPool.sol index 967494d..80db76b 100644 --- a/contracts/test/MockAaveLendingPool.sol +++ b/contracts/test/MockAaveLendingPool.sol @@ -25,4 +25,8 @@ contract MockAaveLendingPool is IAaveLendingPool { function setRevertDeposit(bool _doRevert) external { revertDeposit = _doRevert; } + + function core() external view override returns(address) { + return address(this); + } }