mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Pull master and fix conflicts
This commit is contained in:
commit
d464b0d592
|
@ -1,5 +1,22 @@
|
||||||
stages:
|
stages:
|
||||||
- checks
|
- 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:
|
test:
|
||||||
stage: checks
|
stage: checks
|
||||||
|
@ -12,7 +29,9 @@ test:
|
||||||
after_script:
|
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 run contracts-env npm run ci:clean
|
||||||
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
|
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- merge_requests
|
||||||
deploy-mainnet-fork:
|
deploy-mainnet-fork:
|
||||||
tags:
|
tags:
|
||||||
- aave-build-runner
|
- aave-build-runner
|
||||||
|
@ -24,6 +43,9 @@ deploy-mainnet-fork:
|
||||||
after_script:
|
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 run contracts-env npm run ci:clean
|
||||||
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
|
- docker-compose -p ${CI_JOB_ID} -f docker-compose.test.yml down
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
certora-test:
|
certora-test:
|
||||||
stage: checks
|
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/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 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
|
- 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
|
||||||
|
|
31
README.md
31
README.md
|
@ -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.
|
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
|
## 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`.
|
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`.
|
||||||
|
|
|
@ -346,6 +346,21 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
|
||||||
// Subtract flash loan fee
|
// Subtract flash loan fee
|
||||||
uint256 finalAmountIn = amountIn.sub(amountIn.mul(FLASHLOAN_PREMIUM_TOTAL).div(10000));
|
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);
|
address[] memory simplePath = new address[](2);
|
||||||
simplePath[0] = reserveIn;
|
simplePath[0] = reserveIn;
|
||||||
simplePath[1] = reserveOut;
|
simplePath[1] = reserveOut;
|
||||||
|
@ -421,6 +436,23 @@ abstract contract BaseUniswapAdapter is FlashLoanReceiverBase, IBaseUniswapAdapt
|
||||||
address reserveOut,
|
address reserveOut,
|
||||||
uint256 amountOut
|
uint256 amountOut
|
||||||
) internal view returns (AmountCalc memory) {
|
) 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) =
|
(uint256[] memory amounts, address[] memory path) =
|
||||||
_getAmountsInAndPath(reserveIn, reserveOut, amountOut);
|
_getAmountsInAndPath(reserveIn, reserveOut, amountOut);
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,11 @@ pragma solidity 0.6.12;
|
||||||
* This contract is only required for intermediate, library-like contracts.
|
* This contract is only required for intermediate, library-like contracts.
|
||||||
*/
|
*/
|
||||||
abstract contract Context {
|
abstract contract Context {
|
||||||
function _msgSender() internal virtual view returns (address payable) {
|
function _msgSender() internal view virtual returns (address payable) {
|
||||||
return msg.sender;
|
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
|
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
|
||||||
return msg.data;
|
return msg.data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,14 +95,14 @@ contract ERC20 is Context, IERC20 {
|
||||||
/**
|
/**
|
||||||
* @dev See {IERC20-totalSupply}.
|
* @dev See {IERC20-totalSupply}.
|
||||||
*/
|
*/
|
||||||
function totalSupply() public override view returns (uint256) {
|
function totalSupply() public view override returns (uint256) {
|
||||||
return _totalSupply;
|
return _totalSupply;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev See {IERC20-balanceOf}.
|
* @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];
|
return _balances[account];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ contract ERC20 is Context, IERC20 {
|
||||||
*/
|
*/
|
||||||
function allowance(address owner, address spender)
|
function allowance(address owner, address spender)
|
||||||
public
|
public
|
||||||
|
view
|
||||||
virtual
|
virtual
|
||||||
override
|
override
|
||||||
view
|
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
return _allowances[owner][spender];
|
return _allowances[owner][spender];
|
||||||
|
|
|
@ -24,7 +24,8 @@ contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy {
|
||||||
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
|
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
|
||||||
* validated in the constructor.
|
* 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.
|
* @dev Modifier to check whether the `msg.sender` is the admin.
|
||||||
|
|
|
@ -22,13 +22,14 @@ contract BaseUpgradeabilityProxy is Proxy {
|
||||||
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
|
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
|
||||||
* validated in the constructor.
|
* validated in the constructor.
|
||||||
*/
|
*/
|
||||||
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
bytes32 internal constant IMPLEMENTATION_SLOT =
|
||||||
|
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Returns the current implementation.
|
* @dev Returns the current implementation.
|
||||||
* @return impl Address of 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;
|
bytes32 slot = IMPLEMENTATION_SLOT;
|
||||||
//solium-disable-next-line
|
//solium-disable-next-line
|
||||||
assembly {
|
assembly {
|
||||||
|
|
|
@ -20,7 +20,7 @@ abstract contract Proxy {
|
||||||
/**
|
/**
|
||||||
* @return The Address of the implementation.
|
* @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.
|
* @dev Delegates execution to an implementation contract.
|
||||||
|
|
|
@ -112,10 +112,7 @@ contract ATokensAndRatesHelper is Ownable {
|
||||||
liquidationBonuses[i]
|
liquidationBonuses[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
configurator.enableBorrowingOnReserve(
|
configurator.enableBorrowingOnReserve(assets[i], stableBorrowingEnabled[i]);
|
||||||
assets[i],
|
|
||||||
stableBorrowingEnabled[i]
|
|
||||||
);
|
|
||||||
configurator.setReserveFactor(assets[i], reserveFactors[i]);
|
configurator.setReserveFactor(assets[i], reserveFactors[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ contract AaveOracle is IPriceOracleGetter, Ownable {
|
||||||
|
|
||||||
/// @notice Gets an asset price by address
|
/// @notice Gets an asset price by address
|
||||||
/// @param asset The asset 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];
|
IChainlinkAggregator source = assetsSources[asset];
|
||||||
|
|
||||||
if (asset == WETH) {
|
if (asset == WETH) {
|
||||||
|
|
|
@ -93,7 +93,8 @@ contract WalletBalanceProvider {
|
||||||
uint256[] memory balances = new uint256[](reservesWithEth.length);
|
uint256[] memory balances = new uint256[](reservesWithEth.length);
|
||||||
|
|
||||||
for (uint256 j = 0; j < reserves.length; j++) {
|
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();
|
(bool isActive, , , ) = configuration.getFlagsMemory();
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,8 @@ contract MockFlashLoanReceiver is FlashLoanReceiverBase {
|
||||||
'Invalid balance for the contract'
|
'Invalid balance for the contract'
|
||||||
);
|
);
|
||||||
|
|
||||||
uint256 amountToReturn = (_amountToApprove != 0)
|
uint256 amountToReturn =
|
||||||
? _amountToApprove
|
(_amountToApprove != 0) ? _amountToApprove : amounts[i].add(premiums[i]);
|
||||||
: amounts[i].add(premiums[i]);
|
|
||||||
//execution does not fail - mint tokens and return them to the _destination
|
//execution does not fail - mint tokens and return them to the _destination
|
||||||
|
|
||||||
token.mint(premiums[i]);
|
token.mint(premiums[i]);
|
||||||
|
|
|
@ -8,7 +8,7 @@ contract LendingRateOracle is ILendingRateOracle, Ownable {
|
||||||
mapping(address => uint256) borrowRates;
|
mapping(address => uint256) borrowRates;
|
||||||
mapping(address => uint256) liquidityRates;
|
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];
|
return borrowRates[_asset];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ contract PriceOracle is IPriceOracle {
|
||||||
event AssetPriceUpdated(address _asset, uint256 _price, uint256 timestamp);
|
event AssetPriceUpdated(address _asset, uint256 _price, uint256 timestamp);
|
||||||
event EthPriceUpdated(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];
|
return prices[_asset];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,7 @@ contract DefaultReserveInterestRateStrategy is IReserveInterestRateStrategy {
|
||||||
vars.currentLiquidityRate = 0;
|
vars.currentLiquidityRate = 0;
|
||||||
|
|
||||||
uint256 utilizationRate =
|
uint256 utilizationRate =
|
||||||
vars.totalDebt == 0
|
vars.totalDebt == 0 ? 0 : vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt));
|
||||||
? 0
|
|
||||||
: vars.totalDebt.rayDiv(availableLiquidity.add(vars.totalDebt));
|
|
||||||
|
|
||||||
vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle())
|
vars.currentStableBorrowRate = ILendingRateOracle(addressesProvider.getLendingRateOracle())
|
||||||
.getMarketBorrowRate(reserve);
|
.getMarketBorrowRate(reserve);
|
||||||
|
|
|
@ -90,7 +90,10 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @param bonus The new liquidation bonus
|
* @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);
|
require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.RC_INVALID_LIQ_BONUS);
|
||||||
|
|
||||||
self.data =
|
self.data =
|
||||||
|
@ -116,7 +119,10 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @param decimals The decimals
|
* @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);
|
require(decimals <= MAX_VALID_DECIMALS, Errors.RC_INVALID_DECIMALS);
|
||||||
|
|
||||||
self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION);
|
self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION);
|
||||||
|
@ -127,7 +133,11 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @return The decimals of the asset
|
* @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;
|
return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +186,10 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @param enabled True if the borrowing needs to be enabled, false otherwise
|
* @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 =
|
||||||
(self.data & BORROWING_MASK) |
|
(self.data & BORROWING_MASK) |
|
||||||
(uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION);
|
(uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION);
|
||||||
|
@ -187,7 +200,11 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @return The borrowing state
|
* @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;
|
return (self.data & ~BORROWING_MASK) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,10 +213,10 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @param enabled True if the stable rate borrowing needs to be enabled, false otherwise
|
* @param enabled True if the stable rate borrowing needs to be enabled, false otherwise
|
||||||
**/
|
**/
|
||||||
function setStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled)
|
function setStableRateBorrowingEnabled(
|
||||||
internal
|
DataTypes.ReserveConfigurationMap memory self,
|
||||||
pure
|
bool enabled
|
||||||
{
|
) internal pure {
|
||||||
self.data =
|
self.data =
|
||||||
(self.data & STABLE_BORROWING_MASK) |
|
(self.data & STABLE_BORROWING_MASK) |
|
||||||
(uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION);
|
(uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION);
|
||||||
|
@ -239,7 +256,11 @@ library ReserveConfiguration {
|
||||||
* @param self The reserve configuration
|
* @param self The reserve configuration
|
||||||
* @return The reserve factor
|
* @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;
|
return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,10 @@ library UserConfiguration {
|
||||||
* @param reserveIndex The index of the reserve in the bitmap
|
* @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
|
* @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)
|
function isUsingAsCollateralOrBorrowing(
|
||||||
internal
|
DataTypes.UserConfigurationMap memory self,
|
||||||
pure
|
uint256 reserveIndex
|
||||||
returns (bool)
|
) internal pure returns (bool) {
|
||||||
{
|
|
||||||
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
|
require(reserveIndex < 128, Errors.UL_INVALID_INDEX);
|
||||||
return (self.data >> (reserveIndex * 2)) & 3 != 0;
|
return (self.data >> (reserveIndex * 2)) & 3 != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,9 +213,7 @@ library GenericLogic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vars.avgLtv = vars.totalCollateralInETH > 0
|
vars.avgLtv = vars.totalCollateralInETH > 0 ? vars.avgLtv.div(vars.totalCollateralInETH) : 0;
|
||||||
? vars.avgLtv.div(vars.totalCollateralInETH)
|
|
||||||
: 0;
|
|
||||||
vars.avgLiquidationThreshold = vars.totalCollateralInETH > 0
|
vars.avgLiquidationThreshold = vars.totalCollateralInETH > 0
|
||||||
? vars.avgLiquidationThreshold.div(vars.totalCollateralInETH)
|
? vars.avgLiquidationThreshold.div(vars.totalCollateralInETH)
|
||||||
: 0;
|
: 0;
|
||||||
|
@ -265,7 +263,6 @@ library GenericLogic {
|
||||||
uint256 totalDebtInETH,
|
uint256 totalDebtInETH,
|
||||||
uint256 ltv
|
uint256 ltv
|
||||||
) internal pure returns (uint256) {
|
) internal pure returns (uint256) {
|
||||||
|
|
||||||
uint256 availableBorrowsETH = totalCollateralInETH.percentMul(ltv);
|
uint256 availableBorrowsETH = totalCollateralInETH.percentMul(ltv);
|
||||||
|
|
||||||
if (availableBorrowsETH < totalDebtInETH) {
|
if (availableBorrowsETH < totalDebtInETH) {
|
||||||
|
|
55
package.json
55
package.json
|
@ -1,7 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "protocol-v2",
|
"name": "@aave/protocol-v2",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "Aave Protocol V2 smart contracts",
|
"description": "Aave Protocol V2 smart contracts",
|
||||||
|
"files": [
|
||||||
|
"contracts",
|
||||||
|
"artifacts"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"run-env": "npm i && tail -f /dev/null",
|
"run-env": "npm i && tail -f /dev/null",
|
||||||
"hardhat": "hardhat",
|
"hardhat": "hardhat",
|
||||||
|
@ -39,7 +43,8 @@
|
||||||
"aave:fork:main": "npm run compile && MAINNET_FORK=true hardhat aave:mainnet",
|
"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: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",
|
"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:test": "npm run compile && npm run test",
|
||||||
"ci:clean": "rm -rf ./artifacts ./cache ./types",
|
"ci:clean": "rm -rf ./artifacts ./cache ./types",
|
||||||
"print-contracts:kovan": "npm run hardhat:kovan -- print-contracts",
|
"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",
|
"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",
|
"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-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": {
|
"devDependencies": {
|
||||||
"@nomiclabs/buidler": "^1.4.7",
|
"@nomiclabs/buidler": "^1.4.7",
|
||||||
|
@ -113,38 +119,27 @@
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"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",
|
"author": "Aave",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
"Ernesto Boado <ernesto@aave.com>",
|
||||||
"name": "Emilio Frangella",
|
"Emilio Frangella <emilio@aave.com>",
|
||||||
"email": "emilio@aave.com"
|
"Andrey Kozlov <andrey@aave.com>",
|
||||||
},
|
"David Racero <david.k@aave.com>",
|
||||||
{
|
"Pol Sendra <pol@aave.com>",
|
||||||
"name": "Ernesto Boado",
|
"David Truong <david@aave.com>"
|
||||||
"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"
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"license": "AGPLv3",
|
"license": "AGPLv3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tmp-promise": "^3.0.2"
|
"tmp-promise": "^3.0.2"
|
||||||
}
|
},
|
||||||
|
"keywords": [
|
||||||
|
"aave",
|
||||||
|
"protocol",
|
||||||
|
"protocol-v2",
|
||||||
|
"ethereum",
|
||||||
|
"solidity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,7 @@ import {
|
||||||
|
|
||||||
import { tEthereumAddress, AavePools, eContractid } from '../../helpers/types';
|
import { tEthereumAddress, AavePools, eContractid } from '../../helpers/types';
|
||||||
import { waitForTx, filterMapBy } from '../../helpers/misc-utils';
|
import { waitForTx, filterMapBy } from '../../helpers/misc-utils';
|
||||||
import {
|
import { configureReservesByHelper, initReservesByHelper } from '../../helpers/init-helpers';
|
||||||
configureReservesByHelper,
|
|
||||||
initReservesByHelper,
|
|
||||||
} from '../../helpers/init-helpers';
|
|
||||||
import { getAllTokenAddresses } from '../../helpers/mock-helpers';
|
import { getAllTokenAddresses } from '../../helpers/mock-helpers';
|
||||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
import {
|
import {
|
||||||
|
@ -60,12 +57,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
await configureReservesByHelper(
|
await configureReservesByHelper(reservesParams, protoPoolReservesAddresses, testHelpers, admin);
|
||||||
reservesParams,
|
|
||||||
protoPoolReservesAddresses,
|
|
||||||
testHelpers,
|
|
||||||
admin
|
|
||||||
);
|
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import { task } from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import {
|
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
||||||
getEthersSignersAddresses,
|
|
||||||
insertContractAddressInDb,
|
|
||||||
} from '../../helpers/contracts-helpers';
|
|
||||||
import {
|
import {
|
||||||
deployATokensAndRatesHelper,
|
deployATokensAndRatesHelper,
|
||||||
deployLendingPool,
|
deployLendingPool,
|
||||||
|
|
|
@ -6,13 +6,15 @@ import {
|
||||||
deployAaveProtocolDataProvider,
|
deployAaveProtocolDataProvider,
|
||||||
deployWETHGateway,
|
deployWETHGateway,
|
||||||
} from '../../helpers/contracts-deployments';
|
} 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 { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
|
||||||
import { waitForTx } from '../../helpers/misc-utils';
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
import {
|
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||||
initReservesByHelper,
|
|
||||||
configureReservesByHelper,
|
|
||||||
} from '../../helpers/init-helpers';
|
|
||||||
import { exit } from 'process';
|
import { exit } from 'process';
|
||||||
import {
|
import {
|
||||||
getAaveProtocolDataProvider,
|
getAaveProtocolDataProvider,
|
||||||
|
@ -43,7 +45,14 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
|
|
||||||
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
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);
|
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { task } from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import { checkVerification } from '../../helpers/etherscan-verification';
|
import { checkVerification } from '../../helpers/etherscan-verification';
|
||||||
import { ConfigNames } from '../../helpers/configuration';
|
import { ConfigNames } from '../../helpers/configuration';
|
||||||
import { EthereumNetworkNames } from '../../helpers/types';
|
|
||||||
import { printContracts } from '../../helpers/misc-utils';
|
import { printContracts } from '../../helpers/misc-utils';
|
||||||
import { usingTenderly } from '../../helpers/tenderly-utils';
|
import { usingTenderly } from '../../helpers/tenderly-utils';
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
|
||||||
it('Freezes the ETH reserve', async () => {
|
it('Freezes the ETH reserve', async () => {
|
||||||
const { configurator, weth, helpersContract } = testEnv;
|
const { configurator, weth, helpersContract } = testEnv;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await configurator.freezeReserve(weth.address);
|
await configurator.freezeReserve(weth.address);
|
||||||
const {
|
const {
|
||||||
decimals,
|
decimals,
|
||||||
|
|
|
@ -268,7 +268,6 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
const reserveDataAfter = helpersContract.getReserveData(usdc.address);
|
const reserveDataAfter = helpersContract.getReserveData(usdc.address);
|
||||||
|
|
||||||
|
|
||||||
const reserveData = await helpersContract.getReserveData(usdc.address);
|
const reserveData = await helpersContract.getReserveData(usdc.address);
|
||||||
const userData = await helpersContract.getUserReserveData(usdc.address, depositor.address);
|
const userData = await helpersContract.getUserReserveData(usdc.address, depositor.address);
|
||||||
|
|
||||||
|
@ -406,7 +405,9 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||||
'0'
|
'0'
|
||||||
);
|
);
|
||||||
|
|
||||||
const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address);
|
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||||
|
weth.address
|
||||||
|
);
|
||||||
|
|
||||||
const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);
|
const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);
|
||||||
|
|
||||||
|
@ -480,7 +481,9 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => {
|
||||||
'0'
|
'0'
|
||||||
);
|
);
|
||||||
|
|
||||||
const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address);
|
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||||
|
weth.address
|
||||||
|
);
|
||||||
|
|
||||||
const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);
|
const wethDebtToken = await getStableDebtToken(stableDebtTokenAddress);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
import BigNumber from 'bignumber.js';
|
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' {
|
declare module 'bignumber.js' {
|
||||||
interface BigNumber {
|
interface BigNumber {
|
||||||
|
@ -68,19 +76,22 @@ BigNumber.prototype.wadToRay = function (): BigNumber {
|
||||||
return this.multipliedBy(WAD_RAY_RATIO).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
return this.multipliedBy(WAD_RAY_RATIO).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BigNumber.prototype.halfPercentage = (): BigNumber => {
|
BigNumber.prototype.halfPercentage = (): BigNumber => {
|
||||||
return new BigNumber(HALF_PERCENTAGE).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
return new BigNumber(HALF_PERCENTAGE).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||||
};
|
};
|
||||||
|
|
||||||
BigNumber.prototype.percentMul = function (b: BigNumber): BigNumber {
|
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 {
|
BigNumber.prototype.percentDiv = function (a: BigNumber): BigNumber {
|
||||||
const halfA = a.div(2).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
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);
|
||||||
};
|
};
|
|
@ -30,10 +30,7 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
addressesProvider.setAddress(
|
addressesProvider.setAddress(utils.keccak256(utils.toUtf8Bytes('RANDOM_ID')), mockAddress)
|
||||||
utils.keccak256(utils.toUtf8Bytes('RANDOM_ID')),
|
|
||||||
mockAddress
|
|
||||||
)
|
|
||||||
).to.be.revertedWith(INVALID_OWNER_REVERT_MSG);
|
).to.be.revertedWith(INVALID_OWNER_REVERT_MSG);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
|
@ -42,7 +39,6 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
|
||||||
mockAddress
|
mockAddress
|
||||||
)
|
)
|
||||||
).to.be.revertedWith(INVALID_OWNER_REVERT_MSG);
|
).to.be.revertedWith(INVALID_OWNER_REVERT_MSG);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Tests adding a proxied address with `setAddressAsProxy()`', async () => {
|
it('Tests adding a proxied address with `setAddressAsProxy()`', async () => {
|
||||||
|
@ -51,7 +47,6 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
const currentAddressesProviderOwner = users[1];
|
const currentAddressesProviderOwner = users[1];
|
||||||
|
|
||||||
|
|
||||||
const mockLendingPool = await deployLendingPool();
|
const mockLendingPool = await deployLendingPool();
|
||||||
const proxiedAddressId = utils.keccak256(utils.toUtf8Bytes('RANDOM_PROXIED'));
|
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);
|
expect(proxiedAddressSetReceipt.events[1].args?.hasProxy).to.be.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Tests adding a non proxied address with `setAddress()`', async () => {
|
it('Tests adding a non proxied address with `setAddress()`', async () => {
|
||||||
const { addressesProvider, users } = testEnv;
|
const { addressesProvider, users } = testEnv;
|
||||||
const { INVALID_OWNER_REVERT_MSG } = ProtocolErrors;
|
const { INVALID_OWNER_REVERT_MSG } = ProtocolErrors;
|
||||||
|
@ -103,6 +97,5 @@ makeSuite('LendingPoolAddressesProvider', (testEnv: TestEnv) => {
|
||||||
mockNonProxiedAddress
|
mockNonProxiedAddress
|
||||||
);
|
);
|
||||||
expect(nonProxiedAddressSetReceipt.events[0].args?.hasProxy).to.be.equal(false);
|
expect(nonProxiedAddressSetReceipt.events[0].args?.hasProxy).to.be.equal(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -99,7 +99,7 @@ makeSuite('Mainnet Check list', (testEnv: TestEnv) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Borrow stable WETH and Full Repay with ETH', async () => {
|
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 borrowSize = parseEther('1');
|
||||||
const repaySize = borrowSize.add(borrowSize.mul(5).div(100));
|
const repaySize = borrowSize.add(borrowSize.mul(5).div(100));
|
||||||
const user = users[1];
|
const user = users[1];
|
||||||
|
|
|
@ -119,7 +119,9 @@ makeSuite('Upgradeability', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
await configurator.updateVariableDebtToken(dai.address, newVariableTokenAddress);
|
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);
|
const debtToken = await getMockVariableDebtToken(variableDebtTokenAddress);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
const depositSize = parseEther('5');
|
const depositSize = parseEther('5');
|
||||||
const daiSize = parseEther('10000');
|
const daiSize = parseEther('10000');
|
||||||
it('Deposit WETH via WethGateway and DAI', async () => {
|
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 user = users[1];
|
||||||
const depositor = users[0];
|
const depositor = users[0];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user