Skip to content

Commit

Permalink
fix: lint and preconfiguredAddress decaration of Vtreasury wrong refe…
Browse files Browse the repository at this point in the history
…rence
  • Loading branch information
0xlucian committed Oct 11, 2023
1 parent 53ddd6b commit 3e5c717
Show file tree
Hide file tree
Showing 26 changed files with 508 additions and 138 deletions.
99 changes: 77 additions & 22 deletions contracts/Comptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ contract Comptroller is
* @custom:error SupplyCapExceeded error is thrown if the total supply exceeds the cap after minting
* @custom:access Not restricted
*/
function preMintHook(address vToken, address minter, uint256 mintAmount) external override {
function preMintHook(
address vToken,
address minter,
uint256 mintAmount
) external override {
_checkActionPauseState(vToken, Action.MINT);

if (!markets[vToken].isListed) {
Expand Down Expand Up @@ -309,7 +313,11 @@ contract Comptroller is
* @custom:error PriceError is thrown if the oracle returns an incorrect price for some asset
* @custom:access Not restricted
*/
function preRedeemHook(address vToken, address redeemer, uint256 redeemTokens) external override {
function preRedeemHook(
address vToken,
address redeemer,
uint256 redeemTokens
) external override {
_checkActionPauseState(vToken, Action.REDEEM);

_checkRedeemAllowed(vToken, redeemer, redeemTokens);
Expand Down Expand Up @@ -338,7 +346,11 @@ contract Comptroller is
* @custom:access Not restricted if vToken is enabled as collateral, otherwise only vToken
*/
/// disable-eslint
function preBorrowHook(address vToken, address borrower, uint256 borrowAmount) external override {
function preBorrowHook(
address vToken,
address borrower,
uint256 borrowAmount
) external override {
_checkActionPauseState(vToken, Action.BORROW);

if (!markets[vToken].isListed) {
Expand Down Expand Up @@ -562,7 +574,12 @@ contract Comptroller is
* @custom:error PriceError is thrown if the oracle returns an incorrect price for some asset
* @custom:access Not restricted
*/
function preTransferHook(address vToken, address src, address dst, uint256 transferTokens) external override {
function preTransferHook(
address vToken,
address src,
address dst,
uint256 transferTokens
) external override {
_checkActionPauseState(vToken, Action.TRANSFER);

// Currently the only consideration is whether or not
Expand Down Expand Up @@ -903,7 +920,11 @@ contract Comptroller is
* @param paused The new paused state (true=paused, false=unpaused)
* @custom:access Controlled by AccessControlManager
*/
function setActionsPaused(VToken[] calldata marketsList, Action[] calldata actionsList, bool paused) external {
function setActionsPaused(
VToken[] calldata marketsList,
Action[] calldata actionsList,
bool paused
) external {
_checkAccessAllowed("setActionsPaused(address[],uint256[],bool)");

uint256 marketsCount = marketsList.length;
Expand Down Expand Up @@ -991,9 +1012,15 @@ contract Comptroller is
* @return liquidity Account liquidity in excess of liquidation threshold requirements,
* @return shortfall Account shortfall below liquidation threshold requirements
*/
function getAccountLiquidity(
address account
) external view returns (uint256 error, uint256 liquidity, uint256 shortfall) {
function getAccountLiquidity(address account)
external
view
returns (
uint256 error,
uint256 liquidity,
uint256 shortfall
)
{
AccountLiquiditySnapshot memory snapshot = _getCurrentLiquiditySnapshot(account, _getLiquidationThreshold);
return (NO_ERROR, snapshot.liquidity, snapshot.shortfall);
}
Expand All @@ -1006,9 +1033,15 @@ contract Comptroller is
* @return liquidity Account liquidity in excess of collateral requirements,
* @return shortfall Account shortfall below collateral requirements
*/
function getBorrowingPower(
address account
) external view returns (uint256 error, uint256 liquidity, uint256 shortfall) {
function getBorrowingPower(address account)
external
view
returns (
uint256 error,
uint256 liquidity,
uint256 shortfall
)
{
AccountLiquiditySnapshot memory snapshot = _getCurrentLiquiditySnapshot(account, _getCollateralFactor);
return (NO_ERROR, snapshot.liquidity, snapshot.shortfall);
}
Expand All @@ -1029,7 +1062,15 @@ contract Comptroller is
address vTokenModify,
uint256 redeemTokens,
uint256 borrowAmount
) external view returns (uint256 error, uint256 liquidity, uint256 shortfall) {
)
external
view
returns (
uint256 error,
uint256 liquidity,
uint256 shortfall
)
{
AccountLiquiditySnapshot memory snapshot = _getHypotheticalLiquiditySnapshot(
account,
VToken(vTokenModify),
Expand Down Expand Up @@ -1248,7 +1289,11 @@ contract Comptroller is
* @param action Action id to pause/unpause
* @param paused The new paused state (true=paused, false=unpaused)
*/
function _setActionPaused(address market, Action action, bool paused) internal {
function _setActionPaused(
address market,
Action action,
bool paused
) internal {
require(markets[market].isListed, "cannot pause a market that is not listed");
_actionPaused[market][action] = paused;
emit ActionPausedMarket(VToken(market), action, paused);
Expand All @@ -1260,7 +1305,11 @@ contract Comptroller is
* @param redeemer Account redeeming the tokens
* @param redeemTokens The number of tokens to redeem
*/
function _checkRedeemAllowed(address vToken, address redeemer, uint256 redeemTokens) internal {
function _checkRedeemAllowed(
address vToken,
address redeemer,
uint256 redeemTokens
) internal {
Market storage market = markets[vToken];

if (!market.isListed) {
Expand Down Expand Up @@ -1297,10 +1346,11 @@ contract Comptroller is
* without calculating accumulated interest.
* @return snapshot Account liquidity snapshot
*/
function _getCurrentLiquiditySnapshot(
address account,
function(VToken) internal view returns (Exp memory) weight
) internal view returns (AccountLiquiditySnapshot memory snapshot) {
function _getCurrentLiquiditySnapshot(address account, function(VToken) internal view returns (Exp memory) weight)
internal
view
returns (AccountLiquiditySnapshot memory snapshot)
{
return _getHypotheticalLiquiditySnapshot(account, VToken(address(0)), 0, 0, weight);
}

Expand Down Expand Up @@ -1422,10 +1472,15 @@ contract Comptroller is
* @return borrowBalance Borrowed amount, including the interest
* @return exchangeRateMantissa Stored exchange rate
*/
function _safeGetAccountSnapshot(
VToken vToken,
address user
) internal view returns (uint256 vTokenBalance, uint256 borrowBalance, uint256 exchangeRateMantissa) {
function _safeGetAccountSnapshot(VToken vToken, address user)
internal
view
returns (
uint256 vTokenBalance,
uint256 borrowBalance,
uint256 exchangeRateMantissa
)
{
uint256 err;
(err, vTokenBalance, borrowBalance, exchangeRateMantissa) = vToken.getAccountSnapshot(user);
if (err != 0) {
Expand Down
25 changes: 21 additions & 4 deletions contracts/ComptrollerInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ interface ComptrollerInterface {

/*** Policy Hooks ***/

function preMintHook(address vToken, address minter, uint256 mintAmount) external;
function preMintHook(
address vToken,
address minter,
uint256 mintAmount
) external;

function preRedeemHook(address vToken, address redeemer, uint256 redeemTokens) external;
function preRedeemHook(
address vToken,
address redeemer,
uint256 redeemTokens
) external;

function preBorrowHook(address vToken, address borrower, uint256 borrowAmount) external;
function preBorrowHook(
address vToken,
address borrower,
uint256 borrowAmount
) external;

function preRepayHook(address vToken, address borrower) external;

Expand All @@ -43,7 +55,12 @@ interface ComptrollerInterface {
address borrower
) external;

function preTransferHook(address vToken, address src, address dst, uint256 transferTokens) external;
function preTransferHook(
address vToken,
address src,
address dst,
uint256 transferTokens
) external;

function isComptroller() external view returns (bool);

Expand Down
6 changes: 5 additions & 1 deletion contracts/ExponentialNoError.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ contract ExponentialNoError {
* @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.
*/
// solhint-disable-next-line func-name-mixedcase
function mul_ScalarTruncateAddUInt(Exp memory a, uint256 scalar, uint256 addend) internal pure returns (uint256) {
function mul_ScalarTruncateAddUInt(
Exp memory a,
uint256 scalar,
uint256 addend
) internal pure returns (uint256) {
Exp memory product = mul_(a, scalar);
return add_(truncate(product), addend);
}
Expand Down
50 changes: 28 additions & 22 deletions contracts/Lens/PoolLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ contract PoolLens is ExponentialNoError {
* @param comptroller The Comptroller implementation address
* @return PoolData structure containing the details of the pool
*/
function getPoolByComptroller(
address poolRegistryAddress,
address comptroller
) external view returns (PoolData memory) {
function getPoolByComptroller(address poolRegistryAddress, address comptroller)
external
view
returns (PoolData memory)
{
PoolRegistryInterface poolRegistryInterface = PoolRegistryInterface(poolRegistryAddress);
return getPoolDataFromVenusPool(poolRegistryAddress, poolRegistryInterface.getPoolByComptroller(comptroller));
}
Expand All @@ -207,10 +208,11 @@ contract PoolLens is ExponentialNoError {
* @param asset The underlying asset of vToken
* @return A list of Comptroller contracts
*/
function getPoolsSupportedByAsset(
address poolRegistryAddress,
address asset
) external view returns (address[] memory) {
function getPoolsSupportedByAsset(address poolRegistryAddress, address asset)
external
view
returns (address[] memory)
{
PoolRegistryInterface poolRegistryInterface = PoolRegistryInterface(poolRegistryAddress);
return poolRegistryInterface.getPoolsSupportedByAsset(asset);
}
Expand All @@ -220,9 +222,11 @@ contract PoolLens is ExponentialNoError {
* @param vTokens The list of vToken addresses
* @return An array containing the price data for each asset
*/
function vTokenUnderlyingPriceAll(
VToken[] calldata vTokens
) external view returns (VTokenUnderlyingPrice[] memory) {
function vTokenUnderlyingPriceAll(VToken[] calldata vTokens)
external
view
returns (VTokenUnderlyingPrice[] memory)
{
uint256 vTokenCount = vTokens.length;
VTokenUnderlyingPrice[] memory res = new VTokenUnderlyingPrice[](vTokenCount);
for (uint256 i; i < vTokenCount; ++i) {
Expand All @@ -237,13 +241,14 @@ contract PoolLens is ExponentialNoError {
* @param comptrollerAddress address
* @return Pending rewards array
*/
function getPendingRewards(
address account,
address comptrollerAddress
) external view returns (RewardSummary[] memory) {
function getPendingRewards(address account, address comptrollerAddress)
external
view
returns (RewardSummary[] memory)
{
VToken[] memory markets = ComptrollerInterface(comptrollerAddress).getAllMarkets();
RewardsDistributor[] memory rewardsDistributors = ComptrollerViewInterface(comptrollerAddress)
.getRewardDistributors();
.getRewardDistributors();
RewardSummary[] memory rewardSummary = new RewardSummary[](rewardsDistributors.length);
for (uint256 i; i < rewardsDistributors.length; ++i) {
RewardSummary memory reward;
Expand Down Expand Up @@ -328,10 +333,11 @@ contract PoolLens is ExponentialNoError {
* @param venusPool The VenusPool Object from PoolRegistry
* @return Enriched PoolData
*/
function getPoolDataFromVenusPool(
address poolRegistryAddress,
PoolRegistry.VenusPool memory venusPool
) public view returns (PoolData memory) {
function getPoolDataFromVenusPool(address poolRegistryAddress, PoolRegistry.VenusPool memory venusPool)
public
view
returns (PoolData memory)
{
// Get tokens in the Pool
ComptrollerInterface comptrollerInstance = ComptrollerInterface(venusPool.comptroller);

Expand Down Expand Up @@ -441,10 +447,10 @@ contract PoolLens is ExponentialNoError {
// Market borrow and supply state we will modify update in-memory, in order to not modify storage
RewardTokenState memory borrowState;
(borrowState.index, borrowState.block, borrowState.lastRewardingBlock) = rewardsDistributor
.rewardTokenBorrowState(address(markets[i]));
.rewardTokenBorrowState(address(markets[i]));
RewardTokenState memory supplyState;
(supplyState.index, supplyState.block, supplyState.lastRewardingBlock) = rewardsDistributor
.rewardTokenSupplyState(address(markets[i]));
.rewardTokenSupplyState(address(markets[i]));
Exp memory marketBorrowIndex = Exp({ mantissa: markets[i].borrowIndex() });

// Update market supply and borrow index in-memory
Expand Down
6 changes: 5 additions & 1 deletion contracts/Pool/PoolRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ contract PoolRegistry is Ownable2StepUpgradeable, AccessControlledV8, PoolRegist
return numberOfPools_;
}

function _transferIn(IERC20Upgradeable token, address from, uint256 amount) internal returns (uint256) {
function _transferIn(
IERC20Upgradeable token,
address from,
uint256 amount
) internal returns (uint256) {
uint256 balanceBefore = token.balanceOf(address(this));
token.safeTransferFrom(from, address(this), amount);
uint256 balanceAfter = token.balanceOf(address(this));
Expand Down
12 changes: 10 additions & 2 deletions contracts/Rewards/RewardsDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ contract RewardsDistributor is ExponentialNoError, Ownable2StepUpgradeable, Acce
* @param supplySpeed New supply-side REWARD TOKEN speed for market
* @param borrowSpeed New borrow-side REWARD TOKEN speed for market
*/
function _setRewardTokenSpeed(VToken vToken, uint256 supplySpeed, uint256 borrowSpeed) internal {
function _setRewardTokenSpeed(
VToken vToken,
uint256 supplySpeed,
uint256 borrowSpeed
) internal {
require(comptroller.isMarketListed(vToken), "rewardToken market is not listed");

if (rewardTokenSupplySpeeds[address(vToken)] != supplySpeed) {
Expand Down Expand Up @@ -463,7 +467,11 @@ contract RewardsDistributor is ExponentialNoError, Ownable2StepUpgradeable, Acce
* @param borrower The address of the borrower to distribute REWARD TOKEN to
* @param marketBorrowIndex The current global borrow index of vToken
*/
function _distributeBorrowerRewardToken(address vToken, address borrower, Exp memory marketBorrowIndex) internal {
function _distributeBorrowerRewardToken(
address vToken,
address borrower,
Exp memory marketBorrowIndex
) internal {
RewardToken storage borrowState = rewardTokenBorrowState[vToken];
uint256 borrowIndex = borrowState.index;
uint256 borrowerIndex = rewardTokenBorrowerIndex[vToken][borrower];
Expand Down
14 changes: 9 additions & 5 deletions contracts/RiskFund/ProtocolShareReserve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ contract ProtocolShareReserve is ExponentialNoError, ReserveHelpers, IProtocolSh
* @return Number of total released tokens
* @custom:error ZeroAddressNotAllowed is thrown when asset address is zero
*/
function releaseFunds(address comptroller, address asset, uint256 amount) external nonReentrant returns (uint256) {
function releaseFunds(
address comptroller,
address asset,
uint256 amount
) external nonReentrant returns (uint256) {
ensureNonzeroAddress(asset);
require(amount <= _poolsAssetsReserves[comptroller][asset], "ProtocolShareReserve: Insufficient pool balance");

Expand Down Expand Up @@ -98,10 +102,10 @@ contract ProtocolShareReserve is ExponentialNoError, ReserveHelpers, IProtocolSh
* @param comptroller Comptroller address(pool)
* @param asset Asset address.
*/
function updateAssetsState(
address comptroller,
address asset
) public override(IProtocolShareReserve, ReserveHelpers) {
function updateAssetsState(address comptroller, address asset)
public
override(IProtocolShareReserve, ReserveHelpers)
{
super.updateAssetsState(comptroller, asset);
}
}
Loading

0 comments on commit 3e5c717

Please sign in to comment.