Skip to content

Commit

Permalink
fix: _addCollateral renamede
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMikko.eth committed Oct 8, 2022
1 parent cb5d906 commit 3d6e318
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions contracts/credit/CreditConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract CreditConfigurator is ICreditConfigurator, ACLTrait {
for (uint256 i = 0; i < len; ) {
address token = opts.collateralTokens[i].token;

_addCollateralToken(token); // F:[CC-1]
addCollateralToken(token); // F:[CC-1]

_setLiquidationThreshold(
token,
Expand Down Expand Up @@ -135,13 +135,13 @@ contract CreditConfigurator is ICreditConfigurator, ACLTrait {
override
configuratorOnly // F:[CC-2]
{
_addCollateralToken(token); // F:[CC-3,4]
addCollateralToken(token); // F:[CC-3,4]
_setLiquidationThreshold(token, liquidationThreshold); // F:[CC-4]
}

/// @dev Makes all sanity checks and adds the token to the collateral token list
/// @param token Address of token to be added
function _addCollateralToken(address token) internal {
function addCollateralToken(address token) internal {
// Checks that token != address(0)
if (token == address(0)) revert ZeroAddressException(); // F:[CC-3]

Expand Down
8 changes: 4 additions & 4 deletions contracts/credit/CreditFacade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {
); // F:[FA-5]

// Transfers collateral from the user to the new Credit Account
_addCollateral(onBehalfOf, creditAccount, underlying, amount); // F:[FA-5]
addCollateral(onBehalfOf, creditAccount, underlying, amount); // F:[FA-5]
}

/// @dev Opens a Credit Account and runs a batch of operations in a multicall
Expand Down Expand Up @@ -570,15 +570,15 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {
onBehalfOf
); // F:[FA-2]

_addCollateral(onBehalfOf, creditAccount, token, amount);
addCollateral(onBehalfOf, creditAccount, token, amount);

// Since this action can enable new tokens, Credit Manager
// needs to check that the max enabled token limit is not
// breached
creditManager.checkAndOptimizeEnabledTokens(creditAccount); // F: [FA-21C]
}

function _addCollateral(
function addCollateral(
address onBehalfOf,
address creditAccount,
address token,
Expand Down Expand Up @@ -779,7 +779,7 @@ contract CreditFacade is ICreditFacade, ReentrancyGuard {

// In case onBehalfOf isn't the owner of the currently processed account,
// retrieves onBehalfOf's account
_addCollateral(
addCollateral(
onBehalfOf,
onBehalfOf == borrower
? creditAccount
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/credit/CreditFacade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ contract CreditFacadeTest is
);

// 3 ASSET TEST: 10 DAI + 10 USDC + 0.01 WETH (3200 $/ETH)
_addCollateral(Tokens.WETH, WAD / 100);
addCollateral(Tokens.WETH, WAD / 100);

expectedTV += (WAD / 100) * DAI_WETH_RATE;
expectedTWV += ((WAD / 100) * DAI_WETH_RATE * 8300) / PERCENTAGE_FACTOR;
Expand Down Expand Up @@ -2193,7 +2193,7 @@ contract CreditFacadeTest is

// ADDING USDC AS COLLATERAL

_addCollateral(Tokens.USDC, 10 * 10**6);
addCollateral(Tokens.USDC, 10 * 10**6);

expectedTV += 10 * WAD;
expectedTWV += (10 * WAD * 9000) / PERCENTAGE_FACTOR;
Expand All @@ -2207,7 +2207,7 @@ contract CreditFacadeTest is
);

// 3 ASSET: 10 DAI + 10 USDC + 0.01 WETH (3200 $/ETH)
_addCollateral(Tokens.WETH, WAD / 100);
addCollateral(Tokens.WETH, WAD / 100);

expectedTV += (WAD / 100) * DAI_WETH_RATE;
expectedTWV += ((WAD / 100) * DAI_WETH_RATE * 8300) / PERCENTAGE_FACTOR;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/helpers/CreditFacadeTestEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ contract CreditFacadeTestEngine is DSTest {
);
}

function _addCollateral(address token, uint256 amount) internal {
function addCollateral(address token, uint256 amount) internal {
// tokenTestSuite.mint(t, USER, amount);

evm.startPrank(USER);
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/helpers/CreditFacadeTestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract CreditFacadeTestHelper is CreditFacadeTestEngine {
);
}

function _addCollateral(Tokens t, uint256 amount) internal {
function addCollateral(Tokens t, uint256 amount) internal {
tokenTestSuite().mint(t, USER, amount);
tokenTestSuite().approve(t, USER, address(creditManager));

Expand Down
5 changes: 1 addition & 4 deletions contracts/test/suites/TokensTestSuite.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import { WETHMock } from "../mocks/token/WETHMock.sol";

import { AggregatorV3Interface } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import { PriceFeedConfig } from "../../oracles/PriceOracle.sol";
import { IWETH } from "../../interfaces/external/IWETH.sol";
import { CheatCodes, HEVM_ADDRESS } from "../lib/cheatCodes.sol";
import { ITokenTestSuite } from "../interfaces/ITokenTestSuite.sol";

// MOCKS
import { ERC20Mock } from "../mocks/token/ERC20Mock.sol";
import { PriceFeedMock } from "../mocks/oracles/PriceFeedMock.sol";
import "../lib/constants.sol";
import "../lib/test.sol";

import { TokensTestSuiteHelper } from "../helpers/TokensTestSuiteHelper.sol";
import { TokensTestSuiteHelper } from "./TokensTestSuiteHelper.sol";
import { TokensData, TestToken } from "../config/TokensData.sol";
import { Tokens } from "../config/Tokens.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract TokensTestSuiteHelper is DSTest, ITokenTestSuite {
address token,
address to,
uint256 amount
) public override {
) public virtual override {
if (token == wethToken) {
evm.deal(address(this), amount);
IWETH(wethToken).deposit{ value: amount }();
Expand Down

0 comments on commit 3d6e318

Please sign in to comment.