Pull master and fix conflicts

This commit is contained in:
David Racero 2021-01-29 13:27:12 +01:00
commit d464b0d592
49 changed files with 500 additions and 374 deletions

View File

@ -1,5 +1,22 @@
stages:
- checks
- prepare
- publish
variables:
IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}
lint:
stage: checks
tags:
- aave-build-runner
before_script:
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml build
script:
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run prettier:check
after_script:
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
test:
stage: checks
@ -12,7 +29,9 @@ test:
after_script:
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
only:
- master
- merge_requests
deploy-mainnet-fork:
tags:
- aave-build-runner
@ -24,6 +43,9 @@ deploy-mainnet-fork:
after_script:
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml run contracts-env npm run ci:clean
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
only:
- master
- merge_requests
certora-test:
stage: checks
@ -40,3 +62,31 @@ certora-test:
- certoraRun specs/harness/StableDebtTokenHarness.sol:StableDebtTokenHarness --solc_args "['--optimize']" --verify StableDebtTokenHarness:specs/StableDebtToken.spec --settings -assumeUnwindCond,-b=4 --cache StableDebtToken --cloud
- certoraRun specs/harness/UserConfigurationHarness.sol --verify UserConfigurationHarness:specs/UserConfiguration.spec --solc_args "['--optimize']" --settings -useBitVectorTheory --cache UserConfiguration --cloud
- certoraRun contracts/protocol/tokenization/VariableDebtToken.sol:VariableDebtToken specs/harness/LendingPoolHarnessForVariableDebtToken.sol --solc_args "['--optimize']" --link VariableDebtToken:POOL=LendingPoolHarnessForVariableDebtToken --verify VariableDebtToken:specs/VariableDebtToken.spec --settings -assumeUnwindCond,-useNonLinearArithmetic,-b=4 --cache VariableDebtToken --cloud
only:
- master
- merge_requests
prepare:
stage: prepare
tags:
- docker-builder
script:
- docker build -t ${IMAGE} .
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker push ${IMAGE}
only:
- master
publish:
image: ${IMAGE}
tags:
- docker
stage: publish
script:
- npm ci
- echo //registry.npmjs.org/:_authToken=${NPM_V2_PACKAGES_TOKEN} > .npmrc
- npm run compile
- ${VERSION}
- npm publish --access public
only:
- master

View File

@ -39,6 +39,37 @@ A more detailed and technical description of the protocol can be found in this r
You can join at the [Discord](http://aave.com/discord) channel or at the [Governance Forum](https://governance.aave.com/) for asking questions about the protocol or talk about Aave with other peers.
## Getting Started
You can install `@aave/protocol-v2` as an NPM package in your Hardhat, Buidler or Truffle project to import the contracts and interfaces:
`npm install @aave/protocol-v2`
Import at Solidity files:
```
import {ILendingPool} from "@aave/protocol-v2/contracts/interfaces/ILendingPool.sol";
contract Misc {
function deposit(address pool, address token, address user, uint256 amount) {
ILendingPool(pool).deposit(token, amount, user, '0');
{...}
}
}
```
The JSON artifacts with the ABI and Bytecode are also included into the bundled NPM package at `artifacts/` directory.
Import JSON file via Node JS `require`:
```
const LendingPoolV2Artifact = require('@aave/protocol-v2/artifacts/contracts/protocol/lendingpool/LendingPool.sol/LendingPool.json');
// Log the ABI into console
console.log(LendingPoolV2Artifact.abi)
```
## Setup
The repository uses Docker Compose to manage sensitive keys and load the configuration. Prior any action like test or deploy, you must run `docker-compose up` to start the `contracts-env` container, and then connect to the container console via `docker-compose exec contracts-env bash`.

View File

@ -346,6 +346,21 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
// Subtract flash loan fee
uint256 finalAmountIn = amountIn.sub(amountIn.mul(FLASHLOAN_PREMIUM_TOTAL).div(10000));
if (reserveIn == reserveOut) {
uint256 reserveDecimals = _getDecimals(reserveIn);
address[] memory path = new address[](1);
path[0] = reserveIn;
return
AmountCalc(
finalAmountIn,
finalAmountIn.mul(10**18).div(amountIn),
_calcUsdValue(reserveIn, amountIn, reserveDecimals),
_calcUsdValue(reserveIn, finalAmountIn, reserveDecimals),
path
);
}
address[] memory simplePath = new address[](2);
simplePath[0] = reserveIn;
simplePath[1] = reserveOut;
@ -421,6 +436,23 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
address reserveOut,
uint256 amountOut
) internal view returns (AmountCalc memory) {
if (reserveIn == reserveOut) {
// Add flash loan fee
uint256 amountIn = amountOut.add(amountOut.mul(FLASHLOAN_PREMIUM_TOTAL).div(10000));
uint256 reserveDecimals = _getDecimals(reserveIn);
address[] memory path = new address[](1);
path[0] = reserveIn;
return
AmountCalc(
amountIn,
amountOut.mul(10**18).div(amountIn),
_calcUsdValue(reserveIn, amountIn, reserveDecimals),
_calcUsdValue(reserveIn, amountOut, reserveDecimals),
path
);
}
(uint256[] memory amounts, address[] memory path) =
_getAmountsInAndPath(reserveIn, reserveOut, amountOut);

View File

@ -12,11 +12,11 @@ pragma solidity 0.6.12;
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal virtual view returns (address payable) {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal virtual view returns (bytes memory) {
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}

View File

@ -95,14 +95,14 @@ contract ERC20 is Context, IERC20 {
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public override view returns (uint256) {
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public override view returns (uint256) {
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
@ -124,9 +124,9 @@ contract ERC20 is Context, IERC20 {
*/
function allowance(address owner, address spender)
public
view
virtual
override
view
returns (uint256)
{
return _allowances[owner][spender];

View File

@ -24,7 +24,8 @@ contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy {
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Modifier to check whether the `msg.sender` is the admin.

View File

@ -22,13 +22,14 @@ contract BaseUpgradeabilityProxy is Proxy {
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 internal constant IMPLEMENTATION_SLOT =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation.
* @return impl Address of the current implementation
*/
function _implementation() internal override view returns (address impl) {
function _implementation() internal view override returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
//solium-disable-next-line
assembly {

View File

@ -20,7 +20,7 @@ abstract contract Proxy {
/**
* @return The Address of the implementation.
*/
function _implementation() internal virtual view returns (address);
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates execution to an implementation contract.

View File

@ -112,10 +112,7 @@ contract ATokensAndRatesHelper is Ownable {
liquidationBonuses[i]
);
configurator.enableBorrowingOnReserve(
assets[i],
stableBorrowingEnabled[i]
);
configurator.enableBorrowingOnReserve(assets[i], stableBorrowingEnabled[i]);
configurator.setReserveFactor(assets[i], reserveFactors[i]);
}
}

View File

@ -80,7 +80,7 @@ contract AaveOracle is IPriceOracleGetter, Ownable {
/// @notice Gets an asset price by address
/// @param asset The asset address
function getAssetPrice(address asset) public override view returns (uint256) {
function getAssetPrice(address asset) public view override returns (uint256) {
IChainlinkAggregator source = assetsSources[asset];
if (asset == WETH) {

View File

@ -93,7 +93,8 @@ contract WalletBalanceProvider {
uint256[] memory balances = new uint256[](reservesWithEth.length);
for (uint256 j = 0; j < reserves.length; j++) {
DataTypes.ReserveConfigurationMap memory configuration = pool.getConfiguration(reservesWithEth[j]);
DataTypes.ReserveConfigurationMap memory configuration =
pool.getConfiguration(reservesWithEth[j]);
(bool isActive, , , ) = configuration.getFlagsMemory();

View File

@ -68,9 +68,8 @@ contract MockFlashLoanReceiver is FlashLoanReceiverBase {
'Invalid balance for the contract'
);
uint256 amountToReturn = (_amountToApprove != 0)
? _amountToApprove
: amounts[i].add(premiums[i]);
uint256 amountToReturn =
(_amountToApprove != 0) ? _amountToApprove : amounts[i].add(premiums[i]);
//execution does not fail - mint tokens and return them to the _destination
token.mint(premiums[i]);

View File

@ -8,7 +8,7 @@ contract LendingRateOracle is ILendingRateOracle, Ownable {
mapping(address => uint256) borrowRates;
mapping(address => uint256) liquidityRates;
function getMarketBorrowRate(address _asset) external override view returns (uint256) {
function getMarketBorrowRate(address _asset) external view override returns (uint256) {
return borrowRates[_asset];
}

View File

@ -10,7 +10,7 @@ contract PriceOracle is IPriceOracle {
event AssetPriceUpdated(address _asset, uint256 _price, uint256 timestamp);
event EthPriceUpdated(uint256 _price, uint256 timestamp);
function getAssetPrice(address _asset) external override view returns (uint256) {
function getAssetPrice(address _asset) external view override returns (uint256) {
return prices[_asset];
}

View File

@ -139,9 +139,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
vars.currentLiquidityRate = 0;
uint256 utilizationRate =
vars.totalDebt == 0
? 0
: vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt));
vars.totalDebt == 0 ? 0 : vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt));
vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle())
.getMarketBorrowRate(reserve);

View File

@ -90,7 +90,10 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @param bonus The new liquidation bonus
**/
function setLiquidationBonus(DataTypes.ReserveConfigurationMap memory self, uint256 bonus) internal pure {
function setLiquidationBonus(DataTypes.ReserveConfigurationMap memory self, uint256 bonus)
internal
pure
{
require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.RC_INVALID_LIQ_BONUS);
self.data =
@ -116,7 +119,10 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @param decimals The decimals
**/
function setDecimals(DataTypes.ReserveConfigurationMap memory self, uint256 decimals) internal pure {
function setDecimals(DataTypes.ReserveConfigurationMap memory self, uint256 decimals)
internal
pure
{
require(decimals <= MAX_VALID_DECIMALS, Errors.RC_INVALID_DECIMALS);
self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION);
@ -127,7 +133,11 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @return The decimals of the asset
**/
function getDecimals(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) {
function getDecimals(DataTypes.ReserveConfigurationMap storage self)
internal
view
returns (uint256)
{
return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION;
}
@ -176,7 +186,10 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @param enabled True if the borrowing needs to be enabled, false otherwise
**/
function setBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure {
function setBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled)
internal
pure
{
self.data =
(self.data & BORROWING_MASK) |
(uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION);
@ -187,7 +200,11 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @return The borrowing state
**/
function getBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) {
function getBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self)
internal
view
returns (bool)
{
return (self.data & ~BORROWING_MASK) != 0;
}
@ -196,10 +213,10 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @param enabled True if the stable rate borrowing needs to be enabled, false otherwise
**/
function setStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled)
internal
pure
{
function setStableRateBorrowingEnabled(
DataTypes.ReserveConfigurationMap memory self,
bool enabled
) internal pure {
self.data =
(self.data & STABLE_BORROWING_MASK) |
(uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION);
@ -239,7 +256,11 @@ library ReserveConfiguration {
* @param self The reserve configuration
* @return The reserve factor
**/
function getReserveFactor(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) {
function getReserveFactor(DataTypes.ReserveConfigurationMap storage self)
internal
view
returns (uint256)
{
return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION;
}

View File

@ -53,11 +53,10 @@ library UserConfiguration {
* @param reserveIndex The index of the reserve in the bitmap
* @return True if the user has been using a reserve for borrowing or as collateral, false otherwise
**/
function isUsingAsCollateralOrBorrowing(DataTypes.UserConfigurationMap memory self, uint256 reserveIndex)
internal
pure
returns (bool)
{
function isUsingAsCollateralOrBorrowing(
DataTypes.UserConfigurationMap memory self,
uint256 reserveIndex
) internal pure returns (bool) {
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
return (self.data >> (reserveIndex * 2)) & 3 != 0;
}

View File

@ -213,9 +213,7 @@ library GenericLogic {
}
}
vars.avgLtv = vars.totalCollateralInETH > 0
? vars.avgLtv.div(vars.totalCollateralInETH)
: 0;
vars.avgLtv = vars.totalCollateralInETH > 0 ? vars.avgLtv.div(vars.totalCollateralInETH) : 0;
vars.avgLiquidationThreshold = vars.totalCollateralInETH > 0
? vars.avgLiquidationThreshold.div(vars.totalCollateralInETH)
: 0;
@ -265,7 +263,6 @@ library GenericLogic {
uint256 totalDebtInETH,
uint256 ltv
) internal pure returns (uint256) {
uint256 availableBorrowsETH = totalCollateralInETH.percentMul(ltv);
if (availableBorrowsETH < totalDebtInETH) {

View File

@ -1,7 +1,11 @@
{
"name": "protocol-v2",
"version": "1.0.0",
"name": "@aave/protocol-v2",
"version": "1.0.1",
"description": "Aave Protocol V2 smart contracts",
"files": [
"contracts",
"artifacts"
],
"scripts": {
"run-env": "npm i && tail -f /dev/null",
"hardhat": "hardhat",
@ -39,7 +43,8 @@
"aave:fork:main": "npm run compile && MAINNET_FORK=true hardhat aave:mainnet",
"aave:main:full:migration": "npm run compile && npm run hardhat:main -- aave:mainnet --verify",
"aave:main:full:initialize": "npm run compile && MAINNET_FORK=true full:initialize-tokens --pool Aave",
"dev:prettier": "prettier --write .",
"prettier:check": "npx prettier -c 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts' 'test/**/*.ts'",
"prettier:write": "prettier --write 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts' 'test/**/*.ts'",
"ci:test": "npm run compile && npm run test",
"ci:clean": "rm -rf ./artifacts ./cache ./types",
"print-contracts:kovan": "npm run hardhat:kovan -- print-contracts",
@ -62,7 +67,8 @@
"main:initialize-tokens": "npm run compile && hardhat --network main full:initialize-tokens --pool Aave",
"kovan:initialize-tokens": "npm run compile && hardhat --network kovan full:initialize-tokens --pool Aave",
"external:deploy-assets-kovan": "npm run compile && hardhat --network kovan external:deploy-new-asset --symbol ${SYMBOL} --verify",
"external:deploy-assets-main": "npm run compile && hardhat --network main external:deploy-new-asset --symbol ${SYMBOL} --verify"
"external:deploy-assets-main": "npm run compile && hardhat --network main external:deploy-new-asset --symbol ${SYMBOL} --verify",
"prepublishOnly": "npm run compile"
},
"devDependencies": {
"@nomiclabs/buidler": "^1.4.7",
@ -113,38 +119,27 @@
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
"pre-commit": "pretty-quick --staged --pattern 'contracts/**/*.sol' --pattern 'helpers/**/*.ts' --pattern 'test/**/*.ts' --pattern 'tasks/**/*.ts'"
}
},
"author": "Aave",
"contributors": [
{
"name": "Emilio Frangella",
"email": "emilio@aave.com"
},
{
"name": "Ernesto Boado",
"email": "ernesto@aave.com"
},
{
"name": "Andrey Kozlov",
"email": "andrey@aave.com"
},
{
"name": "David Racero",
"email": "david.k@aave.com"
},
{
"name": "Pol Sendra",
"email": "pol@aave.com"
},
{
"name": "David Truong",
"email": "david@aave.com"
}
"Ernesto Boado <ernesto@aave.com>",
"Emilio Frangella <emilio@aave.com>",
"Andrey Kozlov <andrey@aave.com>",
"David Racero <david.k@aave.com>",
"Pol Sendra <pol@aave.com>",
"David Truong <david@aave.com>"
],
"license": "AGPLv3",
"dependencies": {
"tmp-promise": "^3.0.2"
}
},
"keywords": [
"aave",
"protocol",
"protocol-v2",
"ethereum",
"solidity"
]
}

View File

@ -16,10 +16,7 @@ import {
import { tEthereumAddress, AavePools, eContractid } from '../../helpers/types';
import { waitForTx, filterMapBy } from '../../helpers/misc-utils';
import {
configureReservesByHelper,
initReservesByHelper,
} from '../../helpers/init-helpers';
import { configureReservesByHelper, initReservesByHelper } from '../../helpers/init-helpers';
import { getAllTokenAddresses } from '../../helpers/mock-helpers';
import { ZERO_ADDRESS } from '../../helpers/constants';
import {
@ -60,12 +57,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
ZERO_ADDRESS,
verify
);
await configureReservesByHelper(
reservesParams,
protoPoolReservesAddresses,
testHelpers,
admin
);
await configureReservesByHelper(reservesParams, protoPoolReservesAddresses, testHelpers, admin);
const collateralManager = await deployLendingPoolCollateralManager(verify);
await waitForTx(

View File

@ -1,8 +1,5 @@
import { task } from 'hardhat/config';
import {
getEthersSignersAddresses,
insertContractAddressInDb,
} from '../../helpers/contracts-helpers';
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
import {
deployATokensAndRatesHelper,
deployLendingPool,

View File

@ -6,13 +6,15 @@ import {
deployAaveProtocolDataProvider,
deployWETHGateway,
} from '../../helpers/contracts-deployments';
import { loadPoolConfig, ConfigNames, getWethAddress, getTreasuryAddress } from '../../helpers/configuration';
import {
loadPoolConfig,
ConfigNames,
getWethAddress,
getTreasuryAddress,
} from '../../helpers/configuration';
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
import { waitForTx } from '../../helpers/misc-utils';
import {
initReservesByHelper,
configureReservesByHelper,
} from '../../helpers/init-helpers';
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
import { exit } from 'process';
import {
getAaveProtocolDataProvider,
@ -43,7 +45,14 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
const treasuryAddress = await getTreasuryAddress(poolConfig);
await initReservesByHelper(ReservesConfig, reserveAssets, admin, treasuryAddress, ZERO_ADDRESS, verify);
await initReservesByHelper(
ReservesConfig,
reserveAssets,
admin,
treasuryAddress,
ZERO_ADDRESS,
verify
);
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
const collateralManager = await deployLendingPoolCollateralManager(verify);

View File

@ -1,7 +1,6 @@
import { task } from 'hardhat/config';
import { checkVerification } from '../../helpers/etherscan-verification';
import { ConfigNames } from '../../helpers/configuration';
import { EthereumNetworkNames } from '../../helpers/types';
import { printContracts } from '../../helpers/misc-utils';
import { usingTenderly } from '../../helpers/tenderly-utils';

View File

@ -61,8 +61,6 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
it('Freezes the ETH reserve', async () => {
const { configurator, weth, helpersContract } = testEnv;
await configurator.freezeReserve(weth.address);
const {
decimals,

View File

@ -268,7 +268,6 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
const reserveDataAfter = helpersContract.getReserveData(usdc.address);
const reserveData = await helpersContract.getReserveData(usdc.address);
const userData = await helpersContract.getUserReserveData(usdc.address, depositor.address);
@ -406,7 +405,9 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
'0'
);
const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address);
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
weth.address
);
const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);
@ -480,7 +481,9 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
'0'
);
const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address);
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
weth.address
);
const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);

View File

@ -1,5 +1,13 @@
import BigNumber from 'bignumber.js';
import {RAY, WAD, HALF_RAY, HALF_WAD, WAD_RAY_RATIO, HALF_PERCENTAGE, PERCENTAGE_FACTOR} from '../../../helpers/constants';
import {
RAY,
WAD,
HALF_RAY,
HALF_WAD,
WAD_RAY_RATIO,
HALF_PERCENTAGE,
PERCENTAGE_FACTOR,
} from '../../../helpers/constants';
declare module 'bignumber.js' {
interface BigNumber {
@ -68,19 +76,22 @@ BigNumber.prototype.wadToRay = function (): BigNumber {
return this.multipliedBy(WAD_RAY_RATIO).decimalPlaces(0, BigNumber.ROUND_DOWN);
};
BigNumber.prototype.halfPercentage = (): BigNumber => {
return new BigNumber(HALF_PERCENTAGE).decimalPlaces(0, BigNumber.ROUND_DOWN);
};
BigNumber.prototype.percentMul = function (b: BigNumber): BigNumber {
return this.halfPercentage().plus(this.multipliedBy(b)).div(PERCENTAGE_FACTOR).decimalPlaces(0, BigNumber.ROUND_DOWN);
return this.halfPercentage()
.plus(this.multipliedBy(b))
.div(PERCENTAGE_FACTOR)
.decimalPlaces(0, BigNumber.ROUND_DOWN);
};
BigNumber.prototype.percentDiv = function (a: BigNumber): BigNumber {
const halfA = a.div(2).decimalPlaces(0, BigNumber.ROUND_DOWN);
return halfA.plus(this.multipliedBy(PERCENTAGE_FACTOR)).div(a).decimalPlaces(0, BigNumber.ROUND_DOWN);
return halfA
.plus(this.multipliedBy(PERCENTAGE_FACTOR))
.div(a)
.decimalPlaces(0, BigNumber.ROUND_DOWN);
};

View File

@ -30,10 +30,7 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
}
await expect(
addressesProvider.setAddress(
utils.keccak256(utils.toUtf8Bytes('RANDOM_ID')),
mockAddress
)
addressesProvider.setAddress(utils.keccak256(utils.toUtf8Bytes('RANDOM_ID')), mockAddress)
).to.be.revertedWith(INVALID_OWNER_REVERT_MSG);
await expect(
@ -42,7 +39,6 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
mockAddress
)
).to.be.revertedWith(INVALID_OWNER_REVERT_MSG);
});
it('Tests adding a proxied address with `setAddressAsProxy()`', async () => {
@ -51,7 +47,6 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
const currentAddressesProviderOwner = users[1];
const mockLendingPool = await deployLendingPool();
const proxiedAddressId = utils.keccak256(utils.toUtf8Bytes('RANDOM_PROXIED'));
@ -74,7 +69,6 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
expect(proxiedAddressSetReceipt.events[1].args?.hasProxy).to.be.equal(true);
});
it('Tests adding a non proxied address with `setAddress()`', async () => {
const { addressesProvider, users } = testEnv;
const { INVALID_OWNER_REVERT_MSG } = ProtocolErrors;
@ -103,6 +97,5 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
mockNonProxiedAddress
);
expect(nonProxiedAddressSetReceipt.events[0].args?.hasProxy).to.be.equal(false);
});
});

View File

@ -99,7 +99,7 @@ makeSuite('Mainnet Check list', (testEnv: TestEnv) => {
});
it('Borrow stable WETH and Full Repay with ETH', async () => {
const { users, wethGateway, aWETH, weth, pool, helpersContract } = testEnv;
const { users, wethGateway, aWETH, dai, aDai, weth, pool, helpersContract } = testEnv;
const borrowSize = parseEther('1');
const repaySize = borrowSize.add(borrowSize.mul(5).div(100));
const user = users[1];

View File

@ -119,7 +119,9 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
await configurator.updateVariableDebtToken(dai.address, newVariableTokenAddress);
const {variableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(dai.address);
const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
dai.address
);
const debtToken = await getMockVariableDebtToken(variableDebtTokenAddress);

View File

@ -14,7 +14,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
const depositSize = parseEther('5');
const daiSize = parseEther('10000');
it('Deposit WETH via WethGateway and DAI', async () => {
const { users, wethGateway, aWETH, dai, pool } = testEnv;
const { users, wethGateway, aWETH } = testEnv;
const user = users[1];
const depositor = users[0];