@gearbox-protocol/periphery-v3 1.1.0 → 1.2.0
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.
|
@@ -116,6 +116,7 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait, Li
|
|
|
116
116
|
|
|
117
117
|
address pool = creditManagerV2.pool();
|
|
118
118
|
result.baseBorrowRate = IPoolService(pool).borrowAPY_RAY();
|
|
119
|
+
result.aggregatedBorrowRate = result.baseBorrowRate;
|
|
119
120
|
|
|
120
121
|
uint256 collateralTokenCount = creditManagerV2.collateralTokensCount();
|
|
121
122
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
pragma solidity ^0.8.10;
|
|
5
5
|
pragma experimental ABIEncoderV2;
|
|
6
6
|
|
|
7
|
+
import "@gearbox-protocol/core-v3/contracts/interfaces/IAddressProviderV3.sol";
|
|
7
8
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
8
9
|
import {PERCENTAGE_FACTOR, RAY} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol";
|
|
9
10
|
|
|
@@ -38,6 +39,7 @@ import {IVersion} from "@gearbox-protocol/core-v2/contracts/interfaces/IVersion.
|
|
|
38
39
|
|
|
39
40
|
import {AddressProvider} from "@gearbox-protocol/core-v2/contracts/core/AddressProvider.sol";
|
|
40
41
|
import {IDataCompressorV3_00, PriceOnDemand} from "../interfaces/IDataCompressorV3_00.sol";
|
|
42
|
+
import {IZapper} from "@gearbox-protocol/integrations-v3/contracts/interfaces/zappers/IZapper.sol";
|
|
41
43
|
|
|
42
44
|
import {
|
|
43
45
|
COUNT,
|
|
@@ -51,12 +53,14 @@ import {
|
|
|
51
53
|
GaugeInfo,
|
|
52
54
|
GaugeQuotaParams,
|
|
53
55
|
CreditManagerDebtParams,
|
|
54
|
-
GaugeVote
|
|
56
|
+
GaugeVote,
|
|
57
|
+
ZapperInfo
|
|
55
58
|
} from "./Types.sol";
|
|
56
59
|
|
|
57
60
|
// EXCEPTIONS
|
|
58
61
|
import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
59
62
|
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
63
|
+
import {ZapperRegister} from "./ZapperRegister.sol";
|
|
60
64
|
|
|
61
65
|
/// @title Data compressor 3.0.
|
|
62
66
|
/// @notice Collects data from various contracts for use in the dApp
|
|
@@ -65,9 +69,14 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
65
69
|
// Contract version
|
|
66
70
|
uint256 public constant version = 3_00;
|
|
67
71
|
|
|
72
|
+
ZapperRegister public zapperRegister;
|
|
73
|
+
|
|
68
74
|
error CreditManagerIsNotV3Exception();
|
|
69
75
|
|
|
70
|
-
constructor(address _addressProvider) ContractsRegisterTrait(_addressProvider) {
|
|
76
|
+
constructor(address _addressProvider) ContractsRegisterTrait(_addressProvider) {
|
|
77
|
+
zapperRegister =
|
|
78
|
+
ZapperRegister(IAddressProviderV3(_addressProvider).getAddressOrRevert("ZAPPER_REGISTER", 3_00));
|
|
79
|
+
}
|
|
71
80
|
|
|
72
81
|
/// @dev Returns CreditAccountData for all opened accounts for particular borrower
|
|
73
82
|
/// @param borrower Borrower address
|
|
@@ -194,6 +203,8 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
194
203
|
result.enabledTokensMask = creditManager.enabledTokensMaskOf(_creditAccount);
|
|
195
204
|
|
|
196
205
|
result.balances = new TokenBalance[](collateralTokenCount);
|
|
206
|
+
|
|
207
|
+
uint256 quotaRevenue = 0;
|
|
197
208
|
{
|
|
198
209
|
uint256 forbiddenTokenMask = creditFacade.forbiddenTokenMask();
|
|
199
210
|
uint256 quotedTokensMask = creditManager.quotedTokensMask();
|
|
@@ -215,6 +226,8 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
215
226
|
if (balance.isQuoted) {
|
|
216
227
|
(balance.quota,) = pqk.getQuota(_creditAccount, balance.token);
|
|
217
228
|
balance.quotaRate = pqk.getQuotaRate(balance.token);
|
|
229
|
+
|
|
230
|
+
quotaRevenue += balance.quota * balance.quotaRate;
|
|
218
231
|
}
|
|
219
232
|
|
|
220
233
|
result.balances[i] = balance;
|
|
@@ -222,6 +235,8 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
222
235
|
}
|
|
223
236
|
}
|
|
224
237
|
|
|
238
|
+
result.aggregatedBorrowRate = result.baseBorrowRate + RAY * quotaRevenue / PERCENTAGE_FACTOR / result.debt;
|
|
239
|
+
|
|
225
240
|
// uint256 debt;
|
|
226
241
|
// uint256 cumulativeIndexNow;
|
|
227
242
|
// uint256 cumulativeIndexLastUpdate;
|
|
@@ -441,6 +456,20 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
441
456
|
result.lirm = getLIRMData(pool.interestRateModel());
|
|
442
457
|
result.isPaused = pool.paused();
|
|
443
458
|
|
|
459
|
+
address[] memory zappers = zapperRegister.zappers(address(pool));
|
|
460
|
+
len = zappers.length;
|
|
461
|
+
result.zappers = new ZapperInfo[](len);
|
|
462
|
+
|
|
463
|
+
unchecked {
|
|
464
|
+
for (uint256 i; i < len; ++i) {
|
|
465
|
+
address tokenFrom = IZapper(zappers[i]).unwrappedToken();
|
|
466
|
+
result.zappers[i] = ZapperInfo({tokenFrom: tokenFrom, zapper: zappers[i]});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
result.poolQuotaKeeper = pool.poolQuotaKeeper();
|
|
471
|
+
result.gauge = IPoolQuotaKeeperV3(result.poolQuotaKeeper).gauge();
|
|
472
|
+
|
|
444
473
|
return result;
|
|
445
474
|
}
|
|
446
475
|
|
package/contracts/data/Types.sol
CHANGED
|
@@ -32,6 +32,11 @@ struct ContractAdapter {
|
|
|
32
32
|
address adapter;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
struct ZapperInfo {
|
|
36
|
+
address tokenFrom;
|
|
37
|
+
address zapper;
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
struct CreditAccountData {
|
|
36
41
|
// if not successful, priceFeedsNeeded are filled with the data
|
|
37
42
|
bool isSuccessful;
|
|
@@ -137,7 +142,10 @@ struct PoolData {
|
|
|
137
142
|
uint256 cumulativeIndex_RAY;
|
|
138
143
|
uint256 baseInterestIndexLU;
|
|
139
144
|
uint256 version;
|
|
145
|
+
address poolQuotaKeeper;
|
|
146
|
+
address gauge;
|
|
140
147
|
QuotaInfo[] quotas;
|
|
148
|
+
ZapperInfo[] zappers;
|
|
141
149
|
LinearModel lirm;
|
|
142
150
|
bool isPaused;
|
|
143
151
|
}
|
package/package.json
CHANGED