Skip to content

Commit

Permalink
fix: minor changes in interfaces and contract types
Browse files Browse the repository at this point in the history
  • Loading branch information
lekhovitsky committed Jan 8, 2025
1 parent 06d77c3 commit 1ba7763
Show file tree
Hide file tree
Showing 23 changed files with 51 additions and 30 deletions.
2 changes: 1 addition & 1 deletion contracts/credit/CreditManagerV3_USDT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {IPoolV3} from "../interfaces/IPoolV3.sol";
/// @notice Credit manager variation for USDT underlying with enabled transfer fees
contract CreditManagerV3_USDT is CreditManagerV3, USDT_Transfer {
/// @notice Contract type
bytes32 public constant override contractType = "CREDIT_MANAGER_USDT";
bytes32 public constant override contractType = "CREDIT_MANAGER::USDT";

constructor(
address _pool,
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/base/IAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {IVersion} from "./IVersion.sol";
/// @title Adapter interface
/// @notice Generic interface for an adapter that can be used to interact with external protocols.
/// Adapters can be assumed to be non-malicious since they are developed by Gearbox DAO.
/// @dev Adapters must have type `ADAPTER::{POSTFIX}`
interface IAdapter is IVersion {
/// @notice Credit manager this adapter is connected to
/// @dev Assumed to be an immutable state variable
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/base/IBot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IVersion} from "./IVersion.sol";

/// @title Bot interface
/// @notice Minimal interface contracts must conform to in order to be used as bots in Gearbox V3
/// @dev Since bots might be developed by third-parties, there're no requirements on version or type
/// @dev Bots must have type `BOT::{POSTFIX}`
interface IBot is IVersion {
/// @notice Mask of permissions required for bot operation, see `ICreditFacadeV3Multicall`
function requiredPermissions() external view returns (uint192);
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/base/IInterestRateModel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IVersion} from "./IVersion.sol";

/// @title Interest rate model interface
/// @notice Generic interface for an interest rate model contract that can be used in a pool
/// @dev Interest rate models must have type `IRM::{POSTFIX}`
interface IInterestRateModel is IVersion {
/// @notice Calculates borrow rate based on utilization
/// @dev The last parameter can be used to prevent borrowing above maximum allowed utilization
Expand Down
10 changes: 6 additions & 4 deletions contracts/interfaces/base/ILossPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ pragma solidity ^0.8.17;

import {IVersion} from "./IVersion.sol";

/// @notice Loss policy dictates the conditions under which a liquidation with bad debt can proceed.
/// For example, it can restrict such liquidations to only be performed by whitelisted accounts that
/// can return premium to the DAO to recover part of the losses, or prevent liquidations of an asset
/// whose market price drops for a short period of time while its fundamental value doesn't change.
/// @title Loss policy interface
/// @notice Generic interface for a loss policy contract that dictates conditions under which a liquidation with bad debt
/// can proceed. For example, it can restrict such liquidations to only be performed by whitelisted accounts that
/// can return premium to the DAO to recover part of the losses, or prevent liquidations of an asset whose market
/// price drops for a short period of time while its fundamental value doesn't change.
/// @dev Loss policies must have type `LOSS_POLICY::{POSTFIX}`
interface ILossPolicy is IVersion {
/// @notice Whether `creditAccount` can be liquidated with loss by `caller`, `data` is an optional field
/// that can be used to pass some off-chain data specific to the loss policy implementation
Expand Down
4 changes: 1 addition & 3 deletions contracts/interfaces/base/IPhantomToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;

import {IVersion} from "./IVersion.sol";

/// @title Phantom token interface
/// @notice Broadly speaking, by saying "phantom" we imply that token is not transferable. In Gearbox, we use such tokens
/// to track balances of non-tokenized positions in integrated protocols to allow those to be used as collateral.
interface IPhantomToken is IVersion {
interface IPhantomToken {
/// @notice Returns phantom token's target contract and deposited token
function getPhantomTokenInfo() external view returns (address target, address depositedToken);
}
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/base/IPriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IVersion} from "./IVersion.sol";

/// @title Price feed interface
/// @notice Interface for Chainlink-like price feeds that can be plugged into Gearbox's price oracle
/// @dev Price feeds must have type `PRICE_FEED::{POSTFIX}`
interface IPriceFeed is IVersion {
/// @notice Whether price feed implements its own staleness and sanity checks
function skipPriceCheck() external view returns (bool);
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/base/IRateKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IVersion} from "./IVersion.sol";

/// @title Rate keeper interface
/// @notice Generic interface for a contract that can provide rates to the quota keeper
/// @dev Bots must have type `RATE_KEEPER::{POSTFIX}`
interface IRateKeeper is IVersion {
/// @notice Pool rates are provided for
function pool() external view returns (address);
Expand Down
4 changes: 1 addition & 3 deletions contracts/interfaces/base/IVotingContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;

import {IVersion} from "./IVersion.sol";

/// @title Voting contract interface
/// @notice Generic interface for a contract that can be voted for in `GearStakingV3` contract
/// @dev `vote` and `unvote` must implement votes accounting since it's not performed on the staking contract side
interface IVotingContract is IVersion {
interface IVotingContract {
function voter() external view returns (address);
function vote(address user, uint96 votes, bytes calldata extraData) external;
function unvote(address user, uint96 votes, bytes calldata extraData) external;
Expand Down
24 changes: 24 additions & 0 deletions contracts/interfaces/base/IZapper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
// Gearbox Protocol. Generalized leverage for DeFi protocols
// (c) Gearbox Foundation, 2024.
pragma solidity ^0.8.17;

import {IVersion} from "./IVersion.sol";

/// @title Zapper interface
/// @notice Generic interface for a zapper contract contract that can be used to perform complex batched
/// deposits into a pool which can, e.g., involve native token wrapping or staking pool's shares
/// @dev Zappers must have contract type `ZAPPER::{POSTFIX}`
interface IZapper is IVersion {
/// @notice Pool a zapper deposits into
function pool() external view returns (address);

/// @notice Pool's underlying token
function underlying() external view returns (address);

/// @notice Zapper's input token
function tokenIn() external view returns (address);

/// @notice Zapper's output token
function tokenOut() external view returns (address);
}
3 changes: 1 addition & 2 deletions contracts/pool/GaugeV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ contract GaugeV3 is IGaugeV3, ACLTrait, SanityCheckTrait {
uint256 public constant override version = 3_10;

/// @notice Contract type
/// @dev "RK" stands for "rate keeper"
bytes32 public constant override contractType = "RK_GAUGE";
bytes32 public constant override contractType = "RATE_KEEPER::GAUGE";

/// @notice Address of the pool this gauge is connected to
address public immutable override pool;
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool/LinearInterestRateModelV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract LinearInterestRateModelV3 is ILinearInterestRateModelV3 {
uint256 public constant override version = 3_10;

/// @notice Contract type
bytes32 public constant override contractType = "IRM_LINEAR";
bytes32 public constant override contractType = "IRM::LINEAR";

/// @notice Whether to prevent borrowing over `U_2` utilization
bool public immutable override isBorrowingMoreU2Forbidden;
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool/PoolV3_USDT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {USDT_Transfer} from "../traits/USDT_Transfer.sol";
/// @notice Pool variation for USDT underlying with enabled transfer fees
contract PoolV3_USDT is PoolV3, USDT_Transfer {
/// @notice Contract type
bytes32 public constant override contractType = "POOL_USDT";
bytes32 public constant override contractType = "POOL::USDT";

constructor(
address acl_,
Expand Down
3 changes: 1 addition & 2 deletions contracts/pool/TumblerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ contract TumblerV3 is ITumblerV3, ACLTrait, SanityCheckTrait {
uint256 public constant override version = 3_10;

/// @notice Contract type
/// @dev "RK" stands for "rate keeper"
bytes32 public constant override contractType = "RK_TUMBLER";
bytes32 public constant override contractType = "RATE_KEEPER::TUMBLER";

/// @notice Pool whose quota rates are set by this contract
address public immutable override pool;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/core/AccountFactoryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract AccountFactoryMock is Test, IAccountFactoryV3 {
/// @dev Contract version
uint256 public version;

bytes32 public constant override contractType = "ACCOUNT_FACTORY_MOCK";
bytes32 public constant override contractType = "ACCOUNT_FACTORY::MOCK";

address public usedAccount;

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/core/AdapterMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {IAdapter} from "../../../interfaces/base/IAdapter.sol";
/// @title Adapter Mock
contract AdapterMock is IAdapter {
uint256 public constant override version = 3_10;
bytes32 public constant override contractType = "ADAPTER_MOCK";
bytes32 public constant override contractType = "ADAPTER::MOCK";

address public immutable override creditManager;
address public immutable override targetContract;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/core/BotMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IBot} from "../../../interfaces/base/IBot.sol";

contract BotMock is IBot {
uint256 public constant override version = 3_10;
bytes32 public constant override contractType = "BOT_MOCK";
bytes32 public constant override contractType = "BOT::MOCK";
uint192 public override requiredPermissions;

function setRequiredPermissions(uint192 permissions) external {
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/core/LossPolicyMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ILossPolicy} from "../../../interfaces/base/ILossPolicy.sol";

contract LossPolicyMock is ILossPolicy {
uint256 public constant override version = 3_10;
bytes32 public constant override contractType = "LOSS_POLICY_MOCK";
bytes32 public constant override contractType = "LOSS_POLICY::MOCK";

bool public enabled = true;

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/credit/CreditAccountMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract CreditAccountMock is ICreditAccountV3, CreditAccountMockEvents {
// Contract version
uint256 public constant version = 3_10;

bytes32 public constant contractType = "CREDIT_ACCOUNT_MOCK";
bytes32 public constant contractType = "CREDIT_ACCOUNT::MOCK";

bytes public return_executeResult;

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/governance/GearStakingMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {EPOCHS_TO_WITHDRAW} from "../../../libraries/Constants.sol";
contract GearStakingMock is IGearStakingV3 {
uint256 public constant version = 3_10;

bytes32 public constant override contractType = "GEAR_STAKING_MOCK";
bytes32 public constant override contractType = "GEAR_STAKING::MOCK";

uint16 public getCurrentEpoch;

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/oracles/PriceFeedMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum FlagState {
/// @notice Used for test purposes only
contract PriceFeedMock is IPriceFeed {
uint256 public constant override version = 3_10;
bytes32 public constant override contractType = "PRICE_FEED_MOCK";
bytes32 public constant override contractType = "PRICE_FEED::MOCK";

int256 public price;
uint8 public immutable override decimals;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/mocks/pool/PoolQuotaKeeperMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {TokenQuotaParams, AccountQuota} from "../../../interfaces/IPoolQuotaKeep
contract PoolQuotaKeeperMock {
uint256 public constant version = 3_10;

bytes32 public constant contractType = "POOL_QUOTA_KEEPER_MOCK";
bytes32 public constant contractType = "POOL_QUOTA_KEEPER::MOCK";

/// @dev Address provider
address public immutable underlying;
Expand Down
5 changes: 1 addition & 4 deletions contracts/test/mocks/token/PhantomTokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {IPhantomToken, IPhantomTokenWithdrawer} from "../../../interfaces/base/I
import {ERC20Mock} from "../token/ERC20Mock.sol";

contract PhantomTokenMock is IPhantomToken, ERC20 {
uint256 public constant override version = 3_10;
bytes32 public constant override contractType = "PHANTOM_TOKEN_MOCK";

address public immutable target;
address public immutable depositedToken;

Expand Down Expand Up @@ -53,7 +50,7 @@ contract PhantomTokenMock is IPhantomToken, ERC20 {

contract PhantomTokenWithdrawerMock is IAdapter, IPhantomTokenWithdrawer {
uint256 public constant override version = 3_10;
bytes32 public constant override contractType = "PHANTOM_TOKEN_WITHDRAWER_MOCK";
bytes32 public constant override contractType = "PHANTOM_TOKEN_WITHDRAWER::MOCK";

address public immutable override creditManager;
address public immutable override targetContract;
Expand Down

0 comments on commit 1ba7763

Please sign in to comment.