Skip to content

Commit

Permalink
fix: pool4626 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmikko committed May 15, 2023
1 parent e420cc8 commit 50f8022
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 69 deletions.
9 changes: 5 additions & 4 deletions contracts/pool/Pool4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import {IPool4626} from "../interfaces/IPool4626.sol";
import {ICreditManagerV3} from "../interfaces/ICreditManagerV3.sol";
import {IPoolQuotaKeeper} from "../interfaces/IPoolQuotaKeeper.sol";

import {RAY, MAX_WITHDRAW_FEE} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol";
import {RAY, MAX_WITHDRAW_FEE, SECONDS_PER_YEAR} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol";
import {PERCENTAGE_FACTOR} from "@gearbox-protocol/core-v2/contracts/libraries/PercentageMath.sol";

// EXCEPTIONS
import "../interfaces/IExceptions.sol";
import "forge-std/console.sol";

struct CreditManagerDebt {
uint128 totalBorrowed;
Expand Down Expand Up @@ -419,7 +420,7 @@ contract Pool4626 is ERC4626, IPool4626, ACLNonReentrantTrait, ContractsRegister
/// @dev Computes interest rate accrued from last update (LU)
function _calcBaseInterestAccrued() internal view returns (uint256) {
// TODO: add comment why we divide by RAY
return uint256(_totalBorrowed * _borrowRate).calcLinearGrowth(timestampLU) / RAY;
return (uint256(_totalBorrowed) * _borrowRate).calcLinearGrowth(timestampLU) / RAY;
}

function _calcOutstandingQuotaRevenue() internal view returns (uint128) {
Expand Down Expand Up @@ -732,7 +733,7 @@ contract Pool4626 is ERC4626, IPool4626, ACLNonReentrantTrait, ContractsRegister
uint256 available =
IInterestRateModel(interestRateModel).availableToBorrow(expectedLiquidity(), availableLiquidity()); // F:[P4-27]

canBorrow = Math.max(canBorrow, available); // F:[P4-27]
canBorrow = Math.min(canBorrow, available); // F:[P4-27]

CreditManagerDebt memory cmDebt = creditManagersDebt[_creditManager];
if (cmDebt.totalBorrowed >= cmDebt.limit) {
Expand All @@ -741,7 +742,7 @@ contract Pool4626 is ERC4626, IPool4626, ACLNonReentrantTrait, ContractsRegister

unchecked {
uint256 cmLimit = cmDebt.limit - cmDebt.totalBorrowed;
canBorrow = Math.max(canBorrow, cmLimit); // F:[P4-27]
canBorrow = Math.min(canBorrow, cmLimit); // F:[P4-27]
}
}

Expand Down
Loading

0 comments on commit 50f8022

Please sign in to comment.