From 6f066015340d9069851da5ff1b40e9165444bf27 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Mon, 14 Aug 2023 16:03:44 -0600 Subject: [PATCH] fix: lint --- src/Depositer.sol | 47 +++++------- src/Strategy.sol | 54 ++++++-------- src/TokenizedCompV3LenderBorrowerFactory.sol | 6 +- src/interfaces/Compound/V3/CompoundV3.sol | 77 ++++++++------------ src/periphery/StrategyAprOracle.sol | 10 +-- src/test/Operation.t.sol | 7 +- src/test/utils/Setup.sol | 6 +- 7 files changed, 83 insertions(+), 124 deletions(-) diff --git a/src/Depositer.sol b/src/Depositer.sol index 880b630..be8b1b8 100644 --- a/src/Depositer.sol +++ b/src/Depositer.sol @@ -61,10 +61,9 @@ contract Depositer { event Cloned(address indexed clone); - function cloneDepositer(address _comet) - external - returns (address newDepositer) - { + function cloneDepositer( + address _comet + ) external returns (address newDepositer) { require(original, "!original"); newDepositer = _clone(_comet); } @@ -203,11 +202,9 @@ contract Depositer { return accrued > claimed ? accrued - claimed : 0; } - function getNetBorrowApr(uint256 newAmount) - public - view - returns (uint256 netApr) - { + function getNetBorrowApr( + uint256 newAmount + ) public view returns (uint256 netApr) { uint256 newUtilization = ((comet.totalBorrow() + newAmount) * 1e18) / (comet.totalSupply() + newAmount); uint256 borrowApr = getBorrowApr(newUtilization); @@ -219,11 +216,9 @@ contract Depositer { /* * Get the current supply APR in Compound III */ - function getSupplyApr(uint256 newUtilization) - public - view - returns (uint256) - { + function getSupplyApr( + uint256 newUtilization + ) public view returns (uint256) { unchecked { return comet.getSupplyRate( @@ -235,11 +230,9 @@ contract Depositer { /* * Get the current borrow APR in Compound III */ - function getBorrowApr(uint256 newUtilization) - public - view - returns (uint256) - { + function getBorrowApr( + uint256 newUtilization + ) public view returns (uint256) { unchecked { return comet.getBorrowRate( @@ -261,11 +254,9 @@ contract Depositer { * @param newAmount The new amount we will be supplying * @return The reward APR in USD as a decimal scaled up by 1e18 */ - function getRewardAprForSupplyBase(uint256 newAmount) - public - view - returns (uint256) - { + function getRewardAprForSupplyBase( + uint256 newAmount + ) public view returns (uint256) { Comet _comet = comet; unchecked { uint256 rewardToSuppliersPerDay = _comet.baseTrackingSupplySpeed() * @@ -285,11 +276,9 @@ contract Depositer { * @param newAmount The new amount we will be borrowing * @return The reward APR in USD as a decimal scaled up by 1e18 */ - function getRewardAprForBorrowBase(uint256 newAmount) - public - view - returns (uint256) - { + function getRewardAprForBorrowBase( + uint256 newAmount + ) public view returns (uint256) { // borrowBaseRewardApr = (rewardTokenPriceInUsd * rewardToBorrowersPerDay / (baseTokenTotalBorrow * baseTokenPriceInUsd)) * DAYS_PER_YEAR; Comet _comet = comet; unchecked { diff --git a/src/Strategy.sol b/src/Strategy.sol index 5177cb6..c0aa97a 100644 --- a/src/Strategy.sol +++ b/src/Strategy.sol @@ -123,10 +123,10 @@ contract Strategy is BaseTokenizedStrategy, UniswapV3Swapper { maxGasPriceToTend = _maxGasPriceToTend; } - function setPriceFeed(address token, address priceFeed) - external - onlyManagement - { + function setPriceFeed( + address token, + address priceFeed + ) external onlyManagement { // just check it doesnt revert comet.getPrice(priceFeed); priceFeeds[token] = priceFeed; @@ -531,11 +531,9 @@ contract Strategy is BaseTokenizedStrategy, UniswapV3Swapper { } } - function _calculateAmountToRepay(uint256 amount) - internal - view - returns (uint256) - { + function _calculateAmountToRepay( + uint256 amount + ) internal view returns (uint256) { if (amount == 0) return 0; uint256 collateral = balanceOfCollateral(); // to unlock all collateral we must repay all the debt @@ -554,30 +552,28 @@ contract Strategy is BaseTokenizedStrategy, UniswapV3Swapper { // ----------------- INTERNAL CALCS ----------------- // Returns the _amount of _token in terms of USD, i.e 1e8 - function _toUsd(uint256 _amount, address _token) - internal - view - returns (uint256) - { + function _toUsd( + uint256 _amount, + address _token + ) internal view returns (uint256) { if (_amount == 0) return _amount; // usd price is returned as 1e8 unchecked { return (_amount * getCompoundPrice(_token)) / - (10**ERC20(_token).decimals()); + (10 ** ERC20(_token).decimals()); } } // Returns the _amount of usd (1e8) in terms of _token - function _fromUsd(uint256 _amount, address _token) - internal - view - returns (uint256) - { + function _fromUsd( + uint256 _amount, + address _token + ) internal view returns (uint256) { if (_amount == 0) return _amount; unchecked { return - (_amount * (10**ERC20(_token).decimals())) / + (_amount * (10 ** ERC20(_token).decimals())) / getCompoundPrice(_token); } } @@ -653,11 +649,9 @@ contract Strategy is BaseTokenizedStrategy, UniswapV3Swapper { /* * Get the price feed address for an asset */ - function getPriceFeedAddress(address _asset) - internal - view - returns (address priceFeed) - { + function getPriceFeedAddress( + address _asset + ) internal view returns (address priceFeed) { priceFeed = priceFeeds[_asset]; if (priceFeed == address(0)) { priceFeed = comet.getAssetInfoByAddress(_asset).priceFeed; @@ -667,11 +661,9 @@ contract Strategy is BaseTokenizedStrategy, UniswapV3Swapper { /* * Get the current price of an _asset from the protocol's persepctive */ - function getCompoundPrice(address _asset) - internal - view - returns (uint256 price) - { + function getCompoundPrice( + address _asset + ) internal view returns (uint256 price) { price = comet.getPrice(getPriceFeedAddress(_asset)); // If weth is base token we need to scale response to e18 if (price == 1e8 && _asset == base) price = 1e18; diff --git a/src/TokenizedCompV3LenderBorrowerFactory.sol b/src/TokenizedCompV3LenderBorrowerFactory.sol index 0744719..36d820b 100644 --- a/src/TokenizedCompV3LenderBorrowerFactory.sol +++ b/src/TokenizedCompV3LenderBorrowerFactory.sol @@ -13,11 +13,7 @@ contract TokenizedCompV3LenderBorrowerFactory { event Deployed(address indexed depositer, address indexed strategy); - constructor( - address _managment, - address _rewards, - address _keeper - ) { + constructor(address _managment, address _rewards, address _keeper) { managment = _managment; rewards = _rewards; keeper = _keeper; diff --git a/src/interfaces/Compound/V3/CompoundV3.sol b/src/interfaces/Compound/V3/CompoundV3.sol index 8352a07..694ef6c 100644 --- a/src/interfaces/Compound/V3/CompoundV3.sol +++ b/src/interfaces/Compound/V3/CompoundV3.sol @@ -62,11 +62,7 @@ interface Comet is IERC20 { function supply(address asset, uint256 amount) external; - function supplyTo( - address to, - address asset, - uint256 amount - ) external; + function supplyTo(address to, address asset, uint256 amount) external; function withdraw(address asset, uint256 amount) external; @@ -74,34 +70,31 @@ interface Comet is IERC20 { function getBorrowRate(uint256 utilization) external view returns (uint256); - function getAssetInfoByAddress(address asset) - external - view - returns (CometStructs.AssetInfo memory); + function getAssetInfoByAddress( + address asset + ) external view returns (CometStructs.AssetInfo memory); - function getAssetInfo(uint8 i) - external - view - returns (CometStructs.AssetInfo memory); + function getAssetInfo( + uint8 i + ) external view returns (CometStructs.AssetInfo memory); function borrowBalanceOf(address account) external view returns (uint256); function getPrice(address priceFeed) external view returns (uint128); - function userBasic(address) - external - view - returns (CometStructs.UserBasic memory); + function userBasic( + address + ) external view returns (CometStructs.UserBasic memory); function totalsBasic() external view returns (CometStructs.TotalsBasic memory); - function userCollateral(address, address) - external - view - returns (CometStructs.UserCollateral memory); + function userCollateral( + address, + address + ) external view returns (CometStructs.UserCollateral memory); function baseTokenPriceFeed() external view returns (address); @@ -119,15 +112,13 @@ interface Comet is IERC20 { function baseIndexScale() external pure returns (uint64); - function baseTrackingAccrued(address account) - external - view - returns (uint64); + function baseTrackingAccrued( + address account + ) external view returns (uint64); - function totalsCollateral(address asset) - external - view - returns (CometStructs.TotalsCollateral memory); + function totalsCollateral( + address asset + ) external view returns (CometStructs.TotalsCollateral memory); function baseMinForRewards() external view returns (uint256); @@ -141,23 +132,19 @@ interface Comet is IERC20 { } interface CometRewards { - function getRewardOwed(address comet, address account) - external - returns (CometStructs.RewardOwed memory); - - function claim( + function getRewardOwed( address comet, - address src, - bool shouldAccrue - ) external; + address account + ) external returns (CometStructs.RewardOwed memory); - function rewardsClaimed(address comet, address account) - external - view - returns (uint256); + function claim(address comet, address src, bool shouldAccrue) external; - function rewardConfig(address comet) - external - view - returns (CometStructs.RewardConfig memory); + function rewardsClaimed( + address comet, + address account + ) external view returns (uint256); + + function rewardConfig( + address comet + ) external view returns (CometStructs.RewardConfig memory); } diff --git a/src/periphery/StrategyAprOracle.sol b/src/periphery/StrategyAprOracle.sol index 1c23851..87c5337 100644 --- a/src/periphery/StrategyAprOracle.sol +++ b/src/periphery/StrategyAprOracle.sol @@ -25,12 +25,10 @@ contract StrategyAprOracle is AprOracleBase { * @param _delta The difference in debt. * @return . The expected apr for the strategy represented as 1e18. */ - function aprAfterDebtChange(address _strategy, int256 _delta) - external - view - override - returns (uint256) - { + function aprAfterDebtChange( + address _strategy, + int256 _delta + ) external view override returns (uint256) { // TODO: Implement any necessary logic to return the most accurate // APR estimation for the strategy. return 1e17; diff --git a/src/test/Operation.t.sol b/src/test/Operation.t.sol index 378320a..453c318 100644 --- a/src/test/Operation.t.sol +++ b/src/test/Operation.t.sol @@ -53,9 +53,10 @@ contract OperationTest is Setup { ); } - function test_profitableReport(uint256 _amount, uint16 _profitFactor) - public - { + function test_profitableReport( + uint256 _amount, + uint16 _profitFactor + ) public { vm.assume(_amount > minFuzzAmount && _amount < maxFuzzAmount); _profitFactor = uint16(bound(uint256(_profitFactor), 10, MAX_BPS)); diff --git a/src/test/utils/Setup.sol b/src/test/utils/Setup.sol index 7f43c25..82de011 100644 --- a/src/test/utils/Setup.sol +++ b/src/test/utils/Setup.sol @@ -141,11 +141,7 @@ contract Setup is ExtendedTest, IEvents { assertEq(_totalAssets, _totalDebt + _totalIdle, "!Added"); } - function airdrop( - ERC20 _asset, - address _to, - uint256 _amount - ) public { + function airdrop(ERC20 _asset, address _to, uint256 _amount) public { uint256 balanceBefore = _asset.balanceOf(_to); deal(address(_asset), _to, balanceBefore + _amount); }