Skip to content

Commit

Permalink
test(irm): move exp lib test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Nov 14, 2023
1 parent 677e230 commit 061f89f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions test/AdaptativeCurveIrmTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ contract AdaptativeCurveIrmTest is Test {
assertApproxEqRel(irm.rateAtTarget(marketParams.id()), expectedRateAtTarget, 0.001 ether, "rateAtTarget");
}

function testWExpWMulDownMaxRate() public pure {
ExpLib.wExp(ExpLib.WEXP_UPPER_BOUND).wMulDown(ConstantsLib.MAX_RATE_AT_TARGET);
}

/* HANDLERS */

function handleBorrowRate(uint256 totalSupplyAssets, uint256 totalBorrowAssets, uint256 elapsed) external {
Expand Down
8 changes: 8 additions & 0 deletions test/ExpLibTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
pragma solidity ^0.8.0;

import {WAD_INT} from "../src/libraries/MathLib.sol";
import {ConstantsLib} from "../src/libraries/adaptative-curve/ConstantsLib.sol";
import {ExpLib} from "../src/libraries/adaptative-curve/ExpLib.sol";
import {wadExp} from "../lib/solmate/src/utils/SignedWadMath.sol";
import {MathLib as MorphoMathLib} from "../lib/morpho-blue/src/libraries/MathLib.sol";

import "../lib/forge-std/src/Test.sol";

contract ExpLibTest is Test {
using MorphoMathLib for uint256;

/// @dev ln(1e-9) truncated at 2 decimal places.
int256 internal constant LN_GWEI_INT = -20.72 ether;

Expand Down Expand Up @@ -45,6 +49,10 @@ contract ExpLibTest is Test {
assertEq(_wExpUnbounded(ExpLib.WEXP_UPPER_BOUND), ExpLib.WEXP_UPPER_VALUE);
}

function testWExpWMulDownMaxRate() public pure {
ExpLib.wExp(ExpLib.WEXP_UPPER_BOUND).wMulDown(ConstantsLib.MAX_RATE_AT_TARGET);
}

function _wExpUnbounded(int256 x) internal pure returns (uint256) {
unchecked {
// Decompose x as x = q * ln(2) + r with q an integer and -ln(2)/2 <= r <= ln(2)/2.
Expand Down

0 comments on commit 061f89f

Please sign in to comment.