Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 0cec821

Browse files
authored
Merge pull request #69 from ionicprotocol/fix/net-apr-0
Fix/net apr 0
2 parents 4240880 + c362d37 commit 0cec821

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

contracts/ionic/strategies/flywheel/IonicFlywheelLensRouter.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ contract IonicFlywheelLensRouter {
200200
uint256 collateralValue = (supplied * assetPrice) / 1e18;
201201
uint256 borrowsValue = (borrows * assetPrice) / 1e18;
202202

203-
uint256 yieldValuePerBlock = (collateralValue * supplyRatePerBlock) / 1e18;
204-
uint256 interestOwedValuePerBlock = (borrowsValue * borrowRatePerBlock) / 1e18;
203+
uint256 yieldValuePerBlock = collateralValue * supplyRatePerBlock;
204+
uint256 interestOwedValuePerBlock = borrowsValue * borrowRatePerBlock;
205205

206206
if (collateralValue == 0) return 0;
207207
return ((int256(yieldValuePerBlock) - int256(interestOwedValuePerBlock)) * blocksPerYear) / int256(collateralValue);

contracts/test/DevTesting.t.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import { PoolLens } from "../PoolLens.sol";
1919
import { PoolLensSecondary } from "../PoolLensSecondary.sol";
2020
import { JumpRateModel } from "../compound/JumpRateModel.sol";
2121
import { LeveredPositionsLens } from "../ionic/levered/LeveredPositionsLens.sol";
22+
import { IonicFlywheelLensRouter, IonicComptroller, ICErc20, ERC20, IPriceOracle } from "../ionic/strategies/flywheel/IonicFlywheelLensRouter.sol";
23+
import { PoolDirectory } from "../PoolDirectory.sol";
24+
25+
import "forge-std/console.sol";
2226

2327
contract DevTesting is BaseTest {
2428
IonicComptroller pool = IonicComptroller(0xFB3323E24743Caf4ADD0fDCCFB268565c0685556);
@@ -105,6 +109,17 @@ contract DevTesting is BaseTest {
105109
emit log_named_uint("hf", hf);
106110
}
107111

112+
function testNetAprMode() public debuggingOnly forkAtBlock(MODE_MAINNET, 8479829) {
113+
address user = 0x30D5047e839f079bDE1Ab16b34668f57391DacB3;
114+
int256 blocks = 30 * 24 * 365 * 60;
115+
IonicFlywheelLensRouter lensRouter = new IonicFlywheelLensRouter(
116+
PoolDirectory(0x39C353Cf9041CcF467A04d0e78B63d961E81458a)
117+
);
118+
int256 apr = lensRouter.getUserNetApr(user, blocks);
119+
120+
emit log_named_int("apr", apr);
121+
}
122+
108123
function testModeUsdcBorrowCaps() public debuggingOnly fork(MODE_MAINNET) {
109124
_testModeBorrowCaps(usdcMarket);
110125
}

0 commit comments

Comments
 (0)