Skip to content

Commit

Permalink
Merge pull request #7 from aave/fix/6_remove_lending_name
Browse files Browse the repository at this point in the history
Remove `Lending` name
  • Loading branch information
kartojal authored Oct 1, 2021
2 parents f24ae51 + 16de46a commit f642a9d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions contracts/misc/UiPoolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
uint256
)
{
IPool lendingPool = IPool(provider.getPool());
address[] memory reserves = lendingPool.getReservesList();
DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
IPool pool = IPool(provider.getPool());
address[] memory reserves = pool.getReservesList();
DataTypes.UserConfigurationMap memory userConfig = pool.getUserConfiguration(user);

AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length);
UserReserveData[] memory userReservesData =
Expand All @@ -75,7 +75,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {

// reserve current state
DataTypes.ReserveData memory baseData =
lendingPool.getReserveData(reserveData.underlyingAsset);
pool.getReserveData(reserveData.underlyingAsset);
reserveData.liquidityIndex = baseData.liquidityIndex;
reserveData.variableBorrowIndex = baseData.variableBorrowIndex;
reserveData.liquidityRate = baseData.currentLiquidityRate;
Expand Down
44 changes: 22 additions & 22 deletions contracts/misc/WETHGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,45 @@ contract WETHGateway is IWETHGateway, Ownable {
IWETH internal immutable WETH;

/**
* @dev Sets the WETH address and the LendingPoolAddressesProvider address. Infinite approves lending pool.
* @dev Sets the WETH address and the PoolAddressesProvider address. Infinite approves pool.
* @param weth Address of the Wrapped Ether contract
**/
constructor(address weth) {
WETH = IWETH(weth);
}

function authorizeLendingPool(address lendingPool) external onlyOwner {
WETH.approve(lendingPool, type(uint256).max);
function authorizePool(address pool) external onlyOwner {
WETH.approve(pool, type(uint256).max);
}

/**
* @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens)
* is minted.
* @param lendingPool address of the targeted underlying lending pool
* @param pool address of the targeted underlying pool
* @param onBehalfOf address of the user who will receive the aTokens representing the deposit
* @param referralCode integrators are assigned a referral code and can potentially receive rewards.
**/
function depositETH(
address lendingPool,
address pool,
address onBehalfOf,
uint16 referralCode
) external payable override {
WETH.deposit{value: msg.value}();
IPool(lendingPool).deposit(address(WETH), msg.value, onBehalfOf, referralCode);
IPool(pool).deposit(address(WETH), msg.value, onBehalfOf, referralCode);
}

/**
* @dev withdraws the WETH _reserves of msg.sender.
* @param lendingPool address of the targeted underlying lending pool
* @param pool address of the targeted underlying pool
* @param amount amount of aWETH to withdraw and receive native ETH
* @param to address of the user who will receive native ETH
*/
function withdrawETH(
address lendingPool,
address pool,
uint256 amount,
address to
) external override {
IAToken aWETH = IAToken(IPool(lendingPool).getReserveData(address(WETH)).aTokenAddress);
IAToken aWETH = IAToken(IPool(pool).getReserveData(address(WETH)).aTokenAddress);
uint256 userBalance = aWETH.balanceOf(msg.sender);
uint256 amountToWithdraw = amount;

Expand All @@ -66,28 +66,28 @@ contract WETHGateway is IWETHGateway, Ownable {
amountToWithdraw = userBalance;
}
aWETH.transferFrom(msg.sender, address(this), amountToWithdraw);
IPool(lendingPool).withdraw(address(WETH), amountToWithdraw, address(this));
IPool(pool).withdraw(address(WETH), amountToWithdraw, address(this));
WETH.withdraw(amountToWithdraw);
_safeTransferETH(to, amountToWithdraw);
}

/**
* @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified).
* @param lendingPool address of the targeted underlying lending pool
* @param pool address of the targeted underlying pool
* @param amount the amount to repay, or uint256(-1) if the user wants to repay everything
* @param rateMode the rate mode to repay
* @param onBehalfOf the address for which msg.sender is repaying
*/
function repayETH(
address lendingPool,
address pool,
uint256 amount,
uint256 rateMode,
address onBehalfOf
) external payable override {
(uint256 stableDebt, uint256 variableDebt) =
Helpers.getUserCurrentDebtMemory(
onBehalfOf,
IPool(lendingPool).getReserveData(address(WETH))
IPool(pool).getReserveData(address(WETH))
);

uint256 paybackAmount =
Expand All @@ -100,26 +100,26 @@ contract WETHGateway is IWETHGateway, Ownable {
}
require(msg.value >= paybackAmount, 'msg.value is less than repayment amount');
WETH.deposit{value: paybackAmount}();
IPool(lendingPool).repay(address(WETH), msg.value, rateMode, onBehalfOf);
IPool(pool).repay(address(WETH), msg.value, rateMode, onBehalfOf);

// refund remaining dust eth
if (msg.value > paybackAmount) _safeTransferETH(msg.sender, msg.value - paybackAmount);
}

/**
* @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `LendingPool.borrow`.
* @param lendingPool address of the targeted underlying lending pool
* @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `Pool.borrow`.
* @param pool address of the targeted underlying pool
* @param amount the amount of ETH to borrow
* @param interesRateMode the interest rate mode
* @param referralCode integrators are assigned a referral code and can potentially receive rewards
*/
function borrowETH(
address lendingPool,
address pool,
uint256 amount,
uint256 interesRateMode,
uint16 referralCode
) external override {
IPool(lendingPool).borrow(
IPool(pool).borrow(
address(WETH),
amount,
interesRateMode,
Expand All @@ -132,7 +132,7 @@ contract WETHGateway is IWETHGateway, Ownable {

/**
* @dev withdraws the WETH _reserves of msg.sender.
* @param lendingPool address of the targeted underlying lending pool
* @param pool address of the targeted underlying pool
* @param amount amount of aWETH to withdraw and receive native ETH
* @param to address of the user who will receive native ETH
* @param deadline validity deadline of permit and so depositWithPermit signature
Expand All @@ -141,15 +141,15 @@ contract WETHGateway is IWETHGateway, Ownable {
* @param permitS S parameter of ERC712 permit sig
*/
function withdrawETHWithPermit(
address lendingPool,
address pool,
uint256 amount,
address to,
uint256 deadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external override {
IAToken aWETH = IAToken(IPool(lendingPool).getReserveData(address(WETH)).aTokenAddress);
IAToken aWETH = IAToken(IPool(pool).getReserveData(address(WETH)).aTokenAddress);
uint256 userBalance = aWETH.balanceOf(msg.sender);
uint256 amountToWithdraw = amount;

Expand All @@ -160,7 +160,7 @@ contract WETHGateway is IWETHGateway, Ownable {
// chosing to permit `amount`and not `amountToWithdraw`, easier for frontends, intregrators.
aWETH.permit(msg.sender, address(this), amount, deadline, permitV, permitR, permitS);
aWETH.transferFrom(msg.sender, address(this), amountToWithdraw);
IPool(lendingPool).withdraw(address(WETH), amountToWithdraw, address(this));
IPool(pool).withdraw(address(WETH), amountToWithdraw, address(this));
WETH.withdraw(amountToWithdraw);
_safeTransferETH(to, amountToWithdraw);
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/misc/interfaces/IWETHGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ pragma solidity 0.8.7;

interface IWETHGateway {
function depositETH(
address lendingPool,
address pool,
address onBehalfOf,
uint16 referralCode
) external payable;

function withdrawETH(
address lendingPool,
address pool,
uint256 amount,
address onBehalfOf
) external;

function repayETH(
address lendingPool,
address pool,
uint256 amount,
uint256 rateMode,
address onBehalfOf
) external payable;

function borrowETH(
address lendingPool,
address pool,
uint256 amount,
uint256 interesRateMode,
uint16 referralCode
) external;

function withdrawETHWithPermit(
address lendingPool,
address pool,
uint256 amount,
address to,
uint256 deadline,
Expand Down
2 changes: 1 addition & 1 deletion helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ONE_ADDRESS = '0x0000000000000000000000000000000000000001';
// ----------------
export const OPTIMAL_UTILIZATION_RATE = new BigNumber(0.8).times(RAY);
export const EXCESS_UTILIZATION_RATE = new BigNumber(0.2).times(RAY);
export const APPROVAL_AMOUNT_LENDING_POOL = '1000000000000000000000000000';
export const APPROVAL_AMOUNT_POOL = '1000000000000000000000000000';
export const TOKEN_DISTRIBUTOR_PERCENTAGE_BASE = '10000';
export const MOCK_USD_PRICE_IN_WEI = '5848466240000000';
export const USD_ADDRESS = '0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96';
Expand Down
4 changes: 2 additions & 2 deletions helpers/init-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ export const configureReservesByHelper = async (

export const authorizeWETHGateway = async (
wethGateWay: tEthereumAddress,
lendingPool: tEthereumAddress
pool: tEthereumAddress
) =>
await new WETHGateway__factory(await getFirstSigner())
.attach(wethGateWay)
.authorizeLendingPool(lendingPool);
.authorizePool(pool);
2 changes: 1 addition & 1 deletion test/weth-gateway.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { deploySelfdestructTransferMock } from '../helpers/contracts-deployments

const { expect } = require('chai');

makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) => {
makeSuite('Use native ETH at Pool via WETHGateway', (testEnv: TestEnv) => {
const zero = BigNumber.from('0');
const depositSize = utils.parseEther('5');
const daiSize = utils.parseEther('10000');
Expand Down

0 comments on commit f642a9d

Please sign in to comment.