Skip to content

Commit

Permalink
Merge pull request #212 from Gearbox-protocol/reorganize-project
Browse files Browse the repository at this point in the history
feat: reorganize project
  • Loading branch information
0xmikko authored May 9, 2024
2 parents f255c5a + adec88d commit 50a6e58
Show file tree
Hide file tree
Showing 94 changed files with 383 additions and 3,486 deletions.
4 changes: 2 additions & 2 deletions contracts/core/BotListV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pragma solidity ^0.8.17;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

import {IBot} from "../interfaces/IBot.sol";
import {IBotListV3, BotInfo} from "../interfaces/IBotListV3.sol";
import {IBotV3} from "../interfaces/IBotV3.sol";
import {ICreditAccountV3} from "../interfaces/ICreditAccountV3.sol";
import {ICreditManagerV3} from "../interfaces/ICreditManagerV3.sol";
import {
Expand Down Expand Up @@ -89,7 +89,7 @@ contract BotListV3 is IBotListV3, SanityCheckTrait, Ownable {
BotInfo storage info = _botInfo[bot];
EnumerableSet.AddressSet storage accountBots = _activeBots[creditManager][creditAccount];
if (permissions != 0) {
if (IBotV3(bot).requiredPermissions() & ~permissions != 0) revert InsufficientBotPermissionsException();
if (IBot(bot).requiredPermissions() & ~permissions != 0) revert InsufficientBotPermissionsException();
if (info.forbidden) revert InvalidBotException();
accountBots.add(bot);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

import {IVotingContractV3} from "../interfaces/IVotingContractV3.sol";
import {IVotingContract} from "../interfaces/IVotingContract.sol";
import {
IGearStakingV3,
UserVoteLockData,
WithdrawalData,
MultiVote,
VotingContractStatus,
EPOCHS_TO_WITHDRAW,
EPOCH_LENGTH
VotingContractStatus
} from "../interfaces/IGearStakingV3.sol";

import {EPOCHS_TO_WITHDRAW, EPOCH_LENGTH} from "../libraries/Constants.sol";
import {ACLNonReentrantTrait} from "../traits/ACLNonReentrantTrait.sol";

// EXCEPTIONS
Expand Down Expand Up @@ -239,15 +237,13 @@ contract GearStakingV3 is ACLNonReentrantTrait, IGearStakingV3 {
vld.available -= currentVote.voteAmount;
}

IVotingContractV3(currentVote.votingContract).vote(user, currentVote.voteAmount, currentVote.extraData);
IVotingContract(currentVote.votingContract).vote(user, currentVote.voteAmount, currentVote.extraData);
} else {
if (allowedVotingContract[currentVote.votingContract] == VotingContractStatus.NOT_ALLOWED) {
revert VotingContractNotAllowedException(); // U: [GS-04A]
}

IVotingContractV3(currentVote.votingContract).unvote(
user, currentVote.voteAmount, currentVote.extraData
);
IVotingContract(currentVote.votingContract).unvote(user, currentVote.voteAmount, currentVote.extraData);
vld.available += currentVote.voteAmount;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/core/PriceOracleV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
PriceFeedDoesNotExistException,
PriceFeedIsNotUpdatableException
} from "../interfaces/IExceptions.sol";
import {IUpdatablePriceFeed} from "../interfaces/IPriceFeed.sol";
import {IPriceOracleV3, PriceFeedParams, PriceUpdate} from "../interfaces/IPriceOracleV3.sol";
import {IUpdatablePriceFeed} from "@gearbox-protocol/core-v2/contracts/interfaces/IPriceFeed.sol";

import {ACLNonReentrantTrait} from "../traits/ACLNonReentrantTrait.sol";
import {PriceFeedValidationTrait} from "../traits/PriceFeedValidationTrait.sol";
Expand Down
7 changes: 4 additions & 3 deletions contracts/credit/CreditConfiguratorV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

// LIBRARIES & CONSTANTS
import {BitMask} from "../libraries/BitMask.sol";
import {
DEFAULT_FEE_INTEREST,
DEFAULT_FEE_LIQUIDATION,
Expand All @@ -17,17 +18,17 @@ import {
DEFAULT_LIQUIDATION_PREMIUM_EXPIRED,
DEFAULT_LIMIT_PER_BLOCK_MULTIPLIER,
PERCENTAGE_FACTOR,
UNDERLYING_TOKEN_MASK,
WAD
} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol";
import {BitMask, UNDERLYING_TOKEN_MASK} from "../libraries/BitMask.sol";
} from "../libraries/Constants.sol";

// CONTRACTS
import {ACLNonReentrantTrait} from "../traits/ACLNonReentrantTrait.sol";
import {CreditFacadeV3} from "./CreditFacadeV3.sol";
import {CreditManagerV3} from "./CreditManagerV3.sol";

// INTERFACES
import {IAdapter} from "@gearbox-protocol/core-v2/contracts/interfaces/IAdapter.sol";
import {IAdapter} from "../interfaces/IAdapter.sol";
import {ICreditConfiguratorV3, CreditManagerOpts, AllowanceAction} from "../interfaces/ICreditConfiguratorV3.sol";
import {IPoolQuotaKeeperV3} from "../interfaces/IPoolQuotaKeeperV3.sol";
import {IPriceOracleV3} from "../interfaces/IPriceOracleV3.sol";
Expand Down
31 changes: 18 additions & 13 deletions contracts/credit/CreditFacadeV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,37 @@ import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC2
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

// FIRST-PARTY
import {IDegenNFTV2} from "@gearbox-protocol/core-v2/contracts/interfaces/IDegenNFTV2.sol";
import {IWETH} from "@gearbox-protocol/core-v2/contracts/interfaces/external/IWETH.sol";
import {Balance} from "@gearbox-protocol/core-v2/contracts/libraries/Balances.sol";
import {PERCENTAGE_FACTOR} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol";
import {MultiCall} from "@gearbox-protocol/core-v2/contracts/libraries/MultiCall.sol";

// INTERFACES
import {IBotListV3} from "../interfaces/IBotListV3.sol";
import {AllowanceAction} from "../interfaces/ICreditConfiguratorV3.sol";
import {CumulativeLossParams, DebtLimits, FullCheckParams, ICreditFacadeV3} from "../interfaces/ICreditFacadeV3.sol";
import {
CumulativeLossParams,
DebtLimits,
FullCheckParams,
ICreditFacadeV3,
MultiCall
} from "../interfaces/ICreditFacadeV3.sol";
import "../interfaces/ICreditFacadeV3Multicall.sol";
import {
BOT_PERMISSIONS_SET_FLAG,
CollateralCalcTask,
CollateralDebtData,
ICreditManagerV3,
INACTIVE_CREDIT_ACCOUNT_ADDRESS,
ManageDebtAction
} from "../interfaces/ICreditManagerV3.sol";
import {IDegenNFT} from "../interfaces/IDegenNFT.sol";
import "../interfaces/IExceptions.sol";
import {IPriceOracleV3, PriceUpdate} from "../interfaces/IPriceOracleV3.sol";
import {IWETH} from "../interfaces/external/IWETH.sol";

// LIBRARIES
import {BalanceDelta, BalanceWithMask, BalancesLogic, Comparison} from "../libraries/BalancesLogic.sol";
import {BitMask, UNDERLYING_TOKEN_MASK} from "../libraries/BitMask.sol";
import {Balance, BalanceDelta, BalanceWithMask, BalancesLogic, Comparison} from "../libraries/BalancesLogic.sol";
import {BitMask} from "../libraries/BitMask.sol";
import {
BOT_PERMISSIONS_SET_FLAG,
INACTIVE_CREDIT_ACCOUNT_ADDRESS,
PERCENTAGE_FACTOR,
UNDERLYING_TOKEN_MASK
} from "../libraries/Constants.sol";

// TRAITS
import {ACLNonReentrantTrait} from "../traits/ACLNonReentrantTrait.sol";
Expand Down Expand Up @@ -191,7 +196,7 @@ contract CreditFacadeV3 is ICreditFacadeV3, ACLNonReentrantTrait {
if (msg.sender != onBehalfOf) {
revert ForbiddenInWhitelistedModeException(); // U:[FA-9]
}
IDegenNFTV2(degenNFT).burn(onBehalfOf, 1); // U:[FA-9]
IDegenNFT(degenNFT).burn(onBehalfOf, 1); // U:[FA-9]
}

creditAccount = ICreditManagerV3(creditManager).openCreditAccount({onBehalfOf: onBehalfOf}); // U:[FA-10]
Expand Down
15 changes: 9 additions & 6 deletions contracts/credit/CreditManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

// LIBS & TRAITS
import {UNDERLYING_TOKEN_MASK, BitMask} from "../libraries/BitMask.sol";
import {BitMask} from "../libraries/BitMask.sol";
import {CreditLogic} from "../libraries/CreditLogic.sol";
import {CollateralLogic} from "../libraries/CollateralLogic.sol";
import {CreditAccountHelper} from "../libraries/CreditAccountHelper.sol";
Expand All @@ -28,15 +28,18 @@ import {
ManageDebtAction,
CreditAccountInfo,
CollateralDebtData,
CollateralCalcTask,
DEFAULT_MAX_ENABLED_TOKENS,
INACTIVE_CREDIT_ACCOUNT_ADDRESS
CollateralCalcTask
} from "../interfaces/ICreditManagerV3.sol";
import {IPriceOracleV3} from "../interfaces/IPriceOracleV3.sol";
import {IPoolQuotaKeeperV3} from "../interfaces/IPoolQuotaKeeperV3.sol";

// CONSTANTS
import {PERCENTAGE_FACTOR} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol";
// LIBRARIES
import {
DEFAULT_MAX_ENABLED_TOKENS,
INACTIVE_CREDIT_ACCOUNT_ADDRESS,
PERCENTAGE_FACTOR,
UNDERLYING_TOKEN_MASK
} from "../libraries/Constants.sol";

// EXCEPTIONS
import "../interfaces/IExceptions.sol";
Expand Down
Loading

0 comments on commit 50a6e58

Please sign in to comment.