@@ -110,7 +110,12 @@ contract PoolLens is Initializable {
110
110
*/
111
111
function getPublicPoolsWithData ()
112
112
external
113
- returns (uint256 [] memory , PoolDirectory.Pool[] memory , IonicPoolData[] memory , bool [] memory )
113
+ returns (
114
+ uint256 [] memory ,
115
+ PoolDirectory.Pool[] memory ,
116
+ IonicPoolData[] memory ,
117
+ bool [] memory
118
+ )
114
119
{
115
120
(uint256 [] memory indexes , PoolDirectory.Pool[] memory publicPools ) = directory.getPublicPools ();
116
121
(IonicPoolData[] memory data , bool [] memory errored ) = getPoolsData (publicPools);
@@ -122,9 +127,15 @@ contract PoolLens is Initializable {
122
127
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
123
128
* Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.
124
129
*/
125
- function getPublicPoolsByVerificationWithData (
126
- bool whitelistedAdmin
127
- ) external returns (uint256 [] memory , PoolDirectory.Pool[] memory , IonicPoolData[] memory , bool [] memory ) {
130
+ function getPublicPoolsByVerificationWithData (bool whitelistedAdmin )
131
+ external
132
+ returns (
133
+ uint256 [] memory ,
134
+ PoolDirectory.Pool[] memory ,
135
+ IonicPoolData[] memory ,
136
+ bool [] memory
137
+ )
138
+ {
128
139
(uint256 [] memory indexes , PoolDirectory.Pool[] memory publicPools ) = directory.getPublicPoolsByVerification (
129
140
whitelistedAdmin
130
141
);
@@ -137,9 +148,15 @@ contract PoolLens is Initializable {
137
148
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
138
149
* Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.
139
150
*/
140
- function getPoolsByAccountWithData (
141
- address account
142
- ) external returns (uint256 [] memory , PoolDirectory.Pool[] memory , IonicPoolData[] memory , bool [] memory ) {
151
+ function getPoolsByAccountWithData (address account )
152
+ external
153
+ returns (
154
+ uint256 [] memory ,
155
+ PoolDirectory.Pool[] memory ,
156
+ IonicPoolData[] memory ,
157
+ bool [] memory
158
+ )
159
+ {
143
160
(uint256 [] memory indexes , PoolDirectory.Pool[] memory accountPools ) = directory.getPoolsByAccount (account);
144
161
(IonicPoolData[] memory data , bool [] memory errored ) = getPoolsData (accountPools);
145
162
return (indexes, accountPools, data, errored);
@@ -150,9 +167,15 @@ contract PoolLens is Initializable {
150
167
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
151
168
* Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.
152
169
*/
153
- function getPoolsOIonicrWithData (
154
- address user
155
- ) external returns (uint256 [] memory , PoolDirectory.Pool[] memory , IonicPoolData[] memory , bool [] memory ) {
170
+ function getPoolsOIonicrWithData (address user )
171
+ external
172
+ returns (
173
+ uint256 [] memory ,
174
+ PoolDirectory.Pool[] memory ,
175
+ IonicPoolData[] memory ,
176
+ bool [] memory
177
+ )
178
+ {
156
179
(uint256 [] memory indexes , PoolDirectory.Pool[] memory userPools ) = directory.getPoolsOfUser (user);
157
180
(IonicPoolData[] memory data , bool [] memory errored ) = getPoolsData (userPools);
158
181
return (indexes, userPools, data, errored);
@@ -187,9 +210,16 @@ contract PoolLens is Initializable {
187
210
/**
188
211
* @notice Returns total supply balance (in ETH), total borrow balance (in ETH), underlying token addresses, and underlying token symbols of a Ionic pool.
189
212
*/
190
- function getPoolSummary (
191
- IonicComptroller comptroller
192
- ) external returns (uint256 , uint256 , address [] memory , string [] memory , bool ) {
213
+ function getPoolSummary (IonicComptroller comptroller )
214
+ external
215
+ returns (
216
+ uint256 ,
217
+ uint256 ,
218
+ address [] memory ,
219
+ string [] memory ,
220
+ bool
221
+ )
222
+ {
193
223
uint256 totalBorrow = 0 ;
194
224
uint256 totalSupply = 0 ;
195
225
ICErc20[] memory cTokens = comptroller.getAllMarkets ();
@@ -329,10 +359,7 @@ contract PoolLens is Initializable {
329
359
return (detailedAssets);
330
360
}
331
361
332
- function getBorrowCapsPerCollateral (
333
- ICErc20 borrowedAsset ,
334
- IonicComptroller comptroller
335
- )
362
+ function getBorrowCapsPerCollateral (ICErc20 borrowedAsset , IonicComptroller comptroller )
336
363
internal
337
364
view
338
365
returns (
@@ -431,9 +458,15 @@ contract PoolLens is Initializable {
431
458
* @notice returns the total supply cap for each asset in the pool and the total non-whitelist supplied assets
432
459
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
433
460
*/
434
- function getSupplyCapsDataForPool (
435
- IonicComptroller comptroller
436
- ) public view returns (address [] memory , uint256 [] memory , uint256 [] memory ) {
461
+ function getSupplyCapsDataForPool (IonicComptroller comptroller )
462
+ public
463
+ view
464
+ returns (
465
+ address [] memory ,
466
+ uint256 [] memory ,
467
+ uint256 [] memory
468
+ )
469
+ {
437
470
ICErc20[] memory poolMarkets = comptroller.getAllMarkets ();
438
471
439
472
address [] memory assets = new address [](poolMarkets.length );
@@ -455,9 +488,7 @@ contract PoolLens is Initializable {
455
488
* @notice returns the total borrow cap and the per collateral borrowing cap/blacklist for the asset
456
489
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
457
490
*/
458
- function getBorrowCapsForAsset (
459
- ICErc20 asset
460
- )
491
+ function getBorrowCapsForAsset (ICErc20 asset )
461
492
public
462
493
view
463
494
returns (
@@ -476,9 +507,7 @@ contract PoolLens is Initializable {
476
507
* @notice returns the total borrow cap, the per collateral borrowing cap/blacklist for the asset and the total non-whitelist borrows
477
508
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
478
509
*/
479
- function getBorrowCapsDataForAsset (
480
- ICErc20 asset
481
- )
510
+ function getBorrowCapsDataForAsset (ICErc20 asset )
482
511
public
483
512
view
484
513
returns (
@@ -503,9 +532,11 @@ contract PoolLens is Initializable {
503
532
* Note that the whitelist does not have to be enforced.
504
533
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
505
534
*/
506
- function getWhitelistedPoolsByAccount (
507
- address account
508
- ) public view returns (uint256 [] memory , PoolDirectory.Pool[] memory ) {
535
+ function getWhitelistedPoolsByAccount (address account )
536
+ public
537
+ view
538
+ returns (uint256 [] memory , PoolDirectory.Pool[] memory )
539
+ {
509
540
(, PoolDirectory.Pool[] memory pools ) = directory.getActivePools ();
510
541
uint256 arrayLength = 0 ;
511
542
@@ -538,27 +569,22 @@ contract PoolLens is Initializable {
538
569
* @dev This function is not designed to be called in a transaction: it is too gas-intensive.
539
570
* Ideally, we can add the `view` modifier, but many cToken functions potentially modify the state.
540
571
*/
541
- function getWhitelistedPoolsByAccountWithData (
542
- address account
543
- ) external returns (uint256 [] memory , PoolDirectory.Pool[] memory , IonicPoolData[] memory , bool [] memory ) {
572
+ function getWhitelistedPoolsByAccountWithData (address account )
573
+ external
574
+ returns (
575
+ uint256 [] memory ,
576
+ PoolDirectory.Pool[] memory ,
577
+ IonicPoolData[] memory ,
578
+ bool [] memory
579
+ )
580
+ {
544
581
(uint256 [] memory indexes , PoolDirectory.Pool[] memory accountPools ) = getWhitelistedPoolsByAccount (account);
545
582
(IonicPoolData[] memory data , bool [] memory errored ) = getPoolsData (accountPools);
546
583
return (indexes, accountPools, data, errored);
547
584
}
548
585
549
586
function getHealthFactor (address user , IonicComptroller pool ) external view returns (uint256 ) {
550
- (uint256 err , uint256 collateralValue , uint256 liquidity , uint256 shortfall ) = pool.getAccountLiquidity (user);
551
-
552
- if (err != 0 ) revert ComptrollerError (err);
553
-
554
- if (shortfall > 0 ) {
555
- // HF < 1.0
556
- return (collateralValue * 1e18 ) / (collateralValue + shortfall);
557
- } else {
558
- // HF >= 1.0
559
- if (collateralValue <= liquidity) return type (uint256 ).max;
560
- else return (collateralValue * 1e18 ) / (collateralValue - liquidity);
561
- }
587
+ return getHealthFactorHypothetical (pool, user, address (0 ), 0 , 0 , 0 );
562
588
}
563
589
564
590
function getHealthFactorHypothetical (
@@ -568,7 +594,7 @@ contract PoolLens is Initializable {
568
594
uint256 redeemTokens ,
569
595
uint256 borrowAmount ,
570
596
uint256 repayAmount
571
- ) external view returns (uint256 ) {
597
+ ) public view returns (uint256 ) {
572
598
(uint256 err , uint256 collateralValue , uint256 liquidity , uint256 shortfall ) = pool.getHypotheticalAccountLiquidity (
573
599
account,
574
600
cTokenModify,
0 commit comments