@gearbox-protocol/periphery-v3 1.2.1 → 1.2.3
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.
- package/contracts/data/DataCompressor_3_0.sol +61 -38
- package/contracts/data/LinearInterestModelHelper.sol +2 -0
- package/contracts/data/Types.sol +1 -0
- package/contracts/data/ZapperRegister.sol +2 -2
- package/contracts/interfaces/{IZapperRegistry.sol → IZapperRegister.sol} +1 -1
- package/contracts/test/DC_Printer.sol +1 -1
- package/contracts/test/DC_Test.sol +140 -0
- package/package.json +1 -1
|
@@ -60,7 +60,9 @@ 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
|
+
|
|
65
|
+
import "forge-std/console.sol";
|
|
64
66
|
|
|
65
67
|
/// @title Data compressor 3.0.
|
|
66
68
|
/// @notice Collects data from various contracts for use in the dApp
|
|
@@ -69,13 +71,13 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
69
71
|
// Contract version
|
|
70
72
|
uint256 public constant version = 3_00;
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
IZapperRegister public zapperRegister;
|
|
73
75
|
|
|
74
76
|
error CreditManagerIsNotV3Exception();
|
|
75
77
|
|
|
76
78
|
constructor(address _addressProvider) ContractsRegisterTrait(_addressProvider) {
|
|
77
79
|
zapperRegister =
|
|
78
|
-
|
|
80
|
+
IZapperRegister(IAddressProviderV3(_addressProvider).getAddressOrRevert("ZAPPER_REGISTER", 3_00));
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/// @dev Returns CreditAccountData for all opened accounts for particular borrower
|
|
@@ -130,24 +132,21 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
for (uint256 i = 0; i < len; ++i) {
|
|
133
|
-
address
|
|
135
|
+
address _cm = creditManagers[i];
|
|
134
136
|
|
|
135
|
-
_updatePrices(
|
|
136
|
-
address[] memory creditAccounts = ICreditManagerV3(
|
|
137
|
+
_updatePrices(_cm, priceUpdates);
|
|
138
|
+
address[] memory creditAccounts = ICreditManagerV3(_cm).creditAccounts();
|
|
137
139
|
uint256 caLen = creditAccounts.length;
|
|
138
140
|
for (uint256 j; j < caLen; ++j) {
|
|
139
141
|
if (
|
|
140
|
-
(
|
|
141
|
-
borrower == address(0)
|
|
142
|
-
|| ICreditManagerV3(_pool).getBorrowerOrRevert(creditAccounts[i]) == borrower
|
|
143
|
-
)
|
|
142
|
+
(borrower == address(0) || _getBorrowerOrRevert(_cm, creditAccounts[j]) == borrower)
|
|
144
143
|
&& (
|
|
145
144
|
!liquidatableOnly
|
|
146
|
-
|| ICreditManagerV3(
|
|
145
|
+
|| ICreditManagerV3(_cm).isLiquidatable(creditAccounts[j], PERCENTAGE_FACTOR)
|
|
147
146
|
)
|
|
148
147
|
) {
|
|
149
148
|
if (op == QUERY) {
|
|
150
|
-
result[index] = _getCreditAccountData(
|
|
149
|
+
result[index] = _getCreditAccountData(_cm, creditAccounts[j]);
|
|
151
150
|
}
|
|
152
151
|
++index;
|
|
153
152
|
}
|
|
@@ -182,12 +181,12 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
182
181
|
returns (CreditAccountData memory result)
|
|
183
182
|
{
|
|
184
183
|
ICreditManagerV3 creditManager = ICreditManagerV3(_pool);
|
|
185
|
-
ICreditFacadeV3 creditFacade =
|
|
184
|
+
ICreditFacadeV3 creditFacade = _getCreditFacade(address(creditManager));
|
|
186
185
|
// ICreditConfiguratorV3 creditConfigurator = ICreditConfiguratorV3(creditManager.creditConfigurator());
|
|
187
186
|
|
|
188
|
-
result.cfVersion = creditFacade
|
|
187
|
+
result.cfVersion = _getVersion(address(creditFacade));
|
|
189
188
|
|
|
190
|
-
address borrower = creditManager
|
|
189
|
+
address borrower = _getBorrowerOrRevert(address(creditManager), _creditAccount);
|
|
191
190
|
|
|
192
191
|
result.borrower = borrower;
|
|
193
192
|
result.creditManager = _pool;
|
|
@@ -196,7 +195,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
196
195
|
result.underlying = creditManager.underlying();
|
|
197
196
|
|
|
198
197
|
address pool = creditManager.pool();
|
|
199
|
-
result.baseBorrowRate =
|
|
198
|
+
result.baseBorrowRate = _getBaseInterestRate(pool);
|
|
200
199
|
|
|
201
200
|
uint256 collateralTokenCount = creditManager.collateralTokensCount();
|
|
202
201
|
|
|
@@ -208,7 +207,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
208
207
|
{
|
|
209
208
|
uint256 forbiddenTokenMask = creditFacade.forbiddenTokenMask();
|
|
210
209
|
uint256 quotedTokensMask = creditManager.quotedTokensMask();
|
|
211
|
-
IPoolQuotaKeeperV3 pqk =
|
|
210
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(pool);
|
|
212
211
|
|
|
213
212
|
unchecked {
|
|
214
213
|
for (uint256 i = 0; i < collateralTokenCount; ++i) {
|
|
@@ -235,7 +234,8 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
236
|
|
|
238
|
-
result.aggregatedBorrowRate =
|
|
237
|
+
result.aggregatedBorrowRate =
|
|
238
|
+
result.baseBorrowRate + (result.debt == 0 ? 0 : RAY * quotaRevenue / PERCENTAGE_FACTOR / result.debt);
|
|
239
239
|
|
|
240
240
|
// uint256 debt;
|
|
241
241
|
// uint256 cumulativeIndexNow;
|
|
@@ -315,7 +315,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
function _isContractV3(address _pool) internal view returns (bool) {
|
|
318
|
-
uint256 cmVersion =
|
|
318
|
+
uint256 cmVersion = _getVersion(_pool);
|
|
319
319
|
return cmVersion >= 3_00 && cmVersion < 3_99;
|
|
320
320
|
}
|
|
321
321
|
|
|
@@ -333,23 +333,23 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
/// @dev Returns CreditManagerData for a particular
|
|
337
|
-
/// @param
|
|
338
|
-
function getCreditManagerData(address
|
|
339
|
-
ICreditManagerV3 creditManager = ICreditManagerV3(
|
|
336
|
+
/// @dev Returns CreditManagerData for a particular _cm
|
|
337
|
+
/// @param _cm CreditManager address
|
|
338
|
+
function getCreditManagerData(address _cm) public view returns (CreditManagerData memory result) {
|
|
339
|
+
ICreditManagerV3 creditManager = ICreditManagerV3(_cm);
|
|
340
340
|
ICreditConfiguratorV3 creditConfigurator = ICreditConfiguratorV3(creditManager.creditConfigurator());
|
|
341
|
-
ICreditFacadeV3 creditFacade =
|
|
341
|
+
ICreditFacadeV3 creditFacade = _getCreditFacade(address(creditManager));
|
|
342
342
|
|
|
343
|
-
result.addr =
|
|
344
|
-
result.cfVersion = creditFacade
|
|
343
|
+
result.addr = _cm;
|
|
344
|
+
result.cfVersion = _getVersion(address(creditFacade));
|
|
345
345
|
|
|
346
346
|
result.underlying = creditManager.underlying();
|
|
347
347
|
|
|
348
348
|
{
|
|
349
349
|
result.pool = creditManager.pool();
|
|
350
350
|
IPoolV3 pool = IPoolV3(result.pool);
|
|
351
|
-
result.baseBorrowRate = pool
|
|
352
|
-
result.availableToBorrow = pool.creditManagerBorrowable(
|
|
351
|
+
result.baseBorrowRate = _getBaseInterestRate(address(pool));
|
|
352
|
+
result.availableToBorrow = pool.creditManagerBorrowable(_cm);
|
|
353
353
|
result.lirm = getLIRMData(pool.interestRateModel());
|
|
354
354
|
}
|
|
355
355
|
|
|
@@ -416,7 +416,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
416
416
|
|
|
417
417
|
result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
418
418
|
result.linearCumulativeIndex = pool.calcLinearCumulative_RAY();
|
|
419
|
-
result.baseInterestRate = pool
|
|
419
|
+
result.baseInterestRate = _getBaseInterestRate(address(pool));
|
|
420
420
|
result.underlying = pool.underlyingToken();
|
|
421
421
|
result.dieselToken = address(pool);
|
|
422
422
|
|
|
@@ -450,7 +450,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
450
450
|
|
|
451
451
|
result.supplyRate = pool.supplyRate();
|
|
452
452
|
|
|
453
|
-
result.version = pool
|
|
453
|
+
result.version = _getVersion(address(pool));
|
|
454
454
|
|
|
455
455
|
result.quotas = _getQuotas(_pool);
|
|
456
456
|
result.lirm = getLIRMData(pool.interestRateModel());
|
|
@@ -467,7 +467,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
result.poolQuotaKeeper =
|
|
470
|
+
result.poolQuotaKeeper = address(_getPoolQuotaKeeper(_pool));
|
|
471
471
|
result.gauge = IPoolQuotaKeeperV3(result.poolQuotaKeeper).gauge();
|
|
472
472
|
|
|
473
473
|
return result;
|
|
@@ -515,8 +515,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
515
515
|
uint256 len = priceUpdates.length;
|
|
516
516
|
unchecked {
|
|
517
517
|
for (uint256 i; i < len; ++i) {
|
|
518
|
-
address priceFeed =
|
|
519
|
-
IPriceOracleV3(ICreditManagerV3(creditManager).priceOracle()).priceFeeds(priceUpdates[i].token);
|
|
518
|
+
address priceFeed = _getPriceOracle(creditManager).priceFeeds(priceUpdates[i].token);
|
|
520
519
|
if (priceFeed == address(0)) revert PriceFeedDoesNotExistException();
|
|
521
520
|
|
|
522
521
|
IUpdatablePriceFeed(priceFeed).updatePrice(priceUpdates[i].callData);
|
|
@@ -524,14 +523,14 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
524
523
|
}
|
|
525
524
|
}
|
|
526
525
|
|
|
527
|
-
function _getPriceFeedFailedList(address
|
|
526
|
+
function _getPriceFeedFailedList(address _cm, TokenBalance[] memory balances)
|
|
528
527
|
internal
|
|
529
528
|
view
|
|
530
529
|
returns (address[] memory priceFeedFailed)
|
|
531
530
|
{
|
|
532
531
|
uint256 len = balances.length;
|
|
533
532
|
|
|
534
|
-
IPriceOracleV3 priceOracle =
|
|
533
|
+
IPriceOracleV3 priceOracle = _getPriceOracle(_cm);
|
|
535
534
|
|
|
536
535
|
uint256 index;
|
|
537
536
|
|
|
@@ -560,8 +559,32 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
560
559
|
}
|
|
561
560
|
}
|
|
562
561
|
|
|
562
|
+
function _getPoolQuotaKeeper(address pool) internal view returns (IPoolQuotaKeeperV3) {
|
|
563
|
+
return IPoolQuotaKeeperV3(IPoolV3(pool).poolQuotaKeeper());
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function _getPriceOracle(address _cm) internal view returns (IPriceOracleV3) {
|
|
567
|
+
return IPriceOracleV3(ICreditManagerV3(_cm).priceOracle());
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function _getBaseInterestRate(address pool) internal view returns (uint256) {
|
|
571
|
+
return IPoolV3(pool).baseInterestRate();
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function _getBorrowerOrRevert(address cm, address creditAccount) internal view returns (address) {
|
|
575
|
+
return ICreditManagerV3(cm).getBorrowerOrRevert(creditAccount);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function _getVersion(address versionedContract) internal view returns (uint256) {
|
|
579
|
+
return IVersion(versionedContract).version();
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function _getCreditFacade(address cm) internal view returns (ICreditFacadeV3) {
|
|
583
|
+
return ICreditFacadeV3(ICreditManagerV3(cm).creditFacade());
|
|
584
|
+
}
|
|
585
|
+
|
|
563
586
|
function _getQuotas(address _pool) internal view returns (QuotaInfo[] memory quotas) {
|
|
564
|
-
IPoolQuotaKeeperV3 pqk =
|
|
587
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(_pool);
|
|
565
588
|
|
|
566
589
|
address[] memory quotaTokens = pqk.quotedTokens();
|
|
567
590
|
uint256 len = quotaTokens.length;
|
|
@@ -589,7 +612,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
589
612
|
unchecked {
|
|
590
613
|
for (uint256 i; i < len; ++i) {
|
|
591
614
|
GaugeInfo memory gaugeInfo = result[i];
|
|
592
|
-
IPoolQuotaKeeperV3 pqk =
|
|
615
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(poolsV3[i]);
|
|
593
616
|
address gauge = pqk.gauge();
|
|
594
617
|
gaugeInfo.addr = gauge;
|
|
595
618
|
|
|
@@ -639,7 +662,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
639
662
|
address[] memory quotaTokens;
|
|
640
663
|
address gauge;
|
|
641
664
|
{
|
|
642
|
-
IPoolQuotaKeeperV3 pqk =
|
|
665
|
+
IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(poolsV3[i]);
|
|
643
666
|
gauge = pqk.gauge();
|
|
644
667
|
|
|
645
668
|
quotaTokens = pqk.quotedTokens();
|
|
@@ -22,6 +22,8 @@ contract LinearInterestModelHelper {
|
|
|
22
22
|
} else {
|
|
23
23
|
(irm.U_1, irm.U_2, irm.R_base, irm.R_slope1, irm.R_slope2, irm.R_slope3) =
|
|
24
24
|
LinearInterestRateModelV3(_model).getModelParameters();
|
|
25
|
+
|
|
26
|
+
irm.isBorrowingMoreU2Forbidden = LinearInterestRateModelV3(_model).isBorrowingMoreU2Forbidden();
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}
|
package/contracts/data/Types.sol
CHANGED
|
@@ -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
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Foundation, 2023.
|
|
4
|
+
pragma solidity ^0.8.17;
|
|
5
|
+
|
|
6
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
7
|
+
|
|
8
|
+
import {DataCompressorV2_10} from "../data/DataCompressor_2_1.sol";
|
|
9
|
+
import {DataCompressorV3_00} from "../data/DataCompressor_3_0.sol";
|
|
10
|
+
import {IDataCompressorV3_00, PriceOnDemand} from "../interfaces/IDataCompressorV3_00.sol";
|
|
11
|
+
import {CreditAccountData, CreditManagerData, PoolData, TokenBalance, ContractAdapter} from "../data/Types.sol";
|
|
12
|
+
|
|
13
|
+
import {NetworkDetector} from "@gearbox-protocol/sdk-gov/contracts/NetworkDetector.sol";
|
|
14
|
+
|
|
15
|
+
import "forge-std/console.sol";
|
|
16
|
+
|
|
17
|
+
address constant ap = 0x0Bf1626d4925F8A872801968be11c052862AC2D3;
|
|
18
|
+
|
|
19
|
+
contract DCTest {
|
|
20
|
+
DataCompressorV2_10 public dc2;
|
|
21
|
+
DataCompressorV3_00 public dc3;
|
|
22
|
+
|
|
23
|
+
uint256 chainId;
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
NetworkDetector nd = new NetworkDetector();
|
|
27
|
+
chainId = nd.chainId();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
modifier liveTestOnly() {
|
|
31
|
+
if (chainId == 1) {
|
|
32
|
+
_;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function setUp() public liveTestOnly {
|
|
37
|
+
dc2 = new DataCompressorV2_10(ap);
|
|
38
|
+
dc3 = new DataCompressorV3_00(ap);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _printPools(PoolData[] memory pools) internal view {
|
|
42
|
+
uint256 len = pools.length;
|
|
43
|
+
unchecked {
|
|
44
|
+
for (uint256 i; i < len; ++i) {
|
|
45
|
+
PoolData memory pool = pools[i];
|
|
46
|
+
console.log("\n\n");
|
|
47
|
+
console.log(IERC20Metadata(pool.underlying).symbol(), pool.addr);
|
|
48
|
+
console.log("-------------------------------");
|
|
49
|
+
|
|
50
|
+
console.log("dieselToken: ", pool.dieselToken);
|
|
51
|
+
///
|
|
52
|
+
console.log("linearCumulativeIndex: ", pool.linearCumulativeIndex);
|
|
53
|
+
console.log("availableLiquidity: ", pool.availableLiquidity);
|
|
54
|
+
console.log("expectedLiquidity: ", pool.expectedLiquidity);
|
|
55
|
+
//
|
|
56
|
+
console.log("totalBorrowed: ", pool.totalBorrowed);
|
|
57
|
+
console.log("totalDebtLimit: ", pool.totalDebtLimit);
|
|
58
|
+
// CreditManagerDebtParams[] creditManagerDebtParams;
|
|
59
|
+
console.log("totalAssets: ", pool.totalAssets);
|
|
60
|
+
console.log("totalSupply: ", pool.totalSupply);
|
|
61
|
+
console.log("supplyRate", pool.supplyRate);
|
|
62
|
+
console.log("baseInterestRate: ", pool.baseInterestRate);
|
|
63
|
+
console.log("dieselRate_RAY: ", pool.dieselRate_RAY);
|
|
64
|
+
console.log("withdrawFee", pool.withdrawFee);
|
|
65
|
+
console.log("cumulativeIndex_RAY:", pool.cumulativeIndex_RAY);
|
|
66
|
+
console.log("baseInterestIndexLU:", pool.baseInterestIndexLU);
|
|
67
|
+
console.log("version: ", pool.version);
|
|
68
|
+
// QuotaInfo[] quotas;
|
|
69
|
+
// LinearModel lirm;
|
|
70
|
+
console.log("isPaused", pool.isPaused);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _printCreditManagers(CreditManagerData[] memory cms) internal view {
|
|
76
|
+
uint256 len = cms.length;
|
|
77
|
+
unchecked {
|
|
78
|
+
for (uint256 i; i < len; ++i) {
|
|
79
|
+
CreditManagerData memory cm = cms[i];
|
|
80
|
+
console.log("\n\n");
|
|
81
|
+
console.log(IERC20Metadata(cm.underlying).symbol(), cm.addr);
|
|
82
|
+
console.log("-------------------------------");
|
|
83
|
+
console.log("cfVersion: ", cm.cfVersion);
|
|
84
|
+
console.log("creditFacace: ", cm.creditFacade); // V2 only: address of creditFacade
|
|
85
|
+
console.log("creditConfigurator: ", cm.creditConfigurator); // V2 only: address of creditConfigurator
|
|
86
|
+
console.log("pool: ", cm.pool);
|
|
87
|
+
console.log("totalDebt: ", cm.totalDebt);
|
|
88
|
+
console.log("totalDebtLimit: ", cm.totalDebtLimit);
|
|
89
|
+
console.log("baseBorrowRate: ", cm.baseBorrowRate);
|
|
90
|
+
console.log("minDebt: ", cm.minDebt);
|
|
91
|
+
console.log("maxDebt: ", cm.maxDebt);
|
|
92
|
+
console.log("availableToBorrow: ", cm.availableToBorrow);
|
|
93
|
+
// address[] collateralTokens);
|
|
94
|
+
// ContractAdapter[] adapters);
|
|
95
|
+
// uint256[] liquidationThresholds);
|
|
96
|
+
console.log("isDegenMode: ", cm.isDegenMode); // V2 only: true if contract is in Degen mode
|
|
97
|
+
console.log("degenNFT: ", cm.degenNFT); // V2 only: degenNFT, address(0) if not in degen mode
|
|
98
|
+
console.log("forbiddenTokenMask: ", cm.forbiddenTokenMask); // V2 only: mask which forbids some particular tokens
|
|
99
|
+
console.log("maxEnabledTokensLength: ", cm.maxEnabledTokensLength); // V2 only: in V1 as many tokens as the CM can support (256)
|
|
100
|
+
console.log("feeInterest: ", cm.feeInterest); // Interest fee protocol charges: fee = interest accrues * feeInterest
|
|
101
|
+
console.log("feeLiquidation: ", cm.feeLiquidation); // Liquidation fee protocol charges: fee = totalValue * feeLiquidation
|
|
102
|
+
console.log("liquidationDiscount: ", cm.liquidationDiscount); // Miltiplier to get amount which liquidator should pay: amount = totalValue * liquidationDiscount
|
|
103
|
+
console.log("feeLiquidationExpired: ", cm.feeLiquidationExpired); // Liquidation fee protocol charges on expired accounts
|
|
104
|
+
console.log("liquidationDiscountExpired: ", cm.liquidationDiscountExpired); // Multiplier for the amount the liquidator has to pay when closing an expired account
|
|
105
|
+
// V3 Fileds
|
|
106
|
+
// QuotaInfo[] quotas);
|
|
107
|
+
// LinearModel lirm);
|
|
108
|
+
console.log("sPaused: ", cm.isPaused);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function test_dc_01_pools() public view liveTestOnly {
|
|
114
|
+
PoolData[] memory pools = dc2.getPoolsV1List();
|
|
115
|
+
console.log("V1 pools");
|
|
116
|
+
_printPools(pools);
|
|
117
|
+
|
|
118
|
+
pools = dc3.getPoolsV3List();
|
|
119
|
+
console.log("\nV3 pools");
|
|
120
|
+
_printPools(pools);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function test_dc_02_credit_managers() public view liveTestOnly {
|
|
124
|
+
CreditManagerData[] memory cms = dc2.getCreditManagersV2List();
|
|
125
|
+
console.log("V2 credit managers");
|
|
126
|
+
_printCreditManagers(cms);
|
|
127
|
+
|
|
128
|
+
cms = dc3.getCreditManagersV3List();
|
|
129
|
+
console.log("\n\nV3 credit managers");
|
|
130
|
+
_printCreditManagers(cms);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function test_dc_03_credit_accounts() public liveTestOnly {
|
|
134
|
+
CreditAccountData[] memory cas = dc2.getCreditAccountsByBorrower(address(this));
|
|
135
|
+
console.log("V2 credit accounts", cas.length);
|
|
136
|
+
|
|
137
|
+
cas = dc3.getCreditAccountsByBorrower(address(this), new PriceOnDemand[](0));
|
|
138
|
+
console.log("V3 credit accounts", cas.length);
|
|
139
|
+
}
|
|
140
|
+
}
|
package/package.json
CHANGED