@gearbox-protocol/periphery-v3 1.0.2 → 1.0.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.
|
@@ -17,6 +17,7 @@ import {ICreditFacadeV2} from "@gearbox-protocol/core-v2/contracts/interfaces/IC
|
|
|
17
17
|
import {ICreditConfiguratorV2} from "@gearbox-protocol/core-v2/contracts/interfaces/ICreditConfiguratorV2.sol";
|
|
18
18
|
import {ICreditAccount} from "@gearbox-protocol/core-v2/contracts/interfaces/ICreditAccount.sol";
|
|
19
19
|
import {IPoolService} from "@gearbox-protocol/core-v2/contracts/interfaces/IPoolService.sol";
|
|
20
|
+
import {PoolService} from "@gearbox-protocol/core-v2/contracts/pool/PoolService.sol";
|
|
20
21
|
|
|
21
22
|
import {IVersion} from "@gearbox-protocol/core-v2/contracts/interfaces/IVersion.sol";
|
|
22
23
|
|
|
@@ -27,11 +28,12 @@ import {CreditAccountData, CreditManagerData, PoolData, TokenBalance, ContractAd
|
|
|
27
28
|
|
|
28
29
|
// EXCEPTIONS
|
|
29
30
|
import {ZeroAddressException} from "@gearbox-protocol/core-v2/contracts/interfaces/IErrors.sol";
|
|
31
|
+
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
30
32
|
|
|
31
33
|
/// @title Data compressor 2.1.
|
|
32
34
|
/// @notice Collects data from various contracts for use in the dApp
|
|
33
35
|
/// Do not use for data from data compressor for state-changing functions
|
|
34
|
-
contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait {
|
|
36
|
+
contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait, LinearInterestModelHelper {
|
|
35
37
|
// Contract version
|
|
36
38
|
uint256 public constant version = 2_10;
|
|
37
39
|
|
|
@@ -174,10 +176,13 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait {
|
|
|
174
176
|
|
|
175
177
|
{
|
|
176
178
|
result.pool = creditManagerV2.pool();
|
|
177
|
-
|
|
179
|
+
PoolService pool = PoolService(result.pool);
|
|
178
180
|
// result.canBorrow =;
|
|
179
181
|
result.baseBorrowRate = pool.borrowAPY_RAY();
|
|
182
|
+
// TODO: add limit calculation
|
|
180
183
|
result.availableToBorrow = pool.creditManagersCanBorrow(_creditManager) ? pool.availableLiquidity() : 0;
|
|
184
|
+
|
|
185
|
+
result.lirm = getLIRMData(address(pool.interestRateModel()));
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
(result.minDebt, result.maxDebt) = creditFacade.limits();
|
|
@@ -239,8 +244,10 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait {
|
|
|
239
244
|
|
|
240
245
|
/// @dev Returns PoolData for a particular pool
|
|
241
246
|
/// @param _pool Pool address
|
|
247
|
+
// TODO: add isPaused()
|
|
248
|
+
// TODO: add interestRateModel address / data
|
|
242
249
|
function getPoolData(address _pool) public view registeredPoolOnly(_pool) returns (PoolData memory result) {
|
|
243
|
-
|
|
250
|
+
PoolService pool = PoolService(_pool);
|
|
244
251
|
|
|
245
252
|
result.addr = _pool;
|
|
246
253
|
result.expectedLiquidity = pool.expectedLiquidity();
|
|
@@ -264,6 +271,9 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait {
|
|
|
264
271
|
/ PERCENTAGE_FACTOR;
|
|
265
272
|
|
|
266
273
|
result.version = uint8(pool.version());
|
|
274
|
+
result.lirm = getLIRMData(address(pool.interestRateModel()));
|
|
275
|
+
|
|
276
|
+
result.isPaused = pool.paused();
|
|
267
277
|
|
|
268
278
|
return result;
|
|
269
279
|
}
|
|
@@ -22,6 +22,7 @@ import {IPriceOracleV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPr
|
|
|
22
22
|
import {ICreditAccountV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditAccountV3.sol";
|
|
23
23
|
import {IPoolQuotaKeeperV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolQuotaKeeperV3.sol";
|
|
24
24
|
import {IPoolV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolV3.sol";
|
|
25
|
+
import {PoolV3} from "@gearbox-protocol/core-v3/contracts/pool/PoolV3.sol";
|
|
25
26
|
|
|
26
27
|
import {CreditManagerV3} from "@gearbox-protocol/core-v3/contracts/credit/CreditManagerV3.sol";
|
|
27
28
|
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
|
|
54
55
|
// EXCEPTIONS
|
|
55
56
|
import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
57
|
+
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
56
58
|
|
|
57
59
|
uint256 constant COUNT = 0;
|
|
58
60
|
uint256 constant QUERY = 1;
|
|
@@ -60,7 +62,7 @@ uint256 constant QUERY = 1;
|
|
|
60
62
|
/// @title Data compressor 3.0.
|
|
61
63
|
/// @notice Collects data from various contracts for use in the dApp
|
|
62
64
|
/// Do not use for data from data compressor for state-changing functions
|
|
63
|
-
contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait {
|
|
65
|
+
contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, LinearInterestModelHelper {
|
|
64
66
|
// Contract version
|
|
65
67
|
uint256 public constant version = 3_00;
|
|
66
68
|
|
|
@@ -334,6 +336,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait {
|
|
|
334
336
|
IPoolV3 pool = IPoolV3(result.pool);
|
|
335
337
|
result.baseBorrowRate = pool.baseInterestRate();
|
|
336
338
|
result.availableToBorrow = pool.creditManagerBorrowable(_pool);
|
|
339
|
+
result.lirm = getLIRMData(pool.interestRateModel());
|
|
337
340
|
}
|
|
338
341
|
|
|
339
342
|
(result.minDebt, result.maxDebt) = creditFacade.debtLimits();
|
|
@@ -391,7 +394,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait {
|
|
|
391
394
|
/// @dev Returns PoolData for a particular pool
|
|
392
395
|
/// @param _pool Pool address
|
|
393
396
|
function getPoolData(address _pool) public view registeredPoolOnly(_pool) returns (PoolData memory result) {
|
|
394
|
-
|
|
397
|
+
PoolV3 pool = PoolV3(_pool);
|
|
395
398
|
|
|
396
399
|
result.addr = _pool;
|
|
397
400
|
result.expectedLiquidity = pool.expectedLiquidity();
|
|
@@ -436,6 +439,8 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait {
|
|
|
436
439
|
result.version = uint8(pool.version());
|
|
437
440
|
|
|
438
441
|
result.quotas = _getQuotas(_pool);
|
|
442
|
+
result.lirm = getLIRMData(pool.interestRateModel());
|
|
443
|
+
result.isPaused = pool.paused();
|
|
439
444
|
|
|
440
445
|
return result;
|
|
441
446
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {LinearInterestRateModelV3} from "@gearbox-protocol/core-v3/contracts/pool/LinearInterestRateModelV3.sol";
|
|
2
|
+
import {LinearModel} from "./Types.sol";
|
|
3
|
+
|
|
4
|
+
contract LinearInterestModelHelper {
|
|
5
|
+
function getLIRMData(address _model) internal view returns (LinearModel memory irm) {
|
|
6
|
+
irm.interestModel = _model;
|
|
7
|
+
|
|
8
|
+
(irm.U_1, irm.U_2, irm.R_base, irm.R_slope1, irm.R_slope2, irm.R_slope3) =
|
|
9
|
+
LinearInterestRateModelV3(_model).getModelParameters();
|
|
10
|
+
}
|
|
11
|
+
}
|
package/contracts/data/Types.sol
CHANGED
|
@@ -62,6 +62,16 @@ struct CreditAccountData {
|
|
|
62
62
|
ScheduledWithdrawal[2] schedultedWithdrawals;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
struct LinearModel {
|
|
66
|
+
address interestModel;
|
|
67
|
+
uint16 U_1;
|
|
68
|
+
uint16 U_2;
|
|
69
|
+
uint16 R_base;
|
|
70
|
+
uint16 R_slope1;
|
|
71
|
+
uint16 R_slope2;
|
|
72
|
+
uint16 R_slope3;
|
|
73
|
+
}
|
|
74
|
+
|
|
65
75
|
struct CreditManagerData {
|
|
66
76
|
address addr;
|
|
67
77
|
uint256 cfVersion;
|
|
@@ -89,8 +99,9 @@ struct CreditManagerData {
|
|
|
89
99
|
uint16 liquidationDiscountExpired; // Multiplier for the amount the liquidator has to pay when closing an expired account
|
|
90
100
|
// V3 Fileds
|
|
91
101
|
QuotaInfo[] quotas;
|
|
92
|
-
|
|
102
|
+
LinearModel lirm;
|
|
93
103
|
}
|
|
104
|
+
// LIR
|
|
94
105
|
|
|
95
106
|
struct CreditManagerDebtParams {
|
|
96
107
|
address creditManager;
|
|
@@ -121,6 +132,8 @@ struct PoolData {
|
|
|
121
132
|
uint256 baseInterestIndexLU;
|
|
122
133
|
uint256 version;
|
|
123
134
|
QuotaInfo[] quotas;
|
|
135
|
+
LinearModel lirm;
|
|
136
|
+
bool isPaused;
|
|
124
137
|
}
|
|
125
138
|
|
|
126
139
|
struct GaugeQuotaParams {
|
package/package.json
CHANGED