@gearbox-protocol/periphery-v3 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
// EXCEPTIONS
|
|
61
61
|
import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
62
62
|
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
63
|
-
import {
|
|
63
|
+
import {IZapperRegister} from "../interfaces/IZapperRegister.sol";
|
|
64
64
|
|
|
65
65
|
/// @title Data compressor 3.0.
|
|
66
66
|
/// @notice Collects data from various contracts for use in the dApp
|
|
@@ -69,13 +69,13 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
69
69
|
// Contract version
|
|
70
70
|
uint256 public constant version = 3_00;
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
IZapperRegister public zapperRegister;
|
|
73
73
|
|
|
74
74
|
error CreditManagerIsNotV3Exception();
|
|
75
75
|
|
|
76
76
|
constructor(address _addressProvider) ContractsRegisterTrait(_addressProvider) {
|
|
77
77
|
zapperRegister =
|
|
78
|
-
|
|
78
|
+
IZapperRegister(IAddressProviderV3(_addressProvider).getAddressOrRevert("ZAPPER_REGISTER", 3_00));
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/// @dev Returns CreditAccountData for all opened accounts for particular borrower
|
|
@@ -130,24 +130,21 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
for (uint256 i = 0; i < len; ++i) {
|
|
133
|
-
address
|
|
133
|
+
address _cm = creditManagers[i];
|
|
134
134
|
|
|
135
|
-
_updatePrices(
|
|
136
|
-
address[] memory creditAccounts = ICreditManagerV3(
|
|
135
|
+
_updatePrices(_cm, priceUpdates);
|
|
136
|
+
address[] memory creditAccounts = ICreditManagerV3(_cm).creditAccounts();
|
|
137
137
|
uint256 caLen = creditAccounts.length;
|
|
138
138
|
for (uint256 j; j < caLen; ++j) {
|
|
139
139
|
if (
|
|
140
|
-
(
|
|
141
|
-
borrower == address(0)
|
|
142
|
-
|| ICreditManagerV3(_pool).getBorrowerOrRevert(creditAccounts[i]) == borrower
|
|
143
|
-
)
|
|
140
|
+
(borrower == address(0) || _getBorrowerOrRevert(_cm, creditAccounts[i]) == borrower)
|
|
144
141
|
&& (
|
|
145
142
|
!liquidatableOnly
|
|
146
|
-
|| ICreditManagerV3(
|
|
143
|
+
|| ICreditManagerV3(_cm).isLiquidatable(creditAccounts[i], PERCENTAGE_FACTOR)
|
|
147
144
|
)
|
|
148
145
|
) {
|
|
149
146
|
if (op == QUERY) {
|
|
150
|
-
result[index] = _getCreditAccountData(
|
|
147
|
+
result[index] = _getCreditAccountData(_cm, creditAccounts[j]);
|
|
151
148
|
}
|
|
152
149
|
++index;
|
|
153
150
|
}
|
|
@@ -182,12 +179,12 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
182
179
|
returns (CreditAccountData memory result)
|
|
183
180
|
{
|
|
184
181
|
ICreditManagerV3 creditManager = ICreditManagerV3(_pool);
|
|
185
|
-
ICreditFacadeV3 creditFacade =
|
|
182
|
+
ICreditFacadeV3 creditFacade = _getCreditFacade(address(creditManager));
|
|
186
183
|
// ICreditConfiguratorV3 creditConfigurator = ICreditConfiguratorV3(creditManager.creditConfigurator());
|
|
187
184
|
|
|
188
|
-
result.cfVersion = creditFacade
|
|
185
|
+
result.cfVersion = _getVersion(address(creditFacade));
|
|
189
186
|
|
|
190
|
-
address borrower = creditManager
|
|
187
|
+
address borrower = _getBorrowerOrRevert(address(creditManager), _creditAccount);
|
|
191
188
|
|
|
192
189
|
result.borrower = borrower;
|
|
193
190
|
result.creditManager = _pool;
|
|
@@ -196,7 +193,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
196
193
|
result.underlying = creditManager.underlying();
|
|
197
194
|
|
|
198
195
|
address pool = creditManager.pool();
|
|
199
|
-
result.baseBorrowRate =
|
|
196
|
+
result.baseBorrowRate = _getBaseInterestRate(pool);
|
|
200
197
|
|
|
201
198
|
uint256 collateralTokenCount = creditManager.collateralTokensCount();
|
|
202
199
|
|
|
@@ -208,7 +205,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
208
205
|
{
|
|
209
206
|
uint256 forbiddenTokenMask = creditFacade.forbiddenTokenMask();
|
|
210
207
|
uint256 quotedTokensMask = creditManager.quotedTokensMask();
|
|
211
|
-
IPoolQuotaKeeperV3 pqk =
|
|
208
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(pool);
|
|
212
209
|
|
|
213
210
|
unchecked {
|
|
214
211
|
for (uint256 i = 0; i < collateralTokenCount; ++i) {
|
|
@@ -315,7 +312,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
315
312
|
}
|
|
316
313
|
|
|
317
314
|
function _isContractV3(address _pool) internal view returns (bool) {
|
|
318
|
-
uint256 cmVersion =
|
|
315
|
+
uint256 cmVersion = _getVersion(_pool);
|
|
319
316
|
return cmVersion >= 3_00 && cmVersion < 3_99;
|
|
320
317
|
}
|
|
321
318
|
|
|
@@ -333,23 +330,23 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
333
330
|
}
|
|
334
331
|
}
|
|
335
332
|
|
|
336
|
-
/// @dev Returns CreditManagerData for a particular
|
|
337
|
-
/// @param
|
|
338
|
-
function getCreditManagerData(address
|
|
339
|
-
ICreditManagerV3 creditManager = ICreditManagerV3(
|
|
333
|
+
/// @dev Returns CreditManagerData for a particular _cm
|
|
334
|
+
/// @param _cm CreditManager address
|
|
335
|
+
function getCreditManagerData(address _cm) public view returns (CreditManagerData memory result) {
|
|
336
|
+
ICreditManagerV3 creditManager = ICreditManagerV3(_cm);
|
|
340
337
|
ICreditConfiguratorV3 creditConfigurator = ICreditConfiguratorV3(creditManager.creditConfigurator());
|
|
341
|
-
ICreditFacadeV3 creditFacade =
|
|
338
|
+
ICreditFacadeV3 creditFacade = _getCreditFacade(address(creditManager));
|
|
342
339
|
|
|
343
|
-
result.addr =
|
|
344
|
-
result.cfVersion = creditFacade
|
|
340
|
+
result.addr = _cm;
|
|
341
|
+
result.cfVersion = _getVersion(address(creditFacade));
|
|
345
342
|
|
|
346
343
|
result.underlying = creditManager.underlying();
|
|
347
344
|
|
|
348
345
|
{
|
|
349
346
|
result.pool = creditManager.pool();
|
|
350
347
|
IPoolV3 pool = IPoolV3(result.pool);
|
|
351
|
-
result.baseBorrowRate = pool
|
|
352
|
-
result.availableToBorrow = pool.creditManagerBorrowable(
|
|
348
|
+
result.baseBorrowRate = _getBaseInterestRate(address(pool));
|
|
349
|
+
result.availableToBorrow = pool.creditManagerBorrowable(_cm);
|
|
353
350
|
result.lirm = getLIRMData(pool.interestRateModel());
|
|
354
351
|
}
|
|
355
352
|
|
|
@@ -416,7 +413,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
416
413
|
|
|
417
414
|
result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
418
415
|
result.linearCumulativeIndex = pool.calcLinearCumulative_RAY();
|
|
419
|
-
result.baseInterestRate = pool
|
|
416
|
+
result.baseInterestRate = _getBaseInterestRate(address(pool));
|
|
420
417
|
result.underlying = pool.underlyingToken();
|
|
421
418
|
result.dieselToken = address(pool);
|
|
422
419
|
|
|
@@ -450,7 +447,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
450
447
|
|
|
451
448
|
result.supplyRate = pool.supplyRate();
|
|
452
449
|
|
|
453
|
-
result.version = pool
|
|
450
|
+
result.version = _getVersion(address(pool));
|
|
454
451
|
|
|
455
452
|
result.quotas = _getQuotas(_pool);
|
|
456
453
|
result.lirm = getLIRMData(pool.interestRateModel());
|
|
@@ -467,7 +464,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
467
464
|
}
|
|
468
465
|
}
|
|
469
466
|
|
|
470
|
-
result.poolQuotaKeeper =
|
|
467
|
+
result.poolQuotaKeeper = address(_getPoolQuotaKeeper(_pool));
|
|
471
468
|
result.gauge = IPoolQuotaKeeperV3(result.poolQuotaKeeper).gauge();
|
|
472
469
|
|
|
473
470
|
return result;
|
|
@@ -515,8 +512,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
515
512
|
uint256 len = priceUpdates.length;
|
|
516
513
|
unchecked {
|
|
517
514
|
for (uint256 i; i < len; ++i) {
|
|
518
|
-
address priceFeed =
|
|
519
|
-
IPriceOracleV3(ICreditManagerV3(creditManager).priceOracle()).priceFeeds(priceUpdates[i].token);
|
|
515
|
+
address priceFeed = _getPriceOracle(creditManager).priceFeeds(priceUpdates[i].token);
|
|
520
516
|
if (priceFeed == address(0)) revert PriceFeedDoesNotExistException();
|
|
521
517
|
|
|
522
518
|
IUpdatablePriceFeed(priceFeed).updatePrice(priceUpdates[i].callData);
|
|
@@ -524,14 +520,14 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
524
520
|
}
|
|
525
521
|
}
|
|
526
522
|
|
|
527
|
-
function _getPriceFeedFailedList(address
|
|
523
|
+
function _getPriceFeedFailedList(address _cm, TokenBalance[] memory balances)
|
|
528
524
|
internal
|
|
529
525
|
view
|
|
530
526
|
returns (address[] memory priceFeedFailed)
|
|
531
527
|
{
|
|
532
528
|
uint256 len = balances.length;
|
|
533
529
|
|
|
534
|
-
IPriceOracleV3 priceOracle =
|
|
530
|
+
IPriceOracleV3 priceOracle = _getPriceOracle(_cm);
|
|
535
531
|
|
|
536
532
|
uint256 index;
|
|
537
533
|
|
|
@@ -560,8 +556,32 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
560
556
|
}
|
|
561
557
|
}
|
|
562
558
|
|
|
559
|
+
function _getPoolQuotaKeeper(address pool) internal view returns (IPoolQuotaKeeperV3) {
|
|
560
|
+
return IPoolQuotaKeeperV3(IPoolV3(pool).poolQuotaKeeper());
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function _getPriceOracle(address _cm) internal view returns (IPriceOracleV3) {
|
|
564
|
+
return IPriceOracleV3(ICreditManagerV3(_cm).priceOracle());
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function _getBaseInterestRate(address pool) internal view returns (uint256) {
|
|
568
|
+
return IPoolV3(pool).baseInterestRate();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function _getBorrowerOrRevert(address cm, address creditAccount) internal view returns (address) {
|
|
572
|
+
return ICreditManagerV3(cm).getBorrowerOrRevert(creditAccount);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function _getVersion(address versionedContract) internal view returns (uint256) {
|
|
576
|
+
return IVersion(versionedContract).version();
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function _getCreditFacade(address cm) internal view returns (ICreditFacadeV3) {
|
|
580
|
+
return ICreditFacadeV3(ICreditManagerV3(cm).creditFacade());
|
|
581
|
+
}
|
|
582
|
+
|
|
563
583
|
function _getQuotas(address _pool) internal view returns (QuotaInfo[] memory quotas) {
|
|
564
|
-
IPoolQuotaKeeperV3 pqk =
|
|
584
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(_pool);
|
|
565
585
|
|
|
566
586
|
address[] memory quotaTokens = pqk.quotedTokens();
|
|
567
587
|
uint256 len = quotaTokens.length;
|
|
@@ -589,7 +609,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
589
609
|
unchecked {
|
|
590
610
|
for (uint256 i; i < len; ++i) {
|
|
591
611
|
GaugeInfo memory gaugeInfo = result[i];
|
|
592
|
-
IPoolQuotaKeeperV3 pqk =
|
|
612
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(poolsV3[i]);
|
|
593
613
|
address gauge = pqk.gauge();
|
|
594
614
|
gaugeInfo.addr = gauge;
|
|
595
615
|
|
|
@@ -639,7 +659,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
639
659
|
address[] memory quotaTokens;
|
|
640
660
|
address gauge;
|
|
641
661
|
{
|
|
642
|
-
IPoolQuotaKeeperV3 pqk =
|
|
662
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(poolsV3[i]);
|
|
643
663
|
gauge = pqk.gauge();
|
|
644
664
|
|
|
645
665
|
quotaTokens = pqk.quotedTokens();
|
|
@@ -5,11 +5,11 @@ pragma solidity ^0.8.10;
|
|
|
5
5
|
|
|
6
6
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
7
7
|
import {IZapper} from "@gearbox-protocol/integrations-v3/contracts/interfaces/zappers/IZapper.sol";
|
|
8
|
-
import {
|
|
8
|
+
import {IZapperRegister} from "../interfaces/IZapperRegister.sol";
|
|
9
9
|
import {ACLNonReentrantTrait} from "@gearbox-protocol/core-v3/contracts/traits/ACLNonReentrantTrait.sol";
|
|
10
10
|
import {ContractsRegisterTrait} from "@gearbox-protocol/core-v3/contracts/traits/ContractsRegisterTrait.sol";
|
|
11
11
|
|
|
12
|
-
contract ZapperRegister is ACLNonReentrantTrait, ContractsRegisterTrait,
|
|
12
|
+
contract ZapperRegister is ACLNonReentrantTrait, ContractsRegisterTrait, IZapperRegister {
|
|
13
13
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
14
14
|
|
|
15
15
|
// Contract version
|
package/package.json
CHANGED