Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor cleanup #159

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions contracts/credit/CreditFacadeV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ contract CreditFacadeV3 is ICreditFacadeV3, ACLNonReentrantTrait {
/// @notice Maximum quota size, as a multiple of `maxDebt`
uint256 public constant override maxQuotaMultiplier = 8;

/// @notice Maximum number of approved bots for a credit account
uint256 public constant override maxApprovedBots = 5;

/// @notice Credit manager connected to this credit facade
address public immutable override creditManager;

Expand Down Expand Up @@ -158,9 +155,9 @@ contract CreditFacadeV3 is ICreditFacadeV3, ACLNonReentrantTrait {
{
creditManager = _creditManager; // U:[FA-1]

weth = ICreditManagerV3(_creditManager).weth(); // U:[FA-1]
botList =
IAddressProviderV3(ICreditManagerV3(_creditManager).addressProvider()).getAddressOrRevert(AP_BOT_LIST, 3_00);
address addressProvider = ICreditManagerV3(_creditManager).addressProvider();
weth = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_WETH_TOKEN, NO_VERSION_CONTROL); // U:[FA-1]
botList = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_BOT_LIST, 3_00); // U:[FA-1]

degenNFT = _degenNFT; // U:[FA-1]

Expand Down Expand Up @@ -429,10 +426,6 @@ contract CreditFacadeV3 is ICreditFacadeV3, ACLNonReentrantTrait {
permissions: permissions
}); // U:[FA-41]

if (remainingBots > maxApprovedBots) {
revert TooManyApprovedBotsException(); // U:[FA-41]
}

if (remainingBots == 0) {
_setFlagFor({creditAccount: creditAccount, flag: BOT_PERMISSIONS_SET_FLAG, value: false}); // U:[FA-41]
} else if (_flagsOf(creditAccount) & BOT_PERMISSIONS_SET_FLAG == 0) {
Expand Down
4 changes: 0 additions & 4 deletions contracts/credit/CreditManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuardT
/// @notice Address of the pool credit manager is connected to
address public immutable override pool;

/// @notice WETH token address
address public immutable override weth;

/// @notice Address of the connected credit facade
address public override creditFacade;

Expand Down Expand Up @@ -162,7 +159,6 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuardT
underlying = IPoolV3(_pool).underlyingToken(); // U:[CM-1]
_addToken(underlying); // U:[CM-1]

weth = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_WETH_TOKEN, NO_VERSION_CONTROL); // U:[CM-1]
priceOracle = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_PRICE_ORACLE, 3_00); // U:[CM-1]
accountFactory = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_ACCOUNT_FACTORY, NO_VERSION_CONTROL); // U:[CM-1]

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/ICreditFacadeV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ interface ICreditFacadeV3 is IVersion, ICreditFacadeV3Events {

function maxQuotaMultiplier() external view returns (uint256);

function maxApprovedBots() external view returns (uint256);

function expirable() external view returns (bool);

function expirationDate() external view returns (uint40);
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/ICreditManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ interface ICreditManagerV3 is IVersion, ICreditManagerV3Events {

function accountFactory() external view returns (address);

function weth() external view returns (address);

function name() external view returns (string memory);

// ------------------ //
Expand Down
3 changes: 0 additions & 3 deletions contracts/interfaces/IExceptions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ error NotApprovedBotException();
/// @notice Thrown when attempting to perform a multicall action with no permission for it
error NoPermissionException(uint256 permission);

/// @notice Thrown when user tries to approve more bots than allowed
error TooManyApprovedBotsException();

/// @notice Thrown when attempting to give a bot unexpected permissions
error UnexpectedPermissionsException();

Expand Down
4 changes: 0 additions & 4 deletions contracts/test/mocks/credit/CreditManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ contract CreditManagerMock {
address public poolService;
address public pool;

/// @dev Address of WETH
address public weth;

/// @dev Address of withdrawal manager
address public withdrawalManager;

Expand Down Expand Up @@ -83,7 +80,6 @@ contract CreditManagerMock {

constructor(address _addressProvider, address _pool) {
addressProvider = _addressProvider;
weth = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_WETH_TOKEN, NO_VERSION_CONTROL);
setPoolService(_pool);
creditConfigurator = CONFIGURATOR;
}
Expand Down
8 changes: 1 addition & 7 deletions contracts/test/unit/credit/CreditFacadeV3.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ contract CreditFacadeV3UnitTest is TestHelper, BalanceHelper, ICreditFacadeV3Eve
function test_U_FA_01_constructor_sets_correct_values() public allDegenNftCases allExpirableCases {
assertEq(address(creditFacade.creditManager()), address(creditManagerMock), "Incorrect creditManager");

assertEq(creditFacade.weth(), creditManagerMock.weth(), "Incorrect weth token");
assertEq(creditFacade.weth(), tokenTestSuite.addressOf(Tokens.WETH), "Incorrect weth token");

assertEq(creditFacade.degenNFT(), address(degenNFTMock), "Incorrect degen NFT");
}
Expand Down Expand Up @@ -1786,12 +1786,6 @@ contract CreditFacadeV3UnitTest is TestHelper, BalanceHelper, ICreditFacadeV3Eve
vm.prank(USER);
creditFacade.setBotPermissions({creditAccount: creditAccount, bot: bot, permissions: 1});

/// It reverts if too many bots approved
botListMock.setBotPermissionsReturn(creditFacade.maxApprovedBots() + 1);
vm.expectRevert(TooManyApprovedBotsException.selector);
vm.prank(USER);
creditFacade.setBotPermissions({creditAccount: creditAccount, bot: bot, permissions: 1});

/// It removes flag if no bots left
botListMock.setBotPermissionsReturn(0);
vm.expectCall(
Expand Down
7 changes: 0 additions & 7 deletions contracts/test/unit/credit/CreditManagerV3.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ contract CreditManagerV3UnitTest is TestHelper, ICreditManagerV3Events, BalanceH
underlying = tokenTestSuite.addressOf(Tokens.DAI);

addressProvider = new AddressProviderV3ACLMock();
addressProvider.setAddress(AP_WETH_TOKEN, tokenTestSuite.addressOf(Tokens.WETH), false);

accountFactory = AccountFactoryMock(addressProvider.getAddressOrRevert(AP_ACCOUNT_FACTORY, NO_VERSION_CONTROL));

Expand Down Expand Up @@ -292,12 +291,6 @@ contract CreditManagerV3UnitTest is TestHelper, ICreditManagerV3Events, BalanceH

// assertEq(lt, 0, _testCaseErr("Incorrect LT for underlying"));

assertEq(
creditManager.weth(),
addressProvider.getAddressOrRevert(AP_WETH_TOKEN, 0),
_testCaseErr("Incorrect WETH token")
);

assertEq(
address(creditManager.priceOracle()),
addressProvider.getAddressOrRevert(AP_PRICE_ORACLE, 3_00),
Expand Down
Loading