-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
solidity/contracts/money-market/interest-models/MMFlatSlopeModel3.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: BUSL | ||
pragma solidity 0.8.19; | ||
|
||
contract MMFlatSlopeModel3 { | ||
/// @dev Return the interest rate per second, using 1e18 as denom. | ||
function getInterestRate( | ||
uint256, /*debt*/ | ||
uint256 /*floating*/ | ||
) external pure returns (uint256) { | ||
// 8% flat rate = 8e16 / 365 days | ||
return 2536783358; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
solidity/tests/money-market/interest-models/MMFlatSlope3.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.19; | ||
|
||
import { BaseTest, console } from "../../base/BaseTest.sol"; | ||
|
||
import { MMFlatSlopeModel3 } from "../../../contracts/money-market/interest-models/MMFlatSlopeModel3.sol"; | ||
|
||
// solhint-disable func-name-mixedcase | ||
// solhint-disable contract-name-camelcase | ||
contract MMFlatSlopeModel3_Test is BaseTest { | ||
MMFlatSlopeModel3 private _flatSlopeModel3; | ||
|
||
function setUp() external { | ||
_flatSlopeModel3 = new MMFlatSlopeModel3(); | ||
} | ||
|
||
function _findInterestPerYear(uint256 _interestPerSec) internal pure returns (uint256) { | ||
return _interestPerSec * 365 days; | ||
} | ||
|
||
function testFuzz_getInterestRate(uint256 debt, uint256 floating) external { | ||
// when utilization is whatever, interest will always be 7.99% ~ 8.00% | ||
assertEq(_findInterestPerYear(_flatSlopeModel3.getInterestRate(debt, floating)), 0.079999999977888000 ether); | ||
} | ||
} |