Skip to content

Commit

Permalink
lint: align linting with aave v3 core (#179)
Browse files Browse the repository at this point in the history
* refactor: align linting with core

* rebase: rebase

* fix: revert changelog changes

* fix: revert properly 😓
  • Loading branch information
sakulstra authored Aug 8, 2023
1 parent 9050820 commit 8f3380d
Show file tree
Hide file tree
Showing 43 changed files with 297 additions and 518 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"plugin:prettier/recommended"
],
"rules": {}
}
}
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"singleQuote": true,
"tabWidth": 2,
"overrides": [
{
"files": "*.ts",
"options": {
"bracketSpacing": true
}
},
{
"files": "*.sol",
"options": {
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM ethereum/solc:0.7.6 as build-deps

FROM node:14
FROM node:16

USER node

COPY --from=build-deps /usr/bin/solc /usr/bin/solc
4 changes: 3 additions & 1 deletion contracts/adapters/paraswap/BaseParaSwapAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ abstract contract BaseParaSwapAdapter is FlashLoanSimpleReceiverBase, Ownable {
uint256 receivedAmount
);

constructor(IPoolAddressesProvider addressesProvider) FlashLoanSimpleReceiverBase(addressesProvider) {
constructor(
IPoolAddressesProvider addressesProvider
) FlashLoanSimpleReceiverBase(addressesProvider) {
ORACLE = IPriceOracleGetter(addressesProvider.getPriceOracle());
}

Expand Down
11 changes: 6 additions & 5 deletions contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ abstract contract BaseParaSwapBuyAdapter is BaseParaSwapAdapter {

IParaSwapAugustusRegistry public immutable AUGUSTUS_REGISTRY;

constructor(IPoolAddressesProvider addressesProvider, IParaSwapAugustusRegistry augustusRegistry)
BaseParaSwapAdapter(addressesProvider)
{
constructor(
IPoolAddressesProvider addressesProvider,
IParaSwapAugustusRegistry augustusRegistry
) BaseParaSwapAdapter(addressesProvider) {
// Do something on Augustus registry to check the right contract was passed
require(!augustusRegistry.isValidAugustus(address(0)), 'Not a valid Augustus address');
AUGUSTUS_REGISTRY = augustusRegistry;
Expand Down Expand Up @@ -62,8 +63,8 @@ abstract contract BaseParaSwapBuyAdapter is BaseParaSwapAdapter {
uint256 toAssetPrice = _getPrice(address(assetToSwapTo));

uint256 expectedMaxAmountToSwap = amountToReceive
.mul(toAssetPrice.mul(10**fromAssetDecimals))
.div(fromAssetPrice.mul(10**toAssetDecimals))
.mul(toAssetPrice.mul(10 ** fromAssetDecimals))
.div(fromAssetPrice.mul(10 ** toAssetDecimals))
.percentMul(PercentageMath.PERCENTAGE_FACTOR.add(MAX_SLIPPAGE_PERCENT));

require(maxAmountToSwap <= expectedMaxAmountToSwap, 'maxAmountToSwap exceed max slippage');
Expand Down
11 changes: 6 additions & 5 deletions contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ abstract contract BaseParaSwapSellAdapter is BaseParaSwapAdapter {

IParaSwapAugustusRegistry public immutable AUGUSTUS_REGISTRY;

constructor(IPoolAddressesProvider addressesProvider, IParaSwapAugustusRegistry augustusRegistry)
BaseParaSwapAdapter(addressesProvider)
{
constructor(
IPoolAddressesProvider addressesProvider,
IParaSwapAugustusRegistry augustusRegistry
) BaseParaSwapAdapter(addressesProvider) {
// Do something on Augustus registry to check the right contract was passed
require(!augustusRegistry.isValidAugustus(address(0)));
AUGUSTUS_REGISTRY = augustusRegistry;
Expand Down Expand Up @@ -60,8 +61,8 @@ abstract contract BaseParaSwapSellAdapter is BaseParaSwapAdapter {
uint256 toAssetPrice = _getPrice(address(assetToSwapTo));

uint256 expectedMinAmountOut = amountToSwap
.mul(fromAssetPrice.mul(10**toAssetDecimals))
.div(toAssetPrice.mul(10**fromAssetDecimals))
.mul(fromAssetPrice.mul(10 ** toAssetDecimals))
.div(toAssetPrice.mul(10 ** fromAssetDecimals))
.percentMul(PercentageMath.PERCENTAGE_FACTOR - MAX_SLIPPAGE_PERCENT);

require(expectedMinAmountOut <= minAmountToReceive, 'MIN_AMOUNT_EXCEEDS_MAX_SLIPPAGE');
Expand Down
9 changes: 4 additions & 5 deletions contracts/libraries/DataTypesHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ library DataTypesHelper {
* @return The stable debt balance
* @return The variable debt balance
**/
function getUserCurrentDebt(address user, DataTypes.ReserveData memory reserve)
internal
view
returns (uint256, uint256)
{
function getUserCurrentDebt(
address user,
DataTypes.ReserveData memory reserve
) internal view returns (uint256, uint256) {
return (
IERC20(reserve.stableDebtTokenAddress).balanceOf(user),
IERC20(reserve.variableDebtTokenAddress).balanceOf(user)
Expand Down
41 changes: 18 additions & 23 deletions contracts/misc/UiIncentiveDataProviderV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {IUiIncentiveDataProviderV3} from './interfaces/IUiIncentiveDataProviderV
contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 {
using UserConfiguration for DataTypes.UserConfigurationMap;

function getFullReservesIncentiveData(IPoolAddressesProvider provider, address user)
function getFullReservesIncentiveData(
IPoolAddressesProvider provider,
address user
)
external
view
override
Expand All @@ -23,20 +26,15 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 {
return (_getReservesIncentivesData(provider), _getUserReservesIncentivesData(provider, user));
}

function getReservesIncentivesData(IPoolAddressesProvider provider)
external
view
override
returns (AggregatedReserveIncentiveData[] memory)
{
function getReservesIncentivesData(
IPoolAddressesProvider provider
) external view override returns (AggregatedReserveIncentiveData[] memory) {
return _getReservesIncentivesData(provider);
}

function _getReservesIncentivesData(IPoolAddressesProvider provider)
private
view
returns (AggregatedReserveIncentiveData[] memory)
{
function _getReservesIncentivesData(
IPoolAddressesProvider provider
) private view returns (AggregatedReserveIncentiveData[] memory) {
IPool pool = IPool(provider.getPool());
address[] memory reserves = pool.getReservesList();
AggregatedReserveIncentiveData[]
Expand Down Expand Up @@ -216,20 +214,17 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 {
return (reservesIncentiveData);
}

function getUserReservesIncentivesData(IPoolAddressesProvider provider, address user)
external
view
override
returns (UserReserveIncentiveData[] memory)
{
function getUserReservesIncentivesData(
IPoolAddressesProvider provider,
address user
) external view override returns (UserReserveIncentiveData[] memory) {
return _getUserReservesIncentivesData(provider, user);
}

function _getUserReservesIncentivesData(IPoolAddressesProvider provider, address user)
private
view
returns (UserReserveIncentiveData[] memory)
{
function _getUserReservesIncentivesData(
IPoolAddressesProvider provider,
address user
) private view returns (UserReserveIncentiveData[] memory) {
IPool pool = IPool(provider.getPool());
address[] memory reserves = pool.getReservesList();

Expand Down
32 changes: 11 additions & 21 deletions contracts/misc/UiPoolDataProviderV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,16 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
marketReferenceCurrencyPriceInUsdProxyAggregator = _marketReferenceCurrencyPriceInUsdProxyAggregator;
}

function getReservesList(IPoolAddressesProvider provider)
public
view
override
returns (address[] memory)
{
function getReservesList(
IPoolAddressesProvider provider
) public view override returns (address[] memory) {
IPool pool = IPool(provider.getPool());
return pool.getReservesList();
}

function getReservesData(IPoolAddressesProvider provider)
public
view
override
returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory)
{
function getReservesData(
IPoolAddressesProvider provider
) public view override returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory) {
IAaveOracle oracle = IAaveOracle(provider.getPriceOracle());
IPool pool = IPool(provider.getPool());
AaveProtocolDataProvider poolDataProvider = AaveProtocolDataProvider(
Expand Down Expand Up @@ -216,9 +210,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
try oracle.BASE_CURRENCY_UNIT() returns (uint256 baseCurrencyUnit) {
baseCurrencyInfo.marketReferenceCurrencyUnit = baseCurrencyUnit;
baseCurrencyInfo.marketReferenceCurrencyPriceInUsd = int256(baseCurrencyUnit);
} catch (
bytes memory /*lowLevelData*/
) {
} catch (bytes memory /*lowLevelData*/) {
baseCurrencyInfo.marketReferenceCurrencyUnit = ETH_CURRENCY_UNIT;
baseCurrencyInfo
.marketReferenceCurrencyPriceInUsd = marketReferenceCurrencyPriceInUsdProxyAggregator
Expand All @@ -228,12 +220,10 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 {
return (reservesData, baseCurrencyInfo);
}

function getUserReservesData(IPoolAddressesProvider provider, address user)
external
view
override
returns (UserReserveData[] memory, uint8)
{
function getUserReservesData(
IPoolAddressesProvider provider,
address user
) external view override returns (UserReserveData[] memory, uint8) {
IPool pool = IPool(provider.getPool());
address[] memory reserves = pool.getReservesList();
DataTypes.UserConfigurationMap memory userConfig = pool.getUserConfiguration(user);
Expand Down
18 changes: 8 additions & 10 deletions contracts/misc/WalletBalanceProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ contract WalletBalanceProvider {
* @param tokens The list of tokens
* @return And array with the concatenation of, for each user, his/her balances
**/
function batchBalanceOf(address[] calldata users, address[] calldata tokens)
external
view
returns (uint256[] memory)
{
function batchBalanceOf(
address[] calldata users,
address[] calldata tokens
) external view returns (uint256[] memory) {
uint256[] memory balances = new uint256[](users.length * tokens.length);

for (uint256 i = 0; i < users.length; i++) {
Expand All @@ -74,11 +73,10 @@ contract WalletBalanceProvider {
/**
@dev provides balances of user wallet for all reserves available on the pool
*/
function getUserWalletBalances(address provider, address user)
external
view
returns (address[] memory, uint256[] memory)
{
function getUserWalletBalances(
address provider,
address user
) external view returns (address[] memory, uint256[] memory) {
IPool pool = IPool(IPoolAddressesProvider(provider).getPool());

address[] memory reserves = pool.getReservesList();
Expand Down
24 changes: 4 additions & 20 deletions contracts/misc/WrappedTokenGatewayV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable {
* @param weth Address of the Wrapped Ether contract
* @param owner Address of the owner of this contract
**/
constructor(
address weth,
address owner,
IPool pool
) {
constructor(address weth, address owner, IPool pool) {
WETH = IWETH(weth);
POOL = pool;
transferOwnership(owner);
Expand All @@ -47,11 +43,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable {
* @param onBehalfOf address of the user who will receive the aTokens representing the deposit
* @param referralCode integrators are assigned a referral code and can potentially receive rewards.
**/
function depositETH(
address,
address onBehalfOf,
uint16 referralCode
) external payable override {
function depositETH(address, address onBehalfOf, uint16 referralCode) external payable override {
WETH.deposit{value: msg.value}();
POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode);
}
Expand All @@ -61,11 +53,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable {
* @param amount amount of aWETH to withdraw and receive native ETH
* @param to address of the user who will receive native ETH
*/
function withdrawETH(
address,
uint256 amount,
address to
) external override {
function withdrawETH(address, uint256 amount, address to) external override {
IAToken aWETH = IAToken(POOL.getReserveData(address(WETH)).aTokenAddress);
uint256 userBalance = aWETH.balanceOf(msg.sender);
uint256 amountToWithdraw = amount;
Expand Down Expand Up @@ -181,11 +169,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable {
* @param to recipient of the transfer
* @param amount amount to send
*/
function emergencyTokenTransfer(
address token,
address to,
uint256 amount
) external onlyOwner {
function emergencyTokenTransfer(address token, address to, uint256 amount) external onlyOwner {
IERC20(token).safeTransfer(to, amount);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/misc/interfaces/IERC20DetailedBytes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface IERC20DetailedBytes is IERC20 {
function symbol() external view returns (bytes32);

function decimals() external view returns (uint8);
}
}
20 changes: 11 additions & 9 deletions contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ interface IUiIncentiveDataProviderV3 {
uint8 rewardTokenDecimals;
}

function getReservesIncentivesData(IPoolAddressesProvider provider)
external
view
returns (AggregatedReserveIncentiveData[] memory);
function getReservesIncentivesData(
IPoolAddressesProvider provider
) external view returns (AggregatedReserveIncentiveData[] memory);

function getUserReservesIncentivesData(IPoolAddressesProvider provider, address user)
external
view
returns (UserReserveIncentiveData[] memory);
function getUserReservesIncentivesData(
IPoolAddressesProvider provider,
address user
) external view returns (UserReserveIncentiveData[] memory);

// generic method with full data
function getFullReservesIncentiveData(IPoolAddressesProvider provider, address user)
function getFullReservesIncentiveData(
IPoolAddressesProvider provider,
address user
)
external
view
returns (AggregatedReserveIncentiveData[] memory, UserReserveIncentiveData[] memory);
Expand Down
22 changes: 10 additions & 12 deletions contracts/misc/interfaces/IUiPoolDataProviderV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,16 @@ interface IUiPoolDataProviderV3 {
uint8 networkBaseTokenPriceDecimals;
}

function getReservesList(IPoolAddressesProvider provider)
external
view
returns (address[] memory);
function getReservesList(
IPoolAddressesProvider provider
) external view returns (address[] memory);

function getReservesData(IPoolAddressesProvider provider)
external
view
returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory);
function getReservesData(
IPoolAddressesProvider provider
) external view returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory);

function getUserReservesData(IPoolAddressesProvider provider, address user)
external
view
returns (UserReserveData[] memory, uint8);
function getUserReservesData(
IPoolAddressesProvider provider,
address user
) external view returns (UserReserveData[] memory, uint8);
}
6 changes: 1 addition & 5 deletions contracts/misc/interfaces/IWETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,5 @@ interface IWETH {

function approve(address guy, uint256 wad) external returns (bool);

function transferFrom(
address src,
address dst,
uint256 wad
) external returns (bool);
function transferFrom(address src, address dst, uint256 wad) external returns (bool);
}
Loading

0 comments on commit 8f3380d

Please sign in to comment.