Skip to content

Commit

Permalink
fix: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmikko committed May 11, 2023
1 parent 7613f4a commit 1aa5db0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion contracts/credit/CreditFacadeV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ contract CreditFacadeV3 is ICreditFacade, ACLNonReentrantTrait {
} // F:[FA-45A]

// Sets expected balances to currentBalance + delta
expectedBalances = CreditLogic.storeBalances(creditAccount, mcall.callData[4:]); // F:[FA-45]
Balance[] memory expected = abi.decode(mcall.callData[4:], (Balance[])); // F:[FA-45]
expectedBalances = CreditLogic.storeBalances(creditAccount, expected); // F:[FA-45]
}
//
// SET FULL CHECK PARAMS
Expand Down
11 changes: 8 additions & 3 deletions contracts/credit/CreditManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
/// @dev Whether the CM supports quota-related logic
bool public immutable override supportsQuotas;

uint256 private immutable deployAccountAction;
TakeAccountAction private immutable deployAccountAction;

/// @dev The maximal number of enabled tokens on a single Credit Account
uint8 public override maxAllowedEnabledTokenLength = 12;
Expand Down Expand Up @@ -216,7 +216,9 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
priceOracle = IPriceOracleV2(addressProvider.getPriceOracle()); // F:[CM-1]
accountFactory = IAccountFactory(addressProvider.getAccountFactory()); // F:[CM-1]

deployAccountAction = accountFactory.version() == 3_00 ? uint256(TakeAccountAction.DEPLOY_NEW_ONE) : 0;
deployAccountAction = accountFactory.version() == 3_00
? uint256(TakeAccountAction.DEPLOY_NEW_ONE)
: TakeAccountAction.TAKE_USED_ONE;
creditConfigurator = msg.sender; // F:[CM-1]

withdrawalManager = IWithdrawalManager(_withdrawalManager);
Expand All @@ -243,10 +245,13 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
{
// Takes a Credit Account from the factory and sets initial parameters
// The Credit Account will be connected to this Credit Manager until closing
creditAccount = accountFactory.takeCreditAccount(deployNew ? deployAccountAction : 0, 0); // F:[CM-8]
creditAccount = accountFactory.takeCreditAccount(
uint256(deployNew ? deployAccountAction : TakeAccountAction.TAKE_USED_ONE), 0
); // F:[CM-8]

creditAccountInfo[creditAccount].debt = debt;
creditAccountInfo[creditAccount].cumulativeIndexLastUpdate = IPoolService(pool).calcLinearCumulative_RAY();
creditAccountInfo[creditAccount].flags = 0;
creditAccountInfo[creditAccount].borrower = onBehalfOf;

if (supportsQuotas) creditAccountInfo[creditAccount].cumulativeQuotaInterest = 1; // F: [CMQ-1]
Expand Down
6 changes: 3 additions & 3 deletions contracts/libraries/CreditLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ library CreditLogic {
}

/// @param creditAccount Credit Account to compute balances for
/// @param callData Bytes calldata for parsing
function storeBalances(address creditAccount, bytes memory callData)
function storeBalances(address creditAccount, Balance[] memory desired)
internal
view
returns (Balance[] memory expected)
{
// Retrieves the balance list from calldata
expected = abi.decode(callData, (Balance[])); // F:[FA-45]

expected = desired; // F:[FA-45]
uint256 len = expected.length; // F:[FA-45]

for (uint256 i = 0; i < len;) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/integration/credit/CreditConfigurator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,6 @@ contract CreditConfiguratorTest is Test, ICreditManagerV3Events, ICreditConfigur
);

vm.prank(CONFIGURATOR);
creditConfigurator.rampLiquidationThreshold(usdc, 8900, uint40(block.timestamp + 5), 1000);
creditConfigurator.rampLiquidationThreshold(usdc, 8900, 1000);
}
}
2 changes: 1 addition & 1 deletion contracts/test/unit/libraries/CreditLogic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.17;

import {IncorrectParameterException} from "../../../interfaces/IExceptions.sol";
import {CreditLogic} from "../../../libraries/CreditLogic.sol";

import {ClosureAction} from "../../../interfaces/ICreditManagerV3.sol";
import {TestHelper} from "../../lib/helper.sol";
import "forge-std/console.sol";

Expand Down

0 comments on commit 1aa5db0

Please sign in to comment.