Skip to content

Commit

Permalink
test: add failing
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Nov 14, 2023
1 parent 1316754 commit 8fc80ff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/SpeedJumpIrmTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,22 @@ contract AdaptativeCurveIrmTest is Test {
assertApproxEqAbs(startBorrowRate.wMulDown(adaptationMultiplier), endBorrowRate, 1e3);
}

function testNotUnbounded(uint256 startRateAtTarget, uint256 elapsed) public {
startRateAtTarget = bound(startRateAtTarget, irm.MIN_RATE_AT_TARGET(), irm.MAX_RATE_AT_TARGET());
elapsed = bound(elapsed, 0, 365 days);

int256 err = 1 ether;
int256 speed = ADJUSTMENT_SPEED.wMulDown(err);
uint256 adaptationMultiplier = MathLib.wExp(speed * int256(elapsed));

uint256 endRateAtTarget =
startRateAtTarget.wMulDown(adaptationMultiplier).bound(irm.MIN_RATE_AT_TARGET(), irm.MAX_RATE_AT_TARGET());
uint256 endBorrowRate = _curve(endRateAtTarget, err);
uint256 startBorrowRate = _curve(startRateAtTarget, err);

assertApproxEqAbs(startBorrowRate.wMulDown(adaptationMultiplier), endBorrowRate, 1e3);
}

function _expectedRateAtTarget(Id id, Market memory market) internal view returns (uint256) {
return _expectedUnboundedRateAtTarget(id, market).bound(irm.MIN_RATE_AT_TARGET(), irm.MAX_RATE_AT_TARGET());
}
Expand Down

0 comments on commit 8fc80ff

Please sign in to comment.