mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Lint files. Add all ts and sol files to pre-commit. Add prettier format check to CI.
This commit is contained in:
parent
89db02e79c
commit
6a503eb0a8
|
|
@ -1,17 +1,17 @@
|
|||
stages:
|
||||
- checks
|
||||
|
||||
include:
|
||||
- project: 'guided-explorations/ci-cd-plugin-extensions/ci-cd-plugin-extension-github-action-super-linter'
|
||||
file: '/ci-cd-plugin-extension-github-action-super-linter-gitlab-ci.yml'
|
||||
ref: v0.1.4
|
||||
|
||||
linter:
|
||||
extends: .ci-cd-plugin-extension-github-action-super-linter
|
||||
stage: checks
|
||||
only:
|
||||
- master
|
||||
- merge_requests
|
||||
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 prettier:lint
|
||||
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
|
||||
|
|
|
|||
|
|
@ -208,19 +208,22 @@ contract UniswapLiquiditySwapAdapter is BaseUniswapAdapter {
|
|||
PermitSignature memory permitSignature,
|
||||
bool useEthPath
|
||||
) internal {
|
||||
|
||||
SwapLiquidityLocalVars memory vars;
|
||||
|
||||
vars.aToken = _getReserveData(assetFrom).aTokenAddress;
|
||||
|
||||
vars.aTokenInitiatorBalance = IERC20(vars.aToken).balanceOf(initiator);
|
||||
vars.amountToSwap =
|
||||
swapAllBalance && vars.aTokenInitiatorBalance.sub(premium) <= amount
|
||||
vars.amountToSwap = swapAllBalance && vars.aTokenInitiatorBalance.sub(premium) <= amount
|
||||
? vars.aTokenInitiatorBalance.sub(premium)
|
||||
: amount;
|
||||
|
||||
vars.receivedAmount =
|
||||
_swapExactTokensForTokens(assetFrom, assetTo, vars.amountToSwap, minAmountToReceive, useEthPath);
|
||||
vars.receivedAmount = _swapExactTokensForTokens(
|
||||
assetFrom,
|
||||
assetTo,
|
||||
vars.amountToSwap,
|
||||
minAmountToReceive,
|
||||
useEthPath
|
||||
);
|
||||
|
||||
// Deposit new reserve
|
||||
IERC20(assetTo).safeApprove(address(LENDING_POOL), 0);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,13 @@ contract UniswapRepayAdapter is BaseUniswapAdapter {
|
|||
);
|
||||
|
||||
// Swap collateral asset to the debt asset
|
||||
_swapTokensForExactTokens(collateralAsset, debtAsset, amounts[0], neededForFlashLoanDebt, useEthPath);
|
||||
_swapTokensForExactTokens(
|
||||
collateralAsset,
|
||||
debtAsset,
|
||||
amounts[0],
|
||||
neededForFlashLoanDebt,
|
||||
useEthPath
|
||||
);
|
||||
} else {
|
||||
// Pull aTokens from user
|
||||
_pullAToken(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,20 @@ interface IUniswapV2Router02 {
|
|||
) external returns (uint256[] memory amounts);
|
||||
|
||||
function swapTokensForExactTokens(
|
||||
uint amountOut,
|
||||
uint amountInMax,
|
||||
uint256 amountOut,
|
||||
uint256 amountInMax,
|
||||
address[] calldata path,
|
||||
address to,
|
||||
uint deadline
|
||||
uint256 deadline
|
||||
) external returns (uint256[] memory amounts);
|
||||
|
||||
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
|
||||
function getAmountsOut(uint256 amountIn, address[] calldata path)
|
||||
external
|
||||
view
|
||||
returns (uint256[] memory amounts);
|
||||
|
||||
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
|
||||
function getAmountsIn(uint256 amountOut, address[] calldata path)
|
||||
external
|
||||
view
|
||||
returns (uint256[] memory amounts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
4762
package-lock.json
generated
4762
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -39,6 +39,7 @@
|
|||
"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",
|
||||
"prettier:lint": "npx prettier -c 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts' 'test/**/*.ts'",
|
||||
"dev:prettier": "prettier --write .",
|
||||
"ci:test": "npm run compile && npm run test",
|
||||
"ci:clean": "rm -rf ./artifacts ./cache ./types",
|
||||
|
|
@ -113,7 +114,7 @@
|
|||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
"pre-commit": "pretty-quick --pattern 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts' 'test/**/*.ts'"
|
||||
}
|
||||
},
|
||||
"author": "Aave",
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1211,7 +1211,6 @@ export const calcExpectedInterestRates = (
|
|||
): BigNumber[] => {
|
||||
const { reservesParams } = configuration;
|
||||
|
||||
|
||||
const reserveIndex = Object.keys(reservesParams).findIndex((value) => value === reserveSymbol);
|
||||
const [, reserveConfiguration] = (Object.entries(reservesParams) as [string, IReserveParams][])[
|
||||
reserveIndex
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@ makeSuite('Mainnet Check list', (testEnv: TestEnv) => {
|
|||
const repaySize = borrowSize.add(borrowSize.mul(5).div(100));
|
||||
const user = users[1];
|
||||
|
||||
const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address);
|
||||
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||
weth.address
|
||||
);
|
||||
|
||||
const stableDebtToken = await getStableDebtToken(stableDebtTokenAddress);
|
||||
|
||||
|
|
@ -345,7 +347,7 @@ makeSuite('Mainnet Check list', (testEnv: TestEnv) => {
|
|||
const userBalanceAfterCall = await user.signer.getBalance();
|
||||
|
||||
expect(userBalanceAfterCall).to.be.eq(userBalancePriorCall.sub(amount).sub(gasFees), '');
|
||||
'User should have lost the funds';
|
||||
('User should have lost the funds');
|
||||
|
||||
// Recover the funds from the contract and sends back to the user
|
||||
await wethGateway.connect(deployer.signer).emergencyEtherTransfer(user.address, amount);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
const repaySize = borrowSize.add(borrowSize.mul(5).div(100));
|
||||
const user = users[1];
|
||||
|
||||
const {stableDebtTokenAddress} = await helpersContract.getReserveTokensAddresses(weth.address);
|
||||
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||
weth.address
|
||||
);
|
||||
|
||||
const stableDebtToken = await getStableDebtToken(stableDebtTokenAddress);
|
||||
|
||||
|
|
@ -333,7 +335,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
const userBalanceAfterCall = await user.signer.getBalance();
|
||||
|
||||
expect(userBalanceAfterCall).to.be.eq(userBalancePriorCall.sub(amount).sub(gasFees), '');
|
||||
'User should have lost the funds';
|
||||
('User should have lost the funds');
|
||||
|
||||
// Recover the funds from the contract and sends back to the user
|
||||
await wethGateway.connect(deployer.signer).emergencyEtherTransfer(user.address, amount);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user